@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/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisableOneClickConfirmation.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\n\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { stopPropagationForActionKeys } from '../../../internal/Button/stopPropagationForActionKeys';\nimport './DisableOneClickConfirmation.scss';\n\nconst DisableOneClickConfirmation = ({ id, open, onDisable, onCancel }) => {\n const { i18n } = useCoreContext();\n return (\n <div\n id={id}\n aria-hidden={!open}\n className={classNames({\n 'adyen-checkout__payment-method__disable-confirmation': true,\n 'adyen-checkout__payment-method__disable-confirmation--open': open\n })}\n >\n <div className=\"adyen-checkout__payment-method__disable-confirmation__content\">\n {i18n.get('storedPaymentMethod.disable.confirmation')}\n <div className=\"adyen-checkout__payment-method__disable-confirmation__buttons\">\n <button\n type=\"button\"\n className={classNames(\n 'adyen-checkout__button',\n 'adyen-checkout__payment-method__disable-confirmation__button',\n 'adyen-checkout__payment-method__disable-confirmation__button--remove'\n )}\n disabled={!open}\n onClick={onDisable}\n
|
|
1
|
+
{"version":3,"file":"DisableOneClickConfirmation.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\n\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { stopPropagationForActionKeys } from '../../../internal/Button/stopPropagationForActionKeys';\nimport './DisableOneClickConfirmation.scss';\n\nconst DisableOneClickConfirmation = ({ id, open, onDisable, onCancel }) => {\n const { i18n } = useCoreContext();\n return (\n <div\n id={id}\n aria-hidden={!open}\n className={classNames({\n 'adyen-checkout__payment-method__disable-confirmation': true,\n 'adyen-checkout__payment-method__disable-confirmation--open': open\n })}\n >\n <div className=\"adyen-checkout__payment-method__disable-confirmation__content\">\n {i18n.get('storedPaymentMethod.disable.confirmation')}\n <div className=\"adyen-checkout__payment-method__disable-confirmation__buttons\">\n <button\n type=\"button\"\n className={classNames(\n 'adyen-checkout__button',\n 'adyen-checkout__payment-method__disable-confirmation__button',\n 'adyen-checkout__payment-method__disable-confirmation__button--remove'\n )}\n disabled={!open}\n onClick={onDisable}\n onKeyDown={stopPropagationForActionKeys}\n >\n {i18n.get('storedPaymentMethod.disable.confirmButton')}\n </button>\n <button\n type=\"button\"\n className={classNames(\n 'adyen-checkout__button',\n 'adyen-checkout__payment-method__disable-confirmation__button',\n 'adyen-checkout__payment-method__disable-confirmation__button--cancel'\n )}\n disabled={!open}\n onClick={onCancel}\n onKeyDown={stopPropagationForActionKeys}\n >\n {i18n.get('storedPaymentMethod.disable.cancelButton')}\n </button>\n </div>\n </div>\n </div>\n );\n};\n\nexport default DisableOneClickConfirmation;\n"],"names":["DisableOneClickConfirmation","id","open","onDisable","onCancel","i18n","useCoreContext","h","div","aria-hidden","className","classNames","get","button","type","disabled","onClick","onKeyDown","stopPropagationForActionKeys"],"mappings":"0SAOA,MAAMA,EAA8B,EAAGC,KAAIC,OAAMC,YAAWC,eACxD,MAAMC,KAAEA,GAASC,IACjB,OACIC,EAACC,MAAAA,CACGP,GAAIA,EACJQ,eAAcP,EACdQ,UAAWC,EAAW,CAClB,wDAAwD,EACxD,6DAA8DT,KAGlEK,EAACC,MAAAA,CAAIE,UAAU,iEACVL,EAAKO,IAAI,4CACVL,EAACC,MAAAA,CAAIE,UAAU,iEACXH,EAACM,SAAAA,CACGC,KAAK,SACLJ,UAAWC,EACP,yBACA,+DACA,wEAEJI,UAAWb,EACXc,QAASb,EACTc,UAAWC,GAEVb,EAAKO,IAAI,8CAEdL,EAACM,SAAAA,CACGC,KAAK,SACLJ,UAAWC,EACP,yBACA,+DACA,wEAEJI,UAAWb,EACXc,QAASZ,EACTa,UAAWC,GAEVb,EAAKO,IAAI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"./PaymentMethodIcon.js";import a from"../../../internal/Button/Button.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import r from"../../../../core/Context/useImage.js";import{stopPropagationForActionKeys as n}from"../../../internal/Button/stopPropagationForActionKeys.js";const d=({order:d,orderStatus:m,onOrderCancel:l,brandLogoConfiguration:
|
|
1
|
+
import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"./PaymentMethodIcon.js";import a from"../../../internal/Button/Button.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import r from"../../../../core/Context/useImage.js";import{stopPropagationForActionKeys as n}from"../../../internal/Button/stopPropagationForActionKeys.js";const d=({order:d,orderStatus:m,onOrderCancel:l,brandLogoConfiguration:i})=>{const{i18n:s}=o(),c=r();return e("div",null,e("ul",{className:"adyen-checkout__order-payment-methods-list"},m?.paymentMethods?.map((o,r)=>e("li",{key:`${o.type}-${r}`,className:"adyen-checkout__order-payment-method"},e("div",{className:"adyen-checkout__order-payment-method__header"},e("div",{className:"adyen-checkout__payment-method__header__title",role:"group",id:`order-payment-method-${o.type}-${r}`,"aria-label":o.lastFour?s.get("order.paymentMethod.description",{values:{name:o.name??o.type,lastFour:o.lastFour.toString().split("").join(" ")}}):void 0},e(t,{alt:o.name,type:o.type,src:i[o.type]||c()(o.type)}),o.label?`${o.label}`:`•••• ${o.lastFour}`),l&&e(a,{inline:!0,variant:"link",id:`order-payment-method-remove-${o.type}-${r}`,ariaLabelledBy:o.lastFour?`order-payment-method-${o.type}-${r} order-payment-method-remove-${o.type}-${r}`:void 0,label:s.get("storedPaymentMethod.disable.button"),onKeyDown:n,onClick:()=>{l({order:d})}})),e("div",{className:"adyen-checkout__order-payment-method__details"},e("div",{className:"adyen-checkout__order-payment-method__deducted-amount"},e("span",{className:"adyen-checkout__order-payment-method__deducted-amount__label"},s.get("deductedBalance")),e("span",{className:"adyen-checkout__order-payment-method__deducted-amount__value"},s.amount(o.amount.value,o.amount.currency))))))),m.remainingAmount&&e("p",{className:"adyen-checkout__order-remaining-amount"},s.get("partialPayment.warning")," ",e("strong",null,s.amount(m.remainingAmount.value,m.remainingAmount.currency))))};export{d as OrderPaymentMethods,d as default};
|
|
2
2
|
//# sourceMappingURL=OrderPaymentMethods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/OrderPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodIcon from './PaymentMethodIcon';\nimport Button from '../../../internal/Button';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport './OrderPaymentMethods.scss';\nimport { BrandConfiguration, onOrderCancelInternalCallback, Order, OrderStatus } from '../../../../types';\nimport { stopPropagationForActionKeys } from '../../../internal/Button/stopPropagationForActionKeys';\n\ntype OrderPaymentMethodsProps = {\n order: Order;\n orderStatus: OrderStatus;\n onOrderCancel: onOrderCancelInternalCallback;\n brandLogoConfiguration: BrandConfiguration;\n};\n\nexport const OrderPaymentMethods = ({ order, orderStatus, onOrderCancel, brandLogoConfiguration }: Readonly<OrderPaymentMethodsProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div>\n <ul className={'adyen-checkout__order-payment-methods-list'}>\n {orderStatus?.paymentMethods?.map((orderPaymentMethod, index) => (\n <li key={`${orderPaymentMethod.type}-${index}`} className=\"adyen-checkout__order-payment-method\">\n <div className=\"adyen-checkout__order-payment-method__header\">\n <div\n className=\"adyen-checkout__payment-method__header__title\"\n role=\"group\"\n id={`order-payment-method-${orderPaymentMethod.type}-${index}`}\n aria-label={\n orderPaymentMethod.lastFour\n ? i18n.get('order.paymentMethod.description', {\n values: {\n name: orderPaymentMethod.name ?? orderPaymentMethod.type,\n lastFour: orderPaymentMethod.lastFour.toString().split('').join(' ')\n }\n })\n : undefined\n }\n >\n <PaymentMethodIcon\n alt={orderPaymentMethod.name}\n type={orderPaymentMethod.type}\n src={brandLogoConfiguration[orderPaymentMethod.type] || getImage()(orderPaymentMethod.type)}\n />\n {orderPaymentMethod.label ? `${orderPaymentMethod.label}` : `•••• ${orderPaymentMethod.lastFour}`}\n </div>\n\n {onOrderCancel && (\n <Button\n inline\n variant=\"link\"\n id={`order-payment-method-remove-${orderPaymentMethod.type}-${index}`}\n ariaLabelledBy={\n orderPaymentMethod.lastFour\n ? `order-payment-method-${orderPaymentMethod.type}-${index} order-payment-method-remove-${orderPaymentMethod.type}-${index}`\n : undefined\n }\n label={i18n.get('storedPaymentMethod.disable.button')}\n
|
|
1
|
+
{"version":3,"file":"OrderPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/OrderPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodIcon from './PaymentMethodIcon';\nimport Button from '../../../internal/Button';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport './OrderPaymentMethods.scss';\nimport { BrandConfiguration, onOrderCancelInternalCallback, Order, OrderStatus } from '../../../../types';\nimport { stopPropagationForActionKeys } from '../../../internal/Button/stopPropagationForActionKeys';\n\ntype OrderPaymentMethodsProps = {\n order: Order;\n orderStatus: OrderStatus;\n onOrderCancel: onOrderCancelInternalCallback;\n brandLogoConfiguration: BrandConfiguration;\n};\n\nexport const OrderPaymentMethods = ({ order, orderStatus, onOrderCancel, brandLogoConfiguration }: Readonly<OrderPaymentMethodsProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div>\n <ul className={'adyen-checkout__order-payment-methods-list'}>\n {orderStatus?.paymentMethods?.map((orderPaymentMethod, index) => (\n <li key={`${orderPaymentMethod.type}-${index}`} className=\"adyen-checkout__order-payment-method\">\n <div className=\"adyen-checkout__order-payment-method__header\">\n <div\n className=\"adyen-checkout__payment-method__header__title\"\n role=\"group\"\n id={`order-payment-method-${orderPaymentMethod.type}-${index}`}\n aria-label={\n orderPaymentMethod.lastFour\n ? i18n.get('order.paymentMethod.description', {\n values: {\n name: orderPaymentMethod.name ?? orderPaymentMethod.type,\n lastFour: orderPaymentMethod.lastFour.toString().split('').join(' ')\n }\n })\n : undefined\n }\n >\n <PaymentMethodIcon\n alt={orderPaymentMethod.name}\n type={orderPaymentMethod.type}\n src={brandLogoConfiguration[orderPaymentMethod.type] || getImage()(orderPaymentMethod.type)}\n />\n {orderPaymentMethod.label ? `${orderPaymentMethod.label}` : `•••• ${orderPaymentMethod.lastFour}`}\n </div>\n\n {onOrderCancel && (\n <Button\n inline\n variant=\"link\"\n id={`order-payment-method-remove-${orderPaymentMethod.type}-${index}`}\n ariaLabelledBy={\n orderPaymentMethod.lastFour\n ? `order-payment-method-${orderPaymentMethod.type}-${index} order-payment-method-remove-${orderPaymentMethod.type}-${index}`\n : undefined\n }\n label={i18n.get('storedPaymentMethod.disable.button')}\n onKeyDown={stopPropagationForActionKeys}\n onClick={() => {\n onOrderCancel({ order });\n }}\n />\n )}\n </div>\n <div className=\"adyen-checkout__order-payment-method__details\">\n <div className=\"adyen-checkout__order-payment-method__deducted-amount\">\n <span className=\"adyen-checkout__order-payment-method__deducted-amount__label\">{i18n.get('deductedBalance')}</span>\n <span className=\"adyen-checkout__order-payment-method__deducted-amount__value\">\n {i18n.amount(orderPaymentMethod.amount.value, orderPaymentMethod.amount.currency)}\n </span>\n </div>\n </div>\n </li>\n ))}\n </ul>\n\n {orderStatus.remainingAmount && (\n <p className=\"adyen-checkout__order-remaining-amount\">\n {i18n.get('partialPayment.warning')}{' '}\n <strong>{i18n.amount(orderStatus.remainingAmount.value, orderStatus.remainingAmount.currency)}</strong>\n </p>\n )}\n </div>\n );\n};\n\nexport default OrderPaymentMethods;\n"],"names":["OrderPaymentMethods","order","orderStatus","onOrderCancel","brandLogoConfiguration","i18n","useCoreContext","getImage","useImage","h","div","ul","className","paymentMethods","map","orderPaymentMethod","index","li","key","type","role","id","aria-label","lastFour","get","values","name","toString","split","join","undefined","PaymentMethodIcon","alt","src","label","Button","inline","variant","ariaLabelledBy","onKeyDown","stopPropagationForActionKeys","onClick","span","amount","value","currency","remainingAmount","p","strong"],"mappings":"yYAgBO,MAAMA,EAAsB,EAAGC,QAAOC,cAAaC,gBAAeC,6BACrE,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,WACGD,EAACE,KAAAA,CAAGC,UAAW,8CACVV,GAAaW,gBAAgBC,IAAI,CAACC,EAAoBC,IACnDP,EAACQ,KAAAA,CAAGC,IAAK,GAAGH,EAAmBI,QAAQH,IAASJ,UAAU,wCACtDH,EAACC,MAAAA,CAAIE,UAAU,gDACXH,EAACC,MAAAA,CACGE,UAAU,gDACVQ,KAAK,QACLC,GAAI,wBAAwBN,EAAmBI,QAAQH,IACvDM,aACIP,EAAmBQ,SACblB,EAAKmB,IAAI,kCAAmC,CACxCC,OAAQ,CACJC,KAAMX,EAAmBW,MAAQX,EAAmBI,KACpDI,SAAUR,EAAmBQ,SAASI,WAAWC,MAAM,IAAIC,KAAK,aAGxEC,GAGVrB,EAACsB,EAAAA,CACGC,IAAKjB,EAAmBW,KACxBP,KAAMJ,EAAmBI,KACzBc,IAAK7B,EAAuBW,EAAmBI,OAASZ,IAAWQ,EAAmBI,QAEzFJ,EAAmBmB,MAAQ,GAAGnB,EAAmBmB,QAAU,QAAQnB,EAAmBQ,YAG1FpB,GACGM,EAAC0B,EAAAA,CACGC,QAAAA,EACAC,QAAQ,OACRhB,GAAI,+BAA+BN,EAAmBI,QAAQH,IAC9DsB,eACIvB,EAAmBQ,SACb,wBAAwBR,EAAmBI,QAAQH,iCAAqCD,EAAmBI,QAAQH,SACnHc,EAEVI,MAAO7B,EAAKmB,IAAI,sCAChBe,UAAWC,EACXC,QAAS,KACLtC,EAAc,CAAEF,cAKhCQ,EAACC,MAAAA,CAAIE,UAAU,iDACXH,EAACC,MAAAA,CAAIE,UAAU,yDACXH,EAACiC,OAAAA,CAAK9B,UAAU,gEAAgEP,EAAKmB,IAAI,oBACzFf,EAACiC,OAAAA,CAAK9B,UAAU,gEACXP,EAAKsC,OAAO5B,EAAmB4B,OAAOC,MAAO7B,EAAmB4B,OAAOE,gBAQ/F3C,EAAY4C,iBACTrC,EAACsC,IAAAA,CAAEnC,UAAU,0CACRP,EAAKmB,IAAI,0BAA2B,IACrCf,EAACuC,cAAQ3C,EAAKsC,OAAOzC,EAAY4C,gBAAgBF,MAAO1C,EAAY4C,gBAAgBD"}
|
package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as e,createElement as t}from"../../../../../external/preact/dist/preact.js";import o from"../../../../../_virtual/index.js";import{PaymentMethodDetails as n}from"../PaymentMethodDetails.js";import a from"../PaymentMethodIcon.js";import i from"../DisableOneClickConfirmation.js";import s from"../PaymentMethodBrands/PaymentMethodBrands.js";import{BRAND_ICON_UI_EXCLUSION_LIST as d}from"../../../../internal/SecuredFields/lib/constants.js";import r from"../PaymentMethodName.js";import{useCoreContext as m}from"../../../../../core/Context/CoreProvider.js";import h from"../../../../internal/ExpandButton/ExpandButton.js";import{getFullBrandName as l}from"../../../../Card/components/CardInput/utils.js";import{stopPropagationForActionKeys as p}from"../../../../internal/Button/stopPropagationForActionKeys.js";import c from"../../../../internal/Button/Button.js";function y(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class u extends e{render({paymentMethod:e,isSelected:y,isDisablingPaymentMethod:u,isLoading:_,standalone:f,showRadioButton:b}){const{i18n:C}=m();if(!e)return null;const k="card"===e.props.type||"scheme"===e.props.type,M=o({"adyen-checkout__payment-method":!0,[`adyen-checkout__payment-method--${e.props.type}`]:!0,...k&&{[`adyen-checkout__payment-method--${e.props.fundingSource??"credit"}`]:!0},"adyen-checkout__payment-method--selected":y,"adyen-checkout__payment-method--loading":_,"adyen-checkout__payment-method--disabling":u,"adyen-checkout__payment-method--confirming":this.state.showDisableStoredPaymentMethodConfirmation,"adyen-checkout__payment-method--standalone":f,[e._id]:!0,[this.props.className]:!0}),P=this.props.showRemovePaymentMethodButton&&e.props.oneClick&&y,S=`remove-${e._id}`,g=`container-${e._id}`,D=`button-${e._id}`,w=!e.props.oneClick&&e.brands&&e.brands.length>0;return t("div",{key:e._id,className:M,onClick:this.handleOnListItemClick},t("div",{className:"adyen-checkout__payment-method__header"},t(h,{className:"adyen-checkout__payment-method__header__content",buttonId:D,showRadioButton:b,isSelected:y,expandContentId:g,standalone:f},t(a,{...e.props.oneClick&&{alt:l(e.props.brand)},type:e.type,src:e.icon}),t("div",{className:"adyen-checkout__payment-method__header__details"},t(r,{displayName:e.displayName,isSelected:y,additionalInfo:e.additionalInfo}),w&&t(s,{showOtherInsteadOfNumber:e.props.showOtherInsteadOfNumber,keepBrandsVisible:e.props.keepBrandsVisible,brands:e.brands,excludedUIBrands:d,isPaymentMethodSelected:y}))),P&&t(c,{inline:!0,variant:"link",onClick:this.toggleDisableConfirmation,
|
|
1
|
+
import{Component as e,createElement as t}from"../../../../../external/preact/dist/preact.js";import o from"../../../../../_virtual/index.js";import{PaymentMethodDetails as n}from"../PaymentMethodDetails.js";import a from"../PaymentMethodIcon.js";import i from"../DisableOneClickConfirmation.js";import s from"../PaymentMethodBrands/PaymentMethodBrands.js";import{BRAND_ICON_UI_EXCLUSION_LIST as d}from"../../../../internal/SecuredFields/lib/constants.js";import r from"../PaymentMethodName.js";import{useCoreContext as m}from"../../../../../core/Context/CoreProvider.js";import h from"../../../../internal/ExpandButton/ExpandButton.js";import{getFullBrandName as l}from"../../../../Card/components/CardInput/utils.js";import{stopPropagationForActionKeys as p}from"../../../../internal/Button/stopPropagationForActionKeys.js";import c from"../../../../internal/Button/Button.js";function y(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class u extends e{render({paymentMethod:e,isSelected:y,isDisablingPaymentMethod:u,isLoading:_,standalone:f,showRadioButton:b}){const{i18n:C}=m();if(!e)return null;const k="card"===e.props.type||"scheme"===e.props.type,M=o({"adyen-checkout__payment-method":!0,[`adyen-checkout__payment-method--${e.props.type}`]:!0,...k&&{[`adyen-checkout__payment-method--${e.props.fundingSource??"credit"}`]:!0},"adyen-checkout__payment-method--selected":y,"adyen-checkout__payment-method--loading":_,"adyen-checkout__payment-method--disabling":u,"adyen-checkout__payment-method--confirming":this.state.showDisableStoredPaymentMethodConfirmation,"adyen-checkout__payment-method--standalone":f,[e._id]:!0,[this.props.className]:!0}),P=this.props.showRemovePaymentMethodButton&&e.props.oneClick&&y,S=`remove-${e._id}`,g=`container-${e._id}`,D=`button-${e._id}`,w=!e.props.oneClick&&e.brands&&e.brands.length>0;return t("div",{key:e._id,className:M,onClick:this.handleOnListItemClick},t("div",{className:"adyen-checkout__payment-method__header"},t(h,{className:"adyen-checkout__payment-method__header__content",buttonId:D,showRadioButton:b,isSelected:y,expandContentId:g,standalone:f},t(a,{...e.props.oneClick&&{alt:l(e.props.brand)},type:e.type,src:e.icon}),t("div",{className:"adyen-checkout__payment-method__header__details"},t(r,{displayName:e.displayName,isSelected:y,additionalInfo:e.additionalInfo}),w&&t(s,{showOtherInsteadOfNumber:e.props.showOtherInsteadOfNumber,keepBrandsVisible:e.props.keepBrandsVisible,brands:e.brands,excludedUIBrands:d,isPaymentMethodSelected:y}))),P&&t(c,{inline:!0,variant:"link",onClick:this.toggleDisableConfirmation,onKeyDown:p,ariaExpanded:this.state.showDisableStoredPaymentMethodConfirmation,ariaControls:S},C.get("storedPaymentMethod.disable.button"))),t("div",{className:"adyen-checkout-pm-details-wrapper","aria-hidden":!y},t("div",{className:"adyen-checkout__payment-method__details",id:g,inert:!y||void 0},P&&t(i,{id:S,open:this.state.showDisableStoredPaymentMethodConfirmation,onDisable:this.onDisableStoredPaymentMethod,onCancel:this.toggleDisableConfirmation}),t(n,{paymentMethodComponent:e,isSelected:y}))))}constructor(...e){super(...e),y(this,"state",{showDisableStoredPaymentMethodConfirmation:!1}),y(this,"toggleDisableConfirmation",()=>{this.setState({showDisableStoredPaymentMethodConfirmation:!this.state.showDisableStoredPaymentMethodConfirmation})}),y(this,"onDisableStoredPaymentMethod",()=>{this.props.onDisableStoredPaymentMethod(this.props.paymentMethod),this.toggleDisableConfirmation()}),y(this,"handleOnListItemClick",()=>{const{onSelect:e,paymentMethod:t}=this.props;e(t)})}}y(u,"defaultProps",{paymentMethod:null,isSelected:!1,isLoaded:!1,isLoading:!1,showDisableStoredPaymentMethodConfirmation:!1,showRadioButton:!1});export{u as default};
|
|
2
2
|
//# sourceMappingURL=PaymentMethodItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentMethodItem.js","sources":["../../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\n\nimport { PaymentMethodDetails } from '../PaymentMethodDetails';\nimport PaymentMethodIcon from '../PaymentMethodIcon';\nimport DisableOneClickConfirmation from '../DisableOneClickConfirmation';\nimport UIElement from '../../../../internal/UIElement/UIElement';\nimport PaymentMethodBrands from '../PaymentMethodBrands/PaymentMethodBrands';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../../../../internal/SecuredFields/lib/constants';\nimport PaymentMethodName from '../PaymentMethodName';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport ExpandButton from '../../../../internal/ExpandButton';\nimport { getFullBrandName } from '../../../../Card/components/CardInput/utils';\nimport { stopPropagationForActionKeys } from '../../../../internal/Button/stopPropagationForActionKeys';\nimport './PaymentMethodItem.scss';\nimport Button from '../../../../internal/Button';\n\nexport interface PaymentMethodItemProps {\n paymentMethod: UIElement;\n isSelected?: boolean;\n isLoading?: boolean;\n isDisablingPaymentMethod: boolean;\n showRemovePaymentMethodButton: boolean;\n onDisableStoredPaymentMethod: (paymentMethod) => void;\n onSelect: (paymentMethod: UIElement) => void;\n standalone: boolean;\n className?: string;\n showRadioButton?: boolean;\n}\n\nclass PaymentMethodItem extends Component<Readonly<PaymentMethodItemProps>> {\n public static readonly defaultProps = {\n paymentMethod: null,\n isSelected: false,\n isLoaded: false,\n isLoading: false,\n showDisableStoredPaymentMethodConfirmation: false,\n showRadioButton: false\n };\n\n public state = {\n showDisableStoredPaymentMethodConfirmation: false\n };\n\n public toggleDisableConfirmation = () => {\n this.setState({ showDisableStoredPaymentMethodConfirmation: !this.state.showDisableStoredPaymentMethodConfirmation });\n };\n\n public onDisableStoredPaymentMethod = () => {\n this.props.onDisableStoredPaymentMethod(this.props.paymentMethod);\n this.toggleDisableConfirmation();\n };\n\n private readonly handleOnListItemClick = (): void => {\n const { onSelect, paymentMethod } = this.props;\n onSelect(paymentMethod);\n };\n\n // @ts-ignore need to refine the type for paymentMethod\n render({ paymentMethod, isSelected, isDisablingPaymentMethod, isLoading, standalone, showRadioButton }) {\n const { i18n } = useCoreContext();\n\n if (!paymentMethod) {\n return null;\n }\n\n const isCard = paymentMethod.props.type === 'card' || paymentMethod.props.type === 'scheme';\n\n const paymentMethodClassnames = classNames({\n 'adyen-checkout__payment-method': true,\n [`adyen-checkout__payment-method--${paymentMethod.props.type}`]: true,\n ...(isCard && { [`adyen-checkout__payment-method--${paymentMethod.props.fundingSource ?? 'credit'}`]: true }),\n 'adyen-checkout__payment-method--selected': isSelected,\n 'adyen-checkout__payment-method--loading': isLoading,\n 'adyen-checkout__payment-method--disabling': isDisablingPaymentMethod,\n 'adyen-checkout__payment-method--confirming': this.state.showDisableStoredPaymentMethodConfirmation,\n 'adyen-checkout__payment-method--standalone': standalone,\n [paymentMethod._id]: true,\n [this.props.className]: true\n });\n\n const showRemovePaymentMethodButton = this.props.showRemovePaymentMethodButton && paymentMethod.props.oneClick && isSelected;\n const disableConfirmationId = `remove-${paymentMethod._id}`;\n const containerId = `container-${paymentMethod._id}`;\n const buttonId = `button-${paymentMethod._id}`;\n\n const showBrands = !paymentMethod.props.oneClick && paymentMethod.brands && paymentMethod.brands.length > 0;\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions\n <div key={paymentMethod._id} className={paymentMethodClassnames} onClick={this.handleOnListItemClick}>\n <div className=\"adyen-checkout__payment-method__header\">\n <ExpandButton\n className=\"adyen-checkout__payment-method__header__content\"\n buttonId={buttonId}\n showRadioButton={showRadioButton}\n isSelected={isSelected}\n expandContentId={containerId}\n standalone={standalone}\n >\n <PaymentMethodIcon\n // Only add alt attribute to storedPaymentMethods (to avoid SR reading the PM name twice)\n {...(paymentMethod.props.oneClick && { alt: getFullBrandName(paymentMethod.props.brand) })}\n type={paymentMethod.type}\n src={paymentMethod.icon}\n />\n\n <div className=\"adyen-checkout__payment-method__header__details\">\n <PaymentMethodName\n displayName={paymentMethod.displayName}\n isSelected={isSelected}\n additionalInfo={paymentMethod.additionalInfo}\n />\n {showBrands && (\n <PaymentMethodBrands\n showOtherInsteadOfNumber={paymentMethod.props.showOtherInsteadOfNumber}\n keepBrandsVisible={paymentMethod.props.keepBrandsVisible}\n brands={paymentMethod.brands}\n excludedUIBrands={BRAND_ICON_UI_EXCLUSION_LIST}\n isPaymentMethodSelected={isSelected}\n />\n )}\n </div>\n </ExpandButton>\n\n {showRemovePaymentMethodButton && (\n <Button\n inline\n variant=\"link\"\n onClick={this.toggleDisableConfirmation}\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n ariaExpanded={this.state.showDisableStoredPaymentMethodConfirmation}\n ariaControls={disableConfirmationId}\n >\n {i18n.get('storedPaymentMethod.disable.button')}\n </Button>\n )}\n </div>\n\n <div className=\"adyen-checkout-pm-details-wrapper\" aria-hidden={!isSelected}>\n <div className=\"adyen-checkout__payment-method__details\" id={containerId} inert={isSelected ? undefined : true}>\n {showRemovePaymentMethodButton && (\n <DisableOneClickConfirmation\n id={disableConfirmationId}\n open={this.state.showDisableStoredPaymentMethodConfirmation}\n onDisable={this.onDisableStoredPaymentMethod}\n onCancel={this.toggleDisableConfirmation}\n />\n )}\n\n <PaymentMethodDetails paymentMethodComponent={paymentMethod} isSelected={isSelected} />\n </div>\n </div>\n </div>\n );\n }\n}\n\nexport default PaymentMethodItem;\n"],"names":["PaymentMethodItem","Component","render","paymentMethod","isSelected","isDisablingPaymentMethod","isLoading","standalone","showRadioButton","i18n","useCoreContext","isCard","props","type","paymentMethodClassnames","classNames","fundingSource","this","state","showDisableStoredPaymentMethodConfirmation","_id","className","showRemovePaymentMethodButton","oneClick","disableConfirmationId","containerId","buttonId","showBrands","brands","length","h","div","key","onClick","handleOnListItemClick","ExpandButton","expandContentId","PaymentMethodIcon","alt","getFullBrandName","brand","src","icon","PaymentMethodName","displayName","additionalInfo","PaymentMethodBrands","showOtherInsteadOfNumber","keepBrandsVisible","excludedUIBrands","BRAND_ICON_UI_EXCLUSION_LIST","isPaymentMethodSelected","Button","inline","variant","toggleDisableConfirmation","onKeyPress","stopPropagationForActionKeys","onKeyDown","ariaExpanded","ariaControls","get","aria-hidden","id","inert","undefined","DisableOneClickConfirmation","open","onDisable","onDisableStoredPaymentMethod","onCancel","PaymentMethodDetails","paymentMethodComponent","super","args","_define_property","setState","onSelect","defaultProps","isLoaded"],"mappings":"s+BA8BA,MAAMA,UAA0BC,EA6B5BC,MAAAA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,yBAAEA,EAAwBC,UAAEA,EAASC,WAAEA,EAAUC,gBAAEA,IACjF,MAAMC,KAAEA,GAASC,IAEjB,IAAKP,EACD,OAAO,KAGX,MAAMQ,EAAsC,SAA7BR,EAAcS,MAAMC,MAAgD,WAA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EAACsB,EAAAA,CACGC,QAAAA,EACAC,QAAQ,OACRrB,QAAShB,KAAKsC,0BACdC,WAAYC,EACZC,UAAWD,EACXE,aAAc1C,KAAKC,MAAMC,2CACzByC,aAAcpC,GAEbf,EAAKoD,IAAI,wCAKtB/B,EAACC,MAAAA,CAAIV,UAAU,oCAAoCyC,eAAc1D,GAC7D0B,EAACC,MAAAA,CAAIV,UAAU,0CAA0C0C,GAAItC,EAAauC,OAAO5D,QAAa6D,GACzF3C,GACGQ,EAACoC,EAAAA,CACGH,GAAIvC,EACJ2C,KAAMlD,KAAKC,MAAMC,2CACjBiD,UAAWnD,KAAKoD,6BAChBC,SAAUrD,KAAKsC,4BAIvBzB,EAACyC,EAAAA,CAAqBC,uBAAwBrE,EAAeC,WAAYA,MAK7F,mBA9HJqE,SAAAC,GAUIC,OAAOzD,QAAQ,CACXC,4CAA4C,IAGhDwD,OAAOpB,4BAA4B,KAC/BtC,KAAK2D,SAAS,CAAEzD,4CAA6CF,KAAKC,MAAMC,+CAG5EwD,OAAON,+BAA+B,KAClCpD,KAAKL,MAAMyD,6BAA6BpD,KAAKL,MAAMT,eACnDc,KAAKsC,8BAGToB,OAAiBzC,wBAAwB,KACrC,MAAM2C,SAAEA,EAAQ1E,cAAEA,GAAkBc,KAAKL,MACzCiE,EAAS1E,MAxBbwE,EADE3E,EACqB8E,eAAe,CAClC3E,cAAe,KACfC,YAAY,EACZ2E,UAAU,EACVzE,WAAW,EACXa,4CAA4C,EAC5CX,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"PaymentMethodItem.js","sources":["../../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\n\nimport { PaymentMethodDetails } from '../PaymentMethodDetails';\nimport PaymentMethodIcon from '../PaymentMethodIcon';\nimport DisableOneClickConfirmation from '../DisableOneClickConfirmation';\nimport UIElement from '../../../../internal/UIElement/UIElement';\nimport PaymentMethodBrands from '../PaymentMethodBrands/PaymentMethodBrands';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../../../../internal/SecuredFields/lib/constants';\nimport PaymentMethodName from '../PaymentMethodName';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport ExpandButton from '../../../../internal/ExpandButton';\nimport { getFullBrandName } from '../../../../Card/components/CardInput/utils';\nimport { stopPropagationForActionKeys } from '../../../../internal/Button/stopPropagationForActionKeys';\nimport './PaymentMethodItem.scss';\nimport Button from '../../../../internal/Button';\n\nexport interface PaymentMethodItemProps {\n paymentMethod: UIElement;\n isSelected?: boolean;\n isLoading?: boolean;\n isDisablingPaymentMethod: boolean;\n showRemovePaymentMethodButton: boolean;\n onDisableStoredPaymentMethod: (paymentMethod) => void;\n onSelect: (paymentMethod: UIElement) => void;\n standalone: boolean;\n className?: string;\n showRadioButton?: boolean;\n}\n\nclass PaymentMethodItem extends Component<Readonly<PaymentMethodItemProps>> {\n public static readonly defaultProps = {\n paymentMethod: null,\n isSelected: false,\n isLoaded: false,\n isLoading: false,\n showDisableStoredPaymentMethodConfirmation: false,\n showRadioButton: false\n };\n\n public state = {\n showDisableStoredPaymentMethodConfirmation: false\n };\n\n public toggleDisableConfirmation = () => {\n this.setState({ showDisableStoredPaymentMethodConfirmation: !this.state.showDisableStoredPaymentMethodConfirmation });\n };\n\n public onDisableStoredPaymentMethod = () => {\n this.props.onDisableStoredPaymentMethod(this.props.paymentMethod);\n this.toggleDisableConfirmation();\n };\n\n private readonly handleOnListItemClick = (): void => {\n const { onSelect, paymentMethod } = this.props;\n onSelect(paymentMethod);\n };\n\n // @ts-ignore need to refine the type for paymentMethod\n render({ paymentMethod, isSelected, isDisablingPaymentMethod, isLoading, standalone, showRadioButton }) {\n const { i18n } = useCoreContext();\n\n if (!paymentMethod) {\n return null;\n }\n\n const isCard = paymentMethod.props.type === 'card' || paymentMethod.props.type === 'scheme';\n\n const paymentMethodClassnames = classNames({\n 'adyen-checkout__payment-method': true,\n [`adyen-checkout__payment-method--${paymentMethod.props.type}`]: true,\n ...(isCard && { [`adyen-checkout__payment-method--${paymentMethod.props.fundingSource ?? 'credit'}`]: true }),\n 'adyen-checkout__payment-method--selected': isSelected,\n 'adyen-checkout__payment-method--loading': isLoading,\n 'adyen-checkout__payment-method--disabling': isDisablingPaymentMethod,\n 'adyen-checkout__payment-method--confirming': this.state.showDisableStoredPaymentMethodConfirmation,\n 'adyen-checkout__payment-method--standalone': standalone,\n [paymentMethod._id]: true,\n [this.props.className]: true\n });\n\n const showRemovePaymentMethodButton = this.props.showRemovePaymentMethodButton && paymentMethod.props.oneClick && isSelected;\n const disableConfirmationId = `remove-${paymentMethod._id}`;\n const containerId = `container-${paymentMethod._id}`;\n const buttonId = `button-${paymentMethod._id}`;\n\n const showBrands = !paymentMethod.props.oneClick && paymentMethod.brands && paymentMethod.brands.length > 0;\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions\n <div key={paymentMethod._id} className={paymentMethodClassnames} onClick={this.handleOnListItemClick}>\n <div className=\"adyen-checkout__payment-method__header\">\n <ExpandButton\n className=\"adyen-checkout__payment-method__header__content\"\n buttonId={buttonId}\n showRadioButton={showRadioButton}\n isSelected={isSelected}\n expandContentId={containerId}\n standalone={standalone}\n >\n <PaymentMethodIcon\n // Only add alt attribute to storedPaymentMethods (to avoid SR reading the PM name twice)\n {...(paymentMethod.props.oneClick && { alt: getFullBrandName(paymentMethod.props.brand) })}\n type={paymentMethod.type}\n src={paymentMethod.icon}\n />\n\n <div className=\"adyen-checkout__payment-method__header__details\">\n <PaymentMethodName\n displayName={paymentMethod.displayName}\n isSelected={isSelected}\n additionalInfo={paymentMethod.additionalInfo}\n />\n {showBrands && (\n <PaymentMethodBrands\n showOtherInsteadOfNumber={paymentMethod.props.showOtherInsteadOfNumber}\n keepBrandsVisible={paymentMethod.props.keepBrandsVisible}\n brands={paymentMethod.brands}\n excludedUIBrands={BRAND_ICON_UI_EXCLUSION_LIST}\n isPaymentMethodSelected={isSelected}\n />\n )}\n </div>\n </ExpandButton>\n\n {showRemovePaymentMethodButton && (\n <Button\n inline\n variant=\"link\"\n onClick={this.toggleDisableConfirmation}\n onKeyDown={stopPropagationForActionKeys}\n ariaExpanded={this.state.showDisableStoredPaymentMethodConfirmation}\n ariaControls={disableConfirmationId}\n >\n {i18n.get('storedPaymentMethod.disable.button')}\n </Button>\n )}\n </div>\n\n <div className=\"adyen-checkout-pm-details-wrapper\" aria-hidden={!isSelected}>\n <div className=\"adyen-checkout__payment-method__details\" id={containerId} inert={isSelected ? undefined : true}>\n {showRemovePaymentMethodButton && (\n <DisableOneClickConfirmation\n id={disableConfirmationId}\n open={this.state.showDisableStoredPaymentMethodConfirmation}\n onDisable={this.onDisableStoredPaymentMethod}\n onCancel={this.toggleDisableConfirmation}\n />\n )}\n\n <PaymentMethodDetails paymentMethodComponent={paymentMethod} isSelected={isSelected} />\n </div>\n </div>\n </div>\n );\n }\n}\n\nexport default PaymentMethodItem;\n"],"names":["PaymentMethodItem","Component","render","paymentMethod","isSelected","isDisablingPaymentMethod","isLoading","standalone","showRadioButton","i18n","useCoreContext","isCard","props","type","paymentMethodClassnames","classNames","fundingSource","this","state","showDisableStoredPaymentMethodConfirmation","_id","className","showRemovePaymentMethodButton","oneClick","disableConfirmationId","containerId","buttonId","showBrands","brands","length","h","div","key","onClick","handleOnListItemClick","ExpandButton","expandContentId","PaymentMethodIcon","alt","getFullBrandName","brand","src","icon","PaymentMethodName","displayName","additionalInfo","PaymentMethodBrands","showOtherInsteadOfNumber","keepBrandsVisible","excludedUIBrands","BRAND_ICON_UI_EXCLUSION_LIST","isPaymentMethodSelected","Button","inline","variant","toggleDisableConfirmation","onKeyDown","stopPropagationForActionKeys","ariaExpanded","ariaControls","get","aria-hidden","id","inert","undefined","DisableOneClickConfirmation","open","onDisable","onDisableStoredPaymentMethod","onCancel","PaymentMethodDetails","paymentMethodComponent","super","args","_define_property","setState","onSelect","defaultProps","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preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import
|
|
1
|
+
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import n from"../internal/PayButton/PayButton.js";import s from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as o}from"../tx-variants.js";function a(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class i extends e{formatProps(t){return{...t?.configuration,...t}}formatData(){return{paymentMethod:{type:this.constructor.type,brand:this.props.brand,encryptedCardNumber:this.state.data?.encryptedCardNumber,encryptedSecurityCode:this.state.data?.encryptedSecurityCode}}}get isValid(){return!!this.state.isValid}get icon(){return this.props.brandsConfiguration[this.props.brand]?.icon||this.props.icon||this.resources.getImage()(this.props.brand)}get displayName(){return this.props.brandsConfiguration[this.props.brand]?.name||this.props.name}setBalanceCheckError(t){this.componentRef?.setBalanceCheckErrors?.(t)}balanceCheck(){return this.onBalanceCheck()}submit(){this.balanceCheck()}makeSubmitCall(){super.submit()}componentToRender(){return t(r,{ref:t=>{this.componentRef=t},...this.props,handleKeyDown:this.handleKeyDown,showPayButton:this.props.showPayButton,onChange:this.setState,makeBalanceCheck:()=>this.onBalanceCheck(),makePayment:()=>this.makeSubmitCall(),payButton:this.payButton,onSubmitAnalytics:this.submitAnalytics})}constructor(...e){super(...e),a(this,"componentRef",void 0),a(this,"handleBalanceCheck",t=>this.props.onBalanceCheck?new Promise((e,r)=>{this.props.onBalanceCheck(e,r,t)}):this.props.session?this.props.session.checkBalance(t):void 0),a(this,"onOrderRequest",t=>this.props.onOrderRequest?new Promise((e,r)=>{this.props.onOrderRequest(e,r,t)}):this.props.session?this.props.session.createOrder():void 0),a(this,"onBalanceCheck",()=>{if(!this.isValid)return void this.showValidation();if(!(this.props.session||this.props.onBalanceCheck))return super.submit();this.setStatus("loading"),this.handleBalanceCheck(this.formatData()).then(({balance:t,transactionLimit:e={}})=>{if(this.setBalanceCheckError(null),!t)throw new Error("card-error");if(t?.currency!==this.props.amount?.currency)throw new Error("currency-error");if(t?.value<=0)throw new Error("no-balance");return this.props.amount.value>t.value||this.props.amount.value>e.value?this.props.order?this.makeSubmitCall():this.onOrderRequest(this.data).then(t=>(this.setState({order:{orderData:t.orderData,pspReference:t.pspReference}}),this.makeSubmitCall())):this.handleOnRequiringConfirmation(t,e)}).catch(t=>{this.setBalanceCheckError(t?.message),t instanceof s?this.handleError(t):this.handleError(new s("ERROR",t))})}),a(this,"handleOnRequiringConfirmation",(t,e)=>{if(this.componentRef.setBalance({balance:t,transactionLimit:e}),this.setStatus("ready"),!this.props.showPayButton){if(!this.props.onRequiringConfirmation)throw new s("IMPLEMENTATION_ERROR","onRequiringConfirmation must be provided");return new Promise((t,e)=>{this.props.onRequiringConfirmation(t,e)}).then(()=>this.makeSubmitCall()).catch(()=>{})}}),a(this,"payButton",e=>t(n,e))}}a(i,"type",o.giftcard),a(i,"defaultProps",{brandsConfiguration:{}});export{i as GiftcardElement,i as default};
|
|
2
2
|
//# sourceMappingURL=Giftcard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static readonly type: TxVariants = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static readonly defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance: PaymentAmount, transactionLimit: PaymentAmount): Promise<void> | void => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n protected override payButton = (props: PayButtonProps) => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyPress={this.handleKeyPress}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","configuration","formatData","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","componentRef","setBalanceCheckErrors","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyPress","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","onSubmitAnalytics","submitAnalytics","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"qcAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,MAAO,IACAA,GAAOC,iBACPD,EAEX,CAEAE,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKL,MAAMO,MAClBC,oBAAqBH,KAAKI,MAAMC,MAAMF,oBACtCG,sBAAuBN,KAAKI,MAAMC,MAAMC,uBAGpD,CAEA,WAAIC,GACA,QAASP,KAAKI,MAAMG,OACxB,CAEA,QAAIC,GACA,OAAOR,KAAKL,MAAMc,oBAAoBT,KAAKL,MAAMO,QAAQM,MAAQR,KAAKL,MAAMa,MAAQR,KAAKU,UAAUC,UAAfX,CAA0BA,KAAKL,MAAMO,MAC7H,CAEA,eAAIU,GACA,OAAOZ,KAAKL,MAAMc,oBAAoBT,KAAKL,MAAMO,QAAQW,MAAQb,KAAKL,MAAMkB,IAChF,CAEQC,oBAAAA,CAAqBC,G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G,WAAapD,KAAKL,MAAM0D,QAAQD,SAAU,MAAM,IAAID,MAAM,kBACvE,GAAIF,GAASK,OAAS,EAAG,MAAM,IAAIH,MAAM,cAEzC,OAAInD,KAAKL,MAAM0D,OAAOC,MAAQL,EAAQK,OAAStD,KAAKL,MAAM0D,OAAOC,MAAQJ,EAAiBI,MAClFtD,KAAKL,MAAM4D,MACJvD,KAAKqB,iBAGTrB,KAAK4C,eAAe5C,KAAKK,MAAM2C,KAAMO,IACxCvD,KAAK8B,SAAS,CAAEyB,MAAO,CAAEC,UAAWD,EAAMC,UAAWC,aAAcF,EAAME,gBAClEzD,KAAKqB,mBAGTrB,KAAK0D,8BAA8BT,EAASC,KAG1DS,MAAMC,IAEH5D,KAAKc,qBAAqB8C,GAAOC,SAG7BD,aAAiBE,EACjB9D,KAAK+D,YAAYH,GAEjB5D,KAAK+D,YAAY,IAAID,EAAmB,QAASF,QAQjEvB,EAAArC,KAAQ0D,gCAAgC,CAACT,EAAwBC,KAK7D,GAJAlD,KAAKgB,aAAagD,WAAW,CAAEf,UAASC,qBACxClD,KAAK+C,UAAU,UAGX/C,KAAKL,MAAMiC,cAAf,CAIA,IAAK5B,KAAKL,MAAMsE,wBACZ,MAAM,IAAIH,EAAmB,uBAAwB,4CAGzD,OACI,IAAIvB,QAAc,CAACC,EAASC,KACnBzC,KAAKL,MAAMsE,wBAAwBzB,EAASC,KAGhDO,KAAK,IAAMhD,KAAKqB,kBAEhBsC,MAAM,OAbf,IA6BJtB,EAAArC,KAAmBiC,YAAatC,GACrB6B,EAAC0C,EAAcvE,KA5J1B0C,EADS7C,EACcO,OAAmBoE,EAAWC,UAIrD/B,EALS7C,EAKiB6E,eAAe,CACrC5D,oBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static readonly type: TxVariants = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static readonly defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance: PaymentAmount, transactionLimit: PaymentAmount): Promise<void> | void => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n protected override payButton = (props: PayButtonProps) => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyDown={this.handleKeyDown}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","configuration","formatData","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","componentRef","setBalanceCheckErrors","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyDown","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","onSubmitAnalytics","submitAnalytics","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"qcAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,MAAO,IACAA,GAAOC,iBACPD,EAEX,CAEAE,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKL,MAAMO,MAClBC,oBAAqBH,KAAKI,MAAMC,MAAMF,oBACtCG,sBAAuBN,KAAKI,MAAM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BAEhBsC,MAAM,OAbf,IA6BJtB,EAAArC,KAAmBiC,YAAatC,GACrB6B,EAAC0C,EAAcvE,KA5J1B0C,EADS7C,EACcO,OAAmBoE,EAAWC,UAIrD/B,EALS7C,EAKiB6E,eAAe,CACrC5D,oBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GiftcardComponent.js","sources":["../../../../../src/components/Giftcard/components/GiftcardComponent.tsx"],"sourcesContent":["import { Component, FunctionComponent, h } from 'preact';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport Alert from '../../internal/Alert';\nimport GiftcardResult from './GiftcardResult';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType, GiftCardValidationError } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type { SFPProps } from '../../internal/SecuredFields/SFP/types';\n\ninterface GiftcardComponentProps extends Partial<Pick<SFPProps, 'clientKey' | 'loadingContext'>> {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n showPayButton: boolean;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyPress?: (o: KeyboardEvent) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n}\n\nclass Giftcard extends Component<Readonly<GiftcardComponentProps>> {\n public state = {\n status: 'ready',\n data: {},\n balance: null,\n transactionLimit: null,\n focusedElement: false,\n isValid: false,\n sfpState: {},\n isValidating: false,\n transformedErrors: {}\n };\n\n public static readonly defaultProps = {\n pinRequired: true,\n expiryDateRequired: false,\n onChange: () => {},\n onFocus: () => {},\n onBlur: () => {},\n fieldsLayoutComponent: GiftCardFields\n };\n\n public sfp: SecuredFieldsProvider;\n\n /**\n * Maps string error codes from SecuredFields to validation rule objects\n */\n public mapErrorsToValidationObjects = () => {\n // Use the sfp reference to call mapErrorsToValidationRuleResult\n if (!this.sfp) return {};\n return this.sfp.mapErrorsToValidationRuleResult();\n };\n\n private updateTransformedErrors = (balanceCheckErrors?: Record<string, GiftCardValidationError>) => {\n const transformedErrors = this.mapErrorsToValidationObjects();\n\n const mergedErrors = { ...transformedErrors, ...balanceCheckErrors };\n\n this.setState({ transformedErrors: mergedErrors });\n };\n\n public onChange = sfpState => {\n this.setState({ sfpState }, () => this.updateTransformedErrors());\n\n this.props.onChange({\n data: sfpState.data,\n isValid: sfpState.isSfpValid\n });\n };\n\n public handleFocus = e => {\n this.setState({ focusedElement: e.currentFocusObject });\n\n const isFocused = e.focus === true;\n if (isFocused) {\n this.props.onFocus(e);\n } else {\n this.props.onBlur(e);\n }\n };\n\n public setBalance = ({ balance, transactionLimit }) => {\n this.setState({ balance, transactionLimit });\n };\n\n /**\n * Generates balance check errors in the same format as SFP errors\n * Compatible with the transformedErrors structure\n */\n private generateBalanceCheckErrors(errorType?: GiftCardBalanceCheckErrorType | null): Record<string, GiftCardValidationError> {\n const balanceCheckErrors: Record<string, GiftCardValidationError> = {};\n\n // This is the field that the error is associated with, only used for SR logic\n const fieldToAnnounce = 'encryptedCardNumber';\n\n // If errorType is null, clear errors\n if (errorType === null) {\n return balanceCheckErrors;\n }\n\n // Create error in the same format as SFP errors for consistency\n balanceCheckErrors[fieldToAnnounce] = {\n isValid: false,\n errorMessage: `error.giftcard.${errorType}`,\n error: errorType\n };\n\n return balanceCheckErrors;\n }\n\n /**\n * Checks if a status represents a balance check error\n */\n private isBalanceCheckError(status: string): boolean {\n return ['no-balance', 'card-error', 'currency-error'].includes(status);\n }\n\n /**\n * Method called by GiftcardElement to set balance check errors only\n */\n public setBalanceCheckErrors = (errorType: GiftCardBalanceCheckErrorType | null): void => {\n // Check if the errors should be displayed\n if (this.isBalanceCheckError(errorType)) {\n // Generate balance check errors in the style of useForm\n // This is usefull because then we can use the same logic for SF and balance check errors\n // Also we can use the same logic for SRPanel errors\n const balanceCheckErrors = this.generateBalanceCheckErrors(errorType);\n this.updateTransformedErrors(balanceCheckErrors);\n }\n };\n\n public showValidation = () => {\n this.setState({ isValidating: true });\n\n // Validate SecuredFields\n this.sfp?.showValidation();\n };\n\n public setIsValidating = (val: boolean) => {\n this.setState({ isValidating: val });\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n const { amount } = useAmount();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n setIsValidating: this.setIsValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\n balance={balance}\n transactionLimit={transactionLimit}\n makePayment={props.makePayment}\n status={this.state.status}\n makeBalanceCheck={props.makeBalanceCheck}\n showPayButton={this.props.showPayButton}\n payButton={this.props.payButton}\n />\n );\n }\n\n const getCardErrorMessage = sfpState => {\n if (sfpState.errors.encryptedCardNumber) return i18n.get(sfpState.errors.encryptedCardNumber);\n\n // This logic is a bit of a hack, but it's the only way to get the error message for balance check errors\n // In the future we should move this logic to useForm\n if (transformedErrors.encryptedCardNumber) {\n return i18n.get(transformedErrors.encryptedCardNumber.errorMessage);\n }\n\n return null;\n };\n\n return (\n <div className=\"adyen-checkout__giftcard\">\n {this.state.status === 'error' && <Alert icon={'cross'}>{i18n.get('error.message.unknown')}</Alert>}\n\n <SecuredFieldsProvider\n {...this.props}\n clientKey={this.props.clientKey}\n loadingContext={this.props.loadingContext}\n ref={ref => {\n this.sfp = ref;\n }}\n onChange={this.onChange}\n onFocus={this.handleFocus}\n onSubmitAnalytics={props.onSubmitAnalytics}\n type={GIFT_CARD}\n componentType={props.type}\n render={({ setRootNode, setFocusOn }, sfpState) =>\n this.props.fieldsLayoutComponent({\n i18n: i18n,\n pinRequired: this.props.pinRequired,\n focusedElement: focusedElement,\n getCardErrorMessage: getCardErrorMessage,\n setRootNode: setRootNode,\n setFocusOn: setFocusOn,\n sfpState: sfpState\n })\n }\n />\n\n {this.props.showPayButton &&\n this.props.payButton({\n status: this.state.status,\n onClick: this.props.makeBalanceCheck,\n label: i18n.get('applyGiftcard')\n })}\n </div>\n );\n }\n}\n\nexport default Giftcard;\n"],"names":["Giftcard","Component","generateBalanceCheckErrors","errorType","balanceCheckErrors","isValid","errorMessage","error","isBalanceCheckError","status","includes","render","props","focusedElement","balance","transactionLimit","isValidating","transformedErrors","i18n","useCoreContext","amount","useAmount","useSRPanelForGiftcardErrors","errors","setIsValidating","this","sfp","transactionAmount","value","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","clientKey","loadingContext","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","val","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"isBA+BA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA2BC,GAC/B,MAAMC,EAA8D,CAAA,EAMpE,OAAkB,OAAdD,IAKJC,sBAAsC,CAClCC,S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IrC,MAAMC,EAAqBqB,KAAKvB,2BAA2BC,GAC3DsB,KAAK0C,wBAAwB/D,EACjC,IAGJ2D,OAAOc,iBAAiB,KACpBpD,KAAK4C,SAAS,CAAErD,cAAc,IAG9BS,KAAKC,KAAKmD,mBAGdd,EAAAtC,KAAOD,kBAAmBsD,IACtBrD,KAAK4C,SAAS,CAAErD,aAAc8D,OA1GlCf,EAbE/D,EAaqB+E,eAAe,CAClCrB,aAAa,EACbsB,oBAAoB,EACpBhC,SAAU,OACVC,QAAS,OACTyB,OAAQ,OACRjB,sBAAuBwB"}
|
|
1
|
+
{"version":3,"file":"GiftcardComponent.js","sources":["../../../../../src/components/Giftcard/components/GiftcardComponent.tsx"],"sourcesContent":["import { Component, FunctionComponent, h } from 'preact';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport Alert from '../../internal/Alert';\nimport GiftcardResult from './GiftcardResult';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType, GiftCardValidationError } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type { SFPProps } from '../../internal/SecuredFields/SFP/types';\n\ninterface GiftcardComponentProps extends Partial<Pick<SFPProps, 'clientKey' | 'loadingContext'>> {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n showPayButton: boolean;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyDown?: (event: KeyboardEvent) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n}\n\nclass Giftcard extends Component<Readonly<GiftcardComponentProps>> {\n public state = {\n status: 'ready',\n data: {},\n balance: null,\n transactionLimit: null,\n focusedElement: false,\n isValid: false,\n sfpState: {},\n isValidating: false,\n transformedErrors: {}\n };\n\n public static readonly defaultProps = {\n pinRequired: true,\n expiryDateRequired: false,\n onChange: () => {},\n onFocus: () => {},\n onBlur: () => {},\n fieldsLayoutComponent: GiftCardFields\n };\n\n public sfp: SecuredFieldsProvider;\n\n /**\n * Maps string error codes from SecuredFields to validation rule objects\n */\n public mapErrorsToValidationObjects = () => {\n // Use the sfp reference to call mapErrorsToValidationRuleResult\n if (!this.sfp) return {};\n return this.sfp.mapErrorsToValidationRuleResult();\n };\n\n private updateTransformedErrors = (balanceCheckErrors?: Record<string, GiftCardValidationError>) => {\n const transformedErrors = this.mapErrorsToValidationObjects();\n\n const mergedErrors = { ...transformedErrors, ...balanceCheckErrors };\n\n this.setState({ transformedErrors: mergedErrors });\n };\n\n public onChange = sfpState => {\n this.setState({ sfpState }, () => this.updateTransformedErrors());\n\n this.props.onChange({\n data: sfpState.data,\n isValid: sfpState.isSfpValid\n });\n };\n\n public handleFocus = e => {\n this.setState({ focusedElement: e.currentFocusObject });\n\n const isFocused = e.focus === true;\n if (isFocused) {\n this.props.onFocus(e);\n } else {\n this.props.onBlur(e);\n }\n };\n\n public setBalance = ({ balance, transactionLimit }) => {\n this.setState({ balance, transactionLimit });\n };\n\n /**\n * Generates balance check errors in the same format as SFP errors\n * Compatible with the transformedErrors structure\n */\n private generateBalanceCheckErrors(errorType?: GiftCardBalanceCheckErrorType | null): Record<string, GiftCardValidationError> {\n const balanceCheckErrors: Record<string, GiftCardValidationError> = {};\n\n // This is the field that the error is associated with, only used for SR logic\n const fieldToAnnounce = 'encryptedCardNumber';\n\n // If errorType is null, clear errors\n if (errorType === null) {\n return balanceCheckErrors;\n }\n\n // Create error in the same format as SFP errors for consistency\n balanceCheckErrors[fieldToAnnounce] = {\n isValid: false,\n errorMessage: `error.giftcard.${errorType}`,\n error: errorType\n };\n\n return balanceCheckErrors;\n }\n\n /**\n * Checks if a status represents a balance check error\n */\n private isBalanceCheckError(status: string): boolean {\n return ['no-balance', 'card-error', 'currency-error'].includes(status);\n }\n\n /**\n * Method called by GiftcardElement to set balance check errors only\n */\n public setBalanceCheckErrors = (errorType: GiftCardBalanceCheckErrorType | null): void => {\n // Check if the errors should be displayed\n if (this.isBalanceCheckError(errorType)) {\n // Generate balance check errors in the style of useForm\n // This is usefull because then we can use the same logic for SF and balance check errors\n // Also we can use the same logic for SRPanel errors\n const balanceCheckErrors = this.generateBalanceCheckErrors(errorType);\n this.updateTransformedErrors(balanceCheckErrors);\n }\n };\n\n public showValidation = () => {\n this.setState({ isValidating: true });\n\n // Validate SecuredFields\n this.sfp?.showValidation();\n };\n\n public setIsValidating = (val: boolean) => {\n this.setState({ isValidating: val });\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n const { amount } = useAmount();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n setIsValidating: this.setIsValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\n balance={balance}\n transactionLimit={transactionLimit}\n makePayment={props.makePayment}\n status={this.state.status}\n makeBalanceCheck={props.makeBalanceCheck}\n showPayButton={this.props.showPayButton}\n payButton={this.props.payButton}\n />\n );\n }\n\n const getCardErrorMessage = sfpState => {\n if (sfpState.errors.encryptedCardNumber) return i18n.get(sfpState.errors.encryptedCardNumber);\n\n // This logic is a bit of a hack, but it's the only way to get the error message for balance check errors\n // In the future we should move this logic to useForm\n if (transformedErrors.encryptedCardNumber) {\n return i18n.get(transformedErrors.encryptedCardNumber.errorMessage);\n }\n\n return null;\n };\n\n return (\n <div className=\"adyen-checkout__giftcard\">\n {this.state.status === 'error' && <Alert icon={'cross'}>{i18n.get('error.message.unknown')}</Alert>}\n\n <SecuredFieldsProvider\n {...this.props}\n clientKey={this.props.clientKey}\n loadingContext={this.props.loadingContext}\n ref={ref => {\n this.sfp = ref;\n }}\n onChange={this.onChange}\n onFocus={this.handleFocus}\n onSubmitAnalytics={props.onSubmitAnalytics}\n type={GIFT_CARD}\n componentType={props.type}\n render={({ setRootNode, setFocusOn }, sfpState) =>\n this.props.fieldsLayoutComponent({\n i18n: i18n,\n pinRequired: this.props.pinRequired,\n focusedElement: focusedElement,\n getCardErrorMessage: getCardErrorMessage,\n setRootNode: setRootNode,\n setFocusOn: setFocusOn,\n sfpState: sfpState\n })\n }\n />\n\n {this.props.showPayButton &&\n this.props.payButton({\n status: this.state.status,\n onClick: this.props.makeBalanceCheck,\n label: i18n.get('applyGiftcard')\n })}\n </div>\n );\n }\n}\n\nexport default Giftcard;\n"],"names":["Giftcard","Component","generateBalanceCheckErrors","errorType","balanceCheckErrors","isValid","errorMessage","error","isBalanceCheckError","status","includes","render","props","focusedElement","balance","transactionLimit","isValidating","transformedErrors","i18n","useCoreContext","amount","useAmount","useSRPanelForGiftcardErrors","errors","setIsValidating","this","sfp","transactionAmount","value","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","clientKey","loadingContext","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","val","def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,KAI1BR,OAAOY,aAAa,EAAG7D,UAASC,uBAC5BU,KAAK4C,SAAS,CAAEvD,UAASC,uBAsC7BgD,EAAAtC,KAAOmD,wBAAyBzE,IAE5B,GAAIsB,KAAKjB,oBAAoBL,GAAY,CAIrC,MAAMC,EAAqBqB,KAAKvB,2BAA2BC,GAC3DsB,KAAK0C,wBAAwB/D,EACjC,IAGJ2D,OAAOc,iBAAiB,KACpBpD,KAAK4C,SAAS,CAAErD,cAAc,IAG9BS,KAAKC,KAAKmD,mBAGdd,EAAAtC,KAAOD,kBAAmBsD,IACtBrD,KAAK4C,SAAS,CAAErD,aAAc8D,OA1GlCf,EAbE/D,EAaqB+E,eAAe,CAClCrB,aAAa,EACbsB,oBAAoB,EACpBhC,SAAU,OACVC,QAAS,OACTyB,OAAQ,OACRjB,sBAAuBwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/DoChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { encodeBase64URL } from '../utils';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport {
|
|
1
|
+
{"version":3,"file":"DoChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/DoChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { encodeBase64URL } from '../utils';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport {\n CHALLENGE_TIMEOUT,\n CHALLENGE_TIMEOUT_REJECT_OBJECT,\n THREEDS2_NUM,\n PASSKEY_VISA_IFRAME_ALLOW,\n PASSKEY_3DS2_IFRAME_ALLOW,\n PASSKEY_VISA_IFRAME_SANDBOX\n} from '../../constants';\nimport { DoChallenge3DS2Props, DoChallenge3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSIframe';\n\nclass DoChallenge3DS2 extends Component<DoChallenge3DS2Props, DoChallenge3DS2State> {\n private processMessageHandler: (event: Pick<MessageEvent, 'origin' | 'data'>) => string | boolean;\n private challengePromise: { promise: Promise<ThreeDS2FlowObject>; cancel: () => void };\n\n constructor(props: DoChallenge3DS2Props) {\n super(props);\n\n /**\n * Create and Base64Url encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL\n */\n const jsonStr = JSON.stringify(this.props.cReqData);\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData, status: 'init' };\n }\n\n private iframeCallback = () => {\n this.setState({ status: 'iframeLoaded' });\n // On Test - actually calls-back 3 times: once for challenge screen, once again as challenge.html reloads after the challenge is submitted, and once for redirect to threeDSNotificationURL.\n // But for the purposes of calling the merchant defined onActionHandled callback - we only want to do it once\n if (this.state.status === 'init') {\n this.props.onActionHandled?.({ componentType: '3DS2Challenge', actionDescription: `${THREEDS2_NUM} challenge iframe loaded` });\n }\n };\n\n private get3DS2ChallengePromise(): Promise<ThreeDS2FlowObject> {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'challengeResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Render challenge\n this.challengePromise = promiseTimeout(CHALLENGE_TIMEOUT, this.get3DS2ChallengePromise(), CHALLENGE_TIMEOUT_REJECT_OBJECT);\n this.challengePromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteChallenge(resolveObject);\n })\n /** Catch, for when Challenge times-out */\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorChallenge(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.challengePromise) this.challengePromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render(\n { acsURL, cReqData, iframeSizeArr, onFormSubmit, usePasskeyIFrameAttributes }: DoChallenge3DS2Props,\n { base64URLencodedData, status }: DoChallenge3DS2State\n ) {\n const [width, height] = iframeSizeArr;\n\n return (\n <div\n className={classNames([\n 'adyen-checkout__threeds2__challenge',\n `adyen-checkout__threeds2__challenge--${cReqData.challengeWindowSize}`\n ])}\n >\n {status !== 'iframeLoaded' && <Spinner />}\n\n <Iframe\n name={iframeName}\n width={width}\n height={height}\n callback={this.iframeCallback}\n allow={usePasskeyIFrameAttributes ? PASSKEY_VISA_IFRAME_ALLOW : PASSKEY_3DS2_IFRAME_ALLOW}\n sandbox={usePasskeyIFrameAttributes ? PASSKEY_VISA_IFRAME_SANDBOX : undefined}\n />\n <ThreeDS2Form\n name={'cReqForm'}\n action={acsURL}\n target={iframeName}\n inputName={'creq'}\n inputValue={base64URLencodedData ?? ''}\n onFormSubmit={onFormSubmit}\n />\n </div>\n );\n }\n}\n\nexport default DoChallenge3DS2;\n"],"names":["iframeName","DoChallenge3DS2","Component","get3DS2ChallengePromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","challengePromise","promiseTimeout","CHALLENGE_TIMEOUT","CHALLENGE_TIMEOUT_REJECT_OBJECT","promise","then","resolveObject","removeEventListener","onCompleteChallenge","catch","rejectObject","onErrorChallenge","componentWillUnmount","cancel","render","acsURL","cReqData","iframeSizeArr","onFormSubmit","usePasskeyIFrameAttributes","base64URLencodedData","status","width","height","h","div","className","classNames","challengeWindowSize","Spinner","Iframe","name","callback","iframeCallback","allow","PASSKEY_VISA_IFRAME_ALLOW","PASSKEY_3DS2_IFRAME_ALLOW","sandbox","PASSKEY_VISA_IFRAME_SANDBOX","undefined","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","setState","state","onActionHandled","componentType","actionDescription","THREEDS2_NUM","jsonStr","JSON","stringify","encodeBase64URL"],"mappings":"0vBAmBA,MAAMA,EAAa,gBAEnB,MAAMC,UAAwBC,EAwBlBC,uBAAAA,GACJ,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,mBAErGM,OAAOC,iBAAiB,UAAWN,KAAKC,wBAEhD,CAEAM,iBAAAA,GAEIP,KAAKQ,iBAAmBC,EAAeC,EAAmBV,KAAKJ,0BAA2Be,GAC1FX,KAAKQ,iBAAiBI,QACjBC,KAAMC,IACHT,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMa,oBAAoBF,KAGlCG,MAAOC,IACJb,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMgB,iBAAiBD,IAExC,CAEAE,oBAAAA,GACQpB,KAAKQ,kBAAkBR,KAAKQ,iBAAiBa,SACjDhB,OAAOU,oBAAoB,UAAWf,KAAKC,sBAC/C,CAEAqB,MAAAA,EACIC,OAAEA,EAAMC,SAAEA,EAAQC,cAAEA,EAAaC,aAAEA,EAAYC,2BAAEA,IACjDC,qBAAEA,EAAoBC,OAAEA,IAExB,MAAOC,EAAOC,GAAUN,EAExB,OACIO,EAACC,MAAAA,CACGC,UAAWC,EAAW,CAClB,sCACA,wCAAwCX,EAASY,yBAGzC,iBAAXP,GAA6BG,EAACK,EAAAA,MAE/BL,EAACM,EAAAA,CACGC,KAAM9C,EACNqC,MAAOA,EACPC,OAAQA,EACRS,SAAUxC,KAAKyC,eACfC,MAAOf,EAA6BgB,EAA4BC,EAChEC,QAASlB,EAA6BmB,OAA8BC,IAExEf,EAACgB,EAAAA,CACGT,KAAM,WACNU,OAAQ1B,EACR2B,OAAQzD,EACR0D,UAAW,OACXC,WAAYxB,GAAwB,GACpCF,aAAcA,IAI9B,CApFA,WAAA2B,CAAYlD,GACRmD,MAAMnD,GAJVoD,EAAAvD,KAAQC,6BAAR,GACAsD,EAAAvD,KAAQQ,wBAAR,GAaA+C,EAAAvD,KAAQyC,iBAAiB,KACrBzC,KAAKwD,SAAS,CAAE3B,OAAQ,iBAGE,SAAtB7B,KAAKyD,MAAM5B,QACX7B,KAAKG,MAAMuD,kBAAkB,CAAEC,cAAe,gBAAiBC,kBAAmB,GAAGC,gCAVzF,MAAMC,EAAUC,KAAKC,UAAUhE,KAAKG,MAAMqB,UACpCI,EAAuBqC,EAAgBH,GAC7C9D,KAAKyD,MAAQ,CAAE7B,uBAAsBC,OAAQ,OACjD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as
|
|
1
|
+
import{createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import{useRef as t,useMemo as o,useState as r,useCallback as n,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as d}from"./validate.js";import{countrySpecificFormatters as c,addressFormatters as u}from"./validate.formats.js";import m from"./components/FieldContainer.js";import p from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import f from"./Specifications.js";import{COUNTRY as y,ADDRESS_SCHEMA as F,FALLBACK_VALUE as h}from"./constants.js";import{getMaxLengthByFieldAndCountry as C}from"../../../utils/validator-utils.js";import{useCoreContext as g}from"../../../core/Context/CoreProvider.js";import A from"./components/AddressSearch.js";import{getAddressTypeFromLabel as v}from"./utils.js";const b={};function j(j){const{i18n:S}=g(),{label:x="",requiredFields:k,visibility:M,iOSFocusedField:O=null,showContextualElement:D}=j,w=v(j.addressType,x),B=t({});Object.keys(B.current).length||j.setComponentRef?.(B.current);const E=o(()=>new f(j.specifications),[j.specifications]),L=E.getAddressSchemaForCountryFlat(j.countryCode).filter(e=>k.includes(e)),[N,P]=r(!1),[R,T]=r(!1),[V,H]=r(""),q=!!j.onAddressLookup,[_,I]=r(!1),U=!j.onAddressLookup||(N||R),$=j.data??b,z=$.country,G=z&&!L.includes(y)?[...L,y]:L,J=o(()=>z?{...$,country:z.toUpperCase()}:$,[$,z]),{data:K,errors:Q,valid:W,isValid:X,handleChangeFor:Y,triggerValidation:Z,setData:ee,mergeData:se}=p({schema:G,defaultData:J,rules:{...d(E),...j.validationRules},formatters:u}),te=n(e=>{const s=F.reduce((s,t)=>{const o=e[t];return null!=o&&(s[t]=String(o)),s},{});se(s),I(!0),Z(),P(!0)},[P,Z,ee]),oe=n(()=>{T(!0)},[]);B.current.showValidation=()=>{Z(),H(!q||U||X?"":S.get("address.errors.incomplete"))};const re=L.filter(e=>!O||e===O);if(a(()=>{if(_)return void I(!1);const e=E.countryHasDataset(K.country)?"":h,s={...K,stateOrProvince:e};k.forEach(e=>{Y(e,"input")(s[e]??"")}),s.postalCode&&Y("postalCode","blur")(K.postalCode)},[K.country]),a(()=>{const e=k.includes("stateOrProvince"),s=K.country&&E.countryHasDataset(K.country),t=e&&s,o=K.stateOrProvince||(t?"":h);Y("stateOrProvince","input")(o)},[]),a(()=>{const e=E.getOptionalFieldsForCountry(K.country),s=F.reduce((s,t)=>{const o=e.includes(t),r=k.includes(t),n=K[t],a=J[t],i=o&&!n||!r?!r&&a?a:h:n;return i?.length&&(s[t]=i),s},{});j.onChange({data:s,valid:W,errors:Q,isValid:X})},[K,W,Q,X]),"hidden"===M)return null;if("readOnly"===M)return e(l,{data:K,label:x});const ne=(s,{classNameModifiers:t=[]})=>k.includes(s)?e(m,{key:s,allowedCountries:j.allowedCountries,classNameModifiers:[...t,s],data:K,errors:Q,valid:W,fieldName:s,onInput:Y(s,"input"),onBlur:Y(s,"blur"),onDropdownChange:Y(s,"blur"),specifications:E,maxLength:C(c,s,K.country),trimOnBlur:!0,disabled:!re.includes(s),addressType:w,onFieldFocusAnalytics:j.onFieldFocusAnalytics,onFieldBlurAnalytics:j.onFieldBlurAnalytics}):null,ae=E.getAddressSchemaForCountry(K.country);return e(s,null,e(i,{classNameModifiers:[x,"address"],label:x,renderLabelAsSectionHeading:!0},q&&e(A,{onAddressLookup:j.onAddressLookup,onAddressSelected:j.onAddressSelected,onSelect:te,onManualAddress:oe,externalErrorMessage:V,hideManualButton:U,showContextualElement:D,contextualText:S.get("address.search.contextualText"),addressSearchDebounceMs:j.addressSearchDebounceMs}),U&&e(s,null,ae.map(s=>s instanceof Array?e("div",{className:"adyen-checkout__field-group"},s.map(([e,s])=>ne(e,{classNameModifiers:[`col-${s}`]}))):ne(s,{})))))}j.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:F,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{j as default};
|
|
2
2
|
//# sourceMappingURL=Address.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps, AddressType } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, COUNTRY, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\nimport { getAddressTypeFromLabel } from './utils';\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n const addressType: AddressType = getAddressTypeFromLabel(props.addressType, label);\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n // In partial address mode the country field is not rendered, so it is absent from the address schema.\n // The country the merchant configured must still be part of the form data for country dependent rules to be applied.\n const merchantCountry = (props.data as AddressData)?.country;\n const formSchema = merchantCountry && !requiredFieldsSchema.includes(COUNTRY) ? [...requiredFieldsSchema, COUNTRY] : requiredFieldsSchema;\n const defaultData = useMemo<AddressData>(\n () => (merchantCountry ? { ...props.data, country: merchantCountry.toUpperCase() } : (props.data)),\n [props.data, merchantCountry]\n );\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: formSchema,\n defaultData,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = defaultData[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n addressType={addressType}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressType","getAddressTypeFromLabel","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","merchantCountry","data","country","formSchema","COUNTRY","defaultData","toUpperCase","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","rules","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"68BAmBe,SAASA,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BP,EAC5FQ,EAA2BC,EAAwBT,EAAMQ,YAAaL,GAGtEO,EAAaC,EAA4B,IAE1CC,OAAOC,KAAKH,EAAWI,SAASC,QACjCf,EAAMgB,kBAAkBN,EAAWI,SAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAenB,EAAMiB,gBAAiB,CAACjB,EAAMiB,iBAEhFG,EAAuBH,EAAeI,+BAA+BrB,EAAMsB,aAAaC,OAAOC,GAASpB,EAAeqB,SAASD,KAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GAAyBJ,EAAS,IAEvDK,IAAsBjC,EAAMkC,iBAE3BC,EAAqBC,GAA0BR,GAAS,GAEzDS,GAAoBrC,EAAMkC,kBAAkBR,GAAsBG,GAIlES,EAAmBtC,EAAMuC,MAAsBC,QAC/CC,EAAaH,IAAoBlB,EAAqBK,SAASiB,GAAW,IAAItB,EAAsBsB,GAAWtB,EAC/GuB,EAAczB,EAChB,IAAOoB,EAAkB,IAAKtC,EAAMuC,KAAMC,QAASF,EAAgBM,eAAmB5C,EAAMuC,KAC5F,CAACvC,EAAMuC,KAAMD,KAGXC,KAAEA,EAAIM,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,EAAOC,gBAAEA,EAAeC,kBAAEA,EAAiBC,QAAEA,EAAOC,UAAEA,GAAcC,EAAqB,CAClHC,OAAQZ,EACRE,cAEAW,MAAO,IAAKC,EAA0BtC,MAAoBjB,EAAMwD,i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ACzBoD,wBAAyB3H,EAAM2H,0BAGtCtF,GACG0D,EAACmB,EAAAA,KAAUF,GAAcY,IAAIpG,GAAUA,aAAiBqG,MAxBpE9B,EAAC+B,MAAAA,CAAIC,UAAU,+BAwBwEvG,EAvB5EoG,IAAI,EAAEpG,EAAOwG,KAAU/B,GAAazE,EAAO,CAAE0E,mBAAoB,CAAC,OAAO8B,SAuBY/B,GAAazE,EAAO,CAAA,MAK5H,CAEAzB,EAAQkI,aAAe,CACnB3G,YAAa,KACbkC,gBAAiB,KACjBjB,KAAM,CAAA,EACNuD,SAAU,OACVzF,WAAY,WACZD,eAAgB2D,EAChB9C,eAAgB,CAAA,EAChB6F,sBAAuB,OACvBC,qBAAsB"}
|
|
1
|
+
{"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps, AddressType } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, COUNTRY, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\nimport { getAddressTypeFromLabel } from './utils';\n\nconst EMPTY_ADDRESS_DATA: Readonly<AddressData> = {};\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n const addressType: AddressType = getAddressTypeFromLabel(props.addressType, label);\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n // In partial address mode the country field is not rendered, so it is absent from the address schema.\n // The country the merchant configured must still be part of the form data for country dependent rules to be applied.\n const addressData = props.data ?? EMPTY_ADDRESS_DATA;\n const merchantCountry = addressData.country;\n const formSchema = merchantCountry && !requiredFieldsSchema.includes(COUNTRY) ? [...requiredFieldsSchema, COUNTRY] : requiredFieldsSchema;\n const defaultData = useMemo<AddressData>(\n () => (merchantCountry ? { ...addressData, country: merchantCountry.toUpperCase() } : addressData),\n [addressData, merchantCountry]\n );\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: formSchema,\n defaultData,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = defaultData[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n addressType={addressType}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["EMPTY_ADDRESS_DATA","Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressType","getAddressTypeFromLabel","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","addressData","data","merchantCountry","country","formSchema","COUNTRY","defaultData","toUpperCase","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","rules","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"68BAmBA,MAAMA,EAA4C,CAAA,EAEnC,SAASC,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BP,EAC5FQ,EAA2BC,EAAwBT,EAAMQ,YAAaL,GAGtEO,EAAaC,EAA4B,IAE1CC,OAAOC,KAAKH,EAAWI,SAASC,QACjCf,EAAMgB,kBAAkBN,EAAWI,SAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAenB,EAAMiB,gBAAiB,CAACjB,EAAMiB,iBAEhFG,EAAuBH,EAAeI,+BAA+BrB,EAAMsB,aAAaC,OAAOC,GAASpB,EAAeqB,SAASD,KAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GAAyBJ,EAAS,IAEvDK,IAAsBjC,EAAMkC,iBAE3BC,EAAqBC,GAA0BR,GAAS,GAEzDS,GAAoBrC,EAAMkC,kBAAkBR,GAAsBG,GAIlES,EAActC,EAAMuC,MAAQzC,EAC5B0C,EAAkBF,EAAYG,QAC9BC,EAAaF,IAAoBpB,EAAqBK,SAASkB,GAAW,IAAIvB,EAAsBuB,GAAWvB,EAC/GwB,EAAc1B,EAChB,IAAOsB,EAAkB,IAAKF,EAAaG,QAASD,EAAgBK,eAAkBP,EACtF,CAACA,EAAaE,KAGZD,KAAEA,EAAIO,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,EAAOC,gBAAEA,EAAeC,kBAAEA,EAAiBC,QAAEA,GAAOC,UAAEA,IAAcC,EAAqB,CAClHC,OAAQZ,EACRE,cAEAW,MAAO,IAAKC,EAA0BvC,MAAoBjB,EAAMyD,iBAChEC,WAAYC,IAGVC,GAAgBC,EACjBC,IACG,MAC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,EAAAA,KAAUF,GAAcY,IAAIrG,GAAUA,aAAiBsG,MAxBpE9B,EAAC+B,MAAAA,CAAIC,UAAU,+BAwBwExG,EAvB5EqG,IAAI,EAAErG,EAAOyG,KAAU/B,GAAa1E,EAAO,CAAE2E,mBAAoB,CAAC,OAAO8B,SAuBY/B,GAAa1E,EAAO,CAAA,MAK5H,CAEAzB,EAAQmI,aAAe,CACnB5G,YAAa,KACbmC,gBAAiB,KACjBlB,KAAM,CAAA,EACNwD,SAAU,OACV1F,WAAY,WACZD,eAAgB4D,EAChB/C,eAAgB,CAAA,EAChB8F,sBAAuB,OACvBC,qBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/Address/validate.ts"],"sourcesContent":["import { ValidatorRules, ValidatorRule } from '../../../utils/Validator/types';\nimport { countrySpecificFormatters } from './validate.formats';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../../../core/Errors/constants';\nimport { isEmpty } from '../../../utils/validator-utils';\n\nconst createPatternByDigits = (digits: number) => {\n return {\n pattern: new RegExp(`\\\\d{${digits}}`)\n };\n};\n\nexport const validatePostalCode = (val: string, countryCode: string, validatorRules: ValidatorRules) => {\n if (countryCode) {\n // If there is no value, we display the 'required' error message\n if (isEmpty(val)) return null;\n\n // Dynamically create errorMessage\n (validatorRules.postalCode as ValidatorRule).errorMessage = {\n translationKey: ERROR_INVALID_FORMAT_EXPECTS,\n translationObject: {\n values: {\n format: countrySpecificFormatters[countryCode]?.postalCode.format || null\n }\n }\n };\n\n const pattern = postalCodePatterns[countryCode]?.pattern;\n return pattern ? pattern.test(val) : !!val; // No pattern? Accept any, filled, value.\n }\n // Default rule\n return isEmpty(val) ? null : true;\n};\n\nconst postalCodePatterns = {\n AT: createPatternByDigits(4),\n AU: createPatternByDigits(4),\n BE: { pattern: /(?:(?:[1-9])(?:\\d{3}))/ },\n BG: createPatternByDigits(4),\n BR: { pattern: /^\\d{5}-?\\d{3}$/ },\n CA: { pattern: /(?:[ABCEGHJ-NPRSTVXY]\\d[A-Z][ -]?\\d[A-Z]\\d)/ },\n CH: { pattern: /[1-9]\\d{3}/ },\n CY: createPatternByDigits(4),\n CZ: { pattern: /\\d{3}\\s?\\d{2}/ },\n DE: createPatternByDigits(5),\n DK: createPatternByDigits(4),\n EE: createPatternByDigits(5),\n ES: { pattern: /(?:0[1-9]|[1-4]\\d|5[0-2])\\d{3}/ },\n FI: createPatternByDigits(5),\n FR: createPatternByDigits(5),\n GB: { pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/ },\n GE: createPatternByDigits(4),\n GR: { pattern: /^\\d{3}\\s{0,1}\\d{2}$/ },\n HR: { pattern: /^([1-5])[0-9]{4}$/ },\n HU: createPatternByDigits(4),\n IE: { pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/ },\n IS: createPatternByDigits(3),\n IT: createPatternByDigits(5),\n LI: createPatternByDigits(4),\n LT: { pattern: /^(LT-\\d{5}|\\d{4,5})$/ },\n LU: createPatternByDigits(4),\n LV: { pattern: /^(LV-)[0-9]{4}$/ },\n MC: { pattern: /^980\\d{2}$/ },\n MT: { pattern: /^[A-Za-z]{3}\\d{4}$/ },\n MY: createPatternByDigits(5),\n NL: { pattern: /(?:NL-)?(?:[1-9]\\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/ },\n NO: createPatternByDigits(4),\n PL: { pattern: /^\\d{2}[-]{0,1}\\d{3}$/ },\n PT: { pattern: /^([1-9]\\d{3})([- ]?(\\d{3})? *)$/ },\n RO: createPatternByDigits(6),\n SI: createPatternByDigits(4),\n SE: createPatternByDigits(5),\n SG: createPatternByDigits(6),\n SK: createPatternByDigits(5),\n US: { pattern: /^\\d{5}(?:-\\d{4})?$/ }\n};\n\n/**\n * Validates only postalCode property. As the partial address form does not have the country selector, the country value\n * must be informed beforehand and can't be picked up from the form context\n *\n * @param country - Country that will be used to validate postal code\n */\nexport const getPartialAddressValidationRules = (country: string): ValidatorRules => {\n const validationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: val => {\n return validatePostalCode(val, country, validationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return validationRules;\n};\n\nexport const getAddressValidationRules = (specifications): ValidatorRules => {\n const addressValidationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: (val, context) => {\n const country = context.state.data.country;\n return validatePostalCode(val, country, addressValidationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n },\n houseNumberOrName: {\n validate: (value, context) => {\n const selectedCountry = context.state?.data?.country;\n const isOptional = selectedCountry && specifications.countryHasOptionalField(selectedCountry, 'houseNumberOrName');\n return isOptional || (isEmpty(value) ? null : true);\n },\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n },\n default: {\n validate: value => (isEmpty(value) ? null : true), // true, if there are chars other than spaces\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return addressValidationRules;\n};\n"],"names":["createPatternByDigits","digits","pattern","RegExp","validatePostalCode","val","countryCode","validatorRules","isEmpty","postalCode","errorMessage","translationKey","ERROR_INVALID_FORMAT_EXPECTS","translationObject","values","format","countrySpecificFormatters","postalCodePatterns","test","AT","AU","BE","BG","BR","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GE","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NO","PL","PT","RO","SI","SE","SG","SK","US","getPartialAddressValidationRules","country","validationRules","modes","validate","ERROR_FIELD_REQUIRED","getAddressValidationRules","specifications","addressValidationRules","context","state","data","houseNumberOrName","value","selectedCountry","countryHasOptionalField","default"],"mappings":"yOAKA,MAAMA,EAAyBC,IACpB,CACHC,QAAS,IAAIC,OAAO,OAAOF,QAItBG,EAAqB,CAACC,EAAaC,
|
|
1
|
+
{"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/Address/validate.ts"],"sourcesContent":["import { ValidatorRules, ValidatorRule } from '../../../utils/Validator/types';\nimport { countrySpecificFormatters } from './validate.formats';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../../../core/Errors/constants';\nimport { isEmpty } from '../../../utils/validator-utils';\n\nconst createPatternByDigits = (digits: number) => {\n return {\n pattern: new RegExp(`\\\\d{${digits}}`)\n };\n};\n\nexport const validatePostalCode = (val: string, countryCode: string | null, validatorRules: ValidatorRules) => {\n if (countryCode) {\n // If there is no value, we display the 'required' error message\n if (isEmpty(val)) return null;\n\n // Dynamically create errorMessage\n (validatorRules.postalCode as ValidatorRule).errorMessage = {\n translationKey: ERROR_INVALID_FORMAT_EXPECTS,\n translationObject: {\n values: {\n format: countrySpecificFormatters[countryCode]?.postalCode.format || null\n }\n }\n };\n\n const pattern = postalCodePatterns[countryCode]?.pattern;\n return pattern ? pattern.test(val) : !!val; // No pattern? Accept any, filled, value.\n }\n // Default rule\n return isEmpty(val) ? null : true;\n};\n\nconst postalCodePatterns = {\n AT: createPatternByDigits(4),\n AU: createPatternByDigits(4),\n BE: { pattern: /(?:(?:[1-9])(?:\\d{3}))/ },\n BG: createPatternByDigits(4),\n BR: { pattern: /^\\d{5}-?\\d{3}$/ },\n CA: { pattern: /(?:[ABCEGHJ-NPRSTVXY]\\d[A-Z][ -]?\\d[A-Z]\\d)/ },\n CH: { pattern: /[1-9]\\d{3}/ },\n CY: createPatternByDigits(4),\n CZ: { pattern: /\\d{3}\\s?\\d{2}/ },\n DE: createPatternByDigits(5),\n DK: createPatternByDigits(4),\n EE: createPatternByDigits(5),\n ES: { pattern: /(?:0[1-9]|[1-4]\\d|5[0-2])\\d{3}/ },\n FI: createPatternByDigits(5),\n FR: createPatternByDigits(5),\n GB: { pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/ },\n GE: createPatternByDigits(4),\n GR: { pattern: /^\\d{3}\\s{0,1}\\d{2}$/ },\n HR: { pattern: /^([1-5])[0-9]{4}$/ },\n HU: createPatternByDigits(4),\n IE: { pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/ },\n IS: createPatternByDigits(3),\n IT: createPatternByDigits(5),\n LI: createPatternByDigits(4),\n LT: { pattern: /^(LT-\\d{5}|\\d{4,5})$/ },\n LU: createPatternByDigits(4),\n LV: { pattern: /^(LV-)[0-9]{4}$/ },\n MC: { pattern: /^980\\d{2}$/ },\n MT: { pattern: /^[A-Za-z]{3}\\d{4}$/ },\n MY: createPatternByDigits(5),\n NL: { pattern: /(?:NL-)?(?:[1-9]\\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/ },\n NO: createPatternByDigits(4),\n PL: { pattern: /^\\d{2}[-]{0,1}\\d{3}$/ },\n PT: { pattern: /^([1-9]\\d{3})([- ]?(\\d{3})? *)$/ },\n RO: createPatternByDigits(6),\n SI: createPatternByDigits(4),\n SE: createPatternByDigits(5),\n SG: createPatternByDigits(6),\n SK: createPatternByDigits(5),\n US: { pattern: /^\\d{5}(?:-\\d{4})?$/ }\n};\n\n/**\n * Validates only postalCode property. As the partial address form does not have the country selector, the country value\n * must be informed beforehand and can't be picked up from the form context\n *\n * @param country - Country that will be used to validate postal code\n */\nexport const getPartialAddressValidationRules = (country: string | null): ValidatorRules => {\n const validationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: val => {\n return validatePostalCode(val, country, validationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return validationRules;\n};\n\nexport const getAddressValidationRules = (specifications): ValidatorRules => {\n const addressValidationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: (val, context) => {\n const country = context.state.data.country;\n return validatePostalCode(val, country, addressValidationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n },\n houseNumberOrName: {\n validate: (value, context) => {\n const selectedCountry = context.state?.data?.country;\n const isOptional = selectedCountry && specifications.countryHasOptionalField(selectedCountry, 'houseNumberOrName');\n return isOptional || (isEmpty(value) ? null : true);\n },\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n },\n default: {\n validate: value => (isEmpty(value) ? null : true), // true, if there are chars other than spaces\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return addressValidationRules;\n};\n"],"names":["createPatternByDigits","digits","pattern","RegExp","validatePostalCode","val","countryCode","validatorRules","isEmpty","postalCode","errorMessage","translationKey","ERROR_INVALID_FORMAT_EXPECTS","translationObject","values","format","countrySpecificFormatters","postalCodePatterns","test","AT","AU","BE","BG","BR","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GE","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NO","PL","PT","RO","SI","SE","SG","SK","US","getPartialAddressValidationRules","country","validationRules","modes","validate","ERROR_FIELD_REQUIRED","getAddressValidationRules","specifications","addressValidationRules","context","state","data","houseNumberOrName","value","selectedCountry","countryHasOptionalField","default"],"mappings":"yOAKA,MAAMA,EAAyBC,IACpB,CACHC,QAAS,IAAIC,OAAO,OAAOF,QAItBG,EAAqB,CAACC,EAAaC,EAA4BC,KACxE,GAAID,EAAa,CAEb,GAAIE,EAAQH,GAAM,OAAO,KAGxBE,EAAeE,WAA6BC,aAAe,CACxDC,eAAgBC,EAChBC,kBAAmB,CACfC,OAAQ,CACJC,OAAQC,EAA0BV,IAAcG,WAAWM,QAAU,QAKjF,MAAMb,EAAUe,EAAmBX,IAAcJ,QACjD,OAAOA,EAAUA,EAAQgB,KAAKb,KAASA,CAC3C,CAEA,O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tB,OAAOH,GAGEI,EAA6BC,IACtC,MAAMC,EAAyC,CAC3C1D,WAAY,CACRqD,MAAO,CAAC,QACRC,SAAU,CAAC1D,EAAK+D,KACZ,MAAMR,EAAUQ,EAAQC,MAAMC,KAAKV,QACnC,OAAOxD,EAAmBC,EAAKuD,EAASO,IAE5CzD,aAAcsD,GAElBO,kBAAmB,CACfR,SAAU,CAACS,EAAOJ,KACd,MAAMK,EAAkBL,EAAQC,OAAOC,MAAMV,QAE7C,OADmBa,GAAmBP,EAAeQ,wBAAwBD,EAAiB,uBACxEjE,EAAQgE,IAAS,MAE3CV,MAAO,CAAC,QACRpD,aAAcsD,GAElBW,QAAS,CACLZ,SAAUS,IAAUhE,EAAQgE,IAAS,KACrCV,MAAO,CAAC,QACRpD,aAAcsD,IAGtB,OAAOG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as
|
|
1
|
+
import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as h}from"../../../core/config.js";function c(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class d{buildElementProps(t){this.props=this.formatProps({...this.constructor.defaultProps,...t})}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyDown(t){return null}setState(t){this.state={...this.state,...t}}get data(){const t=this.state.order||this.props.order,e=this.formatData(),o=Boolean(a(e.paymentMethod?.type)),n=this.core.modules.risk.data,s=this.core.modules.analytics.checkoutAttemptId??r,c=o?h.NATIVE:h.GENERIC,d=i(s,n,c);return e.paymentMethod&&s&&(e.paymentMethod.checkoutAttemptId=s),e.paymentMethod&&d&&(e.paymentMethod.sdkData=d),{...n&&{riskData:{clientData:n}},...t&&{order:{orderData:t.orderData,pspReference:t.pspReference}},...e,clientStateDataIndicator:!0}}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const o="string"==typeof e?document.querySelector(e):e;if(!o)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=o,n(this._node,"keydown",this.handleKeyDown,!1),this._component=this.render(),t(this._component,o),this}update(t){return this.props=this.formatProps({...this.props,...t}),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keydown",this.handleKeyDown),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,r){c(this,"_id",`${this.constructor.type}-${e()}`),c(this,"core",void 0),c(this,"props",void 0),c(this,"state",{}),c(this,"_component",void 0),c(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(r),this.handleKeyDown=this.handleKeyDown.bind(this)}}c(d,"defaultProps",{});export{d as default};
|
|
2
2
|
//# sourceMappingURL=BaseElement.js.map
|