@adyen/adyen-web 6.28.0 → 6.29.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 +8 -6
- 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 +2688 -2557
- package/dist/es/adyen.css +8 -6
- 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/types.js.map +1 -1
- package/dist/es/components/Econtext/Econtext.js +1 -1
- package/dist/es/components/Econtext/Econtext.js.map +1 -1
- package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js +1 -1
- package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
- package/dist/es/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js +1 -1
- package/dist/es/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js.map +1 -1
- package/dist/es/components/Iris/Iris.js +2 -0
- package/dist/es/components/Iris/Iris.js.map +1 -0
- package/dist/es/components/Iris/components/IrisComponent.js +2 -0
- package/dist/es/components/Iris/components/IrisComponent.js.map +1 -0
- package/dist/es/components/Iris/components/IrisComponent.module.scss.js +2 -0
- package/dist/es/components/Iris/components/IrisComponent.module.scss.js.map +1 -0
- package/dist/es/components/Iris/components/IrisGenerateQRCode.js +2 -0
- package/dist/es/components/Iris/components/IrisGenerateQRCode.js.map +1 -0
- package/dist/es/components/Iris/components/IrisGenerateQRCode.module.scss.js +2 -0
- package/dist/es/components/Iris/components/IrisGenerateQRCode.module.scss.js.map +1 -0
- package/dist/es/components/Iris/components/IrisQrCodeInstructions.js +2 -0
- package/dist/es/components/Iris/components/IrisQrCodeInstructions.js.map +1 -0
- package/dist/es/components/Iris/constants.js +2 -0
- package/dist/es/components/Iris/constants.js.map +1 -0
- package/dist/es/components/Iris/types.js +2 -0
- package/dist/es/components/Iris/types.js.map +1 -0
- package/dist/es/components/Iris/utils.js +2 -0
- package/dist/es/components/Iris/utils.js.map +1 -0
- package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
- package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
- package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
- package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
- package/dist/es/components/components-name-map.js +1 -1
- package/dist/es/components/components-name-map.js.map +1 -1
- package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es/components/index.js +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/PersonalDetails/PersonalDetails.js +1 -1
- package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.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/SegmentedControl/SegmentedControlRegion.js +2 -0
- package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -0
- package/dist/es/components/internal/Voucher/Voucher.js +1 -1
- package/dist/es/components/internal/Voucher/Voucher.js.map +1 -1
- package/dist/es/components/internal/Voucher/utils.js.map +1 -1
- package/dist/es/components/tx-variants.js +1 -1
- package/dist/es/components/tx-variants.js.map +1 -1
- package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
- package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/PaymentMethods.js +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/PaymentMethods.js.map +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/utils.js +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/utils.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/index.d.ts +2688 -2557
- package/dist/es/index.js +1 -1
- package/dist/es/language/Language.js.map +1 -1
- package/dist/es/utils/createSdkData.js +2 -0
- package/dist/es/utils/createSdkData.js.map +1 -0
- package/dist/es-legacy/adyen.css +8 -6
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js +1 -1
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js.map +1 -1
- package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js +1 -1
- package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.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/Card/components/ClickToPayWrapper.js +1 -1
- package/dist/es-legacy/components/Card/components/ClickToPayWrapper.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/Dragonpay/Dragonpay.js +1 -1
- package/dist/es-legacy/components/Dragonpay/Dragonpay.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/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
- package/dist/es-legacy/components/Econtext/Econtext.js +1 -1
- package/dist/es-legacy/components/Econtext/Econtext.js.map +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/requests.js +1 -1
- package/dist/es-legacy/components/GooglePay/requests.js.map +1 -1
- package/dist/es-legacy/components/Iris/Iris.js +2 -0
- package/dist/es-legacy/components/Iris/Iris.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisComponent.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisComponent.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisComponent.module.scss.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisComponent.module.scss.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.module.scss.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.module.scss.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisQrCodeInstructions.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisQrCodeInstructions.js.map +1 -0
- package/dist/es-legacy/components/Iris/constants.js +2 -0
- package/dist/es-legacy/components/Iris/constants.js.map +1 -0
- package/dist/es-legacy/components/Iris/types.js +2 -0
- package/dist/es-legacy/components/Iris/types.js.map +1 -0
- package/dist/es-legacy/components/Iris/utils.js +2 -0
- package/dist/es-legacy/components/Iris/utils.js.map +1 -0
- package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
- package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
- package/dist/es-legacy/components/PayPal/components/PaypalButtons.js +1 -1
- package/dist/es-legacy/components/PayPal/components/PaypalButtons.js.map +1 -1
- package/dist/es-legacy/components/PayPal/components/PaypalComponent.js +1 -1
- package/dist/es-legacy/components/PayPal/components/PaypalComponent.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
- package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
- package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
- package/dist/es-legacy/components/components-name-map.js +1 -1
- package/dist/es-legacy/components/components-name-map.js.map +1 -1
- package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es-legacy/components/index.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.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/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/FormFields/Checkbox/Checkbox.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/ConsentCheckbox/ConsentCheckbox.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/ConsentCheckbox/ConsentCheckbox.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/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/SelectList.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.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/IssuerList/IssuerList.js +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.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/OpenInvoice/OpenInvoice.js +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoaderDetailsProvider.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoaderDetailsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
- package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
- 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/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.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/SegmentedControl/SegmentedControlRegion.js +2 -0
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -0
- package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js +1 -1
- package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Voucher/Voucher.js +1 -1
- package/dist/es-legacy/components/internal/Voucher/Voucher.js.map +1 -1
- package/dist/es-legacy/components/internal/Voucher/utils.js.map +1 -1
- package/dist/es-legacy/components/tx-variants.js +1 -1
- package/dist/es-legacy/components/tx-variants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/Context/Resources.js +1 -1
- package/dist/es-legacy/core/Context/Resources.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/PaymentMethods.js +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/PaymentMethods.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.js.map +1 -1
- package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js +1 -1
- package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
- package/dist/es-legacy/index.js +1 -1
- package/dist/es-legacy/language/Language.js.map +1 -1
- package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
- package/dist/es-legacy/utils/commonUtils.js.map +1 -1
- package/dist/es-legacy/utils/createSdkData.js +2 -0
- package/dist/es-legacy/utils/createSdkData.js.map +1 -0
- package/dist/es-legacy/utils/useForm/reducer.js +1 -1
- package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
- package/package.json +12 -12
- package/styles/adyen.css +8 -6
package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectListItem.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectListItem.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { SelectItemProps } from '../types';\nimport Img from '../../../Img';\nimport Icon from '../../../Icon';\nimport { PREFIX } from '../../../Icon/constants';\n\nconst SelectListItem = ({ item, active, selected, ...props }: SelectItemProps) => {\n return (\n /* eslint-disable jsx-a11y/click-events-have-key-events */\n <li\n aria-disabled={!!item.disabled}\n aria-selected={selected}\n className={cx([\n 'adyen-checkout__dropdown__element',\n {\n 'adyen-checkout__dropdown__element--active': active,\n 'adyen-checkout__dropdown__element--disabled': !!item.disabled\n }\n ])}\n // A change in Preact v10.11.1 means that all falsy values are assessed and set on data attributes.\n // In the case of data-disabled we only ever want it set if item.disabled is actually true, since the presence of the data-disabled attr,\n // regardless of its value, will disable the select list item\n data-disabled={item.disabled === true ? true : null}\n data-value={item.id}\n onClick={props.onSelect}\n onMouseEnter={props.onHover}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role */\n role=\"option\"\n //tabIndex={-1}\n id={`listItem-${item.id}`}\n >\n {item.icon && <Img className=\"adyen-checkout__dropdown__element__icon\" alt={item.name} src={item.icon} />}\n <span className=\"adyen-checkout__dropdown__element__text\">{item.name}</span>\n {item.secondaryText && <span className=\"adyen-checkout__dropdown__element__secondary-text\">{item.secondaryText}</span>}\n {selected && <Icon type={`${PREFIX}checkmark_black`} height={14} width={14} />}\n </li>\n );\n};\n\nexport default SelectListItem;\n"],"names":["SelectListItem","
|
|
1
|
+
{"version":3,"file":"SelectListItem.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectListItem.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { SelectItemProps } from '../types';\nimport Img from '../../../Img';\nimport Icon from '../../../Icon';\nimport { PREFIX } from '../../../Icon/constants';\n\nconst SelectListItem = ({ item, active, selected, ...props }: SelectItemProps) => {\n return (\n /* eslint-disable jsx-a11y/click-events-have-key-events */\n <li\n aria-disabled={!!item.disabled}\n aria-selected={selected}\n className={cx([\n 'adyen-checkout__dropdown__element',\n {\n 'adyen-checkout__dropdown__element--active': active,\n 'adyen-checkout__dropdown__element--disabled': !!item.disabled\n }\n ])}\n // A change in Preact v10.11.1 means that all falsy values are assessed and set on data attributes.\n // In the case of data-disabled we only ever want it set if item.disabled is actually true, since the presence of the data-disabled attr,\n // regardless of its value, will disable the select list item\n data-disabled={item.disabled === true ? true : null}\n data-value={item.id}\n onClick={props.onSelect}\n onMouseEnter={props.onHover}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role */\n role=\"option\"\n //tabIndex={-1}\n id={`listItem-${item.id}`}\n >\n {item.icon && <Img className=\"adyen-checkout__dropdown__element__icon\" alt={item.name} src={item.icon} />}\n <span className=\"adyen-checkout__dropdown__element__text\">{item.name}</span>\n {item.secondaryText && <span className=\"adyen-checkout__dropdown__element__secondary-text\">{item.secondaryText}</span>}\n {selected && <Icon type={`${PREFIX}checkmark_black`} height={14} width={14} />}\n </li>\n );\n};\n\nexport default SelectListItem;\n"],"names":["SelectListItem","_0","item","active","selected","props","h","li","aria-disabled","disabled","aria-selected","className","cx","data-disabled","data-value","id","onClick","onSelect","onMouseEnter","onHover","role","icon","Img","alt","name","src","span","secondaryText","Icon","type","PREFIX","height","width"],"mappings":"22BAOA,MAAMA,EAAiBC,IAAC,IAAAC,KAAEA,EAAIC,OAAEA,EAAMC,SAAEA,GAAqCH,EAAxBI,EAAAA,EAAAA,EAAAA,8BACjD,OAEIC,EAACC,KAAAA,CACGC,kBAAiBN,EAAKO,SACtBC,gBAAeN,EACfO,UAAWC,EAAG,CACV,oCACA,CACI,4CAA6CT,EAC7C,gDAAiDD,EAAKO,YAM9DI,iBAAiC,IAAlBX,EAAKO,UAA2B,KAC/CK,aAAYZ,EAAKa,GACjBC,QAASX,EAAMY,SACfC,aAAcb,EAAMc,QAEpBC,KAAK,SAELL,GAAI,YAAYb,EAAKa,MAEpBb,EAAKmB,MAAQf,EAACgB,EAAAA,CAAIX,UAAU,0CAA0CY,IAAKrB,EAAKsB,KAAMC,IAAKvB,EAAKmB,OACjGf,EAACoB,OAAAA,CAAKf,UAAU,2CAA2CT,EAAKsB,MAC/DtB,EAAKyB,eAAiBrB,EAACoB,OAAAA,CAAKf,UAAU,qDAAqDT,EAAKyB,eAChGvB,GAAYE,EAACsB,EAAAA,CAAKC,KAAM,GAAGC,mBAAyBC,OAAQ,GAAIC,MAAO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useRef as r,useCallback as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import l from"../FormFields/Field/Field.js";import a from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as p}from"../../../utils/setFocus.js";import f from"../DisclaimerMessage/DisclaimerMessage.js";import g from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as h}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b,UiTarget as j,InfoEventType as v}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";function
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useRef as r,useCallback as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import l from"../FormFields/Field/Field.js";import a from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as p}from"../../../utils/setFocus.js";import f from"../DisclaimerMessage/DisclaimerMessage.js";import g from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as h}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b,UiTarget as j,InfoEventType as v}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";function O(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function x(e,t){if(null==e)return{};var s,r,o,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(s=Reflect.ownKeys(e),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}if(n=function(e,t){if(null==e)return{};var s,r,o={},n=Object.getOwnPropertyNames(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s]);return o}(e,t),Object.getOwnPropertySymbols)for(s=Object.getOwnPropertySymbols(e),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}const C=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find(t=>t.id===e))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},S=["issuer"],w={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function F(F){let{items:I,placeholder:E,issuer:A,highlightedIds:P=[],showContextualElement:_,contextualText:M,selectFieldLabel:k}=F,R=x(F,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText","selectFieldLabel"]);const{i18n:T}=c(),{handleChangeFor:V,triggerValidation:L,data:N,valid:B,errors:D,isValid:K}=i({schema:S,defaultData:{issuer:A},rules:w}),[G,$]=s("ready"),[q,z]=s(1),{setSRMessagesFromObjects:H,shouldMoveFocusSR:J}=m(),Q=null==H?void 0:H({}),U=r(null);this.setStatus=e=>{$(e)};const W=o(e=>t=>{const s=1===e?j.list:j.featuredIssuer,r=I.find(e=>e.id===t.target.value),o=new b({component:R.type,type:v.selected,target:s,issuer:r.name});R.onSubmitAnalytics(o),z(e),V("issuer")(t)},[V,R.type]),X=o(e=>{if(e){const e=new b({component:R.type,type:v.displayed,target:j.list});R.onSubmitAnalytics(e)}},[R.type,R.onSubmitAnalytics]),Y=r(y(R.onSubmitAnalytics,h)),Z=o(()=>{Y.current({type:v.input,target:j.listSearch})},[]);n(()=>{R.onChange({data:N,valid:B,errors:D,isValid:K});const e=null==Q?void 0:Q({errors:D,isValidating:!0});(null==e?void 0:e.action)===d&&J&&p(U.current,"issuer-list")},[N,B,D,K]),this.showValidation=()=>{L()};const{highlightedItems:ee}=I.reduce((e,t)=>(P.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),r.forEach(function(t){O(e,t,s[t])})}return e}({},t)),e),{highlightedItems:[]});return e("div",{ref:U,className:"adyen-checkout__issuer-list"},!!ee.length&&e(t,null,e(a,{selectedIssuerId:0===q?N.issuer:null,items:ee,onChange:W(0)}),e(u,null)),e(l,{label:null!=k?k:T.get("issuerList.selectField.label"),errorMessage:(te=D.issuer,te&&te.errorMessage?T.get(te.errorMessage):!!te),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:_,contextualText:M},e(g,{items:I,selectedValue:1===q?N.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:W(1),onListToggle:X,onInput:Z})),R.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(f,{message:T.get(R.termsAndConditions.translationKey),urls:R.termsAndConditions.urls})),R.showPayButton&&R.payButton({status:G,label:C({issuer:N.issuer,items:[...I,...ee]},T)}));var te}F.defaultProps={onChange:()=>{}};export{F as default};
|
|
2
2
|
//# sourceMappingURL=IssuerList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport { ANALYTICS_SEARCH_DEBOUNCE_TIME } from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../../core/Analytics/events/AnalyticsInfoEvent';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({\n items,\n placeholder,\n issuer,\n highlightedIds = [],\n showContextualElement,\n contextualText,\n selectFieldLabel,\n ...props\n}: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? UiTarget.list : UiTarget.featuredIssuer;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.selected,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor, props.type]\n );\n\n const handleListToggle = useCallback(\n (isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.displayed,\n target: UiTarget.list\n });\n props.onSubmitAnalytics(event);\n }\n },\n [props.type, props.onSubmitAnalytics]\n );\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: InfoEventType.input, target: UiTarget.listSearch });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField(containerRef.current, 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div ref={containerRef} className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={selectFieldLabel ?? i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_param","placeholder","highlightedIds","showContextualElement","contextualText","selectFieldLabel","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","containerRef","useRef","this","newStatus","handleInputChange","useCallback","type","event","target","UiTarget","list","featuredIssuer","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","component","InfoEventType","selected","onSubmitAnalytics","handleListToggle","isOpen","displayed","debounceSearchAnalytics","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","input","listSearch","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","ref","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"0/CAsBA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAsCH,QAAzBC,EAAAA,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,UAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,aAI1CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAChBA,EAAKgB,YACLA,EAAWjB,OACXA,EAAMkB,eACNA,EAAiB,GAAEC,sBACnBA,EAAqBC,eACrBA,EAAcC,iBACdA,GAPgBL,EAQbM,EAAAA,EARaN,EAAA,CAChBf,QACAgB,cACAjB,SACAkB,iBACAC,wBACAC,iBACAC,qBAGA,MAAMnB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,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A,EAiH5B,CAEAlF,EAAW+F,aAAe,CACtBrC,SAAU"}
|
|
1
|
+
{"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport { ANALYTICS_SEARCH_DEBOUNCE_TIME } from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../../core/Analytics/events/AnalyticsInfoEvent';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({\n items,\n placeholder,\n issuer,\n highlightedIds = [],\n showContextualElement,\n contextualText,\n selectFieldLabel,\n ...props\n}: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? UiTarget.list : UiTarget.featuredIssuer;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.selected,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor, props.type]\n );\n\n const handleListToggle = useCallback(\n (isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.displayed,\n target: UiTarget.list\n });\n props.onSubmitAnalytics(event);\n }\n },\n [props.type, props.onSubmitAnalytics]\n );\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: InfoEventType.input, target: UiTarget.listSearch });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField(containerRef.current, 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div ref={containerRef} className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={selectFieldLabel ?? i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_0","placeholder","highlightedIds","showContextualElement","contextualText","selectFieldLabel","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","containerRef","useRef","this","newStatus","handleInputChange","useCallback","type","event","target","UiTarget","list","featuredIssuer","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","component","InfoEventType","selected","onSubmitAnalytics","handleListToggle","isOpen","displayed","debounceSearchAnalytics","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","input","listSearch","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","ref","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"uvDAsBA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAsCH,QAAzBC,EAAAA,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,UAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,aAI1CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAChBA,EAAKgB,YACLA,EAAWjB,OACXA,EAAMkB,eACNA,EAAiB,GAAEC,sBACnBA,EAAqBC,eACrBA,EAAcC,iBACdA,GAEcL,EADXM,EAAAA,EAAAA,EAAAA,+GAEH,MAAMpB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA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1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../_virtual/index.js";import{useModal as n}from"./useModal.js";function s(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../_virtual/index.js";import{useModal as n}from"./useModal.js";function s(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function l(e,r){if(null==e)return{};var t,o,n,s={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(t=Reflect.ownKeys(e),n=0;n<t.length;n++)o=t[n],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(s[o]=e[o]);return s}if(s=function(e,r){if(null==e)return{};var t,o,n={},s=Object.getOwnPropertyNames(e);for(o=0;o<s.length;o++)t=s[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t]);return n}(e,r),Object.getOwnPropertySymbols)for(t=Object.getOwnPropertySymbols(e),n=0;n<t.length;n++)o=t[n],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(s[o]=e[o]);return s}const i=i=>{let{children:a,classNameModifiers:c=[],isOpen:u,onClose:f,isDismissible:p=!0,labelledBy:d,describedBy:m,focusFirst:y,focusAfterClose:b}=i,O=l(i,["children","classNameModifiers","isOpen","onClose","isDismissible","labelledBy","describedBy","focusFirst","focusAfterClose"]);const h=r(),{closeModal:j,handleClickOutside:g}=n({modalElement:h.current,isOpen:u,isDismissible:p,focusFirst:y,focusAfterClose:b,onClose:f});return t(()=>{if(!h.current)return;const e=e=>{"Enter"!==e.key&&"Enter"!==e.code||e.stopPropagation()};return h.current.addEventListener("keypress",e,{capture:!0}),()=>{h.current.removeEventListener("keypress",e)}},[h.current]),e("div",function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(r){s(e,r,t[r])})}return e}({className:o("adyen-checkout__modal-wrapper",c.map(e=>`adyen-checkout__modal-wrapper--${e}`),{"adyen-checkout__modal-wrapper--open":u}),role:"dialog","aria-labelledby":d,"aria-describedby":m,"aria-modal":"true","aria-hidden":!u,onClick:g},O),e("div",{className:"adyen-checkout__modal",ref:h},a({onCloseModal:j})))};export{i as Modal};
|
|
2
2
|
//# sourceMappingURL=Modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":["../../../../../src/components/internal/Modal/Modal.tsx"],"sourcesContent":["import { ComponentChildren, h } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport cx from 'classnames';\nimport './Modal.scss';\nimport { useModal } from './useModal';\n\ntype ModalRenderFnProps = {\n /**\n * Function used to properly trigger the Modal close mechanism. It takes into account the element that the Modal needs\n * to set focus when it is dismissed.\n */\n onCloseModal(): void;\n};\n\ntype ModalProps = {\n children: ({ onCloseModal }: ModalRenderFnProps) => ComponentChildren;\n classNameModifiers?: string[];\n onClose(): void;\n isOpen: boolean;\n isDismissible?: boolean;\n labelledBy: string;\n describedBy: string;\n /**\n * Reference to the element that should be focused when the modal is opened\n */\n focusFirst: HTMLElement;\n /**\n * Reference to the element that should be focused when the modal is closed\n */\n focusAfterClose: HTMLElement;\n};\n\nconst Modal = ({\n children,\n classNameModifiers = [],\n isOpen,\n onClose,\n isDismissible = true,\n labelledBy,\n describedBy,\n focusFirst,\n focusAfterClose,\n ...props\n}: ModalProps) => {\n const modalContainerRef = useRef<HTMLDivElement>();\n const { closeModal, handleClickOutside } = useModal({\n modalElement: modalContainerRef.current,\n isOpen,\n isDismissible,\n focusFirst,\n focusAfterClose,\n onClose\n });\n\n /**\n * It shouldn't propagate ENTER key event to the parent component. This effect suppress the event propagation\n * (e.g. ENTER key press might trigger the payment flow for Card)\n */\n useEffect(() => {\n if (!modalContainerRef.current) return;\n\n const suppressKeyPress = (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.code === 'Enter') event.stopPropagation();\n };\n\n modalContainerRef.current.addEventListener('keypress', suppressKeyPress, { capture: true });\n return () => {\n modalContainerRef.current.removeEventListener('keypress', suppressKeyPress);\n };\n }, [modalContainerRef.current]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <div\n className={cx(\n 'adyen-checkout__modal-wrapper',\n classNameModifiers.map(m => `adyen-checkout__modal-wrapper--${m}`),\n { 'adyen-checkout__modal-wrapper--open': isOpen }\n )}\n role=\"dialog\"\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n aria-modal=\"true\"\n aria-hidden={!isOpen}\n onClick={handleClickOutside}\n {...props}\n >\n <div className=\"adyen-checkout__modal\" ref={modalContainerRef}>\n {children({ onCloseModal: closeModal })}\n </div>\n </div>\n );\n};\n\nexport { Modal };\n"],"names":["Modal","
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../../../../src/components/internal/Modal/Modal.tsx"],"sourcesContent":["import { ComponentChildren, h } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport cx from 'classnames';\nimport './Modal.scss';\nimport { useModal } from './useModal';\n\ntype ModalRenderFnProps = {\n /**\n * Function used to properly trigger the Modal close mechanism. It takes into account the element that the Modal needs\n * to set focus when it is dismissed.\n */\n onCloseModal(): void;\n};\n\ntype ModalProps = {\n children: ({ onCloseModal }: ModalRenderFnProps) => ComponentChildren;\n classNameModifiers?: string[];\n onClose(): void;\n isOpen: boolean;\n isDismissible?: boolean;\n labelledBy: string;\n describedBy: string;\n /**\n * Reference to the element that should be focused when the modal is opened\n */\n focusFirst: HTMLElement;\n /**\n * Reference to the element that should be focused when the modal is closed\n */\n focusAfterClose: HTMLElement;\n};\n\nconst Modal = ({\n children,\n classNameModifiers = [],\n isOpen,\n onClose,\n isDismissible = true,\n labelledBy,\n describedBy,\n focusFirst,\n focusAfterClose,\n ...props\n}: ModalProps) => {\n const modalContainerRef = useRef<HTMLDivElement>();\n const { closeModal, handleClickOutside } = useModal({\n modalElement: modalContainerRef.current,\n isOpen,\n isDismissible,\n focusFirst,\n focusAfterClose,\n onClose\n });\n\n /**\n * It shouldn't propagate ENTER key event to the parent component. This effect suppress the event propagation\n * (e.g. ENTER key press might trigger the payment flow for Card)\n */\n useEffect(() => {\n if (!modalContainerRef.current) return;\n\n const suppressKeyPress = (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.code === 'Enter') event.stopPropagation();\n };\n\n modalContainerRef.current.addEventListener('keypress', suppressKeyPress, { capture: true });\n return () => {\n modalContainerRef.current.removeEventListener('keypress', suppressKeyPress);\n };\n }, [modalContainerRef.current]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <div\n className={cx(\n 'adyen-checkout__modal-wrapper',\n classNameModifiers.map(m => `adyen-checkout__modal-wrapper--${m}`),\n { 'adyen-checkout__modal-wrapper--open': isOpen }\n )}\n role=\"dialog\"\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n aria-modal=\"true\"\n aria-hidden={!isOpen}\n onClick={handleClickOutside}\n {...props}\n >\n <div className=\"adyen-checkout__modal\" ref={modalContainerRef}>\n {children({ onCloseModal: closeModal })}\n </div>\n </div>\n );\n};\n\nexport { Modal };\n"],"names":["Modal","_0","children","classNameModifiers","isOpen","onClose","isDismissible","labelledBy","describedBy","focusFirst","focusAfterClose","props","modalContainerRef","useRef","closeModal","handleClickOutside","useModal","modalElement","current","useEffect","suppressKeyPress","event","key","code","stopPropagation","addEventListener","capture","removeEventListener","h","div","className","cx","map","m","role","aria-labelledby","aria-describedby","aria-modal","aria-hidden","onClick","ref","onCloseModal"],"mappings":"y9BAgCA,MAAMA,EAAQC,QAACC,SACXA,EAAQC,mBACRA,EAAqB,GAAEC,OACvBA,EAAMC,QACNA,EAAOC,cACPA,GAAgB,EAAIC,WACpBA,EAAUC,YACVA,EAAWC,WACXA,EAAUC,gBACVA,GAEST,EADNU,EAAAA,EAAAA,EAAAA,gIAEH,MAAMC,EAAoBC,KACpBC,WAAEA,EAAUC,mBAAEA,GAAuBC,EAAS,CAChDC,aAAcL,EAAkBM,QAChCd,SACAE,gBACAG,aACAC,kBACAL,YAoBJ,OAbAc,EAAU,KACN,IAAKP,EAAkBM,QAAS,OAEhC,MAAME,EAAoBC,IACJ,UAAdA,EAAMC,KAAkC,UAAfD,EAAME,MAAkBF,EAAMG,mBAI/D,OADAZ,EAAkBM,QAAQO,iBAAiB,WAAYL,EAAkB,CAAEM,SAAS,IAC7E,KACHd,EAAkBM,QAAQS,oBAAoB,WAAYP,KAE/D,CAACR,EAAkBM,UAIlBU,EAACC,wUAAAA,CAAAA,CACGC,UAAWC,EACP,gCACA5B,EAAmB6B,IAAIC,GAAK,kCAAkCA,KAC9D,CAAE,sCAAuC7B,IAE7C8B,KAAK,SACLC,kBAAiB5B,EACjB6B,mBAAkB5B,EAClB6B,aAAW,OACXC,eAAclC,EACdmC,QAASxB,GACLJ,GAEJiB,EAACC,MAAAA,CAAIC,UAAU,wBAAwBU,IAAK5B,GACvCV,EAAS,CAAEuC,aAAc3B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useState as s,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import n from"../CompanyDetails/CompanyDetails.js";import i from"../PersonalDetails/PersonalDetails.js";import a from"../Address/Address.js";import l from"../FormFields/Checkbox/Checkbox.js";import d from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as c,fieldsetsSchema as u,getActiveFieldsData as b}from"./utils.js";import p from"../IbanInput/IbanInput.js";import m from"../FormFields/Field/Field.js";import y from"../FormInstruction/FormInstruction.js";import f from"./useSRPanelForOpenInvoiceErrors.js";import v from"../../../_virtual/index.js";function h(e,r,s){return r in e?Object.defineProperty(e,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[r]=s,e}function C(e){for(var r=1;r<arguments.length;r++){var s=null!=arguments[r]?arguments[r]:{},o=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),o.forEach(function(r){h(e,r,s[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r.push.apply(r,s)}return r}(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))}),e}const A={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function k(h){var k,j;const{countryCode:
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useState as s,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import n from"../CompanyDetails/CompanyDetails.js";import i from"../PersonalDetails/PersonalDetails.js";import a from"../Address/Address.js";import l from"../FormFields/Checkbox/Checkbox.js";import d from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as c,fieldsetsSchema as u,getActiveFieldsData as b}from"./utils.js";import p from"../IbanInput/IbanInput.js";import m from"../FormFields/Field/Field.js";import y from"../FormInstruction/FormInstruction.js";import f from"./useSRPanelForOpenInvoiceErrors.js";import v from"../../../_virtual/index.js";function h(e,r,s){return r in e?Object.defineProperty(e,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[r]=s,e}function C(e){for(var r=1;r<arguments.length;r++){var s=null!=arguments[r]?arguments[r]:{},o=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),o.forEach(function(r){h(e,r,s[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r.push.apply(r,s)}return r}(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))}),e}const A={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function k(h){var k,j,D,O;const{countryCode:x,visibility:w}=h,{i18n:F}=t(),P=r({});var S;Object.keys(P.current).length||(null===(S=h.setComponentRef)||void 0===S||S.call(h,P.current));const R=r(!1),E=c(w,h.data),[I,q]=s(E),{current:V}=r(u.reduce((e,r)=>(e[r]=e=>{V[r].current=e},e),{})),M=!!h.consentCheckboxLabel,N=!M&&Object.keys(I).every(e=>!I[e]),_="editable"===w.deliveryAddress&&"hidden"!==w.billingAddress,[L,B]=s(C({},h.data,M&&{consentCheckbox:!1})),[z,G]=s({}),[H,J]=s({}),[K,Q]=s("ready");P.current.showValidation=()=>{R.current=!0,u.forEach(e=>{V[e].current&&V[e].current.showValidation()}),G(C({},M&&{consentCheckbox:L.consentCheckbox?null:A}))},P.current.setStatus=Q,f({errors:z,data:L,props:h,isValidating:R}),o(()=>{const e=Object.keys(I).every(e=>!I[e]||!!H[e]),r=!M||!!H.consentCheckbox,s=e&&r,o=b(I,L);h.onChange({data:o,errors:z,valid:H,isValid:s})},[L,I]);const T=e=>r=>{B(s=>g(C({},s),{[e]:r.data})),J(s=>g(C({},s),{[e]:r.isValid})),G(s=>g(C({},s),{[e]:r.errors}))};return e("div",{className:v({"adyen-checkout__open-invoice":!0,"adyen-checkout__open-invoice--loading":"loading"===K})},e(y,null),I.companyDetails&&e(n,{data:h.data.companyDetails,label:"companyDetails",onChange:T("companyDetails"),setComponentRef:V.companyDetails,visibility:w.companyDetails}),I.personalDetails&&e(i,{data:h.data.personalDetails,requiredFields:h.personalDetailsRequiredFields,label:"personalDetails",onChange:T("personalDetails"),setComponentRef:V.personalDetails,visibility:w.personalDetails}),I.bankAccount&&e(p,{holderName:!0,label:"ach.bankAccount",data:L.bankAccount,onChange:T("bankAccount"),ref:V.bankAccount}),I.billingAddress&&e(a,{allowedCountries:null!==(k=null==h||null===(D=h.billingAddressSpecification)||void 0===D?void 0:D.allowedCountries)&&void 0!==k?k:h.allowedCountries,countryCode:x,requiredFields:h.billingAddressRequiredFields,specifications:h.billingAddressSpecification,data:L.billingAddress,label:"billingAddress",onChange:T("billingAddress"),setComponentRef:V.billingAddress,visibility:w.billingAddress}),_&&e(m,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(l,{label:F.get("separateDeliveryAddress"),checked:I.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{q(e=>g(C({},e),{deliveryAddress:!I.deliveryAddress}))}})),I.deliveryAddress&&e(a,{allowedCountries:null!==(j=null==h||null===(O=h.deliveryAddressSpecification)||void 0===O?void 0:O.allowedCountries)&&void 0!==j?j:h.allowedCountries,countryCode:x,requiredFields:h.deliveryAddressRequiredFields,specifications:h.deliveryAddressSpecification,data:L.deliveryAddress,label:"deliveryAddress",onChange:T("deliveryAddress"),setComponentRef:V.deliveryAddress,visibility:w.deliveryAddress}),M&&e(d,{data:L,errorMessage:!!z.consentCheckbox,label:h.consentCheckboxLabel,onChange:e=>{const{checked:r}=e.target;B(e=>g(C({},e),{consentCheckbox:r})),J(e=>g(C({},e),{consentCheckbox:r})),G(e=>C({},e,{consentCheckbox:r?null:A}))},i18n:F}),h.showPayButton&&h.payButton({status:K,classNameModifiers:[...N?["standalone"]:[]],label:F.get("confirmPurchase")}))}export{k as default};
|
|
2
2
|
//# sourceMappingURL=OpenInvoice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport CompanyDetails from '../CompanyDetails';\nimport PersonalDetails from '../PersonalDetails';\nimport Address from '../Address';\nimport Checkbox from '../FormFields/Checkbox';\nimport ConsentCheckbox from '../FormFields/ConsentCheckbox';\nimport { getActiveFieldsData, getInitialActiveFieldsets, fieldsetsSchema } from './utils';\nimport {\n OpenInvoiceActiveFieldsets,\n OpenInvoiceFieldsetsRefs,\n OpenInvoiceProps,\n OpenInvoiceStateData,\n OpenInvoiceStateError,\n OpenInvoiceStateValid\n} from './types';\nimport './OpenInvoice.scss';\nimport IbanInput from '../IbanInput';\nimport { GenericError } from '../../../core/Errors/types';\nimport Field from '../FormFields/Field';\nimport FormInstruction from '../FormInstruction';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport useSRPanelForOpenInvoiceErrors from './useSRPanelForOpenInvoiceErrors';\nimport classNames from 'classnames';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: OpenInvoiceProps) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const openInvoiceRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(openInvoiceRef.current).length) {\n props.setComponentRef?.(openInvoiceRef.current);\n }\n\n const isValidating = useRef(false);\n\n const initialActiveFieldsets: OpenInvoiceActiveFieldsets = getInitialActiveFieldsets(visibility, props.data);\n const [activeFieldsets, setActiveFieldsets] = useState<OpenInvoiceActiveFieldsets>(initialActiveFieldsets);\n\n const { current: fieldsetsRefs } = useRef<OpenInvoiceFieldsetsRefs>(\n fieldsetsSchema.reduce((acc, fieldset) => {\n acc[fieldset] = ref => {\n fieldsetsRefs[fieldset].current = ref;\n };\n return acc;\n }, {})\n );\n\n const checkFieldsets = () => Object.keys(activeFieldsets).every(fieldset => !activeFieldsets[fieldset] || !!valid[fieldset]);\n const hasConsentCheckbox = !!props.consentCheckboxLabel;\n const isStandAloneButton = !hasConsentCheckbox && Object.keys(activeFieldsets).every(key => !activeFieldsets[key]);\n const showSeparateDeliveryAddressCheckbox = visibility.deliveryAddress === 'editable' && visibility.billingAddress !== 'hidden';\n\n const [data, setData] = useState<OpenInvoiceStateData>({\n ...props.data,\n ...(hasConsentCheckbox && { consentCheckbox: false })\n });\n const [errors, setErrors] = useState<OpenInvoiceStateError>({});\n const [valid, setValid] = useState<OpenInvoiceStateValid>({});\n const [status, setStatus] = useState('ready');\n\n // Expose methods expected by parent\n openInvoiceRef.current.showValidation = () => {\n isValidating.current = true;\n fieldsetsSchema.forEach(fieldset => {\n if (fieldsetsRefs[fieldset].current) fieldsetsRefs[fieldset].current.showValidation();\n });\n\n setErrors({\n ...(hasConsentCheckbox && { consentCheckbox: data.consentCheckbox ? null : consentCBErrorObj })\n });\n };\n\n openInvoiceRef.current.setStatus = setStatus;\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating });\n\n useEffect(() => {\n const fieldsetsAreValid: boolean = checkFieldsets();\n const consentCheckboxValid: boolean = !hasConsentCheckbox || !!valid.consentCheckbox;\n const isValid: boolean = fieldsetsAreValid && consentCheckboxValid;\n const newData: OpenInvoiceStateData = getActiveFieldsData(activeFieldsets, data);\n props.onChange({ data: newData, errors, valid, isValid });\n }, [data, activeFieldsets]);\n\n const handleFieldset = key => state => {\n setData(prevData => ({ ...prevData, [key]: state.data }));\n setValid(prevValid => ({ ...prevValid, [key]: state.isValid }));\n setErrors(prevErrors => ({ ...prevErrors, [key]: state.errors }));\n };\n\n const handleSeparateDeliveryAddress = () => {\n setActiveFieldsets(prevActiveFields => ({\n ...prevActiveFields,\n deliveryAddress: !activeFieldsets.deliveryAddress\n }));\n };\n\n const handleConsentCheckbox = e => {\n const { checked } = e.target;\n setData(prevData => ({ ...prevData, consentCheckbox: checked }));\n setValid(prevValid => ({ ...prevValid, consentCheckbox: checked }));\n setErrors(prevErrors => ({ ...prevErrors, ...{ consentCheckbox: !checked ? consentCBErrorObj : null } }));\n };\n return (\n <div\n className={classNames({\n 'adyen-checkout__open-invoice': true,\n 'adyen-checkout__open-invoice--loading': status === 'loading'\n })}\n >\n <FormInstruction />\n\n {activeFieldsets.companyDetails && (\n <CompanyDetails\n data={props.data.companyDetails}\n label=\"companyDetails\"\n onChange={handleFieldset('companyDetails')}\n setComponentRef={fieldsetsRefs.companyDetails}\n visibility={visibility.companyDetails}\n />\n )}\n\n {activeFieldsets.personalDetails && (\n <PersonalDetails\n data={props.data.personalDetails}\n requiredFields={props.personalDetailsRequiredFields}\n label=\"personalDetails\"\n onChange={handleFieldset('personalDetails')}\n setComponentRef={fieldsetsRefs.personalDetails}\n visibility={visibility.personalDetails}\n />\n )}\n\n {activeFieldsets.bankAccount && (\n <IbanInput\n holderName={true}\n label=\"ach.bankAccount\"\n data={data.bankAccount}\n onChange={handleFieldset('bankAccount')}\n ref={fieldsetsRefs.bankAccount}\n />\n )}\n\n {activeFieldsets.billingAddress && (\n <Address\n allowedCountries={props?.billingAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.billingAddressRequiredFields}\n specifications={props.billingAddressSpecification}\n data={data.billingAddress}\n label=\"billingAddress\"\n onChange={handleFieldset('billingAddress')}\n setComponentRef={fieldsetsRefs.billingAddress}\n visibility={visibility.billingAddress}\n />\n )}\n\n {showSeparateDeliveryAddressCheckbox && (\n <Field\n classNameModifiers={['separateDeliveryAddress', 'consentCheckbox']}\n name={'separateDeliveryAddress'}\n useLabelElement={false}\n showErrorElement={false}\n >\n <Checkbox\n label={i18n.get('separateDeliveryAddress')}\n checked={activeFieldsets.deliveryAddress}\n classNameModifiers={['separateDeliveryAddress']}\n name={'separateDeliveryAddress'}\n onChange={handleSeparateDeliveryAddress}\n />\n </Field>\n )}\n\n {activeFieldsets.deliveryAddress && (\n <Address\n allowedCountries={props?.deliveryAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.deliveryAddressRequiredFields}\n specifications={props.deliveryAddressSpecification}\n data={data.deliveryAddress}\n label=\"deliveryAddress\"\n onChange={handleFieldset('deliveryAddress')}\n setComponentRef={fieldsetsRefs.deliveryAddress}\n visibility={visibility.deliveryAddress}\n />\n )}\n\n {hasConsentCheckbox && (\n <ConsentCheckbox\n data={data}\n errorMessage={!!errors.consentCheckbox}\n label={props.consentCheckboxLabel}\n onChange={handleConsentCheckbox}\n i18n={i18n}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n classNameModifiers: [...(isStandAloneButton ? ['standalone'] : [])],\n label: i18n.get('confirmPurchase')\n })}\n </div>\n );\n}\n"],"names":["consentCBErrorObj","isValid","errorMessage","error","OpenInvoice","props","countryCode","visibility","i18n","useCoreContext","openInvoiceRef","useRef","Object","keys","current","length","setComponentRef","isValidating","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","_object_spread","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","showValidation","forEach","useSRPanelForOpenInvoiceErrors","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","_object_spread_props","prevValid","prevErrors","h","div","className","classNames","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"smDA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,OA2HEA,EA+BAA,EAzJlC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAGXC,EAAiBC,EAA4B,IAG/CN,IAAAA,EADCO,OAAOC,KAAKH,EAAeI,SAASC,SAChB,QAArBV,EAAAA,EAAMW,2BAANX,GAAAA,EAAAA,KAAAA,EAAwBK,EAAeI,UAG3C,MAAMG,EAAeN,GAAO,GAEtBO,EAAqDC,EAA0BZ,EAAYF,EAAMe,OAChGC,EAAiBC,GAAsBC,EAAqCL,IAE3EJ,QAASU,GAAkBb,EAC/Bc,EAAgBC,OAAO,CAACC,EAAKC,KACzBD,EAAIC,GAAYC,IACZL,EAAcI,GAAUd,QAAUe,GAE/BF,GACR,CAAA,IAIDG,IAAuBzB,EAAM0B,qBAC7BC,GAAsBF,GAAsBlB,OAAOC,KAAKQ,GAAiBY,MAAMC,IAAQb,EAAgBa,IACvGC,EAAqE,aAA/B5B,EAAW6B,iBAAgE,WAA9B7B,EAAW8B,gBAE7FjB,EAAMkB,GAAWf,EAA+BgB,EAAA,GAChDlC,EAAMe,KACLU,GAAsB,CAAEU,iBAAiB,MAE1CC,EAAQC,GAAanB,EAAgC,CAAA,IACrDoB,EAAOC,GAAYrB,EAAgC,CAAA,IACnDsB,EAAQC,GAAavB,EAAS,SAGrCb,EAAeI,QAAQiC,eAAiB,KACpC9B,EAAaH,SAAU,EACvBW,EAAgBuB,QAAQpB,IAChBJ,EAAcI,GAAUd,SAASU,EAAcI,GAAUd,QAAQ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OD,gBACvB6B,MAAOhE,EAAM0B,qBACbwB,SAhGcuC,IAC1B,MAAML,QAAEA,GAAYK,EAAEC,OACtBzD,EAAQoB,GAAaC,EAAApB,EAAA,CAAA,EAAKmB,GAAAA,CAAUlB,gBAAiBiD,KACrD7C,EAASgB,GAAcD,EAAApB,EAAA,CAAA,EAAKqB,GAAAA,CAAWpB,gBAAiBiD,KACxD/C,EAAUmB,GAAetB,EAAA,CAAA,EAAKsB,EAAe,CAAErB,gBAAkBiD,EAA8B,KAApBzF,MA6F/DQ,KAAMA,IAIbH,EAAM2F,eACH3F,EAAM4F,UAAU,CACZpD,SACAsC,mBAAoB,IAAKnD,EAAqB,CAAC,cAAgB,IAC/DqC,MAAO7D,EAAKgF,IAAI,qBAIpC"}
|
|
1
|
+
{"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport CompanyDetails from '../CompanyDetails';\nimport PersonalDetails from '../PersonalDetails';\nimport Address from '../Address';\nimport Checkbox from '../FormFields/Checkbox';\nimport ConsentCheckbox from '../FormFields/ConsentCheckbox';\nimport { getActiveFieldsData, getInitialActiveFieldsets, fieldsetsSchema } from './utils';\nimport {\n OpenInvoiceActiveFieldsets,\n OpenInvoiceFieldsetsRefs,\n OpenInvoiceProps,\n OpenInvoiceStateData,\n OpenInvoiceStateError,\n OpenInvoiceStateValid\n} from './types';\nimport './OpenInvoice.scss';\nimport IbanInput from '../IbanInput';\nimport { GenericError } from '../../../core/Errors/types';\nimport Field from '../FormFields/Field';\nimport FormInstruction from '../FormInstruction';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport useSRPanelForOpenInvoiceErrors from './useSRPanelForOpenInvoiceErrors';\nimport classNames from 'classnames';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: OpenInvoiceProps) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const openInvoiceRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(openInvoiceRef.current).length) {\n props.setComponentRef?.(openInvoiceRef.current);\n }\n\n const isValidating = useRef(false);\n\n const initialActiveFieldsets: OpenInvoiceActiveFieldsets = getInitialActiveFieldsets(visibility, props.data);\n const [activeFieldsets, setActiveFieldsets] = useState<OpenInvoiceActiveFieldsets>(initialActiveFieldsets);\n\n const { current: fieldsetsRefs } = useRef<OpenInvoiceFieldsetsRefs>(\n fieldsetsSchema.reduce((acc, fieldset) => {\n acc[fieldset] = ref => {\n fieldsetsRefs[fieldset].current = ref;\n };\n return acc;\n }, {})\n );\n\n const checkFieldsets = () => Object.keys(activeFieldsets).every(fieldset => !activeFieldsets[fieldset] || !!valid[fieldset]);\n const hasConsentCheckbox = !!props.consentCheckboxLabel;\n const isStandAloneButton = !hasConsentCheckbox && Object.keys(activeFieldsets).every(key => !activeFieldsets[key]);\n const showSeparateDeliveryAddressCheckbox = visibility.deliveryAddress === 'editable' && visibility.billingAddress !== 'hidden';\n\n const [data, setData] = useState<OpenInvoiceStateData>({\n ...props.data,\n ...(hasConsentCheckbox && { consentCheckbox: false })\n });\n const [errors, setErrors] = useState<OpenInvoiceStateError>({});\n const [valid, setValid] = useState<OpenInvoiceStateValid>({});\n const [status, setStatus] = useState('ready');\n\n // Expose methods expected by parent\n openInvoiceRef.current.showValidation = () => {\n isValidating.current = true;\n fieldsetsSchema.forEach(fieldset => {\n if (fieldsetsRefs[fieldset].current) fieldsetsRefs[fieldset].current.showValidation();\n });\n\n setErrors({\n ...(hasConsentCheckbox && { consentCheckbox: data.consentCheckbox ? null : consentCBErrorObj })\n });\n };\n\n openInvoiceRef.current.setStatus = setStatus;\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating });\n\n useEffect(() => {\n const fieldsetsAreValid: boolean = checkFieldsets();\n const consentCheckboxValid: boolean = !hasConsentCheckbox || !!valid.consentCheckbox;\n const isValid: boolean = fieldsetsAreValid && consentCheckboxValid;\n const newData: OpenInvoiceStateData = getActiveFieldsData(activeFieldsets, data);\n props.onChange({ data: newData, errors, valid, isValid });\n }, [data, activeFieldsets]);\n\n const handleFieldset = key => state => {\n setData(prevData => ({ ...prevData, [key]: state.data }));\n setValid(prevValid => ({ ...prevValid, [key]: state.isValid }));\n setErrors(prevErrors => ({ ...prevErrors, [key]: state.errors }));\n };\n\n const handleSeparateDeliveryAddress = () => {\n setActiveFieldsets(prevActiveFields => ({\n ...prevActiveFields,\n deliveryAddress: !activeFieldsets.deliveryAddress\n }));\n };\n\n const handleConsentCheckbox = e => {\n const { checked } = e.target;\n setData(prevData => ({ ...prevData, consentCheckbox: checked }));\n setValid(prevValid => ({ ...prevValid, consentCheckbox: checked }));\n setErrors(prevErrors => ({ ...prevErrors, ...{ consentCheckbox: !checked ? consentCBErrorObj : null } }));\n };\n return (\n <div\n className={classNames({\n 'adyen-checkout__open-invoice': true,\n 'adyen-checkout__open-invoice--loading': status === 'loading'\n })}\n >\n <FormInstruction />\n\n {activeFieldsets.companyDetails && (\n <CompanyDetails\n data={props.data.companyDetails}\n label=\"companyDetails\"\n onChange={handleFieldset('companyDetails')}\n setComponentRef={fieldsetsRefs.companyDetails}\n visibility={visibility.companyDetails}\n />\n )}\n\n {activeFieldsets.personalDetails && (\n <PersonalDetails\n data={props.data.personalDetails}\n requiredFields={props.personalDetailsRequiredFields}\n label=\"personalDetails\"\n onChange={handleFieldset('personalDetails')}\n setComponentRef={fieldsetsRefs.personalDetails}\n visibility={visibility.personalDetails}\n />\n )}\n\n {activeFieldsets.bankAccount && (\n <IbanInput\n holderName={true}\n label=\"ach.bankAccount\"\n data={data.bankAccount}\n onChange={handleFieldset('bankAccount')}\n ref={fieldsetsRefs.bankAccount}\n />\n )}\n\n {activeFieldsets.billingAddress && (\n <Address\n allowedCountries={props?.billingAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.billingAddressRequiredFields}\n specifications={props.billingAddressSpecification}\n data={data.billingAddress}\n label=\"billingAddress\"\n onChange={handleFieldset('billingAddress')}\n setComponentRef={fieldsetsRefs.billingAddress}\n visibility={visibility.billingAddress}\n />\n )}\n\n {showSeparateDeliveryAddressCheckbox && (\n <Field\n classNameModifiers={['separateDeliveryAddress', 'consentCheckbox']}\n name={'separateDeliveryAddress'}\n useLabelElement={false}\n showErrorElement={false}\n >\n <Checkbox\n label={i18n.get('separateDeliveryAddress')}\n checked={activeFieldsets.deliveryAddress}\n classNameModifiers={['separateDeliveryAddress']}\n name={'separateDeliveryAddress'}\n onChange={handleSeparateDeliveryAddress}\n />\n </Field>\n )}\n\n {activeFieldsets.deliveryAddress && (\n <Address\n allowedCountries={props?.deliveryAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.deliveryAddressRequiredFields}\n specifications={props.deliveryAddressSpecification}\n data={data.deliveryAddress}\n label=\"deliveryAddress\"\n onChange={handleFieldset('deliveryAddress')}\n setComponentRef={fieldsetsRefs.deliveryAddress}\n visibility={visibility.deliveryAddress}\n />\n )}\n\n {hasConsentCheckbox && (\n <ConsentCheckbox\n data={data}\n errorMessage={!!errors.consentCheckbox}\n label={props.consentCheckboxLabel}\n onChange={handleConsentCheckbox}\n i18n={i18n}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n classNameModifiers: [...(isStandAloneButton ? ['standalone'] : [])],\n label: i18n.get('confirmPurchase')\n })}\n </div>\n );\n}\n"],"names":["consentCBErrorObj","isValid","errorMessage","error","OpenInvoice","props","countryCode","visibility","i18n","useCoreContext","openInvoiceRef","useRef","Object","keys","current","length","setComponentRef","isValidating","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","_object_spread","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","showValidation","forEach","useSRPanelForOpenInvoiceErrors","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","_object_spread_props","prevValid","prevErrors","h","div","className","classNames","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","_ref","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","_ref1","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"smDA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,WA2HEA,EA+BAA,EAzJlC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAGXC,EAAiBC,EAA4B,IAG/CN,IAAAA,EADCO,OAAOC,KAAKH,EAAeI,SAASC,SAChB,QAArBV,EAAAA,EAAMW,2BAANX,GAAAA,EAAAA,KAAAA,EAAwBK,EAAeI,UAG3C,MAAMG,EAAeN,GAAO,GAEtBO,EAAqDC,EAA0BZ,EAAYF,EAAMe,OAChGC,EAAiBC,GAAsBC,EAAqCL,IAE3EJ,QAASU,GAAkBb,EAC/Bc,EAAgBC,OAAO,CAACC,EAAKC,KACzBD,EAAIC,GAAYC,IACZL,EAAcI,GAAUd,QAAUe,GAE/BF,GACR,CAAA,IAIDG,IAAuBzB,EAAM0B,qBAC7BC,GAAsBF,GAAsBlB,OAAOC,KAAKQ,GAAiBY,MAAMC,IAAQb,EAAgBa,IACvGC,EAAqE,aAA/B5B,EAAW6B,iBAAgE,WA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OAAAA,EAAAA,EAAqCyE,wBAAgB,IAAAc,EAAAA,EAAIvF,EAAMyE,iBACjFxE,YAAaA,EACbkE,eAAgBnE,EAAMyF,8BACtBZ,eAAgB7E,EAAMwF,6BACtBzE,KAAMA,EAAKgB,gBACXiC,MAAM,kBACNd,SAAUC,EAAe,mBACzBxC,gBAAiBQ,EAAcY,gBAC/B7B,WAAYA,EAAW6B,kBAI9BN,GACGgC,EAACiC,EAAAA,CACG3E,KAAMA,EACNlB,eAAgBuC,EAAOD,gBACvB6B,MAAOhE,EAAM0B,qBACbwB,SAhGcyC,IAC1B,MAAMN,QAAEA,GAAYM,EAAEC,OACtB3D,EAAQoB,GAAaC,EAAApB,EAAA,CAAA,EAAKmB,GAAAA,CAAUlB,gBAAiBkD,KACrD9C,EAASgB,GAAcD,EAAApB,EAAA,CAAA,EAAKqB,GAAAA,CAAWpB,gBAAiBkD,KACxDhD,EAAUmB,GAAetB,EAAA,CAAA,EAAKsB,EAAe,CAAErB,gBAAkBkD,EAA8B,KAApB1F,MA6F/DQ,KAAMA,IAIbH,EAAM6F,eACH7F,EAAM8F,UAAU,CACZtD,SACAuC,mBAAoB,IAAKpD,EAAqB,CAAC,cAAgB,IAC/DqC,MAAO7D,EAAKiF,IAAI,qBAIpC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as e,useMemo as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as t}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as s}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as l}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as
|
|
1
|
+
import{useState as e,useMemo as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as t}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as s}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as l}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as n,ERROR_ACTION_FOCUS_FIELD as i}from"../../../core/Errors/constants.js";import c from"../../../core/Errors/useSRPanelContext.js";import a from"../Address/Specifications.js";import{setFocusOnField as d}from"../../../utils/setFocus.js";import{usePrevious as u}from"../../../utils/hookUtils.js";import{getArrayDifferences as f}from"../../../utils/arrayUtils.js";import{mapFieldKey as p}from"./utils.js";function y(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function m(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),t.forEach(function(r){y(e,r,o[r])})}return e}function b(e,r){if(null==e)return{};var o,t,s,l={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(e),s=0;s<o.length;s++)t=o[s],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(l[t]=e[t]);return l}if(l=function(e,r){if(null==e)return{};var o,t,s={},l=Object.getOwnPropertyNames(e);for(t=0;t<l.length;t++)o=l[t],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(s[o]=e[o]);return s}(e,r),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(e),s=0;s<o.length;s++)t=o[s],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(l[t]=e[t]);return l}const v=({errors:y,data:v,props:g,isValidating:j})=>{const[O,h]=e(null),A=u(O),{setSRMessagesFromObjects:F,setSRMessagesFromStrings:S,clearSRPanel:w,shouldMoveFocusSR:k}=c(),P=null==F?void 0:F({fieldTypeMappingFn:p}),D=r(()=>new a,[]),E=r(()=>new a(g.deliveryAddressSpecification),[]);o(()=>{try{var e,r,o,c,a;const u="deliveryAddress:",p="billingAddress:",{companyDetails:O,personalDetails:F,bankAccount:C,billingAddress:R,deliveryAddress:x}=y,T=b(y,["companyDetails","personalDetails","bankAccount","billingAddress","deliveryAddress"]),M=t(R,p),$=t(x,u),L=m({},"object"==typeof O&&O,"object"==typeof F&&F,"object"==typeof C&&C,"object"==typeof M&&M,"object"==typeof $&&$,T),_=s,I=null!==(e=g.personalDetailsRequiredFields)&&void 0!==e?e:l,K=l.filter(e=>null==I?void 0:I.includes(e)),U=["holder","iban"],V=D.getAddressSchemaForCountryFlat(null===(r=v.billingAddress)||void 0===r?void 0:r.country).map(e=>`${p}${e}`),q=E.getAddressSchemaForCountryFlat(null===(o=v.deliveryAddress)||void 0===o?void 0:o.country).map(e=>`${u}${e}`),B=_.concat(K,U,V,q,["consentCheckbox"]),N=D.getAddressLabelsForCountry(null===(c=v.billingAddress)||void 0===c?void 0:c.country),z=E.getAddressLabelsForCountry(null===(a=v.deliveryAddress)||void 0===a?void 0:a.country),G=null==P?void 0:P({errors:L,isValidating:j.current,layout:B,countrySpecificLabels:m({},N,z)}),H=null==G?void 0:G.currentErrorsSortedByLayout;switch(h(H),null==G?void 0:G.action){case i:{const e=G.fieldToFocus.includes(":")?G.fieldToFocus.split(":")[1]:G.fieldToFocus;let r="";const o=G.fieldToFocus.includes(":")?G.fieldToFocus.split(":")[0]:"";o.length&&(r=`.adyen-checkout__fieldset--${o} `),k&&d(".adyen-checkout__open-invoice",e,r),setTimeout(()=>{j.current=!1},300);break}case n:{const e=f(H,A,"field"),r=null==e?void 0:e[0];if(r){const e="shopperEmail"===r.field&&"field.error.invalid"===r.errorCode?r.errorMessage:null;S(e)}else w();break}}}catch(e){}},[y,v])};export{v as default};
|
|
2
2
|
//# sourceMappingURL=useSRPanelForOpenInvoiceErrors.js.map
|
package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSRPanelForOpenInvoiceErrors.js","sources":["../../../../../src/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.ts"],"sourcesContent":["import { useEffect, useState, useMemo, MutableRef } from 'preact/hooks';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { mapFieldKey } from './utils';\nimport { OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError } from './types';\n\ninterface UseSRPanelForErrorsProps {\n errors: OpenInvoiceStateError;\n data: OpenInvoiceStateData;\n props: OpenInvoiceProps;\n isValidating: MutableRef<boolean>;\n}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD: {\n /**\n * For prefixed fields (ones that can occur twice but in different contexts i.e. billingAddress & deliveryAddress) - consider the prefix...\n */\n // ...Firstly strip it to gain a \"clean\" reference to the field...\n const fieldToFocus = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[1] : srPanelResp.fieldToFocus; // country, street etc\n\n // ...Secondly use the prefix to add context for when we try to select it\n let focusContextSelector = '';\n const focusContext = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[0] : ''; // 'billingAddress' | 'deliveryAddress'\n if (focusContext.length) {\n focusContextSelector = `.adyen-checkout__fieldset--${focusContext} `;\n }\n\n // Focus first field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__open-invoice', fieldToFocus, focusContextSelector);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n }\n\n /**\n * Relates to errors triggered by a field blurring (some pm forms have this, some don't) - check if there is an error to either set or to clear\n */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.field === 'shopperEmail' && latestErrorMsg.errorCode === 'field.error.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors, data]);\n};\n\nexport default useSRPanelForOpenInvoiceErrors;\n"],"names":["useSRPanelForOpenInvoiceErrors","errors","data","props","isValidating","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","_object_spread","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","split","focusContextSelector","focusContext","length","setFocusOnField","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","field","errorCode","errorMessage","_"],"mappings":"6iDAsBA,MAAMA,EAAiC,EAAGC,SAAQC,OAAMC,QAAOC,mBAE3D,MAAOC,EAAiBC,GAAsBC,EAAS,MAEjDC,EAAuBC,EAAYJ,IACnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAE1FC,EAAuCL,aAAAA,EAAAA,EAA2B,CACpEM,mBAAoBC,IAGlBC,EAA+BC,EAAQ,IAAM,IAAIC,EAAkB,IACnEC,EAAgCF,EAAQ,IAAM,IAAIC,EAAejB,EAAMmB,8BAA+B,IAE5GC,EAAU,KACN,IAsC6FrB,IAAAA,EAIEA,EAYGA,EACEA,EAtDhG,MAAMsB,EAA0B,mBAC1BC,EAAyB,mBAK3BC,eAAgBC,EAChBC,gBAAiBC,EACjBC,YAAaC,EACbC,eAAgBC,EAChBC,gBAAiBC,GAEjBlC,EADGmC,EAAAA,EACHnC,EAAAA,CANAyB,iBACAE,kBACAE,cACAE,iBACAE,oBAMEG,EAA+BC,EAAuBL,EAA+BR,GACrFc,EAAgCD,EAAuBH,EAAgCX,GA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IAAIE,EAAuB,GAC3B,MAAMC,EAAeV,EAAYO,aAAapB,SAAS,KAAOa,EAAYO,aAAaC,MAAM,KAAK,GAAK,GACnGE,EAAaC,SACbF,EAAuB,8BAA8BC,MAIrD5D,GAAmB8D,EAAgB,gCAAiCL,EAAcE,GAEtFI,WAAW,KACPxE,EAAa4D,SAAU,GACxB,KACH,KACJ,CAKA,KAAKa,EAA4B,CAC7B,MAAMC,EAAaC,EAAoBZ,EAA6B3D,EAAsB,SAEpFwE,EAAiBF,aAAAA,EAAAA,EAAa,GAEpC,GAAIE,EAAgB,CAEhB,MAGMC,EAH4C,iBAAzBD,EAAeE,OAAyD,wBAA7BF,EAAeG,UAG1CH,EAAeI,aAAe,KACvEzE,EAAyBsE,EAC7B,MAEIrE,IAGJ,KACJ,EAIR,CAAE,MAAOyE,GAET,GACD,CAACpF,EAAQC"}
|
|
1
|
+
{"version":3,"file":"useSRPanelForOpenInvoiceErrors.js","sources":["../../../../../src/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.ts"],"sourcesContent":["import { useEffect, useState, useMemo, MutableRef } from 'preact/hooks';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { mapFieldKey } from './utils';\nimport { OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError } from './types';\n\ninterface UseSRPanelForErrorsProps {\n errors: OpenInvoiceStateError;\n data: OpenInvoiceStateData;\n props: OpenInvoiceProps;\n isValidating: MutableRef<boolean>;\n}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD: {\n /**\n * For prefixed fields (ones that can occur twice but in different contexts i.e. billingAddress & deliveryAddress) - consider the prefix...\n */\n // ...Firstly strip it to gain a \"clean\" reference to the field...\n const fieldToFocus = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[1] : srPanelResp.fieldToFocus; // country, street etc\n\n // ...Secondly use the prefix to add context for when we try to select it\n let focusContextSelector = '';\n const focusContext = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[0] : ''; // 'billingAddress' | 'deliveryAddress'\n if (focusContext.length) {\n focusContextSelector = `.adyen-checkout__fieldset--${focusContext} `;\n }\n\n // Focus first field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__open-invoice', fieldToFocus, focusContextSelector);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n }\n\n /**\n * Relates to errors triggered by a field blurring (some pm forms have this, some don't) - check if there is an error to either set or to clear\n */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.field === 'shopperEmail' && latestErrorMsg.errorCode === 'field.error.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors, data]);\n};\n\nexport default useSRPanelForOpenInvoiceErrors;\n"],"names":["useSRPanelForOpenInvoiceErrors","errors","data","props","isValidating","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","_object_spread","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","split","focusContextSelector","focusContext","length","setFocusOnField","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","field","errorCode","errorMessage","_"],"mappings":"0yDAsBA,MAAMA,EAAiC,EAAGC,SAAQC,OAAMC,QAAOC,mBAE3D,MAAOC,EAAiBC,GAAsBC,EAAS,MAEjDC,EAAuBC,E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,QAAnB3D,EAAAA,EAAK8B,sBAAL9B,IAAAA,OAAAA,EAAAA,EAAqBoD,SAC7GQ,EAAiCzC,EAA8BwC,2BAA+C,QAApB3D,EAAAA,EAAKgC,uBAALhC,IAAAA,OAAAA,EAAAA,EAAsBoD,SAGhHS,EAAyChD,aAAAA,EAAAA,EAAgB,CAC3Dd,OAAQuC,EACRpC,aAAcA,EAAa4D,QAC3BC,OAAQP,EACRQ,sBAAuBzB,KAAKmB,EAAkCE,KAI5DK,EAA8BJ,aAAAA,EAAAA,EAAaI,4BAQjD,OALA7D,EAAmB6D,GAKXJ,aAAAA,EAAAA,EAAaK,QAEjB,KAAKC,EAA0B,CAK3B,MAAMC,EAAeP,EAAYO,aAAapB,SAAS,KAAOa,EAAYO,aAAaC,MAAM,KAAK,GAAKR,EAAYO,aAGnH,IAAIE,EAAuB,GAC3B,MAAMC,EAAeV,EAAYO,aAAapB,SAAS,KAAOa,EAAYO,aAAaC,MAAM,KAAK,GAAK,GACnGE,EAAaC,SACbF,EAAuB,8BAA8BC,MAIrD5D,GAAmB8D,EAAgB,gCAAiCL,EAAcE,GAEtFI,WAAW,KACPxE,EAAa4D,SAAU,GACxB,KACH,KACJ,CAKA,KAAKa,EAA4B,CAC7B,MAAMC,EAAaC,EAAoBZ,EAA6B3D,EAAsB,SAEpFwE,EAAiBF,aAAAA,EAAAA,EAAa,GAEpC,GAAIE,EAAgB,CAEhB,MAGMC,EAH4C,iBAAzBD,EAAeE,OAAyD,wBAA7BF,EAAeG,UAG1CH,EAAeI,aAAe,KACvEzE,EAAyBsE,EAC7B,MAEIrE,IAGJ,KACJ,EAIR,CAAE,MAAOyE,GAET,GACD,CAACpF,EAAQC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../Button/Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{payAmountLabel as n,secondaryAmountLabel as o}from"./utils.js";import
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../Button/Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{payAmountLabel as n,secondaryAmountLabel as o}from"./utils.js";import l from"./components/SecondaryButtonLabel.js";function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function i(e,t){if(null==e)return{};var r,n,o,l={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(e),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}if(l=function(e,t){if(null==e)return{};var r,n,o={},l=Object.getOwnPropertyNames(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}const s=s=>{let{amount:u,secondaryAmount:p,classNameModifiers:f=[],label:b}=s,y=i(s,["amount","secondaryAmount","classNameModifiers","label"]);const{i18n:O}=r(),m=u&&{}.hasOwnProperty.call(u,"value")&&0===u.value,j=m?O.get("confirmPreauthorization"):n(O,u),d=u&&"number"==typeof u.value&&!!u.currency,g=p&&Object.keys(p).length>0,P=!m&&!b&&d&&g?o(O,p):null;return e(t,a(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){c(e,t,r[t])})}return e}({},y),{disabled:y.disabled||"loading"===y.status,classNameModifiers:[...f,"pay"],label:b||j}),P&&e(l,{label:P}))};export{s as default,n as payAmountLabel};
|
|
2
2
|
//# sourceMappingURL=PayButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayButton.js","sources":["../../../../../src/components/internal/PayButton/PayButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps } from '../Button/types';\nimport { payAmountLabel, secondaryAmountLabel } from './utils';\nimport { PaymentAmountExtended } from '../../../types/global-types';\nimport SecondaryButtonLabel from './components/SecondaryButtonLabel';\n\nexport interface PayButtonProps extends ButtonProps {\n /**\n * Class name modifiers will be used as: `adyen-checkout__image--${modifier}`\n */\n classNameModifiers?: string[];\n label?: string;\n amount?: PaymentAmountExtended;\n secondaryAmount?: PaymentAmountExtended;\n status?: string;\n disabled?: boolean;\n icon?: string;\n onClick?: (e: h.JSX.TargetedMouseEvent<HTMLButtonElement>) => void;\n}\n\nconst PayButton = ({ amount, secondaryAmount, classNameModifiers = [], label, ...props }: PayButtonProps) => {\n const { i18n } = useCoreContext();\n const isZeroAuth = amount && {}.hasOwnProperty.call(amount, 'value') && amount.value === 0;\n const defaultLabel = isZeroAuth ? i18n.get('confirmPreauthorization') : payAmountLabel(i18n, amount);\n\n /**\n * Show the secondaryLabel if:\n * - it's not zero auth, and\n * - we don't have a predefined label (i.e. redirect, qrcode, await based comps...), and\n * - we do have an amount object (merchant might not be passing this in order to not show the amount on the button), and\n * - we have a secondaryAmount object with some properties\n */\n const hasValidAmount = amount && typeof amount.value === 'number' && !!amount.currency;\n const hasSecondaryAmount = secondaryAmount && Object.keys(secondaryAmount).length > 0;\n\n const secondaryLabel = !isZeroAuth && !label && hasValidAmount && hasSecondaryAmount ? secondaryAmountLabel(i18n, secondaryAmount) : null;\n\n return (\n <Button\n {...props}\n disabled={props.disabled || props.status === 'loading'}\n classNameModifiers={[...classNameModifiers, 'pay']}\n label={label || defaultLabel}\n >\n {secondaryLabel && <SecondaryButtonLabel label={secondaryLabel} />}\n </Button>\n );\n};\n\nexport default PayButton;\nexport { payAmountLabel };\n"],"names":["PayButton","
|
|
1
|
+
{"version":3,"file":"PayButton.js","sources":["../../../../../src/components/internal/PayButton/PayButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps } from '../Button/types';\nimport { payAmountLabel, secondaryAmountLabel } from './utils';\nimport { PaymentAmountExtended } from '../../../types/global-types';\nimport SecondaryButtonLabel from './components/SecondaryButtonLabel';\n\nexport interface PayButtonProps extends ButtonProps {\n /**\n * Class name modifiers will be used as: `adyen-checkout__image--${modifier}`\n */\n classNameModifiers?: string[];\n label?: string;\n amount?: PaymentAmountExtended;\n secondaryAmount?: PaymentAmountExtended;\n status?: string;\n disabled?: boolean;\n icon?: string;\n onClick?: (e: h.JSX.TargetedMouseEvent<HTMLButtonElement>) => void;\n}\n\nconst PayButton = ({ amount, secondaryAmount, classNameModifiers = [], label, ...props }: PayButtonProps) => {\n const { i18n } = useCoreContext();\n const isZeroAuth = amount && {}.hasOwnProperty.call(amount, 'value') && amount.value === 0;\n const defaultLabel = isZeroAuth ? i18n.get('confirmPreauthorization') : payAmountLabel(i18n, amount);\n\n /**\n * Show the secondaryLabel if:\n * - it's not zero auth, and\n * - we don't have a predefined label (i.e. redirect, qrcode, await based comps...), and\n * - we do have an amount object (merchant might not be passing this in order to not show the amount on the button), and\n * - we have a secondaryAmount object with some properties\n */\n const hasValidAmount = amount && typeof amount.value === 'number' && !!amount.currency;\n const hasSecondaryAmount = secondaryAmount && Object.keys(secondaryAmount).length > 0;\n\n const secondaryLabel = !isZeroAuth && !label && hasValidAmount && hasSecondaryAmount ? secondaryAmountLabel(i18n, secondaryAmount) : null;\n\n return (\n <Button\n {...props}\n disabled={props.disabled || props.status === 'loading'}\n classNameModifiers={[...classNameModifiers, 'pay']}\n label={label || defaultLabel}\n >\n {secondaryLabel && <SecondaryButtonLabel label={secondaryLabel} />}\n </Button>\n );\n};\n\nexport default PayButton;\nexport { payAmountLabel };\n"],"names":["PayButton","_0","amount","secondaryAmount","classNameModifiers","label","props","i18n","useCoreContext","isZeroAuth","hasOwnProperty","call","value","defaultLabel","get","payAmountLabel","hasValidAmount","currency","hasSecondaryAmount","Object","keys","length","secondaryLabel","secondaryAmountLabel","h","Button","disabled","status","SecondaryButtonLabel"],"mappings":"k4CAsBA,MAAMA,EAAYC,QAACC,OAAEA,EAAMC,gBAAEA,EAAeC,mBAAEA,EAAqB,GAAEC,MAAEA,GAAiCJ,EAAvBK,EAAAA,EAAAA,EAAAA,2DAC7E,MAAMC,KAAEA,GAASC,IACXC,EAAaP,GAAU,CAAC,EAAEQ,eAAeC,KAAKT,EAAQ,UAA6B,IAAjBA,EAAOU,MACzEC,EAAeJ,EAAaF,EAAKO,IAAI,2BAA6BC,EAAeR,EAAML,GASvFc,EAAiBd,GAAkC,iBAAjBA,EAAOU,SAAwBV,EAAOe,SACxEC,EAAqBf,GAAmBgB,OAAOC,KAAKjB,GAAiBkB,OAAS,EAE9EC,GAAkBb,IAAeJ,GAASW,GAAkBE,EAAqBK,EAAqBhB,EAAMJ,GAAmB,KAErI,OACIqB,EAACC,EAAAA,oUAAAA,CAAAA,CAAAA,EACOnB,GAAAA,CACJoB,SAAUpB,EAAMoB,UAA6B,YAAjBpB,EAAMqB,OAClCvB,mBAAoB,IAAIA,EAAoB,OAC5CC,MAAOA,GAASQ,IAEfS,GAAkBE,EAACI,EAAAA,CAAqBvB,MAAOiB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useMemo as r,useRef as t,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import l from"../FormFields/Fieldset/Fieldset.js";import s from"../FormFields/Field/Field.js";import i from"./ReadOnlyPersonalDetails.js";import{personalDetailsValidationRules as o}from"./validate.js";import{useCoreContext as n}from"../../../core/Context/CoreProvider.js";import{checkDateInputSupport as m}from"../FormFields/InputDate/utils.js";import{getFormattedData as p}from"./utils.js";import u from"../../../utils/useForm/useForm.js";import d from"../FormFields/InputText.js";import f from"../FormFields/InputDate/InputDate.js";import c from"../FormFields/InputEmail.js";import h from"../FormFields/InputTelephone.js";import{getErrorMessage as b}from"../../../utils/getErrorMessage.js";function N(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function O(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(r){N(e,r,t[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}const j=["firstName","lastName","dateOfBirth","shopperEmail","telephoneNumber"];function F(N){const{label:j="",namePrefix:F,placeholders:y,requiredFields:v,visibility:M}=N,{i18n:B}=n(),E=r(m,[]),{handleChangeFor:P,triggerValidation:I,data:w,valid:D,errors:C,isValid:q}=u({schema:v,rules:O({},o,N.validationRules),defaultData:N.data}),k=t({showValidation:()=>{I()}});a(()=>{N.setComponentRef(k.current)},[N.setComponentRef]);const x=e=>r=>{const{name:t}=r.target,a=t.split(`${F}.`).pop();P(a,e)(r)},R=e=>`${F?`${F}.`:""}${e}`;return a(()=>{const e=p(w);N.onChange({data:e,valid:D,errors:C,isValid:q})},[w,D,C,q]),"hidden"===M?null:"readOnly"===M?e(i,g(O({},N),{data:w})):e(l,{classNameModifiers:["personalDetails"],label:j},v.includes("firstName")&&e(s,{label:B.get("firstName"),classNameModifiers:["col-50","firstName"],errorMessage:b(B,C.firstName,B.get("firstName")),name:"firstName",i18n:B},e(d,{name:R("firstName"),value:w.firstName,classNameModifiers:["firstName"],onInput:x("input"),onBlur:x("blur"),placeholder:y.firstName,spellCheck:!1,required:!0})),v.includes("lastName")&&e(s,{label:B.get("lastName"),classNameModifiers:["col-50","lastName"],errorMessage:b(B,C.lastName,B.get("lastName")),name:"lastName",i18n:B},e(d,{name:R("lastName"),value:w.lastName,classNameModifiers:["lastName"],onInput:x("input"),onBlur:x("blur"),placeholder:y.lastName,spellCheck:!1,required:!0})),v.includes("dateOfBirth")&&e(s,{label:B.get("dateOfBirth"),classNameModifiers:["col-50","dateOfBirth"],errorMessage:b(B,C.dateOfBirth,B.get("dateOfBirth")),helper:E?null:B.get("dateOfBirth.format"),name:"dateOfBirth",i18n:B},e(f,{name:R("dateOfBirth"),value:w.dateOfBirth,classNameModifiers:["dateOfBirth"],onInput:x("input"),onBlur:x("blur"),placeholder:y.dateOfBirth,required:!0})),v.includes("shopperEmail")&&e(s,{label:B.get("shopperEmail"),classNameModifiers:["shopperEmail"],errorMessage:b(B,C.shopperEmail,B.get("shopperEmail")),dir:"ltr",name:"emailAddress",i18n:B},e(c,{name:R("shopperEmail"),value:w.shopperEmail,classNameModifiers:["shopperEmail"],onInput:x("input"),onBlur:x("blur"),placeholder:y.shopperEmail,required:!0})),v.includes("telephoneNumber")&&e(s,{label:B.get("telephoneNumber"),classNameModifiers:["telephoneNumber"],errorMessage:b(B,C.telephoneNumber,B.get("telephoneNumber")),dir:"ltr",name:"telephoneNumber",i18n:B},e(h,{name:R("telephoneNumber"),value:w.telephoneNumber,classNameModifiers:["telephoneNumber"],onInput:x("input"),onBlur:x("blur"),placeholder:y.telephoneNumber,required:!0})))}F.defaultProps={data:{},onChange:()=>{},placeholders:{},requiredFields:j,validationRules:o,visibility:"editable"};export{j as PERSONAL_DETAILS_SCHEMA,F as default};
|
|
2
2
|
//# sourceMappingURL=PersonalDetails.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/PersonalDetails.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useEffect, useMemo, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyPersonalDetails from './ReadOnlyPersonalDetails';\nimport { personalDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { PersonalDetailsProps } from './types';\nimport { checkDateInputSupport } from '../FormFields/InputDate/utils';\nimport { PersonalDetailsSchema } from '../../../types';\nimport { getFormattedData } from './utils';\nimport useForm from '../../../utils/useForm';\nimport './PersonalDetails.scss';\nimport InputText from '../FormFields/InputText';\nimport InputDate from '../FormFields/InputDate';\nimport InputEmail from '../FormFields/InputEmail';\nimport InputTelephone from '../FormFields/InputTelephone';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\n\nexport const PERSONAL_DETAILS_SCHEMA = ['firstName', 'lastName', 'dateOfBirth', 'shopperEmail', 'telephoneNumber'];\n\nexport default function PersonalDetails(props: PersonalDetailsProps) {\n const { label = '', namePrefix, placeholders, requiredFields, visibility } = props;\n\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const personalDetailsRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(personalDetailsRef.current).length) {\n props.setComponentRef?.(personalDetailsRef.current);\n }\n\n const isDateInputSupported = useMemo(checkDateInputSupport, []);\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<PersonalDetailsSchema>({\n schema: requiredFields,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...personalDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n // Expose method expected by (parent) PersonalDetails.tsx\n personalDetailsRef.current.showValidation = () => {\n triggerValidation();\n };\n\n const eventHandler =\n (mode: HandleChangeForModeType): h.JSX.GenericEventHandler<EventTarget> =>\n (e: Event): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyPersonalDetails {...props} data={data} />;\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={['personalDetails']} label={label}>\n {requiredFields.includes('firstName') && (\n <Field\n label={i18n.get('firstName')}\n classNameModifiers={['col-50', 'firstName']}\n errorMessage={getErrorMessage(i18n, errors.firstName, i18n.get('firstName'))}\n name={'firstName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('firstName')}\n value={data.firstName}\n classNameModifiers={['firstName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.firstName}\n spellCheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('lastName') && (\n <Field\n label={i18n.get('lastName')}\n classNameModifiers={['col-50', 'lastName']}\n errorMessage={getErrorMessage(i18n, errors.lastName, i18n.get('lastName'))}\n name={'lastName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('lastName')}\n value={data.lastName}\n classNameModifiers={['lastName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.lastName}\n spellCheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('dateOfBirth') && (\n <Field\n label={i18n.get('dateOfBirth')}\n classNameModifiers={['col-50', 'dateOfBirth']}\n errorMessage={getErrorMessage(i18n, errors.dateOfBirth, i18n.get('dateOfBirth'))}\n helper={isDateInputSupported ? null : i18n.get('dateOfBirth.format')}\n name={'dateOfBirth'}\n i18n={i18n}\n >\n <InputDate\n name={generateFieldName('dateOfBirth')}\n value={data.dateOfBirth}\n classNameModifiers={['dateOfBirth']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.dateOfBirth}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('shopperEmail') && (\n <Field\n label={i18n.get('shopperEmail')}\n classNameModifiers={['shopperEmail']}\n errorMessage={getErrorMessage(i18n, errors.shopperEmail, i18n.get('shopperEmail'))}\n dir={'ltr'}\n name={'emailAddress'}\n i18n={i18n}\n >\n <InputEmail\n name={generateFieldName('shopperEmail')}\n value={data.shopperEmail}\n classNameModifiers={['shopperEmail']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.shopperEmail}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('telephoneNumber') && (\n <Field\n label={i18n.get('telephoneNumber')}\n classNameModifiers={['telephoneNumber']}\n errorMessage={getErrorMessage(i18n, errors.telephoneNumber, i18n.get('telephoneNumber'))}\n dir={'ltr'}\n name={'telephoneNumber'}\n i18n={i18n}\n >\n <InputTelephone\n name={generateFieldName('telephoneNumber')}\n value={data.telephoneNumber}\n classNameModifiers={['telephoneNumber']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.telephoneNumber}\n required={true}\n />\n </Field>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nPersonalDetails.defaultProps = {\n data: {},\n onChange: () => {},\n placeholders: {},\n requiredFields: PERSONAL_DETAILS_SCHEMA,\n validationRules: personalDetailsValidationRules,\n visibility: 'editable'\n};\n"],"names":["PERSONAL_DETAILS_SCHEMA","PersonalDetails","props","label","namePrefix","placeholders","requiredFields","visibility","i18n","useCoreContext","personalDetailsRef","useRef","Object","keys","current","length","setComponentRef","isDateInputSupported","useMemo","checkDateInputSupport","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","personalDetailsValidationRules","validationRules","defaultData","showValidation","eventHandler","mode","e","name","target","key","split","pop","generateFieldName","useEffect","formattedData","getFormattedData","onChange","h","ReadOnlyPersonalDetails","Fragment","Fieldset","classNameModifiers","includes","Field","get","errorMessage","getErrorMessage","firstName","InputText","value","onInput","onBlur","placeholder","spellCheck","required","lastName","dateOfBirth","helper","InputDate","shopperEmail","dir","InputEmail","telephoneNumber","InputTelephone","defaultProps"],"mappings":"2pDAqBaA,EAA0B,CAAC,YAAa,WAAY,cAAe,eAAgB,mBAEjF,SAASC,EAAgBC,GACpC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,aAAEA,EAAYC,eAAEA,EAAcC,WAAEA,GAAeL,GAEvEM,KAAEA,GAASC,IAGXC,EAAqBC,EAA4B,IAGnDT,IAAAA,EADCU,OAAOC,KAAKH,EAAmBI,SAASC,SACpB,QAArBb,EAAAA,EAAMc,2BAANd,GAAAA,EAAAA,KAAAA,EAAwBQ,EAAmBI,UAG/C,MAAMG,EAAuBC,EAAQC,EAAuB,KACtDC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA+B,CACxGC,OAAQrB,EAERsB,MAAOC,EAAA,CAAA,EAAKC,EAAmC5B,EAAM6B,iBACrDC,YAAa9B,EAAMoB,OAIvBZ,EAAmBI,QAAQmB,eAAiB,KACxCZ,KAGJ,MAAMa,EACDC,GACAC,IACG,MAAMC,KAAEA,GAASD,EAAEE,OACbC,EAAMF,EAAKG,MAAM,GAAGpC,MAAeqC,MAEzCrB,EAAgBmB,EAAKJ,EAArBf,CAA2BgB,IAG7BM,EAAqBL,GA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"PersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/PersonalDetails.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useMemo, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyPersonalDetails from './ReadOnlyPersonalDetails';\nimport { personalDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { PersonalDetailsProps } from './types';\nimport { checkDateInputSupport } from '../FormFields/InputDate/utils';\nimport { PersonalDetailsSchema } from '../../../types';\nimport { getFormattedData } from './utils';\nimport useForm from '../../../utils/useForm';\nimport InputText from '../FormFields/InputText';\nimport InputDate from '../FormFields/InputDate';\nimport InputEmail from '../FormFields/InputEmail';\nimport InputTelephone from '../FormFields/InputTelephone';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\nimport './PersonalDetails.scss';\n\nexport const PERSONAL_DETAILS_SCHEMA = ['firstName', 'lastName', 'dateOfBirth', 'shopperEmail', 'telephoneNumber'];\n\nexport default function PersonalDetails(props: Readonly<PersonalDetailsProps>) {\n const { label = '', namePrefix, placeholders, requiredFields, visibility } = props;\n\n const { i18n } = useCoreContext();\n\n const isDateInputSupported = useMemo(checkDateInputSupport, []);\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<PersonalDetailsSchema>({\n schema: requiredFields,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...personalDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n const personalDetailsRef = useRef<ComponentMethodsRef>({\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n props.setComponentRef(personalDetailsRef.current);\n }, [props.setComponentRef]);\n\n const eventHandler =\n (mode: HandleChangeForModeType): h.JSX.GenericEventHandler<EventTarget> =>\n (e: Event): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyPersonalDetails {...props} data={data} />;\n\n return (\n <Fieldset classNameModifiers={['personalDetails']} label={label}>\n {requiredFields.includes('firstName') && (\n <Field\n label={i18n.get('firstName')}\n classNameModifiers={['col-50', 'firstName']}\n errorMessage={getErrorMessage(i18n, errors.firstName, i18n.get('firstName'))}\n name={'firstName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('firstName')}\n value={data.firstName}\n classNameModifiers={['firstName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.firstName}\n spellCheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('lastName') && (\n <Field\n label={i18n.get('lastName')}\n classNameModifiers={['col-50', 'lastName']}\n errorMessage={getErrorMessage(i18n, errors.lastName, i18n.get('lastName'))}\n name={'lastName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('lastName')}\n value={data.lastName}\n classNameModifiers={['lastName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.lastName}\n spellCheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('dateOfBirth') && (\n <Field\n label={i18n.get('dateOfBirth')}\n classNameModifiers={['col-50', 'dateOfBirth']}\n errorMessage={getErrorMessage(i18n, errors.dateOfBirth, i18n.get('dateOfBirth'))}\n helper={isDateInputSupported ? null : i18n.get('dateOfBirth.format')}\n name={'dateOfBirth'}\n i18n={i18n}\n >\n <InputDate\n name={generateFieldName('dateOfBirth')}\n value={data.dateOfBirth}\n classNameModifiers={['dateOfBirth']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.dateOfBirth}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('shopperEmail') && (\n <Field\n label={i18n.get('shopperEmail')}\n classNameModifiers={['shopperEmail']}\n errorMessage={getErrorMessage(i18n, errors.shopperEmail, i18n.get('shopperEmail'))}\n dir={'ltr'}\n name={'emailAddress'}\n i18n={i18n}\n >\n <InputEmail\n name={generateFieldName('shopperEmail')}\n value={data.shopperEmail}\n classNameModifiers={['shopperEmail']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.shopperEmail}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('telephoneNumber') && (\n <Field\n label={i18n.get('telephoneNumber')}\n classNameModifiers={['telephoneNumber']}\n errorMessage={getErrorMessage(i18n, errors.telephoneNumber, i18n.get('telephoneNumber'))}\n dir={'ltr'}\n name={'telephoneNumber'}\n i18n={i18n}\n >\n <InputTelephone\n name={generateFieldName('telephoneNumber')}\n value={data.telephoneNumber}\n classNameModifiers={['telephoneNumber']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.telephoneNumber}\n required={true}\n />\n </Field>\n )}\n </Fieldset>\n );\n}\n\nPersonalDetails.defaultProps = {\n data: {},\n onChange: () => {},\n placeholders: {},\n requiredFields: PERSONAL_DETAILS_SCHEMA,\n validationRules: personalDetailsValidationRules,\n visibility: 'editable'\n};\n"],"names":["PERSONAL_DETAILS_SCHEMA","PersonalDetails","props","label","namePrefix","placeholders","requiredFields","visibility","i18n","useCoreContext","isDateInputSupported","useMemo","checkDateInputSupport","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","personalDetailsValidationRules","validationRules","defaultData","personalDetailsRef","useRef","showValidation","useEffect","setComponentRef","current","eventHandler","mode","e","name","target","key","split","pop","generateFieldName","formattedData","getFormattedData","onChange","h","ReadOnlyPersonalDetails","Fieldset","classNameModifiers","includes","Field","get","errorMessage","getErrorMessage","firstName","InputText","value","onInput","onBlur","placeholder","spellCheck","required","lastName","dateOfBirth","helper","InputDate","shopperEmail","dir","InputEmail","telephoneNumber","InputTelephone","defaultProps"],"mappings":"6oDAqBaA,EAA0B,CAAC,YAAa,WAAY,cAAe,eAAgB,mBAEjF,SAASC,EAAgBC,GACpC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,aAAEA,EAAYC,eAAEA,EAAcC,WAAEA,GAAeL,GAEvEM,KAAEA,GAASC,IAEXC,EAAuBC,EAAQC,EAAuB,KACtDC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA+B,CACxGC,OAAQd,EAERe,MAAOC,EAAA,CAAA,EAAKC,EAAmCrB,EAAMsB,iBACrDC,YAAavB,EAAMa,OAGjBW,EAAqBC,EAA4B,CACnDC,eAAgB,KACZd,OAIRe,EAAU,KACN3B,EAAM4B,gBAAgBJ,EAAmBK,UAC1C,CAAC7B,EAAM4B,kBAEV,MAAME,EACDC,GACAC,IACG,MAAMC,KAAEA,GAASD,EAAEE,OACbC,EAAMF,EAAKG,MAAM,GAAGlC,MAAemC,MAEzC1B,EAAgBwB,EAAKJ,EAArBpB,CAA2BqB,IAG7BM,EAAqBL,GAAyB,GAAG/B,EAAa,GAAGA,KAAgB,KAAK+B,IAO5F,OALAN,EAAU,KACN,MAAMY,EAAgBC,EAAiB3B,GACvCb,EAAMyC,SAAS,CAAE5B,KAAM0B,EAAezB,QAAOC,SAAQC,aACtD,CAACH,EAAMC,EAAOC,EAAQC,IAEN,WAAfX,EAAgC,KACjB,aAAfA,EAAkCqC,EAACC,EAAAA,EAAAA,EAAAA,GAA4B3C,GAAAA,CAAOa,KAAMA,KAG5E6B,EAACE,EAAAA,CAASC,mBAAoB,CAAC,mBAAoB5C,MAAOA,GACrDG,EAAe0C,SAAS,cACrBJ,EAACK,EAAAA,CACG9C,MAAOK,EAAK0C,IAAI,aAChBH,mBAAoB,C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gB,IAAK,MACL/B,KAAM,eACN3B,KAAMA,GAENoC,EAACuB,EAAAA,CACGhC,KAAMK,EAAkB,gBACxBe,MAAOxC,EAAKkD,aACZlB,mBAAoB,CAAC,gBACrBS,QAASxB,EAAa,SACtByB,OAAQzB,EAAa,QACrB0B,YAAarD,EAAa4D,aAC1BL,UAAU,KAKrBtD,EAAe0C,SAAS,oBACrBJ,EAACK,EAAAA,CACG9C,MAAOK,EAAK0C,IAAI,mBAChBH,mBAAoB,CAAC,mBACrBI,aAAcC,EAAgB5C,EAAMS,EAAOmD,gBAAiB5D,EAAK0C,IAAI,oBACrEgB,IAAK,MACL/B,KAAM,kBACN3B,KAAMA,GAENoC,EAACyB,EAAAA,CACGlC,KAAMK,EAAkB,mBACxBe,MAAOxC,EAAKqD,gBACZrB,mBAAoB,CAAC,mBACrBS,QAASxB,EAAa,SACtByB,OAAQzB,EAAa,QACrB0B,YAAarD,EAAa+D,gBAC1BR,UAAU,KAMlC,CAEA3D,EAAgBqE,aAAe,CAC3BvD,KAAM,CAAA,EACN4B,SAAU,OACVtC,aAAc,CAAA,EACdC,eAAgBN,EAChBwB,gBAAiBD,EACjBhB,WAAY"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as r}from"../../../external/preact/dist/preact.js";import{useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../FormFields/Field/Field.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import l from"../FormFields/Select/Select.js";import
|
|
1
|
+
import{createElement as e,Fragment as r}from"../../../external/preact/dist/preact.js";import{useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../FormFields/Field/Field.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import l from"../FormFields/Select/Select.js";import p from"../FormFields/InputText.js";function i(e,r){if(null==e)return{};var o,n,t,l={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(e),t=0;t<o.length;t++)n=o[t],r.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}if(l=function(e,r){if(null==e)return{};var o,n,t={},l=Object.getOwnPropertyNames(e);for(n=0;n<l.length;n++)o=l[n],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(t[o]=e[o]);return t}(e,r),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(e),t=0;t<o.length;t++)n=o[t],r.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}function a(a){let{getError:u,showNumber:c,showPrefix:m,form:h,canSelectPrefix:s=!0}=a,d=i(a,["getError","showNumber","showPrefix","form","canSelectPrefix"]);var f,b,y;const{i18n:x}=t(),{handleChangeFor:N,data:g,valid:P}=h;return o(()=>{g.phoneNumber&&N("phoneNumber","blur")(g.phoneNumber)},[g.phonePrefix]),e(r,null,m&&e(n,{className:"adyen-checkout-field--phone-prefix",label:x.get("telephonePrefix"),errorMessage:u("phonePrefix"),showValidIcon:!1,isValid:P.phonePrefix,dir:"ltr",i18n:x,name:"phonePrefix"},e(l,{readonly:!s,className:"adyen-checkout-dropdown adyen-checkout-dropdown--countrycode-selector",name:"phonePrefix",items:d.items,onChange:N("phonePrefix"),placeholder:null==d||null===(f=d.placeholders)||void 0===f?void 0:f.phonePrefix,selectedValue:g.phonePrefix})),c&&e(n,{className:"adyen-checkout-field--phone-number",label:d.phoneNumberKey?x.get(d.phoneNumberKey):x.get("telephoneNumber"),errorMessage:u("phoneNumber"),isValid:P.phoneNumber,filled:(null==g||null===(b=g.phoneNumber)||void 0===b?void 0:b.length)>0,dir:"ltr",i18n:x,name:"phoneNumber"},e(p,{className:"adyen-checkout__input adyen-checkout-input adyen-checkout-input--phone-number",type:"tel",name:"phoneNumber",value:g.phoneNumber,onInput:N("phoneNumber","input"),onBlur:N("phoneNumber","blur"),placeholder:null==d||null===(y=d.placeholders)||void 0===y?void 0:y.phoneNumber,autoCorrect:"off",required:!0})))}export{a as default};
|
|
2
2
|
//# sourceMappingURL=PhoneInputFields.js.map
|