@adyen/adyen-web 6.11.0 → 6.12.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/dist/cjs/adyen.css +3 -3
- 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 +88 -98
- package/dist/es/adyen.css +3 -3
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/ANCV/components/ANCVAwait/config.js +1 -1
- package/dist/es/components/ANCV/components/ANCVAwait/config.js.map +1 -1
- package/dist/es/components/Ach/Ach.js +1 -1
- package/dist/es/components/Ach/Ach.js.map +1 -1
- package/dist/es/components/Ach/components/AccountTypeSelector.js +2 -0
- package/dist/es/components/Ach/components/AccountTypeSelector.js.map +1 -0
- package/dist/es/components/Ach/components/AchComponent.js +2 -0
- package/dist/es/components/Ach/components/AchComponent.js.map +1 -0
- package/dist/es/components/Ach/components/useSRPanelForACHErrors.js +2 -0
- package/dist/es/components/Ach/components/useSRPanelForACHErrors.js.map +1 -0
- package/dist/es/components/Ach/components/validate.js +2 -0
- package/dist/es/components/Ach/components/validate.js.map +1 -0
- package/dist/es/components/Ach/defaultProps.js +2 -0
- package/dist/es/components/Ach/defaultProps.js.map +1 -0
- package/dist/es/components/AmazonPay/utils.js +1 -1
- package/dist/es/components/ApplePay/ApplePay.js +1 -1
- package/dist/es/components/Atome/Atome.js +1 -1
- package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
- package/dist/es/components/BcmcMobile/BcmcMobile.js +1 -1
- package/dist/es/components/Boleto/components/BoletoInput/validate.js +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFields.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/DataSfSpan.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
- package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/validate.js +1 -1
- package/dist/es/components/Donation/components/DonationComponent.js +1 -1
- package/dist/es/components/DuitNow/DuitNow.js +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/PayNow/PayNow.js +1 -1
- package/dist/es/components/PayPal/constants.js +1 -1
- package/dist/es/components/PayPal/constants.js.map +1 -1
- package/dist/es/components/PayTo/PayTo.js.map +1 -1
- package/dist/es/components/Pix/PixInput/PixInput.js.map +1 -1
- package/dist/es/components/PromptPay/PromptPay.js +1 -1
- package/dist/es/components/Redirect/Redirect.js +1 -1
- package/dist/es/components/Riverty/Riverty.js +1 -1
- package/dist/es/components/Riverty/config.js +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es/components/WeChat/WeChat.js +1 -1
- package/dist/es/components/internal/Address/Address.js +1 -1
- package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es/components/internal/Countdown/utils.js.map +1 -1
- package/dist/es/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
- package/dist/es/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/internal/FormFields/InputDate/utils.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
- package/dist/es/components/internal/IbanInput/validate.js +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
- package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
- package/dist/es/components/internal/PhoneInput/validate.js +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/iframes/postMessageValidation.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/utils.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/userAgent.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/userAgent.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/utils/processPlaceholders.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/utilities/addContextTranslations.js +1 -1
- package/dist/es/components/internal/StoreDetails/StoreDetails.js +1 -1
- package/dist/es/components/internal/StoreDetails/StoreDetails.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/Analytics.js +1 -1
- package/dist/es/core/Analytics/Analytics.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/utils.js +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/utils.js +1 -1
- package/dist/es/core/Errors/utils.js.map +1 -1
- package/dist/es/core/RiskModule/components/DeviceFingerprint/utils.js +1 -1
- package/dist/es/core/RiskModule/constants.js +1 -1
- package/dist/es/core/RiskModule/constants.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/Services/http.js +1 -1
- package/dist/es/core/core.js +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.map +1 -1
- package/dist/es/index.d.ts +88 -98
- package/dist/es/index.js +1 -1
- package/dist/es/utils/Validator/defaultRules.js +1 -1
- package/dist/es/utils/base64.js.map +1 -1
- package/dist/es/utils/browserInfo.js +1 -1
- package/dist/es/utils/browserInfo.js.map +1 -1
- package/dist/es/utils/setFocus.js +1 -1
- package/dist/es/utils/setFocus.js.map +1 -1
- package/dist/es/utils/textUtils.js +1 -1
- package/dist/es/utils/textUtils.js.map +1 -1
- package/dist/es/utils/useForm/useForm.js +1 -1
- package/dist/es-legacy/adyen.css +3 -3
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ANCV/components/ANCVAwait/config.js +1 -1
- package/dist/es-legacy/components/ANCV/components/ANCVAwait/config.js.map +1 -1
- package/dist/es-legacy/components/Ach/Ach.js +1 -1
- package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AccountTypeSelector.js +2 -0
- package/dist/es-legacy/components/Ach/components/AccountTypeSelector.js.map +1 -0
- package/dist/es-legacy/components/Ach/components/AchComponent.js +2 -0
- package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -0
- package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js +2 -0
- package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js.map +1 -0
- package/dist/es-legacy/components/Ach/components/validate.js +2 -0
- package/dist/es-legacy/components/Ach/components/validate.js.map +1 -0
- package/dist/es-legacy/components/Ach/defaultProps.js +2 -0
- package/dist/es-legacy/components/Ach/defaultProps.js.map +1 -0
- package/dist/es-legacy/components/AmazonPay/utils.js +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
- package/dist/es-legacy/components/Atome/Atome.js +1 -1
- package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
- package/dist/es-legacy/components/BcmcMobile/BcmcMobile.js +1 -1
- package/dist/es-legacy/components/Boleto/components/BoletoInput/validate.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/DataSfSpan.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.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.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/validate.js +1 -1
- package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
- package/dist/es-legacy/components/DuitNow/DuitNow.js +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/PayNow/PayNow.js +1 -1
- package/dist/es-legacy/components/PayPal/constants.js +1 -1
- package/dist/es-legacy/components/PayPal/constants.js.map +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
- package/dist/es-legacy/components/Pix/PixInput/PixInput.js.map +1 -1
- package/dist/es-legacy/components/PromptPay/PromptPay.js +1 -1
- package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
- package/dist/es-legacy/components/Riverty/Riverty.js +1 -1
- package/dist/es-legacy/components/Riverty/config.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es-legacy/components/WeChat/WeChat.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.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/ClickToPay/services/ClickToPayService.js +1 -1
- package/dist/es-legacy/components/internal/Countdown/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.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/InputDate/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
- package/dist/es-legacy/components/internal/IbanInput/validate.js +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +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/CSF/extensions/handleConfig.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/iframes/postMessageValidation.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/userAgent.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/userAgent.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/utils/processPlaceholders.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/utilities/addContextTranslations.js +1 -1
- package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js +1 -1
- package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.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/Analytics.js +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.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/utils.js +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/utils.js +1 -1
- package/dist/es-legacy/core/Errors/utils.js.map +1 -1
- package/dist/es-legacy/core/RiskModule/RiskModule.js +1 -1
- package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/utils.js +1 -1
- package/dist/es-legacy/core/RiskModule/constants.js +1 -1
- package/dist/es-legacy/core/RiskModule/constants.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/core.js +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.map +1 -1
- package/dist/es-legacy/index.js +1 -1
- package/dist/es-legacy/utils/Validator/defaultRules.js +1 -1
- package/dist/es-legacy/utils/base64.js.map +1 -1
- package/dist/es-legacy/utils/browserInfo.js +1 -1
- package/dist/es-legacy/utils/browserInfo.js.map +1 -1
- package/dist/es-legacy/utils/setFocus.js +1 -1
- package/dist/es-legacy/utils/setFocus.js.map +1 -1
- package/dist/es-legacy/utils/textUtils.js +1 -1
- package/dist/es-legacy/utils/textUtils.js.map +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js +1 -1
- package/package.json +21 -21
- package/styles/adyen.css +3 -3
- package/dist/es/components/Ach/components/AchInput/AchInput.js +0 -2
- package/dist/es/components/Ach/components/AchInput/AchInput.js.map +0 -1
- package/dist/es/components/Ach/components/AchInput/components/AchSFInput.js +0 -2
- package/dist/es/components/Ach/components/AchInput/components/AchSFInput.js.map +0 -1
- package/dist/es/components/Ach/components/AchInput/components/AchSecuredFields.js +0 -2
- package/dist/es/components/Ach/components/AchInput/components/AchSecuredFields.js.map +0 -1
- package/dist/es/components/Ach/components/AchInput/defaultProps.js +0 -2
- package/dist/es/components/Ach/components/AchInput/defaultProps.js.map +0 -1
- package/dist/es/components/Ach/components/AchInput/defaultStyles.js +0 -2
- package/dist/es/components/Ach/components/AchInput/defaultStyles.js.map +0 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js +0 -2
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/components/AchSFInput.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/components/AchSFInput.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/components/AchSecuredFields.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/components/AchSecuredFields.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/defaultStyles.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/defaultStyles.js.map +0 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js +0 -2
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js.map +0 -1
package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as e,createElement as t}from"../../../../external/preact/dist/preact.js";import r from"./DoFingerprint3DS2.js";import{isErrorObject as o,createOldFingerprintResolveData as s,createFingerprintResolveData as n,prepareFingerPrintData as i}from"../utils.js";import{isValidHttpUrl as a}from"../../../../utils/isValidURL.js";import{THREEDS2_FINGERPRINT_ERROR as p,MISSING_TOKEN_IN_ACTION_MSG as c,TIMEOUT as l,
|
|
1
|
+
import{Component as e,createElement as t}from"../../../../external/preact/dist/preact.js";import r from"./DoFingerprint3DS2.js";import{isErrorObject as o,createOldFingerprintResolveData as s,createFingerprintResolveData as n,prepareFingerPrintData as i}from"../utils.js";import{isValidHttpUrl as a}from"../../../../utils/isValidURL.js";import{THREEDS2_FINGERPRINT_ERROR as p,MISSING_TOKEN_IN_ACTION_MSG as c,TIMEOUT as l,THREEDS2_NUM as d,THREEDS2_FULL as m,THREEDS2_ERROR as u,THREEDS2_FINGERPRINT as h}from"../../constants.js";import{Analytics3DS2Errors as S,ANALYTICS_ERROR_TYPE as g,Analytics3DS2Events as D}from"../../../../core/Analytics/constants.js";function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){f(e,t,r[t])}))}return e}function O(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class y extends e{componentDidMount(){if(!o(this.state.fingerPrintData)){var e,t;const r="test"===this.props.environment&&(null===(t=this.props._environmentUrls)||void 0===t||null===(e=t.api)||void 0===e?void 0:e.includes("http://localhost:8080")),{threeDSMethodURL:o,threeDSMethodNotificationURL:s,postMessageDomain:n,threeDSServerTransID:i}=this.state.fingerPrintData;if(!a(o,r))return this.setStatusComplete({threeDSCompInd:"U"},{errorCode:S.TOKEN_IS_MISSING_THREEDSMETHODURL,message:`${p}: Decoded token is missing a valid threeDSMethodURL property`}),void console.debug("### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL");const c=a(s,r),l=a(n,r),d=null==i?void 0:i.length;if(!c||!l||!d)return this.setStatusComplete({threeDSCompInd:"N"},{errorCode:S.TOKEN_IS_MISSING_OTHER_PROPS,message:`${p}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`}),void console.debug("### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)");this.setState({status:"retrievingFingerPrint"})}else{const e=this.state.fingerPrintData.error,t=e.indexOf(c)>-1?S.ACTION_IS_MISSING_TOKEN:S.TOKEN_DECODE_OR_PARSING_FAILED;this.setStatusComplete({threeDSCompInd:"N"},{errorCode:t,message:`${p}: ${e}`}),console.debug("### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed")}}setStatusComplete(e,t=null){this.setState({status:"complete"},(()=>{const r=(this.props.isMDFlow?s:n)(this.props.dataKey,e,this.props.paymentData);let o;const i=t||e;if(i.errorCode){const e={code:i.errorCode===l?S.THREEDS2_TIMEOUT:i.errorCode,errorType:i.errorCode===l?g.network:g.apiError};o=b({type:u,message:i.message},e),this.props.onSubmitAnalytics(o)}let a;switch(null==e?void 0:e.threeDSCompInd){case"Y":a="success";break;case"N":a=t?t.errorCode===l?l:"failedInternal":"failed";break;case"U":a="noThreeDSMethodURL"}o={type:m,message:`${d} fingerprinting has completed`,subtype:D.FINGERPRINT_COMPLETED,result:a},this.props.onSubmitAnalytics(o),this.props.onComplete(r)}))}render({showSpinner:e},{status:o,fingerPrintData:s}){return"retrievingFingerPrint"===o?t(r,O(b({onCompleteFingerprint:e=>{this.setStatusComplete(e.result)},onErrorFingerprint:e=>{const t={errorCode:e.errorCode,message:`${h}: ${e.errorCode}`};this.setStatusComplete(e.result,t)},showSpinner:e},s),{onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit})):null}constructor(e){super(e),f(this,"onFormSubmit",(e=>{this.props.onSubmitAnalytics({type:m,message:e,subtype:D.FINGERPRINT_DATA_SENT})}));const{token:t,notificationURL:r}=this.props;if(t){const e=i({token:t,notificationURL:r});this.state={status:"init",fingerPrintData:e}}else this.state={fingerPrintData:{success:!1,error:c}},console.debug(`${p}: ${c}`)}}f(y,"type","scheme"),f(y,"defaultProps",{onComplete:()=>{},onError:()=>{},paymentData:"",showSpinner:!0,isMDFlow:!1});export{y as default};
|
|
2
2
|
//# sourceMappingURL=PrepareFingerprint3DS2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport {\n THREEDS2_FULL,\n THREEDS2_FINGERPRINT,\n THREEDS2_FINGERPRINT_ERROR,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR,\n TIMEOUT\n} from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let analyticsObject: SendAnalyticsObject;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subtype: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","analyticsObject","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","_object_spread","type","THREEDS2_ERROR","onSubmitAnalytics","result","THREEDS2_FULL","THREEDS2_NUM","subtype","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"i8CAmBA,MAAMA,UAA+BC,EAuCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CAG2BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAA,QAAAD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBf,KAAKC,MACpGC,gBAKL,IAH6Bc,EAAeJ,EAAkBN,GAoB1D,OAhBAN,KAAKiB,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBC,kCAC/BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9DsB,EAAmBb,aAAAA,EAAAA,EAAsBc,OAE/C,IAAKH,IAAqCC,IAA8BC,EAiBpE,OAZA5B,KAAKiB,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBU,6BAC/BR,QAAS,GAAGC,uJAIpBC,QAAQC,MACJ,oLAOR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Ae,0BAAX8B,EAEIsC,EAACC,EAAAA,EAAAA,EAAAA,CACGC,sBAAuBC,IACnBzE,KAAKiB,kBAAkBwD,EAAYZ,OAAM,EAE7Ca,mBAAoBD,IAIhB,MAAME,EAAiC,CACnCxD,UAAWsD,EAAYtD,UACvBG,QAAS,GAAGsD,MAAyBH,EAAYtD,aAGrDnB,KAAKiB,kBAAkBwD,EAAYZ,OAAQc,IAE/CN,YAAaA,GACTnE,GAAAA,CACJ2E,gBAAiB7E,KAAKO,MAAMsE,gBAC5BC,aAAc9E,KAAK8E,gBAKxB,IACX,CAtOAC,WAAAA,CAAYxE,GACRyE,MAAMzE,GAmBV0E,EAAOH,KAAAA,gBAAgBI,IACnBlF,KAAKO,MAAMqD,kBAAkB,CACzBF,KAAMI,EACNxC,QAAS4D,EACTlB,QAASC,EAAoBkB,uBACjC,IAtBA,MAAMC,MAAEA,EAAKC,gBAAEA,GAAoBrF,KAAKO,MAExC,GAAI6E,EAAO,CACP,MAAMlF,EAAiDoF,EAAuB,CAAEF,QAAOC,oBAEvFrF,KAAKC,MAAQ,CACT+B,OAAQ,OACR9B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEqF,SAAS,EAAOrD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA6C,EADErF,EACY8D,OAAO,UAErBuB,EAHErF,EAGY4F,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
|
|
1
|
+
{"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport {\n THREEDS2_FULL,\n THREEDS2_FINGERPRINT,\n THREEDS2_FINGERPRINT_ERROR,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR,\n TIMEOUT\n} from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let analyticsObject: SendAnalyticsObject;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subtype: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","analyticsObject","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","_object_spread","type","THREEDS2_ERROR","onSubmitAnalytics","result","THREEDS2_FULL","THREEDS2_NUM","subtype","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","pr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AA,gBAAgBI,IACnBlF,KAAKO,MAAMqD,kBAAkB,CACzBF,KAAMI,EACNxC,QAAS4D,EACTlB,QAASC,EAAoBkB,uBACjC,IAtBA,MAAMC,MAAEA,EAAKC,gBAAEA,GAAoBrF,KAAKO,MAExC,GAAI6E,EAAO,CACP,MAAMlF,EAAiDoF,EAAuB,CAAEF,QAAOC,oBAEvFrF,KAAKC,MAAQ,CACT+B,OAAQ,OACR9B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEqF,SAAS,EAAOrD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA6C,EADErF,EACY8D,OAAO,UAErBuB,EAHErF,EAGY4F,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../helpers/QRLoaderContainer/QRLoaderContainer.js";import{
|
|
1
|
+
import e from"../helpers/QRLoaderContainer/QRLoaderContainer.js";import{countdownTime as t,delay as r}from"./config.js";import{TxVariants as n}from"../tx-variants.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class a extends e{formatProps(e){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){o(e,t,r[t])}))}return e}({delay:r,countdownTime:t},super.formatProps(e))}}o(a,"type",n.wechatpayQR),o(a,"txVariants",[n.wechatpay]),o(a,"analyticsType","wechatpayQR");export{a as default};
|
|
2
2
|
//# sourceMappingURL=WeChat.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{countrySpecificFormatters as d,addressFormatters as u}from"./validate.formats.js";import p from"./components/FieldContainer.js";import m from"../../../utils/useForm/useForm.js";import f from"./Specifications.js";import{ADDRESS_SCHEMA as y,FALLBACK_VALUE as b}from"./constants.js";import{getMaxLengthByFieldAndCountry as O}from"../../../utils/validator-utils.js";import{useCoreContext as g}from"../../../core/Context/CoreProvider.js";import h from"./components/AddressSearch.js";function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){j(e,t,r[t])}))}return e}function F(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}function C(j){const{i18n:C}=g(),{label:A="",requiredFields:P,visibility:w,iOSFocusedField:S=null,showContextualElement:k}=j,x=r({});var D;Object.keys(x.current).length||(null===(D=j.setComponentRef)||void 0===D||D.call(j,x.current));const M=o((()=>new f(j.specifications)),[j.specifications]),E=M.getAddressSchemaForCountryFlat(j.countryCode).filter((e=>P.includes(e))),[B,N]=n(!1),[L,R]=n(!1),[V,q]=n(""),H=!!j.onAddressLookup,[T,_]=n(!1),I=!j.onAddressLookup||(B||L),{data:$,errors:z,valid:G,isValid:J,handleChangeFor:K,triggerValidation:Q,setData:U,mergeData:W}=m({schema:E,defaultData:j.data,rules:v({},c(M),j.validationRules),formatters:u}),X=s((e=>{const t=y.reduce(((t,r)=>{const o=e[r];return null!=o&&(t[r]=String(o)),t}),{});W(t),_(!0),Q(),N(!0)}),[N,Q,U]),Y=s((()=>{R(!0)}),[]);x.current.showValidation=()=>{Q(),q(!H||I||J?"":C.get("address.errors.incomplete"))};const Z=E.filter((e=>!S||e===S));if(a((()=>{if(T)return void _(!1);const e=M.countryHasDataset($.country)?"":b,t=F(v({},$),{stateOrProvince:e});P.forEach((e=>{var r;K(e,"input")(null!==(r=t[e])&&void 0!==r?r:"")})),t.postalCode&&K("postalCode","blur")($.postalCode)}),[$.country]),a((()=>{const e=P.includes("stateOrProvince"),t=$.country&&M.countryHasDataset($.country),r=e&&t,o=$.stateOrProvince||(r?"":b);K("stateOrProvince","input")(o)}),[]),a((()=>{const e=M.getOptionalFieldsForCountry($.country),t=y.reduce(((t,r)=>{const o=e.includes(r),n=P.includes(r),s=$[r],a=j.data[r],i=o&&!s||!n?n||s||!a?b:a:s;return(null==i?void 0:i.length)&&(t[r]=i),t}),{});j.onChange({data:t,valid:G,errors:z,isValid:J})}),[$,G,z,J]),"hidden"===w)return null;if("readOnly"===w)return e(l,{data:$,label:A});const ee=(t,{classNameModifiers:r=[]})=>P.includes(t)?e(p,{key:t,allowedCountries:j.allowedCountries,classNameModifiers:[...r,t],data:$,errors:z,valid:G,fieldName:t,onInput:K(t,"input"),onBlur:K(t,"blur"),onDropdownChange:K(t,"blur"),specifications:M,maxLength:O(d,t,$.country),trimOnBlur:!0,disabled:!Z.includes(t),onFieldFocusAnalytics:j.onFieldFocusAnalytics,onFieldBlurAnalytics:j.onFieldBlurAnalytics}):null,te=M.getAddressSchemaForCountry($.country);return e(t,null,e(i,{classNameModifiers:[A||"address"],label:A},H&&e(h,{onAddressLookup:j.onAddressLookup,onAddressSelected:j.onAddressSelected,onSelect:X,onManualAddress:Y,externalErrorMessage:V,hideManualButton:I,showContextualElement:k,contextualText:C.get("address.search.contextualText"),addressSearchDebounceMs:j.addressSearchDebounceMs}),I&&e(t,null,te.map((t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map((([e,t])=>ee(e,{classNameModifiers:[`col-${t}`]})))):ee(t,{}))))))}C.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:y,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{C as default};
|
|
2
2
|
//# sourceMappingURL=Address.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS, trimValWithOneSpace } from '../../../utils/validator-utils';\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = val => trimValWithOneSpace(val).replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters: CountryFormatRules = {\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n};\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","trimValWithOneSpace","addressFormatters","postalCode","context","countrySpecificFormatters","country","state","data","specificRule","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","indexOf","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"mHAIA,MAAMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAeX,GAAOY,EAAoBZ,GAAKC,QAAQQ,EAAmB,IAEnEI,EAAiC,CAC1CC,WAAY,CACRf,YAAa,CAACC,EAAKe,KAIMC,IAAAA,EAHrB,MAAMC,EAAUF,EAAQG,MAAMC,KAAKF,QAG7BG,UAAeJ,EAAAA,EAA0BC,UAA1BD,IAAAA,OAAAA,EAAAA,EAAoCF,WAAWf,YACpE,OAAIqB,EACOA,EAAapB,GAIjBA,CAAAA,GAGfqB,OAAQ,CACJtB,YAAaY,GAEjBW,kBAAmB,CACfvB,YAAaY,GAEjBY,KAAM,CACFxB,YAAaY,IAORK,EAAgD,CACzDQ,GAAI,CACAV,WAAYjB,EAAqB,IAErC4B,GAAI,CACAX,WAAYjB,EAAqB,IAErC6B,GAAI,CACAZ,WAAYjB,EAAqB,IAErC8B,GAAI,CACAb,WAAYjB,EAAqB,IAErC+B,GAAI,CACA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AY,CACRV,OAAQ,QACRI,UAAW,IAGnB6C,GAAI,CACAvC,WAAY,CACRV,OAAQ,qCACRI,UAAW,IAGnB8C,GAAI,CACAxC,WAAYjB,EAAqB,IAErC0D,GAAI,CACAzC,WAAY,CACRV,OAAQ,SACRI,UAAW,IAGnBgD,GAAI,CACA1C,WAAYjB,EAAqB,IAErC4D,GAAI,CACA3C,WAAYjB,EAAqB,IAErC6D,GAAI,CACA5C,WAAY,CAERf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,QAAQ,MAAQ,EAAI,EAAI,EAChD,OAAOD,EAAM1B,UAAU,EAAGK,EAAAA,EAE9BJ,OAAQ,kBACRI,UAAW,IAGnBmD,GAAI,CACA7C,WAAY,CACRf,YAAaC,GACKA,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IAC/CC,UAAU,EAAG,GAE9BC,OAAQ,WACRI,UAAW,IAGnBoD,GAAI,CACA9C,WAAYjB,EAAqB,IAErCgE,GAAI,CACA/C,WAAY,CACRV,OAAQ,kBACRI,UAAW,IAGnBsD,GAAI,CACAhD,WAAYjB,EAAqB,IAErCkE,GAAI,CACAjD,WAAYjB,EAAqB,IAErCmE,GAAI,CACAlD,WAAY,CACRV,OAAQ,oBACRI,UAAW,IAGnByD,GAAI,CACAnD,WAAY,CACRV,OAAQ,WACRI,UAAW,IAGnB0D,GAAI,CACApD,WAAY,CACRf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,QAAQ,MAAQ,EAAI,GAAK,EACjD,OAAOD,EAAM1B,UAAU,EAAGK,EAAAA,EAE9BJ,OAAQ"}
|
|
1
|
+
{"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS, trimValWithOneSpace } from '../../../utils/validator-utils';\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = val => trimValWithOneSpace(val).replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters: CountryFormatRules = {\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n};\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","trimValWithOneSpace","addressFormatters","postalCode","context","countrySpecificFormatters","country","state","data","specificRule","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","indexOf","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"mHAIA,MAAMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAeX,GAAOY,EAAoBZ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,CACAhD,WAAYjB,EAAqB,IAErCkE,GAAI,CACAjD,WAAYjB,EAAqB,IAErCmE,GAAI,CACAlD,WAAY,CACRV,OAAQ,oBACRI,UAAW,IAGnByD,GAAI,CACAnD,WAAY,CACRV,OAAQ,WACRI,UAAW,IAGnB0D,GAAI,CACApD,WAAY,CACRf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,QAAQ,MAAO,EAAK,GAAK,EACjD,OAAOD,EAAM1B,UAAU,EAAGK,EAAAA,EAE9BJ,OAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import r from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as n,ANALYTICS_RENDERED_STR as s}from"../../../core/Analytics/constants.js";import{on as i,off as c}from"../../../utils/listenerUtils.js";function p(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){p(t,e,r[e])}))}return t}function u(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 r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}function l(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r,o,n={},s=Object.keys(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}class h{buildElementProps(t){this.props=this.formatProps(a({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state=a({},this.state,t)}get data(){var t;const r=e(this.props,"modules.risk.data");var o;const s=null!==(o=null===(t=e(this.props,"modules.analytics.getCheckoutAttemptId"))||void 0===t?void 0:t())&&void 0!==o?o:n,i=this.state.order||this.props.order,c=this.formatData();if(c.paymentMethod&&s&&(c.paymentMethod.checkoutAttemptId=s),"riverty"!==this.props.type&&c.billingAddress){const t=
|
|
1
|
+
import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import r from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as n,ANALYTICS_RENDERED_STR as s}from"../../../core/Analytics/constants.js";import{on as i,off as c}from"../../../utils/listenerUtils.js";function p(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){p(t,e,r[e])}))}return t}function u(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 r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}function l(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r,o,n={},s=Object.keys(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}class h{buildElementProps(t){this.props=this.formatProps(a({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state=a({},this.state,t)}get data(){var t;const r=e(this.props,"modules.risk.data");var o;const s=null!==(o=null===(t=e(this.props,"modules.analytics.getCheckoutAttemptId"))||void 0===t?void 0:t())&&void 0!==o?o:n,i=this.state.order||this.props.order,c=this.formatData();if(c.paymentMethod&&s&&(c.paymentMethod.checkoutAttemptId=s),"riverty"!==this.props.type&&c.billingAddress){const t=c.billingAddress,{firstName:e,lastName:r}=t,o=l(t,["firstName","lastName"]);c.billingAddress=a({},o)}return u(a({},r&&{riskData:{clientData:r}},i&&{order:{orderData:i.orderData,pspReference:i.pspReference}},c),{clientStateDataIndicator:!0})}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");const o=!this._node;var n;(this._node&&this.unmount(),this._node=r,i(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,r),o)&&(this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:r&&r.offsetWidth,component:this.props.isDropin?"dropin":null!==(n=this.constructor.analyticsType)&&void 0!==n?n:this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:s})})));return this}update(t){return this.props=this.formatProps(a({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return c(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){p(this,"_id",`${this.constructor.type}-${r()}`),p(this,"core",void 0),p(this,"props",void 0),p(this,"state",{}),p(this,"_component",void 0),p(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e),this.handleKeyPress=this.handleKeyPress.bind(this)}}p(h,"defaultProps",{});export{h as default};
|
|
2
2
|
//# sourceMappingURL=BaseElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { ANALYTICS_RENDERED_STR, NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { off, on } from '../../../utils/listenerUtils';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const checkoutAttemptId = getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() ?? NO_CHECKOUT_ATTEMPT_ID; // NOTE: we never expect to see this \"failed\" value, but, just in case...\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n // Workaround, to be fixed properly\n // Remove the firstName & lastName in the billingAddress for non Riverty components\n // @ts-ignore type exists\n if (this.props.type !== 'riverty' && componentData.billingAddress) {\n const { firstName, lastName, ...rest } = componentData.billingAddress;\n componentData.billingAddress = { ...rest };\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && node.offsetWidth,\n component: !this.props.isDropin ? (this.constructor['analyticsType'] ?? this.constructor['type']) : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","getProp","clientData","checkoutAttemptId","NO_CHECKOUT_ATTEMPT_ID","order","componentData","paymentMethod","type","billingAddress","rest","firstName","lastName","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","_this_constructor_analyticsType","unmount","on","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","ANALYTICS_RENDERED_STR","update","off","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"qhDAuBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,GAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAI,GACI,MAAO,CAAC,CACZ,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfb,KAAKc,MAAQX,KAAKH,KAAKc,MAAUD,EACrC,CAMA,QAAWE,GAEmBC,IAAAA,EAD1B,MAAMC,EAAaD,EAAQhB,KAAKC,MAAO,qBACbe,IAAAA,EAA1B,MAAME,EAAoBF,QAAAA,UAAAA,EAAAA,EAAQhB,K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AK,KAICtD,KAAKC,MAAMmD,UACZpD,KAAKQ,gBAAgB,CAAEe,KAAMgC,GACjC,KAKZ,OAAOvD,IACX,CAQOwD,MAAAA,CAAOvD,GAIV,OAHAD,KAAKC,MAAQD,KAAKE,YAAYC,EAAK,CAAA,EAAAH,KAAKC,MAAUA,IAClDD,KAAKc,MAAQ,CAAC,EAEPd,KAAK4C,UAAUR,MAAMpC,KAAK0C,MACrC,CAKA,OAAAE,GAQI,OANAa,EAAIzD,KAAK0C,MAAO,WAAY1C,KAAKU,gBAE7BV,KAAK0C,OACLR,EAAO,KAAMlC,KAAK0C,OAGf1C,IACX,CAMA,MAAA0D,GACI1D,KAAK4C,UAED5C,KAAK2D,MACL3D,KAAK2D,KAAKD,OAAO1D,KAEzB,CAvLAI,WAAAA,CAAYwD,EAAiB3D,GAX7B4D,EAAgBC,KAAAA,MAAM,GAAG9D,KAAKI,YAAmB,QAAI2D,OACrDF,EAAA7D,KAAgB2D,YAAhB,GAEAE,EAAA7D,KAAOC,aAAP,GACA4D,EAAA7D,KAAOc,QAAa,IACpB+C,EAAA7D,KAAO8C,kBAAP,GAEAe,EAAA7D,KAAU0C,QAAqB,MAK3B,MAAMsB,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuCpE,KAAKI,YAAmB,6DAIvEJ,KAAK2D,KAAOC,EACZ5D,KAAKF,kBAAkBG,GAEvBD,KAAKU,eAAiBV,KAAKU,eAAe2D,KAAKrE,KACnD,EAhBA6D,EAVWhE,EAUMyE,eAAe"}
|
|
1
|
+
{"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { ANALYTICS_RENDERED_STR, NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { off, on } from '../../../utils/listenerUtils';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const checkoutAttemptId = getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() ?? NO_CHECKOUT_ATTEMPT_ID; // NOTE: we never expect to see this \"failed\" value, but, just in case...\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n // Workaround, to be fixed properly\n // Remove the firstName & lastName in the billingAddress for non Riverty components\n // @ts-ignore type exists\n if (this.props.type !== 'riverty' && componentData.billingAddress) {\n const { firstName, lastName, ...rest } = componentData.billingAddress;\n componentData.billingAddress = { ...rest };\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && node.offsetWidth,\n component: !this.props.isDropin ? (this.constructor['analyticsType'] ?? this.constructor['type']) : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","getProp","clientData","checkoutAttemptId","NO_CHECKOUT_ATTEMPT_ID","order","componentData","paymentMethod","type","billingAddress","firstName","lastName","rest","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","_this_constructor_analyticsType","unmount","on","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","ANALYTICS_RENDERED_STR","update","off","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"qhDAuBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,GAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAI,GACI,MAAO,CAAC,CACZ,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfb,KAAKc,MAAQX,KAAKH,KAAKc,MAAUD,EACrC,CAMA,QAAWE,GAEmBC,IAAAA,EAD1B,MAAMC,EAAaD,EAAQhB,KAAKC,MAAO,qBACbe,IAAAA,EAA1B,MAAME,EAAoBF,QAAAA,UAAAA,EAAAA,EAAQhB,KAAKC,MAAO,iDAApBe,IAAAA,OAAAA,EAAAA,WAAAA,IAAAA,EAAAA,EAAqEG,EACzFC,EAAQpB,KAAKc,MAAMM,OAASpB,KAAKC,MAAMmB,MACvCC,EAAgBrB,KAAKK,aAS3B,GAPIgB,EAAcC,eAAiBJ,IAC/BG,EAAcC,cAAcJ,kBAAoBA,GAM5B,YAApBlB,KAAKC,MAAMsB,MAAsBF,EAAcG,eAAgB,CAC/D,MAAyCH,EAAAA,EAAcG,gBAAjDC,UAAEA,EAASC,SAAEA,GAAsBL,EAATM,EAASN,EAAAA,EAAAA,CAAjCI,YAAWC,aACnBL,EAAcG,eAAiBrB,EAAKwB,CAAAA,EAAAA,EACxC,CAEA,OAAOC,OACCX,GAAc,CAAEY,SAAU,CAAEZ,eAC5BG,GAAS,CAAEA,MAAO,CAAEU,UAAWV,EAAMU,UAAWC,aAAcX,EAAMW,eACrEV,GAAAA,CACHW,0BAA0B,GAElC,CAMA,QAAAC,GAEA,CAEOC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mB,QAAI2D,OACrDF,EAAA7D,KAAgB2D,YAAhB,GAEAE,EAAA7D,KAAOC,aAAP,GACA4D,EAAA7D,KAAOc,QAAa,IACpB+C,EAAA7D,KAAO8C,kBAAP,GAEAe,EAAA7D,KAAU0C,QAAqB,MAK3B,MAAMsB,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuCpE,KAAKI,YAAmB,6DAIvEJ,KAAK2D,KAAOC,EACZ5D,KAAKF,kBAAkBG,GAEvBD,KAAKU,eAAiBV,KAAKU,eAAe2D,KAAKrE,KACnD,EAhBA6D,EAVWhE,EAUMyE,eAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createCheckoutPayloadBasedOnScheme as e,createShopperCardsList as t,CTP_IFRAME_NAME as i}from"./utils.js";import o from"./sdks/SrciError.js";import{SchemeNames as s}from"./sdks/utils.js";import r from"../../../../utils/uuid.js";import n from"../../../../core/Errors/AdyenCheckoutError.js";import{isRejected as a,isFulfilled as d}from"../../../../utils/promise-util.js";import c from"../errors/TimeoutError.js";import{executeWithTimeout as l}from"./execute-with-timeout.js";function h(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function m(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},o=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(i).filter((function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable})))),o.forEach((function(t){h(e,t,i[t])}))}return e}function u(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t}(Object(t)).forEach((function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))})),e}var p=function(e){return e.Idle="Idle",e.Loading="Loading",e.ShopperIdentified="ShopperIdentified",e.OneTimePassword="OneTimePassword",e.Ready="Ready",e.Login="Login",e.NotAvailable="NotAvailable",e}({});class S{get shopperAccountFound(){return["Ready","ShopperIdentified"].includes(this.state)}get schemes(){return this.sdkLoader.schemes}updateStoreCookiesConsent(e){this.storeCookies=e}async initialize(){this.setState("Loading");try{this.sdks=await this.sdkLoader.load(this.environment),await this.initiateSdks();const{recognized:e=!1,idTokens:t=null}=await this.verifyIfShopperIsRecognized();if(e)return await this.getShopperProfile(t),void this.setState("Ready");if(!this.shopperIdentity)return void this.setState("NotAvailable");const{isEnrolled:i}=await this.verifyIfShopperIsEnrolled(this.shopperIdentity);if(i)return void this.setState("ShopperIdentified");this.setState("NotAvailable")}catch(e){e instanceof o&&"REQUEST_TIMEOUT"===(null==e?void 0:e.reason)||e instanceof c?this.handleTimeout(e):e instanceof o?console.warn(`Error at ClickToPayService # init: ${e.toString()}`):console.warn(e),this.setState("NotAvailable")}}subscribeOnStateChange(e){this.stateSubscriber=e}async startIdentityValidation(){if(!this.validationSchemeSdk)throw Error("startIdentityValidation: No ValidationSDK set for the validation process");try{const{maskedValidationChannel:e}=await this.validationSchemeSdk.initiateIdentityValidation();this.identityValidationData={maskedShopperContact:e.replace(/\*/g,"•"),selectedNetwork:s[this.validationSchemeSdk.schemeName]},this.setState("OneTimePassword")}catch(e){throw this.validationSchemeSdk=null,e}}async finishIdentityValidation(e){if(!this.validationSchemeSdk)throw Error("finishIdentityValidation: No ValidationSDK set for the validation process");const t=await this.validationSchemeSdk.completeIdentityValidation(e);await this.getShopperProfile([t.idToken]),this.setState("Ready"),this.validationSchemeSdk=null}async checkout(t){if(!t)throw Error("ClickToPayService # checkout: Missing card data");const o=this.sdks.find((e=>e.schemeName===t.scheme)),s=await o.checkout(m({srcDigitalCardId:t.srcDigitalCardId,srcCorrelationId:t.srcCorrelationId},t.isDcfPopupEmbedded&&{windowRef:window.frames[i]},this.storeCookies&&{complianceSettings:{complianceResources:[{complianceType:"REMEMBER_ME",uri:""}]}}));if("COMPLETE"!==s.dcfActionCode)throw new n("ERROR",`Checkout through Scheme DCF did not complete. DCF Action code received: ${s.dcfActionCode}`);return e(t,s,this.environment)}async logout(){if(!this.sdks)throw new n("ERROR","ClickToPayService is not initialized");try{const e=this.sdks.map((e=>e.unbindAppInstance()));await Promise.all(e)}catch(e){e instanceof o?console.warn(`Error at ClickToPayService # logout: ${e.toString()}`):console.warn(e)}this.shopperCards=null,this.identityValidationData=null,this.validationSchemeSdk=null,this.setState("Login")}verifyIfShopperIsEnrolled(e){const{shopperEmail:t}=e;return new Promise(((e,i)=>{const o=this.sdks.map((o=>l((()=>o.identityLookup({identityValue:t,type:"email"})),5e3,new c({source:"identityLookup",scheme:o.schemeName,isTimeoutTriggeredBySchemeSdk:!1})).then((t=>{t.consumerPresent&&!this.validationSchemeSdk&&(this.setSdkForPerformingShopperIdentityValidation(o),e({isEnrolled:!0}))})).catch((e=>{i(e)}))));Promise.allSettled(o).then((()=>{e({isEnrolled:!1})}))}))}setState(e){var t;this.state=e,null===(t=this.stateSubscriber)||void 0===t||t.call(this,this.state)}setSdkForPerformingShopperIdentityValidation(e){this.validationSchemeSdk=e}handleTimeout(e){var t;const i=e instanceof o?new c({source:e.source,scheme:e.scheme,isTimeoutTriggeredBySchemeSdk:!0}):e;var s,r,n,a,d,l;"visa"===i.scheme&&(i.setCorrelationId(null===(s=window.VISA_SDK)||void 0===s?void 0:s.correlationId),(null===(r=window.VISA_SDK)||void 0===r?void 0:r.correlationId)?null===(a=window.VISA_SDK)||void 0===a||null===(n=a.buildClientProfile)||void 0===n||n.call(a):null===(l=window.VISA_SDK)||void 0===l||null===(d=l.buildClientProfile)||void 0===d||d.call(l,this.schemesConfig.visa.srciDpaId));null===(t=this.onTimeout)||void 0===t||t.call(this,i)}async getShopperProfile(e){return new Promise(((i,o)=>{const s=this.sdks.map((t=>t.getSrcProfile(e)));Promise.allSettled(s).then((e=>{e.every(a)&&o(e[0].reason);const s=e.map(((e,t)=>d(e)&&u(m({},e.value),{scheme:this.sdks[t].schemeName}))).filter((e=>!!e));this.shopperCards=t(s),i()}))}))}verifyIfShopperIsRecognized(){return new Promise(((e,t)=>{const i=this.sdks.map((i=>l((()=>i.isRecognized()),5e3,new c({source:"isRecognized",scheme:i.schemeName,isTimeoutTriggeredBySchemeSdk:!1})).then((t=>{t.recognized&&e(t)})).catch((e=>{t(e)}))));Promise.allSettled(i).then((()=>{e({recognized:!1})}))}))}initiateSdks(){const e=this.sdks.map((e=>{const t=this.schemesConfig[e.schemeName];return l((()=>e.init(t,this.srciTransactionId)),5e3,new c({source:"init",scheme:e.schemeName,isTimeoutTriggeredBySchemeSdk:!1}))}));return Promise.all(e)}constructor(e,t,i,o,s){h(this,"sdkLoader",void 0),h(this,"schemesConfig",void 0),h(this,"shopperIdentity",void 0),h(this,"environment",void 0),h(this,"onTimeout",void 0),h(this,"srciTransactionId",r()),h(this,"sdks",void 0),h(this,"validationSchemeSdk",null),h(this,"stateSubscriber",void 0),h(this,"state","Idle"),h(this,"shopperCards",null),h(this,"identityValidationData",null),h(this,"storeCookies",!1),this.sdkLoader=t,this.schemesConfig=e,this.shopperIdentity=o,this.environment=i,this.onTimeout=s}}export{p as CtpState,S as default};
|
|
2
2
|
//# sourceMappingURL=ClickToPayService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/Countdown/utils.ts"],"sourcesContent":["/**\n * Pads a given string or number with zeros.\n *\n * @param value - Value to zero-pad.\n * @param length - Amount of characters to pad.\n * @returns Left-padded number/string.\n */\nexport const zeroPad = (value, length = 2) => {\n if (length === 0) return value;\n const strValue = String(value);\n return strValue.length >= length ? strValue : ('0'.repeat(length) + strValue).slice(length * -1);\n};\n\n/**\n * Calculates the remaining time as a percentage\n *\n * @param start - Start date\n * @param now - Current date\n * @param end - End date\n * @returns Percentage of the remaining time\n */\nexport const getProgressPercentage = (start, now, end) => {\n const difference = end.getTime() - start.getTime();\n return 100 - Math.round(((now.getTime() - start.getTime()) * 100) / difference);\n};\n\n/**\n * Calculates the difference in minutes and seconds from now to endDate\n *\n * @param startTime -\n * @param endTime -\n * @returns Time difference\n */\nexport const getTimeDifference = (startTime, endTime) => {\n const now = new Date();\n const diff = endTime.getTime() - now.getTime();\n const seconds = diff / 1000;\n const percentage = getProgressPercentage(startTime, now, endTime);\n\n return {\n total: diff,\n minutes: zeroPad(Math.floor((seconds / 60) % 60)),\n seconds: zeroPad(Math.floor(seconds % 60)),\n completed: diff <= 0,\n percentage\n };\n};\n"],"names":["zeroPad","value","length","strValue","String","repeat","slice","getProgressPercentage","start","now","end","difference","getTime","Math","round","getTimeDifference","startTime","endTime","Date","diff","seconds","percentage","total","minutes","floor","completed"],"mappings":"AAOaA,MAAAA,EAAU,CAACC,EAAOC,EAAS,KACpC,GAAe,IAAXA,EAAc,OAAOD,EACzB,MAAME,EAAWC,OAAOH,GACxB,OAAOE,EAASD,QAAUA,EAASC,GAAY,IAAIE,OAAOH,GAAUC,GAAUG,
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/Countdown/utils.ts"],"sourcesContent":["/**\n * Pads a given string or number with zeros.\n *\n * @param value - Value to zero-pad.\n * @param length - Amount of characters to pad.\n * @returns Left-padded number/string.\n */\nexport const zeroPad = (value, length = 2) => {\n if (length === 0) return value;\n const strValue = String(value);\n return strValue.length >= length ? strValue : ('0'.repeat(length) + strValue).slice(length * -1);\n};\n\n/**\n * Calculates the remaining time as a percentage\n *\n * @param start - Start date\n * @param now - Current date\n * @param end - End date\n * @returns Percentage of the remaining time\n */\nexport const getProgressPercentage = (start, now, end) => {\n const difference = end.getTime() - start.getTime();\n return 100 - Math.round(((now.getTime() - start.getTime()) * 100) / difference);\n};\n\n/**\n * Calculates the difference in minutes and seconds from now to endDate\n *\n * @param startTime -\n * @param endTime -\n * @returns Time difference\n */\nexport const getTimeDifference = (startTime, endTime) => {\n const now = new Date();\n const diff = endTime.getTime() - now.getTime();\n const seconds = diff / 1000;\n const percentage = getProgressPercentage(startTime, now, endTime);\n\n return {\n total: diff,\n minutes: zeroPad(Math.floor((seconds / 60) % 60)),\n seconds: zeroPad(Math.floor(seconds % 60)),\n completed: diff <= 0,\n percentage\n };\n};\n"],"names":["zeroPad","value","length","strValue","String","repeat","slice","getProgressPercentage","start","now","end","difference","getTime","Math","round","getTimeDifference","startTime","endTime","Date","diff","seconds","percentage","total","minutes","floor","completed"],"mappings":"AAOaA,MAAAA,EAAU,CAACC,EAAOC,EAAS,KACpC,GAAe,IAAXA,EAAc,OAAOD,EACzB,MAAME,EAAWC,OAAOH,GACxB,OAAOE,EAASD,QAAUA,EAASC,GAAY,IAAIE,OAAOH,GAAUC,GAAUG,OAAe,EAATJ,EAAU,EAWrFK,EAAwB,CAACC,EAAOC,EAAKC,KAC9C,MAAMC,EAAaD,EAAIE,UAAYJ,EAAMI,UACzC,OAAO,IAAMC,KAAKC,MAA2C,KAAnCL,EAAIG,UAAYJ,EAAMI,WAAoBD,EAAAA,EAU3DI,EAAoB,CAACC,EAAWC,KACzC,MAAMR,EAAM,IAAIS,KACVC,EAAOF,EAAQL,UAAYH,EAAIG,UAC/BQ,EAAUD,EAAO,IACjBE,EAAad,EAAsBS,EAAWP,EAAKQ,GAEzD,MAAO,CACHK,MAAOH,EACPI,QAASvB,EAAQa,KAAKW,MAAOJ,EAAU,GAAM,KAC7CA,QAASpB,EAAQa,KAAKW,MAAMJ,EAAU,KACtCK,UAAWN,GAAQ,EACnBE,aACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as r,ARIA_CONTEXT_SUFFIX as n}from"../../../../core/Errors/constants.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}function a(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function i(i){var{classNameModifiers:l=[],label:s,isInvalid:u,onChange:b}=i,
|
|
1
|
+
import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as r,ARIA_CONTEXT_SUFFIX as n}from"../../../../core/Errors/constants.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}function a(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function i(i){var{classNameModifiers:l=[],label:s,isInvalid:u,onChange:b,disabled:p=!1}=i,f=a(i,["classNameModifiers","label","isInvalid","onChange","disabled"]);const{uniqueId:y,showErrorElement:d,showContextualElement:O}=f,m=a(f,["uniqueId","showErrorElement","showContextualElement"]);return e("label",{className:"adyen-checkout__checkbox",htmlFor:y},e("input",c(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){o(e,t,r[t])}))}return e}({id:y},m,d&&{"aria-describedby":`${y}${r}`},O&&{"aria-describedby":`${y}${n}`}),{className:t(["adyen-checkout__checkbox__input",[f.className],{"adyen-checkout__checkbox__input--invalid":u},l.map((e=>`adyen-checkout__input--${e}`))]),type:"checkbox",disabled:p,onChange:b})),e("span",{className:"adyen-checkout__checkbox__label"},s))}i.defaultProps={onChange:()=>{}};export{i as default};
|
|
2
2
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sources":["../../../../../../src/components/internal/FormFields/Checkbox/Checkbox.tsx"],"sourcesContent":["import { ComponentChild, h } from 'preact';\nimport cx from 'classnames';\nimport './Checkbox.scss';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\n\ninterface CheckboxProps {\n checked?: boolean;\n classNameModifiers?: string[];\n label?: string | ComponentChild;\n name?: string;\n isInvalid?: boolean;\n onChange?;\n onInput?;\n className?: string;\n value?: string;\n uniqueId?: string;\n showErrorElement?: boolean;\n showContextualElement?: boolean;\n}\n\nexport default function Checkbox({ classNameModifiers = [], label, isInvalid, onChange, ...props }: CheckboxProps) {\n // Strip some values from props. We need to reference them but don't want to set them as attributes.\n const { uniqueId: uid, showErrorElement, showContextualElement, ...newProps } = props;\n\n return (\n <label className=\"adyen-checkout__checkbox\" htmlFor={uid}>\n <input\n id={uid}\n {...newProps}\n {...(showErrorElement && { 'aria-describedby': `${uid}${ARIA_ERROR_SUFFIX}` })}\n {...(showContextualElement && { 'aria-describedby': `${uid}${ARIA_CONTEXT_SUFFIX}` })}\n className={cx([\n 'adyen-checkout__checkbox__input',\n [props.className],\n { 'adyen-checkout__checkbox__input--invalid': isInvalid },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n ])}\n type=\"checkbox\"\n onChange={onChange}\n />\n <span className=\"adyen-checkout__checkbox__label\">{label}</span>\n </label>\n );\n}\n\nCheckbox.defaultProps = {\n onChange: () => {}\n};\n"],"names":["Checkbox","_param","classNameModifiers","label","isInvalid","onChange","props","_object_without_properties","uniqueId","uid","showErrorElement","showContextualElement","newProps","h","className","htmlFor","input","id","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","cx","map","m","type","span","defaultProps"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sources":["../../../../../../src/components/internal/FormFields/Checkbox/Checkbox.tsx"],"sourcesContent":["import { ComponentChild, h } from 'preact';\nimport cx from 'classnames';\nimport './Checkbox.scss';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\n\ninterface CheckboxProps {\n checked?: boolean;\n classNameModifiers?: string[];\n label?: string | ComponentChild;\n name?: string;\n isInvalid?: boolean;\n onChange?;\n onInput?;\n className?: string;\n value?: string;\n uniqueId?: string;\n showErrorElement?: boolean;\n showContextualElement?: boolean;\n disabled?: boolean;\n}\n\nexport default function Checkbox({ classNameModifiers = [], label, isInvalid, onChange, disabled = false, ...props }: CheckboxProps) {\n // Strip some values from props. We need to reference them but don't want to set them as attributes.\n const { uniqueId: uid, showErrorElement, showContextualElement, ...newProps } = props;\n\n return (\n <label className=\"adyen-checkout__checkbox\" htmlFor={uid}>\n <input\n id={uid}\n {...newProps}\n {...(showErrorElement && { 'aria-describedby': `${uid}${ARIA_ERROR_SUFFIX}` })}\n {...(showContextualElement && { 'aria-describedby': `${uid}${ARIA_CONTEXT_SUFFIX}` })}\n className={cx([\n 'adyen-checkout__checkbox__input',\n [props.className],\n { 'adyen-checkout__checkbox__input--invalid': isInvalid },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n ])}\n type=\"checkbox\"\n disabled={disabled}\n onChange={onChange}\n />\n <span className=\"adyen-checkout__checkbox__label\">{label}</span>\n </label>\n );\n}\n\nCheckbox.defaultProps = {\n onChange: () => {}\n};\n"],"names":["Checkbox","_param","classNameModifiers","label","isInvalid","onChange","disabled","props","_object_without_properties","uniqueId","uid","showErrorElement","showContextualElement","newProps","h","className","htmlFor","input","id","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","cx","map","m","type","span","defaultProps"],"mappings":"qjCAqBe,SAASA,EAASC,GAAA,IAAAC,mBAAEA,EAAqB,GAAEC,MAAEA,EAAKC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,GAAW,GAAlEL,EAA4EM,EAA5EC,EAAAP,EAAA,CAAEC,qBAAyBC,QAAOC,YAAWC,WAAUC,aAEpF,MAAQG,SAAUC,EAAGC,iBAAEA,EAAgBC,sBAAEA,GAAuCL,EAAbM,EAAaN,EAAAA,EAAAA,CAAxEE,WAAeE,mBAAkBC,0BAEzC,OACIE,EAACX,QAAAA,CAAMY,UAAU,2BAA2BC,QAASN,GACjDI,EAACG,QAAAA,wUAAAA,CAAAA,CACGC,GAAIR,GACAG,EACCF,GAAoB,CAAE,mBAAoB,GAAGD,IAAMS,KACnDP,GAAyB,CAAE,mBAAoB,GAAGF,IAAMU,MAAsB,CACnFL,UAAWM,EAAG,CACV,kCACA,CAACd,EAAMQ,WACP,CAAE,2CAA4CX,GAC9CF,EAAmBoB,KAAIC,GAAK,0BAA0BA,QAE1DC,KAAK,WACLlB,SAAUA,EACVD,SAAUA,KAEdS,EAACW,OAAAA,CAAKV,UAAU,mCAAmCZ,GAG/D,CAEAH,EAAS0B,aAAe,CACpBrB,SAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as r}from"../../../external/preact/hooks/dist/hooks.js";import t from"../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as n,ARIA_CONTEXT_SUFFIX as o}from"../../../core/Errors/constants.js";function l(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function a(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}function i(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},l=Object.keys(e);for(n=0;n<l.length;n++)t=l[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)t=l[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function u(u){var{setRef:
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as r}from"../../../external/preact/hooks/dist/hooks.js";import t from"../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as n,ARIA_CONTEXT_SUFFIX as o}from"../../../core/Errors/constants.js";function l(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function a(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}function i(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},l=Object.keys(e);for(n=0;n<l.length;n++)t=l[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)t=l[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function u(u){var{setRef:s}=u,c=i(u,["setRef"]);const{autoCorrect:p,classNameModifiers:d,isInvalid:y,isValid:f,readonly:b=null,spellCheck:O,type:m,uniqueId:v,disabled:j}=c,h=c.className;Object.prototype.hasOwnProperty.call(c,"onChange")&&console.error("Error: Form fields that rely on InputBase may not have an onChange property");const P=r((e=>{c.onInput(e)}),[c.onInput]),g=r((e=>{(null==c?void 0:c.onKeyPress)&&c.onKeyPress(e)}),[null==c?void 0:c.onKeyPress]),k=r((e=>{(null==c?void 0:c.onKeyUp)&&c.onKeyUp(e)}),[null==c?void 0:c.onKeyUp]),w=r((e=>{var r,t;null==c||null===(r=c.onBlurHandler)||void 0===r||r.call(c,e),c.trimOnBlur&&(e.target.value=e.target.value.trim()),null==c||null===(t=c.onBlur)||void 0===t||t.call(c,e)}),[c.onBlur,c.onBlurHandler]),I=r((e=>{var r;null==c||null===(r=c.onFocusHandler)||void 0===r||r.call(c,e)}),[c.onFocusHandler]),_=t("adyen-checkout__input",[`adyen-checkout__input--${m}`],h,{"adyen-checkout__input--invalid":y,"adyen-checkout__input--valid":f},d.map((e=>`adyen-checkout__input--${e}`))),{classNameModifiers:x,uniqueId:C,isInvalid:E,isValid:K,addContextualElement:B}=c,N=i(c,["classNameModifiers","uniqueId","isInvalid","isValid","addContextualElement"]);return e("input",a(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){l(e,r,t[r])}))}return e}({id:v},N),{"aria-required":N.required,type:m,className:_,readOnly:b,spellCheck:O,autoCorrect:p,"aria-describedby":`${v}${y?n:o}`,"aria-invalid":y,onInput:P,onBlur:w,onFocus:I,onKeyUp:k,onKeyPress:g,disabled:j,ref:s}))}u.defaultProps={type:"text",classNameModifiers:[]};export{u as default};
|
|
2
2
|
//# sourceMappingURL=InputBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import { h, RefCallback } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends h.JSX.HTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n}\n\nexport default function InputBase({ setRef, ...props }: InputBaseProps) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellCheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: h.JSX.TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n /**\n * Event is fired when a key that produces a character value is pressed down.\n * ENTER keypress also triggers this event.\n *\n * TODO: 'keypress' event is deprecated\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n */\n const handleKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n /**\n * Event is fired when certain keys are pressed (keys that do not output characters):\n * Backspace, Arrow keys, Shift, Ctrl, Command, Option, Esc\n *\n * Exception: ENTER keypress triggers 'onKeyPress' AND 'onKeyUp'\n */\n const handleKeyUp = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: h.JSX.TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, addContextualElement: ace, ...newProps } = props;\n\n return (\n <input\n id={uniqueId}\n {...newProps}\n aria-required={newProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n spellCheck={spellCheck}\n autoCorrect={autoCorrect}\n aria-describedby={`${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}`}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","_param","setRef","props","_object_without_properties","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellCheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","
|
|
1
|
+
{"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import { h, RefCallback } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends h.JSX.HTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n}\n\nexport default function InputBase({ setRef, ...props }: InputBaseProps) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellCheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: h.JSX.TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n /**\n * Event is fired when a key that produces a character value is pressed down.\n * ENTER keypress also triggers this event.\n *\n * TODO: 'keypress' event is deprecated\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n */\n const handleKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n /**\n * Event is fired when certain keys are pressed (keys that do not output characters):\n * Backspace, Arrow keys, Shift, Ctrl, Command, Option, Esc\n *\n * Exception: ENTER keypress triggers 'onKeyPress' AND 'onKeyUp'\n */\n const handleKeyUp = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: h.JSX.TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, addContextualElement: ace, ...newProps } = props;\n\n return (\n <input\n id={uniqueId}\n {...newProps}\n aria-required={newProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n spellCheck={spellCheck}\n autoCorrect={autoCorrect}\n aria-describedby={`${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}`}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","_param","setRef","props","_object_without_properties","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellCheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","newProps","h","input","id","aria-required","required","readOnly","aria-describedby","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","aria-invalid","onFocus","ref","defaultProps"],"mappings":"unCA8Be,SAASA,EAAUC,GAAA,IAAAC,OAAEA,GAAFD,EAAaE,EAAbC,EAA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IC,qBAAsBC,GAAqB5C,EAAb6C,EAAa7C,EAAAA,EAAAA,CAAhHG,qBAAyBM,WAAeL,YAAgBC,UAAasC,yBAE7E,OACIG,EAACC,QAAAA,wUAAAA,CAAAA,CACGC,GAAIvC,GACAoC,GAAAA,CACJI,gBAAeJ,EAASK,SACxB1C,KAAMA,EACNG,UAAWwB,EACXgB,SAAU7C,EACVC,WAAYA,EACZL,YAAaA,EACbkD,mBAAkB,GAAG3C,IAAWL,EAAYiD,EAAoBC,IAChEC,eAAcnD,EACdiB,QAASH,EACTc,OAAQN,EACR8B,QAASvB,EACTR,QAASD,EACTD,WAAYD,EACZZ,SAAUA,EACV+C,IAAK1D,IAGjB,CAEAF,EAAU6D,aAAe,CACrBlD,KAAM,OACNL,mBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../../src/components/internal/FormFields/InputDate/utils.ts"],"sourcesContent":["/**\n * Returns either the date input is supported or not in the current browser\n */\nconst checkDateInputSupport = (): boolean => {\n const input = document.createElement('input');\n input.setAttribute('type', 'date');\n return input.type === 'date';\n};\n\n/**\n * Returns a formatted date\n * @param value -\n * @example\n * formatDate('22111990');\n * // '22/11/1990'\n */\nconst formatDate = (value: string): string => {\n const date = value\n .replace(/\\D|\\s/g, '') // Digits only\n .replace(/^(00)(.*)?/, '01$2') // 00 -> 01\n .replace(/^(3[2-9])(.*)?/, '0$1$2') // 34 -> 03/04\n .replace(/^([4-9])(.*)?/, '0$1') // 4 -> 04\n .replace(/^([0-9]{2})(00)(.*)?/, '$101') // 01/00 -> 01/01\n .replace(/^(3[01])(02)(.*)?/, '29$2') // Force up to day 29 for Feb\n .replace(/^([0-9]{2})([2-9]|1[3-9])(.*)?/, '$10$2') // 01/4 -> 01/04\n .replace(/^([0-9]{2})([0-9]{2})([0-9])/, '$1/$2/$3') // 22111990 -> 22/11/1990\n .replace(/^([0-9]{2})([0-9])/, '$1/$2'); // 2211 -> 22/11\n\n const [day = '', month = '', year = ''] = date.split('/');\n\n // Check leap year\n if (year.length === 4 && day === '29' && month === '02' && (Number(year) % 4 !== 0 || (year.substr(2, 2) === '00' && Number(year) % 400 !== 0))) {\n return date.replace(/^29/, '28');\n }\n\n return date;\n};\n\n/**\n * Receives a formatted date and returns it as the API expects it\n * @param value -\n * @example\n * unformatDate('22/11/1990');\n * // '1990-11-22'\n */\nconst unformatDate = (value = ''): string => {\n if (value.indexOf('/') === -1) return value;\n const [day = '', month = '', year = ''] = value.split('/');\n if (!day || !month || !year) return null;\n return `${year}-${month}-${day}`;\n};\n\nexport { checkDateInputSupport, formatDate, unformatDate };\n"],"names":["checkDateInputSupport","input","document","createElement","setAttribute","type","formatDate","value","date","replace","day","month","year","split","length","Number","substr","unformatDate","indexOf"],"mappings":"MAGMA,EAAwB,KAC1B,MAAMC,EAAQC,SAASC,cAAc,SAErC,OADAF,EAAMG,aAAa,OAAQ,QACL,SAAfH,EAAMI,IAAS,EAUpBC,EAAcC,IAChB,MAAMC,EAAOD,EACRE,QAAQ,SAAU,IAClBA,QAAQ,aAAc,QACtBA,QAAQ,iBAAkB,SAC1BA,QAAQ,gBAAiB,OACzBA,QAAQ,uBAAwB,QAChCA,QAAQ,oBAAqB,QAC7BA,QAAQ,iCAAkC,SAC1CA,QAAQ,+BAAgC,YACxCA,QAAQ,qBAAsB,UAE5BC,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAMJ,EAAKK,MAAM,KAGrD,OAAoB,IAAhBD,EAAKE,QAAwB,OAARJ,GAA0B,OAAVC,IAAmBI,OAAOH,GAAQ,GAAM,GAA4B,OAAtBA,EAAKI,OAAO,EAAG,IAAeD,OAAOH,GAAQ,KAAQ,GACjIJ,EAAKC,QAAQ,MAAO,MAGxBD,CAAAA,EAULS,EAAe,CAACV,EAAQ,MAC1B,
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../../src/components/internal/FormFields/InputDate/utils.ts"],"sourcesContent":["/**\n * Returns either the date input is supported or not in the current browser\n */\nconst checkDateInputSupport = (): boolean => {\n const input = document.createElement('input');\n input.setAttribute('type', 'date');\n return input.type === 'date';\n};\n\n/**\n * Returns a formatted date\n * @param value -\n * @example\n * formatDate('22111990');\n * // '22/11/1990'\n */\nconst formatDate = (value: string): string => {\n const date = value\n .replace(/\\D|\\s/g, '') // Digits only\n .replace(/^(00)(.*)?/, '01$2') // 00 -> 01\n .replace(/^(3[2-9])(.*)?/, '0$1$2') // 34 -> 03/04\n .replace(/^([4-9])(.*)?/, '0$1') // 4 -> 04\n .replace(/^([0-9]{2})(00)(.*)?/, '$101') // 01/00 -> 01/01\n .replace(/^(3[01])(02)(.*)?/, '29$2') // Force up to day 29 for Feb\n .replace(/^([0-9]{2})([2-9]|1[3-9])(.*)?/, '$10$2') // 01/4 -> 01/04\n .replace(/^([0-9]{2})([0-9]{2})([0-9])/, '$1/$2/$3') // 22111990 -> 22/11/1990\n .replace(/^([0-9]{2})([0-9])/, '$1/$2'); // 2211 -> 22/11\n\n const [day = '', month = '', year = ''] = date.split('/');\n\n // Check leap year\n if (year.length === 4 && day === '29' && month === '02' && (Number(year) % 4 !== 0 || (year.substr(2, 2) === '00' && Number(year) % 400 !== 0))) {\n return date.replace(/^29/, '28');\n }\n\n return date;\n};\n\n/**\n * Receives a formatted date and returns it as the API expects it\n * @param value -\n * @example\n * unformatDate('22/11/1990');\n * // '1990-11-22'\n */\nconst unformatDate = (value = ''): string => {\n if (value.indexOf('/') === -1) return value;\n const [day = '', month = '', year = ''] = value.split('/');\n if (!day || !month || !year) return null;\n return `${year}-${month}-${day}`;\n};\n\nexport { checkDateInputSupport, formatDate, unformatDate };\n"],"names":["checkDateInputSupport","input","document","createElement","setAttribute","type","formatDate","value","date","replace","day","month","year","split","length","Number","substr","unformatDate","indexOf"],"mappings":"MAGMA,EAAwB,KAC1B,MAAMC,EAAQC,SAASC,cAAc,SAErC,OADAF,EAAMG,aAAa,OAAQ,QACL,SAAfH,EAAMI,IAAS,EAUpBC,EAAcC,IAChB,MAAMC,EAAOD,EACRE,QAAQ,SAAU,IAClBA,QAAQ,aAAc,QACtBA,QAAQ,iBAAkB,SAC1BA,QAAQ,gBAAiB,OACzBA,QAAQ,uBAAwB,QAChCA,QAAQ,oBAAqB,QAC7BA,QAAQ,iCAAkC,SAC1CA,QAAQ,+BAAgC,YACxCA,QAAQ,qBAAsB,UAE5BC,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAMJ,EAAKK,MAAM,KAGrD,OAAoB,IAAhBD,EAAKE,QAAwB,OAARJ,GAA0B,OAAVC,IAAmBI,OAAOH,GAAQ,GAAM,GAA4B,OAAtBA,EAAKI,OAAO,EAAG,IAAeD,OAAOH,GAAQ,KAAQ,GACjIJ,EAAKC,QAAQ,MAAO,MAGxBD,CAAAA,EAULS,EAAe,CAACV,EAAQ,MAC1B,IAA2B,IAAvBA,EAAMW,QAAQ,KAAa,OAAOX,EACtC,MAAOG,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAML,EAAMM,MAAM,KACtD,OAAKH,GAAQC,GAAUC,EAChB,GAAGA,KAAQD,KAASD,IADS,IACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import n from"../../../../../_virtual/index.js";import o from"../../../Img/Img.js";function
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import n from"../../../../../_virtual/index.js";import o from"../../../Img/Img.js";import{useMemo as r}from"../../../../../external/preact/hooks/dist/hooks.js";function a(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(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),o.forEach((function(t){a(e,t,n[t])}))}return e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function l(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function d(t){var{filterable:n,toggleButtonRef:o}=t,r=l(t,["filterable","toggleButtonRef"]);if(n){const{id:t}=r,n=l(r,["id"]);return e("div",i(c({},n),{ref:o}))}return e("button",i(c({id:r.id,"aria-describedby":r.ariaDescribedBy,type:"button"},r),{ref:o}))}function u(a){const{active:i,selected:l,inputText:u,readonly:s,showList:p,required:_}=a,f=r((()=>{const e=l.selectedOptionName||l.name;return!0!==("string"==typeof e&&""!==e.trim())}),[l,a.placeholder]),b=l.selectedOptionName||l.name||a.placeholder||"",y=p?u:b,m=s?null:a.filterable?e=>{e.preventDefault(),document.activeElement===a.filterInputRef.current?a.showList||a.toggleList(e):a.filterInputRef.current&&a.filterInputRef.current.focus()}:a.toggleList,O=s?null:a.onFocus,g=i.id?`listItem-${i.id}`:"";return e(d,c({className:n({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":s,"adyen-checkout__dropdown__button--active":p,"adyen-checkout__dropdown__button--invalid":a.isInvalid,"adyen-checkout__dropdown__button--valid":a.isValid,"adyen-checkout__dropdown__button--disabled":l.disabled}),disabled:a.disabled,filterable:a.filterable,onClick:m,onKeyDown:s?null:a.onButtonKeyDown,toggleButtonRef:a.toggleButtonRef},a.allowIdOnButton&&a.id&&{id:a.id}),a.filterable?e(t,null,!p&&l.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:l.icon,alt:l.name}),e("input",{value:y,"aria-autocomplete":"list","aria-controls":a.selectListId,"aria-expanded":p,"aria-owns":a.selectListId,autoComplete:"off",className:"adyen-checkout__filter-input",onInput:a.onInput,onFocus:O,ref:a.filterInputRef,role:"combobox","aria-activedescendant":g,type:"text",readOnly:a.readonly,id:a.id,"aria-describedby":a.ariaDescribedBy,required:_}),!p&&l.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},l.secondaryText)):e(t,null,l.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:l.icon,alt:l.name}),e("span",{className:n("adyen-checkout__dropdown__button__text",{"adyen-checkout__dropdown__button__text-placeholder":f})},b),l.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},l.secondaryText)))}export{u as default};
|
|
2
2
|
//# sourceMappingURL=SelectButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonProps } from '../types';\nimport Img from '../../../Img';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, ...props }) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef} />;\n }\n\n return <button id={props.id} aria-describedby={props.ariaDescribedBy} type={'button'} {...props} ref={toggleButtonRef} />;\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n const displayInputText = showList ? inputText : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n const onFocusHandler = readonly ? null : props.onFocus;\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n // Only for some dropdowns e.g. the one found in installments when it is just in the form of a single dropdown, do we want to add an id that links to a label's for attr\n // If we allow an id to be added to the buttons in CtPCardsList, for example, unit tests start failing because it seems a button with an id no longer has a name property that can be used\n // as a qualifier in findByRole\n {...(props.allowIdOnButton && props.id && { id: props.id })}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span
|
|
1
|
+
{"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonProps } from '../types';\nimport Img from '../../../Img';\nimport { useMemo } from 'preact/hooks';\nimport classnames from 'classnames';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, ...props }) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef} />;\n }\n\n return <button id={props.id} aria-describedby={props.ariaDescribedBy} type={'button'} {...props} ref={toggleButtonRef} />;\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n const isShowingPlaceholder = useMemo(() => {\n const displayText = selected.selectedOptionName || selected.name;\n const isValidValue = typeof displayText === 'string' && displayText.trim() !== '';\n return isValidValue !== true;\n }, [selected, props.placeholder]);\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n const displayInputText = showList ? inputText : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n const onFocusHandler = readonly ? null : props.onFocus;\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n // Only for some dropdowns e.g. the one found in installments when it is just in the form of a single dropdown, do we want to add an id that links to a label's for attr\n // If we allow an id to be added to the buttons in CtPCardsList, for example, unit tests start failing because it seems a button with an id no longer has a name property that can be used\n // as a qualifier in findByRole\n {...(props.allowIdOnButton && props.id && { id: props.id })}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span\n className={classnames('adyen-checkout__dropdown__button__text', {\n 'adyen-checkout__dropdown__button__text-placeholder': isShowingPlaceholder\n })}\n >\n {displayText}\n </span>\n {selected.secondaryText && <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>}\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className=\"adyen-checkout__filter-input\"\n onInput={props.onInput}\n onFocus={onFocusHandler}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && selected.secondaryText && (\n <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>\n )}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","_param","filterable","toggleButtonRef","props","_object_without_properties","id","strippedProps","h","div","ref","button","aria-describedby","ariaDescribedBy","type","SelectButton","active","selected","inputText","readonly","showList","required","isShowingPlaceholder","useMemo","displayText","selectedOptionName","name","trim","placeholder","displayInputText","onClickHandler","e","preventDefault","document","activeElement","filterInputRef","current","toggleList","focus","onFocusHandler","onFocus","currentSelectedItemId","className","cx","isInvalid","isValid","disabled","onClick","onKeyDown","onButtonKeyDown","allowIdOnButton","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-controls","selectListId","aria-expanded","aria-owns","autoComplete","onInput","role","aria-activedescendant","readOnly","secondaryText","span","classnames"],"mappings":"+5CAOA,SAASA,EAAoBC,GAAA,IAAAC,WAAEA,EAAUC,gBAAEA,GAAdF,EAAkCG,EAAlCC,EAAAJ,EAAA,CAAEC,aAAYC,oBACvC,GAAID,EAAY,CAEZ,MAAMI,GAAEA,GAAyBF,EAAlBG,EAAkBH,EAAAA,EAAAA,CAAzBE,OACR,OAAOE,EAACC,MAAQF,EAAAA,EAAAA,CAAAA,EAAAA,GAAAA,CAAeG,IAAKP,IACxC,CAEA,OAAOK,EAACG,SAAAA,EAAAA,EAAAA,CAAOL,GAAIF,EAAME,GAAIM,mBAAkBR,EAAMS,gBAAiBC,KAAM,UAAcV,GAAAA,CAAOM,IAAKP,IAC1G,CAEA,SAASY,EAAaX,GAClB,MAAMY,OAAEA,EAAMC,SAAEA,EAAQC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,EAAQC,SAAEA,GAAajB,EAEhEkB,EAAuBC,GAAQ,KACjC,MAAMC,EAAcP,EAASQ,oBAAsBR,EAASS,KAE5D,OAAwB,KADoB,iBAAhBF,GAAmD,KAAvBA,EAAYG,OAC5C,GACzB,CAACV,EAAUb,EAAMwB,cAGdJ,EAAcP,EAASQ,oBAAsBR,EAASS,MAAQtB,EAAMwB,aAAe,GAInFC,EAAmBT,EAAWF,EAAYM,EAc1CM,EAAiBX,EAAW,KAAOf,EAAMF,WAZ7B6B,IACdA,EAAEC,iBACEC,SAASC,gBAAkB9B,EAAM+B,eAAeC,QAC3ChC,EAAMgB,UACPhB,EAAMiC,WAAWN,GAEd3B,EAAM+B,eAAeC,SAAShC,EAAM+B,eAAeC,QAAQE,OAAK,EAMRlC,EAAMiC,WAEvEE,EAAiBpB,EAAW,KAAOf,EAAMoC,QAGzCC,EAAwBzB,EAAOV,GAAK,YAAYU,EAA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|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{electronicFormat as t,getCountryCode as n,
|
|
1
|
+
import{electronicFormat as t,getCountryCode as n,getIbanCountrySpecification as e,iso13616Prepare as i,iso7064Mod97_10 as l,regex as s}from"./utils.js";import{isEmpty as o}from"../../../utils/validator-utils.js";function r(t,n=null){this.status=t,this.code=n}const a=n=>{const e=t(n),o=i(e);return 1===l(o)&&(t=>{const n=t.slice(0,2),e=s(t,n);return e.test&&e.test(t.slice(4))||!1})(e)},u=i=>{const l=t(i);if(i.length<2)return new r("no-validate","TOO_SHORT");const s=n(l),o=e(s);return o?l.length>o.length?new r("invalid","TOO_LONG"):l.length===o.length?a(i)?new r("valid","VALID"):new r("invalid","INVALID_IBAN"):new r("no-validate","UNKNOWN"):new r("invalid","INVALID_COUNTRY")},c=t=>!o(t)||null;export{u as checkIbanStatus,c as isValidHolder,a as isValidIBAN};
|
|
2
2
|
//# sourceMappingURL=validate.js.map
|