@adyen/adyen-web 6.43.0 → 6.45.0
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/README.md +1 -1
- package/dist/cjs/adyen.css +8 -8
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +99 -37
- package/dist/es/adyen.css +8 -8
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/BacsDD/BacsDD.js +1 -1
- package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVC.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFields.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFields.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +1 -1
- package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCard.js +1 -1
- package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es/components/Donation/DonationCampaignService.js +1 -1
- package/dist/es/components/Donation/DonationCampaignService.js.map +1 -1
- package/dist/es/components/Dropin/Dropin.js +1 -1
- package/dist/es/components/Dropin/Dropin.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodDetails.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodDetails.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePay.js +1 -1
- package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePayService.js +1 -1
- package/dist/es/components/GooglePay/GooglePayService.js.map +1 -1
- package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
- package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es/components/PayByBankUS/PayByBankUS.js +1 -1
- package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
- package/dist/es/components/PayTo/PayTo.js +1 -1
- package/dist/es/components/PayTo/PayTo.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es/components/Twint/Twint.js +1 -1
- package/dist/es/components/Twint/Twint.js.map +1 -1
- package/dist/es/components/internal/Address/Address.js +1 -1
- package/dist/es/components/internal/Address/Address.js.map +1 -1
- package/dist/es/components/internal/Address/validate.formats.js +1 -1
- package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es/components/internal/Address/validate.js +1 -1
- package/dist/es/components/internal/Address/validate.js.map +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/Button/CopyButton.js +1 -1
- package/dist/es/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es/components/internal/Button/CopyIconButton.js +1 -1
- package/dist/es/components/internal/Button/CopyIconButton.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es/components/internal/LoadingWrapper/LoadingWrapper.js +1 -1
- package/dist/es/components/internal/LoadingWrapper/LoadingWrapper.js.map +1 -1
- package/dist/es/components/internal/Modal/Modal.js +1 -1
- package/dist/es/components/internal/Modal/Modal.js.map +1 -1
- package/dist/es/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es/components/internal/PayButton/utils.js +1 -1
- package/dist/es/components/internal/PayButton/utils.js.map +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es/components/internal/QRLoader/components/QRFinalState.js +1 -1
- package/dist/es/components/internal/QRLoader/components/QRFinalState.js.map +1 -1
- package/dist/es/components/internal/QRLoader/components/QRLoaderPendingState.js +2 -0
- package/dist/es/components/internal/QRLoader/components/QRLoaderPendingState.js.map +1 -0
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es/core/Analytics/constants.js +1 -1
- package/dist/es/core/Analytics/constants.js.map +1 -1
- package/dist/es/core/Analytics/events/AnalyticsLogEvent.js +1 -1
- package/dist/es/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
- package/dist/es/core/Errors/SRMessages.js +1 -1
- package/dist/es/core/Errors/SRMessages.js.map +1 -1
- package/dist/es/core/Errors/SRPanel.js.map +1 -1
- package/dist/es/core/Errors/SRPanelProvider.js.map +1 -1
- package/dist/es/core/Errors/constants.js +1 -1
- package/dist/es/core/Errors/constants.js.map +1 -1
- package/dist/es/core/Errors/useA11yReporter.js +1 -1
- package/dist/es/core/Errors/useA11yReporter.js.map +1 -1
- package/dist/es/core/Errors/useLoadingA11yReporter.js +2 -0
- package/dist/es/core/Errors/useLoadingA11yReporter.js.map +1 -0
- package/dist/es/core/Errors/utils.js +1 -1
- package/dist/es/core/Errors/utils.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/core/config.js.map +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.js.map +1 -1
- package/dist/es/core/utils.js +1 -1
- package/dist/es/core/utils.js.map +1 -1
- package/dist/es/external/preact/compat/dist/compat.js +1 -1
- package/dist/es/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es/external/preact/dist/preact.js +1 -1
- package/dist/es/external/preact/dist/preact.js.map +1 -1
- package/dist/es/external/preact/hooks/dist/hooks.js +1 -1
- package/dist/es/external/preact/hooks/dist/hooks.js.map +1 -1
- package/dist/es/index.d.ts +99 -37
- package/dist/es/packages/server/translations/en-US.json.js +1 -1
- package/dist/es/utils/useForm/useForm.js +1 -1
- package/dist/es/utils/useForm/useForm.js.map +1 -1
- package/dist/es/utils/validator-utils.js +1 -1
- package/dist/es/utils/validator-utils.js.map +1 -1
- package/dist/es-legacy/adyen.css +8 -8
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/BacsDD/BacsDD.js +1 -1
- package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es-legacy/components/Donation/DonationCampaignService.js +1 -1
- package/dist/es-legacy/components/Donation/DonationCampaignService.js.map +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodDetails.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodDetails.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePayService.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePayService.js.map +1 -1
- package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
- package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +1 -1
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/Twint/Twint.js +1 -1
- package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyIconButton.js +1 -1
- package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es-legacy/components/internal/LoadingWrapper/LoadingWrapper.js +1 -1
- package/dist/es-legacy/components/internal/LoadingWrapper/LoadingWrapper.js.map +1 -1
- package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
- package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/utils.js +1 -1
- package/dist/es-legacy/components/internal/PayButton/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRFinalState.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRFinalState.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRLoaderPendingState.js +2 -0
- package/dist/es-legacy/components/internal/QRLoader/components/QRLoaderPendingState.js.map +1 -0
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/core/Analytics/constants.js +1 -1
- package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRMessages.js +1 -1
- package/dist/es-legacy/core/Errors/SRMessages.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRPanelProvider.js.map +1 -1
- package/dist/es-legacy/core/Errors/constants.js +1 -1
- package/dist/es-legacy/core/Errors/constants.js.map +1 -1
- package/dist/es-legacy/core/Errors/useA11yReporter.js +1 -1
- package/dist/es-legacy/core/Errors/useA11yReporter.js.map +1 -1
- package/dist/es-legacy/core/Errors/useLoadingA11yReporter.js +2 -0
- package/dist/es-legacy/core/Errors/useLoadingA11yReporter.js.map +1 -0
- package/dist/es-legacy/core/Errors/utils.js +1 -1
- package/dist/es-legacy/core/Errors/utils.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/core/config.js.map +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.js.map +1 -1
- package/dist/es-legacy/core/utils.js +1 -1
- package/dist/es-legacy/core/utils.js.map +1 -1
- package/dist/es-legacy/external/preact/compat/dist/compat.js +1 -1
- package/dist/es-legacy/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
- package/dist/es-legacy/external/preact/hooks/dist/hooks.js +1 -1
- package/dist/es-legacy/external/preact/hooks/dist/hooks.js.map +1 -1
- package/dist/es-legacy/packages/server/translations/en-US.json.js +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
- package/dist/es-legacy/utils/validator-utils.js +1 -1
- package/dist/es-legacy/utils/validator-utils.js.map +1 -1
- package/package.json +27 -27
- package/styles/adyen.css +8 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../external/preact/dist/preact.js";import{useRef as
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../external/preact/dist/preact.js";import{useRef as n,useState as r}from"../../external/preact/hooks/dist/hooks.js";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c({setComponentRef:c}){const l=n({});Object.keys(l.current).length||null==c||c(l.current);const[u,s]=r(null),a=n(null),i=n(0),[f,p]=r(0);return l.current.setMessages=e=>{const t=a.current;!!(null==e?void 0:e.length)&&(null==t?void 0:t.length)===e.length&&t.every((t,n)=>t===e[n])&&(i.current+=1,p(i.current)),s(e)},a.current=u,u?e(t,null,u.map(t=>e("div",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){o(e,t,n[t])})}return e}({key:`${f}-${t}`,className:"adyen-checkout-sr-panel__msg"},!1),t))):null}export{c as SRMessages};
|
|
2
2
|
//# sourceMappingURL=SRMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SRMessages.js","sources":["../../../../src/core/Errors/SRMessages.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useRef, useState } from 'preact/hooks';\nimport { SRMessagesProps } from './types';\n\n// An interface for the members exposed by SRMessages to its parent\nexport interface SRMessagesRef {\n setMessages?: (
|
|
1
|
+
{"version":3,"file":"SRMessages.js","sources":["../../../../src/core/Errors/SRMessages.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useRef, useState } from 'preact/hooks';\nimport { SRMessagesProps } from './types';\n\n// An interface for the members exposed by SRMessages to its parent\nexport interface SRMessagesRef {\n setMessages?: (messages: string[] | null) => void;\n}\n\nexport function SRMessages({ setComponentRef }: Readonly<SRMessagesProps>) {\n const messagesRef = useRef<SRMessagesRef>({});\n // Just call once to create the object by which we expose the members expected by the parent comp\n if (!Object.keys(messagesRef.current).length) {\n setComponentRef?.(messagesRef.current);\n }\n\n const [messages, setMessages] = useState<string[] | null>(null);\n\n // Pairs with \"never clear\": if the panel is never emptied, re-writing the message that is\n // already displayed would diff to nothing and the AT would stay silent. Bumping the key\n // remounts the nodes so the change is observable.\n //\n // Only bump when the incoming messages are identical to what is rendered, so a partial\n // change (one validation error replaced by another) still diffs granularly and announces\n // just the new entry instead of re-reading the whole list.\n const renderedRef = useRef<string[] | null>(null);\n const versionRef = useRef(0);\n const [version, setVersion] = useState(0);\n\n // Expose method expected by parent\n messagesRef.current.setMessages = (msgs: string[] | null) => {\n const rendered = renderedRef.current;\n const isDuplicate = !!msgs?.length && rendered?.length === msgs.length && rendered.every((m, i) => m === msgs[i]);\n\n if (isDuplicate) {\n versionRef.current += 1;\n setVersion(versionRef.current);\n }\n\n setMessages(msgs);\n };\n\n // Track what is committed to the DOM rather than the latest pending state: a clear followed\n // by a re-set in the same tick batches into one render, which would hide the duplicate.\n renderedRef.current = messages;\n\n return messages ? (\n <Fragment>\n {messages.map(msg => {\n return (\n <div\n key={`${version}-${msg}`}\n className=\"adyen-checkout-sr-panel__msg\"\n {...(process.env.NODE_ENV !== 'production' && { 'data-testid': msg })}\n >\n {msg}\n </div>\n );\n })}\n </Fragment>\n ) : null;\n}\n"],"names":["SRMessages","setComponentRef","messagesRef","useRef","Object","keys","current","length","messages","setMessages","useState","renderedRef","versionRef","version","setVersion","msgs","rendered","every","m","i","h","Fragment","map","msg","div","key","className"],"mappings":"4RASO,SAASA,GAAWC,gBAAEA,IACzB,MAAMC,EAAcC,EAAsB,IAErCC,OAAOC,KAAKH,EAAYI,SAASC,QAClCN,SAAAA,EAAkBC,EAAYI,SAGlC,MAAOE,EAAUC,GAAeC,EAA0B,MASpDC,EAAcR,EAAwB,MACtCS,EAAaT,EAAO,IACnBU,EAASC,GAAcJ,EAAS,GAmBvC,OAhBAR,EAAYI,QAAQG,YAAeM,IAC/B,MAAMC,EAAWL,EAAYL,WACPS,aAAAA,EAAAA,EAAMR,UAAUS,aAAAA,EAAAA,EAAUT,UAAWQ,EAAKR,QAAUS,EAASC,MAAM,CAACC,EAAGC,IAAMD,IAAMH,EAAKI,MAG1GP,EAAWN,SAAW,EACtBQ,EAAWF,EAAWN,UAG1BG,EAAYM,IAKhBJ,EAAYL,QAAUE,EAEfA,EACHY,EAACC,EAAAA,KACIb,EAASc,IAAIC,GAENH,EAACI,wUAAAA,CAAAA,CACGC,IAAK,GAAGZ,KAAWU,IACnBG,UAAU,iCACL,GAEJH,KAKjB,IACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SRPanel.js","sources":["../../../../src/core/Errors/SRPanel.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { AriaAttributes, SRPanelProps } from './types';\nimport BaseElement from '../../components/internal/BaseElement/BaseElement';\nimport { SRMessages, SRMessagesRef } from './SRMessages';\nimport type { ICore } from '../types';\nimport './SRPanel.scss';\n\n/**\n * A panel meant to hold messages that will be read out by ScreenReaders on an aria-live=\"polite\" basis\n * Expects a string or string array of message to add to the panel to be read out\n * For testing purposes can be made visible\n */\nexport class SRPanel extends BaseElement<SRPanelProps> {\n public static readonly type = 'srPanel';\n\n public static readonly defaultProps: Partial<SRPanelProps> = {\n enabled: true,\n node: 'body',\n showPanel: false,\n id: 'ariaLiveSRPanel',\n ariaAttributes: {\n 'aria-relevant': 'all',\n 'aria-live': 'polite',\n 'aria-atomic': 'true'\n }\n };\n\n private readonly srPanelContainer = null;\n\n private readonly id;\n private readonly showPanel;\n private readonly _enabled: boolean;\n private readonly _moveFocus: boolean;\n\n private componentRef: SRMessagesRef;\n\n constructor(checkout: ICore, props?: SRPanelProps) {\n super(checkout, props);\n\n this.id = this.props.id;\n this.showPanel = process.env.NODE_ENV !== 'production' ? this.props.showPanel : false;\n this._enabled = false;\n this._moveFocus = this.props.moveFocus ?? true;\n\n if (this.props.enabled) {\n this._enabled = true;\n\n const panelParent = document.querySelector(this.props.node);\n\n if (panelParent) {\n const preExistingSRPanel = document.getElementById(this.id);\n if (preExistingSRPanel) {\n panelParent.removeChild(preExistingSRPanel);\n }\n\n this.srPanelContainer = document.createElement('div');\n this.srPanelContainer.className = 'sr-panel-holder';\n this.srPanelContainer.id = this.id;\n\n panelParent.appendChild(this.srPanelContainer);\n\n this.mount(this.srPanelContainer);\n } else {\n throw new Error('Component could not mount. Root node was not found.');\n }\n }\n }\n\n public setComponentRef = ref => {\n this.componentRef = ref;\n };\n\n public get enabled() {\n return this._enabled;\n }\n\n public get moveFocus() {\n return this._moveFocus;\n }\n\n public setAriaProps(ariaAttributes: AriaAttributes): void {\n if (!this.props.enabled) return;\n\n const firstPanel = document.querySelector('[class^=\"adyen-checkout-sr-panel\"]');\n\n if (!firstPanel) {\n console.error('SRPanel: Failed to set aria props because no panel was found');\n return;\n }\n\n for (const [key, value] of Object.entries(ariaAttributes)) {\n firstPanel.setAttribute(key, value);\n }\n this.props = { ...this.props, ariaAttributes: { ...this.props.ariaAttributes, ...ariaAttributes } };\n }\n\n // A method we can expose to allow comps to set messages in this panel\n public setMessages = (messages: string[] | string): void => {\n if (!this.props.enabled) return;\n\n let panelMessages = null;\n if (messages) {\n // Ensure panelMessages is an array\n panelMessages = Array.isArray(messages) ? messages : [messages];\n }\n\n this.componentRef.setMessages(panelMessages);\n };\n\n render() {\n if (!this.props.enabled) return null;\n return (\n <div\n className={this.showPanel ? 'adyen-checkout-sr-panel' : 'adyen-checkout-sr-panel--sr-only'}\n role={'log'}\n {...this.props.ariaAttributes}\n {...(process.env.NODE_ENV !== 'production' && { 'data-testid': this.id })}\n >\n <SRMessages setComponentRef={this.setComponentRef} />\n </div>\n );\n }\n}\n"],"names":["SRPanel","BaseElement","enabled","this","_enabled","moveFocus","_moveFocus","setAriaProps","ariaAttributes","props","firstPanel","document","querySelector","key","value","Object","entries","setAttribute","_object_spread_props","_object_spread","console","error","render","h","div","className","showPanel","role","SRMessages","setComponentRef","constructor","checkout","_this_props_moveFocus","super","_define_property","srPanelContainer","id","componentRef","ref","setMessages","messages","panelMessages","Array","isArray","panelParent","node","Error","preExistingSRPanel","getElementById","removeChild","createElement","appendChild","mount","type","defaultProps"],"mappings":"+9BAYO,MAAMA,UAAgBC,EA4DzB,WAAWC,GACP,OAAOC,KAAKC,QAChB,CAEA,aAAWC,GACP,OAAOF,KAAKG,UAChB,CAEOC,YAAAA,CAAaC,GAChB,IAAKL,KAAKM,MAAMP,QAAS,OAEzB,MAAMQ,EAAaC,SAASC,cAAc,sCAE1C,GAAKF,EAAL,CAKA,IAAK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AqBpC,SAASqC,eAAe7C,KAAKiC,IACpDW,GACAH,EAAYK,YAAYF,GAG5B5C,KAAKgC,iBAAmBxB,SAASuC,cAAc,OAC/C/C,KAAKgC,iBAAiBV,UAAY,kBAClCtB,KAAKgC,iBAAiBC,GAAKjC,KAAKiC,GAEhCQ,EAAYO,YAAYhD,KAAKgC,kBAE7BhC,KAAKiD,MAAMjD,KAAKgC,iBACpB,CAGJ,CACJ,EArDAD,EADSlC,EACcqD,OAAO,WAE9BnB,EAHSlC,EAGcsD,eAAsC,CACzDpD,SAAS,EACT2C,KAAM,OACNnB,WAAW,EACXU,GAAI,kBACJ5B,eAAgB,CACZ,gBAAiB,MACjB,YAAa,SACb,cAAe"}
|
|
1
|
+
{"version":3,"file":"SRPanel.js","sources":["../../../../src/core/Errors/SRPanel.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { AriaAttributes, SRPanelProps } from './types';\nimport BaseElement from '../../components/internal/BaseElement/BaseElement';\nimport { SRMessages, SRMessagesRef } from './SRMessages';\nimport type { ICore } from '../types';\nimport './SRPanel.scss';\n\n/**\n * A panel meant to hold messages that will be read out by ScreenReaders on an aria-live=\"polite\" basis\n * Expects a string or string array of message to add to the panel to be read out\n * For testing purposes can be made visible\n */\nexport class SRPanel extends BaseElement<SRPanelProps> {\n public static readonly type = 'srPanel';\n\n public static readonly defaultProps: Partial<SRPanelProps> = {\n enabled: true,\n node: 'body',\n showPanel: false,\n id: 'ariaLiveSRPanel',\n ariaAttributes: {\n 'aria-relevant': 'all',\n 'aria-live': 'polite',\n 'aria-atomic': 'true'\n }\n };\n\n private readonly srPanelContainer = null;\n\n private readonly id;\n private readonly showPanel;\n private readonly _enabled: boolean;\n private readonly _moveFocus: boolean;\n\n private componentRef: SRMessagesRef;\n\n constructor(checkout: ICore, props?: SRPanelProps) {\n super(checkout, props);\n\n this.id = this.props.id;\n this.showPanel = process.env.NODE_ENV !== 'production' ? this.props.showPanel : false;\n this._enabled = false;\n this._moveFocus = this.props.moveFocus ?? true;\n\n if (this.props.enabled) {\n this._enabled = true;\n\n const panelParent = document.querySelector(this.props.node);\n\n if (panelParent) {\n const preExistingSRPanel = document.getElementById(this.id);\n if (preExistingSRPanel) {\n panelParent.removeChild(preExistingSRPanel);\n }\n\n this.srPanelContainer = document.createElement('div');\n this.srPanelContainer.className = 'sr-panel-holder';\n this.srPanelContainer.id = this.id;\n\n panelParent.appendChild(this.srPanelContainer);\n\n this.mount(this.srPanelContainer);\n } else {\n throw new Error('Component could not mount. Root node was not found.');\n }\n }\n }\n\n public setComponentRef = ref => {\n this.componentRef = ref;\n };\n\n public get enabled() {\n return this._enabled;\n }\n\n public get moveFocus() {\n return this._moveFocus;\n }\n\n public setAriaProps(ariaAttributes: AriaAttributes): void {\n if (!this.props.enabled) return;\n\n const firstPanel = document.querySelector('[class^=\"adyen-checkout-sr-panel\"]');\n\n if (!firstPanel) {\n console.error('SRPanel: Failed to set aria props because no panel was found');\n return;\n }\n\n for (const [key, value] of Object.entries(ariaAttributes)) {\n firstPanel.setAttribute(key, value);\n }\n this.props = { ...this.props, ariaAttributes: { ...this.props.ariaAttributes, ...ariaAttributes } };\n }\n\n // A method we can expose to allow comps to set messages in this panel\n public setMessages = (messages: string[] | string | null): void => {\n if (!this.props.enabled) return;\n\n let panelMessages = null;\n if (messages) {\n // Ensure panelMessages is an array\n panelMessages = Array.isArray(messages) ? messages : [messages];\n }\n\n this.componentRef.setMessages(panelMessages);\n };\n\n render() {\n if (!this.props.enabled) return null;\n return (\n <div\n className={this.showPanel ? 'adyen-checkout-sr-panel' : 'adyen-checkout-sr-panel--sr-only'}\n role={'log'}\n {...this.props.ariaAttributes}\n {...(process.env.NODE_ENV !== 'production' && { 'data-testid': this.id })}\n >\n <SRMessages setComponentRef={this.setComponentRef} />\n </div>\n );\n }\n}\n"],"names":["SRPanel","BaseElement","enabled","this","_enabled","moveFocus","_moveFocus","setAriaProps","ariaAttributes","props","firstPanel","document","querySelector","key","value","Object","entries","setAttribute","_object_spread_props","_object_spread","console","error","render","h","div","className","showPanel","role","SRMessages","setComponentRef","constructor","checkout","_this_props_moveFocus","super","_define_property","srPanelContainer","id","componentRef","ref","setMessages","messages","panelMessages","Array","isArray","panelParent","node","Error","preExistingSRPanel","getElementById","removeChild","createElement","appendChild","mount","type","defaultProps"],"mappings":"+9BAYO,MAAMA,UAAgBC,EA4DzB,WAAWC,GACP,OAAOC,KAAKC,QAChB,CAEA,aAAWC,GACP,OAAOF,KAAKG,UAChB,CAEOC,YAAAA,CAAaC,GAChB,IAAKL,KAAKM,MAAMP,QAAS,OAEzB,MAAMQ,EAAaC,SAASC,cAAc,sCAE1C,GAAKF,EAAL,CAKA,IAAK,MAAOG,EAAKC,KAAUC,OAAOC,QAAQR,GACtCE,EAAWO,aAAaJ,EAAKC,GAEjCX,KAAKM,MAAQS,EAAAC,EAAA,CAAA,EAAKhB,KAAKM,OAAK,CAAED,eAAgBW,KAAKhB,KAAKM,MAAMD,eAAmBA,IALjF,MAFIY,QAAQC,MAAM,+DAQtB,CAeAC,MAAAA,GACI,OAAKnB,KAAKM,MAAMP,QAEZqB,EAACC,MAAAA,EAAAA,CACGC,UAAWtB,KAAKuB,UAAY,0BAA4B,mCACxDC,KAAM,OACFxB,KAAKM,MAAMD,gBACV,GAELe,EAACK,EAAAA,CAAWC,gBAAiB1B,KAAK0B,mBARV,IAWpC,CArFA,WAAAC,CAAYC,EAAiBtB,GAMP,IAAAuB,EAElB,GAPAC,MAAMF,EAAUtB,GAVpByB,EAAA/B,KAAiBgC,mBAAmB,MAEpCD,EAAA/B,KAAiBiC,aACjBF,EAAA/B,KAAiBuB,oBACjBQ,EAAA/B,KAAiBC,mBACjB8B,EAAA/B,KAAiBG,qBAEjB4B,EAAA/B,KAAQkC,uBAkCRH,EAAA/B,KAAO0B,kBAAkBS,IACrBnC,KAAKkC,aAAeC,IA4BxBJ,EAAA/B,KAAOoC,cAAeC,IAClB,IAAKrC,KAAKM,MAAMP,QAAS,OAEzB,IAAIuC,EAAgB,KAChBD,IAEAC,EAAgBC,MAAMC,QAAQH,GAAYA,EAAW,CAACA,IAG1DrC,KAAKkC,aAAaE,YAAYE,KAnE9BtC,KAAKiC,GAAKjC,KAAKM,MAAM2B,GACrBjC,KAAKuB,WAA2E,EAChFvB,KAAKC,UAAW,EAChBD,KAAKG,WAAiC,QAApB0B,EAAA7B,KAAKM,MAAMJ,iBAAX,IAAA2B,GAAAA,EAEd7B,KAAKM,MAAMP,QAAS,CACpBC,KAAKC,UAAW,EAEhB,MAAMwC,EAAcjC,SAASC,cAAcT,KAAKM,MAAMoC,MAEtD,IAAID,EAcA,MAAM,IAAIE,MAAM,uDAdH,CACb,MAAMC,EAAqBpC,SAASqC,eAAe7C,KAAKiC,IACpDW,GACAH,EAAYK,YAAYF,GAG5B5C,KAAKgC,iBAAmBxB,SAASuC,cAAc,OAC/C/C,KAAKgC,iBAAiBV,UAAY,kBAClCtB,KAAKgC,iBAAiBC,GAAKjC,KAAKiC,GAEhCQ,EAAYO,YAAYhD,KAAKgC,kBAE7BhC,KAAKiD,MAAMjD,KAAKgC,iBACpB,CAGJ,CACJ,EArDAD,EADSlC,EACcqD,OAAO,WAE9BnB,EAHSlC,EAGcsD,eAAsC,CACzDpD,SAAS,EACT2C,KAAM,OACNnB,WAAW,EACXU,GAAI,kBACJ5B,eAAgB,CACZ,gBAAiB,MACjB,YAAa,SACb,cAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SRPanelProvider.js","sources":["../../../../src/core/Errors/SRPanelProvider.tsx"],"sourcesContent":["import { h, ComponentChildren } from 'preact';\nimport { SRPanelContext } from './SRPanelContext';\nimport { useCoreContext } from '../Context/CoreProvider';\nimport { partial } from '../../components/internal/SecuredFields/lib/utilities/commonUtils';\nimport { setSRMessagesFromErrors } from './utils';\nimport { SRPanel } from './SRPanel';\nimport { SetSRMessagesReturnObject } from './types';\nimport { StringObject } from '../../components/internal/Address/types';\n\ntype SRPanelProviderProps = {\n srPanel: SRPanel;\n children: ComponentChildren;\n};\n\ninterface SetSRMessagesReturnFnProps {\n errors: {\n [key: string]: any;\n };\n isValidating: boolean;\n layout?: string[];\n countrySpecificLabels?: StringObject;\n}\n\nexport type SetSRMessagesReturnFn = (props: SetSRMessagesReturnFnProps) => SetSRMessagesReturnObject;\n\nconst SRPanelProvider = ({ srPanel, children }: Readonly<SRPanelProviderProps>) => {\n const { i18n } = useCoreContext();\n\n // Helper fns\n const setSRMessagesFromObjects = ({ fieldTypeMappingFn }): SetSRMessagesReturnFn => {\n return partial(setSRMessagesFromErrors, {\n SRPanelRef: srPanel,\n i18n,\n fieldTypeMappingFn\n });\n };\n\n const setSRMessagesFromStrings = strs => {\n srPanel.setMessages(strs);\n };\n\n const clearSRPanel = () => {\n srPanel.setMessages(null);\n };\n\n const shouldMoveFocusSR = srPanel.moveFocus;\n\n return (\n <SRPanelContext.Provider value={{ srPanel, setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR }}>\n {children}\n </SRPanelContext.Provider>\n );\n};\n\nexport default SRPanelProvider;\n"],"names":["SRPanelProvider","srPanel","children","i18n","useCoreContext","shouldMoveFocusSR","moveFocus","h","SRPanelContext","Provider","value","setSRMessagesFromObjects","fieldTypeMappingFn","partial","setSRMessagesFromErrors","SRPanelRef","setSRMessagesFromStrings","strs","setMessages","clearSRPanel"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SRPanelProvider.js","sources":["../../../../src/core/Errors/SRPanelProvider.tsx"],"sourcesContent":["import { h, ComponentChildren } from 'preact';\nimport { SRPanelContext } from './SRPanelContext';\nimport { useCoreContext } from '../Context/CoreProvider';\nimport { partial } from '../../components/internal/SecuredFields/lib/utilities/commonUtils';\nimport { setSRMessagesFromErrors } from './utils';\nimport { SRPanel } from './SRPanel';\nimport { SetSRMessagesReturnObject } from './types';\nimport { StringObject } from '../../components/internal/Address/types';\n\ntype SRPanelProviderProps = {\n srPanel: SRPanel;\n children: ComponentChildren;\n};\n\ninterface SetSRMessagesReturnFnProps {\n errors: {\n [key: string]: any;\n };\n isValidating: boolean;\n layout?: string[];\n countrySpecificLabels?: StringObject;\n /**\n * Whether this form currently has errors of its own on display. The SR panel is shared with\n * status reporters (loading, await, countdown), so a form must not clear it when it has\n * nothing of its own to clear. Defaults to true to preserve existing caller behaviour.\n */\n hasDisplayedErrors?: boolean;\n}\n\nexport type SetSRMessagesReturnFn = (props: SetSRMessagesReturnFnProps) => SetSRMessagesReturnObject;\n\nconst SRPanelProvider = ({ srPanel, children }: Readonly<SRPanelProviderProps>) => {\n const { i18n } = useCoreContext();\n\n // Helper fns\n const setSRMessagesFromObjects = ({ fieldTypeMappingFn }): SetSRMessagesReturnFn => {\n return partial(setSRMessagesFromErrors, {\n SRPanelRef: srPanel,\n i18n,\n fieldTypeMappingFn\n });\n };\n\n const setSRMessagesFromStrings = strs => {\n srPanel.setMessages(strs);\n };\n\n const clearSRPanel = () => {\n srPanel.setMessages(null);\n };\n\n const shouldMoveFocusSR = srPanel.moveFocus;\n\n return (\n <SRPanelContext.Provider value={{ srPanel, setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR }}>\n {children}\n </SRPanelContext.Provider>\n );\n};\n\nexport default SRPanelProvider;\n"],"names":["SRPanelProvider","srPanel","children","i18n","useCoreContext","shouldMoveFocusSR","moveFocus","h","SRPanelContext","Provider","value","setSRMessagesFromObjects","fieldTypeMappingFn","partial","setSRMessagesFromErrors","SRPanelRef","setSRMessagesFromStrings","strs","setMessages","clearSRPanel"],"mappings":"0UA+BA,MAAMA,EAAkB,EAAGC,UAASC,eAChC,MAAMC,KAAEA,GAASC,IAmBXC,EAAoBJ,EAAQK,UAElC,OACIC,EAACC,EAAeC,SAAQ,CAACC,MAAO,CAAET,UAASU,yBAnBd,EAAGC,wBACzBC,EAAQC,EAAyB,CACpCC,WAAYd,EACZE,OACAS,uBAeiEI,yBAXxCC,IAC7BhB,EAAQiB,YAAYD,IAU2EE,aAP9E,KACjBlB,EAAQiB,YAAY,OAMyFb,sBACxGH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ENCRYPTED_PWD_FIELD as
|
|
1
|
+
import{ENCRYPTED_PWD_FIELD as _,ENCRYPTED_SECURITY_CODE as R,ENCRYPTED_EXPIRY_YEAR as c,ENCRYPTED_EXPIRY_MONTH as E,ENCRYPTED_EXPIRY_DATE as r,ENCRYPTED_CARD_NUMBER as C}from"../../components/internal/SecuredFields/lib/constants.js";const O="-ariaError",e="-ariaContext",t="focusField",a="notValidating:blurScenario",M="field.error.required",i="field.error.invalid",n="field.error.invalidCharacters",d="invalid.format.expects",S="creditCard.holderName.invalid",L="creditCard.taxNumber.invalid",T="boleto.socialSecurityNumber.invalid";var o=function(_){return _.CC_NUM="cc.num",_.CC_DAT="cc.dat",_.CC_MTH="cc.mth",_.CC_YR="cc.yr",_.CC_CVC="cc.cvc",_.KCP_PWD="kcp.pwd",_}({}),D=function(_){return _.ERROR_MSG_INCOMPLETE_FIELD="err.gen.9100",_.ERROR_MSG_INVALID_FIELD="err.gen.9101",_.ERROR_MSG_LUHN_CHECK_FAILED="cc.num.902",_.ERROR_MSG_EMPTY_PAN="cc.num.900",_.ERROR_MSG_UNSUPPORTED_CARD_ENTERED="cc.num.903",_.ERROR_MSG_INCORRECTLY_FILLED_PAN="cc.num.901",_.ERROR_MSG_CARD_TOO_OLD="cc.dat.912",_.ERROR_MSG_CARD_TOO_FAR_IN_FUTURE="cc.dat.913",_.ERROR_MSG_CARD_EXPIRES_TOO_SOON="cc.dat.914",_.ERROR_MSG_EMPTY_DATE="cc.dat.910",_.ERROR_MSG_INCORRECTLY_FILLED__DATE="cc.dat.911",_.ERROR_MSG_EMPTY_YEAR="cc.yr.917",_.ERROR_MSG_INCORRECTLY_FILLED_YEAR="cc.yr.918",_.ERROR_MSG_EMPTY_MONTH="cc.mth.915",_.ERROR_MSG_EMPTY_CVC="cc.cvc.920",_.ERROR_MSG_INCORRECTLY_FILLED_CVC="cc.cvc.921",_.ERROR_MSG_EMPTY_CVC_AMEX="cc.cvc.920.amex",_.ERROR_MSG_INCORRECTLY_FILLED_CVC_AMEX="cc.cvc.921.amex",_.ERROR_MSG_EMPTY_KCP_PWD="kcp.pwd.940",_.ERROR_MSG_INCORRECTLY_FILLED_KCP_PWD="kcp.pwd.941",_}({});const G={[C]:"cc.num.900",[r]:"cc.dat.910",[E]:"cc.mth.915",[c]:"cc.yr.917",[R]:"cc.cvc.920",[_]:"kcp.pwd.940"};export{e as ARIA_CONTEXT_SUFFIX,O as ARIA_ERROR_SUFFIX,T as BOLETO_SOCIAL_SECURITY_NUMBER_INVALID,S as CREDITCARD_HOLDER_NAME_INVALID,L as CREDITCARD_TAX_NUMBER_INVALID,G as EMPTY_FIELD_ERROR_MESSAGES,a as ERROR_ACTION_BLUR_SCENARIO,t as ERROR_ACTION_FOCUS_FIELD,i as ERROR_FIELD_INVALID,M as ERROR_FIELD_REQUIRED,n as ERROR_INVALID_CHARACTERS,d as ERROR_INVALID_FORMAT_EXPECTS,o as ErrorCodePrefixes,D as SF_ErrorCodes};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/core/Errors/constants.ts"],"sourcesContent":["import {\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_PWD_FIELD,\n ENCRYPTED_SECURITY_CODE\n} from '../../components/internal/SecuredFields/lib/constants';\n\nexport const ARIA_ERROR_SUFFIX = '-ariaError';\nexport const ARIA_CONTEXT_SUFFIX = '-ariaContext';\n\nexport const ERROR_ACTION_FOCUS_FIELD = 'focusField';\nexport const ERROR_ACTION_BLUR_SCENARIO = 'notValidating:blurScenario';\nexport const ERROR_FIELD_REQUIRED = 'field.error.required';\nexport const ERROR_FIELD_INVALID = 'field.error.invalid';\n\nexport const ERROR_INVALID_FORMAT_EXPECTS = 'invalid.format.expects';\nexport const CREDITCARD_HOLDER_NAME_INVALID = 'creditCard.holderName.invalid';\nexport const CREDITCARD_TAX_NUMBER_INVALID = 'creditCard.taxNumber.invalid';\nexport const BOLETO_SOCIAL_SECURITY_NUMBER_INVALID = 'boleto.socialSecurityNumber.invalid';\n\nexport enum ErrorCodePrefixes {\n CC_NUM = 'cc.num',\n CC_DAT = 'cc.dat',\n CC_MTH = 'cc.mth',\n CC_YR = 'cc.yr',\n CC_CVC = 'cc.cvc',\n KCP_PWD = 'kcp.pwd'\n}\n\n/**\n * For SecuredFields\n * Human readable error strings mapped to the codes, used as keys, in the translations files\n */\nexport enum SF_ErrorCodes {\n ERROR_MSG_INCOMPLETE_FIELD = 'err.gen.9100',\n ERROR_MSG_INVALID_FIELD = 'err.gen.9101',\n\n ERROR_MSG_LUHN_CHECK_FAILED = `${ErrorCodePrefixes.CC_NUM}.902`,\n ERROR_MSG_EMPTY_PAN = `${ErrorCodePrefixes.CC_NUM}.900`,\n ERROR_MSG_UNSUPPORTED_CARD_ENTERED = `${ErrorCodePrefixes.CC_NUM}.903`,\n ERROR_MSG_INCORRECTLY_FILLED_PAN = `${ErrorCodePrefixes.CC_NUM}.901`, // 'Enter the complete card number'\n\n ERROR_MSG_CARD_TOO_OLD = `${ErrorCodePrefixes.CC_DAT}.912`,\n ERROR_MSG_CARD_TOO_FAR_IN_FUTURE = `${ErrorCodePrefixes.CC_DAT}.913`,\n ERROR_MSG_CARD_EXPIRES_TOO_SOON = `${ErrorCodePrefixes.CC_DAT}.914`,\n ERROR_MSG_EMPTY_DATE = `${ErrorCodePrefixes.CC_DAT}.910`,\n ERROR_MSG_INCORRECTLY_FILLED__DATE = `${ErrorCodePrefixes.CC_DAT}.911`,\n\n ERROR_MSG_EMPTY_YEAR = `${ErrorCodePrefixes.CC_YR}.917`,\n ERROR_MSG_INCORRECTLY_FILLED_YEAR = `${ErrorCodePrefixes.CC_YR}.918`,\n\n // ERROR_MSG_INCORRECTLY_FILLED_MONTH= `cc.mth.916`,\n ERROR_MSG_EMPTY_MONTH = `${ErrorCodePrefixes.CC_MTH}.915`,\n\n ERROR_MSG_EMPTY_CVC = `${ErrorCodePrefixes.CC_CVC}.920`,\n ERROR_MSG_INCORRECTLY_FILLED_CVC = `${ErrorCodePrefixes.CC_CVC}.921`,\n\n ERROR_MSG_EMPTY_KCP_PWD = `${ErrorCodePrefixes.KCP_PWD}.940`,\n ERROR_MSG_INCORRECTLY_FILLED_KCP_PWD = `${ErrorCodePrefixes.KCP_PWD}.941`\n}\n\nexport const EMPTY_FIELD_ERROR_MESSAGES = {\n [ENCRYPTED_CARD_NUMBER]: SF_ErrorCodes.ERROR_MSG_EMPTY_PAN,\n [ENCRYPTED_EXPIRY_DATE]: SF_ErrorCodes.ERROR_MSG_EMPTY_DATE,\n [ENCRYPTED_EXPIRY_MONTH]: SF_ErrorCodes.ERROR_MSG_EMPTY_MONTH,\n [ENCRYPTED_EXPIRY_YEAR]: SF_ErrorCodes.ERROR_MSG_EMPTY_YEAR,\n [ENCRYPTED_SECURITY_CODE]: SF_ErrorCodes.ERROR_MSG_EMPTY_CVC,\n [ENCRYPTED_PWD_FIELD]: SF_ErrorCodes.ERROR_MSG_EMPTY_KCP_PWD\n};\n"],"names":["ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","ERROR_ACTION_FOCUS_FIELD","ERROR_ACTION_BLUR_SCENARIO","ERROR_FIELD_REQUIRED","ERROR_FIELD_INVALID","ERROR_INVALID_FORMAT_EXPECTS","CREDITCARD_HOLDER_NAME_INVALID","CREDITCARD_TAX_NUMBER_INVALID","BOLETO_SOCIAL_SECURITY_NUMBER_INVALID","ErrorCodePrefixes","SF_ErrorCodes","EMPTY_FIELD_ERROR_MESSAGES","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD"],"mappings":"yOASO,MAAMA,EAAoB,aACpBC,EAAsB,eAEtBC,EAA2B,aAC3BC,EAA6B,6BAC7BC,EAAuB,uBACvBC,EAAsB,
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/core/Errors/constants.ts"],"sourcesContent":["import {\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_PWD_FIELD,\n ENCRYPTED_SECURITY_CODE\n} from '../../components/internal/SecuredFields/lib/constants';\n\nexport const ARIA_ERROR_SUFFIX = '-ariaError';\nexport const ARIA_CONTEXT_SUFFIX = '-ariaContext';\n\nexport const ERROR_ACTION_FOCUS_FIELD = 'focusField';\nexport const ERROR_ACTION_BLUR_SCENARIO = 'notValidating:blurScenario';\nexport const ERROR_FIELD_REQUIRED = 'field.error.required';\nexport const ERROR_FIELD_INVALID = 'field.error.invalid';\nexport const ERROR_INVALID_CHARACTERS = 'field.error.invalidCharacters';\n\nexport const ERROR_INVALID_FORMAT_EXPECTS = 'invalid.format.expects';\nexport const CREDITCARD_HOLDER_NAME_INVALID = 'creditCard.holderName.invalid';\nexport const CREDITCARD_TAX_NUMBER_INVALID = 'creditCard.taxNumber.invalid';\nexport const BOLETO_SOCIAL_SECURITY_NUMBER_INVALID = 'boleto.socialSecurityNumber.invalid';\n\nexport enum ErrorCodePrefixes {\n CC_NUM = 'cc.num',\n CC_DAT = 'cc.dat',\n CC_MTH = 'cc.mth',\n CC_YR = 'cc.yr',\n CC_CVC = 'cc.cvc',\n KCP_PWD = 'kcp.pwd'\n}\n\n/**\n * For SecuredFields\n * Human readable error strings mapped to the codes, used as keys, in the translations files\n */\nexport enum SF_ErrorCodes {\n ERROR_MSG_INCOMPLETE_FIELD = 'err.gen.9100',\n ERROR_MSG_INVALID_FIELD = 'err.gen.9101',\n\n ERROR_MSG_LUHN_CHECK_FAILED = `${ErrorCodePrefixes.CC_NUM}.902`,\n ERROR_MSG_EMPTY_PAN = `${ErrorCodePrefixes.CC_NUM}.900`,\n ERROR_MSG_UNSUPPORTED_CARD_ENTERED = `${ErrorCodePrefixes.CC_NUM}.903`,\n ERROR_MSG_INCORRECTLY_FILLED_PAN = `${ErrorCodePrefixes.CC_NUM}.901`, // 'Enter the complete card number'\n\n ERROR_MSG_CARD_TOO_OLD = `${ErrorCodePrefixes.CC_DAT}.912`,\n ERROR_MSG_CARD_TOO_FAR_IN_FUTURE = `${ErrorCodePrefixes.CC_DAT}.913`,\n ERROR_MSG_CARD_EXPIRES_TOO_SOON = `${ErrorCodePrefixes.CC_DAT}.914`,\n ERROR_MSG_EMPTY_DATE = `${ErrorCodePrefixes.CC_DAT}.910`,\n ERROR_MSG_INCORRECTLY_FILLED__DATE = `${ErrorCodePrefixes.CC_DAT}.911`,\n\n ERROR_MSG_EMPTY_YEAR = `${ErrorCodePrefixes.CC_YR}.917`,\n ERROR_MSG_INCORRECTLY_FILLED_YEAR = `${ErrorCodePrefixes.CC_YR}.918`,\n\n // ERROR_MSG_INCORRECTLY_FILLED_MONTH= `cc.mth.916`,\n ERROR_MSG_EMPTY_MONTH = `${ErrorCodePrefixes.CC_MTH}.915`,\n\n ERROR_MSG_EMPTY_CVC = `${ErrorCodePrefixes.CC_CVC}.920`,\n ERROR_MSG_INCORRECTLY_FILLED_CVC = `${ErrorCodePrefixes.CC_CVC}.921`,\n\n ERROR_MSG_EMPTY_CVC_AMEX = `${ErrorCodePrefixes.CC_CVC}.920.amex`,\n ERROR_MSG_INCORRECTLY_FILLED_CVC_AMEX = `${ErrorCodePrefixes.CC_CVC}.921.amex`,\n\n ERROR_MSG_EMPTY_KCP_PWD = `${ErrorCodePrefixes.KCP_PWD}.940`,\n ERROR_MSG_INCORRECTLY_FILLED_KCP_PWD = `${ErrorCodePrefixes.KCP_PWD}.941`\n}\n\nexport const EMPTY_FIELD_ERROR_MESSAGES = {\n [ENCRYPTED_CARD_NUMBER]: SF_ErrorCodes.ERROR_MSG_EMPTY_PAN,\n [ENCRYPTED_EXPIRY_DATE]: SF_ErrorCodes.ERROR_MSG_EMPTY_DATE,\n [ENCRYPTED_EXPIRY_MONTH]: SF_ErrorCodes.ERROR_MSG_EMPTY_MONTH,\n [ENCRYPTED_EXPIRY_YEAR]: SF_ErrorCodes.ERROR_MSG_EMPTY_YEAR,\n [ENCRYPTED_SECURITY_CODE]: SF_ErrorCodes.ERROR_MSG_EMPTY_CVC,\n [ENCRYPTED_PWD_FIELD]: SF_ErrorCodes.ERROR_MSG_EMPTY_KCP_PWD\n};\n"],"names":["ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","ERROR_ACTION_FOCUS_FIELD","ERROR_ACTION_BLUR_SCENARIO","ERROR_FIELD_REQUIRED","ERROR_FIELD_INVALID","ERROR_INVALID_CHARACTERS","ERROR_INVALID_FORMAT_EXPECTS","CREDITCARD_HOLDER_NAME_INVALID","CREDITCARD_TAX_NUMBER_INVALID","BOLETO_SOCIAL_SECURITY_NUMBER_INVALID","ErrorCodePrefixes","SF_ErrorCodes","EMPTY_FIELD_ERROR_MESSAGES","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD"],"mappings":"yOASO,MAAMA,EAAoB,aACpBC,EAAsB,eAEtBC,EAA2B,aAC3BC,EAA6B,6BAC7BC,EAAuB,uBACvBC,EAAsB,sBACtBC,EAA2B,gCAE3BC,EAA+B,yBAC/BC,EAAiC,gCACjCC,EAAgC,+BAChCC,EAAwC,sCAE9C,IAAAC,EAAKA,SAAAA,GAAAA,mHAAAA,CAOX,CAPWA,CAOX,CAAA,GAMWC,EAAAA,SAAAA,GAAAA,s3BAAAA,CA6BX,CA7BWA,CA6BX,CAAA,SAEYC,EAA6B,CACtCC,CAACA,GAAsB,aACvBC,CAACA,GAAsB,aACvBC,CAACA,GAAuB,aACxBC,CAACA,GAAsB,YACvBC,CAACA,GAAwB,aACzBC,CAACA,GAAoB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as t}from"../../external/preact/hooks/dist/hooks.js";import e from"./useSRPanelContext.js";const r=r=>{const{srPanel:s}=e();t(()=>{if(s)return s.setAriaProps({"aria-relevant":"additions text"}),()=>{s.setAriaProps({"aria-relevant":s.constructor.defaultProps.ariaAttributes["aria-relevant"]})}},[s]),t(()=>{s&&void 0!==r&&s.setMessages(r)},[s,r])};export{r as useA11yReporter};
|
|
2
2
|
//# sourceMappingURL=useA11yReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useA11yReporter.js","sources":["../../../../src/core/Errors/useA11yReporter.ts"],"sourcesContent":["import { useEffect } from 'preact/hooks';\nimport useSRPanelContext from './useSRPanelContext';\n\nexport const useA11yReporter = (statusMessage): void => {\n const { srPanel } = useSRPanelContext();\n\n useEffect(() => {\n srPanel.setAriaProps({ 'aria-relevant': 'additions text' });\n return () => {\n
|
|
1
|
+
{"version":3,"file":"useA11yReporter.js","sources":["../../../../src/core/Errors/useA11yReporter.ts"],"sourcesContent":["import { useEffect } from 'preact/hooks';\nimport useSRPanelContext from './useSRPanelContext';\n\nexport const useA11yReporter = (statusMessage?: string | null): void => {\n const { srPanel } = useSRPanelContext();\n\n useEffect(() => {\n if (!srPanel) return;\n srPanel.setAriaProps({ 'aria-relevant': 'additions text' });\n return () => {\n // Deliberately does not clear the panel. The panel is shared, so clearing on unmount\n // destroys whatever is on display -- often a message another component just wrote --\n // and truncates our own message before a screen reader has had time to read it.\n // A status message stays until something supersedes it.\n srPanel.setAriaProps({ 'aria-relevant': srPanel.constructor['defaultProps'].ariaAttributes['aria-relevant'] });\n };\n }, [srPanel]);\n\n useEffect(() => {\n if (!srPanel || statusMessage === undefined) return;\n srPanel.setMessages(statusMessage);\n }, [srPanel, statusMessage]);\n};\n"],"names":["useA11yReporter","statusMessage","srPanel","useSRPanelContext","useEffect","setAriaProps","constructor","ariaAttributes","undefined","setMessages"],"mappings":"4GAGO,MAAMA,EAAmBC,IAC5B,MAAMC,QAAEA,GAAYC,IAEpBC,EAAU,KACN,GAAKF,EAEL,OADAA,EAAQG,aAAa,CAAE,gBAAiB,mBACjC,KAKHH,EAAQG,aAAa,CAAE,gBAAiBH,EAAQI,yBAA4BC,eAAe,qBAEhG,CAACL,IAEJE,EAAU,KACDF,QAA6BM,IAAlBP,GAChBC,EAAQO,YAAYR,IACrB,CAACC,EAASD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useRef as o}from"../../external/preact/hooks/dist/hooks.js";import{useCoreContext as r}from"../Context/CoreProvider.js";import{useA11yReporter as e}from"./useA11yReporter.js";const t=(t,s)=>{const{i18n:n}=r(),i=o(t);t&&(i.current=!0);const c=t?n.get("loading"):null!=s?s:i.current?n.get("loaded"):void 0;e(c)};export{t as useLoadingA11yReporter};
|
|
2
|
+
//# sourceMappingURL=useLoadingA11yReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLoadingA11yReporter.js","sources":["../../../../src/core/Errors/useLoadingA11yReporter.ts"],"sourcesContent":["import { useRef } from 'preact/hooks';\n\nimport { useCoreContext } from '../Context/CoreProvider';\nimport { useA11yReporter } from './useA11yReporter';\n\n/**\n * Announces loading transitions to screen readers, for components whose spinner has no\n * accessible name of its own.\n *\n * The terminal message is required rather than cosmetic: the SR panel is shared and is\n * deliberately not cleared when a reporter unmounts, so without something to supersede it the\n * \"loading\" announcement would be left on display after loading has finished.\n *\n * Call this from a component that stays mounted across the whole transition. Calling it from a\n * component that only exists while loading cannot work, because it unmounts before it is able\n * to announce the terminal message.\n *\n * @param isLoading - whether the component is currently loading\n * @param finalMessage - announced instead of the generic \"loaded\" once loading ends, e.g. a payment result\n */\nexport const useLoadingA11yReporter = (isLoading: boolean, finalMessage?: string): void => {\n const { i18n } = useCoreContext();\n const hasStartedLoading = useRef(isLoading);\n\n if (isLoading) {\n hasStartedLoading.current = true;\n }\n\n const statusMessage = isLoading ? i18n.get('loading') : (finalMessage ?? (hasStartedLoading.current ? i18n.get('loaded') : undefined));\n useA11yReporter(statusMessage);\n};\n"],"names":["useLoadingA11yReporter","isLoading","finalMessage","i18n","useCoreContext","hasStartedLoading","useRef","current","statusMessage","get","undefined","useA11yReporter"],"mappings":"sLAoBO,MAAMA,EAAyB,CAACC,EAAoBC,KACvD,MAAMC,KAAEA,GAASC,IACXC,EAAoBC,EAAOL,GAE7BA,IACAI,EAAkBE,SAAU,GAGhC,MAAMC,EAAgBP,EAAYE,EAAKM,IAAI,WAAcP,QAAAA,EAAiBG,EAAkBE,QAAUJ,EAAKM,IAAI,eAAYC,EAC3HC,EAAgBH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SF_ErrorCodes as e,ERROR_ACTION_FOCUS_FIELD as r,ERROR_ACTION_BLUR_SCENARIO as t,ErrorCodePrefixes as n}from"./constants.js";import{ENCRYPTED_PWD_FIELD as o,ENCRYPTED_SECURITY_CODE as s,ENCRYPTED_EXPIRY_YEAR as a,ENCRYPTED_EXPIRY_MONTH as i,ENCRYPTED_EXPIRY_DATE as c,ENCRYPTED_CARD_NUMBER as l}from"../../components/internal/SecuredFields/lib/constants.js";function u(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}const f=(r,t)=>Object.values(e).reduce((e,n)=>(n.includes(t)&&(e[n]=r.get(n)),e),{}),b=(e,r,t)=>{const n=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){u(e,r,t[r])})}return e}({},e),o=y(t);return n.error=f(r,o),n},p=(e,r)=>{let t=e;for(const[n,o]of Object.entries(r))if(o===e){t=n;break}return null==t?void 0:t.toLowerCase().replace(/[_.\s]/g,"-")},y=e=>{let r;switch(e){case l:r=n.CC_NUM;break;case c:r=n.CC_DAT;break;case i:r=n.CC_MTH;break;case a:r=n.CC_YR;break;case s:r=n.CC_CVC;break;case o:r=n.KCP_PWD}return r},
|
|
1
|
+
import{SF_ErrorCodes as e,ERROR_ACTION_FOCUS_FIELD as r,ERROR_ACTION_BLUR_SCENARIO as t,ErrorCodePrefixes as n}from"./constants.js";import{ENCRYPTED_PWD_FIELD as o,ENCRYPTED_SECURITY_CODE as s,ENCRYPTED_EXPIRY_YEAR as a,ENCRYPTED_EXPIRY_MONTH as i,ENCRYPTED_EXPIRY_DATE as c,ENCRYPTED_CARD_NUMBER as l}from"../../components/internal/SecuredFields/lib/constants.js";function u(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}const f=(r,t)=>Object.values(e).reduce((e,n)=>(n.includes(t)&&(e[n]=r.get(n)),e),{}),b=(e,r,t)=>{const n=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){u(e,r,t[r])})}return e}({},e),o=y(t);return n.error=f(r,o),n},p=(e,r)=>{let t=e;for(const[n,o]of Object.entries(r))if(o===e){t=n;break}return null==t?void 0:t.toLowerCase().replace(/[_.\s]/g,"-")},y=e=>{let r;switch(e){case l:r=n.CC_NUM;break;case c:r=n.CC_DAT;break;case i:r=n.CC_MTH;break;case a:r=n.CC_YR;break;case s:r=n.CC_CVC;break;case o:r=n.KCP_PWD}return r},d=({errors:e,i18n:r,layout:t,countrySpecificLabels:n,fieldTypeMappingFn:o})=>Object.entries(e).reduce((s,[a,i])=>{if(i){const i=e[a],c="errorI18n"in i&&"rootNode"in i,l="object"==typeof i.errorMessage;let u,f;if(u=c?i.error:l?i.errorMessage.translationKey:i.errorMessage,c&&"errorI18n"in i)f=i.errorI18n+"";else{const e=o?o(a,r,n):"";if(l){const t=i.errorMessage.translationKey,n=i.errorMessage.translationObject.values.format;f=`${r.get(t,{values:{label:e,format:n}})}`}else f=r.get(i.errorMessage,{values:{label:e}})+""}s.push({field:a,errorMessage:f,errorCode:u}),t&&s.sort((e,r)=>t.indexOf(e.field)-t.indexOf(r.field))}return s},[]),g=({i18n:e,fieldTypeMappingFn:n,SRPanelRef:o},{errors:s,isValidating:a,layout:i,countrySpecificLabels:c,hasDisplayedErrors:l=!0})=>{const u=d({errors:s,i18n:e,fieldTypeMappingFn:n,countrySpecificLabels:c,layout:i});if(u.length){if(a){const e=u.map(e=>e.errorMessage);o.setMessages(e);const t=u.map(e=>e.field);return{currentErrorsSortedByLayout:u,action:r,fieldToFocus:t[0]}}return null==o||o.setMessages(null),{currentErrorsSortedByLayout:u,action:t}}return l&&(null==o||o.setMessages(null)),{currentErrorsSortedByLayout:u,action:"none"}},M=(e,r)=>{if(!e)return null;return Object.entries(e).reduce((e,[t,n])=>{if(n){e[`${r}${t}`]=n}return e},{})};export{b as addErrorTranslationsToObject,M as enhanceErrorObjectKeys,p as getErrorMessageFromCode,f as getTranslatedErrors,g as setSRMessagesFromErrors,d as sortErrorsByLayout};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/core/Errors/utils.ts"],"sourcesContent":["import { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD, ErrorCodePrefixes, SF_ErrorCodes } from './constants';\nimport { SFError } from '../../components/Card/components/CardInput/types';\nimport { SortErrorsObj, SortedErrorObject, GenericError, SetSRMessagesReturnObject } from './types';\nimport { ValidationRuleResult } from '../../utils/Validator/ValidationRuleResult';\nimport { ErrorMessageObject } from '../../utils/Validator/types';\nimport {\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_PWD_FIELD,\n ENCRYPTED_SECURITY_CODE\n} from '../../components/internal/SecuredFields/lib/constants';\nimport { AriaConfigObject } from '../../components/internal/SecuredFields/lib/types';\nimport type Language from '../../language';\n\n/**\n * Extract and translate all the errorCodes related to a specific securedField\n * @param i18n\n * @param errorCodeIdentifier - the identifier for which type of errorCodes we need to collect e.g. 'cc-num'\n */\nexport const getTranslatedErrors = (i18n: Language, errorCodeIdentifier: string): Record<SF_ErrorCodes, string> => {\n const transObj = Object.values(SF_ErrorCodes).reduce((acc, value) => {\n // Limit to errors related to specific sf\n if (value.includes(errorCodeIdentifier)) {\n acc[value] = i18n.get(value);\n }\n return acc;\n }, {}) as Record<SF_ErrorCodes, string>;\n\n return transObj;\n};\n\n/**\n * Adds a new error property to an object.\n * This error property is an object containing the translated errors, stored by code, that relate to the securedFields\n * @param originalObject - object we want to duplicate and enhance\n * @param i18n - an i18n object to use to get translations\n * @returns a duplicate of the original object with a new property: \"error\" whose value is a object containing the translated errors\n */\nexport const addErrorTranslationsToObject = (originalObj: AriaConfigObject, i18n: Language, fieldType: string): AriaConfigObject => {\n const nuObj: AriaConfigObject = { ...originalObj };\n\n const errorCodeIdentifier = fieldTypeToErrorCodeIdentifier(fieldType);\n nuObj.error = getTranslatedErrors(i18n, errorCodeIdentifier);\n\n return nuObj;\n};\n\nexport const getErrorMessageFromCode = (errorCode: string, codeMap: Record<string, string>): string => {\n let errMsg = errorCode;\n for (const [key, value] of Object.entries(codeMap)) {\n if (value === errorCode) {\n errMsg = key;\n break;\n }\n }\n return errMsg?.toLowerCase().replace(/[_.\\s]/g, '-');\n};\n\n/**\n * errorCodeIdentifiers must match the prefixes to the numbers in ERROR_CODES (Errors/constants.ts)\n * (Which in turn must match the keys in the translations files)\n */\nconst fieldTypeToErrorCodeIdentifier = (fieldType: string): string => {\n let errorCodeIdentifier;\n switch (fieldType) {\n case ENCRYPTED_CARD_NUMBER:\n errorCodeIdentifier = ErrorCodePrefixes.CC_NUM;\n break;\n case ENCRYPTED_EXPIRY_DATE:\n errorCodeIdentifier = ErrorCodePrefixes.CC_DAT;\n break;\n case ENCRYPTED_EXPIRY_MONTH:\n errorCodeIdentifier = ErrorCodePrefixes.CC_MTH;\n break;\n case ENCRYPTED_EXPIRY_YEAR:\n errorCodeIdentifier = ErrorCodePrefixes.CC_YR;\n break;\n case ENCRYPTED_SECURITY_CODE:\n errorCodeIdentifier = ErrorCodePrefixes.CC_CVC;\n break;\n case ENCRYPTED_PWD_FIELD:\n errorCodeIdentifier = ErrorCodePrefixes.KCP_PWD;\n break;\n default:\n }\n return errorCodeIdentifier;\n};\n\n/**\n * sortErrorsByLayout - takes a list of errors and a layout, and returns a sorted array of error objects with translated error messages\n *\n * @param errors - an object containing errors, referenced by field type\n * @param layout - a string[] controlling how the output error objects will be ordered. Required when it is known that the way the error object is populated can vary e.g. Card comp, &/or anything with a country selector\n * @param i18n - our internal Language mechanism\n * @param countrySpecificLabels - some errors are region specific, e.g. in the US \"postal code\" = \"zip code\", so map the fieldType value accordingly (if it is being added to the errorMessage string)\n * @param fieldTypeMappingFn - a component specific lookup function that will tell us both if we need to prepend the field type to the SR panel message, and, if so, will retrieve the correct translation for the field type\n */\nexport const sortErrorsByLayout = ({ errors, i18n, layout, countrySpecificLabels, fieldTypeMappingFn }: SortErrorsObj): SortedErrorObject[] => {\n const SR_INDICATOR_PREFIX = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test' ? '' : '-sr'; // Useful for testing whether SR is reading out aria-live errors (sr) or aria-describedby ones\n\n // Create array of error objects, sorted by layout\n const sortedErrors: SortedErrorObject[] = Object.entries(errors).reduce((acc, [key, value]) => {\n if (value) {\n const errObj: ValidationRuleResult | SFError | GenericError = errors[key];\n\n const TREAT_AS_SF_ERROR = 'errorI18n' in errObj && `rootNode` in errObj; // look for expected props, unique to an SFError\n\n // Some ValidationRuleResults can be passed an object in the 'errorMessage' prop (to give country specific errors)\n const ERROR_MSG_IS_OBJECT = typeof errObj.errorMessage === 'object';\n\n /**\n * Get error codes - these are used if we need to distinguish between showValidation & onBlur errors\n * - For a ValidationRuleResult or GenericError the error \"code\" is contained in the errorMessage prop.\n * - For an SFError the error \"code\" is contained in the error prop.\n */\n let errorCode: string;\n if (TREAT_AS_SF_ERROR) {\n errorCode = errObj.error;\n } else {\n /** Special handling for Address~postalCode (where the errorMessage is an object) */\n if (ERROR_MSG_IS_OBJECT) {\n /** is ValidationRuleResult w. country specific error */\n errorCode = (errObj.errorMessage as ErrorMessageObject).translationKey;\n } else {\n /** is ValidationRuleResult || GenericError || an as yet incorrectly formed error */\n errorCode = errObj.errorMessage as string;\n }\n }\n\n /**\n * Get corresponding error msg - a translated string we can place into the SRPanel\n * NOTE: the error object for a secured field already contains the error in a translated form (errorI18n).\n * For other fields we still need to translate it, so we use the errObj.errorMessage prop as a translation key\n */\n let errorMsg: string;\n if (TREAT_AS_SF_ERROR && 'errorI18n' in errObj) {\n errorMsg = errObj.errorI18n + SR_INDICATOR_PREFIX;\n } else {\n /**\n * For some fields, for a11y reasons (when the translated error msg doesn't contain a reference to the field it refers to), we need to\n * add the field type into the translated error message.\n *\n * This happens with generic errors\n * e.g. \"field.error.required\": \"Enter the %{label}\"\n * or \"invalid.format.expects\": \"%{label} Invalid format. Expected format: %{format}\"\n */\n const mappedLabel = fieldTypeMappingFn ? fieldTypeMappingFn(key, i18n, countrySpecificLabels) : ''; // Retrieve the translated field name, if required\n\n /** Special handling for Address~postalCode where the errorMessage object contains the details of the country specific format that should have been used for the postcode */\n if (ERROR_MSG_IS_OBJECT) {\n /** is ValidationRuleResult w. country specific error */\n const translationKey = (errObj.errorMessage as ErrorMessageObject).translationKey;\n const countrySpecificFormat = (errObj.errorMessage as ErrorMessageObject).translationObject.values.format;\n\n errorMsg = `${i18n.get(translationKey, { values: { label: mappedLabel, format: countrySpecificFormat } })}${SR_INDICATOR_PREFIX}`;\n } else {\n /** is ValidationRuleResult || GenericError || an as yet incorrectly formed error */\n errorMsg = i18n.get(errObj.errorMessage as string, { values: { label: mappedLabel } }) + SR_INDICATOR_PREFIX;\n }\n }\n\n acc.push({ field: key, errorMessage: errorMsg, errorCode });\n\n if (layout) acc.sort((a, b) => layout.indexOf(a.field) - layout.indexOf(b.field));\n }\n return acc;\n }, []);\n\n return sortedErrors;\n};\n\n/**\n * Implemented as a partial, with an object containing the first 6 arguments; then the final argument, errors, is passed to the partial\n *\n * NOTE: using this generic error setting fny is only suitable when errors for the SRPanel are *only* generated by showValidation().\n * When errors are also generated onBlur, as the user leaves the input, the SR message generation becomes more complex - see CardInput as an example\n */\nexport const setSRMessagesFromErrors = (\n { i18n, fieldTypeMappingFn, SRPanelRef },\n { errors, isValidating, layout, countrySpecificLabels }\n): SetSRMessagesReturnObject => {\n const currentErrorsSortedByLayout = sortErrorsByLayout({\n errors,\n i18n,\n fieldTypeMappingFn,\n countrySpecificLabels,\n layout\n });\n\n const doLog = false;\n\n if (doLog) console.log('### setSRMessagesFromErrors::currentErrorsSortedByLayout:: ', currentErrorsSortedByLayout);\n\n if (currentErrorsSortedByLayout.length) {\n /** If validating i.e. \"on submit\" type event - then display all errors in the SR panel */\n if (isValidating) {\n const errorMsgArr: string[] = currentErrorsSortedByLayout.map(errObj => errObj.errorMessage);\n if (doLog) console.log('### setSRMessagesFromErrors:: #1 multiple errors:: (validating) errorMsgArr=', errorMsgArr);\n SRPanelRef.setMessages(errorMsgArr);\n\n const fieldListArr: string[] = currentErrorsSortedByLayout.map(errObj => errObj.field);\n return { currentErrorsSortedByLayout, action: ERROR_ACTION_FOCUS_FIELD, fieldToFocus: fieldListArr[0] };\n } else {\n // prettier-ignore\n if (doLog) console.log('### setSRMessagesFromErrors:: #3 on blur scenario:: not validating but there might be an error, either to set or to clear');\n SRPanelRef?.setMessages(null);\n\n return { currentErrorsSortedByLayout, action: ERROR_ACTION_BLUR_SCENARIO }; // on blur scenario: not validating but there might be an error, either to set or to clear\n }\n } else {\n if (doLog) console.log('### setSRMessagesFromErrors::componentDidUpdate:: #4 clearing errors:: NO currentErrorsSortedByLayout');\n SRPanelRef?.setMessages(null); // no errors - so clear SR panel\n return { currentErrorsSortedByLayout, action: 'none' };\n }\n};\n\nexport const enhanceErrorObjectKeys = (errorObj, keyPrefix) => {\n if (!errorObj) return null;\n const enhancedObj = Object.entries(errorObj).reduce((acc, [key, value]) => {\n if (value) {\n const newKey = `${keyPrefix}${key}`;\n acc[newKey] = value;\n }\n return acc;\n }, {});\n\n return enhancedObj;\n};\n"],"names":["getTranslatedErrors","i18n","errorCodeIdentifier","Object","values","SF_ErrorCodes","reduce","acc","value","includes","get","addErrorTranslationsToObject","originalObj","fieldType","nuObj","_object_spread","fieldTypeToErrorCodeIdentifier","error","getErrorMessageFromCode","errorCode","codeMap","errMsg","key","entries","toLowerCase","replace","ENCRYPTED_CARD_NUMBER","ErrorCodePrefixes","CC_NUM","ENCRYPTED_EXPIRY_DATE","CC_DAT","ENCRYPTED_EXPIRY_MONTH","CC_MTH","ENCRYPTED_EXPIRY_YEAR","CC_YR","ENCRYPTED_SECURITY_CODE","CC_CVC","ENCRYPTED_PWD_FIELD","KCP_PWD","sortErrorsByLayout","errors","layout","countrySpecificLabels","fieldTypeMappingFn","errObj","TREAT_AS_SF_ERROR","ERROR_MSG_IS_OBJECT","errorMessage","errorMsg","translationKey","errorI18n","mappedLabel","countrySpecificFormat","translationObject","format","label","push","field","sort","a","b","indexOf","setSRMessagesFromErrors","SRPanelRef","isValidating","currentErrorsSortedByLayout","length","errorMsgArr","map","setMessages","fieldListArr","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","ERROR_ACTION_BLUR_SCENARIO","enhanceErrorObjectKeys","errorObj","keyPrefix"],"mappings":"qeAqBO,MAAMA,EAAsB,CAACC,EAAgBC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,IAAYvD,KAChBd,CAClB,CACA,OAAOD,GACR,CAAA"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/core/Errors/utils.ts"],"sourcesContent":["import { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD, ErrorCodePrefixes, SF_ErrorCodes } from './constants';\nimport { SFError } from '../../components/Card/components/CardInput/types';\nimport { SortErrorsObj, SortedErrorObject, GenericError, SetSRMessagesReturnObject } from './types';\nimport { ValidationRuleResult } from '../../utils/Validator/ValidationRuleResult';\nimport { ErrorMessageObject } from '../../utils/Validator/types';\nimport {\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_PWD_FIELD,\n ENCRYPTED_SECURITY_CODE\n} from '../../components/internal/SecuredFields/lib/constants';\nimport { AriaConfigObject } from '../../components/internal/SecuredFields/lib/types';\nimport type Language from '../../language';\n\n/**\n * Extract and translate all the errorCodes related to a specific securedField\n * @param i18n\n * @param errorCodeIdentifier - the identifier for which type of errorCodes we need to collect e.g. 'cc-num'\n */\nexport const getTranslatedErrors = (i18n: Language, errorCodeIdentifier: string): Record<SF_ErrorCodes, string> => {\n const transObj = Object.values(SF_ErrorCodes).reduce((acc, value) => {\n // Limit to errors related to specific sf\n if (value.includes(errorCodeIdentifier)) {\n acc[value] = i18n.get(value);\n }\n return acc;\n }, {}) as Record<SF_ErrorCodes, string>;\n\n return transObj;\n};\n\n/**\n * Adds a new error property to an object.\n * This error property is an object containing the translated errors, stored by code, that relate to the securedFields\n * @param originalObject - object we want to duplicate and enhance\n * @param i18n - an i18n object to use to get translations\n * @returns a duplicate of the original object with a new property: \"error\" whose value is a object containing the translated errors\n */\nexport const addErrorTranslationsToObject = (originalObj: AriaConfigObject, i18n: Language, fieldType: string): AriaConfigObject => {\n const nuObj: AriaConfigObject = { ...originalObj };\n\n const errorCodeIdentifier = fieldTypeToErrorCodeIdentifier(fieldType);\n nuObj.error = getTranslatedErrors(i18n, errorCodeIdentifier);\n\n return nuObj;\n};\n\nexport const getErrorMessageFromCode = (errorCode: string, codeMap: Record<string, string>): string => {\n let errMsg = errorCode;\n for (const [key, value] of Object.entries(codeMap)) {\n if (value === errorCode) {\n errMsg = key;\n break;\n }\n }\n return errMsg?.toLowerCase().replace(/[_.\\s]/g, '-');\n};\n\n/**\n * errorCodeIdentifiers must match the prefixes to the numbers in ERROR_CODES (Errors/constants.ts)\n * (Which in turn must match the keys in the translations files)\n */\nconst fieldTypeToErrorCodeIdentifier = (fieldType: string): string => {\n let errorCodeIdentifier;\n switch (fieldType) {\n case ENCRYPTED_CARD_NUMBER:\n errorCodeIdentifier = ErrorCodePrefixes.CC_NUM;\n break;\n case ENCRYPTED_EXPIRY_DATE:\n errorCodeIdentifier = ErrorCodePrefixes.CC_DAT;\n break;\n case ENCRYPTED_EXPIRY_MONTH:\n errorCodeIdentifier = ErrorCodePrefixes.CC_MTH;\n break;\n case ENCRYPTED_EXPIRY_YEAR:\n errorCodeIdentifier = ErrorCodePrefixes.CC_YR;\n break;\n case ENCRYPTED_SECURITY_CODE:\n errorCodeIdentifier = ErrorCodePrefixes.CC_CVC;\n break;\n case ENCRYPTED_PWD_FIELD:\n errorCodeIdentifier = ErrorCodePrefixes.KCP_PWD;\n break;\n default:\n }\n return errorCodeIdentifier;\n};\n\n/**\n * sortErrorsByLayout - takes a list of errors and a layout, and returns a sorted array of error objects with translated error messages\n *\n * @param errors - an object containing errors, referenced by field type\n * @param layout - a string[] controlling how the output error objects will be ordered. Required when it is known that the way the error object is populated can vary e.g. Card comp, &/or anything with a country selector\n * @param i18n - our internal Language mechanism\n * @param countrySpecificLabels - some errors are region specific, e.g. in the US \"postal code\" = \"zip code\", so map the fieldType value accordingly (if it is being added to the errorMessage string)\n * @param fieldTypeMappingFn - a component specific lookup function that will tell us both if we need to prepend the field type to the SR panel message, and, if so, will retrieve the correct translation for the field type\n */\nexport const sortErrorsByLayout = ({ errors, i18n, layout, countrySpecificLabels, fieldTypeMappingFn }: SortErrorsObj): SortedErrorObject[] => {\n const SR_INDICATOR_PREFIX = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test' ? '' : '-sr'; // Useful for testing whether SR is reading out aria-live errors (sr) or aria-describedby ones\n\n // Create array of error objects, sorted by layout\n const sortedErrors: SortedErrorObject[] = Object.entries(errors).reduce((acc, [key, value]) => {\n if (value) {\n const errObj: ValidationRuleResult | SFError | GenericError = errors[key];\n\n const TREAT_AS_SF_ERROR = 'errorI18n' in errObj && `rootNode` in errObj; // look for expected props, unique to an SFError\n\n // Some ValidationRuleResults can be passed an object in the 'errorMessage' prop (to give country specific errors)\n const ERROR_MSG_IS_OBJECT = typeof errObj.errorMessage === 'object';\n\n /**\n * Get error codes - these are used if we need to distinguish between showValidation & onBlur errors\n * - For a ValidationRuleResult or GenericError the error \"code\" is contained in the errorMessage prop.\n * - For an SFError the error \"code\" is contained in the error prop.\n */\n let errorCode: string;\n if (TREAT_AS_SF_ERROR) {\n errorCode = errObj.error;\n } else {\n /** Special handling for Address~postalCode (where the errorMessage is an object) */\n if (ERROR_MSG_IS_OBJECT) {\n /** is ValidationRuleResult w. country specific error */\n errorCode = (errObj.errorMessage as ErrorMessageObject).translationKey;\n } else {\n /** is ValidationRuleResult || GenericError || an as yet incorrectly formed error */\n errorCode = errObj.errorMessage as string;\n }\n }\n\n /**\n * Get corresponding error msg - a translated string we can place into the SRPanel\n * NOTE: the error object for a secured field already contains the error in a translated form (errorI18n).\n * For other fields we still need to translate it, so we use the errObj.errorMessage prop as a translation key\n */\n let errorMsg: string;\n if (TREAT_AS_SF_ERROR && 'errorI18n' in errObj) {\n errorMsg = errObj.errorI18n + SR_INDICATOR_PREFIX;\n } else {\n /**\n * For some fields, for a11y reasons (when the translated error msg doesn't contain a reference to the field it refers to), we need to\n * add the field type into the translated error message.\n *\n * This happens with generic errors\n * e.g. \"field.error.required\": \"Enter the %{label}\"\n * or \"invalid.format.expects\": \"%{label} Invalid format. Expected format: %{format}\"\n */\n const mappedLabel = fieldTypeMappingFn ? fieldTypeMappingFn(key, i18n, countrySpecificLabels) : ''; // Retrieve the translated field name, if required\n\n /** Special handling for Address~postalCode where the errorMessage object contains the details of the country specific format that should have been used for the postcode */\n if (ERROR_MSG_IS_OBJECT) {\n /** is ValidationRuleResult w. country specific error */\n const translationKey = (errObj.errorMessage as ErrorMessageObject).translationKey;\n const countrySpecificFormat = (errObj.errorMessage as ErrorMessageObject).translationObject.values.format;\n\n errorMsg = `${i18n.get(translationKey, { values: { label: mappedLabel, format: countrySpecificFormat } })}${SR_INDICATOR_PREFIX}`;\n } else {\n /** is ValidationRuleResult || GenericError || an as yet incorrectly formed error */\n errorMsg = i18n.get(errObj.errorMessage as string, { values: { label: mappedLabel } }) + SR_INDICATOR_PREFIX;\n }\n }\n\n acc.push({ field: key, errorMessage: errorMsg, errorCode });\n\n if (layout) acc.sort((a, b) => layout.indexOf(a.field) - layout.indexOf(b.field));\n }\n return acc;\n }, []);\n\n return sortedErrors;\n};\n\n/**\n * Implemented as a partial, with an object containing the first 6 arguments; then the final argument, errors, is passed to the partial\n *\n * NOTE: using this generic error setting fny is only suitable when errors for the SRPanel are *only* generated by showValidation().\n * When errors are also generated onBlur, as the user leaves the input, the SR message generation becomes more complex - see CardInput as an example\n */\nexport const setSRMessagesFromErrors = (\n { i18n, fieldTypeMappingFn, SRPanelRef },\n { errors, isValidating, layout, countrySpecificLabels, hasDisplayedErrors = true }\n): SetSRMessagesReturnObject => {\n const currentErrorsSortedByLayout = sortErrorsByLayout({\n errors,\n i18n,\n fieldTypeMappingFn,\n countrySpecificLabels,\n layout\n });\n\n const doLog = false;\n\n if (doLog) console.log('### setSRMessagesFromErrors::currentErrorsSortedByLayout:: ', currentErrorsSortedByLayout);\n\n if (currentErrorsSortedByLayout.length) {\n /** If validating i.e. \"on submit\" type event - then display all errors in the SR panel */\n if (isValidating) {\n const errorMsgArr: string[] = currentErrorsSortedByLayout.map(errObj => errObj.errorMessage);\n if (doLog) console.log('### setSRMessagesFromErrors:: #1 multiple errors:: (validating) errorMsgArr=', errorMsgArr);\n SRPanelRef.setMessages(errorMsgArr);\n\n const fieldListArr: string[] = currentErrorsSortedByLayout.map(errObj => errObj.field);\n return { currentErrorsSortedByLayout, action: ERROR_ACTION_FOCUS_FIELD, fieldToFocus: fieldListArr[0] };\n } else {\n // prettier-ignore\n if (doLog) console.log('### setSRMessagesFromErrors:: #3 on blur scenario:: not validating but there might be an error, either to set or to clear');\n SRPanelRef?.setMessages(null);\n\n return { currentErrorsSortedByLayout, action: ERROR_ACTION_BLUR_SCENARIO }; // on blur scenario: not validating but there might be an error, either to set or to clear\n }\n } else {\n if (doLog) console.log('### setSRMessagesFromErrors::componentDidUpdate:: #4 clearing errors:: NO currentErrorsSortedByLayout');\n /**\n * Only clear if we actually have errors on display to clear. The SR panel is shared with\n * status reporters (loading, await, countdown); clearing it when this form has never shown\n * an error wipes their messages instead - see PR #4098.\n */\n if (hasDisplayedErrors) {\n SRPanelRef?.setMessages(null); // no errors - so clear SR panel\n }\n return { currentErrorsSortedByLayout, action: 'none' };\n }\n};\n\nexport const enhanceErrorObjectKeys = (errorObj, keyPrefix) => {\n if (!errorObj) return null;\n const enhancedObj = Object.entries(errorObj).reduce((acc, [key, value]) => {\n if (value) {\n const newKey = `${keyPrefix}${key}`;\n acc[newKey] = value;\n }\n return acc;\n }, {});\n\n return enhancedObj;\n};\n"],"names":["getTranslatedErrors","i18n","errorCodeIdentifier","Object","values","SF_ErrorCodes","reduce","acc","value","includes","get","addErrorTranslationsToObject","originalObj","fieldType","nuObj","_object_spread","fieldTypeToErrorCodeIdentifier","error","getErrorMessageFromCode","errorCode","codeMap","errMsg","key","entries","toLowerCase","replace","ENCRYPTED_CARD_NUMBER","ErrorCodePrefixes","CC_NUM","ENCRYPTED_EXPIRY_DATE","CC_DAT","ENCRYPTED_EXPIRY_MONTH","CC_MTH","ENCRYPTED_EXPIRY_YEAR","CC_YR","ENCRYPTED_SECURITY_CODE","CC_CVC","ENCRYPTED_PWD_FIELD","KCP_PWD","sortErrorsByLayout","errors","layout","countrySpecificLabels","fieldTypeMappingFn","errObj","TREAT_AS_SF_ERROR","ERROR_MSG_IS_OBJECT","errorMessage","errorMsg","translationKey","errorI18n","mappedLabel","countrySpecificFormat","translationObject","format","label","push","field","sort","a","b","indexOf","setSRMessagesFromErrors","SRPanelRef","isValidating","hasDisplayedErrors","currentErrorsSortedByLayout","length","errorMsgArr","map","setMessages","fieldListArr","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","ERROR_ACTION_BLUR_SCENARIO","enhanceErrorObjectKeys","errorObj","keyPrefix"],"mappings":"qeAqBO,MAAMA,EAAsB,CAACC,EAAgBC,IAC/BC,OAAOC,OAAOC,GAAeC,OAAO,CAACC,EAAKC,KAEnDA,EAAMC,SAASP,KACfK,EAAIC,GAASP,EAAKS,IAAIF,IAEnBD,GACR,CAAA,GAYMI,EAA+B,CAACC,EAA+BX,EAAgBY,KACxF,MAAMC,oUAA0BC,CAAA,CAAA,EAAKH,GAE/BV,EAAsBc,EAA+BH,GAG3D,OAFAC,EAAMG,MAAQjB,EAAoBC,EAAMC,GAEjCY,GAGEI,EAA0B,CAACC,EAAmBC,KACvD,IAAIC,EAASF,EACb,IAAK,MAAOG,EAAKd,KAAUL,OAAOoB,QAAQH,GACtC,GAAIZ,IAAUW,EAAW,CACrBE,EAASC,EACT,KACJ,CAEJ,OAAOD,aAAAA,EAAAA,EAAQG,cAAcC,QAAQ,UAAW,MAO9CT,EAAkCH,IACpC,IAAIX,EACJ,OAAQW,GACJ,KAAKa,EACDxB,EAAsByB,EAAkBC,OACxC,MACJ,KAAKC,EACD3B,EAAsByB,EAAkBG,OACxC,MACJ,KAAKC,EACD7B,EAAsByB,EAAkBK,OACxC,MACJ,KAAKC,EACD/B,EAAsByB,EAAkBO,MACxC,MACJ,KAAKC,EACDjC,EAAsByB,EAAkBS,OACxC,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,EAAc,CACd,MAAMI,EAAwBF,EAA4BG,IAAIzB,GAAUA,EAAOG,cAE/EgB,EAAWO,YAAYF,GAEvB,MAAMG,EAAyBL,EAA4BG,IAAIzB,GAAUA,EAAOa,OAChF,MAAO,CAAES,8BAA6BM,OAAQC,EAA0BC,aAAcH,EAAa,GACvG,CAKI,OAFAR,SAAAA,EAAYO,YAAY,MAEjB,CAAEJ,8BAA6BM,OAAQG,EAEtD,CAUI,OAHIV,IACAF,SAAAA,EAAYO,YAAY,OAErB,CAAEJ,8BAA6BM,OAAQ,SAIzCI,EAAyB,CAACC,EAAUC,KAC7C,IAAKD,EAAU,OAAO,KAStB,OARoB1E,OAAOoB,QAAQsD,GAAUvE,OAAO,CAACC,GAAMe,EAAKd,MAC5D,GAAIA,EAAO,CAEPD,EADe,GAAGuE,IAAYxD,KAChBd,CAClB,CACA,OAAOD,GACR,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,n){if(null==e)throw new Error(n);return e}const n="https://checkoutshopper-live.adyen.com/checkoutshopper/",o=e("6.
|
|
1
|
+
function e(e,n){if(null==e)throw new Error(n);return e}const n="https://checkoutshopper-live.adyen.com/checkoutshopper/",o=e("6.45.0","LIBRARY_VERSION is not defined"),t=e("eslegacy","BUNDLE_TYPE is not defined"),r=["amount","secondaryAmount","countryCode","environment","_environmentUrls","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","donation","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onReview","onAction","onActionHandled","onAdditionalDetails","onChange","onEnterKeyPressed","onError","onBalanceCheck","onOrderCancel","onOrderRequest","onOrderUpdated","onPaymentMethodsRequest"],i=6e4;var d=function(e){return e.WEB="web",e}({});const a="web";var c=function(e){return e.NATIVE="nativeComponent",e.GENERIC="genericComponent",e}({});export{d as CHANNEL,i as DEFAULT_HTTP_TIMEOUT,n as FALLBACK_CONTEXT,r as GENERIC_OPTIONS,t as LIBRARY_BUNDLE_TYPE,o as LIBRARY_VERSION,c as PAYMENT_METHOD_BEHAVIOR,a as PLATFORM};
|
|
2
2
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/core/config.ts"],"sourcesContent":["/**\n * Asserts that a value is defined and throws an error if it is not.\n *\n * @param value The value to check.\n * @param message The error message to throw if the value is undefined.\n * @returns The value if it is defined.\n */\nfunction assertDefined<T>(value: T | undefined, message: string): T {\n if (value === undefined || value === null) {\n throw new Error(message);\n }\n return value;\n}\n\n/**\n * FALLBACK_CONTEXT\n */\nexport const FALLBACK_CONTEXT = 'https://checkoutshopper-live.adyen.com/checkoutshopper/';\n\n/**\n * Library version injected at build time.\n * Always defined - the build process ensures this value is set.\n */\nexport const LIBRARY_VERSION = assertDefined(process.env.VERSION, 'LIBRARY_VERSION is not defined');\n\n/**\n * Bundle type injected at build time.\n * Always defined - the build process ensures this value is set.\n */\nexport const LIBRARY_BUNDLE_TYPE = assertDefined(process.env.BUNDLE_TYPE, 'BUNDLE_TYPE is not defined');\n\nexport const GENERIC_OPTIONS = [\n 'amount',\n 'secondaryAmount',\n 'countryCode',\n 'environment',\n '_environmentUrls',\n 'loadingContext',\n 'i18n',\n 'modules',\n 'order',\n 'session',\n 'clientKey',\n 'showPayButton',\n 'redirectFromTopWhenInIframe',\n 'donation',\n\n // Events\n 'onPaymentCompleted',\n 'onPaymentFailed',\n 'beforeRedirect',\n 'beforeSubmit',\n 'onSubmit',\n 'onActionHandled',\n 'onAdditionalDetails',\n 'onChange',\n 'onEnterKeyPressed',\n 'onError',\n 'onBalanceCheck',\n 'onOrderCancel',\n 'onOrderRequest',\n 'onOrderUpdated',\n 'onPaymentMethodsRequest'\n];\n\nexport const DEFAULT_HTTP_TIMEOUT = 60000;\n\nexport default {\n FALLBACK_CONTEXT,\n GENERIC_OPTIONS,\n DEFAULT_HTTP_TIMEOUT\n};\n\n/**\n * @internal\n */\n\nexport enum CHANNEL {\n WEB = 'web'\n}\n\n/**\n * @internal\n */\nexport const PLATFORM = 'web';\n\n/**\n * How the SDK handles the rendering of a payment method.\n *\n * - NATIVE: The payment method has a dedicated component in the SDK.\n * - GENERIC: The payment method has no dedicated component; it falls back to a generic component (Redirect).\n * @internal\n */\nexport enum PAYMENT_METHOD_BEHAVIOR {\n NATIVE = 'nativeComponent',\n GENERIC = 'genericComponent'\n}\n"],"names":["assertDefined","value","message","Error","FALLBACK_CONTEXT","LIBRARY_VERSION","LIBRARY_BUNDLE_TYPE","GENERIC_OPTIONS","DEFAULT_HTTP_TIMEOUT","CHANNEL","PLATFORM","PAYMENT_METHOD_BEHAVIOR"],"mappings":"AAOA,SAASA,EAAiBC,EAAsBC,GAC5C,GAAID,QACA,MAAM,IAAIE,MAAMD,GAEpB,OAAOD,CACX,CAKO,MAAMG,EAAmB,0DAMnBC,EAAkBL,EAAc,SAAqB,kCAMrDM,EAAsBN,EAAc,WAAyB,8BAE7DO,EAAkB,CAC3B,SACA,kBACA,cACA,cACA,mBACA,iBACA,OACA,UACA,QACA,UACA,YACA,gBACA,8BACA,WAGA,qBACA,kBACA,iBACA,eACA,WACA,kBACA,sBACA,WACA,oBACA,UACA,iBACA,gBACA,iBACA,iBACA,2BAGSC,EAAuB,IAY7B,IAAKC,EAAAA,SAAAA,GAAAA,mBAAAA,CAEZ,CAFYA,CAEZ,CAAA,GAKO,MAAMC,EAAW,MASjB,IAAKC,EAAAA,SAAAA,GAAAA,+DAAAA,CAGZ,CAHYA,CAGZ,CAAA"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/core/config.ts"],"sourcesContent":["/**\n * Asserts that a value is defined and throws an error if it is not.\n *\n * @param value The value to check.\n * @param message The error message to throw if the value is undefined.\n * @returns The value if it is defined.\n */\nfunction assertDefined<T>(value: T | undefined, message: string): T {\n if (value === undefined || value === null) {\n throw new Error(message);\n }\n return value;\n}\n\n/**\n * FALLBACK_CONTEXT\n */\nexport const FALLBACK_CONTEXT = 'https://checkoutshopper-live.adyen.com/checkoutshopper/';\n\n/**\n * Library version injected at build time.\n * Always defined - the build process ensures this value is set.\n */\nexport const LIBRARY_VERSION = assertDefined(process.env.VERSION, 'LIBRARY_VERSION is not defined');\n\n/**\n * Bundle type injected at build time.\n * Always defined - the build process ensures this value is set.\n */\nexport const LIBRARY_BUNDLE_TYPE = assertDefined(process.env.BUNDLE_TYPE, 'BUNDLE_TYPE is not defined');\n\nexport const GENERIC_OPTIONS = [\n 'amount',\n 'secondaryAmount',\n 'countryCode',\n 'environment',\n '_environmentUrls',\n 'loadingContext',\n 'i18n',\n 'modules',\n 'order',\n 'session',\n 'clientKey',\n 'showPayButton',\n 'redirectFromTopWhenInIframe',\n 'donation',\n\n // Events\n 'onPaymentCompleted',\n 'onPaymentFailed',\n 'beforeRedirect',\n 'beforeSubmit',\n 'onSubmit',\n 'onReview',\n 'onAction',\n 'onActionHandled',\n 'onAdditionalDetails',\n 'onChange',\n 'onEnterKeyPressed',\n 'onError',\n 'onBalanceCheck',\n 'onOrderCancel',\n 'onOrderRequest',\n 'onOrderUpdated',\n 'onPaymentMethodsRequest'\n];\n\nexport const DEFAULT_HTTP_TIMEOUT = 60000;\n\nexport default {\n FALLBACK_CONTEXT,\n GENERIC_OPTIONS,\n DEFAULT_HTTP_TIMEOUT\n};\n\n/**\n * @internal\n */\n\nexport enum CHANNEL {\n WEB = 'web'\n}\n\n/**\n * @internal\n */\nexport const PLATFORM = 'web';\n\n/**\n * How the SDK handles the rendering of a payment method.\n *\n * - NATIVE: The payment method has a dedicated component in the SDK.\n * - GENERIC: The payment method has no dedicated component; it falls back to a generic component (Redirect).\n * @internal\n */\nexport enum PAYMENT_METHOD_BEHAVIOR {\n NATIVE = 'nativeComponent',\n GENERIC = 'genericComponent'\n}\n"],"names":["assertDefined","value","message","Error","FALLBACK_CONTEXT","LIBRARY_VERSION","LIBRARY_BUNDLE_TYPE","GENERIC_OPTIONS","DEFAULT_HTTP_TIMEOUT","CHANNEL","PLATFORM","PAYMENT_METHOD_BEHAVIOR"],"mappings":"AAOA,SAASA,EAAiBC,EAAsBC,GAC5C,GAAID,QACA,MAAM,IAAIE,MAAMD,GAEpB,OAAOD,CACX,CAKO,MAAMG,EAAmB,0DAMnBC,EAAkBL,EAAc,SAAqB,kCAMrDM,EAAsBN,EAAc,WAAyB,8BAE7DO,EAAkB,CAC3B,SACA,kBACA,cACA,cACA,mBACA,iBACA,OACA,UACA,QACA,UACA,YACA,gBACA,8BACA,WAGA,qBACA,kBACA,iBACA,eACA,WACA,WACA,WACA,kBACA,sBACA,WACA,oBACA,UACA,iBACA,gBACA,iBACA,iBACA,2BAGSC,EAAuB,IAY7B,IAAKC,EAAAA,SAAAA,GAAAA,mBAAAA,CAEZ,CAFYA,CAEZ,CAAA,GAKO,MAAMC,EAAW,MASjB,IAAKC,EAAAA,SAAAA,GAAAA,+DAAAA,CAGZ,CAHYA,CAGZ,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Language as t}from"../language/Language.js";import e from"./RiskModule/RiskModule.js";import o from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import n from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{processGlobalOptions as s,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import d from"./core.registry.js";import{sanitizeResponse as p,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{THREEDS2_FULL as v}from"../components/ThreeDS2/constants.js";import{defaultProps as g}from"./core.defaultProps.js";import{resolveEnvironments as b}from"./Environment/Environment.js";import{LIBRARY_BUNDLE_TYPE as w,LIBRARY_VERSION as C}from"./config.js";import{AnalyticsLogEvent as j,LogEventType as A}from"./Analytics/events/AnalyticsLogEvent.js";import O from"./Errors/CancelError.js";import{AnalyticsService as P}from"./Analytics/AnalyticsService.js";import{AnalyticsEventQueue as E}from"./Analytics/AnalyticsEventQueue.js";import{isAmountValid as T}from"../utils/amount-util.js";import{LanguageService as M}from"../language/LanguageService.js";function I(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function x(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),n.forEach(function(e){I(t,e,o[e])})}return t}function R(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}function k(t,e){if(null==t)return{};var o,n,i,s={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(Object(t)),i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(s[n]=t[n]);return s}if(s=function(t,e){if(null==t)return{};var o,n,i={},s=Object.getOwnPropertyNames(t);for(n=0;n<s.length;n++)o=s[n],e.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(i[o]=t[o]);return i}(t,e),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(t),i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(s[n]=t[n]);return s}class U{static setBundleType(t){U.metadata.bundleType=t}static register(...t){d.add(...t)}register(...t){d.add(...t)}getComponent(t){return d.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),this.createCoreModules(),this.assignLocaleToCore(),this.requestAnalyticsAttemptId(),await this.requestTranslations(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then(t=>{const{amount:e,shopperLocale:o,countryCode:n,paymentMethods:i}=t,s=k(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(R(x({},s),{amount:this.options.order?this.options.order.remainingAmount:e,locale:this.options.locale||o,countryCode:this.options.countryCode||n})),this.createPaymentMethodsList(i),this}).catch(t=>(this.options.onError&&this.options.onError(t),Promise.reject(t))):(this.createPaymentMethodsList(),Promise.resolve(this))}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.")}submitDetails(t){let e=null;var o,n;(this.options.onAdditionalDetails&&(e=new Promise((e,o)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:e,reject:o})})),this.session&&(e=this.session.submitDetails(t).catch(t=>{var e,o;return null===(e=(o=this.options).onError)||void 0===e||e.call(o,t),Promise.reject(t)})),e)?e.then(p).then(m).then(this.afterAdditionalDetails).then(t=>{var e,o;u(t),null===(e=(o=this.options).onPaymentCompleted)||void 0===e||e.call(o,t)}).catch(t=>{var e,o;t instanceof O||(u(t),null===(e=(o=this.options).onPaymentFailed)||void 0===e||e.call(o,t))}):null===(o=(n=this.options).onError)||void 0===o||o.call(n,new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,e={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const o=t.type===v?`${t.type}${t.subtype}`:t.paymentMethodType,i=new j({type:A.action,subType:j.getSubtypeFromActionType(t.type),message:`${o} action was handled by the SDK`,component:o});this.modules.analytics.sendAnalytics(i);const s=x({},this.getCorePropsForComponent(),e);return n(this,d,t,s)}return this.handleCreateError()}update(t={},{shouldReinitializeCheckout:e=!0}={}){if(e)return this.setOptions(t),this.initialize().then(()=>(this.components.forEach(e=>{var o;const n=x({},(null===(o=t.order)||void 0===o?void 0:o.remainingAmount)?{amount:t.order.remainingAmount}:{amount:this.options.amount},this.session&&{session:this.session},t);e.update(n)}),this));const{amount:o,secondaryAmount:n}=t;return(o||n)&&this.triggerAmountUpdate(o,n),Promise.resolve(this)}triggerAmountUpdate(t,e){T(t)?!e||T(e)?(this.setOptions(x({amount:t},e&&{secondaryAmount:e})),this.components.forEach(o=>{o.updateAmount(t,e)})):console.warn("Core update(): Update canceled. Invalid secondary amount object"):console.warn("Core update(): Update canceled. Invalid amount object")}getCorePropsForComponent(){return R(x({},s(this.options)),{core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){var e;const o=null!==(e=null==t?void 0:t.name)&&void 0!==e?e:"The passed payment method",n=t?`${o} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(n)}createPaymentMethodsList(t){this.paymentMethodsResponse=new o(this.options.paymentMethodsResponse||t,this.options)}createCoreModules(){var o,n,s;this.modules||(this.modules=Object.freeze({risk:new e(this,R(x({},this.options),{loadingContext:this.loadingContext})),analytics:new i({eventQueue:new E,service:new P({analyticsContext:this.analyticsContext,clientKey:this.options.clientKey}),enabled:null===(o=this.options.analytics)||void 0===o?void 0:o.enabled,analyticsData:null===(n=this.options.analytics)||void 0===n?void 0:n.analyticsData}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,customTranslations:this.options.translations,service:new M({cdnUrl:this.cdnTranslationsUrl,sdkVersion:U.metadata.version}),onError:null===(s=this.options)||void 0===s?void 0:s.onError}),srPanel:new h(this,x({},this.options.srConfig))}))}assignLocaleToCore(){this.options.locale=this.modules.i18n.locale}async requestTranslations(){try{await this.modules.i18n.requestTranslations()}catch(t){console.warn("Core - requestTranslations(): Something went wrong.",t)}}async requestAnalyticsAttemptId(){var t;await this.modules.analytics.setUp(x({locale:this.options.locale},(null===(t=this.session)||void 0===t?void 0:t.id)&&{sessionId:this.session.id}))}constructor(t){var e;I(this,"session",void 0),I(this,"paymentMethodsResponse",void 0),I(this,"modules",void 0),I(this,"options",void 0),I(this,"analyticsContext",void 0),I(this,"loadingContext",void 0),I(this,"cdnImagesUrl",void 0),I(this,"cdnTranslationsUrl",void 0),I(this,"components",[]),I(this,"afterAdditionalDetails",t=>{if(this.options.afterAdditionalDetails&&(null==t?void 0:t.action)){const e=this.createFromAction(t.action);return this.options.afterAdditionalDetails(e),Promise.reject(new O("Handled by afterAdditionalDetails"))}return Promise.resolve(t)}),I(this,"remove",t=>(this.components=this.components.filter(e=>e._id!==t._id),t.unmount(),this)),I(this,"setOptions",t=>{var e,o;this.options=R(x({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(e=this.options)||void 0===e?void 0:e.locale),environment:String.prototype.toLowerCase.apply((null==t?void 0:t.environment)||(null===(o=this.options)||void 0===o?void 0:o.environment))})}),r(t),this.createFromAction=this.createFromAction.bind(this),this.update=this.update.bind(this),this.setOptions(x({},g,t));const{apiUrl:o,analyticsUrl:n,cdnImagesUrl:i,cdnTranslationsUrl:s}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=n,this.cdnImagesUrl=i,this.cdnTranslationsUrl=s,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(e=this.options.clientKey)||void 0===e?void 0:e.substring(0,4);var c,h;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);"pub."===l&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${null===(h=this.options.clientKey)||void 0===h?void 0:h.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=U.metadata)}}I(U,"metadata",{version:C,bundleType:w}),I(U,"registry",d);export{U as default};
|
|
1
|
+
import{Language as t}from"../language/Language.js";import e from"./RiskModule/RiskModule.js";import o from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import n from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{processGlobalOptions as s,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as d}from"./Errors/SRPanel.js";import h from"./core.registry.js";import{sanitizeResponse as p,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as v}from"./Errors/AdyenCheckoutError.js";import{THREEDS2_FULL as f}from"../components/ThreeDS2/constants.js";import{defaultProps as g}from"./core.defaultProps.js";import{resolveEnvironments as b}from"./Environment/Environment.js";import{LIBRARY_BUNDLE_TYPE as w,LIBRARY_VERSION as C}from"./config.js";import{AnalyticsLogEvent as A,LogEventType as j,LogEventSubtype as O}from"./Analytics/events/AnalyticsLogEvent.js";import P from"./Errors/CancelError.js";import{AnalyticsService as E}from"./Analytics/AnalyticsService.js";import{AnalyticsEventQueue as T}from"./Analytics/AnalyticsEventQueue.js";import{isAmountValid as M}from"../utils/amount-util.js";import{LanguageService as R}from"../language/LanguageService.js";function I(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function k(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),n.forEach(function(e){I(t,e,o[e])})}return t}function x(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}function U(t,e){if(null==t)return{};var o,n,i,s={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(Object(t)),i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(s[n]=t[n]);return s}if(s=function(t,e){if(null==t)return{};var o,n,i={},s=Object.getOwnPropertyNames(t);for(n=0;n<s.length;n++)o=s[n],e.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(i[o]=t[o]);return i}(t,e),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(t),i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(s[n]=t[n]);return s}class S{static setBundleType(t){S.metadata.bundleType=t}static register(...t){h.add(...t)}register(...t){h.add(...t)}getComponent(t){return h.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),this.createCoreModules(),this.assignLocaleToCore(),this.requestAnalyticsAttemptId(),await this.requestTranslations(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then(t=>{const{amount:e,shopperLocale:o,countryCode:n,paymentMethods:i}=t,s=U(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(x(k({},s),{amount:this.options.order?this.options.order.remainingAmount:e,locale:this.options.locale||o,countryCode:this.options.countryCode||n})),this.createPaymentMethodsList(i),this}).catch(t=>(this.options.onError&&this.options.onError(t),Promise.reject(t))):(this.createPaymentMethodsList(),Promise.resolve(this))}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(v,"You must specify a countryCode when initializing checkout.")}submitDetails(t){let e=null;var o,n;(this.options.onAdditionalDetails&&(e=new Promise((e,o)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:e,reject:o})})),this.session&&(e=this.session.submitDetails(t).catch(t=>{var e,o;return null===(e=(o=this.options).onError)||void 0===e||e.call(o,t),Promise.reject(t)})),e)?e.then(p).then(m).then(this.afterAdditionalDetails).then(t=>{var e,o;u(t),null===(e=(o=this.options).onPaymentCompleted)||void 0===e||e.call(o,t)}).catch(t=>{var e,o;t instanceof P||(u(t),null===(e=(o=this.options).onPaymentFailed)||void 0===e||e.call(o,t))}):null===(o=(n=this.options).onError)||void 0===o||o.call(n,new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,e={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const o=t.type===f?`${t.type}${t.subtype}`:t.paymentMethodType,i=new A({type:j.action,subType:A.getSubtypeFromActionType(t.type),message:`${o} action was handled by the SDK`,component:o});this.modules.analytics.sendAnalytics(i);const s=k({},this.getCorePropsForComponent(),e);return n(this,h,t,s)}return this.handleCreateError()}update(t={},{shouldReinitializeCheckout:e=!0}={}){if(e)return this.setOptions(t),this.initialize().then(()=>(this.components.forEach(e=>{var o;const n=k({},(null===(o=t.order)||void 0===o?void 0:o.remainingAmount)?{amount:t.order.remainingAmount}:{amount:this.options.amount},this.session&&{session:this.session},t);e.update(n)}),this));const{amount:o,secondaryAmount:n}=t;return(o||n)&&this.triggerAmountUpdate(o,n),Promise.resolve(this)}triggerAmountUpdate(t,e){M(t)?!e||M(e)?(this.setOptions(k({amount:t},e&&{secondaryAmount:e})),this.components.forEach(o=>{o.updateAmount(t,e)})):console.warn("Core update(): Update canceled. Invalid secondary amount object"):console.warn("Core update(): Update canceled. Invalid amount object")}getCorePropsForComponent(){return x(k({},s(this.options)),{core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction})}processPayment(t){var e,o,n;if(!this.session)return void(null===(o=(n=this.options).onError)||void 0===o||o.call(n,new y("IMPLEMENTATION_ERROR","processPayment requires a session to be configured")));const i=new A({type:j.submit,subType:O.review,message:"Shopper clicked pay",component:null===(e=t.paymentMethod)||void 0===e?void 0:e.type});this.modules.analytics.sendAnalytics(i),this.session.submitPayment(t).then(p).then(m).then(t=>{var e,o,n,i;if(t.action){var s,r;if(this.options.onAction)this.options.onAction(this.createFromAction(t.action));else null===(s=(r=this.options).onError)||void 0===s||s.call(r,new y("IMPLEMENTATION_ERROR","onAction callback is required to handle payment actions"));return}const a=t.order;var l,c;a&&(null!==(e=null===(o=a.remainingAmount)||void 0===o?void 0:o.value)&&void 0!==e?e:0)>0?null===(l=(c=this.options).onOrderUpdated)||void 0===l||l.call(c,{order:a}):(u(t),null===(n=(i=this.options).onPaymentCompleted)||void 0===n||n.call(i,t))}).catch(t=>{var e,o;t instanceof P||(u(t),null===(e=(o=this.options).onPaymentFailed)||void 0===e||e.call(o,t))})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){var e;const o=null!==(e=null==t?void 0:t.name)&&void 0!==e?e:"The passed payment method",n=t?`${o} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(n)}createPaymentMethodsList(t){this.paymentMethodsResponse=new o(this.options.paymentMethodsResponse||t,this.options)}createCoreModules(){var o,n,s;this.modules||(this.modules=Object.freeze({risk:new e(this,x(k({},this.options),{loadingContext:this.loadingContext})),analytics:new i({eventQueue:new T,service:new E({analyticsContext:this.analyticsContext,clientKey:this.options.clientKey}),enabled:null===(o=this.options.analytics)||void 0===o?void 0:o.enabled,analyticsData:null===(n=this.options.analytics)||void 0===n?void 0:n.analyticsData}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,customTranslations:this.options.translations,service:new R({cdnUrl:this.cdnTranslationsUrl,sdkVersion:S.metadata.version}),onError:null===(s=this.options)||void 0===s?void 0:s.onError}),srPanel:new d(this,k({},this.options.srConfig))}))}assignLocaleToCore(){this.options.locale=this.modules.i18n.locale}async requestTranslations(){try{await this.modules.i18n.requestTranslations()}catch(t){console.warn("Core - requestTranslations(): Something went wrong.",t)}}async requestAnalyticsAttemptId(){var t;await this.modules.analytics.setUp(k({locale:this.options.locale},(null===(t=this.session)||void 0===t?void 0:t.id)&&{sessionId:this.session.id}))}constructor(t){var e;I(this,"session",void 0),I(this,"paymentMethodsResponse",void 0),I(this,"modules",void 0),I(this,"options",void 0),I(this,"analyticsContext",void 0),I(this,"loadingContext",void 0),I(this,"cdnImagesUrl",void 0),I(this,"cdnTranslationsUrl",void 0),I(this,"components",[]),I(this,"afterAdditionalDetails",t=>{if(this.options.afterAdditionalDetails&&(null==t?void 0:t.action)){const e=this.createFromAction(t.action);return this.options.afterAdditionalDetails(e),Promise.reject(new P("Handled by afterAdditionalDetails"))}return Promise.resolve(t)}),I(this,"remove",t=>(this.components=this.components.filter(e=>e._id!==t._id),t.unmount(),this)),I(this,"setOptions",t=>{var e,o;this.options=x(k({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(e=this.options)||void 0===e?void 0:e.locale),environment:String.prototype.toLowerCase.apply((null==t?void 0:t.environment)||(null===(o=this.options)||void 0===o?void 0:o.environment))})}),r(t),this.createFromAction=this.createFromAction.bind(this),this.update=this.update.bind(this),this.setOptions(k({},g,t));const{apiUrl:o,analyticsUrl:n,cdnImagesUrl:i,cdnTranslationsUrl:s}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=n,this.cdnImagesUrl=i,this.cdnTranslationsUrl=s,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(e=this.options.clientKey)||void 0===e?void 0:e.substring(0,4);var c,d;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);"pub."===l&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${null===(d=this.options.clientKey)||void 0===d?void 0:d.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=S.metadata)}}I(S,"metadata",{version:C,bundleType:w}),I(S,"registry",h);export{S as default};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../../../src/core/core.ts"],"sourcesContent":["import Language from '../language';\nimport UIElement from '../components/internal/UIElement/UIElement';\nimport RiskModule from './RiskModule';\nimport PaymentMethods from './ProcessResponse/PaymentMethods';\nimport getComponentForAction from './ProcessResponse/PaymentAction';\nimport Analytics from './Analytics';\nimport { assertConfigurationPropertiesAreValid, processGlobalOptions } from './utils';\nimport Session from './CheckoutSession';\nimport { hasOwnProperty } from '../utils/hasOwnProperty';\nimport { Resources } from './Context/Resources';\nimport { SRPanel } from './Errors/SRPanel';\nimport registry, { NewableComponent } from './core.registry';\nimport { cleanupFinalResult, sanitizeResponse, verifyPaymentDidNotFail } from '../components/internal/UIElement/utils';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from './Errors/AdyenCheckoutError';\nimport { THREEDS2_FULL } from '../components/ThreeDS2/constants';\nimport { defaultProps } from './core.defaultProps';\nimport { resolveEnvironments } from './Environment';\nimport { LIBRARY_BUNDLE_TYPE, LIBRARY_VERSION } from './config';\n\nimport type { PaymentAction, PaymentAmount, PaymentResponseData } from '../types/global-types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData, CoreModules } from './types';\nimport type { UIElementProps } from '../components/internal/UIElement/types';\nimport { AnalyticsLogEvent, LogEventType } from './Analytics/events/AnalyticsLogEvent';\nimport CancelError from './Errors/CancelError';\nimport { AnalyticsService } from './Analytics/AnalyticsService';\nimport { AnalyticsEventQueue } from './Analytics/AnalyticsEventQueue';\nimport { isAmountValid } from '../utils/amount-util';\nimport { LanguageService } from '../language/LanguageService';\n\nclass Core implements ICore {\n public session?: Session;\n public paymentMethodsResponse: PaymentMethods;\n public modules: CoreModules;\n public options: CoreConfiguration;\n\n public analyticsContext: string;\n public loadingContext: string;\n public cdnImagesUrl: string;\n public cdnTranslationsUrl: string;\n\n private components: UIElement[] = [];\n\n public static readonly metadata: { version: string; bundleType: string } = {\n version: LIBRARY_VERSION,\n bundleType: LIBRARY_BUNDLE_TYPE\n };\n\n public static readonly registry = registry;\n\n public static setBundleType(type: string): void {\n Core.metadata.bundleType = type;\n }\n\n public static register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n /**\n * Used internally by the PaymentMethod components to auto-register themselves\n * @internal\n */\n public register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n public getComponent(txVariant: string) {\n return registry.getComponent(txVariant);\n }\n\n constructor(props: CoreConfiguration) {\n assertConfigurationPropertiesAreValid(props);\n\n this.createFromAction = this.createFromAction.bind(this);\n this.update = this.update.bind(this);\n\n this.setOptions({ ...defaultProps, ...props });\n\n const { apiUrl, analyticsUrl, cdnImagesUrl, cdnTranslationsUrl } = resolveEnvironments(\n this.options.environment,\n this.options._environmentUrls\n );\n\n this.loadingContext = apiUrl;\n this.analyticsContext = analyticsUrl;\n this.cdnImagesUrl = cdnImagesUrl;\n this.cdnTranslationsUrl = cdnTranslationsUrl;\n\n this.session = this.options.session && new Session(this.options.session, this.options.clientKey, this.loadingContext);\n\n const clientKeyType = this.options.clientKey?.substring(0, 4);\n if ((clientKeyType === 'test' || clientKeyType === 'live') && !this.loadingContext.includes(clientKeyType)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Error: you are using a ${clientKeyType} clientKey against the ${this.options._environmentUrls?.api || this.options.environment} environment`\n );\n }\n if (clientKeyType === 'pub.') {\n console.debug(\n `The value you are passing as your \"clientKey\" looks like an originKey (${this.options.clientKey?.substring(0, 12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`\n );\n }\n\n if (this.options.exposeLibraryMetadata) {\n window['AdyenWebMetadata'] = Core.metadata;\n }\n }\n\n public async initialize(): Promise<this> {\n await this.initializeCore();\n this.validateCoreConfiguration();\n this.createCoreModules();\n this.assignLocaleToCore();\n void this.requestAnalyticsAttemptId();\n await this.requestTranslations();\n return this;\n }\n\n private async initializeCore(): Promise<this> {\n if (this.session) {\n return this.session\n .setupSession(this.options)\n .then(sessionResponse => {\n const { amount, shopperLocale, countryCode, paymentMethods, ...rest } = sessionResponse;\n\n this.setOptions({\n ...rest,\n amount: this.options.order ? this.options.order.remainingAmount : amount,\n locale: this.options.locale || shopperLocale,\n countryCode: this.options.countryCode || countryCode\n });\n\n this.createPaymentMethodsList(paymentMethods);\n\n return this;\n })\n .catch(error => {\n if (this.options.onError) this.options.onError(error);\n return Promise.reject(error);\n });\n }\n\n this.createPaymentMethodsList();\n return Promise.resolve(this);\n }\n\n private validateCoreConfiguration(): void {\n // @ts-ignore This property does not exist, although merchants might be using when migrating from v5 to v6\n if (this.options.paymentMethodsConfiguration) {\n console.warn('WARNING: \"paymentMethodsConfiguration\" is supported only by Drop-in.');\n }\n\n if (!this.options.countryCode) {\n throw new AdyenCheckoutError(IMPLEMENTATION_ERROR, 'You must specify a countryCode when initializing checkout.');\n }\n }\n\n /**\n * Method used when handling redirects. It submits details using 'onAdditionalDetails' or the Sessions flow if available.\n *\n * @public\n * @see {https://docs.adyen.com/online-payments/build-your-integration/?platform=Web&integration=Components&version=5.55.1#handle-the-redirect}\n * @param details - Details object containing the redirectResult\n */\n public submitDetails(details: AdditionalDetailsData['data']): void {\n let promise = null;\n\n if (this.options.onAdditionalDetails) {\n promise = new Promise((resolve, reject) => {\n this.options.onAdditionalDetails({ data: details }, undefined, { resolve, reject });\n });\n }\n\n if (this.session) {\n promise = this.session.submitDetails(details).catch(error => {\n this.options.onError?.(error);\n return Promise.reject(error);\n });\n }\n\n if (!promise) {\n this.options.onError?.(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not submit the details. The callback \"onAdditionalDetails\" or the Session is not setup correctly.'\n )\n );\n return;\n }\n\n promise\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.afterAdditionalDetails)\n .then((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n return;\n }\n\n cleanupFinalResult(e as PaymentResponseData);\n this.options.onPaymentFailed?.(e as PaymentResponseData);\n });\n }\n\n private readonly afterAdditionalDetails = (response: PaymentResponseData): Promise<PaymentResponseData | Error> => {\n /**\n * After the user is redirected back, a request to `/details` or `/paymentDetails` will be made.\n * Typically, the response will not include an action object, except for the case of `paybybank_pix` payment method.\n * In terms of `paybybank_pix`, the action UIElement will be created and passed to the `afterAdditionalDetails` callback, allowing it to be mounted on the page.\n */\n if (this.options.afterAdditionalDetails && response?.action) {\n const actionEle = this.createFromAction(response.action);\n this.options.afterAdditionalDetails(actionEle);\n return Promise.reject(new CancelError('Handled by afterAdditionalDetails'));\n }\n return Promise.resolve(response);\n };\n\n /**\n * Instantiates a new element component ready to be mounted from an action object\n *\n * @param action - action defining the component with the component data\n * @param options - options that will be merged to the global Checkout props\n * @returns new UIElement\n */\n public createFromAction(action: PaymentAction, options = {}): UIElement {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'createFromAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('createFromAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type) {\n // 'threeDS2' OR 'qrCode', 'voucher', 'redirect', 'await', 'bankTransfer`\n const component = action.type === THREEDS2_FULL ? `${action.type}${action.subtype}` : action.paymentMethodType;\n\n const event = new AnalyticsLogEvent({\n type: LogEventType.action,\n subType: AnalyticsLogEvent.getSubtypeFromActionType(action.type),\n message: `${component} action was handled by the SDK`,\n component\n });\n this.modules.analytics.sendAnalytics(event);\n\n const props = {\n ...this.getCorePropsForComponent(),\n ...options\n };\n\n return getComponentForAction(this, registry, action, props);\n }\n\n return this.handleCreateError();\n }\n\n /**\n * Updates global configurations, resets the internal state and remounts each element.\n *\n * @param props - props to update\n * @param options - Can be used to avoid remounting the elements\n * @returns this - the Core instance\n */\n public update(props: Partial<Omit<CoreConfiguration, 'session'>> = {}, { shouldReinitializeCheckout = true } = {}): Promise<this> {\n if (shouldReinitializeCheckout) {\n this.setOptions(props);\n\n return this.initialize().then(() => {\n this.components.forEach(component => {\n // We update only with the new options that have been received\n const newProps: Partial<UIElementProps> = {\n ...(props.order?.remainingAmount ? { amount: props.order.remainingAmount } : { amount: this.options.amount }),\n ...(this.session && { session: this.session }),\n ...props\n };\n component.update(newProps);\n });\n return this;\n });\n }\n\n const { amount, secondaryAmount } = props;\n\n if (amount || secondaryAmount) {\n this.triggerAmountUpdate(amount, secondaryAmount);\n }\n\n return Promise.resolve(this);\n }\n\n /**\n * Validates and propagates amount updates to all mounted components.\n *\n * @param amount - Primary payment amount object (required)\n * @param secondaryAmount - Optional secondary amount for display purposes (e.g., converted currency)\n * @internal\n */\n private triggerAmountUpdate(amount: PaymentAmount, secondaryAmount?: PaymentAmount): void {\n if (!isAmountValid(amount)) {\n console.warn('Core update(): Update canceled. Invalid amount object');\n return;\n }\n\n if (secondaryAmount && !isAmountValid(secondaryAmount)) {\n console.warn('Core update(): Update canceled. Invalid secondary amount object');\n return;\n }\n\n this.setOptions({\n amount,\n ...(secondaryAmount && { secondaryAmount })\n });\n\n this.components.forEach(component => {\n component.updateAmount(amount, secondaryAmount);\n });\n }\n\n /**\n * Remove the reference of a component\n * @param component - reference to the component to be removed\n * @returns this - the element instance\n * // TODO: Do we need this?\n */\n public remove = (component): this => {\n this.components = this.components.filter(c => c._id !== component._id);\n component.unmount();\n\n return this;\n };\n\n /**\n * @internal\n * Create or update the config object passed when AdyenCheckout is initialised (environment, clientKey, etc...)\n */\n private setOptions = (options: CoreConfiguration): void => {\n this.options = {\n ...this.options,\n ...options,\n locale: options?.locale || this.options?.locale,\n // Make environment lowercase to ensure consistency\n environment: String.prototype.toLowerCase.apply(options?.environment || this.options?.environment)\n };\n };\n\n /**\n * @internal\n * @returns props for a new UIElement\n */\n public getCorePropsForComponent(): any {\n const globalOptions = processGlobalOptions(this.options);\n\n return {\n ...globalOptions,\n core: this,\n i18n: this.modules.i18n,\n modules: this.modules,\n session: this.session,\n loadingContext: this.loadingContext,\n cdnContext: this.cdnImagesUrl,\n createFromAction: this.createFromAction\n };\n }\n\n public storeElementReference(element: UIElement) {\n if (element) {\n this.components.push(element);\n }\n }\n\n /**\n * @internal\n */\n private handleCreateError(paymentMethod?): never {\n const paymentMethodName = paymentMethod?.name ?? 'The passed payment method';\n const errorMessage = paymentMethod\n ? `${paymentMethodName} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(\n paymentMethod\n )}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`\n : 'No Payment Method component was passed';\n\n throw new Error(errorMessage);\n }\n\n private createPaymentMethodsList(paymentMethodsResponse?: PaymentMethods): void {\n this.paymentMethodsResponse = new PaymentMethods(this.options.paymentMethodsResponse || paymentMethodsResponse, this.options);\n }\n\n private createCoreModules(): void {\n if (this.modules) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Core: Core modules are already created.');\n }\n return;\n }\n\n this.modules = Object.freeze({\n risk: new RiskModule(this, { ...this.options, loadingContext: this.loadingContext }),\n analytics: new Analytics({\n eventQueue: new AnalyticsEventQueue(),\n service: new AnalyticsService({\n analyticsContext: this.analyticsContext,\n clientKey: this.options.clientKey\n }),\n enabled: this.options.analytics?.enabled,\n analyticsData: this.options.analytics?.analyticsData\n }),\n resources: new Resources(this.cdnImagesUrl),\n i18n: new Language({\n locale: this.options.locale,\n customTranslations: this.options.translations,\n service: new LanguageService({\n cdnUrl: this.cdnTranslationsUrl,\n sdkVersion: Core.metadata.version\n }),\n onError: this.options?.onError\n }),\n srPanel: new SRPanel(this, { ...this.options.srConfig })\n });\n }\n\n /**\n * Retrieve the parsed locale from the i18n module and assigns it to the core options.\n */\n private assignLocaleToCore(): void {\n this.options.locale = this.modules.i18n.locale;\n }\n\n /**\n * Request translations to the CDN. If an error occurs, it will be logged to the console in development mode.\n */\n private async requestTranslations(): Promise<void> {\n try {\n await this.modules.i18n.requestTranslations();\n } catch (error: unknown) {\n console.warn('Core - requestTranslations(): Something went wrong.', error);\n }\n }\n\n private async requestAnalyticsAttemptId(): Promise<void> {\n await this.modules.analytics.setUp({\n locale: this.options.locale,\n ...(this.session?.id && { sessionId: this.session.id })\n });\n }\n}\n\nexport default Core;\n"],"names":["Core","setBundleType","type","metadata","bundleType","register","items","registry","add","getComponent","txVariant","initialize","this","initializeCore","validateCoreConfiguration","createCoreModules","assignLocaleToCore","requestAnalyticsAttemptId","requestTranslations","session","setupSession","options","then","sessionResponse","amount","shopperLocale","countryCode","paymentMethods","rest","setOptions","_object_spread_props","_object_spread","order","remainingAmount","locale","createPaymentMethodsList","catch","error","onError","Promise","reject","resolve","paymentMethodsConfiguration","console","warn","AdyenCheckoutError","IMPLEMENTATION_ERROR","submitDetails","details","promise","_this_options_onError","_this_options","onAdditionalDetails","data","undefined","call","sanitizeResponse","verifyPaymentDidNotFail","afterAdditionalDetails","response","_this_options_onPaymentCompleted","cleanupFinalResult","onPaymentCompleted","e","_this_options_onPaymentFailed","CancelError","onPaymentFailed","createFromAction","action","hasOwnProperty","Error","component","THREEDS2_FULL","subtype","paymentMethodType","event","AnalyticsLogEvent","LogEventType","subType","getSubtypeFromActionType","message","modules","analytics","sendAnalytics","props","getCorePropsForComponent","getComponentForAction","handleCreateError","update","shouldReinitializeCheckout","components","forEach","newProps","secondaryAmount","triggerAmountUpdate","isAmountValid","updateAmount","processGlobalOptions","globalOptions","core","i18n","loadingContext","cdnContext","cdnImagesUrl","storeElementReference","element","push","paymentMethod","paymentMethodName","name","_ref","errorMessage","JSON","stringify","paymentMethodsResponse","PaymentMethods","_this_options_analytics","_this_options_analytics1","Object","freeze","risk","RiskModule","Analytics","eventQueue","AnalyticsEventQueue","service","AnalyticsService","analyticsContext","clientKey","enabled","analyticsData","resources","Resources","Language","customTranslations","translations","LanguageService","cdnUrl","cdnTranslationsUrl","sdkVersion","version","srPanel","SRPanel","srConfig","_this_session","setUp","id","sessionId","constructor","_this_options_clientKey","_define_property","actionEle","remove","filter","c","_id","unmount","_this_options1","environment","String","prototype","toLowerCase","apply","assertConfigurationPropertiesAreValid","bind","defaultProps","apiUrl","analyticsUrl","resolveEnvironments","_environmentUrls","Session","clientKeyType","substring","_this_options__environmentUrls","_this_options_clientKey1","includes","api","debug","exposeLibraryMetadata","window","LIBRARY_VERSION","LIBRARY_BUNDLE_TYPE"],"mappings":"k1FA6BA,MAAMA,EAoBF,oBAAcC,CAAcC,GACxBF,EAAKG,SAASC,WAAaF,CAC/B,CAEA,eAAcG,IAAYC,GACtBC,EAASC,OAAOF,EACpB,CAMA,QAAAD,IAAmBC,GACfC,EAASC,OAAOF,E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from '../components/internal/UIElement/UIElement';\nimport RiskModule from './RiskModule';\nimport PaymentMethods from './ProcessResponse/PaymentMethods';\nimport getComponentForAction from './ProcessResponse/PaymentAction';\nimport Analytics from './Analytics';\nimport { assertConfigurationPropertiesAreValid, processGlobalOptions } from './utils';\nimport Session from './CheckoutSession';\nimport { hasOwnProperty } from '../utils/hasOwnProperty';\nimport { Resources } from './Context/Resources';\nimport { SRPanel } from './Errors/SRPanel';\nimport registry, { NewableComponent } from './core.registry';\nimport { cleanupFinalResult, sanitizeResponse, verifyPaymentDidNotFail } from '../components/internal/UIElement/utils';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from './Errors/AdyenCheckoutError';\nimport { THREEDS2_FULL } from '../components/ThreeDS2/constants';\nimport { defaultProps } from './core.defaultProps';\nimport { resolveEnvironments } from './Environment';\nimport { LIBRARY_BUNDLE_TYPE, LIBRARY_VERSION } from './config';\n\nimport type { PaymentAction, PaymentAmount, PaymentData, PaymentResponseData } from '../types/global-types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData, CoreModules } from './types';\nimport type { UIElementProps } from '../components/internal/UIElement/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from './Analytics/events/AnalyticsLogEvent';\nimport CancelError from './Errors/CancelError';\nimport { AnalyticsService } from './Analytics/AnalyticsService';\nimport { AnalyticsEventQueue } from './Analytics/AnalyticsEventQueue';\nimport { isAmountValid } from '../utils/amount-util';\nimport { LanguageService } from '../language/LanguageService';\n\nclass Core implements ICore {\n public session?: Session;\n public paymentMethodsResponse: PaymentMethods;\n public modules: CoreModules;\n public options: CoreConfiguration;\n\n public analyticsContext: string;\n public loadingContext: string;\n public cdnImagesUrl: string;\n public cdnTranslationsUrl: string;\n\n private components: UIElement[] = [];\n\n public static readonly metadata: { version: string; bundleType: string } = {\n version: LIBRARY_VERSION,\n bundleType: LIBRARY_BUNDLE_TYPE\n };\n\n public static readonly registry = registry;\n\n public static setBundleType(type: string): void {\n Core.metadata.bundleType = type;\n }\n\n public static register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n /**\n * Used internally by the PaymentMethod components to auto-register themselves\n * @internal\n */\n public register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n public getComponent(txVariant: string) {\n return registry.getComponent(txVariant);\n }\n\n constructor(props: CoreConfiguration) {\n assertConfigurationPropertiesAreValid(props);\n\n this.createFromAction = this.createFromAction.bind(this);\n this.update = this.update.bind(this);\n\n this.setOptions({ ...defaultProps, ...props });\n\n const { apiUrl, analyticsUrl, cdnImagesUrl, cdnTranslationsUrl } = resolveEnvironments(\n this.options.environment,\n this.options._environmentUrls\n );\n\n this.loadingContext = apiUrl;\n this.analyticsContext = analyticsUrl;\n this.cdnImagesUrl = cdnImagesUrl;\n this.cdnTranslationsUrl = cdnTranslationsUrl;\n\n this.session = this.options.session && new Session(this.options.session, this.options.clientKey, this.loadingContext);\n\n const clientKeyType = this.options.clientKey?.substring(0, 4);\n if ((clientKeyType === 'test' || clientKeyType === 'live') && !this.loadingContext.includes(clientKeyType)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Error: you are using a ${clientKeyType} clientKey against the ${this.options._environmentUrls?.api || this.options.environment} environment`\n );\n }\n if (clientKeyType === 'pub.') {\n console.debug(\n `The value you are passing as your \"clientKey\" looks like an originKey (${this.options.clientKey?.substring(0, 12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`\n );\n }\n\n if (this.options.exposeLibraryMetadata) {\n window['AdyenWebMetadata'] = Core.metadata;\n }\n }\n\n public async initialize(): Promise<this> {\n await this.initializeCore();\n this.validateCoreConfiguration();\n this.createCoreModules();\n this.assignLocaleToCore();\n void this.requestAnalyticsAttemptId();\n await this.requestTranslations();\n return this;\n }\n\n private async initializeCore(): Promise<this> {\n if (this.session) {\n return this.session\n .setupSession(this.options)\n .then(sessionResponse => {\n const { amount, shopperLocale, countryCode, paymentMethods, ...rest } = sessionResponse;\n\n this.setOptions({\n ...rest,\n amount: this.options.order ? this.options.order.remainingAmount : amount,\n locale: this.options.locale || shopperLocale,\n countryCode: this.options.countryCode || countryCode\n });\n\n this.createPaymentMethodsList(paymentMethods);\n\n return this;\n })\n .catch(error => {\n if (this.options.onError) this.options.onError(error);\n return Promise.reject(error);\n });\n }\n\n this.createPaymentMethodsList();\n return Promise.resolve(this);\n }\n\n private validateCoreConfiguration(): void {\n // @ts-ignore This property does not exist, although merchants might be using when migrating from v5 to v6\n if (this.options.paymentMethodsConfiguration) {\n console.warn('WARNING: \"paymentMethodsConfiguration\" is supported only by Drop-in.');\n }\n\n if (!this.options.countryCode) {\n throw new AdyenCheckoutError(IMPLEMENTATION_ERROR, 'You must specify a countryCode when initializing checkout.');\n }\n }\n\n /**\n * Method used when handling redirects. It submits details using 'onAdditionalDetails' or the Sessions flow if available.\n *\n * @public\n * @see {https://docs.adyen.com/online-payments/build-your-integration/?platform=Web&integration=Components&version=5.55.1#handle-the-redirect}\n * @param details - Details object containing the redirectResult\n */\n public submitDetails(details: AdditionalDetailsData['data']): void {\n let promise = null;\n\n if (this.options.onAdditionalDetails) {\n promise = new Promise((resolve, reject) => {\n this.options.onAdditionalDetails({ data: details }, undefined, { resolve, reject });\n });\n }\n\n if (this.session) {\n promise = this.session.submitDetails(details).catch(error => {\n this.options.onError?.(error);\n return Promise.reject(error);\n });\n }\n\n if (!promise) {\n this.options.onError?.(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not submit the details. The callback \"onAdditionalDetails\" or the Session is not setup correctly.'\n )\n );\n return;\n }\n\n promise\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.afterAdditionalDetails)\n .then((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n return;\n }\n\n cleanupFinalResult(e as PaymentResponseData);\n this.options.onPaymentFailed?.(e as PaymentResponseData);\n });\n }\n\n private readonly afterAdditionalDetails = (response: PaymentResponseData): Promise<PaymentResponseData | Error> => {\n /**\n * After the user is redirected back, a request to `/details` or `/paymentDetails` will be made.\n * Typically, the response will not include an action object, except for the case of `paybybank_pix` payment method.\n * In terms of `paybybank_pix`, the action UIElement will be created and passed to the `afterAdditionalDetails` callback, allowing it to be mounted on the page.\n */\n if (this.options.afterAdditionalDetails && response?.action) {\n const actionEle = this.createFromAction(response.action);\n this.options.afterAdditionalDetails(actionEle);\n return Promise.reject(new CancelError('Handled by afterAdditionalDetails'));\n }\n return Promise.resolve(response);\n };\n\n /**\n * Instantiates a new element component ready to be mounted from an action object\n *\n * @param action - action defining the component with the component data\n * @param options - options that will be merged to the global Checkout props\n * @returns new UIElement\n */\n public createFromAction(action: PaymentAction, options = {}): UIElement {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'createFromAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('createFromAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type) {\n // 'threeDS2' OR 'qrCode', 'voucher', 'redirect', 'await', 'bankTransfer`\n const component = action.type === THREEDS2_FULL ? `${action.type}${action.subtype}` : action.paymentMethodType;\n\n const event = new AnalyticsLogEvent({\n type: LogEventType.action,\n subType: AnalyticsLogEvent.getSubtypeFromActionType(action.type),\n message: `${component} action was handled by the SDK`,\n component\n });\n this.modules.analytics.sendAnalytics(event);\n\n const props = {\n ...this.getCorePropsForComponent(),\n ...options\n };\n\n return getComponentForAction(this, registry, action, props);\n }\n\n return this.handleCreateError();\n }\n\n /**\n * Updates global configurations, resets the internal state and remounts each element.\n *\n * @param props - props to update\n * @param options - Can be used to avoid remounting the elements\n * @returns this - the Core instance\n */\n public update(props: Partial<Omit<CoreConfiguration, 'session'>> = {}, { shouldReinitializeCheckout = true } = {}): Promise<this> {\n if (shouldReinitializeCheckout) {\n this.setOptions(props);\n\n return this.initialize().then(() => {\n this.components.forEach(component => {\n // We update only with the new options that have been received\n const newProps: Partial<UIElementProps> = {\n ...(props.order?.remainingAmount ? { amount: props.order.remainingAmount } : { amount: this.options.amount }),\n ...(this.session && { session: this.session }),\n ...props\n };\n component.update(newProps);\n });\n return this;\n });\n }\n\n const { amount, secondaryAmount } = props;\n\n if (amount || secondaryAmount) {\n this.triggerAmountUpdate(amount, secondaryAmount);\n }\n\n return Promise.resolve(this);\n }\n\n /**\n * Validates and propagates amount updates to all mounted components.\n *\n * @param amount - Primary payment amount object (required)\n * @param secondaryAmount - Optional secondary amount for display purposes (e.g., converted currency)\n * @internal\n */\n private triggerAmountUpdate(amount: PaymentAmount, secondaryAmount?: PaymentAmount): void {\n if (!isAmountValid(amount)) {\n console.warn('Core update(): Update canceled. Invalid amount object');\n return;\n }\n\n if (secondaryAmount && !isAmountValid(secondaryAmount)) {\n console.warn('Core update(): Update canceled. Invalid secondary amount object');\n return;\n }\n\n this.setOptions({\n amount,\n ...(secondaryAmount && { secondaryAmount })\n });\n\n this.components.forEach(component => {\n component.updateAmount(amount, secondaryAmount);\n });\n }\n\n /**\n * Remove the reference of a component\n * @param component - reference to the component to be removed\n * @returns this - the element instance\n * // TODO: Do we need this?\n */\n public remove = (component): this => {\n this.components = this.components.filter(c => c._id !== component._id);\n component.unmount();\n\n return this;\n };\n\n /**\n * @internal\n * Create or update the config object passed when AdyenCheckout is initialised (environment, clientKey, etc...)\n */\n private setOptions = (options: CoreConfiguration): void => {\n this.options = {\n ...this.options,\n ...options,\n locale: options?.locale || this.options?.locale,\n // Make environment lowercase to ensure consistency\n environment: String.prototype.toLowerCase.apply(options?.environment || this.options?.environment)\n };\n };\n\n /**\n * @internal\n * @returns props for a new UIElement\n */\n public getCorePropsForComponent(): any {\n const globalOptions = processGlobalOptions(this.options);\n\n return {\n ...globalOptions,\n core: this,\n i18n: this.modules.i18n,\n modules: this.modules,\n session: this.session,\n loadingContext: this.loadingContext,\n cdnContext: this.cdnImagesUrl,\n createFromAction: this.createFromAction\n };\n }\n\n public processPayment(data: PaymentData): void {\n if (!this.session) {\n this.options.onError?.(new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'processPayment requires a session to be configured'));\n return;\n }\n\n const event = new AnalyticsLogEvent({\n type: LogEventType.submit,\n subType: LogEventSubtype.review,\n message: 'Shopper clicked pay',\n component: data.paymentMethod?.type\n });\n\n this.modules.analytics.sendAnalytics(event);\n\n this.session\n .submitPayment(data)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((response: PaymentResponseData) => {\n if (response.action) {\n if (this.options.onAction) {\n this.options.onAction(this.createFromAction(response.action));\n } else {\n this.options.onError?.(\n new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onAction callback is required to handle payment actions')\n );\n }\n return;\n }\n const order = response.order;\n if (order && (order.remainingAmount?.value ?? 0) > 0) {\n this.options.onOrderUpdated?.({ order });\n return;\n }\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) return;\n cleanupFinalResult(e as PaymentResponseData);\n this.options.onPaymentFailed?.(e as PaymentResponseData);\n });\n }\n\n public storeElementReference(element: UIElement) {\n if (element) {\n this.components.push(element);\n }\n }\n\n /**\n * @internal\n */\n private handleCreateError(paymentMethod?): never {\n const paymentMethodName = paymentMethod?.name ?? 'The passed payment method';\n const errorMessage = paymentMethod\n ? `${paymentMethodName} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(\n paymentMethod\n )}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`\n : 'No Payment Method component was passed';\n\n throw new Error(errorMessage);\n }\n\n private createPaymentMethodsList(paymentMethodsResponse?: PaymentMethods): void {\n this.paymentMethodsResponse = new PaymentMethods(this.options.paymentMethodsResponse || paymentMethodsResponse, this.options);\n }\n\n private createCoreModules(): void {\n if (this.modules) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Core: Core modules are already created.');\n }\n return;\n }\n\n this.modules = Object.freeze({\n risk: new RiskModule(this, { ...this.options, loadingContext: this.loadingContext }),\n analytics: new Analytics({\n eventQueue: new AnalyticsEventQueue(),\n service: new AnalyticsService({\n analyticsContext: this.analyticsContext,\n clientKey: this.options.clientKey\n }),\n enabled: this.options.analytics?.enabled,\n analyticsData: this.options.analytics?.analyticsData\n }),\n resources: new Resources(this.cdnImagesUrl),\n i18n: new Language({\n locale: this.options.locale,\n customTranslations: this.options.translations,\n service: new LanguageService({\n cdnUrl: this.cdnTranslationsUrl,\n sdkVersion: Core.metadata.version\n }),\n onError: this.options?.onError\n }),\n srPanel: new SRPanel(this, { ...this.options.srConfig })\n });\n }\n\n /**\n * Retrieve the parsed locale from the i18n module and assigns it to the core options.\n */\n private assignLocaleToCore(): void {\n this.options.locale = this.modules.i18n.locale;\n }\n\n /**\n * Request translations to the CDN. If an error occurs, it will be logged to the console in development mode.\n */\n private async requestTranslations(): Promise<void> {\n try {\n await this.modules.i18n.requestTranslations();\n } catch (error: unknown) {\n console.warn('Core - requestTranslations(): Something went wrong.', error);\n }\n }\n\n private async requestAnalyticsAttemptId(): Promise<void> {\n await this.modules.analytics.setUp({\n locale: this.options.locale,\n ...(this.session?.id && { sessionId: this.session.id })\n });\n }\n}\n\nexport default Core;\n"],"names":["Core","setBundleType","type","metadata","bundleType","register","items","registry","add","getComponent","txVariant","initialize","this","initializeCore","validateCoreConfiguration","createCoreModules","assignLocaleToCore","requestAnalyticsAttemptId","requestTranslations","session","setupSession","options","then","sessionResponse","amount","shopperLocale","countryCode","paymentMethods","rest","setOptions","_object_spread_props","_object_spread","order","remainingAmount","locale","createPaymentMethodsList","catch","error","onError","Promise","reject","resolve","paymentMethodsConfiguration","console","warn","AdyenCheckoutError","IMPLEMENTATION_ERROR","submitDetails","details","promise","_this_options_onError","_this_options","onAdditionalDetails","data","undefined","call","sanitizeResponse","verifyPaymentDidNotFail","afterAdditionalDetails","response","_this_options_onPaymentCompleted","cleanupFinalResult","onPaymentCompleted","e","_this_options_onPaymentFailed","CancelError","onPaymentFailed","createFromAction","action","hasOwnProperty","Error","component","THREEDS2_FULL","subtype","paymentMethodType","event","AnalyticsLogEvent","LogEventType","subType","getSubtypeFromActionType","message","modules","analytics","sendAnalytics","props","getCorePropsForComponent","getComponentForAction","handleCreateError","update","shouldReinitializeCheckout","components","forEach","newProps","secondaryAmount","triggerAmountUpdate","isAmountValid","updateAmount","processGlobalOptions","globalOptions","core","i18n","loadingContext","cdnContext","cdnImagesUrl","processPayment","submit","LogEventSubtype","review","paymentMethod","submitPayment","_this_options1","onAction","_this_options_onOrderUpdated","_this_options2","_ref","value","onOrderUpdated","storeElementReference","element","push","paymentMethodName","name","errorMessage","JSON","stringify","paymentMethodsResponse","PaymentMethods","_this_options_analytics","_this_options_analytics1","Object","freeze","risk","RiskModule","Analytics","eventQueue","AnalyticsEventQueue","service","AnalyticsService","analyticsContext","clientKey","enabled","analyticsData","resources","Resources","Language","customTranslations","translations","LanguageService","cdnUrl","cdnTranslationsUrl","sdkVersion","version","srPanel","SRPanel","srConfig","_this_session","setUp","id","sessionId","constructor","_this_options_clientKey","_define_property","actionEle","remove","filter","c","_id","unmount","environment","String","prototype","toLowerCase","apply","assertConfigurationPropertiesAreValid","bind","defaultProps","apiUrl","analyticsUrl","resolveEnvironments","_environmentUrls","Session","clientKeyType","substring","_this_options__environmentUrls","_this_options_clientKey1","includes","api","debug","exposeLibraryMetadata","window","LIBRARY_VERSION","LIBRARY_BUNDLE_TYPE"],"mappings":"u2FA6BA,MAAMA,EAoBF,oBAAcC,CAAcC,GACxBF,EAAKG,SAASC,WAAaF,CAC/B,CAEA,eAAcG,IAAYC,GACtBC,EAASC,OAAOF,EACpB,CAMA,QAAAD,IAAmBC,GACfC,EAASC,OAAOF,EACpB,CAEOG,YAAAA,CAAaC,GAChB,OAAOH,EAASE,aAAaC,EAC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.js";function n(n){return Object.keys(n).reduce((o,t)=>(e.includes(t)&&(o[t]=n[t]),o),{})}function o(e){const n=(e=>e)(["session","environment","_environmentUrls","showPayButton","clientKey","locale","translations","paymentMethodsResponse","amount","secondaryAmount","countryCode","allowPaymentMethods","removePaymentMethods","srConfig","analytics","risk","order","donation","exposeLibraryMetadata","beforeRedirect","beforeSubmit","onPaymentCompleted","onPaymentFailed","onSubmit","onAdditionalDetails","onActionHandled","onChange","onError","onBalanceCheck","onOrderRequest","onPaymentMethodsRequest","onOrderCancel","onOrderUpdated","loadingContext","onEnterKeyPressed","afterAdditionalDetails"]);Object.keys(e).forEach(e=>{n.includes(e)||console.warn(`AdyenCheckout - Configuration property "${e}" is not a valid AdyenCheckout property. If it is a payment method configuration, make sure to pass it directly to the Component. If you are using Drop-in, make sure to pass it to "paymentMethodsConfiguration" object`)})}function t(e){const n=Object.values(e);return e=>n.includes(e)}export{o as assertConfigurationPropertiesAreValid,t as createEnumChecker,n as processGlobalOptions};
|
|
1
|
+
import{GENERIC_OPTIONS as e}from"./config.js";function n(n){return Object.keys(n).reduce((o,t)=>(e.includes(t)&&(o[t]=n[t]),o),{})}function o(e){const n=(e=>e)(["session","environment","_environmentUrls","showPayButton","clientKey","locale","translations","paymentMethodsResponse","amount","secondaryAmount","countryCode","allowPaymentMethods","removePaymentMethods","srConfig","analytics","risk","order","donation","exposeLibraryMetadata","beforeRedirect","beforeSubmit","onPaymentCompleted","onPaymentFailed","onSubmit","onReview","onAdditionalDetails","onAction","onActionHandled","onChange","onError","onBalanceCheck","onOrderRequest","onPaymentMethodsRequest","onOrderCancel","onOrderUpdated","loadingContext","onEnterKeyPressed","afterAdditionalDetails"]);Object.keys(e).forEach(e=>{n.includes(e)||console.warn(`AdyenCheckout - Configuration property "${e}" is not a valid AdyenCheckout property. If it is a payment method configuration, make sure to pass it directly to the Component. If you are using Drop-in, make sure to pass it to "paymentMethodsConfiguration" object`)})}function t(e){const n=Object.values(e);return e=>n.includes(e)}export{o as assertConfigurationPropertiesAreValid,t as createEnumChecker,n as processGlobalOptions};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/core/utils.ts"],"sourcesContent":["import { GENERIC_OPTIONS } from './config';\nimport type { CoreConfiguration } from './types';\n\n/**\n * Filter properties in a global configuration object from an allow list (GENERIC_OPTIONS)\n * @param globalOptions -\n * @returns any\n */\nexport function processGlobalOptions(globalOptions) {\n return Object.keys(globalOptions).reduce((r, e) => {\n if (GENERIC_OPTIONS.includes(e)) r[e] = globalOptions[e];\n return r;\n }, {});\n}\n\n/**\n * Validates that there is no unknown property as part of the CoreConfiguration.\n * The validator makes sure to throw a lint error in case a property is added to CoreConfiguration, but it is not added here\n *\n * @param props - AdyenCheckout props\n */\nexport function assertConfigurationPropertiesAreValid(propsSetByMerchant: CoreConfiguration): void {\n /** Helper that creates a function that validates the array contain ALL CoreConfiguration properties in it */\n function createConfigurationKeysValidator<T>() {\n const arrayOfAll =\n <T>() =>\n <U extends T[]>(array: U & ([T] extends [U[number]] ? unknown : 'Invalid')) =>\n array;\n const arrayWithAllKeys = arrayOfAll<T>();\n return arrayWithAllKeys;\n }\n\n const validator = createConfigurationKeysValidator<keyof CoreConfiguration>();\n const possibleFields = validator([\n 'session',\n 'environment',\n '_environmentUrls',\n 'showPayButton',\n 'clientKey',\n 'locale',\n 'translations',\n 'paymentMethodsResponse',\n 'amount',\n 'secondaryAmount',\n 'countryCode',\n 'allowPaymentMethods',\n 'removePaymentMethods',\n 'srConfig',\n 'analytics',\n 'risk',\n 'order',\n 'donation',\n 'exposeLibraryMetadata',\n 'beforeRedirect',\n 'beforeSubmit',\n 'onPaymentCompleted',\n 'onPaymentFailed',\n 'onSubmit',\n 'onAdditionalDetails',\n 'onActionHandled',\n 'onChange',\n 'onError',\n 'onBalanceCheck',\n 'onOrderRequest',\n 'onPaymentMethodsRequest',\n 'onOrderCancel',\n 'onOrderUpdated',\n 'loadingContext',\n 'onEnterKeyPressed',\n 'afterAdditionalDetails'\n ]);\n\n Object.keys(propsSetByMerchant).forEach((prop: keyof CoreConfiguration) => {\n if (!possibleFields.includes(prop)) {\n console.warn(\n `AdyenCheckout - Configuration property \"${prop}\" is not a valid AdyenCheckout property. If it is a payment method configuration, make sure to pass it directly to the Component. If you are using Drop-in, make sure to pass it to \"paymentMethodsConfiguration\" object`\n );\n }\n });\n}\n\n/**\n * TODO: Check if this is correct place\n * Type guard for enums, helpful to make sure strings keep enum value\n * Comes from this: https://github.com/microsoft/TypeScript/issues/30611#issuecomment-570773496\n * @param enumVariable\n */\nexport function createEnumChecker<T extends string, TEnumValue extends string>(enumVariable: { [key in T]: TEnumValue }) {\n const enumValues = Object.values(enumVariable);\n return (value: string): value is TEnumValue => enumValues.includes(value);\n}\n"],"names":["processGlobalOptions","globalOptions","Object","keys","reduce","r","e","GENERIC_OPTIONS","includes","assertConfigurationPropertiesAreValid","propsSetByMerchant","possibleFields","array","validator","forEach","prop","console","warn","createEnumChecker","enumVariable","enumValues","values","value"],"mappings":"8CAQO,SAASA,EAAqBC,GACjC,OAAOC,OAAOC,KAAKF,GAAeG,OAAO,CAACC,EAAGC,KACrCC,EAAgBC,SAASF,KAAID,EAAEC,GAAKL,EAAcK,IAC/CD,GACR,CAAA,EACP,CAQO,SAASI,EAAsCC,GAWlD,MACMC,EAPE,CAAgBC,GACZA,EAMWC,CAAU,CAC7B,UACA,cACA,mBACA,gBACA,YACA,SACA,eACA,yBACA,SACA,kBACA,cACA,sBACA,uBACA,WACA,YACA,OACA,QACA,WACA,wBACA,iBACA,eACA,qBACA,kBACA,WACA,sBACA,kBACA,WACA,UACA,iBACA,iBACA,0BACA,gBACA,iBACA,iBACA,oBACA,2BAGJX,OAAOC,KAAKO,GAAoBI,QAASC,IAChCJ,EAAeH,SAASO,IACzBC,QAAQC,KACJ,2CAA2CF,8NAI3D,CAQO,SAASG,EAA+DC,GAC3E,MAAMC,EAAalB,OAAOmB,OAAOF,GACjC,OAAQG,GAAuCF,EAAWZ,SAASc,EACvE"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/core/utils.ts"],"sourcesContent":["import { GENERIC_OPTIONS } from './config';\nimport type { CoreConfiguration } from './types';\n\n/**\n * Filter properties in a global configuration object from an allow list (GENERIC_OPTIONS)\n * @param globalOptions -\n * @returns any\n */\nexport function processGlobalOptions(globalOptions) {\n return Object.keys(globalOptions).reduce((r, e) => {\n if (GENERIC_OPTIONS.includes(e)) r[e] = globalOptions[e];\n return r;\n }, {});\n}\n\n/**\n * Validates that there is no unknown property as part of the CoreConfiguration.\n * The validator makes sure to throw a lint error in case a property is added to CoreConfiguration, but it is not added here\n *\n * @param props - AdyenCheckout props\n */\nexport function assertConfigurationPropertiesAreValid(propsSetByMerchant: CoreConfiguration): void {\n /** Helper that creates a function that validates the array contain ALL CoreConfiguration properties in it */\n function createConfigurationKeysValidator<T>() {\n const arrayOfAll =\n <T>() =>\n <U extends T[]>(array: U & ([T] extends [U[number]] ? unknown : 'Invalid')) =>\n array;\n const arrayWithAllKeys = arrayOfAll<T>();\n return arrayWithAllKeys;\n }\n\n const validator = createConfigurationKeysValidator<keyof CoreConfiguration>();\n const possibleFields = validator([\n 'session',\n 'environment',\n '_environmentUrls',\n 'showPayButton',\n 'clientKey',\n 'locale',\n 'translations',\n 'paymentMethodsResponse',\n 'amount',\n 'secondaryAmount',\n 'countryCode',\n 'allowPaymentMethods',\n 'removePaymentMethods',\n 'srConfig',\n 'analytics',\n 'risk',\n 'order',\n 'donation',\n 'exposeLibraryMetadata',\n 'beforeRedirect',\n 'beforeSubmit',\n 'onPaymentCompleted',\n 'onPaymentFailed',\n 'onSubmit',\n 'onReview',\n 'onAdditionalDetails',\n 'onAction',\n 'onActionHandled',\n 'onChange',\n 'onError',\n 'onBalanceCheck',\n 'onOrderRequest',\n 'onPaymentMethodsRequest',\n 'onOrderCancel',\n 'onOrderUpdated',\n 'loadingContext',\n 'onEnterKeyPressed',\n 'afterAdditionalDetails'\n ]);\n\n Object.keys(propsSetByMerchant).forEach((prop: keyof CoreConfiguration) => {\n if (!possibleFields.includes(prop)) {\n console.warn(\n `AdyenCheckout - Configuration property \"${prop}\" is not a valid AdyenCheckout property. If it is a payment method configuration, make sure to pass it directly to the Component. If you are using Drop-in, make sure to pass it to \"paymentMethodsConfiguration\" object`\n );\n }\n });\n}\n\n/**\n * TODO: Check if this is correct place\n * Type guard for enums, helpful to make sure strings keep enum value\n * Comes from this: https://github.com/microsoft/TypeScript/issues/30611#issuecomment-570773496\n * @param enumVariable\n */\nexport function createEnumChecker<T extends string, TEnumValue extends string>(enumVariable: { [key in T]: TEnumValue }) {\n const enumValues = Object.values(enumVariable);\n return (value: string): value is TEnumValue => enumValues.includes(value);\n}\n"],"names":["processGlobalOptions","globalOptions","Object","keys","reduce","r","e","GENERIC_OPTIONS","includes","assertConfigurationPropertiesAreValid","propsSetByMerchant","possibleFields","array","validator","forEach","prop","console","warn","createEnumChecker","enumVariable","enumValues","values","value"],"mappings":"8CAQO,SAASA,EAAqBC,GACjC,OAAOC,OAAOC,KAAKF,GAAeG,OAAO,CAACC,EAAGC,KACrCC,EAAgBC,SAASF,KAAID,EAAEC,GAAKL,EAAcK,IAC/CD,GACR,CAAA,EACP,CAQO,SAASI,EAAsCC,GAWlD,MACMC,EAPE,CAAgBC,GACZA,EAMWC,CAAU,CAC7B,UACA,cACA,mBACA,gBACA,YACA,SACA,eACA,yBACA,SACA,kBACA,cACA,sBACA,uBACA,WACA,YACA,OACA,QACA,WACA,wBACA,iBACA,eACA,qBACA,kBACA,WACA,WACA,sBACA,WACA,kBACA,WACA,UACA,iBACA,iBACA,0BACA,gBACA,iBACA,iBACA,oBACA,2BAGJX,OAAOC,KAAKO,GAAoBI,QAASC,IAChCJ,EAAeH,SAASO,IACzBC,QAAQC,KACJ,2CAA2CF,8NAI3D,CAQO,SAASG,EAA+DC,GAC3E,MAAMC,EAAalB,OAAOmB,OAAOF,GACjC,OAAQG,GAAuCF,EAAWZ,SAASc,EACvE"}
|