@adyen/adyen-web 6.38.0 → 6.40.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 +91 -91
- 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 +91 -75
- package/dist/es/adyen.css +91 -91
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
- package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
- package/dist/es/components/Ach/components/AchComponent.js +1 -1
- package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
- package/dist/es/components/Affirm/Affirm.js +1 -1
- package/dist/es/components/Affirm/Affirm.js.map +1 -1
- package/dist/es/components/Affirm/config.js +1 -1
- package/dist/es/components/Affirm/config.js.map +1 -1
- package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
- package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
- package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
- package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
- package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
- package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es/components/PayPal/Paypal.js +1 -1
- package/dist/es/components/PayPal/Paypal.js.map +1 -1
- package/dist/es/components/PayPal/constants.js +1 -1
- package/dist/es/components/PayPal/constants.js.map +1 -1
- package/dist/es/components/PayTo/components/BSBInput.js +1 -1
- package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
- package/dist/es/components/PayTo/components/PayIDInput.js +1 -1
- package/dist/es/components/PayTo/components/PayIDInput.js.map +1 -1
- package/dist/es/components/PayTo/components/PayToNameFields.js +1 -1
- package/dist/es/components/PayTo/components/PayToNameFields.js.map +1 -1
- package/dist/es/components/Pix/components/PixQRDetails.js +1 -1
- package/dist/es/components/Pix/components/PixQRDetails.js.map +1 -1
- package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
- package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
- package/dist/es/components/internal/Address/Address.js +1 -1
- package/dist/es/components/internal/Address/Address.js.map +1 -1
- package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
- package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
- package/dist/es/components/internal/Address/constants.js +1 -1
- package/dist/es/components/internal/Address/constants.js.map +1 -1
- package/dist/es/components/internal/Address/utils.js +1 -1
- package/dist/es/components/internal/Address/utils.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/validate.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/validate.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
- package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
- package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es/components/internal/FormFields/RadioGroup/RadioGroup.js +1 -1
- package/dist/es/components/internal/FormFields/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectList.js +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectList.js.map +1 -1
- package/dist/es/components/internal/IbanInput/IbanInput.js +1 -1
- package/dist/es/components/internal/IbanInput/IbanInput.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/PhoneInput/PhoneInputFields.js +1 -1
- package/dist/es/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
- package/dist/es/components/internal/SendCopyToEmail/SendCopyToEmail.js +1 -1
- package/dist/es/components/internal/SendCopyToEmail/SendCopyToEmail.js.map +1 -1
- package/dist/es/components/internal/SocialSecurityNumberBrazil/BrazilPersonalDetail.js +1 -1
- package/dist/es/components/internal/SocialSecurityNumberBrazil/BrazilPersonalDetail.js.map +1 -1
- package/dist/es/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js +1 -1
- package/dist/es/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/external/preact/dist/preact.js +1 -1
- package/dist/es/external/preact/dist/preact.js.map +1 -1
- package/dist/es/index.d.ts +91 -75
- package/dist/es/packages/server/translations/en-US.json.js +1 -1
- package/dist/es/utils/Validator/ValidationRuleResult.js +1 -1
- package/dist/es/utils/Validator/ValidationRuleResult.js.map +1 -1
- package/dist/es/utils/Validator/Validator.js +1 -1
- package/dist/es/utils/Validator/Validator.js.map +1 -1
- package/dist/es/utils/useForm/useForm.js +1 -1
- package/dist/es/utils/useForm/useForm.js.map +1 -1
- package/dist/es-legacy/adyen.css +91 -91
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
- package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
- package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
- package/dist/es-legacy/components/Affirm/Affirm.js +1 -1
- package/dist/es-legacy/components/Affirm/Affirm.js.map +1 -1
- package/dist/es-legacy/components/Affirm/config.js +1 -1
- package/dist/es-legacy/components/Affirm/config.js.map +1 -1
- package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
- package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
- package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
- package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
- package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
- package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
- package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
- package/dist/es-legacy/components/PayPal/constants.js +1 -1
- package/dist/es-legacy/components/PayPal/constants.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
- package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/PayIDInput.js +1 -1
- package/dist/es-legacy/components/PayTo/components/PayIDInput.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToNameFields.js +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToNameFields.js.map +1 -1
- package/dist/es-legacy/components/Pix/components/PixQRDetails.js +1 -1
- package/dist/es-legacy/components/Pix/components/PixQRDetails.js.map +1 -1
- package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
- package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
- package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/constants.js +1 -1
- package/dist/es-legacy/components/internal/Address/constants.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/utils.js +1 -1
- package/dist/es-legacy/components/internal/Address/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/validate.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
- package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
- package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.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/RadioGroup/RadioGroup.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.js.map +1 -1
- package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
- package/dist/es-legacy/components/internal/IbanInput/IbanInput.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/SendCopyToEmail/SendCopyToEmail.js +1 -1
- package/dist/es-legacy/components/internal/SendCopyToEmail/SendCopyToEmail.js.map +1 -1
- package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/BrazilPersonalDetail.js +1 -1
- package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/BrazilPersonalDetail.js.map +1 -1
- package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js +1 -1
- package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
- package/dist/es-legacy/packages/server/translations/en-US.json.js +1 -1
- package/dist/es-legacy/utils/Validator/ValidationRuleResult.js +1 -1
- package/dist/es-legacy/utils/Validator/ValidationRuleResult.js.map +1 -1
- package/dist/es-legacy/utils/Validator/Validator.js +1 -1
- package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
- package/package.json +17 -17
- package/styles/adyen.css +91 -91
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paypal.js","sources":["../../../../src/components/PayPal/Paypal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PaypalComponent from './components/PaypalComponent';\nimport defaultProps from './defaultProps';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { ERRORS } from './constants';\nimport { TxVariants } from '../tx-variants';\nimport { formatPaypalOrderContactToAdyenFormat } from './utils/format-paypal-order-contact-to-adyen-format';\n\nimport type { ICore } from '../../core/types';\nimport type { PaymentAction } from '../../types/global-types';\nimport type { Intent, PayPalConfiguration } from './types';\nimport type {\n PayPalOnApproveActions,\n PayPalOnApproveData,\n PayPalOnShippingAddressChangeActions,\n PayPalOnShippingAddressChangeData,\n PayPalOnShippingOptionsChangeActions,\n PayPalOnShippingOptionsChangeData,\n PayPalOrderResponseBody\n} from './paypal-js-types';\n\nimport { AnalyticsInfoEvent, InfoEventType } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport './Paypal.scss';\n\nclass PaypalElement extends UIElement<PayPalConfiguration> {\n public static readonly type = TxVariants.paypal;\n public static readonly subtype = 'sdk';\n\n public paymentData: string | null = null;\n\n private resolve: ((value: string) => void) | null = null;\n private reject: ((error?: Error) => void) | null = null;\n\n protected static readonly defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: PayPalConfiguration) {\n super(checkout, props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleOnShippingAddressChange = this.handleOnShippingAddressChange.bind(this);\n this.handleOnShippingOptionsChange = this.handleOnShippingOptionsChange.bind(this);\n }\n\n formatProps(props: PayPalConfiguration): PayPalConfiguration {\n const merchantId = props.configuration?.merchantId;\n const intentFromConfig = props.configuration?.intent;\n const isZeroAuth = props.amount?.value === 0;\n const intent: Intent | undefined = isZeroAuth ? 'tokenize' : props.intent || intentFromConfig;\n const vault = intent === 'tokenize' || props.vault;\n\n const displayContinueToReviewPageButton = props.userAction === 'continue';\n\n return {\n ...props,\n commit: displayContinueToReviewPageButton ? false : props.commit,\n vault,\n configuration: {\n intent,\n merchantId\n }\n };\n }\n\n protected override beforeRender(configSetByMerchant?: PayPalConfiguration) {\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.isExpress && { isExpress: configSetByMerchant.isExpress }),\n ...(configSetByMerchant?.expressPage && { expressPage: configSetByMerchant.expressPage })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n public submit = () => {\n this.handleError(new AdyenCheckoutError('IMPLEMENTATION_ERROR', ERRORS.SUBMIT_NOT_SUPPORTED));\n };\n\n /**\n * Updates the paymentData value. It must be used in the PayPal Express flow, when patching the amount\n * @param paymentData - Payment data value\n */\n public updatePaymentData(paymentData: string): void {\n if (!paymentData) console.warn('PayPal - Updating payment data with an invalid value');\n this.paymentData = paymentData;\n }\n\n /**\n * Formats the component data output\n */\n protected formatData() {\n const { isExpress, userAction } = this.props;\n\n return {\n paymentMethod: {\n type: PaypalElement.type,\n userAction,\n subtype: isExpress ? 'express' : PaypalElement.subtype\n }\n };\n }\n\n public handleAction = (action: PaymentAction) => {\n return this.updateWithAction(action);\n };\n\n public updateWithAction = (action: PaymentAction) => {\n if (action.paymentMethodType !== this.type) throw new Error('Invalid Action');\n\n if (action.paymentData) {\n this.paymentData = action.paymentData;\n }\n\n if (action.sdkData && action.sdkData.token) {\n this.onActionHandled({ componentType: this.type, actionDescription: 'sdk-loaded', originalAction: action });\n this.handleResolve(action.sdkData.token);\n } else {\n this.handleReject(ERRORS.NO_TOKEN_PROVIDED);\n }\n\n return null;\n };\n\n /**\n * Dropin Validation\n *\n * @remarks\n * Paypal does not require any specific Dropin validation\n */\n get isValid() {\n return true;\n }\n\n private readonly handleOnApprove = (data: PayPalOnApproveData, actions: PayPalOnApproveActions): Promise<void> => {\n const { onAuthorized } = this.props;\n const state = { data: { details: data, paymentData: this.paymentData ?? undefined } };\n\n if (!onAuthorized) {\n this.handleAdditionalDetails(state);\n return Promise.resolve();\n }\n\n if (!actions.order) {\n this.handleError(new AdyenCheckoutError('ERROR', 'PayPal order actions are not available'));\n return Promise.resolve();\n }\n\n return actions.order\n .get()\n .then((paypalOrder: PayPalOrderResponseBody) => {\n const billingAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.purchase_units?.[0].shipping, true);\n\n this.setState({\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<void>((resolve, reject) =>\n onAuthorized(\n {\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n )\n );\n })\n .then(() => this.handleAdditionalDetails(state))\n .catch(error => this.handleError(new AdyenCheckoutError('ERROR', 'Something went wrong while parsing PayPal Order', { cause: error })));\n };\n\n handleResolve(token: string) {\n if (!this.resolve) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.resolve(token);\n }\n\n handleReject(errorMessage: string) {\n if (!this.reject) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.reject(new Error(errorMessage));\n }\n\n private handleSubmit(): Promise<string> {\n super.submit();\n\n return new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n\n /**\n * If the merchant provides the 'onShippingAddressChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingAddressChange(data: PayPalOnShippingAddressChangeData, actions: PayPalOnShippingAddressChangeActions): Promise<void> {\n const { onShippingAddressChange } = this.props;\n\n if (!onShippingAddressChange) return Promise.resolve();\n\n return onShippingAddressChange(data, actions, this);\n }\n\n /**\n * If the merchant provides the 'onShippingOptionsChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingOptionsChange(data: PayPalOnShippingOptionsChangeData, actions: PayPalOnShippingOptionsChangeActions): Promise<void> {\n const { onShippingOptionsChange } = this.props;\n\n if (!onShippingOptionsChange) return Promise.resolve();\n\n return onShippingOptionsChange(data, actions, this);\n }\n\n protected override componentToRender(): h.JSX.Element | null {\n if (!this.props.showPayButton) return null;\n\n const { onShippingAddressChange, onShippingOptionsChange, ...rest } = this.props;\n\n return (\n <PaypalComponent\n {...rest}\n setComponentRef={this.setComponentRef}\n {...(onShippingAddressChange && { onShippingAddressChange: this.handleOnShippingAddressChange })}\n {...(onShippingOptionsChange && { onShippingOptionsChange: this.handleOnShippingOptionsChange })}\n onCancel={() => this.handleError(new AdyenCheckoutError('CANCEL'))}\n onChange={this.setState}\n onApprove={this.handleOnApprove}\n onError={error => {\n this.handleError(new AdyenCheckoutError('ERROR', String(error), { cause: error }));\n }}\n onScriptLoadFailure={error => this.handleError(error)}\n onSubmit={this.handleSubmit}\n />\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","formatProps","props","merchantId","configuration","intentFromConfig","intent","amount","value","vault","displayContinueToReviewPageButton","userAction","_object_spread_props","_object_spread","commit","beforeRender","configSetByMerchant","event","AnalyticsInfoEvent","type","InfoEventType","rendered","component","this","configData","showPayButton","isExpress","expressPage","analytics","sendAnalytics","updatePaymentData","paymentData","console","warn","formatData","paymentMethod","subtype","isValid","handleResolve","token","resolve","handleError","AdyenCheckoutError","ERRORS","WRONG_INSTANCE","handleReject","errorMessage","reject","Error","handleSubmit","super","submit","Promise","handleOnShippingAddressChange","data","actions","onShippingAddressChange","handleOnShippingOptionsChange","onShippingOptionsChange","componentToRender","_this_props","rest","h","PaypalComponent","setComponentRef","onCancel","onChange","setState","onApprove","handleOnApprove","onError","error","String","cause","onScriptLoadFailure","onSubmit","constructor","checkout","_define_property","SUBMIT_NOT_SUPPORTED","handleAction","action","updateWithAction","paymentMethodType","sdkData","onActionHandled","componentType","actionDescription","originalAction","NO_TOKEN_PROVIDED","_this_paymentData","onAuthorized","state","details","undefined","order","get","then","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","authorizedEvent","handleAdditionalDetails","catch","bind","TxVariants","paypal","defaultProps"],"mappings":"69DAyBA,MAAMA,UAAsBC,EAkBxBC,WAAAA,CAAYC,GACWA,IAAAA,EACMA,EACNA,EAFnB,MAAMC,EAAgC,QAAnBD,EAAAA,EAAME,qBAANF,IAAAA,SAAAA,EAAqBC,WAClCE,EAAsC,Q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AAS,kDAAmD,CAAE+B,MAAOF,OA5B7HhD,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,2CAC1CU,QAAQZ,YANfjB,KAAKmF,wBAAwBd,GACtBxC,QAAQZ,aAtGnBjB,KAAK0B,aAAe1B,KAAK0B,aAAa2D,KAAKrF,MAC3CA,KAAK8B,8BAAgC9B,KAAK8B,8BAA8BuD,KAAKrF,MAC7EA,KAAKkC,8BAAgClC,KAAKkC,8BAA8BmD,KAAKrF,KACjF,EAfAuD,EADE/E,EACqBoB,OAAO0F,EAAWC,QACzChC,EAFE/E,EAEqBqC,UAAU,OAOjC0C,EATE/E,EASwBgH,eAAeA"}
|
|
1
|
+
{"version":3,"file":"Paypal.js","sources":["../../../../src/components/PayPal/Paypal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PaypalComponent from './components/PaypalComponent';\nimport defaultProps from './defaultProps';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { ERRORS } from './constants';\nimport { TxVariants } from '../tx-variants';\nimport { formatPaypalOrderContactToAdyenFormat } from './utils/format-paypal-order-contact-to-adyen-format';\n\nimport type { ICore } from '../../core/types';\nimport type { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport type { Intent, PayPalConfiguration } from './types';\nimport type {\n PayPalOnApproveActions,\n PayPalOnApproveData,\n PayPalOnShippingAddressChangeActions,\n PayPalOnShippingAddressChangeData,\n PayPalOnShippingOptionsChangeActions,\n PayPalOnShippingOptionsChangeData,\n PayPalOrderResponseBody\n} from './paypal-js-types';\n\nimport { AnalyticsInfoEvent, InfoEventType } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport CancelError from '../../core/Errors/CancelError';\nimport './Paypal.scss';\n\nclass PaypalElement extends UIElement<PayPalConfiguration> {\n public static readonly type = TxVariants.paypal;\n public static readonly subtype = 'sdk';\n\n public paymentData: string | null = null;\n\n private resolve: ((value: string) => void) | null = null;\n private reject: ((error?: Error) => void) | null = null;\n\n protected static readonly defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: PayPalConfiguration) {\n super(checkout, props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleOnShippingAddressChange = this.handleOnShippingAddressChange.bind(this);\n this.handleOnShippingOptionsChange = this.handleOnShippingOptionsChange.bind(this);\n }\n\n formatProps(props: PayPalConfiguration): PayPalConfiguration {\n const merchantId = props.configuration?.merchantId;\n const intentFromConfig = props.configuration?.intent;\n const isZeroAuth = props.amount?.value === 0;\n const intent: Intent | undefined = isZeroAuth ? 'tokenize' : props.intent || intentFromConfig;\n const vault = intent === 'tokenize' || props.vault;\n\n const displayContinueToReviewPageButton = props.userAction === 'continue';\n\n return {\n ...props,\n commit: displayContinueToReviewPageButton ? false : props.commit,\n vault,\n configuration: {\n intent,\n merchantId\n }\n };\n }\n\n protected override beforeRender(configSetByMerchant?: PayPalConfiguration) {\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.isExpress && { isExpress: configSetByMerchant.isExpress }),\n ...(configSetByMerchant?.expressPage && { expressPage: configSetByMerchant.expressPage })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n public submit = () => {\n this.handleError(new AdyenCheckoutError('IMPLEMENTATION_ERROR', ERRORS.SUBMIT_NOT_SUPPORTED));\n };\n\n /**\n * Updates the paymentData value. It must be used in the PayPal Express flow, when patching the amount\n * @param paymentData - Payment data value\n */\n public updatePaymentData(paymentData: string): void {\n if (!paymentData) console.warn('PayPal - Updating payment data with an invalid value');\n this.paymentData = paymentData;\n }\n\n /**\n * Formats the component data output\n */\n protected formatData() {\n const { isExpress, userAction } = this.props;\n\n return {\n paymentMethod: {\n type: PaypalElement.type,\n userAction,\n subtype: isExpress ? 'express' : PaypalElement.subtype\n }\n };\n }\n\n public handleAction = (action: PaymentAction) => {\n return this.updateWithAction(action);\n };\n\n public updateWithAction = (action: PaymentAction) => {\n if (action.paymentMethodType !== this.type) throw new Error('Invalid Action');\n\n if (action.paymentData) {\n this.paymentData = action.paymentData;\n }\n\n if (action.sdkData && action.sdkData.token) {\n this.onActionHandled({ componentType: this.type, actionDescription: 'sdk-loaded', originalAction: action });\n this.handleResolve(action.sdkData.token);\n } else {\n this.handleReject(ERRORS.NO_TOKEN_PROVIDED);\n }\n\n return null;\n };\n\n /**\n * Dropin Validation\n *\n * @remarks\n * Paypal does not require any specific Dropin validation\n */\n get isValid() {\n return true;\n }\n\n private readonly handleOnApprove = (data: PayPalOnApproveData, actions: PayPalOnApproveActions): Promise<void> => {\n const { onAuthorized } = this.props;\n const state = { data: { details: data, paymentData: this.paymentData ?? undefined } };\n\n if (!onAuthorized) {\n this.handleAdditionalDetails(state);\n return Promise.resolve();\n }\n\n if (!actions.order) {\n this.handleError(new AdyenCheckoutError('ERROR', 'PayPal order actions are not available'));\n return Promise.resolve();\n }\n\n return actions.order\n .get()\n .then((paypalOrder: PayPalOrderResponseBody) => {\n const billingAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.purchase_units?.[0].shipping, true);\n\n this.setState({\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<void>((resolve, reject) =>\n onAuthorized(\n {\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n )\n );\n })\n .then(() => this.handleAdditionalDetails(state))\n .catch(error => this.handleError(new AdyenCheckoutError('ERROR', 'Something went wrong while parsing PayPal Order', { cause: error })));\n };\n\n handleResolve(token: string) {\n if (!this.resolve) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.resolve(token);\n }\n\n handleReject(errorMessage: string) {\n if (!this.reject) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.reject(new Error(errorMessage));\n }\n\n private handleSubmit(): Promise<string> {\n return new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n\n this.makePaymentsCall()\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n const errorDetail = e instanceof Error ? e.message : JSON.stringify(e);\n const errorMessage = e ? `: ${errorDetail}` : '';\n this.handleReject(`${ERRORS.PAYMENT_FAILED}${errorMessage}`);\n });\n });\n }\n\n /**\n * If the merchant provides the 'onShippingAddressChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingAddressChange(data: PayPalOnShippingAddressChangeData, actions: PayPalOnShippingAddressChangeActions): Promise<void> {\n const { onShippingAddressChange } = this.props;\n\n if (!onShippingAddressChange) return Promise.resolve();\n\n return onShippingAddressChange(data, actions, this);\n }\n\n /**\n * If the merchant provides the 'onShippingOptionsChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingOptionsChange(data: PayPalOnShippingOptionsChangeData, actions: PayPalOnShippingOptionsChangeActions): Promise<void> {\n const { onShippingOptionsChange } = this.props;\n\n if (!onShippingOptionsChange) return Promise.resolve();\n\n return onShippingOptionsChange(data, actions, this);\n }\n\n protected override componentToRender(): h.JSX.Element | null {\n if (!this.props.showPayButton) return null;\n\n const { onShippingAddressChange, onShippingOptionsChange, ...rest } = this.props;\n\n return (\n <PaypalComponent\n {...rest}\n setComponentRef={this.setComponentRef}\n {...(onShippingAddressChange && { onShippingAddressChange: this.handleOnShippingAddressChange })}\n {...(onShippingOptionsChange && { onShippingOptionsChange: this.handleOnShippingOptionsChange })}\n onCancel={() => this.handleError(new AdyenCheckoutError('CANCEL'))}\n onChange={this.setState}\n onApprove={this.handleOnApprove}\n onError={error => {\n this.handleError(new AdyenCheckoutError('ERROR', String(error), { cause: error }));\n }}\n onScriptLoadFailure={error => this.handleError(error)}\n onSubmit={this.handleSubmit}\n />\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","formatProps","props","merchantId","configuration","intentFromConfig","intent","amount","value","vault","displayContinueToReviewPageButton","userAction","_object_spread_props","_object_spread","commit","beforeRender","configSetByMerchant","event","AnalyticsInfoEvent","type","InfoEventType","rendered","component","this","configData","showPayButton","isExpress","expressPage","analytics","sendAnalytics","updatePaymentData","paymentData","console","warn","formatData","paymentMethod","subtype","isValid","handleResolve","token","resolve","handleError","AdyenCheckoutError","ERRORS","WRONG_INSTANCE","handleReject","errorMessage","reject","Error","handleSubmit","Promise","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","setElementStatus","handleFailedResult","errorDetail","message","JSON","stringify","PAYMENT_FAILED","handleOnShippingAddressChange","data","actions","onShippingAddressChange","handleOnShippingOptionsChange","onShippingOptionsChange","componentToRender","_this_props","rest","h","PaypalComponent","setComponentRef","onCancel","onChange","setState","onApprove","handleOnApprove","onError","error","String","cause","onScriptLoadFailure","onSubmit","constructor","checkout","super","_define_property","submit","SUBMIT_NOT_SUPPORTED","handleAction","action","updateWithAction","paymentMethodType","sdkData","onActionHandled","componentType","actionDescription","originalAction","NO_TOKEN_PROVIDED","_this_paymentData","onAuthorized","state","details","undefined","order","get","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","authorizedEvent","handleAdditionalDetails","bind","TxVariants","paypal","defaultProps"],"mappings":"4mEA2BA,MAAMA,UAAsBC,E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AAaG,OACpEC,EAAkBF,EAAsCF,SAA2B,QAA3BA,EAAAA,EAAaK,0BAAbL,SAAAA,EAA8B,GAAGM,UAAU,GAQzG,OANA/F,KAAKyD,SAASnE,EAAA,CACV0G,gBAAiBP,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,qBAGtB,IAAIlE,QAAc,CAACV,EAASO,IAC/B2D,EACI7F,EAAA,CACI0G,gBAAiBP,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,oBAE7B,CAAE5E,UAASO,cAItBK,KAAK,IAAM7B,KAAKiG,wBAAwBb,IACxCnD,MAAM4B,GAAS7D,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,kDAAmD,CAAE4C,MAAOF,OA5B7H7D,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,2CAC1CQ,QAAQV,YANfjB,KAAKiG,wBAAwBb,GACtBzD,QAAQV,aAtGnBjB,KAAK0B,aAAe1B,KAAK0B,aAAawE,KAAKlG,MAC3CA,KAAK2C,8BAAgC3C,KAAK2C,8BAA8BuD,KAAKlG,MAC7EA,KAAK+C,8BAAgC/C,KAAK+C,8BAA8BmD,KAAKlG,KACjF,EAfAqE,EADE7F,EACqBoB,OAAOuG,EAAWC,QACzC/B,EAFE7F,EAEqBqC,UAAU,OAOjCwD,EATE7F,EASwB6H,eAAeA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t={NO_TOKEN_PROVIDED:"No token was provided",SUBMIT_NOT_SUPPORTED:"Calling submit() is not supported for this payment method",WRONG_INSTANCE:"The instance of the PayPal component being used is not the same which started the payment"};export{t as ERRORS};
|
|
1
|
+
const t={NO_TOKEN_PROVIDED:"No token was provided",SUBMIT_NOT_SUPPORTED:"Calling submit() is not supported for this payment method",WRONG_INSTANCE:"The instance of the PayPal component being used is not the same which started the payment",PAYMENT_FAILED:"Something went wrong during PayPal payment"};export{t as ERRORS};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/components/PayPal/constants.ts"],"sourcesContent":["export const ERRORS = {\n INVALID_ACTION: 'Invalid Action',\n NO_TOKEN_PROVIDED: 'No token was provided',\n PAYPAL_OVERLAY_CLOSED: 'PayPal overlay closed',\n SUBMIT_NOT_SUPPORTED: 'Calling submit() is not supported for this payment method',\n WRONG_INSTANCE: 'The instance of the PayPal component being used is not the same which started the payment'\n};\n"],"names":["ERRORS","NO_TOKEN_PROVIDED","SUBMIT_NOT_SUPPORTED","WRONG_INSTANCE"],"mappings":"MAAaA,EAAS,CAElBC,kBAAmB,wBAEnBC,qBAAsB,4DACtBC,eAAgB"}
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/PayPal/constants.ts"],"sourcesContent":["export const ERRORS = {\n INVALID_ACTION: 'Invalid Action',\n NO_TOKEN_PROVIDED: 'No token was provided',\n PAYPAL_OVERLAY_CLOSED: 'PayPal overlay closed',\n SUBMIT_NOT_SUPPORTED: 'Calling submit() is not supported for this payment method',\n WRONG_INSTANCE: 'The instance of the PayPal component being used is not the same which started the payment',\n PAYMENT_FAILED: 'Something went wrong during PayPal payment'\n};\n"],"names":["ERRORS","NO_TOKEN_PROVIDED","SUBMIT_NOT_SUPPORTED","WRONG_INSTANCE","PAYMENT_FAILED"],"mappings":"MAAaA,EAAS,CAElBC,kBAAmB,wBAEnBC,qBAAsB,4DACtBC,eAAgB,4FAChBC,eAAgB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import{useEffect as t,useRef as a}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../utils/useForm/useFormWithA11y.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import{getErrorMessage as
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import{useEffect as t,useRef as a}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import s from"../../../utils/useForm/useFormWithA11y.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import{getErrorMessage as n}from"../../../utils/getErrorMessage.js";import i from"../../internal/FormFields/Field/Field.js";import l from"../../internal/FormFields/InputText.js";import{bsbValidationRules as u}from"./validate.js";import{phoneFormatters as b}from"../../internal/PhoneInput/validate.js";import m from"./PayToNameFields.js";const c=["bankAccountNumber","bsb","firstName","lastName"];function d({setComponentRef:d,defaultData:p,placeholders:f,onChange:h,setStatus:F,id:N}){const{i18n:k}=o(),g=s({schema:c,defaultData:p,rules:u,formatters:b,formHolder:`#${N}`}),{handleChangeFor:v,triggerValidation:A,data:j,errors:B,valid:C,isValid:S}=g;t(()=>{h({data:j,valid:C,errors:B,isValid:S})},[j,C,B,S]);const y=a({setStatus:F,showValidation:A});return t(()=>{d(y.current)},[d]),e(r,{id:N,classNameModifiers:["payto__bsb_input"],label:"BSB",description:"payto.bsb.description"},e(i,{label:k.get("payto.bsb.label.bankAccountNumber"),classNameModifiers:["col-60","bankAccountNumber"],errorMessage:n(k,B.bankAccountNumber,k.get("payto.bsb.label.bankAccountNumber")),name:"bankAccountNumber",i18n:k,errorLive:!0},e(l,{name:"bankAccountNumber",value:j.bankAccountNumber,onInput:v("bankAccountNumber","input"),onBlur:v("bankAccountNumber","blur"),placeholder:null==f?void 0:f.bankAccountNumber,required:!0,autocomplete:void 0})),e(i,{label:k.get("Bank State Branch"),classNameModifiers:["col-40","bsb"],errorMessage:n(k,B.bsb,k.get("Bank State Branch")),name:"bsb",i18n:k,errorLive:!0},e(l,{name:"bsb",value:j.bsb,onInput:v("bsb","input"),onBlur:v("bsb","blur"),placeholder:null==f?void 0:f.bsb,required:!0,autocomplete:void 0})),e(m,{i18n:k,data:j,handleChangeFor:v,errors:B,placeholders:f}))}export{d as default};
|
|
2
2
|
//# sourceMappingURL=BSBInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BSBInput.js","sources":["../../../../../src/components/PayTo/components/BSBInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Fieldset from '../../internal/FormFields/Fieldset';\nimport { useEffect, useRef } from 'preact/hooks';\nimport { useFormWithA11y } from '../../../utils/useForm';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport Field from '../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport InputText from '../../internal/FormFields/InputText';\nimport { bsbValidationRules } from './validate';\nimport './PayIDInput.scss';\nimport { phoneFormatters } from '../../internal/PhoneInput/validate';\nimport { ComponentMethodsRef, UIElementStatus } from '../../internal/UIElement/types';\nimport PayToNameFields from './PayToNameFields';\nimport { PayToPlaceholdersType } from '../types';\n\nexport interface BSBFormData {\n bsb: string;\n bankAccountNumber: string;\n firstName: string;\n lastName: string;\n}\n\nexport interface BSBInputProps {\n status: UIElementStatus;\n setStatus: (status: UIElementStatus) => void;\n defaultData: BSBFormData;\n placeholders: PayToPlaceholdersType;\n onChange: (e) => void;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n id?: string;\n}\n\nconst BASE_SCHEMA = ['bankAccountNumber', 'bsb', 'firstName', 'lastName'];\n\nexport default function BSBInput({ setComponentRef, defaultData, placeholders, onChange, setStatus, id }: Readonly<BSBInputProps>) {\n const { i18n } = useCoreContext();\n\n const form = useFormWithA11y<BSBFormData>({\n schema: BASE_SCHEMA,\n defaultData: defaultData,\n rules: bsbValidationRules,\n formatters: phoneFormatters,\n formHolder: `#${id}`\n });\n const { handleChangeFor, triggerValidation, data, errors, valid, isValid } = form;\n\n // standard onChange propagate to parent state\n useEffect(() => {\n onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const payToRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n setComponentRef(payToRef.current);\n }, [setComponentRef]);\n\n return (\n <Fieldset id={id} classNameModifiers={['payto__bsb_input']} label={'BSB'} description={'payto.bsb.description'}>\n <Field\n label={i18n.get('payto.bsb.label.bankAccountNumber')}\n classNameModifiers={['col-60', 'bankAccountNumber']}\n errorMessage={getErrorMessage(i18n, errors.bankAccountNumber, i18n.get('payto.bsb.label.bankAccountNumber'))}\n name={'bankAccountNumber'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'bankAccountNumber'}\n value={data.bankAccountNumber}\n onInput={handleChangeFor('bankAccountNumber', 'input')}\n onBlur={handleChangeFor('bankAccountNumber', 'blur')}\n placeholder={placeholders?.bankAccountNumber}\n required={true}\n />\n </Field>\n\n <Field\n label={i18n.get('Bank State Branch')}\n classNameModifiers={['col-40', 'bsb']}\n errorMessage={getErrorMessage(i18n, errors.bsb, i18n.get('Bank State Branch'))}\n name={'bsb'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'bsb'}\n value={data.bsb}\n onInput={handleChangeFor('bsb', 'input')}\n onBlur={handleChangeFor('bsb', 'blur')}\n placeholder={placeholders?.bsb}\n required={true}\n />\n </Field>\n\n <PayToNameFields i18n={i18n} data={data} handleChangeFor={handleChangeFor} errors={errors} placeholders={placeholders} />\n </Fieldset>\n );\n}\n"],"names":["BASE_SCHEMA","BSBInput","setComponentRef","defaultData","placeholders","onChange","setStatus","id","i18n","useCoreContext","form","useFormWithA11y","schema","rules","bsbValidationRules","formatters","phoneFormatters","formHolder","handleChangeFor","triggerValidation","data","errors","valid","isValid","useEffect","payToRef","useRef","showValidation","current","h","Fieldset","classNameModifiers","label","description","Field","get","errorMessage","getErrorMessage","bankAccountNumber","name","errorLive","InputText","value","onInput","onBlur","placeholder","required","bsb","PayToNameFields"],"mappings":"4uBAgCA,MAAMA,EAAc,CAAC,oBAAqB,MAAO,YAAa,YAE/C,SAASC,GAASC,gBAAEA,EAAeC,YAAEA,EAAWC,aAAEA,EAAYC,SAAEA,EAAQC,UAAEA,EAASC,GAAEA,IAChG,MAAMC,KAAEA,GAASC,IAEXC,EAAOC,EAA6B,CACtCC,OAAQZ,EACRG,YAAaA,EACbU,MAAOC,EACPC,WAAYC,EACZC,WAAY,IAAIV,OAEdW,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,GAAYb,EAG7Ec,EAAU,KACNnB,EAAS,CAAEe,OAAME,QAAOD,SAAQE,aACjC,CAACH,EAAME,EAAOD,EAAQE,IAEzB,MAAME,EAAWC,EAA4B,CACzCpB,UAAWA,EACXqB,eAAgBR,IAOpB,OAJAK,EAAU,KACNtB,EAAgBuB,EAASG,UAC1B,CAAC1B,IAGA2B,EAACC,EAAAA,CAASvB,GAAIA,EAAIwB,mBAAoB,CAAC,oBAAqBC,MAAO,MAAOC,YAAa,yBACnFJ,EAACK,EAAAA,CACGF,MAAOxB,EAAK2B,IAAI,qCAChBJ,mBAAoB,CAAC,SAAU,qBAC/BK,aAAcC,EAAgB7B,EAAMa,EAAOiB,kBAAmB9B,EAAK2B,IAAI,sCACvEI,KAAM,oBACN/B,KAAMA,EACNgC,WAAW,GAEXX,EAACY,EAAAA,CACGF,KAAM,oBACNG,MAAOtB,EAAKkB,kBACZK,QAASzB,EAAgB,oBAAqB,SAC9C0B,OAAQ1B,EAAgB,oBAAqB,QAC7C2B,YAAazC,aAAAA,EAAAA,EAAckC,kBAC3BQ,UAAU,
|
|
1
|
+
{"version":3,"file":"BSBInput.js","sources":["../../../../../src/components/PayTo/components/BSBInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Fieldset from '../../internal/FormFields/Fieldset';\nimport { useEffect, useRef } from 'preact/hooks';\nimport { useFormWithA11y } from '../../../utils/useForm';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport Field from '../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport InputText from '../../internal/FormFields/InputText';\nimport { bsbValidationRules } from './validate';\nimport './PayIDInput.scss';\nimport { phoneFormatters } from '../../internal/PhoneInput/validate';\nimport { ComponentMethodsRef, UIElementStatus } from '../../internal/UIElement/types';\nimport PayToNameFields from './PayToNameFields';\nimport { PayToPlaceholdersType } from '../types';\n\nexport interface BSBFormData {\n bsb: string;\n bankAccountNumber: string;\n firstName: string;\n lastName: string;\n}\n\nexport interface BSBInputProps {\n status: UIElementStatus;\n setStatus: (status: UIElementStatus) => void;\n defaultData: BSBFormData;\n placeholders: PayToPlaceholdersType;\n onChange: (e) => void;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n id?: string;\n}\n\nconst BASE_SCHEMA = ['bankAccountNumber', 'bsb', 'firstName', 'lastName'];\n\nexport default function BSBInput({ setComponentRef, defaultData, placeholders, onChange, setStatus, id }: Readonly<BSBInputProps>) {\n const { i18n } = useCoreContext();\n\n const form = useFormWithA11y<BSBFormData>({\n schema: BASE_SCHEMA,\n defaultData: defaultData,\n rules: bsbValidationRules,\n formatters: phoneFormatters,\n formHolder: `#${id}`\n });\n const { handleChangeFor, triggerValidation, data, errors, valid, isValid } = form;\n\n // standard onChange propagate to parent state\n useEffect(() => {\n onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const payToRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n setComponentRef(payToRef.current);\n }, [setComponentRef]);\n\n return (\n <Fieldset id={id} classNameModifiers={['payto__bsb_input']} label={'BSB'} description={'payto.bsb.description'}>\n <Field\n label={i18n.get('payto.bsb.label.bankAccountNumber')}\n classNameModifiers={['col-60', 'bankAccountNumber']}\n errorMessage={getErrorMessage(i18n, errors.bankAccountNumber, i18n.get('payto.bsb.label.bankAccountNumber'))}\n name={'bankAccountNumber'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'bankAccountNumber'}\n value={data.bankAccountNumber}\n onInput={handleChangeFor('bankAccountNumber', 'input')}\n onBlur={handleChangeFor('bankAccountNumber', 'blur')}\n placeholder={placeholders?.bankAccountNumber}\n required={true}\n autocomplete={undefined}\n />\n </Field>\n\n <Field\n label={i18n.get('Bank State Branch')}\n classNameModifiers={['col-40', 'bsb']}\n errorMessage={getErrorMessage(i18n, errors.bsb, i18n.get('Bank State Branch'))}\n name={'bsb'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'bsb'}\n value={data.bsb}\n onInput={handleChangeFor('bsb', 'input')}\n onBlur={handleChangeFor('bsb', 'blur')}\n placeholder={placeholders?.bsb}\n required={true}\n autocomplete={undefined}\n />\n </Field>\n\n <PayToNameFields i18n={i18n} data={data} handleChangeFor={handleChangeFor} errors={errors} placeholders={placeholders} />\n </Fieldset>\n );\n}\n"],"names":["BASE_SCHEMA","BSBInput","setComponentRef","defaultData","placeholders","onChange","setStatus","id","i18n","useCoreContext","form","useFormWithA11y","schema","rules","bsbValidationRules","formatters","phoneFormatters","formHolder","handleChangeFor","triggerValidation","data","errors","valid","isValid","useEffect","payToRef","useRef","showValidation","current","h","Fieldset","classNameModifiers","label","description","Field","get","errorMessage","getErrorMessage","bankAccountNumber","name","errorLive","InputText","value","onInput","onBlur","placeholder","required","autocomplete","undefined","bsb","PayToNameFields"],"mappings":"4uBAgCA,MAAMA,EAAc,CAAC,oBAAqB,MAAO,YAAa,YAE/C,SAASC,GAASC,gBAAEA,EAAeC,YAAEA,EAAWC,aAAEA,EAAYC,SAAEA,EAAQC,UAAEA,EAASC,GAAEA,IAChG,MAAMC,KAAEA,GAASC,IAEXC,EAAOC,EAA6B,CACtCC,OAAQZ,EACRG,YAAaA,EACbU,MAAOC,EACPC,WAAYC,EACZC,WAAY,IAAIV,OAEdW,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,GAAYb,EAG7Ec,EAAU,KACNnB,EAAS,CAAEe,OAAME,QAAOD,SAAQE,aACjC,CAACH,EAAME,EAAOD,EAAQE,IAEzB,MAAME,EAAWC,EAA4B,CACzCpB,UAAWA,EACXqB,eAAgBR,IAOpB,OAJAK,EAAU,KACNtB,EAAgBuB,EAASG,UAC1B,CAAC1B,IAGA2B,EAACC,EAAAA,CAASvB,GAAIA,EAAIwB,mBAAoB,CAAC,oBAAqBC,MAAO,MAAOC,YAAa,yBACnFJ,EAACK,EAAAA,CACGF,MAAOxB,EAAK2B,IAAI,qCAChBJ,mBAAoB,CAAC,SAAU,qBAC/BK,aAAcC,EAAgB7B,EAAMa,EAAOiB,kBAAmB9B,EAAK2B,IAAI,sCACvEI,KAAM,oBACN/B,KAAMA,EACNgC,WAAW,GAEXX,EAACY,EAAAA,CACGF,KAAM,oBACNG,MAAOtB,EAAKkB,kBACZK,QAASzB,EAAgB,oBAAqB,SAC9C0B,OAAQ1B,EAAgB,oBAAqB,QAC7C2B,YAAazC,aAAAA,EAAAA,EAAckC,kBAC3BQ,UAAU,EACVC,kBAAcC,KAItBnB,EAACK,EAAAA,CACGF,MAAOxB,EAAK2B,IAAI,qBAChBJ,mBAAoB,CAAC,SAAU,OAC/BK,aAAcC,EAAgB7B,EAAMa,EAAO4B,IAAKzC,EAAK2B,IAAI,sBACzDI,KAAM,MACN/B,KAAMA,EACNgC,WAAW,GAEXX,EAACY,EAAAA,CACGF,KAAM,MACNG,MAAOtB,EAAK6B,IACZN,QAASzB,EAAgB,MAAO,SAChC0B,OAAQ1B,EAAgB,MAAO,QAC/B2B,YAAazC,aAAAA,EAAAA,EAAc6C,IAC3BH,UAAU,EACVC,kBAAcC,KAItBnB,EAACqB,EAAAA,CAAgB1C,KAAMA,EAAMY,KAAMA,EAAMF,gBAAiBA,EAAiBG,OAAQA,EAAQjB,aAAcA,IAGrH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import i,{PayToIdentifierEnum as t}from"./IdentifierSelector.js";import{useEffect as o,useRef as a}from"../../../external/preact/hooks/dist/hooks.js";import l from"../../../utils/useForm/useFormWithA11y.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import i,{PayToIdentifierEnum as t}from"./IdentifierSelector.js";import{useEffect as o,useRef as a}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as l}from"../../../core/Context/CoreProvider.js";import n from"../../../utils/useForm/useFormWithA11y.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import s from"./PayToPhone.js";import d from"../../internal/FormFields/InputEmail.js";import{getErrorMessage as m}from"../../../utils/getErrorMessage.js";import p from"../../internal/FormFields/Field/Field.js";import c from"../../internal/FormFields/InputText.js";import{payIdValidationRules as u}from"./validate.js";import{phoneFormatters as f}from"../../internal/PhoneInput/validate.js";import g from"./PayToNameFields.js";function b(e,r,i){return r in e?Object.defineProperty(e,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[r]=i,e}function h(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{},t=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),t.forEach(function(r){b(e,r,i[r])})}return e}const j=["selectedIdentifier","firstName","lastName"],y={[t.email]:["email"],[t.phone]:["phoneNumber","phonePrefix"],[t.abn]:["abn"],[t.orgid]:["orgid"]};function I({setComponentRef:b,defaultData:I,placeholders:v,onChange:F,setStatus:N,id:P}){const{i18n:M}=l(),S=n({schema:j,defaultData:h({selectedIdentifier:t.phone},I),rules:u,formatters:f,formHolder:`#${P}`}),{handleChangeFor:O,triggerValidation:C,data:E,errors:x,valid:B,isValid:w,setSchema:A}=S;o(()=>{A([...y[E.selectedIdentifier],...j])},[E.selectedIdentifier]),o(()=>{F({data:E,valid:B,errors:x,isValid:w})},[E,B,x,w]);const D=a({setStatus:N,showValidation:C});return o(()=>{b(D.current)},[b]),e(r,{id:P,classNameModifiers:["payto__payid_input"],label:"PayID",description:"payto.payid.description"},e(i,{classNameModifiers:["col-40"],onSelectedIdentifier:O("selectedIdentifier"),selectedIdentifier:E.selectedIdentifier}),E.selectedIdentifier===t.phone&&e(s,{form:S}),E.selectedIdentifier===t.email&&e(p,{label:M.get("shopperEmail"),classNameModifiers:["col-60","email"],errorMessage:m(M,x.email,M.get("shopperEmail")),dir:"ltr",name:"email",i18n:M,errorLive:!0},e(d,{name:"email",value:E.email,onInput:O("email","input"),onBlur:O("email","blur"),placeholder:null==v?void 0:v.email,required:!0,autocomplete:"email"})),E.selectedIdentifier===t.abn&&e(p,{label:M.get("ABN"),classNameModifiers:["col-60","abn"],errorMessage:m(M,x.abn,M.get("ABN")),name:"ABN",i18n:M,errorLive:!0},e(c,{name:"abn",value:E.abn,onInput:O("abn","input"),onBlur:O("abn","blur"),placeholder:null==v?void 0:v.abn,required:!0,autocomplete:void 0})),E.selectedIdentifier===t.orgid&&e(p,{label:M.get("payto.payid.label.orgid"),classNameModifiers:["col-60","orgid"],errorMessage:m(M,x.orgid,M.get("payto.payid.label.orgid")),name:"orgid",i18n:M,errorLive:!0},e(c,{name:"orgid",value:E.orgid,onInput:O("orgid","input"),onBlur:O("orgid","blur"),placeholder:null==v?void 0:v.orgid,required:!0,autocomplete:void 0})),e(g,{i18n:M,data:E,handleChangeFor:O,errors:x,placeholders:v}))}export{I as default};
|
|
2
2
|
//# sourceMappingURL=PayIDInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayIDInput.js","sources":["../../../../../src/components/PayTo/components/PayIDInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Fieldset from '../../internal/FormFields/Fieldset';\nimport IdentifierSelector, { PayToIdentifierEnum } from './IdentifierSelector';\nimport { useEffect, useRef } from 'preact/hooks';\nimport { useFormWithA11y } from '../../../utils/useForm';\nimport PayToPhone from './PayToPhone';\nimport InputEmail from '../../internal/FormFields/InputEmail';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport Field from '../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport InputText from '../../internal/FormFields/InputText';\nimport { payIdValidationRules } from './validate';\nimport './PayIDInput.scss';\nimport { phoneFormatters } from '../../internal/PhoneInput/validate';\nimport { ComponentMethodsRef, UIElementStatus } from '../../internal/UIElement/types';\nimport PayToNameFields from './PayToNameFields';\nimport { PayToPlaceholdersType } from '../types';\n\nexport interface PayIdFormData {\n email: string;\n phone: string;\n abn: string;\n orgid: string;\n firstName: string;\n lastName: string;\n phoneNumber?: string;\n phonePrefix?: string;\n selectedIdentifier: PayToIdentifierEnum;\n}\n\nexport interface PayIDInputProps {\n status: UIElementStatus;\n setStatus: (status: UIElementStatus) => void;\n defaultData: PayIdFormData;\n placeholders: PayToPlaceholdersType;\n onChange: (e) => void;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n id?: string;\n}\n\nconst BASE_SCHEMA = ['selectedIdentifier', 'firstName', 'lastName'];\n\nconst IDENTIFIER_SCHEMA = {\n [PayToIdentifierEnum.email]: ['email'],\n [PayToIdentifierEnum.phone]: ['phoneNumber', 'phonePrefix'],\n [PayToIdentifierEnum.abn]: ['abn'],\n [PayToIdentifierEnum.orgid]: ['orgid']\n};\n\nexport default function PayIDInput({ setComponentRef, defaultData, placeholders, onChange, setStatus, id }: Readonly<PayIDInputProps>) {\n const { i18n } = useCoreContext();\n\n const form = useFormWithA11y<PayIdFormData>({\n schema: BASE_SCHEMA,\n defaultData: { selectedIdentifier: PayToIdentifierEnum.phone, ...defaultData },\n rules: payIdValidationRules,\n formatters: phoneFormatters,\n formHolder: `#${id}`\n });\n const { handleChangeFor, triggerValidation, data, errors, valid, isValid, setSchema } = form;\n\n // handle the changes of identifier, each identifier gets its own schema\n useEffect(() => {\n // get the correct schema for each identifier and merge it with the base\n setSchema([...IDENTIFIER_SCHEMA[data.selectedIdentifier], ...BASE_SCHEMA]);\n }, [data.selectedIdentifier]);\n\n // standard onChange propagate to parent state\n useEffect(() => {\n onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const payToRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n setComponentRef(payToRef.current);\n }, [setComponentRef]);\n\n return (\n <Fieldset id={id} classNameModifiers={['payto__payid_input']} label={'PayID'} description={'payto.payid.description'}>\n <IdentifierSelector\n classNameModifiers={['col-40']}\n onSelectedIdentifier={handleChangeFor('selectedIdentifier')}\n selectedIdentifier={data.selectedIdentifier}\n />\n {data.selectedIdentifier === PayToIdentifierEnum.phone && <PayToPhone form={form} />}\n\n {/* TODO probably worth refactoring this into either re-usable components or builder */}\n {data.selectedIdentifier === PayToIdentifierEnum.email && (\n <Field\n label={i18n.get('shopperEmail')}\n classNameModifiers={['col-60', 'email']}\n errorMessage={getErrorMessage(i18n, errors.email, i18n.get('shopperEmail'))}\n dir={'ltr'}\n name={'email'}\n i18n={i18n}\n errorLive={true}\n >\n <InputEmail\n name={'email'}\n value={data.email}\n onInput={handleChangeFor('email', 'input')}\n onBlur={handleChangeFor('email', 'blur')}\n placeholder={placeholders?.email}\n required={true}\n />\n </Field>\n )}\n\n {data.selectedIdentifier === PayToIdentifierEnum.abn && (\n <Field\n label={i18n.get('ABN')}\n classNameModifiers={['col-60', 'abn']}\n errorMessage={getErrorMessage(i18n, errors.abn, i18n.get('ABN'))}\n name={'ABN'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'abn'}\n value={data.abn}\n onInput={handleChangeFor('abn', 'input')}\n onBlur={handleChangeFor('abn', 'blur')}\n placeholder={placeholders?.abn}\n required={true}\n />\n </Field>\n )}\n\n {data.selectedIdentifier === PayToIdentifierEnum.orgid && (\n <Field\n label={i18n.get('payto.payid.label.orgid')}\n classNameModifiers={['col-60', 'orgid']}\n errorMessage={getErrorMessage(i18n, errors.orgid, i18n.get('payto.payid.label.orgid'))}\n name={'orgid'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'orgid'}\n value={data.orgid}\n onInput={handleChangeFor('orgid', 'input')}\n onBlur={handleChangeFor('orgid', 'blur')}\n placeholder={placeholders?.orgid}\n required={true}\n />\n </Field>\n )}\n\n <PayToNameFields i18n={i18n} data={data} handleChangeFor={handleChangeFor} errors={errors} placeholders={placeholders} />\n </Fieldset>\n );\n}\n"],"names":["BASE_SCHEMA","IDENTIFIER_SCHEMA","PayToIdentifierEnum","email","phone","abn","orgid","PayIDInput","setComponentRef","defaultData","placeholders","onChange","setStatus","id","i18n","useCoreContext","form","useFormWithA11y","schema","_object_spread","selectedIdentifier","rules","payIdValidationRules","formatters","phoneFormatters","formHolder","handleChangeFor","triggerValidation","data","errors","valid","isValid","setSchema","useEffect","payToRef","useRef","showValidation","current","h","Fieldset","classNameModifiers","label","description","IdentifierSelector","onSelectedIdentifier","PayToPhone","Field","get","errorMessage","getErrorMessage","dir","name","errorLive","InputEmail","value","onInput","onBlur","placeholder","required","InputText","PayToNameFields"],"mappings":"i0CAwCA,MAAMA,EAAc,CAAC,qBAAsB,YAAa,YAElDC,EAAoB,CACtB,CAACC,EAAoBC,OAAQ,CAAC,SAC9B,CAACD,EAAoBE,OAAQ,CAAC,cAAe,eAC7C,CAACF,EAAoBG,KAAM,CAAC,OAC5B,CAACH,EAAoBI,OAAQ,CAAC,UAGnB,SAASC,GAAWC,gBAAEA,EAAeC,YAAEA,EAAWC,aAAEA,EAAYC,SAAEA,EAAQC,UAAEA,EAASC,GAAEA,IAClG,MAAMC,KAAEA,GAASC,IAEXC,EAAOC,EAA+B,CACxCC,OAAQlB,EACRS,YAAaU,EAAA,CAAEC,mBAAoBlB,EAAoBE,OAAUK,GACjEY,MAAOC,EACPC,WAAYC,EACZC,WAAY,IAAIZ,OAEda,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,EAAOC,UAAEA,GAAchB,EAGxFiB,EAAU,KAEND,EAAU,IAAI/B,EAAkB2B,EAAKR,uBAAwBpB,KAC9D,CAAC4B,EAAKR,qBAGTa,EAAU,KACNtB,EAAS,CAAEiB,OAAME,QAAOD,SAAQE,aACjC,CAACH,EAAME,EAAOD,EAAQE,IAEzB,MAAMG,EAAWC,EAA4B,CACzCvB,UAAWA,EACXwB,eAAgBT,IAOpB,OAJAM,EAAU,KACNzB,EAAgB0B,EAASG,UAC1B,CAAC7B,IAGA8B,EAACC,EAAAA,CAAS1B,GAAIA,EAAI2B,mBAAoB,CAAC,sBAAuBC,MAAO,QAASC,YAAa,2BACvFJ,EAACK,EAAAA,CACGH,mBAAoB,CAAC,UACrBI,qBAAsBlB,EAAgB,sBACtCN,mBAAoBQ,EAAKR,qBAE5BQ,EAAKR,qBAAuBlB,EAAoBE,OAASkC,EAACO,EAAAA,CAAW7B,KAAMA,IAG3EY,EAAKR,qBAAuBlB,EAAoBC,OAC7CmC,EAACQ,EAAAA,CACGL,MAAO3B,EAAKiC,IAAI,gBAChBP,mBAAoB,CAAC,SAAU,SAC/BQ,aAAcC,EAAgBnC,EAAMe,EAAO1B,MAAOW,EAAKiC,IAAI,iBAC3DG,IAAK,MACLC,KAAM,QACNrC,KAAMA,EACNsC,WAAW,GAEXd,EAACe,EAAAA,CACGF,KAAM,QACNG,MAAO1B,EAAKzB,MACZoD,QAAS7B,EAAgB,QAAS,SAClC8B,OAAQ9B,EAAgB,QAAS,QACjC+B,YAAa/C,aAAAA,EAAAA,EAAcP,MAC3BuD,UAAU,
|
|
1
|
+
{"version":3,"file":"PayIDInput.js","sources":["../../../../../src/components/PayTo/components/PayIDInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Fieldset from '../../internal/FormFields/Fieldset';\nimport IdentifierSelector, { PayToIdentifierEnum } from './IdentifierSelector';\nimport { useEffect, useRef } from 'preact/hooks';\nimport { useFormWithA11y } from '../../../utils/useForm';\nimport PayToPhone from './PayToPhone';\nimport InputEmail from '../../internal/FormFields/InputEmail';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport Field from '../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport InputText from '../../internal/FormFields/InputText';\nimport { payIdValidationRules } from './validate';\nimport './PayIDInput.scss';\nimport { phoneFormatters } from '../../internal/PhoneInput/validate';\nimport { ComponentMethodsRef, UIElementStatus } from '../../internal/UIElement/types';\nimport PayToNameFields from './PayToNameFields';\nimport { PayToPlaceholdersType } from '../types';\n\nexport interface PayIdFormData {\n email: string;\n phone: string;\n abn: string;\n orgid: string;\n firstName: string;\n lastName: string;\n phoneNumber?: string;\n phonePrefix?: string;\n selectedIdentifier: PayToIdentifierEnum;\n}\n\nexport interface PayIDInputProps {\n status: UIElementStatus;\n setStatus: (status: UIElementStatus) => void;\n defaultData: PayIdFormData;\n placeholders: PayToPlaceholdersType;\n onChange: (e) => void;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n id?: string;\n}\n\nconst BASE_SCHEMA = ['selectedIdentifier', 'firstName', 'lastName'];\n\nconst IDENTIFIER_SCHEMA = {\n [PayToIdentifierEnum.email]: ['email'],\n [PayToIdentifierEnum.phone]: ['phoneNumber', 'phonePrefix'],\n [PayToIdentifierEnum.abn]: ['abn'],\n [PayToIdentifierEnum.orgid]: ['orgid']\n};\n\nexport default function PayIDInput({ setComponentRef, defaultData, placeholders, onChange, setStatus, id }: Readonly<PayIDInputProps>) {\n const { i18n } = useCoreContext();\n\n const form = useFormWithA11y<PayIdFormData>({\n schema: BASE_SCHEMA,\n defaultData: { selectedIdentifier: PayToIdentifierEnum.phone, ...defaultData },\n rules: payIdValidationRules,\n formatters: phoneFormatters,\n formHolder: `#${id}`\n });\n const { handleChangeFor, triggerValidation, data, errors, valid, isValid, setSchema } = form;\n\n // handle the changes of identifier, each identifier gets its own schema\n useEffect(() => {\n // get the correct schema for each identifier and merge it with the base\n setSchema([...IDENTIFIER_SCHEMA[data.selectedIdentifier], ...BASE_SCHEMA]);\n }, [data.selectedIdentifier]);\n\n // standard onChange propagate to parent state\n useEffect(() => {\n onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const payToRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n setComponentRef(payToRef.current);\n }, [setComponentRef]);\n\n return (\n <Fieldset id={id} classNameModifiers={['payto__payid_input']} label={'PayID'} description={'payto.payid.description'}>\n <IdentifierSelector\n classNameModifiers={['col-40']}\n onSelectedIdentifier={handleChangeFor('selectedIdentifier')}\n selectedIdentifier={data.selectedIdentifier}\n />\n {data.selectedIdentifier === PayToIdentifierEnum.phone && <PayToPhone form={form} />}\n\n {/* TODO probably worth refactoring this into either re-usable components or builder */}\n {data.selectedIdentifier === PayToIdentifierEnum.email && (\n <Field\n label={i18n.get('shopperEmail')}\n classNameModifiers={['col-60', 'email']}\n errorMessage={getErrorMessage(i18n, errors.email, i18n.get('shopperEmail'))}\n dir={'ltr'}\n name={'email'}\n i18n={i18n}\n errorLive={true}\n >\n <InputEmail\n name={'email'}\n value={data.email}\n onInput={handleChangeFor('email', 'input')}\n onBlur={handleChangeFor('email', 'blur')}\n placeholder={placeholders?.email}\n required={true}\n autocomplete={'email'}\n />\n </Field>\n )}\n\n {data.selectedIdentifier === PayToIdentifierEnum.abn && (\n <Field\n label={i18n.get('ABN')}\n classNameModifiers={['col-60', 'abn']}\n errorMessage={getErrorMessage(i18n, errors.abn, i18n.get('ABN'))}\n name={'ABN'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'abn'}\n value={data.abn}\n onInput={handleChangeFor('abn', 'input')}\n onBlur={handleChangeFor('abn', 'blur')}\n placeholder={placeholders?.abn}\n required={true}\n autocomplete={undefined}\n />\n </Field>\n )}\n\n {data.selectedIdentifier === PayToIdentifierEnum.orgid && (\n <Field\n label={i18n.get('payto.payid.label.orgid')}\n classNameModifiers={['col-60', 'orgid']}\n errorMessage={getErrorMessage(i18n, errors.orgid, i18n.get('payto.payid.label.orgid'))}\n name={'orgid'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'orgid'}\n value={data.orgid}\n onInput={handleChangeFor('orgid', 'input')}\n onBlur={handleChangeFor('orgid', 'blur')}\n placeholder={placeholders?.orgid}\n required={true}\n autocomplete={undefined}\n />\n </Field>\n )}\n\n <PayToNameFields i18n={i18n} data={data} handleChangeFor={handleChangeFor} errors={errors} placeholders={placeholders} />\n </Fieldset>\n );\n}\n"],"names":["BASE_SCHEMA","IDENTIFIER_SCHEMA","PayToIdentifierEnum","email","phone","abn","orgid","PayIDInput","setComponentRef","defaultData","placeholders","onChange","setStatus","id","i18n","useCoreContext","form","useFormWithA11y","schema","_object_spread","selectedIdentifier","rules","payIdValidationRules","formatters","phoneFormatters","formHolder","handleChangeFor","triggerValidation","data","errors","valid","isValid","setSchema","useEffect","payToRef","useRef","showValidation","current","h","Fieldset","classNameModifiers","label","description","IdentifierSelector","onSelectedIdentifier","PayToPhone","Field","get","errorMessage","getErrorMessage","dir","name","errorLive","InputEmail","value","onInput","onBlur","placeholder","required","autocomplete","InputText","undefined","PayToNameFields"],"mappings":"i0CAwCA,MAAMA,EAAc,CAAC,qBAAsB,YAAa,YAElDC,EAAoB,CACtB,CAACC,EAAoBC,OAAQ,CAAC,SAC9B,CAACD,EAAoBE,OAAQ,CAAC,cAAe,eAC7C,CAACF,EAAoBG,KAAM,CAAC,OAC5B,CAACH,EAAoBI,OAAQ,CAAC,UAGnB,SAASC,GAAWC,gBAAEA,EAAeC,YAAEA,EAAWC,aAAEA,EAAYC,SAAEA,EAAQC,UAAEA,EAASC,GAAEA,IAClG,MAAMC,KAAEA,GAASC,IAEXC,EAAOC,EAA+B,CACxCC,OAAQlB,EACRS,YAAaU,EAAA,CAAEC,mBAAoBlB,EAAoBE,OAAUK,GACjEY,MAAOC,EACPC,WAAYC,EACZC,WAAY,IAAIZ,OAEda,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,OAAEA,EAAM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AW,GAEXd,EAACsB,EAAAA,CACGT,KAAM,MACNG,MAAO1B,EAAKvB,IACZkD,QAAS7B,EAAgB,MAAO,SAChC8B,OAAQ9B,EAAgB,MAAO,QAC/B+B,YAAa/C,aAAAA,EAAAA,EAAcL,IAC3BqD,UAAU,EACVC,kBAAcE,KAKzBjC,EAAKR,qBAAuBlB,EAAoBI,OAC7CgC,EAACQ,EAAAA,CACGL,MAAO3B,EAAKiC,IAAI,2BAChBP,mBAAoB,CAAC,SAAU,SAC/BQ,aAAcC,EAAgBnC,EAAMe,EAAOvB,MAAOQ,EAAKiC,IAAI,4BAC3DI,KAAM,QACNrC,KAAMA,EACNsC,WAAW,GAEXd,EAACsB,EAAAA,CACGT,KAAM,QACNG,MAAO1B,EAAKtB,MACZiD,QAAS7B,EAAgB,QAAS,SAClC8B,OAAQ9B,EAAgB,QAAS,QACjC+B,YAAa/C,aAAAA,EAAAA,EAAcJ,MAC3BoD,UAAU,EACVC,kBAAcE,KAK1BvB,EAACwB,EAAAA,CAAgBhD,KAAMA,EAAMc,KAAMA,EAAMF,gBAAiBA,EAAiBG,OAAQA,EAAQnB,aAAcA,IAGrH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as a}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Field/Field.js";import{getErrorMessage as l}from"../../../utils/getErrorMessage.js";import
|
|
1
|
+
import{createElement as e,Fragment as a}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Field/Field.js";import{getErrorMessage as l}from"../../../utils/getErrorMessage.js";import t from"../../internal/FormFields/InputText.js";function s({i18n:s,errors:m,data:i,handleChangeFor:o,placeholders:n}){return e(a,null,e(r,{label:s.get("payto.label.firstName"),classNameModifiers:["col-50","firstName"],errorMessage:l(s,m.firstName,s.get("firstName")),name:"firstName",i18n:s,errorLive:!0},e(t,{name:"firstName",value:i.firstName,classNameModifiers:["firstName"],onInput:o("firstName","input"),onBlur:o("firstName","input"),placeholder:null==n?void 0:n.firstName,spellcheck:!1,required:!0,autocomplete:"given-name"})),e(r,{label:s.get("payto.label.lastName"),classNameModifiers:["col-50","lastName"],errorMessage:l(s,m.lastName,s.get("lastName")),name:"lastName",i18n:s,errorLive:!0},e(t,{name:"lastName",value:i.lastName,classNameModifiers:["lastName"],onInput:o("lastName","input"),onBlur:o("lastName","blur"),placeholder:null==n?void 0:n.lastName,spellcheck:!1,required:!0,autocomplete:"family-name"})))}export{s as default};
|
|
2
2
|
//# sourceMappingURL=PayToNameFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayToNameFields.js","sources":["../../../../../src/components/PayTo/components/PayToNameFields.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport Field from '../../internal/FormFields/Field';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport InputText from '../../internal/FormFields/InputText';\nimport Language from '../../../language';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\nimport { ValidationRuleResult } from '../../../utils/Validator/ValidationRuleResult';\n\nexport interface PayToNameFieldsProps {\n i18n: Language;\n errors: {\n [key: string]: ValidationRuleResult;\n };\n data: {\n firstName: string;\n lastName: string;\n };\n handleChangeFor: (key: string, mode?: HandleChangeForModeType) => (e: h.JSX.TargetedEvent<HTMLInputElement, Event>) => void;\n placeholders: {\n firstName: string;\n lastName: string;\n };\n}\n\nexport default function PayToNameFields({ i18n, errors, data, handleChangeFor, placeholders }: Readonly<PayToNameFieldsProps>) {\n return (\n <Fragment>\n <Field\n label={i18n.get('payto.label.firstName')}\n classNameModifiers={['col-50', 'firstName']}\n errorMessage={getErrorMessage(i18n, errors.firstName, i18n.get('firstName'))}\n name={'firstName'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'firstName'}\n value={data.firstName}\n classNameModifiers={['firstName']}\n onInput={handleChangeFor('firstName', 'input')}\n onBlur={handleChangeFor('firstName', 'input')}\n placeholder={placeholders?.firstName}\n spellcheck={false}\n required={true}\n />\n </Field>\n <Field\n label={i18n.get('payto.label.lastName')}\n classNameModifiers={['col-50', 'lastName']}\n errorMessage={getErrorMessage(i18n, errors.lastName, i18n.get('lastName'))}\n name={'lastName'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'lastName'}\n value={data.lastName}\n classNameModifiers={['lastName']}\n onInput={handleChangeFor('lastName', 'input')}\n onBlur={handleChangeFor('lastName', 'blur')}\n placeholder={placeholders?.lastName}\n spellcheck={false}\n required={true}\n />\n </Field>\n </Fragment>\n );\n}\n"],"names":["PayToNameFields","i18n","errors","data","handleChangeFor","placeholders","h","Fragment","Field","label","get","classNameModifiers","errorMessage","getErrorMessage","firstName","name","errorLive","InputText","value","onInput","onBlur","placeholder","spellcheck","required","lastName"],"mappings":"wQAwBe,SAASA,GAAgBC,KAAEA,EAAIC,OAAEA,EAAMC,KAAEA,EAAIC,gBAAEA,EAAeC,aAAEA,IAC3E,OACIC,EAACC,OACGD,EAACE,EAAAA,CACGC,MAAOR,EAAKS,IAAI,yBAChBC,mBAAoB,CAAC,SAAU,aAC/BC,aAAcC,EAAgBZ,EAAMC,EAAOY,UAAWb,EAAKS,IAAI,cAC/DK,KAAM,YACNd,KAAMA,EACNe,WAAW,GAEXV,EAACW,EAAAA,CACGF,KAAM,YACNG,MAAOf,EAAKW,UACZH,mBAAoB,CAAC,aACrBQ,QAASf,EAAgB,YAAa,SACtCgB,OAAQhB,EAAgB,YAAa,SACrCiB,YAAahB,aAAAA,EAAAA,EAAcS,UAC3BQ,YAAY,EACZC,UAAU,
|
|
1
|
+
{"version":3,"file":"PayToNameFields.js","sources":["../../../../../src/components/PayTo/components/PayToNameFields.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport Field from '../../internal/FormFields/Field';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport InputText from '../../internal/FormFields/InputText';\nimport Language from '../../../language';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\nimport { ValidationRuleResult } from '../../../utils/Validator/ValidationRuleResult';\n\nexport interface PayToNameFieldsProps {\n i18n: Language;\n errors: {\n [key: string]: ValidationRuleResult;\n };\n data: {\n firstName: string;\n lastName: string;\n };\n handleChangeFor: (key: string, mode?: HandleChangeForModeType) => (e: h.JSX.TargetedEvent<HTMLInputElement, Event>) => void;\n placeholders: {\n firstName: string;\n lastName: string;\n };\n}\n\nexport default function PayToNameFields({ i18n, errors, data, handleChangeFor, placeholders }: Readonly<PayToNameFieldsProps>) {\n return (\n <Fragment>\n <Field\n label={i18n.get('payto.label.firstName')}\n classNameModifiers={['col-50', 'firstName']}\n errorMessage={getErrorMessage(i18n, errors.firstName, i18n.get('firstName'))}\n name={'firstName'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'firstName'}\n value={data.firstName}\n classNameModifiers={['firstName']}\n onInput={handleChangeFor('firstName', 'input')}\n onBlur={handleChangeFor('firstName', 'input')}\n placeholder={placeholders?.firstName}\n spellcheck={false}\n required={true}\n autocomplete={'given-name'}\n />\n </Field>\n <Field\n label={i18n.get('payto.label.lastName')}\n classNameModifiers={['col-50', 'lastName']}\n errorMessage={getErrorMessage(i18n, errors.lastName, i18n.get('lastName'))}\n name={'lastName'}\n i18n={i18n}\n errorLive={true}\n >\n <InputText\n name={'lastName'}\n value={data.lastName}\n classNameModifiers={['lastName']}\n onInput={handleChangeFor('lastName', 'input')}\n onBlur={handleChangeFor('lastName', 'blur')}\n placeholder={placeholders?.lastName}\n spellcheck={false}\n required={true}\n autocomplete={'family-name'}\n />\n </Field>\n </Fragment>\n );\n}\n"],"names":["PayToNameFields","i18n","errors","data","handleChangeFor","placeholders","h","Fragment","Field","label","get","classNameModifiers","errorMessage","getErrorMessage","firstName","name","errorLive","InputText","value","onInput","onBlur","placeholder","spellcheck","required","autocomplete","lastName"],"mappings":"wQAwBe,SAASA,GAAgBC,KAAEA,EAAIC,OAAEA,EAAMC,KAAEA,EAAIC,gBAAEA,EAAeC,aAAEA,IAC3E,OACIC,EAACC,OACGD,EAACE,EAAAA,CACGC,MAAOR,EAAKS,IAAI,yBAChBC,mBAAoB,CAAC,SAAU,aAC/BC,aAAcC,EAAgBZ,EAAMC,EAAOY,UAAWb,EAAKS,IAAI,cAC/DK,KAAM,YACNd,KAAMA,EACNe,WAAW,GAEXV,EAACW,EAAAA,CACGF,KAAM,YACNG,MAAOf,EAAKW,UACZH,mBAAoB,CAAC,aACrBQ,QAASf,EAAgB,YAAa,SACtCgB,OAAQhB,EAAgB,YAAa,SACrCiB,YAAahB,aAAAA,EAAAA,EAAcS,UAC3BQ,YAAY,EACZC,UAAU,EACVC,aAAc,gBAGtBlB,EAACE,EAAAA,CACGC,MAAOR,EAAKS,IAAI,wBAChBC,mBAAoB,CAAC,SAAU,YAC/BC,aAAcC,EAAgBZ,EAAMC,EAAOuB,SAAUxB,EAAKS,IAAI,aAC9DK,KAAM,WACNd,KAAMA,EACNe,WAAW,GAEXV,EAACW,EAAAA,CACGF,KAAM,WACNG,MAAOf,EAAKsB,SACZd,mBAAoB,CAAC,YACrBQ,QAASf,EAAgB,WAAY,SACrCgB,OAAQhB,EAAgB,WAAY,QACpCiB,YAAahB,aAAAA,EAAAA,EAAcoB,SAC3BH,YAAY,EACZC,UAAU,EACVC,aAAc,iBAKlC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import"../../internal/QRLoader/QRLoader.js";import{QRImage as o}from"../../internal/QRLoader/components/QRImage.js";import{QRProgressbar as r}from"../../internal/QRLoader/components/QRProgressbar.js";import{QRCountdown as
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import"../../internal/QRLoader/QRLoader.js";import{QRImage as o}from"../../internal/QRLoader/components/QRImage.js";import{QRProgressbar as r}from"../../internal/QRLoader/components/QRProgressbar.js";import{QRCountdown as t}from"../../internal/QRLoader/components/QRCountdown.js";import{useCoreContext as a}from"../../../core/Context/CoreProvider.js";import{QRCodeCopyButton as n}from"../../internal/QRLoader/components/QRCodeCopyButton.js";import{useQRLoaderDetails as i}from"../../internal/QRLoader/QRLoaderDetailsProvider.js";import d from"../../internal/FormFields/Field/Field.js";import l from"../../internal/FormFields/InputText.js";import{TxVariants as m}from"../../tx-variants.js";const p=()=>{const{i18n:p}=a(),{qrCodeData:s,qrCodeImage:c,percentage:_,timeToPay:x,onTick:u,countdownTime:L,onQRCodeLoad:Q,onTimeUp:R,handleCopy:y}=i();return e("div",{className:"adyen-checkout__qr-loader--pix__qr_details"},e(o,{type:m.pix,src:c,onLoad:Q}),e("div",{className:"adyen-checkout__qr-loader--pix__qr_details__timer"},e(r,{percentage:_}),e(t,{countdownTime:L,timeToPay:x,onTick:u,onCompleted:R})),e(d,{name:"pix-code",useLabelElement:!1},e(l,{className:"adyen-checkout__qr-loader--pix__qr_details__code",value:s,readonly:!0,"aria-label":p.get("pix.code.label"),autocomplete:void 0})),e(n,{text:s,copyLabel:p.get("pix.code.copy.label"),copiedLabel:p.get("pix.code.copied.label"),handleCopy:y}))};export{p as default};
|
|
2
2
|
//# sourceMappingURL=PixQRDetails.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PixQRDetails.js","sources":["../../../../../src/components/Pix/components/PixQRDetails.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { QRImage, QRProgressbar, QRCountdown, QRCodeCopyButton, useQRLoaderDetails } from '../../internal/QRLoader';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../../internal/FormFields/Field';\nimport InputText from '../../internal/FormFields/InputText';\nimport { TxVariants } from '../../tx-variants';\n\nconst PixQRDetails = () => {\n const { i18n } = useCoreContext();\n const { qrCodeData, qrCodeImage, percentage, timeToPay, onTick, countdownTime, onQRCodeLoad, onTimeUp, handleCopy } = useQRLoaderDetails();\n\n return (\n <div className=\"adyen-checkout__qr-loader--pix__qr_details\">\n <QRImage type={TxVariants.pix} src={qrCodeImage} onLoad={onQRCodeLoad} />\n <div className=\"adyen-checkout__qr-loader--pix__qr_details__timer\">\n <QRProgressbar percentage={percentage} />\n <QRCountdown countdownTime={countdownTime} timeToPay={timeToPay} onTick={onTick} onCompleted={onTimeUp} />\n </div>\n <Field name=\"pix-code\" useLabelElement={false}>\n <InputText\n className=\"adyen-checkout__qr-loader--pix__qr_details__code\"\n value={qrCodeData}\n readonly\n aria-label={i18n.get('pix.code.label')}\n />\n </Field>\n <QRCodeCopyButton\n text={qrCodeData}\n copyLabel={i18n.get('pix.code.copy.label')}\n copiedLabel={i18n.get('pix.code.copied.label')}\n handleCopy={handleCopy}\n />\n </div>\n );\n};\n\nexport default PixQRDetails;\n"],"names":["PixQRDetails","i18n","useCoreContext","qrCodeData","qrCodeImage","percentage","timeToPay","onTick","countdownTime","onQRCodeLoad","onTimeUp","handleCopy","useQRLoaderDetails","h","div","className","QRImage","type","TxVariants","pix","src","onLoad","QRProgressbar","QRCountdown","onCompleted","Field","name","useLabelElement","InputText","value","readonly","aria-label","get","QRCodeCopyButton","text","copyLabel","copiedLabel"],"mappings":"yvBAOA,MAAMA,EAAe,KACjB,MAAMC,KAAEA,GAASC,KACXC,WAAEA,EAAUC,YAAEA,EAAWC,WAAEA,EAAUC,UAAEA,EAASC,OAAEA,EAAMC,cAAEA,EAAaC,aAAEA,EAAYC,SAAEA,EAAQC,WAAEA,GAAeC,IAEtH,OACIC,EAACC,MAAAA,CAAIC,UAAU,8CACXF,EAACG,EAAAA,CAAQC,KAAMC,EAAWC,IAAKC,IAAKhB,EAAaiB,OAAQZ,IACzDI,EAACC,MAAAA,CAAIC,UAAU,qDACXF,EAACS,EAAAA,CAAcjB,WAAYA,IAC3BQ,EAACU,EAAAA,CAAYf,cAAeA,EAAeF,UAAWA,EAAWC,OAAQA,EAAQiB,YAAad,KAElGG,EAACY,EAAAA,CAAMC,KAAK,WAAWC,iBAAiB,GACpCd,EAACe,EAAAA,CACGb,UAAU,mDACVc,MAAO1B,EACP2B,UAAAA,EACAC,aAAY9B,EAAK+B,IAAI,
|
|
1
|
+
{"version":3,"file":"PixQRDetails.js","sources":["../../../../../src/components/Pix/components/PixQRDetails.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { QRImage, QRProgressbar, QRCountdown, QRCodeCopyButton, useQRLoaderDetails } from '../../internal/QRLoader';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../../internal/FormFields/Field';\nimport InputText from '../../internal/FormFields/InputText';\nimport { TxVariants } from '../../tx-variants';\n\nconst PixQRDetails = () => {\n const { i18n } = useCoreContext();\n const { qrCodeData, qrCodeImage, percentage, timeToPay, onTick, countdownTime, onQRCodeLoad, onTimeUp, handleCopy } = useQRLoaderDetails();\n\n return (\n <div className=\"adyen-checkout__qr-loader--pix__qr_details\">\n <QRImage type={TxVariants.pix} src={qrCodeImage} onLoad={onQRCodeLoad} />\n <div className=\"adyen-checkout__qr-loader--pix__qr_details__timer\">\n <QRProgressbar percentage={percentage} />\n <QRCountdown countdownTime={countdownTime} timeToPay={timeToPay} onTick={onTick} onCompleted={onTimeUp} />\n </div>\n <Field name=\"pix-code\" useLabelElement={false}>\n <InputText\n className=\"adyen-checkout__qr-loader--pix__qr_details__code\"\n value={qrCodeData}\n readonly\n aria-label={i18n.get('pix.code.label')}\n autocomplete={undefined}\n />\n </Field>\n <QRCodeCopyButton\n text={qrCodeData}\n copyLabel={i18n.get('pix.code.copy.label')}\n copiedLabel={i18n.get('pix.code.copied.label')}\n handleCopy={handleCopy}\n />\n </div>\n );\n};\n\nexport default PixQRDetails;\n"],"names":["PixQRDetails","i18n","useCoreContext","qrCodeData","qrCodeImage","percentage","timeToPay","onTick","countdownTime","onQRCodeLoad","onTimeUp","handleCopy","useQRLoaderDetails","h","div","className","QRImage","type","TxVariants","pix","src","onLoad","QRProgressbar","QRCountdown","onCompleted","Field","name","useLabelElement","InputText","value","readonly","aria-label","get","autocomplete","undefined","QRCodeCopyButton","text","copyLabel","copiedLabel"],"mappings":"yvBAOA,MAAMA,EAAe,KACjB,MAAMC,KAAEA,GAASC,KACXC,WAAEA,EAAUC,YAAEA,EAAWC,WAAEA,EAAUC,UAAEA,EAASC,OAAEA,EAAMC,cAAEA,EAAaC,aAAEA,EAAYC,SAAEA,EAAQC,WAAEA,GAAeC,IAEtH,OACIC,EAACC,MAAAA,CAAIC,UAAU,8CACXF,EAACG,EAAAA,CAAQC,KAAMC,EAAWC,IAAKC,IAAKhB,EAAaiB,OAAQZ,IACzDI,EAACC,MAAAA,CAAIC,UAAU,qDACXF,EAACS,EAAAA,CAAcjB,WAAYA,IAC3BQ,EAACU,EAAAA,CAAYf,cAAeA,EAAeF,UAAWA,EAAWC,OAAQA,EAAQiB,YAAad,KAElGG,EAACY,EAAAA,CAAMC,KAAK,WAAWC,iBAAiB,GACpCd,EAACe,EAAAA,CACGb,UAAU,mDACVc,MAAO1B,EACP2B,UAAAA,EACAC,aAAY9B,EAAK+B,IAAI,kBACrBC,kBAAcC,KAGtBrB,EAACsB,EAAAA,CACGC,KAAMjC,EACNkC,UAAWpC,EAAK+B,IAAI,uBACpBM,YAAarC,EAAK+B,IAAI,yBACtBrB,WAAYA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as a,useRef as t,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import l from"../../internal/FormInstruction/FormInstruction.js";import i from"../../../utils/useForm/useForm.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as a,useRef as t,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import l from"../../internal/FormInstruction/FormInstruction.js";import i from"../../../utils/useForm/useForm.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import u from"../../internal/FormFields/Field/Field.js";import s from"../../internal/FormFields/InputText.js";import{preAuthorizedDebitCanadaValidationRules as d,preAuthorizedDebitCanadaFormatters as m}from"./validate.js";import c from"../../internal/StoreDetails/StoreDetails.js";import b from"../../../core/Context/useImage.js";import{SettlementInfo as p}from"./SettlementInfo.js";function k({onChange:k,payButton:f,showPayButton:g,placeholders:N,setComponentRef:x,enableStoreDetails:h,showContextualElement:C=!0}){const I=b(),{i18n:F}=o(),[w,v]=a("ready"),{handleChangeFor:j,triggerValidation:A,data:M,errors:L,valid:S,isValid:V}=i({schema:["ownerName","bankAccountNumber","bankCode","bankLocationId"],rules:d,formatters:m}),[T,y]=a(!1),B="loading"===w,E=t({setStatus:v,showValidation:()=>{A()}});return n(()=>{x(E.current)},[x,E.current]),n(()=>{k({data:M,valid:S,errors:L,isValid:V,storePaymentMethod:T})},[k,M,S,L,V,T]),e("div",{className:"adyen-checkout__eftpad-canada"},e(l,null),e(r,null,e(u,{label:F.get("eftpad-canada.input.accountHolderName.label"),errorMessage:!!L.ownerName&&F.get(L.ownerName.errorMessage),isValid:!!S.ownerName,name:"ownerName"},e(s,{disabled:B,name:"ownerName",placeholder:null==N?void 0:N.ownerName,value:M.ownerName,onInput:j("ownerName","input"),onBlur:j("ownerName","blur"),required:!0,"data-testid":"owner-name",autocomplete:"name"})),e(u,{label:F.get("eftpad-canada.input.accountNumber.label"),errorMessage:!!L.bankAccountNumber&&F.get(L.bankAccountNumber.errorMessage),name:"bankAccountNumber",isValid:!!S.bankAccountNumber,showContextualElement:C,contextualText:F.get("eftpad-canada.input.accountNumber.contextualText")},e(s,{disabled:B,name:"bankAccountNumber",placeholder:null==N?void 0:N.bankAccountNumber,value:M.bankAccountNumber,onInput:j("bankAccountNumber","input"),onBlur:j("bankAccountNumber","blur"),required:!0,maxlength:12,autocomplete:void 0})),e(u,{label:F.get("eftpad-canada.input.institutionNumber.label"),classNameModifiers:["col-50"],errorMessage:!!L.bankCode&&F.get(L.bankCode.errorMessage),isValid:!!S.bankCode,name:"bankCode",showContextualElement:C,contextualText:F.get("eftpad-canada.input.institutionNumber.contextualText")},e(s,{disabled:B,name:"bankCode",placeholder:null==N?void 0:N.bankCode,value:M.bankCode,onInput:j("bankCode","input"),onBlur:j("bankCode","blur"),required:!0,maxlength:3,autocomplete:void 0})),e(u,{label:F.get("eftpad-canada.input.transitNumber.label"),classNameModifiers:["col-50"],errorMessage:!!L.bankLocationId&&F.get(L.bankLocationId.errorMessage),name:"bankLocationId",isValid:!!S.bankLocationId,showContextualElement:C,contextualText:F.get("eftpad-canada.input.transitNumber.contextualText")},e(s,{disabled:B,name:"bankLocationId",placeholder:null==N?void 0:N.bankLocationId,value:M.bankLocationId,onInput:j("bankLocationId","input"),onBlur:j("bankLocationId","blur"),required:!0,maxlength:5,autocomplete:void 0}))),h&&e(c,{className:"adyen-checkout_eftpad-canada-store-details",disabled:B,onChange:y}),e(p,null),g&&f({status:w,icon:I({imageFolder:"components/"})("bento_lock")}))}export{k as default};
|
|
2
2
|
//# sourceMappingURL=PreAuthorizedDebitCanadaComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreAuthorizedDebitCanadaComponent.js","sources":["../../../../../src/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Fieldset from '../../internal/FormFields/Fieldset';\nimport FormInstruction from '../../internal/FormInstruction';\nimport useForm from '../../../utils/useForm';\nimport Field from '../../internal/FormFields/Field';\nimport InputText from '../../internal/FormFields/InputText';\nimport { preAuthorizedDebitCanadaFormatters, preAuthorizedDebitCanadaValidationRules } from './validate';\nimport StoreDetails from '../../internal/StoreDetails';\nimport useImage from '../../../core/Context/useImage';\nimport { SettlementInfo } from './SettlementInfo';\n\nimport type { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport type { ComponentMethodsRef } from '../../internal/UIElement/types';\nimport type { PreAuthorizedDebitCanadaPlaceholders } from '../types';\n\nimport './PreAuthorizedDebitCanada.scss';\nimport { ValidationRuleResult } from '../../../utils/Validator/ValidationRuleResult';\n\ninterface PreAuthorizedDebitCanadaForm {\n ownerName: string;\n bankAccountNumber: string;\n bankCode: string;\n bankLocationId: string;\n}\n\ninterface PreAuthorizedDebitCanadaComponentProps {\n onChange({\n data,\n valid,\n errors,\n isValid,\n storePaymentMethod\n }: {\n data: PreAuthorizedDebitCanadaForm;\n valid: { [key: string]: boolean };\n errors: { [key: string]: ValidationRuleResult };\n isValid: boolean;\n storePaymentMethod: boolean;\n }): void;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n showPayButton: boolean;\n enableStoreDetails: boolean;\n showContextualElement?: boolean;\n placeholders?: PreAuthorizedDebitCanadaPlaceholders;\n}\n\nfunction PreAuthorizedDebitCanadaComponent({\n onChange,\n payButton,\n showPayButton,\n placeholders,\n setComponentRef,\n enableStoreDetails,\n showContextualElement = true\n}: Readonly<PreAuthorizedDebitCanadaComponentProps>) {\n const getImage = useImage();\n const { i18n } = useCoreContext();\n const [status, setStatus] = useState('ready');\n const { handleChangeFor, triggerValidation, data, errors, valid, isValid } = useForm<PreAuthorizedDebitCanadaForm>({\n schema: ['ownerName', 'bankAccountNumber', 'bankCode', 'bankLocationId'],\n rules: preAuthorizedDebitCanadaValidationRules,\n formatters: preAuthorizedDebitCanadaFormatters\n });\n const [storePaymentMethod, setStorePaymentMethod] = useState(false);\n\n const isFormDisabled = status === 'loading';\n\n const componentRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n setComponentRef(componentRef.current);\n }, [setComponentRef, componentRef.current]);\n\n useEffect(() => {\n onChange({ data, valid, errors, isValid, storePaymentMethod });\n }, [onChange, data, valid, errors, isValid, storePaymentMethod]);\n\n return (\n <div className=\"adyen-checkout__eftpad-canada\">\n <FormInstruction />\n\n <Fieldset>\n <Field\n label={i18n.get('eftpad-canada.input.accountHolderName.label')}\n errorMessage={!!errors.ownerName && i18n.get(errors.ownerName.errorMessage)}\n isValid={!!valid.ownerName}\n name={'ownerName'}\n >\n <InputText\n disabled={isFormDisabled}\n name={'ownerName'}\n placeholder={placeholders?.ownerName}\n value={data.ownerName}\n onInput={handleChangeFor('ownerName', 'input')}\n onBlur={handleChangeFor('ownerName', 'blur')}\n required={true}\n data-testid={'owner-name'}\n />\n </Field>\n\n <Field\n label={i18n.get('eftpad-canada.input.accountNumber.label')}\n errorMessage={!!errors.bankAccountNumber && i18n.get(errors.bankAccountNumber.errorMessage)}\n name={'bankAccountNumber'}\n isValid={!!valid.bankAccountNumber}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('eftpad-canada.input.accountNumber.contextualText')}\n >\n <InputText\n disabled={isFormDisabled}\n name={'bankAccountNumber'}\n placeholder={placeholders?.bankAccountNumber}\n value={data.bankAccountNumber}\n onInput={handleChangeFor('bankAccountNumber', 'input')}\n onBlur={handleChangeFor('bankAccountNumber', 'blur')}\n required={true}\n maxlength={12}\n />\n </Field>\n\n <Field\n label={i18n.get('eftpad-canada.input.institutionNumber.label')}\n classNameModifiers={['col-50']}\n errorMessage={!!errors.bankCode && i18n.get(errors.bankCode.errorMessage)}\n isValid={!!valid.bankCode}\n name={'bankCode'}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('eftpad-canada.input.institutionNumber.contextualText')}\n >\n <InputText\n disabled={isFormDisabled}\n name={'bankCode'}\n placeholder={placeholders?.bankCode}\n value={data.bankCode}\n onInput={handleChangeFor('bankCode', 'input')}\n onBlur={handleChangeFor('bankCode', 'blur')}\n required={true}\n maxlength={3}\n />\n </Field>\n\n <Field\n label={i18n.get('eftpad-canada.input.transitNumber.label')}\n classNameModifiers={['col-50']}\n errorMessage={!!errors.bankLocationId && i18n.get(errors.bankLocationId.errorMessage)}\n name={'bankLocationId'}\n isValid={!!valid.bankLocationId}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('eftpad-canada.input.transitNumber.contextualText')}\n >\n <InputText\n disabled={isFormDisabled}\n name={'bankLocationId'}\n placeholder={placeholders?.bankLocationId}\n value={data.bankLocationId}\n onInput={handleChangeFor('bankLocationId', 'input')}\n onBlur={handleChangeFor('bankLocationId', 'blur')}\n required={true}\n maxlength={5}\n />\n </Field>\n </Fieldset>\n\n {enableStoreDetails && (\n <StoreDetails className={'adyen-checkout_eftpad-canada-store-details'} disabled={isFormDisabled} onChange={setStorePaymentMethod} />\n )}\n\n <SettlementInfo />\n\n {showPayButton && payButton({ status, icon: getImage({ imageFolder: 'components/' })('bento_lock') })}\n </div>\n );\n}\n\nexport default PreAuthorizedDebitCanadaComponent;\n"],"names":["PreAuthorizedDebitCanadaComponent","onChange","payButton","showPayButton","placeholders","setComponentRef","enableStoreDetails","showContextualElement","getImage","useImage","i18n","useCoreContext","status","setStatus","useState","handleChangeFor","triggerValidation","data","errors","valid","isValid","useForm","schema","rules","preAuthorizedDebitCanadaValidationRules","formatters","preAuthorizedDebitCanadaFormatters","storePaymentMethod","setStorePaymentMethod","isFormDisabled","componentRef","useRef","showValidation","useEffect","current","h","div","className","FormInstruction","Fieldset","Field","label","get","errorMessage","ownerName","name","InputText","disabled","placeholder","value","onInput","onBlur","required","data-testid","bankAccountNumber","contextualText","maxlength","classNameModifiers","bankCode","bankLocationId","StoreDetails","SettlementInfo","icon","imageFolder"],"mappings":"i2BAiDA,SAASA,GAAkCC,SACvCA,EAAQC,UACRA,EAASC,cACTA,EAAaC,aACbA,EAAYC,gBACZA,EAAeC,mBACfA,EAAkBC,sBAClBA,GAAwB,IAExB,MAAMC,EAAWC,KACXC,KAAEA,GAASC,KACVC,EAAQC,GAAaC,EAAS,UAC/BC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,GAAYC,EAAsC,CAC/GC,OAAQ,CAAC,YAAa,oBAAqB,WAAY,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Be,mBAAoB,CAAC,UACrBd,eAAgBzB,EAAOwC,UAAYhD,EAAKgC,IAAIxB,EAAOwC,SAASf,cAC5DvB,UAAWD,EAAMuC,SACjBb,KAAM,WACNtC,sBAAuBA,EACvBgD,eAAgB7C,EAAKgC,IAAI,yDAEzBP,EAACW,EAAAA,CACGC,SAAUlB,EACVgB,KAAM,WACNG,YAAa5C,aAAAA,EAAAA,EAAcsD,SAC3BT,MAAOhC,EAAKyC,SACZR,QAASnC,EAAgB,WAAY,SACrCoC,OAAQpC,EAAgB,WAAY,QACpCqC,UAAU,EACVI,UAAW,KAInBrB,EAACK,EAAAA,CACGC,MAAO/B,EAAKgC,IAAI,2CAChBe,mBAAoB,CAAC,UACrBd,eAAgBzB,EAAOyC,gBAAkBjD,EAAKgC,IAAIxB,EAAOyC,eAAehB,cACxEE,KAAM,iBACNzB,UAAWD,EAAMwC,eACjBpD,sBAAuBA,EACvBgD,eAAgB7C,EAAKgC,IAAI,qDAEzBP,EAACW,EAAAA,CACGC,SAAUlB,EACVgB,KAAM,iBACNG,YAAa5C,aAAAA,EAAAA,EAAcuD,eAC3BV,MAAOhC,EAAK0C,eACZT,QAASnC,EAAgB,iBAAkB,SAC3CoC,OAAQpC,EAAgB,iBAAkB,QAC1CqC,UAAU,EACVI,UAAW,MAKtBlD,GACG6B,EAACyB,EAAAA,CAAavB,UAAW,6CAA8CU,SAAUlB,EAAgB5B,SAAU2B,IAG/GO,EAAC0B,EAAAA,MAEA1D,GAAiBD,EAAU,CAAEU,SAAQkD,KAAMtD,EAAS,CAAEuD,YAAa,eAAxBvD,CAAyC,gBAGjG"}
|
|
1
|
+
{"version":3,"file":"PreAuthorizedDebitCanadaComponent.js","sources":["../../../../../src/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Fieldset from '../../internal/FormFields/Fieldset';\nimport FormInstruction from '../../internal/FormInstruction';\nimport useForm from '../../../utils/useForm';\nimport Field from '../../internal/FormFields/Field';\nimport InputText from '../../internal/FormFields/InputText';\nimport { preAuthorizedDebitCanadaFormatters, preAuthorizedDebitCanadaValidationRules } from './validate';\nimport StoreDetails from '../../internal/StoreDetails';\nimport useImage from '../../../core/Context/useImage';\nimport { SettlementInfo } from './SettlementInfo';\n\nimport type { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport type { ComponentMethodsRef } from '../../internal/UIElement/types';\nimport type { PreAuthorizedDebitCanadaPlaceholders } from '../types';\n\nimport './PreAuthorizedDebitCanada.scss';\nimport { ValidationRuleResult } from '../../../utils/Validator/ValidationRuleResult';\n\ninterface PreAuthorizedDebitCanadaForm {\n ownerName: string;\n bankAccountNumber: string;\n bankCode: string;\n bankLocationId: string;\n}\n\ninterface PreAuthorizedDebitCanadaComponentProps {\n onChange({\n data,\n valid,\n errors,\n isValid,\n storePaymentMethod\n }: {\n data: PreAuthorizedDebitCanadaForm;\n valid: { [key: string]: boolean };\n errors: { [key: string]: ValidationRuleResult };\n isValid: boolean;\n storePaymentMethod: boolean;\n }): void;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n showPayButton: boolean;\n enableStoreDetails: boolean;\n showContextualElement?: boolean;\n placeholders?: PreAuthorizedDebitCanadaPlaceholders;\n}\n\nfunction PreAuthorizedDebitCanadaComponent({\n onChange,\n payButton,\n showPayButton,\n placeholders,\n setComponentRef,\n enableStoreDetails,\n showContextualElement = true\n}: Readonly<PreAuthorizedDebitCanadaComponentProps>) {\n const getImage = useImage();\n const { i18n } = useCoreContext();\n const [status, setStatus] = useState('ready');\n const { handleChangeFor, triggerValidation, data, errors, valid, isValid } = useForm<PreAuthorizedDebitCanadaForm>({\n schema: ['ownerName', 'bankAccountNumber', 'bankCode', 'bankLocationId'],\n rules: preAuthorizedDebitCanadaValidationRules,\n formatters: preAuthorizedDebitCanadaFormatters\n });\n const [storePaymentMethod, setStorePaymentMethod] = useState(false);\n\n const isFormDisabled = status === 'loading';\n\n const componentRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n setComponentRef(componentRef.current);\n }, [setComponentRef, componentRef.current]);\n\n useEffect(() => {\n onChange({ data, valid, errors, isValid, storePaymentMethod });\n }, [onChange, data, valid, errors, isValid, storePaymentMethod]);\n\n return (\n <div className=\"adyen-checkout__eftpad-canada\">\n <FormInstruction />\n\n <Fieldset>\n <Field\n label={i18n.get('eftpad-canada.input.accountHolderName.label')}\n errorMessage={!!errors.ownerName && i18n.get(errors.ownerName.errorMessage)}\n isValid={!!valid.ownerName}\n name={'ownerName'}\n >\n <InputText\n disabled={isFormDisabled}\n name={'ownerName'}\n placeholder={placeholders?.ownerName}\n value={data.ownerName}\n onInput={handleChangeFor('ownerName', 'input')}\n onBlur={handleChangeFor('ownerName', 'blur')}\n required={true}\n data-testid={'owner-name'}\n autocomplete=\"name\"\n />\n </Field>\n\n <Field\n label={i18n.get('eftpad-canada.input.accountNumber.label')}\n errorMessage={!!errors.bankAccountNumber && i18n.get(errors.bankAccountNumber.errorMessage)}\n name={'bankAccountNumber'}\n isValid={!!valid.bankAccountNumber}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('eftpad-canada.input.accountNumber.contextualText')}\n >\n <InputText\n disabled={isFormDisabled}\n name={'bankAccountNumber'}\n placeholder={placeholders?.bankAccountNumber}\n value={data.bankAccountNumber}\n onInput={handleChangeFor('bankAccountNumber', 'input')}\n onBlur={handleChangeFor('bankAccountNumber', 'blur')}\n required={true}\n maxlength={12}\n autocomplete={undefined}\n />\n </Field>\n\n <Field\n label={i18n.get('eftpad-canada.input.institutionNumber.label')}\n classNameModifiers={['col-50']}\n errorMessage={!!errors.bankCode && i18n.get(errors.bankCode.errorMessage)}\n isValid={!!valid.bankCode}\n name={'bankCode'}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('eftpad-canada.input.institutionNumber.contextualText')}\n >\n <InputText\n disabled={isFormDisabled}\n name={'bankCode'}\n placeholder={placeholders?.bankCode}\n value={data.bankCode}\n onInput={handleChangeFor('bankCode', 'input')}\n onBlur={handleChangeFor('bankCode', 'blur')}\n required={true}\n maxlength={3}\n autocomplete={undefined}\n />\n </Field>\n\n <Field\n label={i18n.get('eftpad-canada.input.transitNumber.label')}\n classNameModifiers={['col-50']}\n errorMessage={!!errors.bankLocationId && i18n.get(errors.bankLocationId.errorMessage)}\n name={'bankLocationId'}\n isValid={!!valid.bankLocationId}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('eftpad-canada.input.transitNumber.contextualText')}\n >\n <InputText\n disabled={isFormDisabled}\n name={'bankLocationId'}\n placeholder={placeholders?.bankLocationId}\n value={data.bankLocationId}\n onInput={handleChangeFor('bankLocationId', 'input')}\n onBlur={handleChangeFor('bankLocationId', 'blur')}\n required={true}\n maxlength={5}\n autocomplete={undefined}\n />\n </Field>\n </Fieldset>\n\n {enableStoreDetails && (\n <StoreDetails className={'adyen-checkout_eftpad-canada-store-details'} disabled={isFormDisabled} onChange={setStorePaymentMethod} />\n )}\n\n <SettlementInfo />\n\n {showPayButton && payButton({ status, icon: getImage({ imageFolder: 'components/' })('bento_lock') })}\n </div>\n );\n}\n\nexport default PreAuthorizedDebitCanadaComponent;\n"],"names":["PreAuthorizedDebitCanadaComponent","onChange","payButton","showPayButton","placeholders","setComponentRef","enableStoreDetails","showContextualElement","getImage","useImage","i18n","useCoreContext","status","setStatus","useState","handleChangeFor","triggerValidation","data","errors","valid","isValid","useForm","schema","rules","preAuthorizedDebitCanadaValidationRules","formatters","preAuthorizedDebitCanadaFormatters","storePaymentMethod","setStorePaymentMethod","isFormDisabled","componentRef","useRef","showValidation","useEffect","current","h","div","className","FormInstruction","Fieldset","Field","label","get","errorMessage","ownerName","name","InputText","disabled","placeholder","value","onInput","onBlur","required","data-testid","autocomplete","bankAccountNumber","contextualText","maxlength","undefined","classNameModifiers","bankCode","bankLocationId","StoreDetails","SettlementInfo","icon","imageFolder"],"mappings":"i2BAiDA,SAASA,GAAkCC,SACvCA,EAAQC,UACRA,EAASC,cACTA,EAAaC,aACbA,EAAYC,gBACZA,EAAeC,mBACfA,EAAkBC,sBAClBA,GAAwB,IAExB,MAAMC,EAAWC,KACXC,KAAEA,GAASC,KACVC,EAAQC,GAAaC,EAAS,UAC/BC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,GAAYC,EAAsC,CAC/GC,OAAQ,CAAC,YAAa,oBAAqB,WAAY,kBACvDC,MAAOC,EACPC,WAAYC,KAETC,EAAoBC,GAAyBd,GAAS,GAEvDe,EAA4B,YAAXjB,EAEjBkB,EAAeC,EAA4B,CAC7ClB,UAAWA,EACXmB,eAAgB,KACZhB,OAYR,OARAiB,EAAU,KACN5B,EAAgByB,EAAaI,UAC9B,CAAC7B,EAAiByB,EAAaI,UAElCD,EAAU,KACNhC,EAAS,CAAEgB,OAAME,QAAOD,SAAQE,UAASO,wBAC1C,CAAC1B,EAAUgB,EAAME,EAAOD,EAAQE,EAASO,IAGxCQ,EAACC,MAAAA,CAAIC,UAAU,iCACXF,EAACG,EAAAA,MAEDH,EAACI,EAAAA,KACGJ,EAACK,EAAAA,CACGC,MAAO/B,EAAKgC,IAAI,+CAChBC,eAAgBzB,EAAO0B,WAAalC,EAAKgC,IAAIxB,EAAO0B,UAAUD,cAC9DvB,UAAWD,EAAMyB,UACjBC,KAAM,aAENV,EAACW,EAAAA,CACGC,SAAUlB,EACVgB,KAAM,YACNG,YAAa5C,aAAAA,EAAAA,EAAcwC,UAC3BK,MAAOhC,EAAK2B,UACZM,QAASnC,EAAgB,YAAa,SACtCoC,OAAQpC,EAAgB,YAAa,QACrCqC,UAAU,EACVC,cAAa,aACbC,aAAa,UAIrBnB,EAACK,EAAAA,CACGC,MAAO/B,EAAKgC,IAAI,2CAChBC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1CqC,UAAU,EACVK,UAAW,EACXH,kBAAcI,MAKzBpD,GACG6B,EAAC2B,EAAAA,CAAazB,UAAW,6CAA8CU,SAAUlB,EAAgB5B,SAAU2B,IAG/GO,EAAC4B,EAAAA,MAEA5D,GAAiBD,EAAU,CAAEU,SAAQoD,KAAMxD,EAAS,CAAEyD,YAAa,eAAxBzD,CAAyC,gBAGjG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{addressFormatters as
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{addressFormatters as d,countrySpecificFormatters as u}from"./validate.formats.js";import p from"./components/FieldContainer.js";import m from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import f from"./Specifications.js";import{ADDRESS_SCHEMA as y,FALLBACK_VALUE as b}from"./constants.js";import{getMaxLengthByFieldAndCountry as v}from"../../../utils/validator-utils.js";import{useCoreContext as O}from"../../../core/Context/CoreProvider.js";import g from"./components/AddressSearch.js";import{getAddressTypeFromLabel as j}from"./utils.js";function F(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){F(e,t,r[t])})}return e}function C(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function A(F){var A,S;const{i18n:P}=O(),{label:w="",requiredFields:k,visibility:x,iOSFocusedField:D=null,showContextualElement:M}=F,E=j(F.addressType,w),B=r({});var L;Object.keys(B.current).length||(null===(L=F.setComponentRef)||void 0===L||L.call(F,B.current));const N=o(()=>new f(F.specifications),[F.specifications]),R=N.getAddressSchemaForCountryFlat(F.countryCode).filter(e=>k.includes(e)),[T,V]=n(!1),[H,q]=n(!1),[_,I]=n(""),U=!!F.onAddressLookup,[$,z]=n(!1),G=!F.onAddressLookup||(T||H),{data:J,errors:K,valid:Q,isValid:W,handleChangeFor:X,triggerValidation:Y,setData:Z,mergeData:ee}=m({schema:R,defaultData:F.data,rules:h({},c(N),F.validationRules),formatters:d}),te=r(null===(A=F.data)||void 0===A?void 0:A.country),re=null===(S=J.country||te.current)||void 0===S?void 0:S.toUpperCase(),oe=o(()=>C(h({},J),{country:re}),[J,re]),ne=s(e=>{const t=y.reduce((t,r)=>{const o=e[r];return null!=o&&(t[r]=String(o)),t},{});ee(t),z(!0),Y(),V(!0)},[V,Y,Z]),se=s(()=>{q(!0)},[]);B.current.showValidation=()=>{Y(),I(!U||G||W?"":P.get("address.errors.incomplete"))};const ae=R.filter(e=>!D||e===D);if(a(()=>{if($)return void z(!1);const e=N.countryHasDataset(J.country)?"":b,t=C(h({},J),{stateOrProvince:e});k.forEach(e=>{var r;X(e,"input")(null!==(r=t[e])&&void 0!==r?r:"")}),t.postalCode&&X("postalCode","blur")(J.postalCode)},[J.country]),a(()=>{const e=k.includes("stateOrProvince"),t=J.country&&N.countryHasDataset(J.country),r=e&&t,o=J.stateOrProvince||(r?"":b);X("stateOrProvince","input")(o)},[]),a(()=>{const e=N.getOptionalFieldsForCountry(J.country),t=y.reduce((t,r)=>{const o=e.includes(r),n=k.includes(r),s=J[r],a=F.data[r],i=o&&!s||!n?n||s||!a?b:a:s;return(null==i?void 0:i.length)&&(t[r]=i),t},{});!t.country&&te.current&&(t.country=te.current),F.onChange({data:t,valid:Q,errors:K,isValid:W})},[J,Q,K,W]),"hidden"===x)return null;if("readOnly"===x)return e(l,{data:J,label:w});const ie=(t,{classNameModifiers:r=[]})=>k.includes(t)?e(p,{key:t,allowedCountries:F.allowedCountries,classNameModifiers:[...r,t],data:oe,errors:K,valid:Q,fieldName:t,onInput:X(t,"input"),onBlur:X(t,"blur"),onDropdownChange:X(t,"blur"),specifications:N,maxLength:v(u,t,re),trimOnBlur:!0,disabled:!ae.includes(t),addressType:E,onFieldFocusAnalytics:F.onFieldFocusAnalytics,onFieldBlurAnalytics:F.onFieldBlurAnalytics}):null,le=N.getAddressSchemaForCountry(J.country);return e(t,null,e(i,{classNameModifiers:[w,"address"],label:w,renderLabelAsSectionHeading:!0},U&&e(g,{onAddressLookup:F.onAddressLookup,onAddressSelected:F.onAddressSelected,onSelect:ne,onManualAddress:se,externalErrorMessage:_,hideManualButton:G,showContextualElement:M,contextualText:P.get("address.search.contextualText"),addressSearchDebounceMs:F.addressSearchDebounceMs}),G&&e(t,null,le.map(t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map(([e,t])=>ie(e,{classNameModifiers:[`col-${t}`]}))):ie(t,{})))))}A.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:y,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{A as default};
|
|
2
2
|
//# sourceMappingURL=Address.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n // In partial address mode, country is not in the form schema but we need it for regionalized labels.\n // Store the merchant's country config once at mount, then use it if form data doesn't have country.\n const initialCountryRef = useRef<string | undefined>((props.data as AddressData)?.country);\n const effectiveCountry = (data.country || initialCountryRef.current)?.toUpperCase();\n const dataWithCountry = useMemo(() => ({ ...data, country: effectiveCountry }), [data, effectiveCountry]);\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n // In partial address mode, ensure country is included in output for regionalized labels/validation.\n if (!(processedData as AddressData).country && initialCountryRef.current) {\n (processedData as AddressData).country = initialCountryRef.current;\n }\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={dataWithCountry}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, effectiveCountry, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","data","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","_object_spread","getAddressValidationRules","validationRules","formatters","addressFormatters","initialCountryRef","_props_data","country","effectiveCountry","_this","toUpperCase","dataWithCountry","_object_spread_props","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"orDAkBe,SAASA,EAAQC,OAsC0BA,EAC5BC,EAtC1B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BR,EAG5FS,EAAaC,EAA4B,IAG3CV,IAAAA,EADCW,OAAOC,KAAKH,EAAWI,SAASC,SACZ,QAArBd,EAAAA,EAAMe,2BAANf,GAAAA,EAAAA,KAAAA,EAAwBS,EAAWI,UAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAelB,EAAMgB,gBAAiB,CAAChB,EAAMgB,iBAEhFG,EAAuBH,EAAeI,+BAA+BpB,EAAMqB,aAAaC,OAAOC,GAASlB,EAAemB,SAASD,KAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GA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|
|
1
|
+
{"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps, AddressType } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\nimport { getAddressTypeFromLabel } from './utils';\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n const addressType: AddressType = getAddressTypeFromLabel(props.addressType, label);\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n // In partial address mode, country is not in the form schema but we need it for regionalized labels.\n // Store the merchant's country config once at mount, then use it if form data doesn't have country.\n const initialCountryRef = useRef<string | undefined>((props.data as AddressData)?.country);\n const effectiveCountry = (data.country || initialCountryRef.current)?.toUpperCase();\n const dataWithCountry = useMemo(() => ({ ...data, country: effectiveCountry }), [data, effectiveCountry]);\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n // In partial address mode, ensure country is included in output for regionalized labels/validation.\n if (!(processedData as AddressData).country && initialCountryRef.current) {\n (processedData as AddressData).country = initialCountryRef.current;\n }\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={dataWithCountry}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, effectiveCountry, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n addressType={addressType}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","data","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressType","getAddressTypeFromLabel","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","_object_spread","getAddressValidationRules","validationRules","formatters","addressFormatters","initialCountryRef","_props_data","country","effectiveCountry","_this","toUpperCase","dataWithCountry","_object_spread_props","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"yuDAmBe,SAASA,EAAQC,OAuC0BA,EAC5BC,EAvC1B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BR,EAC5FS,EAA2BC,EAAwBV,EAAMS,YAAaL,GAGtEO,EAAaC,EAA4B,IAG3CZ,IAAAA,EADCa,OAAOC,KAAKH,EAAWI,SAASC,SACZ,QAArBhB,EAAAA,EAAMiB,2BAANjB,GAAAA,EAAAA,KAAAA,EAAwBW,EAAWI,UA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/B,GAAa5E,EAAO,CAAE6E,mBAAoB,CAAC,OAAO8B,SAuBY/B,GAAa5E,EAAO,CAAA,MAK5H,CAEA1B,EAAQsI,aAAe,CACnB9G,YAAa,KACb6B,gBAAiB,KACjBnD,KAAM,CAAA,EACNiG,SAAU,OACV5F,WAAY,WACZD,eAAgB8D,EAChBjD,eAAgB,CAAA,EAChBgG,sBAAuB,OACvBC,qBAAsB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../FormFields/Field/Field.js";import o from"./StateField.js";import i from"./CountryField.js";import{useCoreContext as
|
|
1
|
+
import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../FormFields/Field/Field.js";import o from"./StateField.js";import i from"./CountryField.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import t from"../../FormFields/InputText.js";import{ADDRESS_FIELD_TOKEN_MAP as n}from"../constants.js";function a(e,r){const o=n[e];if(o)return"billingAddress"===r?`billing ${o}`:"deliveryAddress"===r?`shipping ${o}`:o}function l(n){const{i18n:l}=s(),{classNameModifiers:d=[],data:c,errors:u,valid:m,fieldName:p,onInput:f,onBlur:g,trimOnBlur:F,maxLength:v,disabled:y,addressType:C}=n,M=c[p],b=c.country,j=n.specifications.countryHasOptionalField(b,p),h=n.specifications.getKeyForField(p,b),w=j?` ${l.get("field.title.optional")}`:"",x=`${l.get(h)}${w}`,B=function(e,r,o,i){var s,t;if("object"==typeof(null===(s=e[r])||void 0===s?void 0:s.errorMessage)){const{translationKey:i,translationObject:s}=e[r].errorMessage;return o.get(i,s)}return o.get(null===(t=e[r])||void 0===t?void 0:t.errorMessage,{values:{label:i.toLowerCase()}})||!!e[r]}(u,p,l,x);switch(p){case"country":return e(i,{allowedCountries:n.allowedCountries,classNameModifiers:d,label:x,errorMessage:B,onDropdownChange:n.onDropdownChange,value:M,required:!j});case"stateOrProvince":return e(o,{classNameModifiers:d,label:x,errorMessage:B,onDropdownChange:n.onDropdownChange,selectedCountry:b,specifications:n.specifications,value:M,required:!j});default:return e(r,{label:x,classNameModifiers:d,errorMessage:B,isValid:m[p],name:p,i18n:l,onFocus:e=>n.onFieldFocusAnalytics(p,e),onBlur:e=>n.onFieldBlurAnalytics(p,e)},e(t,{name:p,classNameModifiers:d,value:M,onInput:f,onBlur:g,maxlength:v,trimOnBlur:F,disabled:y,required:!j,autocomplete:a(p,C)}))}}export{l as default};
|
|
2
2
|
//# sourceMappingURL=FieldContainer.js.map
|