@adyen/adyen-web 6.42.0 → 6.44.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 +4 -2
- 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 +26 -27
- package/dist/es/adyen.css +4 -2
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVC.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFields.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFields.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +1 -1
- package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCard.js +1 -1
- package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es/components/Dropin/Dropin.js +1 -1
- package/dist/es/components/Dropin/Dropin.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es/components/internal/Address/Address.js +1 -1
- package/dist/es/components/internal/Address/Address.js.map +1 -1
- package/dist/es/components/internal/Address/validate.js.map +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/Button/CopyButton.js +1 -1
- package/dist/es/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es/components/internal/Button/CopyIconButton.js +1 -1
- package/dist/es/components/internal/Button/CopyIconButton.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es/components/internal/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/FormFields/Select/components/SelectListItem.js +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
- package/dist/es/components/internal/LoadingWrapper/LoadingWrapper.js +1 -1
- package/dist/es/components/internal/LoadingWrapper/LoadingWrapper.js.map +1 -1
- package/dist/es/components/internal/Modal/Modal.js +1 -1
- package/dist/es/components/internal/Modal/Modal.js.map +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es/components/internal/QRLoader/components/QRFinalState.js +1 -1
- package/dist/es/components/internal/QRLoader/components/QRFinalState.js.map +1 -1
- package/dist/es/components/internal/QRLoader/components/QRLoaderPendingState.js +2 -0
- package/dist/es/components/internal/QRLoader/components/QRLoaderPendingState.js.map +1 -0
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es/components/internal/Tag/Tag.js +2 -0
- package/dist/es/components/internal/Tag/Tag.js.map +1 -0
- package/dist/es/components/internal/Tag/Tag.module.scss.js +2 -0
- package/dist/es/components/internal/Tag/Tag.module.scss.js.map +1 -0
- package/dist/es/components/internal/Tag/TagList.js +2 -0
- package/dist/es/components/internal/Tag/TagList.js.map +1 -0
- package/dist/es/components/internal/Tag/TagList.module.scss.js +2 -0
- package/dist/es/components/internal/Tag/TagList.module.scss.js.map +1 -0
- package/dist/es/components/internal/Tag/types.js +2 -0
- package/dist/es/components/internal/Tag/types.js.map +1 -0
- 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/Errors/SRMessages.js +1 -1
- package/dist/es/core/Errors/SRMessages.js.map +1 -1
- package/dist/es/core/Errors/SRPanel.js.map +1 -1
- package/dist/es/core/Errors/SRPanelProvider.js.map +1 -1
- package/dist/es/core/Errors/constants.js +1 -1
- package/dist/es/core/Errors/constants.js.map +1 -1
- package/dist/es/core/Errors/useA11yReporter.js +1 -1
- package/dist/es/core/Errors/useA11yReporter.js.map +1 -1
- package/dist/es/core/Errors/useLoadingA11yReporter.js +2 -0
- package/dist/es/core/Errors/useLoadingA11yReporter.js.map +1 -0
- package/dist/es/core/Errors/utils.js +1 -1
- package/dist/es/core/Errors/utils.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/external/preact/compat/dist/compat.js +1 -1
- package/dist/es/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es/external/preact/dist/preact.js +1 -1
- package/dist/es/external/preact/dist/preact.js.map +1 -1
- package/dist/es/external/preact/hooks/dist/hooks.js +1 -1
- package/dist/es/external/preact/hooks/dist/hooks.js.map +1 -1
- package/dist/es/index.d.ts +26 -27
- package/dist/es/packages/server/translations/en-US.json.js +1 -1
- package/dist/es/utils/useForm/useForm.js +1 -1
- package/dist/es/utils/useForm/useForm.js.map +1 -1
- package/dist/es-legacy/adyen.css +4 -2
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyIconButton.js +1 -1
- package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es-legacy/components/internal/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/FormFields/Select/components/SelectListItem.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
- package/dist/es-legacy/components/internal/LoadingWrapper/LoadingWrapper.js +1 -1
- package/dist/es-legacy/components/internal/LoadingWrapper/LoadingWrapper.js.map +1 -1
- package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
- package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRFinalState.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRFinalState.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRLoaderPendingState.js +2 -0
- package/dist/es-legacy/components/internal/QRLoader/components/QRLoaderPendingState.js.map +1 -0
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es-legacy/components/internal/Tag/Tag.js +2 -0
- package/dist/es-legacy/components/internal/Tag/Tag.js.map +1 -0
- package/dist/es-legacy/components/internal/Tag/Tag.module.scss.js +2 -0
- package/dist/es-legacy/components/internal/Tag/Tag.module.scss.js.map +1 -0
- package/dist/es-legacy/components/internal/Tag/TagList.js +2 -0
- package/dist/es-legacy/components/internal/Tag/TagList.js.map +1 -0
- package/dist/es-legacy/components/internal/Tag/TagList.module.scss.js +2 -0
- package/dist/es-legacy/components/internal/Tag/TagList.module.scss.js.map +1 -0
- package/dist/es-legacy/components/internal/Tag/types.js +2 -0
- package/dist/es-legacy/components/internal/Tag/types.js.map +1 -0
- 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/Errors/SRMessages.js +1 -1
- package/dist/es-legacy/core/Errors/SRMessages.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRPanelProvider.js.map +1 -1
- package/dist/es-legacy/core/Errors/constants.js +1 -1
- package/dist/es-legacy/core/Errors/constants.js.map +1 -1
- package/dist/es-legacy/core/Errors/useA11yReporter.js +1 -1
- package/dist/es-legacy/core/Errors/useA11yReporter.js.map +1 -1
- package/dist/es-legacy/core/Errors/useLoadingA11yReporter.js +2 -0
- package/dist/es-legacy/core/Errors/useLoadingA11yReporter.js.map +1 -0
- package/dist/es-legacy/core/Errors/utils.js +1 -1
- package/dist/es-legacy/core/Errors/utils.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/external/preact/compat/dist/compat.js +1 -1
- package/dist/es-legacy/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
- package/dist/es-legacy/external/preact/hooks/dist/hooks.js +1 -1
- package/dist/es-legacy/external/preact/hooks/dist/hooks.js.map +1 -1
- package/dist/es-legacy/packages/server/translations/en-US.json.js +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
- package/package.json +11 -11
- package/styles/adyen.css +4 -2
package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecuredField.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/securedField/SecuredField.ts"],"sourcesContent":["import * as logger from '../utilities/logger';\nimport createIframe from './utils/createIframe';\nimport { removeAllChildren, selectOne } from '../utilities/dom';\nimport { off, on } from '../../../../../utils/listenerUtils';\nimport postMessageToIframe from '../CSF/utils/iframes/postMessageToIframe';\nimport { isChromeVoxPostMsg, isWebpackPostMsg, originCheckPassed } from '../CSF/utils/iframes/postMessageValidation';\nimport {\n CVC_POLICY_HIDDEN,\n CVC_POLICY_OPTIONAL,\n DATE_POLICY_HIDDEN,\n DATE_POLICY_OPTIONAL,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE\n} from '../constants';\nimport { generateRandomNumber } from '../utilities/commonUtils';\nimport { CVCPolicyType, DatePolicyType, RtnType_callbackFn, RtnType_noParamVoidFn, RtnType_postMessageListener, SFFeedbackObj } from '../types';\nimport AbstractSecuredField from './AbstractSecuredField';\nimport { AriaConfig, IframeConfigObject, SecuredFieldSetupObject, SecuredFieldCommonProps } from '../types';\nimport { reject } from '../../../../../utils/commonUtils';\nimport { processAriaConfig } from './utils/processAriaConfig';\nimport { processPlaceholders } from './utils/processPlaceholders';\nimport Language from '../../../../../language/Language';\nimport { hasOwnProperty } from '../../../../../utils/hasOwnProperty';\nimport { Placeholders } from '../../SFP/types';\nimport './SecuredField.scss';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../../core/Analytics/events/AnalyticsErrorEvent';\n\nconst logPostMsg = false;\nconst doLog = false;\n\nclass SecuredField extends AbstractSecuredField {\n public override sfConfig: SecuredFieldCommonProps;\n\n constructor(pSetupObj: SecuredFieldSetupObject, i18n: Language) {\n super();\n\n /**\n * List of props to exclude from being set on this.sfConfig.\n * These props are only required for internal purposes. They do not get sent to the iframe\n */\n const deltaPropsArr: string[] = ['loadingContext', 'holderEl', 'iframeSrc', 'showContextualElement', 'placeholders'];\n\n /**\n * List of props from setup object that will be set on this.sfConfig\n * These props will all end up being sent to the iframe\n */\n const configVarsFromSetUpObj = reject(deltaPropsArr).from(pSetupObj);\n\n // Copy passed setup object values to this.sfConfig\n this.sfConfig = {\n // ...this.sfConfig, // Do we need to do this? Pretty sure we don't\n ...configVarsFromSetUpObj,\n // Break references on iframeUIConfig object so we can overwrite its properties in each securedField instance\n iframeUIConfig: { ...configVarsFromSetUpObj.iframeUIConfig }\n } as SecuredFieldCommonProps;\n\n /**\n * Extract values only needed for init\n */\n const { iframeSrc, placeholders, showContextualElement } = pSetupObj;\n\n /**\n * Store those passed setup object values that are needed in multiple functions\n */\n this.loadingContext = pSetupObj.loadingContext;\n this.holderEl = pSetupObj.holderEl;\n this.submitAnalytics = pSetupObj.submitAnalytics;\n this.componentType = pSetupObj.componentType;\n\n /**\n * Initiate other values on 'this' through setters\n */\n this.isValid = false;\n this.iframeContentWindow = null;\n this.numKey = generateRandomNumber();\n this.isEncrypted = false;\n this.hasError = false;\n this.errorType = '';\n this.cvcPolicy = pSetupObj.cvcPolicy;\n this.expiryDatePolicy = pSetupObj.expiryDatePolicy;\n\n if (process.env.NODE_ENV === 'development' && doLog) {\n logger.log(\n '### SecuredField::constructor:: this.sfConfig.fieldType=',\n this.sfConfig.fieldType,\n 'isValid=',\n this._isValid,\n 'numKey=',\n this.numKey\n );\n logger.log('\\n');\n }\n\n return this.init(i18n, iframeSrc, placeholders, showContextualElement);\n }\n\n init(i18n: Language, iframeSrc: string, placeholders: Placeholders, showContextualElement: boolean): SecuredField {\n /**\n * Ensure all fields have a related ariaConfig object containing, at minimum, an iframeTitle property and a (translated) errors object\n */\n const processedAriaConfig: AriaConfig = processAriaConfig(this.sfConfig.txVariant, this.sfConfig.fieldType, i18n, showContextualElement);\n // Set result back onto config object\n this.sfConfig.iframeUIConfig.ariaConfig = processedAriaConfig;\n\n // Set result back onto config object\n this.sfConfig.iframeUIConfig.placeholders = processPlaceholders(this.sfConfig.txVariant, this.sfConfig.fieldType, placeholders);\n\n /**\n * Configure, create & reference iframe and add load listener\n */\n const iframeConfig = {\n src: iframeSrc,\n title: processedAriaConfig[this.sfConfig.fieldType].iframeTitle,\n policy: 'origin'\n };\n\n const iframeEl: HTMLIFrameElement = createIframe(iframeConfig);\n\n // Place the iframe into the holder\n this.holderEl.appendChild(iframeEl);\n\n // Now examine the holder to get an actual DOM node\n const iframe: HTMLIFrameElement = selectOne(this.holderEl, '.js-iframe');\n\n if (iframe) {\n if (!iframe.contentWindow) {\n // Warn the dev\n console.error(\n 'ERROR: Trying to initialise a securedField iframe, but the iframe.contentWindow is undefined. Are you sure the element into which the Card component is being mounted already exists in the DOM *before* the Card component is mounted?'\n );\n // Log the error\n const event = new AnalyticsErrorEvent({\n component: this.componentType,\n code: ErrorEventCode.SECURED_FIELDS_IFRAME_CONTENT_WINDOW_NOT_FOUND,\n errorType: ErrorEventType.implementation,\n message: `Trying to initialise an iframe for ${this.sfConfig.fieldType}, but the iframe.contentWindow is undefined`\n });\n\n this.submitAnalytics?.(event);\n }\n\n this.iframeContentWindow = iframe.contentWindow;\n\n // Create reference to bound fn (see getters/setters for binding)\n this.iframeOnLoadListener = this.iframeOnLoadListenerFn;\n\n on(iframe, 'load', this.iframeOnLoadListener, false);\n }\n\n this.iframeRef = iframe;\n\n return this;\n }\n\n iframeOnLoadListenerFn(): void {\n // Create reference to bound fn (see getters/setters for binding)\n this.postMessageListener = this.postMessageListenerFn;\n\n // Add general listener for 'message' EVENT - the event that 'powers' postMessage\n on(window, 'message', this.postMessageListener, false);\n\n // Create and send config object to iframe\n const configObj: IframeConfigObject = {\n ...this.sfConfig,\n numKey: this.numKey\n };\n\n if (window._b$dl) console.log('### SecuredField:::: onIframeLoaded:: created configObj=', configObj);\n\n postMessageToIframe(configObj, this.iframeContentWindow, this.loadingContext);\n //--\n\n // Callback to say iframe loaded\n this.onIframeLoadedCallback();\n }\n\n postMessageListenerFn(event: MessageEvent): void {\n // Check message is from expected domain\n if (!originCheckPassed(event, this.loadingContext, this.sfConfig.showWarnings)) {\n return;\n }\n\n // TODO - for debugging purposes this would always be useful to see\n // logger.log('\\n',this.sfConfig.fieldType,'### CSF SecuredField::postMessageListener:: event.data=',event.data);\n\n if (process.env.NODE_ENV === 'development' && logPostMsg) {\n logger.log(\n '\\n###CSF SecuredField::postMessageListener:: DOMAIN & ORIGIN MATCH, NO WEBPACK WEIRDNESS fieldType=',\n this.sfConfig.fieldType,\n 'txVariant=',\n this.sfConfig.txVariant,\n 'this.numKey=',\n this.numKey\n );\n }\n\n // PARSE DATA OBJECT (thus testing if it is a JSON string) - OR TRY & WORK OUT WHY THE PARSING FAILED\n let feedbackObj: SFFeedbackObj;\n\n try {\n feedbackObj = JSON.parse(event.data);\n } catch (e) {\n // Was the message generated by webpack?\n if (isWebpackPostMsg(event)) {\n if (this.sfConfig.showWarnings) logger.log('### SecuredField::postMessageListenerFn:: PARSE FAIL - WEBPACK');\n return;\n }\n\n // Was the message generated by ChromeVox?\n if (isChromeVoxPostMsg(event)) {\n if (this.sfConfig.showWarnings) logger.log('### SecuredField::postMessageListenerFn:: PARSE FAIL - CHROMEVOX');\n return;\n }\n\n if (this.sfConfig.showWarnings)\n logger.log('### SecuredField::postMessageListenerFn:: PARSE FAIL - UNKNOWN REASON: event.data=', event.data);\n return;\n }\n\n // CHECK FOR EXPECTED PROPS\n const hasMainProps: boolean = hasOwnProperty(feedbackObj, 'action') && hasOwnProperty(feedbackObj, 'numKey');\n\n if (!hasMainProps) {\n if (this.sfConfig.showWarnings) logger.warn('WARNING SecuredField :: postMessage listener for iframe :: data mismatch!');\n return;\n }\n\n if (process.env.NODE_ENV === 'development' && logPostMsg) {\n logger.log('### SecuredField::postMessageListener:: feedbackObj.numKey=', feedbackObj.numKey);\n }\n\n if (this.numKey !== feedbackObj.numKey) {\n if (this.sfConfig.showWarnings) {\n logger.warn(\n 'WARNING SecuredField :: postMessage listener for iframe :: data mismatch! (Probably a message from an unrelated securedField)'\n );\n }\n return;\n }\n\n // VALIDATION CHECKS PASSED - DECIDE ON COURSE OF ACTION\n if (process.env.NODE_ENV === 'development' && logPostMsg) {\n logger.log(\n '### SecuredField::postMessageListener:: numkeys match PROCEED WITH POST MESSAGE PROCESSING fieldType=',\n this.sfConfig.fieldType,\n 'txVariant=',\n this.sfConfig.txVariant\n );\n }\n\n switch (feedbackObj.action) {\n case 'encryption':\n this.isValid = true;\n this.onEncryptionCallback(feedbackObj);\n break;\n\n case 'config':\n if (window._b$dl)\n console.log('### SecuredField::postMessageListenerFn:: configured - calling onConfigCallback', feedbackObj.fieldType);\n this.onConfigCallback(feedbackObj);\n break;\n\n case 'focus':\n this.onFocusCallback(feedbackObj);\n break;\n\n case 'binValue':\n this.onBinValueCallback(feedbackObj);\n break;\n\n // iOS ONLY - RE. iOS BUGS AROUND BLUR AND FOCUS EVENTS\n case 'touch':\n this.onTouchstartCallback(feedbackObj);\n break;\n\n // Only happens for Firefox & IE <= 11\n case 'shifttab':\n this.onShiftTabCallback(feedbackObj);\n break;\n\n case 'autoComplete':\n this.onAutoCompleteCallback(feedbackObj);\n break;\n\n case 'enterKeyPressed':\n this.onKeyPressedCallback(feedbackObj);\n break;\n\n case 'encryptionError': {\n const event = new AnalyticsErrorEvent({\n component: this.componentType,\n code: feedbackObj.code,\n errorType: ErrorEventType.internal,\n message: `${feedbackObj.error}. Field= ${this.sfConfig.fieldType}`\n });\n\n this.submitAnalytics?.(event);\n break;\n }\n\n /**\n * Validate, because action =\n *\n * 'brand'\n * 'delete'\n * 'luhnCheck'\n * 'incomplete field' (an error that follows from a focus (blur) event)\n * 'incorrectly filled field' (an error that follows from a focus (blur) event)\n * 'numberKeyPressed' (or date-, month-, year-, cvc-, pin-, or iban- KeyPressed)\n * - since we have no \"error\" action \"...KeyPressed\" is the action type on most error events (other than \"incomplete field, 'incorrectly filled field' or \"luhnCheck\")\n * and often these error events representing the clearing of an existing error\n */\n default:\n // If we're validation handling (& not encryption handling) field must be invalid\n this.isValid = false;\n this.onValidationCallback(feedbackObj);\n }\n }\n\n destroy(): void {\n off(window, 'message', this.postMessageListener, false);\n off(this.iframeRef, 'load', this.iframeOnLoadListener, false);\n this.iframeContentWindow = null;\n removeAllChildren(this.holderEl);\n }\n\n /**\n * Returns whether the securedField is hidden OR whether it is optional and not in error\n */\n isOptionalOrHidden(): boolean {\n if (\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_DATE ||\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_MONTH ||\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_YEAR\n ) {\n switch (this.expiryDatePolicy) {\n case DATE_POLICY_HIDDEN:\n return true;\n case DATE_POLICY_OPTIONAL:\n return !this.hasError;\n default:\n return false;\n }\n }\n\n if (this.sfConfig.fieldType === ENCRYPTED_SECURITY_CODE) {\n switch (this.cvcPolicy) {\n case CVC_POLICY_HIDDEN:\n return true;\n case CVC_POLICY_OPTIONAL:\n return !this.hasError;\n default:\n return false;\n }\n }\n\n // Any other type of securedField is not optional & can't be hidden\n return false;\n }\n\n // /////// ALLOCATE CALLBACKS /////////\n onIframeLoaded(callbackFn: RtnType_noParamVoidFn): SecuredField {\n this.onIframeLoadedCallback = callbackFn;\n return this;\n }\n\n onEncryption(callbackFn: RtnType_callbackFn): SecuredField {\n this.onEncryptionCallback = callbackFn;\n return this;\n }\n\n onValidation(callbackFn: RtnType_callbackFn): SecuredField {\n this.onValidationCallback = callbackFn;\n return this;\n }\n\n onConfig(callbackFn: RtnType_callbackFn): SecuredField {\n this.onConfigCallback = callbackFn;\n return this;\n }\n\n onFocus(callbackFn: RtnType_callbackFn): SecuredField {\n this.onFocusCallback = callbackFn;\n return this;\n }\n\n onBinValue(callbackFn: RtnType_callbackFn): SecuredField {\n this.onBinValueCallback = callbackFn;\n return this;\n }\n\n onTouchstart(callbackFn: RtnType_callbackFn): SecuredField {\n this.onTouchstartCallback = callbackFn;\n return this;\n }\n\n onShiftTab(callbackFn: RtnType_callbackFn): SecuredField {\n this.onShiftTabCallback = callbackFn;\n return this;\n }\n\n onAutoComplete(callbackFn: RtnType_callbackFn): SecuredField {\n this.onAutoCompleteCallback = callbackFn;\n return this;\n }\n\n onKeyPressed(callbackFn: RtnType_callbackFn): SecuredField {\n this.onKeyPressedCallback = callbackFn;\n return this;\n }\n //------------------------------------\n\n // ///////////// GETTERS/SETTERS //////////////\n\n get errorType(): string {\n return this._errorType;\n }\n set errorType(value: string) {\n this._errorType = value;\n }\n\n get hasError(): boolean {\n return this._hasError;\n }\n set hasError(value: boolean) {\n this._hasError = value;\n }\n\n get isValid(): boolean {\n if (this.sfConfig.fieldType === ENCRYPTED_SECURITY_CODE) {\n switch (this.cvcPolicy) {\n case CVC_POLICY_HIDDEN:\n // If cvc is hidden then the field is always valid\n return true;\n case CVC_POLICY_OPTIONAL:\n // If cvc is optional then the field is always valid UNLESS it has an error\n return !this.hasError;\n default:\n return this._isValid;\n }\n }\n\n if (\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_DATE ||\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_MONTH ||\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_YEAR\n ) {\n switch (this.expiryDatePolicy) {\n case DATE_POLICY_HIDDEN:\n // If date is hidden then the field is always valid\n return true;\n case DATE_POLICY_OPTIONAL:\n // If date is optional then the field is always valid UNLESS it has an error\n return !this.hasError;\n default:\n return this._isValid;\n }\n }\n\n return this._isValid;\n }\n set isValid(value: boolean) {\n this._isValid = value;\n }\n\n get cvcPolicy(): CVCPolicyType {\n return this._cvcPolicy;\n }\n\n set cvcPolicy(value: CVCPolicyType) {\n // Only set if this is a CVC field\n if (this.sfConfig.fieldType !== ENCRYPTED_SECURITY_CODE) return;\n\n // Only set if value has changed\n if (value === this.cvcPolicy) return;\n\n if (process.env.NODE_ENV === 'development' && doLog) logger.log(this.sfConfig.fieldType, '### SecuredField::cvcPolicy:: value=', value);\n\n this._cvcPolicy = value;\n\n // If the field has changed status (required <--> not required) AND it's error state was due to an isValidated call\n // NOTE: fixes issue in Components where you first validate and then start typing a maestro number\n // - w/o this and the fix in CSF the maestro PM will never register as valid\n if (this.hasError && this.errorType === 'isValidated') {\n this.hasError = false;\n }\n }\n\n get expiryDatePolicy(): DatePolicyType {\n return this._expiryDatePolicy;\n }\n\n set expiryDatePolicy(value: DatePolicyType) {\n // Only set if this is a date field type of securedField\n if (\n this.sfConfig.fieldType !== ENCRYPTED_EXPIRY_DATE &&\n this.sfConfig.fieldType !== ENCRYPTED_EXPIRY_MONTH &&\n this.sfConfig.fieldType !== ENCRYPTED_EXPIRY_YEAR\n )\n return;\n\n // Only set if value has changed\n if (value === this.expiryDatePolicy) return;\n\n if (process.env.NODE_ENV === 'development' && doLog) logger.log(this.sfConfig.fieldType, '### SecuredField:expiryDatePolicy:: value=', value);\n\n this._expiryDatePolicy = value;\n\n // If the field has changed status (required <--> not required) AND it's error state was due to an isValidated call\n if (this.hasError && this.errorType === 'isValidated') {\n this.hasError = false;\n }\n }\n\n get iframeContentWindow(): Window {\n return this._iframeContentWindow;\n }\n set iframeContentWindow(value: Window) {\n this._iframeContentWindow = value;\n }\n\n get isEncrypted(): boolean {\n return this._isEncrypted;\n }\n set isEncrypted(value: boolean) {\n this._isEncrypted = value;\n }\n\n get numKey(): number {\n return this._numKey;\n }\n set numKey(value: number) {\n this._numKey = value;\n }\n\n // Internal use - way to create listener refs that we can add/remove\n get iframeOnLoadListener(): RtnType_noParamVoidFn {\n return this._iframeOnLoadListener;\n }\n set iframeOnLoadListener(value: RtnType_noParamVoidFn) {\n this._iframeOnLoadListener = value.bind(this);\n }\n\n get postMessageListener(): RtnType_postMessageListener {\n return this._postMessageListener;\n }\n set postMessageListener(value: RtnType_postMessageListener) {\n this._postMessageListener = value.bind(this);\n }\n}\n\nexport default SecuredField;\n"],"names":["SecuredField","AbstractSecuredField","init","i18n","iframeSrc","placeholders","showContextualElement","processedAriaConfig","processAriaConfig","this","sfConfig","txVariant","fieldType","iframeUIConfig","ariaConfig","processPlaceholders","iframeConfig","src","title","iframeTitle","policy","iframeEl","createIframe","holderEl","appendChild","iframe","selectOne","contentWindow","_this_submitAnalytics","console","error","event","AnalyticsErrorEvent","component","componentType","code","ErrorEventCode","SECURED_FIELDS_IFRAME_CONTENT_WINDOW_NOT_FOUND","errorType","ErrorEventType","implementation","message","submitAnalytics","iframeContentWindow","iframeOnLoadListener","iframeOnLoadListenerFn","on","iframeRef","postMessageListener","postMessageListenerFn","window","configObj","_object_spread_props","_object_spread","numKey","_b$dl","log","postMessageToIframe","loadingContext","onIframeLoadedCallback","originCheckPassed","showWarnings","feedbackObj","JSON","parse","data","e","isWebpackPostMsg","logger","isChromeVoxPostMsg","hasOwnProperty","action","isValid","onEncryptionCallback","onConfigCallback","onFocusCallback","onBinValueCallback","onTouchstartCallback","onShiftTabCallback","onAutoCompleteCallback","onKeyPressedCallback","internal","onValidationCallback","destroy","off","removeAllChildren","isOptionalOrHidden","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","expiryDatePolicy","DATE_POLICY_HIDDEN","DATE_POLICY_OPTIONAL","hasError","ENCRYPTED_SECURITY_CODE","cvcPolicy","CVC_POLICY_HIDDEN","CVC_POLICY_OPTIONAL","onIframeLoaded","callbackFn","onEncryption","onValidation","onConfig","onFocus","onBinValue","onTouchstart","onShiftTab","onAutoComplete","onKeyPressed","_errorType","value","_hasError","_isValid","_cvcPolicy","_expiryDatePolicy","_iframeContentWindow","isEncrypted","_isEncrypted","_numKey","_iframeOnLoadListener","bind","_postMessageListener","constructor","pSetupObj","super","_define_property","configVarsFromSetUpObj","reject","from","generateRandomNumber"],"mappings":"47DAgCA,MAAMA,UAAqBC,EAkEvBC,IAAAA,CAAKC,EAAgBC,EAAmBC,EAA4BC,GAIhE,MAAMC,EAAkCC,EAAkBC,KAAKC,SAASC,UAAWF,KAAKC,SAASE,UAAWT,EAAMG,GAElHG,KAAKC,SAASG,eAAeC,WAAaP,EAG1CE,KAAKC,SAASG,eAAeR,aAAeU,EAAoBN,KAAKC,SAASC,UAAWF,KAAKC,SAASE,UAAWP,GAKlH,MAAMW,EAAe,CACjBC,IAAKb,EACLc,MAAOX,EAAoBE,KAAKC,SAASE,WAAWO,YACpDC,OAAQ,UAGNC,EAA8BC,EAAaN,GAGjDP,KAAKc,SAASC,YAAYH,GAG1B,MAAMI,EAA4BC,EAAUjB,KAAKc,SAAU,cAE3D,GAAIE,EAAQ,CACR,IAAKA,EAAOE,cAAe,KAavBC,EAXAC,QAAQC,MACJ,2OAGJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWxB,KAAKyB,cAChBC,KAAMC,EAAeC,+CACrBC,UAAWC,EAAeC,eAC1BC,QAAS,sCAAsChC,KAAKC,SAASE,yDAG7C,QAApBgB,EAAAnB,KAAKiC,uBAAL,IAAAd,GAAAA,OAAAnB,KAAuBsB,EAC3B,CAEAtB,KAAKkC,oBAAsBlB,EAAOE,cAGlClB,KAAKmC,qBAAuBnC,KAAKoC,uBAEjCC,EAAGrB,EAAQ,OAAQhB,KAAKmC,sBAAsB,EAClD,CAIA,OAFAnC,KAAKsC,UAAYtB,EAEVhB,IACX,CAEAoC,sBAAAA,GAEIpC,KAAKuC,oBAAsBvC,KAAKwC,sBAGhCH,EAAGI,OAAQ,UAAWzC,KAAKuC,qBAAqB,GAGhD,MAAMG,EAAgCC,EAAAC,EAAA,CAAA,EAC/B5C,KAAKC,UAAQ,CAChB4C,OAAQ7C,KAAK6C,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B7B,KAAKsF,UAAY4B,EAAU5B,UAC3BtF,KAAKiF,iBAAmBiC,EAAUjC,iBAc3BjF,KAAKP,KAAKC,EAAMC,EAAWC,EAAcC,EACpD"}
|
|
1
|
+
{"version":3,"file":"SecuredField.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/securedField/SecuredField.ts"],"sourcesContent":["import * as logger from '../utilities/logger';\nimport createIframe from './utils/createIframe';\nimport { removeAllChildren, selectOne } from '../utilities/dom';\nimport { off, on } from '../../../../../utils/listenerUtils';\nimport postMessageToIframe from '../CSF/utils/iframes/postMessageToIframe';\nimport { isChromeVoxPostMsg, isWebpackPostMsg, originCheckPassed } from '../CSF/utils/iframes/postMessageValidation';\nimport {\n CVC_POLICY_HIDDEN,\n CVC_POLICY_OPTIONAL,\n DATE_POLICY_HIDDEN,\n DATE_POLICY_OPTIONAL,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE\n} from '../constants';\nimport { generateRandomNumber } from '../utilities/commonUtils';\nimport { CVCPolicyType, DatePolicyType, RtnType_callbackFn, RtnType_noParamVoidFn, RtnType_postMessageListener, SFFeedbackObj } from '../types';\nimport AbstractSecuredField from './AbstractSecuredField';\nimport { AriaConfig, IframeConfigObject, SecuredFieldSetupObject, SecuredFieldCommonProps } from '../types';\nimport { reject } from '../../../../../utils/commonUtils';\nimport { processAriaConfig } from './utils/processAriaConfig';\nimport { processPlaceholders } from './utils/processPlaceholders';\nimport Language from '../../../../../language/Language';\nimport { hasOwnProperty } from '../../../../../utils/hasOwnProperty';\nimport { Placeholders } from '../../SFP/types';\nimport './SecuredField.scss';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../../core/Analytics/events/AnalyticsErrorEvent';\n\nconst logPostMsg = false;\nconst doLog = false;\n\nclass SecuredField extends AbstractSecuredField {\n public override sfConfig: SecuredFieldCommonProps;\n\n constructor(pSetupObj: SecuredFieldSetupObject, i18n: Language) {\n super();\n\n /**\n * List of props to exclude from being set on this.sfConfig.\n * These props are only required for internal purposes. They do not get sent to the iframe\n */\n const deltaPropsArr: string[] = ['loadingContext', 'holderEl', 'iframeSrc', 'showContextualElement', 'placeholders'];\n\n /**\n * List of props from setup object that will be set on this.sfConfig\n * These props will all end up being sent to the iframe\n */\n const configVarsFromSetUpObj = reject(deltaPropsArr).from(pSetupObj);\n\n // Copy passed setup object values to this.sfConfig\n this.sfConfig = {\n // ...this.sfConfig, // Do we need to do this? Pretty sure we don't\n ...configVarsFromSetUpObj,\n // Break references on iframeUIConfig object so we can overwrite its properties in each securedField instance\n iframeUIConfig: { ...configVarsFromSetUpObj.iframeUIConfig }\n } as SecuredFieldCommonProps;\n\n /**\n * Extract values only needed for init\n */\n const { iframeSrc, placeholders, showContextualElement } = pSetupObj;\n\n /**\n * Store those passed setup object values that are needed in multiple functions\n */\n this.loadingContext = pSetupObj.loadingContext;\n this.holderEl = pSetupObj.holderEl;\n this.submitAnalytics = pSetupObj.submitAnalytics;\n this.componentType = pSetupObj.componentType;\n\n /**\n * Initiate other values on 'this' through setters\n */\n this.isValid = false;\n this.iframeContentWindow = null;\n this.numKey = generateRandomNumber();\n this.isEncrypted = false;\n this.hasError = false;\n this.errorType = '';\n this.cvcPolicy = pSetupObj.cvcPolicy;\n this.expiryDatePolicy = pSetupObj.expiryDatePolicy;\n\n if (process.env.NODE_ENV === 'development' && doLog) {\n logger.log(\n '### SecuredField::constructor:: this.sfConfig.fieldType=',\n this.sfConfig.fieldType,\n 'isValid=',\n this._isValid,\n 'numKey=',\n this.numKey\n );\n logger.log('\\n');\n }\n\n return this.init(i18n, iframeSrc, placeholders, showContextualElement);\n }\n\n init(i18n: Language, iframeSrc: string, placeholders: Placeholders, showContextualElement: boolean): SecuredField {\n /**\n * Ensure all fields have a related ariaConfig object containing, at minimum, an iframeTitle property and a (translated) errors object\n */\n const processedAriaConfig: AriaConfig = processAriaConfig(this.sfConfig.txVariant, this.sfConfig.fieldType, i18n, showContextualElement);\n // Set result back onto config object\n this.sfConfig.iframeUIConfig.ariaConfig = processedAriaConfig;\n\n // Set result back onto config object\n this.sfConfig.iframeUIConfig.placeholders = processPlaceholders(this.sfConfig.txVariant, this.sfConfig.fieldType, placeholders);\n\n /**\n * Configure, create & reference iframe and add load listener\n */\n const iframeConfig = {\n src: iframeSrc,\n title: processedAriaConfig[this.sfConfig.fieldType].iframeTitle,\n policy: 'origin'\n };\n\n const iframeEl: HTMLIFrameElement = createIframe(iframeConfig);\n\n // Place the iframe into the holder\n this.holderEl.appendChild(iframeEl);\n\n // Now examine the holder to get an actual DOM node\n const iframe: HTMLIFrameElement = selectOne(this.holderEl, '.js-iframe');\n\n if (iframe) {\n if (!iframe.contentWindow) {\n // Warn the dev\n console.error(\n 'ERROR: Trying to initialise a securedField iframe, but the iframe.contentWindow is undefined. Are you sure the element into which the Card component is being mounted already exists in the DOM *before* the Card component is mounted?'\n );\n // Log the error\n const event = new AnalyticsErrorEvent({\n component: this.componentType,\n code: ErrorEventCode.SECURED_FIELDS_IFRAME_CONTENT_WINDOW_NOT_FOUND,\n errorType: ErrorEventType.implementation,\n message: `Trying to initialise an iframe for ${this.sfConfig.fieldType}, but the iframe.contentWindow is undefined`\n });\n\n this.submitAnalytics?.(event);\n }\n\n this.iframeContentWindow = iframe.contentWindow;\n\n // Create reference to bound fn (see getters/setters for binding)\n this.iframeOnLoadListener = this.iframeOnLoadListenerFn;\n\n on(iframe, 'load', this.iframeOnLoadListener, false);\n }\n\n this.iframeRef = iframe;\n\n return this;\n }\n\n iframeOnLoadListenerFn(): void {\n // Create reference to bound fn (see getters/setters for binding)\n this.postMessageListener = this.postMessageListenerFn;\n\n // Add general listener for 'message' EVENT - the event that 'powers' postMessage\n on(window, 'message', this.postMessageListener, false);\n\n // Create and send config object to iframe\n const configObj: IframeConfigObject = {\n ...this.sfConfig,\n numKey: this.numKey\n };\n\n if (window._b$dl) console.log('### SecuredField:::: onIframeLoaded:: created configObj=', configObj);\n\n postMessageToIframe(configObj, this.iframeContentWindow, this.loadingContext);\n //--\n\n // Callback to say iframe loaded\n this.onIframeLoadedCallback();\n }\n\n postMessageListenerFn(event: MessageEvent): void {\n // Check message is from expected domain\n if (!originCheckPassed(event, this.loadingContext, this.sfConfig.showWarnings)) {\n return;\n }\n\n // TODO - for debugging purposes this would always be useful to see\n // logger.log('\\n',this.sfConfig.fieldType,'### CSF SecuredField::postMessageListener:: event.data=',event.data);\n\n if (process.env.NODE_ENV === 'development' && logPostMsg) {\n logger.log(\n '\\n###CSF SecuredField::postMessageListener:: DOMAIN & ORIGIN MATCH, NO WEBPACK WEIRDNESS fieldType=',\n this.sfConfig.fieldType,\n 'txVariant=',\n this.sfConfig.txVariant,\n 'this.numKey=',\n this.numKey\n );\n }\n\n // PARSE DATA OBJECT (thus testing if it is a JSON string) - OR TRY & WORK OUT WHY THE PARSING FAILED\n let feedbackObj: SFFeedbackObj;\n\n try {\n feedbackObj = JSON.parse(event.data);\n } catch (e) {\n // Was the message generated by webpack?\n if (isWebpackPostMsg(event)) {\n if (this.sfConfig.showWarnings) logger.log('### SecuredField::postMessageListenerFn:: PARSE FAIL - WEBPACK');\n return;\n }\n\n // Was the message generated by ChromeVox?\n if (isChromeVoxPostMsg(event)) {\n if (this.sfConfig.showWarnings) logger.log('### SecuredField::postMessageListenerFn:: PARSE FAIL - CHROMEVOX');\n return;\n }\n\n if (this.sfConfig.showWarnings)\n logger.log('### SecuredField::postMessageListenerFn:: PARSE FAIL - UNKNOWN REASON: event.data=', event.data);\n return;\n }\n\n // CHECK FOR EXPECTED PROPS\n const hasMainProps: boolean = hasOwnProperty(feedbackObj, 'action') && hasOwnProperty(feedbackObj, 'numKey');\n\n if (!hasMainProps) {\n if (this.sfConfig.showWarnings) logger.warn('WARNING SecuredField :: postMessage listener for iframe :: data mismatch!');\n return;\n }\n\n if (process.env.NODE_ENV === 'development' && logPostMsg) {\n logger.log('### SecuredField::postMessageListener:: feedbackObj.numKey=', feedbackObj.numKey);\n }\n\n if (this.numKey !== feedbackObj.numKey) {\n if (this.sfConfig.showWarnings) {\n logger.warn(\n 'WARNING SecuredField :: postMessage listener for iframe :: data mismatch! (Probably a message from an unrelated securedField)'\n );\n }\n return;\n }\n\n // VALIDATION CHECKS PASSED - DECIDE ON COURSE OF ACTION\n if (process.env.NODE_ENV === 'development' && logPostMsg) {\n logger.log(\n '### SecuredField::postMessageListener:: numkeys match PROCEED WITH POST MESSAGE PROCESSING fieldType=',\n this.sfConfig.fieldType,\n 'txVariant=',\n this.sfConfig.txVariant\n );\n }\n\n switch (feedbackObj.action) {\n case 'encryption':\n this.isValid = true;\n this.onEncryptionCallback(feedbackObj);\n break;\n\n case 'config':\n if (window._b$dl)\n console.log('### SecuredField::postMessageListenerFn:: configured - calling onConfigCallback', feedbackObj.fieldType);\n this.onConfigCallback(feedbackObj);\n break;\n\n case 'focus':\n this.onFocusCallback(feedbackObj);\n break;\n\n case 'binValue':\n this.onBinValueCallback(feedbackObj);\n break;\n\n // iOS ONLY - RE. iOS BUGS AROUND BLUR AND FOCUS EVENTS\n case 'touch':\n this.onTouchstartCallback(feedbackObj);\n break;\n\n // Only happens for Firefox & IE <= 11\n case 'shifttab':\n this.onShiftTabCallback(feedbackObj);\n break;\n\n case 'autoComplete':\n this.onAutoCompleteCallback(feedbackObj);\n break;\n\n case 'enterKeyPressed':\n this.onKeyDownCallback(feedbackObj);\n break;\n\n case 'encryptionError': {\n const event = new AnalyticsErrorEvent({\n component: this.componentType,\n code: feedbackObj.code,\n errorType: ErrorEventType.internal,\n message: `${feedbackObj.error}. Field= ${this.sfConfig.fieldType}`\n });\n\n this.submitAnalytics?.(event);\n break;\n }\n\n /**\n * Validate, because action =\n *\n * 'brand'\n * 'delete'\n * 'luhnCheck'\n * 'incomplete field' (an error that follows from a focus (blur) event)\n * 'incorrectly filled field' (an error that follows from a focus (blur) event)\n * 'numberKeyPressed' (or date-, month-, year-, cvc-, pin-, or iban- KeyPressed)\n * - since we have no \"error\" action \"...KeyPressed\" is the action type on most error events (other than \"incomplete field, 'incorrectly filled field' or \"luhnCheck\")\n * and often these error events representing the clearing of an existing error\n */\n default:\n // If we're validation handling (& not encryption handling) field must be invalid\n this.isValid = false;\n this.onValidationCallback(feedbackObj);\n }\n }\n\n destroy(): void {\n off(window, 'message', this.postMessageListener, false);\n off(this.iframeRef, 'load', this.iframeOnLoadListener, false);\n this.iframeContentWindow = null;\n removeAllChildren(this.holderEl);\n }\n\n /**\n * Returns whether the securedField is hidden OR whether it is optional and not in error\n */\n isOptionalOrHidden(): boolean {\n if (\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_DATE ||\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_MONTH ||\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_YEAR\n ) {\n switch (this.expiryDatePolicy) {\n case DATE_POLICY_HIDDEN:\n return true;\n case DATE_POLICY_OPTIONAL:\n return !this.hasError;\n default:\n return false;\n }\n }\n\n if (this.sfConfig.fieldType === ENCRYPTED_SECURITY_CODE) {\n switch (this.cvcPolicy) {\n case CVC_POLICY_HIDDEN:\n return true;\n case CVC_POLICY_OPTIONAL:\n return !this.hasError;\n default:\n return false;\n }\n }\n\n // Any other type of securedField is not optional & can't be hidden\n return false;\n }\n\n // /////// ALLOCATE CALLBACKS /////////\n onIframeLoaded(callbackFn: RtnType_noParamVoidFn): SecuredField {\n this.onIframeLoadedCallback = callbackFn;\n return this;\n }\n\n onEncryption(callbackFn: RtnType_callbackFn): SecuredField {\n this.onEncryptionCallback = callbackFn;\n return this;\n }\n\n onValidation(callbackFn: RtnType_callbackFn): SecuredField {\n this.onValidationCallback = callbackFn;\n return this;\n }\n\n onConfig(callbackFn: RtnType_callbackFn): SecuredField {\n this.onConfigCallback = callbackFn;\n return this;\n }\n\n onFocus(callbackFn: RtnType_callbackFn): SecuredField {\n this.onFocusCallback = callbackFn;\n return this;\n }\n\n onBinValue(callbackFn: RtnType_callbackFn): SecuredField {\n this.onBinValueCallback = callbackFn;\n return this;\n }\n\n onTouchstart(callbackFn: RtnType_callbackFn): SecuredField {\n this.onTouchstartCallback = callbackFn;\n return this;\n }\n\n onShiftTab(callbackFn: RtnType_callbackFn): SecuredField {\n this.onShiftTabCallback = callbackFn;\n return this;\n }\n\n onAutoComplete(callbackFn: RtnType_callbackFn): SecuredField {\n this.onAutoCompleteCallback = callbackFn;\n return this;\n }\n\n onKeyDown(callbackFn: RtnType_callbackFn): SecuredField {\n this.onKeyDownCallback = callbackFn;\n return this;\n }\n //------------------------------------\n\n // ///////////// GETTERS/SETTERS //////////////\n\n get errorType(): string {\n return this._errorType;\n }\n set errorType(value: string) {\n this._errorType = value;\n }\n\n get hasError(): boolean {\n return this._hasError;\n }\n set hasError(value: boolean) {\n this._hasError = value;\n }\n\n get isValid(): boolean {\n if (this.sfConfig.fieldType === ENCRYPTED_SECURITY_CODE) {\n switch (this.cvcPolicy) {\n case CVC_POLICY_HIDDEN:\n // If cvc is hidden then the field is always valid\n return true;\n case CVC_POLICY_OPTIONAL:\n // If cvc is optional then the field is always valid UNLESS it has an error\n return !this.hasError;\n default:\n return this._isValid;\n }\n }\n\n if (\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_DATE ||\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_MONTH ||\n this.sfConfig.fieldType === ENCRYPTED_EXPIRY_YEAR\n ) {\n switch (this.expiryDatePolicy) {\n case DATE_POLICY_HIDDEN:\n // If date is hidden then the field is always valid\n return true;\n case DATE_POLICY_OPTIONAL:\n // If date is optional then the field is always valid UNLESS it has an error\n return !this.hasError;\n default:\n return this._isValid;\n }\n }\n\n return this._isValid;\n }\n set isValid(value: boolean) {\n this._isValid = value;\n }\n\n get cvcPolicy(): CVCPolicyType {\n return this._cvcPolicy;\n }\n\n set cvcPolicy(value: CVCPolicyType) {\n // Only set if this is a CVC field\n if (this.sfConfig.fieldType !== ENCRYPTED_SECURITY_CODE) return;\n\n // Only set if value has changed\n if (value === this.cvcPolicy) return;\n\n if (process.env.NODE_ENV === 'development' && doLog) logger.log(this.sfConfig.fieldType, '### SecuredField::cvcPolicy:: value=', value);\n\n this._cvcPolicy = value;\n\n // If the field has changed status (required <--> not required) AND it's error state was due to an isValidated call\n // NOTE: fixes issue in Components where you first validate and then start typing a maestro number\n // - w/o this and the fix in CSF the maestro PM will never register as valid\n if (this.hasError && this.errorType === 'isValidated') {\n this.hasError = false;\n }\n }\n\n get expiryDatePolicy(): DatePolicyType {\n return this._expiryDatePolicy;\n }\n\n set expiryDatePolicy(value: DatePolicyType) {\n // Only set if this is a date field type of securedField\n if (\n this.sfConfig.fieldType !== ENCRYPTED_EXPIRY_DATE &&\n this.sfConfig.fieldType !== ENCRYPTED_EXPIRY_MONTH &&\n this.sfConfig.fieldType !== ENCRYPTED_EXPIRY_YEAR\n )\n return;\n\n // Only set if value has changed\n if (value === this.expiryDatePolicy) return;\n\n if (process.env.NODE_ENV === 'development' && doLog) logger.log(this.sfConfig.fieldType, '### SecuredField:expiryDatePolicy:: value=', value);\n\n this._expiryDatePolicy = value;\n\n // If the field has changed status (required <--> not required) AND it's error state was due to an isValidated call\n if (this.hasError && this.errorType === 'isValidated') {\n this.hasError = false;\n }\n }\n\n get iframeContentWindow(): Window {\n return this._iframeContentWindow;\n }\n set iframeContentWindow(value: Window) {\n this._iframeContentWindow = value;\n }\n\n get isEncrypted(): boolean {\n return this._isEncrypted;\n }\n set isEncrypted(value: boolean) {\n this._isEncrypted = value;\n }\n\n get numKey(): number {\n return this._numKey;\n }\n set numKey(value: number) {\n this._numKey = value;\n }\n\n // Internal use - way to create listener refs that we can add/remove\n get iframeOnLoadListener(): RtnType_noParamVoidFn {\n return this._iframeOnLoadListener;\n }\n set iframeOnLoadListener(value: RtnType_noParamVoidFn) {\n this._iframeOnLoadListener = value.bind(this);\n }\n\n get postMessageListener(): RtnType_postMessageListener {\n return this._postMessageListener;\n }\n set postMessageListener(value: RtnType_postMessageListener) {\n this._postMessageListener = value.bind(this);\n }\n}\n\nexport default SecuredField;\n"],"names":["SecuredField","AbstractSecuredField","init","i18n","iframeSrc","placeholders","showContextualElement","processedAriaConfig","processAriaConfig","this","sfConfig","txVariant","fieldType","iframeUIConfig","ariaConfig","processPlaceholders","iframeConfig","src","title","iframeTitle","policy","iframeEl","createIframe","holderEl","appendChild","iframe","selectOne","contentWindow","_this_submitAnalytics","console","error","event","AnalyticsErrorEvent","component","componentType","code","ErrorEventCode","SECURED_FIELDS_IFRAME_CONTENT_WINDOW_NOT_FOUND","errorType","ErrorEventType","implementation","message","submitAnalytics","iframeContentWindow","iframeOnLoadListener","iframeOnLoadListenerFn","on","iframeRef","postMessageListener","postMessageListenerFn","window","configObj","_object_spread_props","_object_spread","numKey","_b$dl","log","postMessageToIframe","loadingContext","onIframeLoadedCallback","originCheckPassed","showWarnings","feedbackObj","JSON","parse","data","e","isWebpackPostMsg","logger","isChromeVoxPostMsg","hasOwnProperty","action","isValid","onEncryptionCallback","onConfigCallback","onFocusCallback","onBinValueCallback","onTouchstartCallback","onShiftTabCallback","onAutoCompleteCallback","onKeyDownCallback","internal","onValidationCallback","destroy","off","removeAllChildren","isOptionalOrHidden","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","expiryDatePolicy","DATE_POLICY_HIDDEN","DATE_POLICY_OPTIONAL","hasError","ENCRYPTED_SECURITY_CODE","cvcPolicy","CVC_POLICY_HIDDEN","CVC_POLICY_OPTIONAL","onIframeLoaded","callbackFn","onEncryption","onValidation","onConfig","onFocus","onBinValue","onTouchstart","onShiftTab","onAutoComplete","onKeyDown","_errorType","value","_hasError","_isValid","_cvcPolicy","_expiryDatePolicy","_iframeContentWindow","isEncrypted","_isEncrypted","_numKey","_iframeOnLoadListener","bind","_postMessageListener","constructor","pSetupObj","super","_define_property","configVarsFromSetUpObj","reject","from","generateRandomNumber"],"mappings":"47DAgCA,MAAMA,UAAqBC,EAkEvBC,IA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 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import{stopPropagationForActionKeys as o}from"../Button/stopPropagationForActionKeys.js";function n(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}const r=({classNameModifiers:r=[],selectedValue:c,disabled:a=!1,options:l,onChange:s})=>l&&0!==l.length?e("div",{className:t("adyen-checkout__segmented-control",{"adyen-checkout__segmented-control--disabled":a},...r.map(e=>`adyen-checkout__segmented-control--${e}`)),role:"tablist"},l.map(({label:r,value:l,id:i,controls:d,htmlProps:u})=>e("button",function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){n(e,t,o[t])})}return e}({role:"tab",id:i,disabled:a,key:l,onClick:e=>s(l,e),
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import{stopPropagationForActionKeys as o}from"../Button/stopPropagationForActionKeys.js";function n(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}const r=({classNameModifiers:r=[],selectedValue:c,disabled:a=!1,options:l,onChange:s})=>l&&0!==l.length?e("div",{className:t("adyen-checkout__segmented-control",{"adyen-checkout__segmented-control--disabled":a},...r.map(e=>`adyen-checkout__segmented-control--${e}`)),role:"tablist"},l.map(({label:r,value:l,id:i,controls:d,htmlProps:u})=>e("button",function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){n(e,t,o[t])})}return e}({role:"tab",id:i,disabled:a,key:l,onClick:e=>s(l,e),onKeyDown:o,className:t("adyen-checkout__segmented-control-segment",{"adyen-checkout__segmented-control-segment--selected":c===l}),"aria-controls":d,"aria-selected":c===l,type:"button"},u),r))):null;export{r as SegmentedControl};
|
|
2
2
|
//# sourceMappingURL=SegmentedControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.js","sources":["../../../../../src/components/internal/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\n\nimport './SegmentedControl.scss';\nimport { stopPropagationForActionKeys } from '../Button/stopPropagationForActionKeys';\n\nexport interface SegmentedControlOption<T> {\n readonly label: string;\n readonly value: T;\n readonly id: string;\n readonly controls: string;\n readonly htmlProps?: {};\n}\n\nexport type SegmentedControlOptions<T> = Array<SegmentedControlOption<T>>;\n\nexport interface SegmentedControlProps<T> {\n classNameModifiers?: string[];\n selectedValue: T;\n disabled?: boolean;\n options: SegmentedControlOptions<T>;\n onChange: (value: T, event: MouseEvent) => void;\n}\n\n/**\n *\n * example:\n * <SegmentedControl\n * onChange={(value) = setMode(value)}\n * selectedValue={mode}\n * disabled={status === 'loading'}\n * classNameModifiers={['css-class']}\n * options={segmentedControlOptions}\n * />\n *\n * @param classNameModifiers\n * @param selectedValue\n * @param disabled\n * @param options\n * @param onChange\n * @constructor\n */\nexport const SegmentedControl = <T,>({\n classNameModifiers = [],\n selectedValue,\n disabled = false,\n options,\n onChange\n}: Readonly<SegmentedControlProps<T>>) => {\n if (!options || options.length === 0) {\n return null;\n }\n\n return (\n <div\n className={cx(\n 'adyen-checkout__segmented-control',\n { 'adyen-checkout__segmented-control--disabled': disabled },\n ...classNameModifiers.map(modifier => `adyen-checkout__segmented-control--${modifier}`)\n )}\n role=\"tablist\"\n >\n {options.map(({ label, value, id, controls, htmlProps }: SegmentedControlOption<T>) => (\n <button\n role=\"tab\"\n id={id}\n disabled={disabled}\n key={value}\n onClick={(event: MouseEvent) => onChange(value, event)}\n // Workaround: See ADR-0001-uielement-keyboard-event-propagation-workaround\n
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","sources":["../../../../../src/components/internal/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\n\nimport './SegmentedControl.scss';\nimport { stopPropagationForActionKeys } from '../Button/stopPropagationForActionKeys';\n\nexport interface SegmentedControlOption<T> {\n readonly label: string;\n readonly value: T;\n readonly id: string;\n readonly controls: string;\n readonly htmlProps?: {};\n}\n\nexport type SegmentedControlOptions<T> = Array<SegmentedControlOption<T>>;\n\nexport interface SegmentedControlProps<T> {\n classNameModifiers?: string[];\n selectedValue: T;\n disabled?: boolean;\n options: SegmentedControlOptions<T>;\n onChange: (value: T, event: MouseEvent) => void;\n}\n\n/**\n *\n * example:\n * <SegmentedControl\n * onChange={(value) = setMode(value)}\n * selectedValue={mode}\n * disabled={status === 'loading'}\n * classNameModifiers={['css-class']}\n * options={segmentedControlOptions}\n * />\n *\n * @param classNameModifiers\n * @param selectedValue\n * @param disabled\n * @param options\n * @param onChange\n * @constructor\n */\nexport const SegmentedControl = <T,>({\n classNameModifiers = [],\n selectedValue,\n disabled = false,\n options,\n onChange\n}: Readonly<SegmentedControlProps<T>>) => {\n if (!options || options.length === 0) {\n return null;\n }\n\n return (\n <div\n className={cx(\n 'adyen-checkout__segmented-control',\n { 'adyen-checkout__segmented-control--disabled': disabled },\n ...classNameModifiers.map(modifier => `adyen-checkout__segmented-control--${modifier}`)\n )}\n role=\"tablist\"\n >\n {options.map(({ label, value, id, controls, htmlProps }: SegmentedControlOption<T>) => (\n <button\n role=\"tab\"\n id={id}\n disabled={disabled}\n key={value}\n onClick={(event: MouseEvent) => onChange(value, event)}\n // Workaround: See ADR-0001-uielement-keyboard-event-propagation-workaround\n onKeyDown={stopPropagationForActionKeys}\n className={cx('adyen-checkout__segmented-control-segment', {\n 'adyen-checkout__segmented-control-segment--selected': selectedValue === value\n })}\n aria-controls={controls}\n aria-selected={selectedValue === value}\n type=\"button\"\n {...htmlProps}\n >\n {label}\n </button>\n ))}\n </div>\n );\n};\n"],"names":["SegmentedControl","classNameModifiers","selectedValue","disabled","options","onChange","length","h","div","className","cx","map","modifier","role","label","value","id","controls","htmlProps","button","key","onClick","event","onKeyDown","stopPropagationForActionKeys","aria-controls","aria-selected","type"],"mappings":"mUA0CO,MAAMA,EAAmB,EAC5BC,qBAAqB,GACrBC,gBACAC,YAAW,EACXC,UACAC,cAEKD,GAA8B,IAAnBA,EAAQE,OAKpBC,EAACC,MAAAA,CACGC,UAAWC,EACP,oCACA,CAAE,8CAA+CP,MAC9CF,EAAmBU,IAAIC,GAAY,sCAAsCA,MAEhFC,KAAK,WAEJT,EAAQO,IAAI,EAAGG,QAAOC,QAAOC,KAAIC,WAAUC,eACxCX,EAACY,2UAAAA,CAAAA,CACGN,KAAK,MACLG,GAAIA,EACJb,SAAUA,EACViB,IAAKL,EACLM,QAAUC,GAAsBjB,EAASU,EAAOO,GAEhDC,UAAWC,EACXf,UAAWC,EAAG,4CAA6C,CACvD,sDAAuDR,IAAkBa,IAE7EU,gBAAeR,EACfS,gBAAexB,IAAkBa,EACjCY,KAAK,UACDT,GAEHJ,KA7BN"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createElement as s}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import e from"./Tag.module.scss.js";import{TagVariant as r}from"./types.js";const a={[r.SUCCESS]:e.success,[r.INFO]:e.info},o=({label:o,variant:m=r.INFO})=>s("span",{className:t(e.tag,a[m])},o);export{o as Tag};
|
|
2
|
+
//# sourceMappingURL=Tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.js","sources":["../../../../../src/components/internal/Tag/Tag.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport type { TagProps } from './types';\nimport styles from './Tag.module.scss';\nimport { TagVariant } from './types';\n\nconst variantClass: Record<TagVariant, string> = {\n [TagVariant.SUCCESS]: styles.success,\n [TagVariant.INFO]: styles.info\n};\n\nexport const Tag = ({ label, variant = TagVariant.INFO }: Readonly<TagProps>) => {\n return <span className={cx(styles.tag, variantClass[variant])}>{label}</span>;\n};\n"],"names":["variantClass","TagVariant","SUCCESS","styles","success","INFO","info","Tag","label","variant","h","span","className","cx","tag"],"mappings":"8LAMA,MAAMA,EAA2C,CAC7C,CAACC,EAAWC,SAAUC,EAAOC,QAC7B,CAACH,EAAWI,MAAOF,EAAOG,MAGjBC,EAAM,EAAGC,QAAOC,UAAUR,EAAWI,QACvCK,EAACC,OAAAA,CAAKC,UAAWC,EAAGV,EAAOW,IAAKd,EAAaS,KAAYD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createElement as a}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import{Tag as e}from"./Tag.js";import l from"./TagList.module.scss.js";const s=({tags:s,className:r})=>(null==s?void 0:s.length)?a("div",{className:t(l.tagList,r)},s.map((t,l)=>a(e,{key:`${l}-${t.label}`,label:t.label,variant:t.variant}))):null;export{s as TagList};
|
|
2
|
+
//# sourceMappingURL=TagList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagList.js","sources":["../../../../../src/components/internal/Tag/TagList.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { Tag } from './Tag';\nimport type { TagListProps } from './types';\nimport styles from './TagList.module.scss';\n\nexport const TagList = ({ tags, className }: Readonly<TagListProps>) => {\n if (!tags?.length) return null;\n return (\n <div className={cx(styles.tagList, className)}>\n {tags.map((tag, index) => (\n <Tag key={`${index}-${tag.label}`} label={tag.label} variant={tag.variant} />\n ))}\n </div>\n );\n};\n"],"names":["TagList","tags","className","length","h","div","cx","styles","tagList","map","tag","index","Tag","key","label","variant"],"mappings":"+LAMaA,EAAU,EAAGC,OAAMC,gBACvBD,aAAAA,EAAAA,EAAME,QAEPC,EAACC,MAAAA,CAAIH,UAAWI,EAAGC,EAAOC,QAASN,IAC9BD,EAAKQ,IAAI,CAACC,EAAKC,IACZP,EAACQ,EAAAA,CAAIC,IAAK,GAAGF,KAASD,EAAII,QAASA,MAAOJ,EAAII,MAAOC,QAASL,EAAIK,YAJpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagList.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../src/components/internal/Tag/types.ts"],"sourcesContent":["export enum TagVariant {\n SUCCESS = 'success',\n INFO = 'info'\n}\n\nexport interface TagProps {\n label: string;\n variant?: TagVariant;\n}\n\nexport interface TagListProps {\n tags?: TagProps[];\n className?: string;\n}\n"],"names":["TagVariant"],"mappings":"AAAO,IAAAA,EAAKA,SAAAA,GAAAA,yCAAAA,CAGX,CAHWA,CAGX,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,createRef as t}from"../../../external/preact/dist/preact.js";import s,{NETWORK_ERROR as n}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as o}from"../../../utils/hasOwnProperty.js";import i from"../BaseElement/BaseElement.js";import r from"../PayButton/PayButton.js";import{assertIsDropin as a,getRegulatoryDefaults as l,sanitizeResponse as h,verifyPaymentDidNotFail as d,cleanupFinalResult as c}from"./utils.js";import{AnalyticsErrorEvent as p,ErrorEventType as m}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as u,InfoEventType as y}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as f,LogEventType as v}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import b from"../../../core/Errors/CancelError.js";import{CoreProvider as R}from"../../../core/Context/CoreProvider.js";import P from"../../../core/Errors/SRPanelProvider.js";import{AmountProvider as A}from"../../../core/Context/AmountProvider.js";import{TxVariants as g}from"../../tx-variants.js";function E(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function w(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),n.forEach(function(t){E(e,t,s[t])})}return e}function S(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 s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}class C extends i{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(null==e?void 0:e.originalAction)return;const t=new u(w({type:y.rendered,component:this.type,configData:S(w({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.oneClick)&&{isStoredPaymentMethod:!0}));this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return(null==e?void 0:e.storedPaymentMethodId)?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(null==e?void 0:e.type,null==e?void 0:e.paymentMethodId)}buildElementProps(e){const t=w({showPayButton:!0},this.core.getCorePropsForComponent(),this.getPaymentMethodConfigFromResponse(e),e),s=a(this);this.props=this.formatProps(w({},this.constructor.defaultProps,l(this.core.options.countryCode,s),t))}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){var s;return t?this.core.paymentMethodsResponse.findById(t):null===(s=this.core.paymentMethodsResponse)||void 0===s?void 0:s.find(e||this.constructor.type)}storeElementRefOnCore(e){(null==e?void 0:e.isDropin)||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state=w({},this.state,e),this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}updateAmount(e,t){var s;this.props=w({},this.props,e&&{amount:e},t&&{secondaryAmount:t}),null===(s=this.amountProviderRef.current)||void 0===s||s.update(e,t)}setElementStatus(e,t){var s;return null===(s=this.elementRef)||void 0===s||s.setStatus(e,t),this}setStatus(e,t){var s;return(null===(s=this.componentRef)||void 0===s?void 0:s.setStatus)&&this.componentRef.setStatus(e,t),this}onChange(){var e,t;null===(e=(t=this.props).onChange)||void 0===e||e.call(t,{data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){this.isValid?this.makePaymentsCall().then(h).then(d).then(this.handleResponse).catch(e=>{e instanceof b?this.setElementStatus("ready"):this.handleFailedResult(e)}):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>{this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new b("beforeSubmitRejected"))})}):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new f({component:this.type,type:v.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const t=new f({component:this.type,type:v.submit,message:"Shopper clicked pay"});this.submitAnalytics(t);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(h).then(d).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(o(e,"action")&&o(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,w({},this.elementRef.props,t));return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){var t,s;null===(s=this.props)||void 0===s||null===(t=s.onActionHandled)||void 0===t||t.call(s,w({originalAction:this.props.originalAction},e))}setupSessionsDonation(){const{amount:e,donation:t}=this.props;if(!1!==(null==t?void 0:t.autoMount)){const t=a(this.elementRef)?this.elementRef._node:this._node;new(this.core.getComponent(g.donation))(this.core,{rootNode:t,commercialTxAmount:e.value})}}handleResponse(e){var t,s;e.action?this.elementRef.handleAction(e.action):(null===(s=e.order)||void 0===s||null===(t=s.remainingAmount)||void 0===t?void 0:t.value)>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyPress(e){var t;"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(null===(t=document)||void 0===t?void 0:t.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){var e;const t=this.props.paymentMethodType||this.type;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()(t)}get displayName(){var e,t;const s=null===(t=this.core.paymentMethodsResponse)||void 0===t||null===(e=t.paymentMethods)||void 0===e?void 0:e.find(e=>e.type===this.type);return this.props.name||(null==s?void 0:s.name)||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,t){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest(S(w({},e&&{order:{orderData:e.orderData,pspReference:e.pspReference}}),{locale:this.core.options.locale}),{resolve:t,reject:s})}).catch(e=>{this.handleError(new s("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(s=>this.core.update(S(w({},s&&{paymentMethodsResponse:s}),{order:e,amount:e?e.remainingAmount:t})))}render(){return e(R,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(P,{srPanel:this.srPanel},e(A,{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,providerRef:this.amountProviderRef},this.componentToRender())))}constructor(s,o){super(s,o),E(this,"componentRef",void 0),E(this,"resources",void 0),E(this,"elementRef",void 0),E(this,"amountProviderRef",t()),E(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===n&&e.options.code){const t=new p({component:this.type,errorType:m.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),E(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{var e,s;null===(e=(s=this.props).onOrderUpdated)||void 0===e||e.call(s,{order:t})})}),E(this,"handleFailedResult",e=>{var t,s;a(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),c(e),null===(t=(s=this.props).onPaymentFailed)||void 0===t||t.call(s,e,this.elementRef)}),E(this,"handleSuccessResult",e=>{var t,s;a(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),c(e),this.core.session&&!0===e.askDonation&&this.setupSessionsDonation(),null===(t=(s=this.props).onPaymentCompleted)||void 0===t||t.call(s,e,this.elementRef)}),E(this,"setComponentRef",e=>{this.componentRef=e}),E(this,"payButton",t=>e(r,S(w({},t),{onClick:this.submit}))),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.updateAmount=this.updateAmount.bind(this),this.setupSessionsDonation=this.setupSessionsDonation.bind(this),this.elementRef=o&&o.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(o),this.reportIntegrationFlavor()}}E(C,"type",void 0),E(C,"txVariants",[]);export{C as UIElement,C as default};
|
|
1
|
+
import{createElement as e,createRef as t}from"../../../external/preact/dist/preact.js";import s,{NETWORK_ERROR as n}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as o}from"../../../utils/hasOwnProperty.js";import i from"../BaseElement/BaseElement.js";import r from"../PayButton/PayButton.js";import{assertIsDropin as a,getRegulatoryDefaults as l,sanitizeResponse as h,verifyPaymentDidNotFail as d,cleanupFinalResult as c}from"./utils.js";import{AnalyticsErrorEvent as p,ErrorEventType as m}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as u,InfoEventType as y}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as f,LogEventType as v}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import b from"../../../core/Errors/CancelError.js";import{CoreProvider as R}from"../../../core/Context/CoreProvider.js";import P from"../../../core/Errors/SRPanelProvider.js";import{AmountProvider as A}from"../../../core/Context/AmountProvider.js";import{TxVariants as g}from"../../tx-variants.js";function E(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function w(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),n.forEach(function(t){E(e,t,s[t])})}return e}function S(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 s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}class C extends i{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(null==e?void 0:e.originalAction)return;const t=new u(w({type:y.rendered,component:this.type,configData:S(w({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.oneClick)&&{isStoredPaymentMethod:!0}));this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return(null==e?void 0:e.storedPaymentMethodId)?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(null==e?void 0:e.type,null==e?void 0:e.paymentMethodId)}buildElementProps(e){const t=w({showPayButton:!0},this.core.getCorePropsForComponent(),this.getPaymentMethodConfigFromResponse(e),e),s=a(this);this.props=this.formatProps(w({},this.constructor.defaultProps,l(this.core.options.countryCode,s),t))}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){var s;return t?this.core.paymentMethodsResponse.findById(t):null===(s=this.core.paymentMethodsResponse)||void 0===s?void 0:s.find(e||this.constructor.type)}storeElementRefOnCore(e){(null==e?void 0:e.isDropin)||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state=w({},this.state,e),this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}updateAmount(e,t){var s;this.props=w({},this.props,e&&{amount:e},t&&{secondaryAmount:t}),null===(s=this.amountProviderRef.current)||void 0===s||s.update(e,t)}setElementStatus(e,t){var s;return null===(s=this.elementRef)||void 0===s||s.setStatus(e,t),this}setStatus(e,t){var s;return(null===(s=this.componentRef)||void 0===s?void 0:s.setStatus)&&this.componentRef.setStatus(e,t),this}onChange(){var e,t;null===(e=(t=this.props).onChange)||void 0===e||e.call(t,{data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){this.isValid?this.makePaymentsCall().then(h).then(d).then(this.handleResponse).catch(e=>{e instanceof b?this.setElementStatus("ready"):this.handleFailedResult(e)}):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>{this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new b("beforeSubmitRejected"))})}):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new f({component:this.type,type:v.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const t=new f({component:this.type,type:v.submit,message:"Shopper clicked pay"});this.submitAnalytics(t);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(h).then(d).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(o(e,"action")&&o(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,w({},this.elementRef.props,t));return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){var t,s;null===(s=this.props)||void 0===s||null===(t=s.onActionHandled)||void 0===t||t.call(s,w({originalAction:this.props.originalAction},e))}setupSessionsDonation(){const{amount:e,donation:t}=this.props;if(!1!==(null==t?void 0:t.autoMount)){const t=a(this.elementRef)?this.elementRef._node:this._node;new(this.core.getComponent(g.donation))(this.core,{rootNode:t,commercialTxAmount:e.value})}}handleResponse(e){var t,s;e.action?this.elementRef.handleAction(e.action):(null===(s=e.order)||void 0===s||null===(t=s.remainingAmount)||void 0===t?void 0:t.value)>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyDown(e){var t;"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(null===(t=document)||void 0===t?void 0:t.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){var e;const t=this.props.paymentMethodType||this.type;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()(t)}get displayName(){var e,t;const s=null===(t=this.core.paymentMethodsResponse)||void 0===t||null===(e=t.paymentMethods)||void 0===e?void 0:e.find(e=>e.type===this.type);return this.props.name||(null==s?void 0:s.name)||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,t){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest(S(w({},e&&{order:{orderData:e.orderData,pspReference:e.pspReference}}),{locale:this.core.options.locale}),{resolve:t,reject:s})}).catch(e=>{this.handleError(new s("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(s=>this.core.update(S(w({},s&&{paymentMethodsResponse:s}),{order:e,amount:e?e.remainingAmount:t})))}render(){return e(R,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(P,{srPanel:this.srPanel},e(A,{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,providerRef:this.amountProviderRef},this.componentToRender())))}constructor(s,o){super(s,o),E(this,"componentRef",void 0),E(this,"resources",void 0),E(this,"elementRef",void 0),E(this,"amountProviderRef",t()),E(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===n&&e.options.code){const t=new p({component:this.type,errorType:m.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),E(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{var e,s;null===(e=(s=this.props).onOrderUpdated)||void 0===e||e.call(s,{order:t})})}),E(this,"handleFailedResult",e=>{var t,s;a(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),c(e),null===(t=(s=this.props).onPaymentFailed)||void 0===t||t.call(s,e,this.elementRef)}),E(this,"handleSuccessResult",e=>{var t,s;a(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),c(e),this.core.session&&!0===e.askDonation&&this.setupSessionsDonation(),null===(t=(s=this.props).onPaymentCompleted)||void 0===t||t.call(s,e,this.elementRef)}),E(this,"setComponentRef",e=>{this.componentRef=e}),E(this,"payButton",t=>e(r,S(w({},t),{onClick:this.submit}))),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.updateAmount=this.updateAmount.bind(this),this.setupSessionsDonation=this.setupSessionsDonation.bind(this),this.elementRef=o&&o.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(o),this.reportIntegrationFlavor()}}E(C,"type",void 0),E(C,"txVariants",[]);export{C as UIElement,C as default};
|
|
2
2
|
//# sourceMappingURL=UIElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { createRef, h, RefObject } from 'preact';\nimport { Resources } from '../../../core/Context/Resources';\nimport AdyenCheckoutError, { NETWORK_ERROR } from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\n\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventType } from '../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { AnalyticsLogEvent, LogEventType } from '../../../core/Analytics/events/AnalyticsLogEvent';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type { NewableComponent } from '../../../core/core.registry';\nimport CancelError from '../../../core/Errors/CancelError';\nimport type { AdditionalDetailsData, CoreConfiguration, ICore } from '../../../core/types';\nimport type {\n ActionHandledReturnObject,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentMethod\n} from '../../../types/global-types';\nimport type { ComponentMethodsRef, UIElementProps, UIElementStatus } from './types';\nimport type { IAnalytics } from '../../../core/Analytics/Analytics';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport { SRPanel } from '../../../core/Errors/SRPanel';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { AmountProvider, AmountProviderRef } from '../../../core/Context/AmountProvider';\nimport { PayButtonProps } from '../PayButton/PayButton';\nimport { TxVariants } from '../../tx-variants';\nimport Donation from '../../Donation/Donation';\nimport './UIElement.scss';\n\nexport abstract class UIElement<P extends UIElementProps = UIElementProps> extends BaseElement<P> {\n /**\n * componentRef is a ref to the primary component inside the subclass that extends UIElement e.g. CardInput.tsx (which sits inside Card.tsx)\n */\n protected componentRef: any;\n\n protected resources: Resources;\n\n /**\n * elementRef is a ref to the subclass that extends UIElement e.g. Card.tsx or Dropin.tsx\n */\n public elementRef: UIElement;\n\n public static readonly type: string | undefined = undefined;\n\n /**\n * Reference to the methods exposed by the AmountProvider context\n */\n protected amountProviderRef: RefObject<AmountProviderRef> = createRef();\n\n /**\n * Defines all txVariants that the Component supports (in case it support multiple ones besides the 'type' one)\n */\n public static readonly txVariants: string[] = [];\n\n constructor(checkout: ICore, props?: P) {\n super(checkout, props);\n\n this.core.register(this.constructor as NewableComponent);\n\n this.submit = this.submit.bind(this);\n this.setState = this.setState.bind(this);\n this.onComplete = this.onComplete.bind(this);\n this.handleAction = this.handleAction.bind(this);\n this.handleOrder = this.handleOrder.bind(this);\n this.handleAdditionalDetails = this.handleAdditionalDetails.bind(this);\n this.handleResponse = this.handleResponse.bind(this);\n this.setElementStatus = this.setElementStatus.bind(this);\n this.submitAnalytics = this.submitAnalytics.bind(this);\n this.makePaymentsCall = this.makePaymentsCall.bind(this);\n this.makeAdditionalDetailsCall = this.makeAdditionalDetailsCall.bind(this);\n this.submitUsingSessionsFlow = this.submitUsingSessionsFlow.bind(this);\n this.updateAmount = this.updateAmount.bind(this);\n this.setupSessionsDonation = this.setupSessionsDonation.bind(this);\n\n this.elementRef = (props && props.elementRef) || this;\n this.resources = this.props.modules ? this.props.modules.resources : undefined;\n\n this.storeElementRefOnCore(this.props);\n\n this.onEnterKeyPressed = this.onEnterKeyPressed.bind(this);\n this.onActionHandled = this.onActionHandled.bind(this);\n\n this.createBeforeRenderHook(props);\n this.reportIntegrationFlavor();\n }\n\n /**\n * Creates a hook tied to render() method. This hook is called every time render() is invoked.\n * Currently useful for Analytics\n *\n * @param configSetByMerchant\n * @private\n */\n private createBeforeRenderHook(configSetByMerchant: P): void {\n const originalRender = this.render;\n\n this.render = (...args: any[]) => {\n this.beforeRender(configSetByMerchant);\n return originalRender.apply(this, args);\n };\n }\n\n protected beforeRender(configSetByMerchant?: P): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && { isStoredPaymentMethod: true })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n protected reportIntegrationFlavor(): void {\n void this.analytics.sendFlavor('components');\n }\n\n get analytics(): IAnalytics {\n return this.core.modules.analytics;\n }\n\n get srPanel(): SRPanel {\n return this.core.modules.srPanel;\n }\n\n protected getPaymentMethodConfigFromResponse(componentProps: P) {\n if (componentProps?.storedPaymentMethodId) return this.getStoredPaymentMethodDetails(componentProps.storedPaymentMethodId);\n return this.getPaymentMethodFromPaymentMethodsResponse(componentProps?.type, componentProps?.paymentMethodId);\n }\n\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n\n const paymentMethodFromResponse = this.getPaymentMethodConfigFromResponse(componentProps);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodFromResponse,\n ...componentProps\n };\n\n const isDropinInstance = assertIsDropin(this);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropinInstance), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\n }\n\n protected getStoredPaymentMethodDetails(storedPaymentMethodId: string) {\n return this.core.paymentMethodsResponse.findStoredPaymentMethod(storedPaymentMethodId);\n }\n\n /**\n * Get the payment method from the paymentMethodsResponse\n *\n * @param type - The type of the payment method to get. (This prop is passed by Drop-in OR Standalone components containing the property 'type' as part of their configuration)\n * @param paymentMethodId - Unique internal payment method ID\n */\n protected getPaymentMethodFromPaymentMethodsResponse(type?: string, paymentMethodId?: string): RawPaymentMethod {\n if (paymentMethodId) return this.core.paymentMethodsResponse.findById(paymentMethodId);\n return this.core.paymentMethodsResponse?.find(type || this.constructor['type']);\n }\n\n protected storeElementRefOnCore(props?: P) {\n if (!props?.isDropin) {\n this.core.storeElementReference(this);\n }\n }\n\n public isAvailable(): Promise<void> {\n return Promise.resolve();\n }\n\n public setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n this.onChange();\n }\n\n public showValidation(): this {\n if (this.componentRef && this.componentRef.showValidation) this.componentRef.showValidation();\n return this;\n }\n\n /**\n * Updates the amount in the props and propagates it to the AmountProvider.\n * This allows children components to access the updated amount via context.\n *\n * @param amount - Primary payment amount object\n * @param secondaryAmount - Optional secondary amount for display purposes (e.g., converted currency)\n * @internal\n */\n public updateAmount(amount: PaymentAmount, secondaryAmount?: PaymentAmount): void {\n this.props = {\n ...this.props,\n ...(amount && { amount }),\n ...(secondaryAmount && { secondaryAmount })\n };\n this.amountProviderRef.current?.update(amount, secondaryAmount);\n }\n\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\n\n /**\n * componentRef is a ref to the primary component inside that subclass e.g. CardInput.tsx\n */\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n return this;\n }\n\n protected onChange(): void {\n this.props.onChange?.(\n {\n data: this.data,\n isValid: this.isValid,\n errors: this.state.errors,\n valid: this.state.valid\n },\n this.elementRef\n );\n }\n\n protected override submitAnalytics(event: AbstractAnalyticsEvent) {\n this.analytics.sendAnalytics(event);\n }\n\n public submit(): void {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n this.makePaymentsCall()\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n });\n }\n\n protected makePaymentsCall(): Promise<CheckoutAdvancedFlowResponse | CheckoutSessionPaymentResponse> {\n this.setElementStatus('loading');\n\n if (this.props.onSubmit) {\n return this.submitUsingAdvancedFlow();\n }\n\n if (this.core.session) {\n const beforeSubmitEvent: Promise<PaymentData> = this.props.beforeSubmit\n ? new Promise((resolve, reject) => {\n void this.props.beforeSubmit(this.data, this.elementRef, {\n resolve,\n reject: () => reject(new CancelError('beforeSubmitRejected'))\n });\n })\n : Promise.resolve(this.data);\n\n return beforeSubmitEvent.then(this.submitUsingSessionsFlow);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments call. Callback \"onSubmit\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitUsingAdvancedFlow(): Promise<CheckoutAdvancedFlowResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onSubmit(\n {\n data: this.data,\n isValid: this.isValid\n },\n this.elementRef,\n { resolve, reject }\n );\n });\n }\n\n private async submitUsingSessionsFlow(data: PaymentData): Promise<CheckoutSessionPaymentResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\n }\n\n return Promise.reject(error);\n }\n\n // // Uncomment to simulate failed\n // return {\n // resultCode: 'Refused',\n // sessionData:\n // 'Ab02b4c0!BQABAgBKGgqfEz8uQlU4yCIOWjA8bkEwmbJ7Qt4r+x5IPXREu1rMjwNk5MDoHFNlv+MWvinS6nXIDniXgRzXCdSC4ksw9CNDBAjOa+B88wRoj/rLTieuWh/0leR88qkV24vtIkjsIsbJTDB78Pd8wX8MEDsXhaAdEIyX9E8eqxuQ3bwPbvLs1Dlgo1ZrfkQRzaNiuVM8ejRG0IWE1bGThJzY+sJvZZHvlDMXIlxhZcDoQvsMj/WwE6+nFJxBiC3oRzmvVn3AbkLQGtvwq16UUSfYbPzG9dXypJMtcrZAQYq2g/2+BSibCcmee9AXq/wij11BERrYmjbDt5NkkdUnDVgAB7pdqbnWX0A2sxBKeYtLSP2kxp+5LoU/Wty3fmcVA3VKVkHfgmIihkeL8lY++5hvHjnkzOE4tyx/sheiKS4zqoWE43TD6n8mpFskAzwMHq4G2o6vkXqvaKFEq7y/R2fVrCypenmRhkPASizpM265rKLU+L4E/C+LMHfN0LYKRMCrLr0gI2GAp+1PZLHgh0tCtiJC/zcJJtJs6sHNQxLUN+kxJuELUHOcuL3ivjG+mWteUnBENZu7KqOSZYetiWYRiyLOXDiBHqbxuQwTuO54L15VLkS/mYB20etibM1nn+fRmbo+1IJkCSalhwi5D7fSrpjbQTmAsOpJT1N8lC1MSNmAvAwG1kWL4JxYwXDKYyYASnsia2V5IjoiQUYwQUFBMTAzQ0E1MzdFQUVEODdDMjRERDUzOTA5QjgwQTc4QTkyM0UzODIzRDY4REFDQzk0QjlGRjgzMDVEQyJ98uZI4thGveOByYbomCeeP2Gy2rzs99FOBoDYVeWIUjyM+gfnW89DdJZAhxe74Tv0TnL5DRQYPCTRQPOoLbQ21NaeSho70FNE+n8XYKlVK5Ore6BoB6IVCaal5MkM27VmZPMmGflgc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leAdditionalDetails(state);\n }\n\n protected handleError = (error: AdyenCheckoutError): void => {\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n this.setElementStatus('ready');\n\n if (error.name === NETWORK_ERROR && error.options.code) {\n const event = new AnalyticsErrorEvent({\n component: this.type,\n errorType: ErrorEventType.apiError,\n code: error.options.code\n });\n\n this.submitAnalytics(event);\n }\n\n if (this.props.onError) {\n this.props.onError(error, this.elementRef);\n }\n };\n\n protected handleAdditionalDetails(state: AdditionalDetailsData): void {\n this.makeAdditionalDetailsCall(state)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n private makeAdditionalDetailsCall(state: AdditionalDetailsData): Promise<CheckoutSessionDetailsResponse | CheckoutAdvancedFlowResponse> {\n if (this.props.onAdditionalDetails) {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onAdditionalDetails(state, this.elementRef, { resolve, reject });\n });\n }\n\n if (this.core.session) {\n return this.submitAdditionalDetailsUsingSessionsFlow(state.data);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments/details call. Callback \"onAdditionalDetails\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitAdditionalDetailsUsingSessionsFlow(data: any): Promise<CheckoutSessionDetailsResponse> {\n try {\n return await this.core.session.submitDetails(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /details call', { cause: error }));\n\n return Promise.reject(error);\n }\n }\n\n public handleAction(action: PaymentAction, props = {}): UIElement | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props\n });\n\n if (paymentAction) {\n this.unmount();\n return paymentAction.mount(this._node);\n }\n\n return null;\n }\n\n protected onActionHandled(actionHandledObj: ActionHandledReturnObject) {\n this.props?.onActionHandled?.({ originalAction: this.props.originalAction, ...actionHandledObj });\n }\n\n protected handleOrder = (response: PaymentResponseData): void => {\n const { order } = response;\n\n const updateCorePromise = this.core.session\n ? this.core.update({\n order\n })\n : this.handleAdvanceFlowPaymentMethodsUpdate(order);\n\n void updateCorePromise.then(() => {\n this.props.onOrderUpdated?.({ order });\n });\n };\n\n protected setupSessionsDonation() {\n const { amount, donation } = this.props;\n\n // If merchant hasn't explicitly disabled autoMount by setting it to false\n if (donation?.autoMount !== false) {\n const rootNode: HTMLElement = assertIsDropin(this.elementRef) ? this.elementRef._node : this._node;\n\n const DonationComponentRef = this.core.getComponent(TxVariants.donation) as typeof Donation;\n new DonationComponentRef(this.core, { rootNode, commercialTxAmount: amount.value }); // NOSONAR: Instantiation triggers internal async initialization (fire-and-forget pattern)\n }\n }\n\n /**\n * Handles when the payment fails. The payment fails when:\n * - adv flow: the merchant rejects the payment due to a critical error\n * - adv flow: the merchant resolves the payment with a failed resultCode\n * - sessions: a network error occurs when making the payment\n * - sessions: the payment fails with a failed resultCode\n *\n * @param result\n */\n protected handleFailedResult = (result?: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('error');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentFailed?.(result, this.elementRef);\n };\n\n protected handleSuccessResult = (result: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('success');\n }\n\n cleanupFinalResult(result);\n\n /** If we are using sessions and the response mandates it - create a Donation instance */\n if (this.core.session && result.askDonation === true) {\n this.setupSessionsDonation();\n }\n\n this.props.onPaymentCompleted?.(result, this.elementRef);\n };\n\n /**\n * Handles a /payments or /payments/details response.\n * The component will handle automatically actions, orders, and final results.\n *\n * Expected to be called after sanitizeResponse has been run on the raw payment response\n *\n * @param response -\n */\n protected handleResponse(response: PaymentResponseData): void {\n if (response.action) {\n this.elementRef.handleAction(response.action);\n return;\n }\n\n if (response.order?.remainingAmount?.value > 0) {\n // we don't want to call elementRef here, use the component handler\n // we do this way so the logic on handlingOrder is associated with payment method\n this.handleOrder(response);\n return;\n }\n\n this.handleSuccessResult(response);\n }\n\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n e.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n\n this.onEnterKeyPressed(document?.activeElement, this);\n }\n }\n\n /**\n * Handle Enter key pressed from a UIElement (called via handleKeyPress)\n * @param obj\n */\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n if (this.props.onEnterKeyPressed) {\n this.props.onEnterKeyPressed(activeElement, component);\n } else {\n (activeElement as HTMLElement).blur();\n this.submit();\n }\n }\n\n /**\n * Call update on parent instance\n * This function exist to make safe access to the protected _parentInstance\n * @param options - CoreOptions\n */\n public updateParent(options: CoreConfiguration = {}): Promise<ICore> {\n return this.elementRef.core.update(options);\n }\n\n public setComponentRef = (ref: ComponentMethodsRef) => {\n this.componentRef = ref;\n };\n\n /**\n * Get the current validation status of the element\n */\n public get isValid(): boolean {\n return false;\n }\n\n /**\n * Get the element icon URL for the current environment\n */\n public get icon(): string {\n const type = this.props.paymentMethodType || this.type;\n return this.props.icon ?? this.resources.getImage()(type);\n }\n\n /**\n * Get the element's displayable name\n */\n public get displayName(): string {\n const paymentMethodFromResponse = this.core.paymentMethodsResponse?.paymentMethods?.find(pm => pm.type === this.type);\n return this.props.name || paymentMethodFromResponse?.name || this.type;\n }\n\n /**\n * Get the element accessible name, used in the aria-label of the button that controls selected payment method\n */\n public get accessibleName(): string {\n return this.displayName;\n }\n\n /**\n * Used to display the second line of a payment method item\n */\n get additionalInfo(): string {\n return null;\n }\n\n /**\n * Return the type of an element\n */\n public get type(): string {\n return this.props.type || this.constructor['type'];\n }\n\n /**\n * Get the payButton component for the current element\n */\n protected payButton = (props: PayButtonProps) => {\n return <PayButton {...props} onClick={this.submit} />;\n };\n\n /**\n * Used in the Partial Orders flow.\n * When the Order is updated, the merchant can request new payment methods based on the new remaining amount\n *\n * @private\n */\n protected async handleAdvanceFlowPaymentMethodsUpdate(order: Order | null, amount?: PaymentAmount) {\n return new Promise<void | PaymentMethodsResponse>((resolve, reject) => {\n if (!this.props.onPaymentMethodsRequest) {\n return resolve();\n }\n\n this.props.onPaymentMethodsRequest(\n {\n ...(order && {\n order: {\n orderData: order.orderData,\n pspReference: order.pspReference\n }\n }),\n locale: this.core.options.locale\n },\n { resolve, reject }\n );\n })\n .catch(error => {\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'Something failed during payment methods update or onPaymentMethodsRequest was not implemented',\n {\n cause: error\n }\n )\n );\n })\n .then(paymentMethodsResponse => {\n // in the case of the session flow we get order, amount, countryCode and shopperLocale from initialize()\n // apply the same logic here for order and amount\n // in the future it might be worth moving this logic to be performed by the core on update()\n // it would make this more consistent\n return this.core.update({\n ...(paymentMethodsResponse && { paymentMethodsResponse }),\n order,\n amount: order ? order.remainingAmount : amount\n });\n });\n }\n\n protected abstract componentToRender(): h.JSX.Element | null;\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources} analytics={this.analytics}>\n <SRPanelProvider srPanel={this.srPanel}>\n <AmountProvider amount={this.props.amount} secondaryAmount={this.props.secondaryAmount} providerRef={this.amountProviderRef}>\n {this.componentToRender()}\n </AmountProvider>\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UIElement;\n"],"names":["UIElement","BaseElement","createBeforeRenderHook","configSetByMerchant","originalRender","this","render","args","beforeRender","apply","originalAction","event","AnalyticsInfoEvent","_object_spread","type","InfoEventType","rendered","component","configData","_object_spread_props","showPayButton","props","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","reportIntegrationFlavor","sendFlavor","core","modules","srPanel","getPaymentMethodConfigFromResponse","componentProps","storedPaymentMethodId","getStoredPaymentMethodDetails","getPaymentMethodFromPaymentMethodsResponse","paymentMethodId","buildElementProps","finalProps","getCorePropsForComponent","isDropinInstance","assertIsDropin","formatProps","constructor","getRegulatoryDefaults","options","countryCode","paymentMethodsResponse","findStoredPaymentMethod","_this_core_paymentMethodsResponse","findById","find","storeElementRefOnCore","isDropin","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","updateAmount","amount","secondaryAmount","_this_amountProviderRef_current","amountProviderRef","current","update","setElementStatus","status","_this_elementRef","elementRef","setStatus","_this_componentRef","_this_props_onChange","_this_props","call","data","isValid","errors","valid","submitAnalytics","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","handleFailedResult","onSubmit","submitUsingAdvancedFlow","session","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","AnalyticsLogEvent","LogEventType","message","submitPayment","error","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","unmount","mount","_node","onActionHandled","actionHandledObj","_this_props_onActionHandled","setupSessionsDonation","donation","autoMount","rootNode","getComponent","TxVariants","commercialTxAmount","value","response","order","remainingAmount","handleOrder","handleSuccessResult","handleKeyPress","document","key","code","preventDefault","onEnterKeyPressed","activeElement","blur","updateParent","icon","_this_props_icon","paymentMethodType","resources","getImage","displayName","_this_core_paymentMethodsResponse_paymentMethods","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","onPaymentMethodsRequest","orderData","pspReference","locale","h","CoreProvider","i18n","loadingContext","SRPanelProvider","AmountProvider","providerRef","componentToRender","checkout","super","_define_property","createRef","NETWORK_ERROR","AnalyticsErrorEvent","errorType","ErrorEventType","apiError","onError","_this_props_onOrderUpdated","onOrderUpdated","result","_this_props_onPaymentFailed","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","_this_props_onPaymentCompleted","askDonation","onPaymentCompleted","setComponentRef","ref","payButton","PayButton","onClick","register","bind","undefined","txVariants"],"mappings":"y2DAsCO,MAAeA,UAA6DC,EAgEvEC,sBAAAA,CAAuBC,GAC3B,MAAMC,EAAiBC,KAAKC,OAE5BD,KAAKC,OAAS,IAAIC,KACdF,KAAKG,aAAaL,GACXC,EAAeK,MAAMJ,KAAME,GAE1C,CAEUC,YAAAA,CAAaL,GAEnB,GAAIA,aAAAA,EAAAA,EAAqBO,eACrB,OAGJ,MAAMC,EAAQ,IAAIC,EAAmBC,EAAA,CACjCC,KAAMC,EAAcC,SACpBC,UAAWZ,KAAKS,KAChBI,WAAYC,EAAAN,EAAA,CAAA,EAAKV,GAAAA,CAAqBiB,cAAef,KAAKgB,MAAMD,kBAC5DjB,aAAAA,EAAAA,EAAqBmB,WAAY,CAAEC,uBAAuB,KAGlElB,KAAKmB,UAAUC,cAAcd,EACjC,CAEUe,uBAAAA,GACDrB,KAAKmB,UAAUG,WAAW,aACnC,CAEA,aAAIH,GACA,OAAOnB,KAAKuB,KAAKC,QAAQL,SAC7B,CAEA,WAAIM,GACA,OAAOzB,KAAKuB,KAAKC,QAAQC,OAC7B,CAEUC,kCAAAA,CAAmCC,GACzC,OAAIA,aAAAA,EAAAA,EAAgBC,uBAA8B5B,KAAK6B,8BAA8BF,EAAeC,uBAC7F5B,KAAK8B,2CAA2CH,eAAAA,EAAgBlB,KAAMkB,aAAAA,EAAAA,EAAgBI,gBACjG,CAEmBC,iBAAAA,CAAkBL,GACjC,MAIMM,EAAazB,EAAA,CACfO,eAAe,GALKf,KAAKuB,KAAKW,2BAEAlC,KA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I,KAAKqI,YAAY+D,KAAKpM,MACzCA,KAAKyG,wBAA0BzG,KAAKyG,wBAAwB2F,KAAKpM,MACjEA,KAAKqF,eAAiBrF,KAAKqF,eAAe+G,KAAKpM,MAC/CA,KAAKkE,iBAAmBlE,KAAKkE,iBAAiBkI,KAAKpM,MACnDA,KAAK+E,gBAAkB/E,KAAK+E,gBAAgBqH,KAAKpM,MACjDA,KAAKiF,iBAAmBjF,KAAKiF,iBAAiBmH,KAAKpM,MACnDA,KAAK0G,0BAA4B1G,KAAK0G,0BAA0B0F,KAAKpM,MACrEA,KAAK+F,wBAA0B/F,KAAK+F,wBAAwBqG,KAAKpM,MACjEA,KAAK2D,aAAe3D,KAAK2D,aAAayI,KAAKpM,MAC3CA,KAAK0H,sBAAwB1H,KAAK0H,sBAAsB0E,KAAKpM,MAE7DA,KAAKqE,WAAcrD,GAASA,EAAMqD,YAAerE,KACjDA,KAAKmJ,UAAYnJ,KAAKgB,MAAMQ,QAAUxB,KAAKgB,MAAMQ,QAAQ2H,eAAYkD,EAErErM,KAAK+C,sBAAsB/C,KAAKgB,OAEhChB,KAAK4I,kBAAoB5I,KAAK4I,kBAAkBwD,KAAKpM,MACrDA,KAAKuH,gBAAkBvH,KAAKuH,gBAAgB6E,KAAKpM,MAEjDA,KAAKH,uBAAuBmB,GAC5BhB,KAAKqB,yBACT,EA1CAuJ,EAbkBjL,EAaKc,YAA2B4L,GAUlDzB,EAvBkBjL,EAuBK2M,aAAuB"}
|
|
1
|
+
{"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { createRef, h, RefObject, TargetedKeyboardEvent } from 'preact';\nimport { Resources } from '../../../core/Context/Resources';\nimport AdyenCheckoutError, { NETWORK_ERROR } from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\n\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventType } from '../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { AnalyticsLogEvent, LogEventType } from '../../../core/Analytics/events/AnalyticsLogEvent';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type { NewableComponent } from '../../../core/core.registry';\nimport CancelError from '../../../core/Errors/CancelError';\nimport type { AdditionalDetailsData, CoreConfiguration, ICore } from '../../../core/types';\nimport type {\n ActionHandledReturnObject,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentMethod\n} from '../../../types/global-types';\nimport type { ComponentMethodsRef, UIElementProps, UIElementStatus } from './types';\nimport type { IAnalytics } from '../../../core/Analytics/Analytics';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport { SRPanel } from '../../../core/Errors/SRPanel';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { AmountProvider, AmountProviderRef } from '../../../core/Context/AmountProvider';\nimport { PayButtonProps } from '../PayButton/PayButton';\nimport { TxVariants } from '../../tx-variants';\nimport Donation from '../../Donation/Donation';\nimport './UIElement.scss';\n\nexport abstract class UIElement<P extends UIElementProps = UIElementProps> extends BaseElement<P> {\n /**\n * componentRef is a ref to the primary component inside the subclass that extends UIElement e.g. CardInput.tsx (which sits inside Card.tsx)\n */\n protected componentRef: any;\n\n protected resources: Resources;\n\n /**\n * elementRef is a ref to the subclass that extends UIElement e.g. Card.tsx or Dropin.tsx\n */\n public elementRef: UIElement;\n\n public static readonly type: string | undefined = undefined;\n\n /**\n * Reference to the methods exposed by the AmountProvider context\n */\n protected amountProviderRef: RefObject<AmountProviderRef> = createRef();\n\n /**\n * Defines all txVariants that the Component supports (in case it support multiple ones besides the 'type' one)\n */\n public static readonly txVariants: string[] = [];\n\n constructor(checkout: ICore, props?: P) {\n super(checkout, props);\n\n this.core.register(this.constructor as NewableComponent);\n\n this.submit = this.submit.bind(this);\n this.setState = this.setState.bind(this);\n this.onComplete = this.onComplete.bind(this);\n this.handleAction = this.handleAction.bind(this);\n this.handleOrder = this.handleOrder.bind(this);\n this.handleAdditionalDetails = this.handleAdditionalDetails.bind(this);\n this.handleResponse = this.handleResponse.bind(this);\n this.setElementStatus = this.setElementStatus.bind(this);\n this.submitAnalytics = this.submitAnalytics.bind(this);\n this.makePaymentsCall = this.makePaymentsCall.bind(this);\n this.makeAdditionalDetailsCall = this.makeAdditionalDetailsCall.bind(this);\n this.submitUsingSessionsFlow = this.submitUsingSessionsFlow.bind(this);\n this.updateAmount = this.updateAmount.bind(this);\n this.setupSessionsDonation = this.setupSessionsDonation.bind(this);\n\n this.elementRef = (props && props.elementRef) || this;\n this.resources = this.props.modules ? this.props.modules.resources : undefined;\n\n this.storeElementRefOnCore(this.props);\n\n this.onEnterKeyPressed = this.onEnterKeyPressed.bind(this);\n this.onActionHandled = this.onActionHandled.bind(this);\n\n this.createBeforeRenderHook(props);\n this.reportIntegrationFlavor();\n }\n\n /**\n * Creates a hook tied to render() method. This hook is called every time render() is invoked.\n * Currently useful for Analytics\n *\n * @param configSetByMerchant\n * @private\n */\n private createBeforeRenderHook(configSetByMerchant: P): void {\n const originalRender = this.render;\n\n this.render = (...args: any[]) => {\n this.beforeRender(configSetByMerchant);\n return originalRender.apply(this, args);\n };\n }\n\n protected beforeRender(configSetByMerchant?: P): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && { isStoredPaymentMethod: true })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n protected reportIntegrationFlavor(): void {\n void this.analytics.sendFlavor('components');\n }\n\n get analytics(): IAnalytics {\n return this.core.modules.analytics;\n }\n\n get srPanel(): SRPanel {\n return this.core.modules.srPanel;\n }\n\n protected getPaymentMethodConfigFromResponse(componentProps: P) {\n if (componentProps?.storedPaymentMethodId) return this.getStoredPaymentMethodDetails(componentProps.storedPaymentMethodId);\n return this.getPaymentMethodFromPaymentMethodsResponse(componentProps?.type, componentProps?.paymentMethodId);\n }\n\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n\n const paymentMethodFromResponse = this.getPaymentMethodConfigFromResponse(componentProps);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodFromResponse,\n ...componentProps\n };\n\n const isDropinInstance = assertIsDropin(this);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropinInstance), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\n }\n\n protected getStoredPaymentMethodDetails(storedPaymentMethodId: string) {\n return this.core.paymentMethodsResponse.findStoredPaymentMethod(storedPaymentMethodId);\n }\n\n /**\n * Get the payment method from the paymentMethodsResponse\n *\n * @param type - The type of the payment method to get. (This prop is passed by Drop-in OR Standalone components containing the property 'type' as part of their configuration)\n * @param paymentMethodId - Unique internal payment method ID\n */\n protected getPaymentMethodFromPaymentMethodsResponse(type?: string, paymentMethodId?: string): RawPaymentMethod {\n if (paymentMethodId) return this.core.paymentMethodsResponse.findById(paymentMethodId);\n return this.core.paymentMethodsResponse?.find(type || this.constructor['type']);\n }\n\n protected storeElementRefOnCore(props?: P) {\n if (!props?.isDropin) {\n this.core.storeElementReference(this);\n }\n }\n\n public isAvailable(): Promise<void> {\n return Promise.resolve();\n }\n\n public setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n this.onChange();\n }\n\n public showValidation(): this {\n if (this.componentRef && this.componentRef.showValidation) this.componentRef.showValidation();\n return this;\n }\n\n /**\n * Updates the amount in the props and propagates it to the AmountProvider.\n * This allows children components to access the updated amount via context.\n *\n * @param amount - Primary payment amount object\n * @param secondaryAmount - Optional secondary amount for display purposes (e.g., converted currency)\n * @internal\n */\n public updateAmount(amount: PaymentAmount, secondaryAmount?: PaymentAmount): void {\n this.props = {\n ...this.props,\n ...(amount && { amount }),\n ...(secondaryAmount && { secondaryAmount })\n };\n this.amountProviderRef.current?.update(amount, secondaryAmount);\n }\n\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\n\n /**\n * componentRef is a ref to the primary component inside that subclass e.g. CardInput.tsx\n */\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n return this;\n }\n\n protected onChange(): void {\n this.props.onChange?.(\n {\n data: this.data,\n isValid: this.isValid,\n errors: this.state.errors,\n valid: this.state.valid\n },\n this.elementRef\n );\n }\n\n protected override submitAnalytics(event: AbstractAnalyticsEvent) {\n this.analytics.sendAnalytics(event);\n }\n\n public submit(): void {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n this.makePaymentsCall()\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n });\n }\n\n protected makePaymentsCall(): Promise<CheckoutAdvancedFlowResponse | CheckoutSessionPaymentResponse> {\n this.setElementStatus('loading');\n\n if (this.props.onSubmit) {\n return this.submitUsingAdvancedFlow();\n }\n\n if (this.core.session) {\n const beforeSubmitEvent: Promise<PaymentData> = this.props.beforeSubmit\n ? new Promise((resolve, reject) => {\n void this.props.beforeSubmit(this.data, this.elementRef, {\n resolve,\n reject: () => reject(new CancelError('beforeSubmitRejected'))\n });\n })\n : Promise.resolve(this.data);\n\n return beforeSubmitEvent.then(this.submitUsingSessionsFlow);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments call. Callback \"onSubmit\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitUsingAdvancedFlow(): Promise<CheckoutAdvancedFlowResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onSubmit(\n {\n data: this.data,\n isValid: this.isValid\n },\n this.elementRef,\n { resolve, reject }\n );\n });\n }\n\n private async submitUsingSessionsFlow(data: PaymentData): Promise<CheckoutSessionPaymentResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\n }\n\n return Promise.reject(error);\n }\n\n // // Uncomment to simulate failed\n // return {\n // resultCode: 'Refused',\n // sessionData:\n // 'Ab02b4c0!BQABAgBKGgqfEz8uQlU4yCIOWjA8bkEwmbJ7Qt4r+x5IPXREu1rMjwNk5MDoHFNlv+MWvinS6nXIDniXgRzXCdSC4ksw9CNDBAjOa+B88wRoj/rLTieuWh/0leR88qkV24vtIkjsIsbJTDB78Pd8wX8MEDsXhaAdEIyX9E8eqxuQ3bwPbvLs1Dlgo1ZrfkQRzaNiuVM8ejRG0IWE1bGThJzY+sJvZZHvlDMXIlxhZcDoQvsMj/WwE6+nFJxBiC3oRzmvVn3AbkLQGtvwq16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doMZON1YEiWY5EzazQwtHd9yzdty9ZHPxAfuOfCh4OhbhFNp+v5YQ+PzKZ+UpM1VxV863+9XgWEURPNvX7qq1cpUSRzrSGq01QBBM3MKzRh5mAgqIdXgtl7L0EXAep0MECc7QY0/o3tW3VR8eEJGsSzrNxpFItqj0SEaIWo25dRfkl5zuw47GQrN9Qzxl2WV3A38MQPUqFtIr/71Rjkphgg49ZGWEYCwgFmm8jJc2/5qTabSGk4bzwiETCTzeydq30bUGqCwglj8CrFViAuQeTJm7dp+PYKMkUNvQRpnSXMj6Kz7rvAMzhzJgK62ltN2idqKxLC7WtivCUgejuQUvNreCYBQCaKwTwP02lZsJpGF9yw8gbyuoB+2aB7IZmgIB8GP4qVQ/ht5B9z/FLohK/8cSPV/4i32SNNdcwhV',\n // sessionResult:\n // 'X3XtfGC7!H4sIAAAAAAAA/6tWykxRslJyDjaxNDMyM3E2MXIyNDUys3RU0lHKTS1KzkjMK3FMTs4vzSsBKgtJLS7xhYo6Z6QmZ+eXlgAVFpcklpQWA+WLUtNKi1NTlGoBMEEbz1cAAAA=iMsCaEJ5LcnsqIUtmNxjm8HtfQ8gZW8JewEU3wHz4qg='\n // };\n }\n\n protected onComplete(state): void {\n this.handleAdditionalDetails(state);\n }\n\n protected handleError = (error: AdyenCheckoutError): void => {\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n this.setElementStatus('ready');\n\n if (error.name === NETWORK_ERROR && error.options.code) {\n const event = new AnalyticsErrorEvent({\n component: this.type,\n errorType: ErrorEventType.apiError,\n code: error.options.code\n });\n\n this.submitAnalytics(event);\n }\n\n if (this.props.onError) {\n this.props.onError(error, this.elementRef);\n }\n };\n\n protected handleAdditionalDetails(state: AdditionalDetailsData): void {\n this.makeAdditionalDetailsCall(state)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n private makeAdditionalDetailsCall(state: AdditionalDetailsData): Promise<CheckoutSessionDetailsResponse | CheckoutAdvancedFlowResponse> {\n if (this.props.onAdditionalDetails) {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onAdditionalDetails(state, this.elementRef, { resolve, reject });\n });\n }\n\n if (this.core.session) {\n return this.submitAdditionalDetailsUsingSessionsFlow(state.data);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments/details call. Callback \"onAdditionalDetails\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitAdditionalDetailsUsingSessionsFlow(data: any): Promise<CheckoutSessionDetailsResponse> {\n try {\n return await this.core.session.submitDetails(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /details call', { cause: error }));\n\n return Promise.reject(error);\n }\n }\n\n public handleAction(action: PaymentAction, props = {}): UIElement | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props\n });\n\n if (paymentAction) {\n this.unmount();\n return paymentAction.mount(this._node);\n }\n\n return null;\n }\n\n protected onActionHandled(actionHandledObj: ActionHandledReturnObject) {\n this.props?.onActionHandled?.({ originalAction: this.props.originalAction, ...actionHandledObj });\n }\n\n protected handleOrder = (response: PaymentResponseData): void => {\n const { order } = response;\n\n const updateCorePromise = this.core.session\n ? this.core.update({\n order\n })\n : this.handleAdvanceFlowPaymentMethodsUpdate(order);\n\n void updateCorePromise.then(() => {\n this.props.onOrderUpdated?.({ order });\n });\n };\n\n protected setupSessionsDonation() {\n const { amount, donation } = this.props;\n\n // If merchant hasn't explicitly disabled autoMount by setting it to false\n if (donation?.autoMount !== false) {\n const rootNode: HTMLElement = assertIsDropin(this.elementRef) ? this.elementRef._node : this._node;\n\n const DonationComponentRef = this.core.getComponent(TxVariants.donation) as typeof Donation;\n new DonationComponentRef(this.core, { rootNode, commercialTxAmount: amount.value }); // NOSONAR: Instantiation triggers internal async initialization (fire-and-forget pattern)\n }\n }\n\n /**\n * Handles when the payment fails. The payment fails when:\n * - adv flow: the merchant rejects the payment due to a critical error\n * - adv flow: the merchant resolves the payment with a failed resultCode\n * - sessions: a network error occurs when making the payment\n * - sessions: the payment fails with a failed resultCode\n *\n * @param result\n */\n protected handleFailedResult = (result?: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('error');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentFailed?.(result, this.elementRef);\n };\n\n protected handleSuccessResult = (result: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('success');\n }\n\n cleanupFinalResult(result);\n\n /** If we are using sessions and the response mandates it - create a Donation instance */\n if (this.core.session && result.askDonation === true) {\n this.setupSessionsDonation();\n }\n\n this.props.onPaymentCompleted?.(result, this.elementRef);\n };\n\n /**\n * Handles a /payments or /payments/details response.\n * The component will handle automatically actions, orders, and final results.\n *\n * Expected to be called after sanitizeResponse has been run on the raw payment response\n *\n * @param response -\n */\n protected handleResponse(response: PaymentResponseData): void {\n if (response.action) {\n this.elementRef.handleAction(response.action);\n return;\n }\n\n if (response.order?.remainingAmount?.value > 0) {\n // we don't want to call elementRef here, use the component handler\n // we do this way so the logic on handlingOrder is associated with payment method\n this.handleOrder(response);\n return;\n }\n\n this.handleSuccessResult(response);\n }\n\n protected handleKeyDown(e: TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n e.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n\n this.onEnterKeyPressed(document?.activeElement, this);\n }\n }\n\n /**\n * Handle Enter key pressed from a UIElement (called via handleKeyDown)\n * @param obj\n */\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n if (this.props.onEnterKeyPressed) {\n this.props.onEnterKeyPressed(activeElement, component);\n } else {\n (activeElement as HTMLElement).blur();\n this.submit();\n }\n }\n\n /**\n * Call update on parent instance\n * This function exist to make safe access to the protected _parentInstance\n * @param options - CoreOptions\n */\n public updateParent(options: CoreConfiguration = {}): Promise<ICore> {\n return this.elementRef.core.update(options);\n }\n\n public setComponentRef = (ref: ComponentMethodsRef) => {\n this.componentRef = ref;\n };\n\n /**\n * Get the current validation status of the element\n */\n public get isValid(): boolean {\n return false;\n }\n\n /**\n * Get the element icon URL for the current environment\n */\n public get icon(): string {\n const type = this.props.paymentMethodType || this.type;\n return this.props.icon ?? this.resources.getImage()(type);\n }\n\n /**\n * Get the element's displayable name\n */\n public get displayName(): string {\n const paymentMethodFromResponse = this.core.paymentMethodsResponse?.paymentMethods?.find(pm => pm.type === this.type);\n return this.props.name || paymentMethodFromResponse?.name || this.type;\n }\n\n /**\n * Get the element accessible name, used in the aria-label of the button that controls selected payment method\n */\n public get accessibleName(): string {\n return this.displayName;\n }\n\n /**\n * Used to display the second line of a payment method item\n */\n get additionalInfo(): string {\n return null;\n }\n\n /**\n * Return the type of an element\n */\n public get type(): string {\n return this.props.type || this.constructor['type'];\n }\n\n /**\n * Get the payButton component for the current element\n */\n protected payButton = (props: PayButtonProps) => {\n return <PayButton {...props} onClick={this.submit} />;\n };\n\n /**\n * Used in the Partial Orders flow.\n * When the Order is updated, the merchant can request new payment methods based on the new remaining amount\n *\n * @private\n */\n protected async handleAdvanceFlowPaymentMethodsUpdate(order: Order | null, amount?: PaymentAmount) {\n return new Promise<void | PaymentMethodsResponse>((resolve, reject) => {\n if (!this.props.onPaymentMethodsRequest) {\n return resolve();\n }\n\n this.props.onPaymentMethodsRequest(\n {\n ...(order && {\n order: {\n orderData: order.orderData,\n pspReference: order.pspReference\n }\n }),\n locale: this.core.options.locale\n },\n { resolve, reject }\n );\n })\n .catch(error => {\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'Something failed during payment methods update or onPaymentMethodsRequest was not implemented',\n {\n cause: error\n }\n )\n );\n })\n .then(paymentMethodsResponse => {\n // in the case of the session flow we get order, amount, countryCode and shopperLocale from initialize()\n // apply the same logic here for order and amount\n // in the future it might be worth moving this logic to be performed by the core on update()\n // it would make this more consistent\n return this.core.update({\n ...(paymentMethodsResponse && { paymentMethodsResponse }),\n order,\n amount: order ? order.remainingAmount : amount\n });\n });\n }\n\n protected abstract componentToRender(): h.JSX.Element | null;\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources} analytics={this.analytics}>\n <SRPanelProvider srPanel={this.srPanel}>\n <AmountProvider amount={this.props.amount} secondaryAmount={this.props.secondaryAmount} providerRef={this.amountProviderRef}>\n {this.componentToRender()}\n </AmountProvider>\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UIElement;\n"],"names":["UIElement","BaseElement","createBeforeRenderHook","configSetByMerchant","originalRender","this","render","args","beforeRender","apply","originalAction","event","AnalyticsInfoEvent","_object_spread","type","InfoEventType","rendered","component","configData","_object_spread_props","showPayButton","props","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","reportIntegrationFlavor","sendFlavor","core","modules","srPanel","getPaymentMethodConfigFromResponse","componentProps","storedPaymentMethodId","getStoredPaymentMethodDetails","getPaymentMethodFromPaymentMethodsResponse","paymentMethodId","buildElementProps","finalProps","getCorePropsForComponent","isDropinInstance","assertIsDropin","formatProps","constructor","getRegulatoryDefaults","options","countryCode","paymentMethodsResponse","findStoredPaymentMethod","_this_core_paymentMethodsResponse","findById","find","storeElementRefOnCore","isDropin","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","updateAmount","amount","secondaryAmount","_this_amountProviderRef_current","amountProviderRef","current","update","setElementStatus","status","_this_elementRef","elementRef","setStatus","_this_componentRef","_this_props_onChange","_this_props","call","data","isValid","errors","valid","submitAnalytics","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","handleFailedResult","onSubmit","submitUsingAdvancedFlow","session","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","AnalyticsLogEvent","LogEventType","message","submitPayment","error","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","unmount","mount","_node","onActionHandled","actionHandledObj","_this_props_onActionHandled","setupSessionsDonation","donation","autoMount","rootNode","getComponent","TxVariants","commercialTxAmount","value","response","order","remainingAmount","handleOrder","handleSuccessResult","handleKeyDown","document","key","code","preventDefault","onEnterKeyPressed","activeElement","blur","updateParent","icon","_this_props_icon","paymentMethodType","resources","getImage","displayName","_this_core_paymentMethodsResponse_paymentMethods","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","onPaymentMethodsRequest","orderData","pspReference","locale","h","CoreProvider","i18n","loadingContext","SRPanelProvider","AmountProvider","providerRef","componentToRender","checkout","super","_define_property","createRef","NETWORK_ERROR","AnalyticsErrorEvent","errorType","ErrorEventType","apiError","onError","_this_props_onOrderUpdated","onOrderUpdated","result","_this_props_onPaymentFailed","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","_this_props_onPaymentCompleted","askDonation","onPaymentCompleted","setComponentRef","ref","payButton","PayButton","onClick","register","bind","undefined","txVariants"],"mappings":"y2DAsCO,MAAeA,UAA6DC,EAgEvEC,sBAAAA,CAAuBC,GAC3B,MAAMC,EAAiBC,KAAKC,OAE5BD,KAAKC,OAAS,IAAIC,KACdF,KAAKG,aAAaL,GACXC,EAAeK,MAAMJ,KAAME,GAE1C,CAEUC,YAAAA,CAAa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K0H,sBAAsB0E,KAAKpM,MAE7DA,KAAKqE,WAAcrD,GAASA,EAAMqD,YAAerE,KACjDA,KAAKmJ,UAAYnJ,KAAKgB,MAAMQ,QAAUxB,KAAKgB,MAAMQ,QAAQ2H,eAAYkD,EAErErM,KAAK+C,sBAAsB/C,KAAKgB,OAEhChB,KAAK4I,kBAAoB5I,KAAK4I,kBAAkBwD,KAAKpM,MACrDA,KAAKuH,gBAAkBvH,KAAKuH,gBAAgB6E,KAAKpM,MAEjDA,KAAKH,uBAAuBmB,GAC5BhB,KAAKqB,yBACT,EA1CAuJ,EAbkBjL,EAaKc,YAA2B4L,GAUlDzB,EAvBkBjL,EAuBK2M,aAAuB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../external/preact/dist/preact.js";import{useRef as
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../external/preact/dist/preact.js";import{useRef as n,useState as r}from"../../external/preact/hooks/dist/hooks.js";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c({setComponentRef:c}){const l=n({});Object.keys(l.current).length||null==c||c(l.current);const[u,s]=r(null),a=n(null),i=n(0),[f,p]=r(0);return l.current.setMessages=e=>{const t=a.current;!!(null==e?void 0:e.length)&&(null==t?void 0:t.length)===e.length&&t.every((t,n)=>t===e[n])&&(i.current+=1,p(i.current)),s(e)},a.current=u,u?e(t,null,u.map(t=>e("div",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){o(e,t,n[t])})}return e}({key:`${f}-${t}`,className:"adyen-checkout-sr-panel__msg"},!1),t))):null}export{c as SRMessages};
|
|
2
2
|
//# sourceMappingURL=SRMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SRMessages.js","sources":["../../../../src/core/Errors/SRMessages.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useRef, useState } from 'preact/hooks';\nimport { SRMessagesProps } from './types';\n\n// An interface for the members exposed by SRMessages to its parent\nexport interface SRMessagesRef {\n setMessages?: (
|
|
1
|
+
{"version":3,"file":"SRMessages.js","sources":["../../../../src/core/Errors/SRMessages.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useRef, useState } from 'preact/hooks';\nimport { SRMessagesProps } from './types';\n\n// An interface for the members exposed by SRMessages to its parent\nexport interface SRMessagesRef {\n setMessages?: (messages: string[] | null) => void;\n}\n\nexport function SRMessages({ setComponentRef }: Readonly<SRMessagesProps>) {\n const messagesRef = useRef<SRMessagesRef>({});\n // Just call once to create the object by which we expose the members expected by the parent comp\n if (!Object.keys(messagesRef.current).length) {\n setComponentRef?.(messagesRef.current);\n }\n\n const [messages, setMessages] = useState<string[] | null>(null);\n\n // Pairs with \"never clear\": if the panel is never emptied, re-writing the message that is\n // already displayed would diff to nothing and the AT would stay silent. Bumping the key\n // remounts the nodes so the change is observable.\n //\n // Only bump when the incoming messages are identical to what is rendered, so a partial\n // change (one validation error replaced by another) still diffs granularly and announces\n // just the new entry instead of re-reading the whole list.\n const renderedRef = useRef<string[] | null>(null);\n const versionRef = useRef(0);\n const [version, setVersion] = useState(0);\n\n // Expose method expected by parent\n messagesRef.current.setMessages = (msgs: string[] | null) => {\n const rendered = renderedRef.current;\n const isDuplicate = !!msgs?.length && rendered?.length === msgs.length && rendered.every((m, i) => m === msgs[i]);\n\n if (isDuplicate) {\n versionRef.current += 1;\n setVersion(versionRef.current);\n }\n\n setMessages(msgs);\n };\n\n // Track what is committed to the DOM rather than the latest pending state: a clear followed\n // by a re-set in the same tick batches into one render, which would hide the duplicate.\n renderedRef.current = messages;\n\n return messages ? (\n <Fragment>\n {messages.map(msg => {\n return (\n <div\n key={`${version}-${msg}`}\n className=\"adyen-checkout-sr-panel__msg\"\n {...(process.env.NODE_ENV !== 'production' && { 'data-testid': msg })}\n >\n {msg}\n </div>\n );\n })}\n </Fragment>\n ) : null;\n}\n"],"names":["SRMessages","setComponentRef","messagesRef","useRef","Object","keys","current","length","messages","setMessages","useState","renderedRef","versionRef","version","setVersion","msgs","rendered","every","m","i","h","Fragment","map","msg","div","key","className"],"mappings":"4RASO,SAASA,GAAWC,gBAAEA,IACzB,MAAMC,EAAcC,EAAsB,IAErCC,OAAOC,KAAKH,EAAYI,SAASC,QAClCN,SAAAA,EAAkBC,EAAYI,SAGlC,MAAOE,EAAUC,GAAeC,EAA0B,MASpDC,EAAcR,EAAwB,MACtCS,EAAaT,EAAO,IACnBU,EAASC,GAAcJ,EAAS,GAmBvC,OAhBAR,EAAYI,QAAQG,YAAeM,IAC/B,MAAMC,EAAWL,EAAYL,WACPS,aAAAA,EAAAA,EAAMR,UAAUS,aAAAA,EAAAA,EAAUT,UAAWQ,EAAKR,QAAUS,EAASC,MAAM,CAACC,EAAGC,IAAMD,IAAMH,EAAKI,MAG1GP,EAAWN,SAAW,EACtBQ,EAAWF,EAAWN,UAG1BG,EAAYM,IAKhBJ,EAAYL,QAAUE,EAEfA,EACHY,EAACC,EAAAA,KACIb,EAASc,IAAIC,GAENH,EAACI,wUAAAA,CAAAA,CACGC,IAAK,GAAGZ,KAAWU,IACnBG,UAAU,iCACL,GAEJH,KAKjB,IACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SRPanel.js","sources":["../../../../src/core/Errors/SRPanel.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { AriaAttributes, SRPanelProps } from './types';\nimport BaseElement from '../../components/internal/BaseElement/BaseElement';\nimport { SRMessages, SRMessagesRef } from './SRMessages';\nimport type { ICore } from '../types';\nimport './SRPanel.scss';\n\n/**\n * A panel meant to hold messages that will be read out by ScreenReaders on an aria-live=\"polite\" basis\n * Expects a string or string array of message to add to the panel to be read out\n * For testing purposes can be made visible\n */\nexport class SRPanel extends BaseElement<SRPanelProps> {\n public static readonly type = 'srPanel';\n\n public static readonly defaultProps: Partial<SRPanelProps> = {\n enabled: true,\n node: 'body',\n showPanel: false,\n id: 'ariaLiveSRPanel',\n ariaAttributes: {\n 'aria-relevant': 'all',\n 'aria-live': 'polite',\n 'aria-atomic': 'true'\n }\n };\n\n private readonly srPanelContainer = null;\n\n private readonly id;\n private readonly showPanel;\n private readonly _enabled: boolean;\n private readonly _moveFocus: boolean;\n\n private componentRef: SRMessagesRef;\n\n constructor(checkout: ICore, props?: SRPanelProps) {\n super(checkout, props);\n\n this.id = this.props.id;\n this.showPanel = process.env.NODE_ENV !== 'production' ? this.props.showPanel : false;\n this._enabled = false;\n this._moveFocus = this.props.moveFocus ?? true;\n\n if (this.props.enabled) {\n this._enabled = true;\n\n const panelParent = document.querySelector(this.props.node);\n\n if (panelParent) {\n const preExistingSRPanel = document.getElementById(this.id);\n if (preExistingSRPanel) {\n panelParent.removeChild(preExistingSRPanel);\n }\n\n this.srPanelContainer = document.createElement('div');\n this.srPanelContainer.className = 'sr-panel-holder';\n this.srPanelContainer.id = this.id;\n\n panelParent.appendChild(this.srPanelContainer);\n\n this.mount(this.srPanelContainer);\n } else {\n throw new Error('Component could not mount. Root node was not found.');\n }\n }\n }\n\n public setComponentRef = ref => {\n this.componentRef = ref;\n };\n\n public get enabled() {\n return this._enabled;\n }\n\n public get moveFocus() {\n return this._moveFocus;\n }\n\n public setAriaProps(ariaAttributes: AriaAttributes): void {\n if (!this.props.enabled) return;\n\n const firstPanel = document.querySelector('[class^=\"adyen-checkout-sr-panel\"]');\n\n if (!firstPanel) {\n console.error('SRPanel: Failed to set aria props because no panel was found');\n return;\n }\n\n for (const [key, value] of Object.entries(ariaAttributes)) {\n firstPanel.setAttribute(key, value);\n }\n this.props = { ...this.props, ariaAttributes: { ...this.props.ariaAttributes, ...ariaAttributes } };\n }\n\n // A method we can expose to allow comps to set messages in this panel\n public setMessages = (messages: string[] | string): void => {\n if (!this.props.enabled) return;\n\n let panelMessages = null;\n if (messages) {\n // Ensure panelMessages is an array\n panelMessages = Array.isArray(messages) ? messages : [messages];\n }\n\n this.componentRef.setMessages(panelMessages);\n };\n\n render() {\n if (!this.props.enabled) return null;\n return (\n <div\n className={this.showPanel ? 'adyen-checkout-sr-panel' : 'adyen-checkout-sr-panel--sr-only'}\n role={'log'}\n {...this.props.ariaAttributes}\n {...(process.env.NODE_ENV !== 'production' && { 'data-testid': this.id })}\n >\n <SRMessages setComponentRef={this.setComponentRef} />\n </div>\n );\n }\n}\n"],"names":["SRPanel","BaseElement","enabled","this","_enabled","moveFocus","_moveFocus","setAriaProps","ariaAttributes","props","firstPanel","document","querySelector","key","value","Object","entries","setAttribute","_object_spread_props","_object_spread","console","error","render","h","div","className","showPanel","role","SRMessages","setComponentRef","constructor","checkout","_this_props_moveFocus","super","_define_property","srPanelContainer","id","componentRef","ref","setMessages","messages","panelMessages","Array","isArray","panelParent","node","Error","preExistingSRPanel","getElementById","removeChild","createElement","appendChild","mount","type","defaultProps"],"mappings":"+9BAYO,MAAMA,UAAgBC,EA4DzB,WAAWC,GACP,OAAOC,KAAKC,QAChB,CAEA,aAAWC,GACP,OAAOF,KAAKG,UAChB,CAEOC,YAAAA,CAAaC,GAChB,IAAKL,KAAKM,MAAMP,QAAS,OAEzB,MAAMQ,EAAaC,SAASC,cAAc,sCAE1C,GAAKF,EAAL,CAKA,IAAK,MAAOG,EAAKC,KAAUC,OAAOC,QAAQR,GACtCE,EAAWO,aAAaJ,EAAKC,GAEjCX,KAAKM,MAAQS,EAAAC,EAAA,CAAA,EAAKhB,KAAKM,OAAK,CAAED,eAAgBW,KAAKhB,KAAKM,MAAMD,eAAmBA,IALjF,MAFIY,QAAQC,MAAM,+DAQtB,CAeAC,MAAAA,GACI,OAAKnB,KAAKM,MAAMP,QAEZqB,EAACC,MAAAA,EAAAA,CACGC,UAAWtB,KAAKuB,UAAY,0BAA4B,mCACxDC,KAAM,OACFxB,KAAK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ACT2C,KAAM,OACNnB,WAAW,EACXU,GAAI,kBACJ5B,eAAgB,CACZ,gBAAiB,MACjB,YAAa,SACb,cAAe"}
|
|
1
|
+
{"version":3,"file":"SRPanel.js","sources":["../../../../src/core/Errors/SRPanel.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { AriaAttributes, SRPanelProps } from './types';\nimport BaseElement from '../../components/internal/BaseElement/BaseElement';\nimport { SRMessages, SRMessagesRef } from './SRMessages';\nimport type { ICore } from '../types';\nimport './SRPanel.scss';\n\n/**\n * A panel meant to hold messages that will be read out by ScreenReaders on an aria-live=\"polite\" basis\n * Expects a string or string array of message to add to the panel to be read out\n * For testing purposes can be made visible\n */\nexport class SRPanel extends BaseElement<SRPanelProps> {\n public static readonly type = 'srPanel';\n\n public static readonly defaultProps: Partial<SRPanelProps> = {\n enabled: true,\n node: 'body',\n showPanel: false,\n id: 'ariaLiveSRPanel',\n ariaAttributes: {\n 'aria-relevant': 'all',\n 'aria-live': 'polite',\n 'aria-atomic': 'true'\n }\n };\n\n private readonly srPanelContainer = null;\n\n private readonly id;\n private readonly showPanel;\n private readonly _enabled: boolean;\n private readonly _moveFocus: boolean;\n\n private componentRef: SRMessagesRef;\n\n constructor(checkout: ICore, props?: SRPanelProps) {\n super(checkout, props);\n\n this.id = this.props.id;\n this.showPanel = process.env.NODE_ENV !== 'production' ? this.props.showPanel : false;\n this._enabled = false;\n this._moveFocus = this.props.moveFocus ?? true;\n\n if (this.props.enabled) {\n this._enabled = true;\n\n const panelParent = document.querySelector(this.props.node);\n\n if (panelParent) {\n const preExistingSRPanel = document.getElementById(this.id);\n if (preExistingSRPanel) {\n panelParent.removeChild(preExistingSRPanel);\n }\n\n this.srPanelContainer = document.createElement('div');\n this.srPanelContainer.className = 'sr-panel-holder';\n this.srPanelContainer.id = this.id;\n\n panelParent.appendChild(this.srPanelContainer);\n\n this.mount(this.srPanelContainer);\n } else {\n throw new Error('Component could not mount. Root node was not found.');\n }\n }\n }\n\n public setComponentRef = ref => {\n this.componentRef = ref;\n };\n\n public get enabled() {\n return this._enabled;\n }\n\n public get moveFocus() {\n return this._moveFocus;\n }\n\n public setAriaProps(ariaAttributes: AriaAttributes): void {\n if (!this.props.enabled) return;\n\n const firstPanel = document.querySelector('[class^=\"adyen-checkout-sr-panel\"]');\n\n if (!firstPanel) {\n console.error('SRPanel: Failed to set aria props because no panel was found');\n return;\n }\n\n for (const [key, value] of Object.entries(ariaAttributes)) {\n firstPanel.setAttribute(key, value);\n }\n this.props = { ...this.props, ariaAttributes: { ...this.props.ariaAttributes, ...ariaAttributes } };\n }\n\n // A method we can expose to allow comps to set messages in this panel\n public setMessages = (messages: string[] | string | null): void => {\n if (!this.props.enabled) return;\n\n let panelMessages = null;\n if (messages) {\n // Ensure panelMessages is an array\n panelMessages = Array.isArray(messages) ? messages : [messages];\n }\n\n this.componentRef.setMessages(panelMessages);\n };\n\n render() {\n if (!this.props.enabled) return null;\n return (\n <div\n className={this.showPanel ? 'adyen-checkout-sr-panel' : 'adyen-checkout-sr-panel--sr-only'}\n role={'log'}\n {...this.props.ariaAttributes}\n {...(process.env.NODE_ENV !== 'production' && { 'data-testid': this.id })}\n >\n <SRMessages setComponentRef={this.setComponentRef} />\n </div>\n );\n }\n}\n"],"names":["SRPanel","BaseElement","enabled","this","_enabled","moveFocus","_moveFocus","setAriaProps","ariaAttributes","props","firstPanel","document","querySelector","key","value","Object","entries","setAttribute","_object_spread_props","_object_spread","console","error","render","h","div","className","showPanel","role","SRMessages","setComponentRef","constructor","checkout","_this_props_moveFocus","super","_define_property","srPanelContainer","id","componentRef","ref","setMessages","messages","panelMessages","Array","isArray","panelParent","node","Error","preExistingSRPanel","getElementById","removeChild","createElement","appendChild","mount","type","defaultProps"],"mappings":"+9BAYO,MAAMA,UAAgBC,EA4DzB,WAAWC,GACP,OAAOC,KAAKC,QAChB,CAEA,aAAWC,GACP,OAAOF,KAAKG,UAChB,CAEOC,YAAAA,CAAaC,GAChB,IAAKL,KAAKM,MAAMP,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