@adyen/adyen-web 6.38.0 → 6.39.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/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +82 -74
- 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/PayIDInput.js +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/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/core/config.js +1 -1
- package/dist/es/index.d.ts +82 -74
- 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/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/PayIDInput.js +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/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/core/config.js +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 +15 -15
package/dist/cjs/index.d.cts
CHANGED
|
@@ -4,14 +4,87 @@ import * as preact from 'preact';
|
|
|
4
4
|
import { h, TargetedMouseEvent, Ref, RefObject, Component, ComponentChildren, FunctionComponent, ComponentChild } from 'preact';
|
|
5
5
|
import { OrderResponseBody, OnShippingAddressChangeData, OnShippingOptionsChangeData, OnInitActions } from '@paypal/paypal-js';
|
|
6
6
|
|
|
7
|
+
interface ILanguageService {
|
|
8
|
+
fetchTranslationsFromCdn(locale: string): Promise<Readonly<Translations>>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type CustomTranslations = {
|
|
12
|
+
[locale: string]: Translations;
|
|
13
|
+
};
|
|
14
|
+
type Translations = {
|
|
15
|
+
[translationKey: string]: string;
|
|
16
|
+
};
|
|
17
|
+
interface LanguageOptions {
|
|
18
|
+
service: ILanguageService;
|
|
19
|
+
locale?: string;
|
|
20
|
+
customTranslations?: CustomTranslations;
|
|
21
|
+
onError?: CoreConfiguration['onError'];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class Language {
|
|
25
|
+
readonly locale: string;
|
|
26
|
+
readonly languageCode: string;
|
|
27
|
+
private readonly service;
|
|
28
|
+
private readonly customTranslations;
|
|
29
|
+
/**
|
|
30
|
+
* Supported locales list
|
|
31
|
+
* Includes all supported locales from the CDN and any custom locales defined in customTranslations
|
|
32
|
+
*/
|
|
33
|
+
private readonly supportedLocales;
|
|
34
|
+
/**
|
|
35
|
+
* Translations object
|
|
36
|
+
* Contains all translations for the current locale, including English as fallback
|
|
37
|
+
*/
|
|
38
|
+
private _translations;
|
|
39
|
+
readonly timeFormatOptions: Intl.DateTimeFormatOptions;
|
|
40
|
+
readonly timeAndDateFormatOptions: Intl.DateTimeFormatOptions;
|
|
41
|
+
readonly timeAndDateFormatter: Intl.DateTimeFormat;
|
|
42
|
+
constructor(props: LanguageOptions);
|
|
43
|
+
requestTranslations(): Promise<void>;
|
|
44
|
+
get translations(): Readonly<Translations>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a translated string from a key in the current {@link Language.locale}
|
|
47
|
+
* @param key - Translation key
|
|
48
|
+
* @param options - Translation options
|
|
49
|
+
* @returns Translated string
|
|
50
|
+
*/
|
|
51
|
+
get(key: string, options?: any): string;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a localized string for an amount
|
|
54
|
+
* @param amount - Amount to be converted
|
|
55
|
+
* @param currencyCode - Currency code of the amount
|
|
56
|
+
* @param options - Options for String.prototype.toLocaleString
|
|
57
|
+
*/
|
|
58
|
+
amount(amount: number, currencyCode: string, options?: object): string;
|
|
59
|
+
/**
|
|
60
|
+
* Returns a localized string for a date
|
|
61
|
+
* @param date - Date to be localized
|
|
62
|
+
* @param options - Options for {@link Intl.DateTimeFormatOptions}
|
|
63
|
+
*/
|
|
64
|
+
date(date: string, options?: Intl.DateTimeFormatOptions): string;
|
|
65
|
+
/**
|
|
66
|
+
* Returns a localized string for a date and time
|
|
67
|
+
* @param date - Date to be localized
|
|
68
|
+
*/
|
|
69
|
+
dateTime(date: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a list of supported locales including the ones passed as custom translations
|
|
72
|
+
*
|
|
73
|
+
* @param customTranslations - Custom translations to include
|
|
74
|
+
* @returns Array of supported locales
|
|
75
|
+
*/
|
|
76
|
+
private createSupportedLocalesList;
|
|
77
|
+
}
|
|
78
|
+
|
|
7
79
|
/**
|
|
8
80
|
* Holds the result of a validation
|
|
9
81
|
*/
|
|
10
82
|
declare class ValidationRuleResult {
|
|
11
83
|
private readonly shouldValidate;
|
|
12
84
|
isValid: boolean;
|
|
13
|
-
errorMessage: string | ErrorMessageObject;
|
|
14
|
-
|
|
85
|
+
errorMessage: string | ErrorMessageObject | undefined;
|
|
86
|
+
errorI18n: string;
|
|
87
|
+
constructor(rule: ValidatorRule, value: string, mode: ValidatorMode, context: FieldContext, i18n: Language);
|
|
15
88
|
/**
|
|
16
89
|
* Whether the validation is considered an error.
|
|
17
90
|
* A field is only considered to be an error if the validation rule applies to the current mode i.e. 'blur' or 'input'.
|
|
@@ -37,6 +110,11 @@ interface ValidatorRule {
|
|
|
37
110
|
type ValidatorRules = {
|
|
38
111
|
[field: string]: ValidatorRule | ValidatorRule[];
|
|
39
112
|
};
|
|
113
|
+
interface FieldContext {
|
|
114
|
+
state: {
|
|
115
|
+
[key: string]: unknown;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
40
118
|
|
|
41
119
|
type OnAddressLookupType = (value: string, actions: {
|
|
42
120
|
resolve: (value: Array<AddressLookupItem>) => void;
|
|
@@ -182,78 +260,6 @@ interface InstallmentOptions {
|
|
|
182
260
|
[key: string]: InstallmentOption;
|
|
183
261
|
}
|
|
184
262
|
|
|
185
|
-
interface ILanguageService {
|
|
186
|
-
fetchTranslationsFromCdn(locale: string): Promise<Readonly<Translations>>;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
type CustomTranslations = {
|
|
190
|
-
[locale: string]: Translations;
|
|
191
|
-
};
|
|
192
|
-
type Translations = {
|
|
193
|
-
[translationKey: string]: string;
|
|
194
|
-
};
|
|
195
|
-
interface LanguageOptions {
|
|
196
|
-
service: ILanguageService;
|
|
197
|
-
locale?: string;
|
|
198
|
-
customTranslations?: CustomTranslations;
|
|
199
|
-
onError?: CoreConfiguration['onError'];
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
declare class Language {
|
|
203
|
-
readonly locale: string;
|
|
204
|
-
readonly languageCode: string;
|
|
205
|
-
private readonly service;
|
|
206
|
-
private readonly customTranslations;
|
|
207
|
-
/**
|
|
208
|
-
* Supported locales list
|
|
209
|
-
* Includes all supported locales from the CDN and any custom locales defined in customTranslations
|
|
210
|
-
*/
|
|
211
|
-
private readonly supportedLocales;
|
|
212
|
-
/**
|
|
213
|
-
* Translations object
|
|
214
|
-
* Contains all translations for the current locale, including English as fallback
|
|
215
|
-
*/
|
|
216
|
-
private _translations;
|
|
217
|
-
readonly timeFormatOptions: Intl.DateTimeFormatOptions;
|
|
218
|
-
readonly timeAndDateFormatOptions: Intl.DateTimeFormatOptions;
|
|
219
|
-
readonly timeAndDateFormatter: Intl.DateTimeFormat;
|
|
220
|
-
constructor(props: LanguageOptions);
|
|
221
|
-
requestTranslations(): Promise<void>;
|
|
222
|
-
get translations(): Readonly<Translations>;
|
|
223
|
-
/**
|
|
224
|
-
* Returns a translated string from a key in the current {@link Language.locale}
|
|
225
|
-
* @param key - Translation key
|
|
226
|
-
* @param options - Translation options
|
|
227
|
-
* @returns Translated string
|
|
228
|
-
*/
|
|
229
|
-
get(key: string, options?: any): string;
|
|
230
|
-
/**
|
|
231
|
-
* Returns a localized string for an amount
|
|
232
|
-
* @param amount - Amount to be converted
|
|
233
|
-
* @param currencyCode - Currency code of the amount
|
|
234
|
-
* @param options - Options for String.prototype.toLocaleString
|
|
235
|
-
*/
|
|
236
|
-
amount(amount: number, currencyCode: string, options?: object): string;
|
|
237
|
-
/**
|
|
238
|
-
* Returns a localized string for a date
|
|
239
|
-
* @param date - Date to be localized
|
|
240
|
-
* @param options - Options for {@link Intl.DateTimeFormatOptions}
|
|
241
|
-
*/
|
|
242
|
-
date(date: string, options?: Intl.DateTimeFormatOptions): string;
|
|
243
|
-
/**
|
|
244
|
-
* Returns a localized string for a date and time
|
|
245
|
-
* @param date - Date to be localized
|
|
246
|
-
*/
|
|
247
|
-
dateTime(date: string): string;
|
|
248
|
-
/**
|
|
249
|
-
* Creates a list of supported locales including the ones passed as custom translations
|
|
250
|
-
*
|
|
251
|
-
* @param customTranslations - Custom translations to include
|
|
252
|
-
* @returns Array of supported locales
|
|
253
|
-
*/
|
|
254
|
-
private createSupportedLocalesList;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
263
|
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'action' | 'link' | 'iconOnly';
|
|
258
264
|
interface ButtonProps {
|
|
259
265
|
status?: string;
|
|
@@ -265,7 +271,9 @@ interface ButtonProps {
|
|
|
265
271
|
disabled?: boolean;
|
|
266
272
|
label?: string | h.JSX.Element;
|
|
267
273
|
onClickCompletedLabel?: string | h.JSX.Element;
|
|
274
|
+
id?: string;
|
|
268
275
|
ariaLabel?: string;
|
|
276
|
+
ariaLabelledBy?: string;
|
|
269
277
|
ariaDescribedBy?: string;
|
|
270
278
|
ariaExpanded?: boolean;
|
|
271
279
|
ariaControls?: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"./PaymentMethodIcon.js";import{useCoreContext as
|
|
1
|
+
import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"./PaymentMethodIcon.js";import a from"../../../internal/Button/Button.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import r from"../../../../core/Context/useImage.js";import{stopPropagationForActionKeys as n}from"../../../internal/Button/stopPropagationForActionKeys.js";const d=({order:d,orderStatus:m,onOrderCancel:l,brandLogoConfiguration:s})=>{const{i18n:i}=o(),c=r();return e("div",null,e("ul",{className:"adyen-checkout__order-payment-methods-list"},m?.paymentMethods?.map((o,r)=>e("li",{key:`${o.type}-${r}`,className:"adyen-checkout__order-payment-method"},e("div",{className:"adyen-checkout__order-payment-method__header"},e("div",{className:"adyen-checkout__payment-method__header__title",role:"group",id:`order-payment-method-${o.type}-${r}`,"aria-label":o.lastFour?i.get("order.paymentMethod.description",{values:{name:o.name??o.type,lastFour:o.lastFour.toString().split("").join(" ")}}):void 0},e(t,{alt:o.name,type:o.type,src:s[o.type]||c()(o.type)}),o.label?`${o.label}`:`•••• ${o.lastFour}`),l&&e(a,{inline:!0,variant:"link",id:`order-payment-method-remove-${o.type}-${r}`,ariaLabelledBy:o.lastFour?`order-payment-method-${o.type}-${r} order-payment-method-remove-${o.type}-${r}`:void 0,label:i.get("storedPaymentMethod.disable.button"),onKeyPress:n,onKeyDown:n,onClick:()=>{l({order:d})}})),e("div",{className:"adyen-checkout__order-payment-method__details"},e("div",{className:"adyen-checkout__order-payment-method__deducted-amount"},e("span",{className:"adyen-checkout__order-payment-method__deducted-amount__label"},i.get("deductedBalance")),e("span",{className:"adyen-checkout__order-payment-method__deducted-amount__value"},i.amount(o.amount.value,o.amount.currency))))))),m.remainingAmount&&e("p",{className:"adyen-checkout__order-remaining-amount"},i.get("partialPayment.warning")," ",e("strong",null,i.amount(m.remainingAmount.value,m.remainingAmount.currency))))};export{d as OrderPaymentMethods,d as default};
|
|
2
2
|
//# sourceMappingURL=OrderPaymentMethods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/OrderPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodIcon from './PaymentMethodIcon';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport './OrderPaymentMethods.scss';\nimport { Order, OrderStatus } from '../../../../types';\n\ntype OrderPaymentMethodsProps = {\n order: Order;\n orderStatus: OrderStatus;\n onOrderCancel: (order) => void;\n brandLogoConfiguration: any;\n};\n\nexport const OrderPaymentMethods = ({ order, orderStatus, onOrderCancel, brandLogoConfiguration }: Readonly<OrderPaymentMethodsProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div>\n <ul className={'adyen-checkout__order-payment-methods-list'}>\n {orderStatus?.paymentMethods?.map((orderPaymentMethod, index) => (\n <li key={`${orderPaymentMethod.type}-${index}`} className=\"adyen-checkout__order-payment-method\">\n <div className=\"adyen-checkout__order-payment-method__header\">\n <div
|
|
1
|
+
{"version":3,"file":"OrderPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/OrderPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodIcon from './PaymentMethodIcon';\nimport Button from '../../../internal/Button';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport './OrderPaymentMethods.scss';\nimport { Order, OrderStatus } from '../../../../types';\nimport { stopPropagationForActionKeys } from '../../../internal/Button/stopPropagationForActionKeys';\n\ntype OrderPaymentMethodsProps = {\n order: Order;\n orderStatus: OrderStatus;\n onOrderCancel: (order) => void;\n brandLogoConfiguration: any;\n};\n\nexport const OrderPaymentMethods = ({ order, orderStatus, onOrderCancel, brandLogoConfiguration }: Readonly<OrderPaymentMethodsProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div>\n <ul className={'adyen-checkout__order-payment-methods-list'}>\n {orderStatus?.paymentMethods?.map((orderPaymentMethod, index) => (\n <li key={`${orderPaymentMethod.type}-${index}`} className=\"adyen-checkout__order-payment-method\">\n <div className=\"adyen-checkout__order-payment-method__header\">\n <div\n className=\"adyen-checkout__payment-method__header__title\"\n role=\"group\"\n id={`order-payment-method-${orderPaymentMethod.type}-${index}`}\n aria-label={\n orderPaymentMethod.lastFour\n ? i18n.get('order.paymentMethod.description', {\n values: {\n name: orderPaymentMethod.name ?? orderPaymentMethod.type,\n lastFour: orderPaymentMethod.lastFour.toString().split('').join(' ')\n }\n })\n : undefined\n }\n >\n <PaymentMethodIcon\n alt={orderPaymentMethod.name}\n type={orderPaymentMethod.type}\n src={brandLogoConfiguration[orderPaymentMethod.type] || getImage()(orderPaymentMethod.type)}\n />\n {orderPaymentMethod.label ? `${orderPaymentMethod.label}` : `•••• ${orderPaymentMethod.lastFour}`}\n </div>\n\n {onOrderCancel && (\n <Button\n inline\n variant=\"link\"\n id={`order-payment-method-remove-${orderPaymentMethod.type}-${index}`}\n ariaLabelledBy={\n orderPaymentMethod.lastFour\n ? `order-payment-method-${orderPaymentMethod.type}-${index} order-payment-method-remove-${orderPaymentMethod.type}-${index}`\n : undefined\n }\n label={i18n.get('storedPaymentMethod.disable.button')}\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n onClick={() => {\n onOrderCancel({ order });\n }}\n />\n )}\n </div>\n <div className=\"adyen-checkout__order-payment-method__details\">\n <div className=\"adyen-checkout__order-payment-method__deducted-amount\">\n <span className=\"adyen-checkout__order-payment-method__deducted-amount__label\">{i18n.get('deductedBalance')}</span>\n <span className=\"adyen-checkout__order-payment-method__deducted-amount__value\">\n {i18n.amount(orderPaymentMethod.amount.value, orderPaymentMethod.amount.currency)}\n </span>\n </div>\n </div>\n </li>\n ))}\n </ul>\n\n {orderStatus.remainingAmount && (\n <p className=\"adyen-checkout__order-remaining-amount\">\n {i18n.get('partialPayment.warning')}{' '}\n <strong>{i18n.amount(orderStatus.remainingAmount.value, orderStatus.remainingAmount.currency)}</strong>\n </p>\n )}\n </div>\n );\n};\n\nexport default OrderPaymentMethods;\n"],"names":["OrderPaymentMethods","order","orderStatus","onOrderCancel","brandLogoConfiguration","i18n","useCoreContext","getImage","useImage","h","div","ul","className","paymentMethods","map","orderPaymentMethod","index","li","key","type","role","id","aria-label","lastFour","get","values","name","toString","split","join","undefined","PaymentMethodIcon","alt","src","label","Button","inline","variant","ariaLabelledBy","onKeyPress","stopPropagationForActionKeys","onKeyDown","onClick","span","amount","value","currency","remainingAmount","p","strong"],"mappings":"yYAgBO,MAAMA,EAAsB,EAAGC,QAAOC,cAAaC,gBAAeC,6BACrE,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,WACGD,EAACE,KAAAA,CAAGC,UAAW,8CACVV,GAAaW,gBAAgBC,IAAI,CAACC,EAAoBC,IACnDP,EAACQ,KAAAA,CAAGC,IAAK,GAAGH,EAAmBI,QAAQH,IAASJ,UAAU,wCACtDH,EAACC,MAAAA,CAAIE,UAAU,gDACXH,EAACC,MAAAA,CACGE,UAAU,gDACVQ,KAAK,QACLC,GAAI,wBAAwBN,EAAmBI,QAAQH,IACvDM,aACIP,EAAmBQ,SACblB,EAAKmB,IAAI,kCAAmC,CACxCC,OAAQ,CACJC,KAAMX,EAAmBW,MAAQX,EAAmBI,KACpDI,SAAUR,EAAmBQ,SAASI,WAAWC,MAAM,IAAIC,KAAK,aAGxEC,GAGVrB,EAACsB,EAAAA,CACGC,IAAKjB,EAAmBW,KACxBP,KAAMJ,EAAmBI,KACzBc,IAAK7B,EAAuBW,EAAmBI,OAASZ,IAAWQ,EAAmBI,QAEzFJ,EAAmBmB,MAAQ,GAAGnB,EAAmBmB,QAAU,QAAQnB,EAAmBQ,YAG1FpB,GACGM,EAAC0B,EAAAA,CACGC,QAAAA,EACAC,QAAQ,OACRhB,GAAI,+BAA+BN,EAAmBI,QAAQH,IAC9DsB,eACIvB,EAAmBQ,SACb,wBAAwBR,EAAmBI,QAAQH,iCAAqCD,EAAmBI,QAAQH,SACnHc,EAEVI,MAAO7B,EAAKmB,IAAI,sCAChBe,WAAYC,EACZC,UAAWD,EACXE,QAAS,KACLvC,EAAc,CAAEF,cAKhCQ,EAACC,MAAAA,CAAIE,UAAU,iDACXH,EAACC,MAAAA,CAAIE,UAAU,yDACXH,EAACkC,OAAAA,CAAK/B,UAAU,gEAAgEP,EAAKmB,IAAI,oBACzFf,EAACkC,OAAAA,CAAK/B,UAAU,gEACXP,EAAKuC,OAAO7B,EAAmB6B,OAAOC,MAAO9B,EAAmB6B,OAAOE,gBAQ/F5C,EAAY6C,iBACTtC,EAACuC,IAAAA,CAAEpC,UAAU,0CACRP,EAAKmB,IAAI,0BAA2B,IACrCf,EAACwC,cAAQ5C,EAAKuC,OAAO1C,EAAY6C,gBAAgBF,MAAO3C,EAAY6C,gBAAgBD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import
|
|
1
|
+
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import s from"./defaultProps.js";import i from"../../core/Errors/AdyenCheckoutError.js";import{ERRORS as r}from"./constants.js";import{TxVariants as a}from"../tx-variants.js";import{formatPaypalOrderContactToAdyenFormat as o}from"./utils/format-paypal-order-contact-to-adyen-format.js";import{AnalyticsInfoEvent as h,InfoEventType as p}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{sanitizeResponse as l,verifyPaymentDidNotFail as d}from"../internal/UIElement/utils.js";import c from"../../core/Errors/CancelError.js";function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u extends t{formatProps(e){const t=e.configuration?.merchantId,n=e.configuration?.intent,s=0===e.amount?.value?"tokenize":e.intent||n,i="tokenize"===s||e.vault,r="continue"===e.userAction;return{...e,commit:!r&&e.commit,vault:i,configuration:{intent:s,merchantId:t}}}beforeRender(e){const t=new h({type:p.rendered,component:this.type,configData:{...e,showPayButton:this.props.showPayButton},...e?.isExpress&&{isExpress:e.isExpress},...e?.expressPage&&{expressPage:e.expressPage}});this.analytics.sendAnalytics(t)}updatePaymentData(e){e||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=e}formatData(){const{isExpress:e,userAction:t}=this.props;return{paymentMethod:{type:u.type,userAction:t,subtype:e?"express":u.subtype}}}get isValid(){return!0}handleResolve(e){if(!this.resolve)return this.handleError(new i("ERROR",r.WRONG_INSTANCE));this.resolve(e)}handleReject(e){if(!this.reject)return this.handleError(new i("ERROR",r.WRONG_INSTANCE));this.reject(new Error(e))}handleSubmit(){return new Promise((e,t)=>{this.resolve=e,this.reject=t,this.makePaymentsCall().then(l).then(d).then(this.handleResponse).catch(e=>{if(e instanceof c)return void this.setElementStatus("ready");this.handleFailedResult(e);const t=e instanceof Error?e.message:JSON.stringify(e),n=e?`: ${t}`:"";this.handleReject(`${r.PAYMENT_FAILED}${n}`)})})}handleOnShippingAddressChange(e,t){const{onShippingAddressChange:n}=this.props;return n?n(e,t,this):Promise.resolve()}handleOnShippingOptionsChange(e,t){const{onShippingOptionsChange:n}=this.props;return n?n(e,t,this):Promise.resolve()}componentToRender(){if(!this.props.showPayButton)return null;const{onShippingAddressChange:t,onShippingOptionsChange:s,...r}=this.props;return e(n,{...r,setComponentRef:this.setComponentRef,...t&&{onShippingAddressChange:this.handleOnShippingAddressChange},...s&&{onShippingOptionsChange:this.handleOnShippingOptionsChange},onCancel:()=>this.handleError(new i("CANCEL")),onChange:this.setState,onApprove:this.handleOnApprove,onError:e=>{this.handleError(new i("ERROR",String(e),{cause:e}))},onScriptLoadFailure:e=>this.handleError(e),onSubmit:this.handleSubmit})}constructor(e,t){super(e,t),m(this,"paymentData",null),m(this,"resolve",null),m(this,"reject",null),m(this,"submit",()=>{this.handleError(new i("IMPLEMENTATION_ERROR",r.SUBMIT_NOT_SUPPORTED))}),m(this,"handleAction",e=>this.updateWithAction(e)),m(this,"updateWithAction",e=>{if(e.paymentMethodType!==this.type)throw new Error("Invalid Action");return e.paymentData&&(this.paymentData=e.paymentData),e.sdkData&&e.sdkData.token?(this.onActionHandled({componentType:this.type,actionDescription:"sdk-loaded",originalAction:e}),this.handleResolve(e.sdkData.token)):this.handleReject(r.NO_TOKEN_PROVIDED),null}),m(this,"handleOnApprove",(e,t)=>{const{onAuthorized:n}=this.props,s={data:{details:e,paymentData:this.paymentData??void 0}};return n?t.order?t.order.get().then(e=>{const t=o(e?.payer),s=o(e?.purchase_units?.[0].shipping,!0);return this.setState({authorizedEvent:e,...t&&{billingAddress:t},...s&&{deliveryAddress:s}}),new Promise((i,r)=>n({authorizedEvent:e,...t&&{billingAddress:t},...s&&{deliveryAddress:s}},{resolve:i,reject:r}))}).then(()=>this.handleAdditionalDetails(s)).catch(e=>this.handleError(new i("ERROR","Something went wrong while parsing PayPal Order",{cause:e}))):(this.handleError(new i("ERROR","PayPal order actions are not available")),Promise.resolve()):(this.handleAdditionalDetails(s),Promise.resolve())}),this.handleSubmit=this.handleSubmit.bind(this),this.handleOnShippingAddressChange=this.handleOnShippingAddressChange.bind(this),this.handleOnShippingOptionsChange=this.handleOnShippingOptionsChange.bind(this)}}m(u,"type",a.paypal),m(u,"subtype","sdk"),m(u,"defaultProps",s);export{u as default};
|
|
2
2
|
//# sourceMappingURL=Paypal.js.map
|
|
@@ -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","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","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","onAuthorized","state","details","undefined","order","get","then","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","authorizedEvent","handleAdditionalDetails","catch","bind","TxVariants","paypal","defaultProps"],"mappings":"mrBAyBA,MAAMA,UAAsBC,EAkBxBC,WAAAA,CAAYC,GACR,MAAMC,EAAaD,EAAME,eAAeD,WAClCE,EAAmBH,EAAME,eAAeE,OAExCA,EADqC,IAAxBJ,EAAMK,QAAQC,MACe,WAAaN,EAAMI,QAAUD,EACvEI,EAAmB,aAAXH,GAAyBJ,EAAMO,MAEvCC,EAAyD,aAArBR,EAAMS,WAEhD,MAAO,IACAT,EACHU,QAAQF,GAA4CR,EAAMU,OAC1DH,QACAL,cAAe,CACXE,SACAH,cAGZ,CAEmBU,YAAAA,CAAaC,GAC5B,MAAMC,EAAQ,IAAIC,EAAmB,CACjCC,KAAMC,EAAcC,SACpBC,UAAWC,KAAKJ,KAChBK,WAAY,IAAKR,EAAqBS,cAAeF,KAAKnB,MAAMqB,kBAC5DT,GAAqBU,WAAa,CAAEA,UAAWV,EAAoBU,cACnEV,GAAqBW,aAAe,CAAEA,YAAaX,EAAoBW,eAG/EJ,KAAKK,UAAUC,cAAcZ,EACjC,CAUOa,iBAAAA,CAAkBC,GAChBA,GAAaC,QAAQC,KAAK,wDAC/BV,KAAKQ,YAAcA,CACvB,CAKA,UAAAG,GACI,MAAMR,UAAEA,EAASb,WAAEA,GAAeU,KAAKnB,MAEvC,MA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c,gBAAiBP,KACbC,GAAkB,CAAEA,qBACpBG,GAAmB,CAAEA,oBAE7B,CAAE5D,UAASO,cAItBgD,KAAK,IAAMxE,KAAKiF,wBAAwBd,IACxCe,MAAMnC,GAAS/C,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,kDAAmD,CAAE8B,MAAOF,OA5B7H/C,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,2CAC1CU,QAAQZ,YANfjB,KAAKiF,wBAAwBd,GACtBtC,QAAQZ,aAtGnBjB,KAAK0B,aAAe1B,KAAK0B,aAAayD,KAAKnF,MAC3CA,KAAK8B,8BAAgC9B,KAAK8B,8BAA8BqD,KAAKnF,MAC7EA,KAAKkC,8BAAgClC,KAAKkC,8BAA8BiD,KAAKnF,KACjF,EAfAsD,EADE5E,EACqBkB,OAAOwF,EAAWC,QACzC/B,EAFE5E,EAEqBmC,UAAU,OAOjCyC,EATE5E,EASwB4G,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","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","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","onAuthorized","state","details","undefined","order","get","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","authorizedEvent","handleAdditionalDetails","bind","TxVariants","paypal","defaultProps"],"mappings":"k0BA2BA,MAAMA,UAAsBC,EAkBxBC,WAAAA,CAAYC,GACR,MAAMC,EAAaD,EAAME,eAAeD,WAClCE,EAAmBH,EAAME,eAAeE,OAExCA,EADqC,IAAxBJ,EAAMK,QAAQC,MACe,WAAaN,EAAMI,QAAUD,EACvEI,EAAmB,aAAXH,GAAyBJ,EAAMO,MAEvCC,EAAyD,aAArBR,EAAMS,WAEhD,MAAO,IACAT,EACHU,QAAQF,GAA4CR,EAAMU,OAC1DH,QACAL,cAAe,CACXE,SACAH,cAGZ,CAEmBU,YAAAA,CAAaC,GAC5B,MAAMC,EAAQ,IAAIC,EAAmB,CACjCC,KAAMC,EAAcC,SACpBC,UAAWC,KAAKJ,KAChBK,WAAY,IAAKR,EAAqBS,cAAeF,KAAKnB,MAAMqB,kBAC5DT,GAAqBU,WAAa,CAAEA,UAAWV,EAAoBU,cACnEV,GAAqBW,aAAe,CAAEA,YAAaX,EAAoBW,eAG/EJ,KAAKK,UAAUC,cAAcZ,EACjC,CAUOa,iBAAAA,CAAkBC,GAChBA,GAAaC,QAAQC,KAAK,wDAC/BV,KAAKQ,YAAcA,CACvB,CAKA,UAAAG,GACI,MAAMR,UAAEA,EAASb,WAAEA,GAAeU,KAAKnB,MAEvC,MAAO,CACH+B,cAAe,CACXhB,KAAMlB,EAAckB,KACpBN,aACAuB,QAASV,EAAY,UAAYzB,EAAcmC,SAG3D,CA6BA,WAAIC,GACA,OAAO,CACX,CA2CAC,aAAAA,CAAcC,GACV,IAAKhB,KAAKiB,QAAS,OAAOjB,KAAKkB,YAAY,IAAIC,EAAmB,QAASC,EAAOC,iBAClFrB,KAAKiB,QAAQD,EACjB,CAEAM,YAAAA,CAAaC,GACT,IAAKvB,KAAKwB,OAAQ,OAAOxB,KAAKkB,YAAY,IAAIC,EAAmB,QAASC,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BAE7B,CAAE1E,UAASO,cAItBK,KAAK,IAAM7B,KAAK+F,wBAAwBb,IACxCjD,MAAM2B,GAAS5D,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,kDAAmD,CAAE2C,MAAOF,OA5B7H5D,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,2CAC1CQ,QAAQV,YANfjB,KAAK+F,wBAAwBb,GACtBvD,QAAQV,aAtGnBjB,KAAK0B,aAAe1B,KAAK0B,aAAasE,KAAKhG,MAC3CA,KAAK2C,8BAAgC3C,KAAK2C,8BAA8BqD,KAAKhG,MAC7EA,KAAK+C,8BAAgC/C,KAAK+C,8BAA8BiD,KAAKhG,KACjF,EAfAoE,EADE1F,EACqBkB,OAAOqG,EAAWC,QACzC9B,EAFE1F,EAEqBmC,UAAU,OAOjCuD,EATE1F,EASwByH,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 b}from"./validate.js";import{phoneFormatters as u}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:b,formatters:u,formHolder:`#${N}`}),{handleChangeFor:A,triggerValidation:j,data:v,errors:B,valid:C,isValid:S}=g;t(()=>{h({data:v,valid:C,errors:B,isValid:S})},[v,C,B,S]);const y=a({setStatus:F,showValidation:j});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:v.bankAccountNumber,onInput:A("bankAccountNumber","input"),onBlur:A("bankAccountNumber","blur"),placeholder:f?.bankAccountNumber,required:!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:v.bsb,onInput:A("bsb","input"),onBlur:A("bsb","blur"),placeholder:f?.bsb,required:!0})),e(m,{i18n:k,data:v,handleChangeFor:A,errors:B,placeholders:f}))}export{d as default};
|
|
2
2
|
//# sourceMappingURL=BSBInput.js.map
|
|
@@ -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 a}from"./IdentifierSelector.js";import{useEffect as t,useRef as o}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 a}from"./IdentifierSelector.js";import{useEffect as t,useRef as o}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as l}from"../../../core/Context/CoreProvider.js";import s from"../../../utils/useForm/useFormWithA11y.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import n 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 f from"../../internal/FormFields/InputText.js";import{payIdValidationRules as c}from"./validate.js";import{phoneFormatters as u}from"../../internal/PhoneInput/validate.js";import g from"./PayToNameFields.js";const h=["selectedIdentifier","firstName","lastName"],b={[a.email]:["email"],[a.phone]:["phoneNumber","phonePrefix"],[a.abn]:["abn"],[a.orgid]:["orgid"]};function I({setComponentRef:I,defaultData:F,placeholders:j,onChange:y,setStatus:N,id:v}){const{i18n:M}=l(),C=s({schema:h,defaultData:{selectedIdentifier:a.phone,...F},rules:c,formatters:u,formHolder:`#${v}`}),{handleChangeFor:P,triggerValidation:S,data:x,errors:B,valid:E,isValid:A,setSchema:V}=C;t(()=>{V([...b[x.selectedIdentifier],...h])},[x.selectedIdentifier]),t(()=>{y({data:x,valid:E,errors:B,isValid:A})},[x,E,B,A]);const q=o({setStatus:N,showValidation:S});return t(()=>{I(q.current)},[I]),e(r,{id:v,classNameModifiers:["payto__payid_input"],label:"PayID",description:"payto.payid.description"},e(i,{classNameModifiers:["col-40"],onSelectedIdentifier:P("selectedIdentifier"),selectedIdentifier:x.selectedIdentifier}),x.selectedIdentifier===a.phone&&e(n,{form:C}),x.selectedIdentifier===a.email&&e(p,{label:M.get("shopperEmail"),classNameModifiers:["col-60","email"],errorMessage:m(M,B.email,M.get("shopperEmail")),dir:"ltr",name:"email",i18n:M,errorLive:!0},e(d,{name:"email",value:x.email,onInput:P("email","input"),onBlur:P("email","blur"),placeholder:j?.email,required:!0})),x.selectedIdentifier===a.abn&&e(p,{label:M.get("ABN"),classNameModifiers:["col-60","abn"],errorMessage:m(M,B.abn,M.get("ABN")),name:"ABN",i18n:M,errorLive:!0},e(f,{name:"abn",value:x.abn,onInput:P("abn","input"),onBlur:P("abn","blur"),placeholder:j?.abn,required:!0})),x.selectedIdentifier===a.orgid&&e(p,{label:M.get("payto.payid.label.orgid"),classNameModifiers:["col-60","orgid"],errorMessage:m(M,B.orgid,M.get("payto.payid.label.orgid")),name:"orgid",i18n:M,errorLive:!0},e(f,{name:"orgid",value:x.orgid,onInput:P("orgid","input"),onBlur:P("orgid","blur"),placeholder:j?.orgid,required:!0})),e(g,{i18n:M,data:x,handleChangeFor:P,errors:B,placeholders:j}))}export{I as default};
|
|
2
2
|
//# sourceMappingURL=PayIDInput.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{classNameModifiers:
|
|
1
|
+
import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{id:e,classNameModifiers:i=[],disabled:r,href:s,icon:l,onClickCompletedIcon:c,inline:d,label:u,ariaLabel:p,ariaLabelledBy:m,ariaDescribedBy:b,ariaExpanded:h,ariaControls:_,status:y,variant:f,buttonRef:g,onClickCompletedLabel:k,onMouseEnter:C,onMouseLeave:v,onFocus:x,onBlur:N,onKeyDown:S,onKeyPress:L}=this.props,{completed:B}=this.state,{i18n:j}=o(),D=c||l?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed?c??l:l,alt:"","aria-hidden":"true"}):"",M=[...i,..."primary"===f?[]:[f],...d?["inline"]:[],...B?["completed"]:[],..."loading"===y||"redirect"===y?["loading"]:[]],P=a(["adyen-checkout__button",...M.map(e=>`adyen-checkout__button--${e}`)]),E={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),j.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},D,t("span",{className:"adyen-checkout__button__text"},this.state.completed?k??u:u))},K=E[y]||E.default;return s?t("a",{className:P,href:s,target:this.props.target,rel:this.props.rel,"aria-disabled":r,onClick:e=>{r&&e.preventDefault()}},K):t("button",{ref:g,id:e,className:P,type:"button",disabled:r,onClick:this.onClick,"aria-label":p,"aria-labelledby":m,"aria-describedby":b,"aria-expanded":h,"aria-controls":_,onMouseEnter:C,onMouseLeave:v,onKeyDown:S,onFocus:x,onBlur:N,onKeyPress:L},K,"loading"!==y&&"redirect"!==y&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},j.get(this.buttonStatusSRLabel(y))))}constructor(...e){super(...e),i(this,"onClick",e=>{e.preventDefault(),this.props.disabled||this.props.onClick?.(e,{complete:this.complete})}),i(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),i(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}i(r,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{r as default};
|
|
2
2
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaDescribedBy,\n ariaExpanded,\n ariaControls,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaDescribedBy","ariaExpanded","ariaControls","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-describedby","aria-expanded","aria-controls","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n id,\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaExpanded,\n ariaControls,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n id={id}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","id","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaExpanded","ariaControls","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-labelledby","aria-describedby","aria-expanded","aria-controls","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,GACFA,EAAEC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,eACTA,EAAcC,gBACdA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,OACZA,EAAMC,QACNA,EAAOC,UACPA,EAASC,sBACTA,EAAqBC,aACrBA,EAAYC,aACZA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,EAASC,WACTA,GACaC,KAAKC,OAChBC,UAAEA,GAAcF,KAAKG,OACrBC,KAAEA,GAASC,IAEXC,EACFxB,GAAwBD,EACpB0B,EAACC,MAAAA,CACGC,UAAU,+BACVC,IAAKV,KAAKG,MAAMD,UAAapB,GAAwBD,EAAQA,EAC7D8B,IAAI,GACJC,cAAY,SAGhB,GAGFC,EAAY,IACXnC,KACa,YAAZa,EAAwB,GAAK,CAACA,MAC9BR,EAAS,CAAC,UAAY,MACtBmB,EAAY,CAAC,aAAe,MACjB,YAAXZ,GAAmC,aAAXA,EAAwB,CAAC,WAAa,IAGhEwB,EAAgBC,EAAW,CAAC,4BAA6BF,EAAUG,IAAIC,GAAK,2BAA2BA,OAEvGC,EAAe,CACjBC,QACIZ,EAACa,OA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mD,SAAS,CAAEjD,WAAW,IAC3BkD,WAAW,KACPpD,KAAKmD,SAAS,CAAEjD,WAAW,KAC5BgD,KAGPF,EAAAhD,KAAiB6C,sBAAuBvD,IACK,CACrC6B,QAAS,UACTI,SAAU,yBAGEjC,IAAW,MA9B/B0D,EADE1E,EACqB+E,eAAe,CAClC/D,OAAQ,UACRC,QAAS,UACTZ,UAAU,EACVK,MAAO,GACPD,QAAQ,EACR6C,OAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t,Fragment as o}from"../../../../../external/preact/dist/preact.js";import{useState as r,useCallback as e}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../../Button/Button.js";import s from"../../context/useClickToPayContext.js";import i from"./CtPLoginInput.js";import{CtPInfo as a}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import m from"../../services/sdks/SrciError.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import c from"../../errors/TimeoutError.js";import{isSrciError as u}from"../../services/utils.js";const d=()=>{const{i18n:d}=p(),{isCtpPrimaryPaymentMethod:f,setIsCtpPrimaryPaymentMethod:g,verifyIfShopperIsEnrolled:C,startIdentityValidation:
|
|
1
|
+
import{createElement as t,Fragment as o}from"../../../../../external/preact/dist/preact.js";import{useState as r,useCallback as e}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../../Button/Button.js";import s from"../../context/useClickToPayContext.js";import i from"./CtPLoginInput.js";import{CtPInfo as a}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import m from"../../services/sdks/SrciError.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import c from"../../errors/TimeoutError.js";import{isSrciError as u}from"../../services/utils.js";const d=()=>{const{i18n:d}=p(),{isCtpPrimaryPaymentMethod:f,setIsCtpPrimaryPaymentMethod:g,verifyIfShopperIsEnrolled:C,startIdentityValidation:I}=s(),[P,y]=r(null),[h,j]=r(!1),[E,S]=r(null),[k,x]=r(!1),[L,v]=r(null),A=e(t=>{v(t)},[]),T=e(({data:t,isValid:o})=>{y(t.shopperLogin),j(o),t?.shopperLogin?.length>0&&g(!0)},[]),w=e(async()=>{if(S(null),h){x(!0);try{const{isEnrolled:t}=await C({shopperEmail:P});t?await I():(S("NOT_FOUND"),x(!1))}catch(t){t instanceof m&&console.warn(`CtP - Login error: ${t.toString()}`),t instanceof c&&console.warn(t.toString()),u(t)?S("INVALID_PARAMETER"===t.reason?"INVALID_EMAIL":t.reason):console.error(t),x(!1)}}else L.validateInput()},[C,I,P,h,L]),M=e(t=>{"Enter"===t.key&&w()},[w]);return t(o,null,t(l.Title,{endAdornment:t(a,null)},d.get("ctp.login.title")),t(l.Text,null,d.get("ctp.login.subtitle")),t(i,{onChange:T,onSetInputHandlers:A,disabled:k,errorMessage:E&&d.get(`ctp.errors.${E}`),onPressEnter:w}),t(n,{label:d.get("continue"),variant:f?"primary":"secondary",status:k&&"loading",onClick:()=>{w()},onKeyDown:M}))};export{d as default};
|
|
2
2
|
//# sourceMappingURL=CtPLogin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPLogin.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLogin.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPLoginInput, { CtPLoginInputHandlers } from './CtPLoginInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport SrciError from '../../services/sdks/SrciError';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPLogin.scss';\nimport TimeoutError from '../../errors/TimeoutError';\nimport { isSrciError } from '../../services/utils';\n\nconst CtPLogin = (): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod, verifyIfShopperIsEnrolled, startIdentityValidation } = useClickToPayContext();\n const [shopperLogin, setShopperLogin] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);\n const [loginInputHandlers, setLoginInputHandlers] = useState<CtPLoginInputHandlers>(null);\n\n const onSetLoginInputHandlers = useCallback((handlers: CtPLoginInputHandlers) => {\n setLoginInputHandlers(handlers);\n }, []);\n\n const handleOnLoginChange = useCallback(({ data, isValid }) => {\n setShopperLogin(data.shopperLogin);\n setIsValid(isValid);\n\n // As soon as the Shopper interacts with input, the CtP becomes the primary PM\n if (data?.shopperLogin?.length > 0) {\n setIsCtpPrimaryPaymentMethod(true);\n }\n }, []);\n\n const handleOnLoginButtonClick = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n loginInputHandlers.validateInput();\n return;\n }\n\n setIsLoggingIn(true);\n\n try {\n const { isEnrolled } = await verifyIfShopperIsEnrolled({ shopperEmail: shopperLogin });\n if (isEnrolled) {\n await startIdentityValidation();\n } else {\n setErrorCode('NOT_FOUND');\n setIsLoggingIn(false);\n }\n } catch (error: unknown) {\n if (error instanceof SrciError) console.warn(`CtP - Login error: ${error.toString()}`);\n if (error instanceof TimeoutError) console.warn(error.toString());\n if (isSrciError(error)) setErrorCode(error
|
|
1
|
+
{"version":3,"file":"CtPLogin.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLogin.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPLoginInput, { CtPLoginInputHandlers } from './CtPLoginInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport SrciError from '../../services/sdks/SrciError';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPLogin.scss';\nimport TimeoutError from '../../errors/TimeoutError';\nimport { isSrciError } from '../../services/utils';\n\nconst CtPLogin = (): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod, verifyIfShopperIsEnrolled, startIdentityValidation } = useClickToPayContext();\n const [shopperLogin, setShopperLogin] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);\n const [loginInputHandlers, setLoginInputHandlers] = useState<CtPLoginInputHandlers>(null);\n\n const onSetLoginInputHandlers = useCallback((handlers: CtPLoginInputHandlers) => {\n setLoginInputHandlers(handlers);\n }, []);\n\n const handleOnLoginChange = useCallback(({ data, isValid }) => {\n setShopperLogin(data.shopperLogin);\n setIsValid(isValid);\n\n // As soon as the Shopper interacts with input, the CtP becomes the primary PM\n if (data?.shopperLogin?.length > 0) {\n setIsCtpPrimaryPaymentMethod(true);\n }\n }, []);\n\n const handleOnLoginButtonClick = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n loginInputHandlers.validateInput();\n return;\n }\n\n setIsLoggingIn(true);\n\n try {\n const { isEnrolled } = await verifyIfShopperIsEnrolled({ shopperEmail: shopperLogin });\n if (isEnrolled) {\n await startIdentityValidation();\n } else {\n setErrorCode('NOT_FOUND');\n setIsLoggingIn(false);\n }\n } catch (error: unknown) {\n if (error instanceof SrciError) console.warn(`CtP - Login error: ${error.toString()}`);\n if (error instanceof TimeoutError) console.warn(error.toString());\n if (isSrciError(error)) {\n setErrorCode(error.reason === 'INVALID_PARAMETER' ? 'INVALID_EMAIL' : error.reason);\n } else console.error(error);\n\n setIsLoggingIn(false);\n }\n }, [verifyIfShopperIsEnrolled, startIdentityValidation, shopperLogin, isValid, loginInputHandlers]);\n\n const handleButtonKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n void handleOnLoginButtonClick();\n }\n },\n [handleOnLoginButtonClick]\n );\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.login.title')}</CtPSection.Title>\n\n <CtPSection.Text>{i18n.get('ctp.login.subtitle')}</CtPSection.Text>\n\n <CtPLoginInput\n onChange={handleOnLoginChange}\n onSetInputHandlers={onSetLoginInputHandlers}\n disabled={isLoggingIn}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={handleOnLoginButtonClick}\n />\n\n <Button\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n status={isLoggingIn && 'loading'}\n onClick={() => {\n void handleOnLoginButtonClick();\n }}\n onKeyDown={handleButtonKeyDown}\n />\n </Fragment>\n );\n};\n\nexport default CtPLogin;\n"],"names":["CtPLogin","i18n","useCoreContext","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","verifyIfShopperIsEnrolled","startIdentityValidation","useClickToPayContext","shopperLogin","setShopperLogin","useState","isValid","setIsValid","errorCode","setErrorCode","isLoggingIn","setIsLoggingIn","loginInputHandlers","setLoginInputHandlers","onSetLoginInputHandlers","useCallback","handlers","handleOnLoginChange","data","length","handleOnLoginButtonClick","async","isEnrolled","shopperEmail","error","SrciError","console","warn","toString","TimeoutError","isSrciError","reason","validateInput","handleButtonKeyDown","event","key","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","get","Text","CtPLoginInput","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","Button","label","variant","status","onClick","onKeyDown"],"mappings":"qnBAaA,MAAMA,EAAW,KACb,MAAMC,KAAEA,GAASC,KACXC,0BAAEA,EAAyBC,6BAAEA,EAA4BC,0BAAEA,EAAyBC,wBAAEA,GAA4BC,KACjHC,EAAcC,GAAmBC,EAAiB,OAClDC,EAASC,GAAcF,GAAkB,IACzCG,EAAWC,GAAgBJ,EAAiB,OAC5CK,EAAaC,GAAkBN,GAAkB,IACjDO,EAAoBC,GAAyBR,EAAgC,MAE9ES,EAA0BC,EAAaC,IACzCH,EAAsBG,IACvB,IAEGC,EAAsBF,EAAY,EAAGG,OAAMZ,cAC7CF,EAAgBc,EAAKf,cACrBI,EAAWD,GAGPY,GAAMf,cAAcgB,OAAS,GAC7BpB,GAA6B,IAElC,IAEGqB,EAA2BL,EAAYM,UAGzC,GAFAZ,EAAa,MAERH,EAAL,CAKAK,GAAe,GAEf,IACI,MAAMW,WAAEA,SAAqBtB,EAA0B,CAAEuB,aAAcpB,IACnEmB,QACMrB,KAENQ,EAAa,aACbE,GAAe,GAEvB,CAAE,MAAOa,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,sBAAsBH,EAAMI,cACrEJ,aAAiBK,GAAcH,QAAQC,KAAKH,EAAMI,YAClDE,EAAYN,GACZf,EAA8B,sBAAjBe,EAAMO,OAAiC,gBAAkBP,EAAMO,QACzEL,QAAQF,MAAMA,GAErBb,GAAe,EACnB,CApBA,MAFIC,EAAmBoB,iBAuBxB,CAAChC,EAA2BC,EAAyBE,EAAcG,EAASM,IAEzEqB,EAAsBlB,EACvBmB,IACqB,UAAdA,EAAMC,KACDf,KAGb,CAACA,IAGL,OACIgB,EAACC,EAAAA,KACGD,EAACE,EAAWC,MAAK,CAACC,aAAcJ,EAACK,EAAAA,OAAa7C,EAAK8C,IAAI,oBAEvDN,EAACE,EAAWK,KAAI,KAAE/C,EAAK8C,IAAI,uBAE3BN,EAACQ,EAAAA,CACGC,SAAU5B,EACV6B,mBAAoBhC,EACpBiC,SAAUrC,EACVsC,aAAcxC,GAAaZ,EAAK8C,IAAI,cAAclC,KAClDyC,aAAc7B,IAGlBgB,EAACc,EAAAA,CACGC,MAAOvD,EAAK8C,IAAI,YAChBU,QAAStD,EAA4B,UAAY,YACjDuD,OAAQ3C,GAAe,UACvB4C,QAAS,KACAlC,KAETmC,UAAWtB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as
|
|
1
|
+
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as p}from"../../../../../utils/setFocus.js";import l from"../../../FormFields/Field/Field.js";import u from"../../../FormFields/InputEmail.js";const d=d=>{const{i18n:m}=a(),g=r(null),{handleChangeFor:c,data:h,triggerValidation:f,valid:L,errors:F,isValid:v}=i({schema:["shopperLogin"],rules:n,formHolder:g}),j=r({validateInput:null,focusInput:null}),[I,b]=o(!1),E=s(()=>{b(!0),f()},[f]);t(()=>{g.current&&d.errorMessage&&p(g.current,"shopperLogin")},[d.errorMessage]),t(()=>{h.shopperLogin&&b(!0)},[h.shopperLogin]),t(()=>{j.current.validateInput=E,d.onSetInputHandlers(j.current)},[E,d.onSetInputHandlers]);const M=s(e=>{"Enter"===e.key&&d.onPressEnter()},[d.onPressEnter]);return t(()=>{d.onChange({data:h,valid:L,errors:F,isValid:v})},[h,L,F]),e("div",{ref:g},e(l,{name:"shopperLogin",label:m.get("ctp.login.inputLabel"),errorMessage:I?d.errorMessage||F.shopperLogin&&m.get(F.shopperLogin.errorMessage):null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:h.shopperLogin,disabled:d.disabled,onInput:c("shopperLogin","input"),onBlur:c("shopperLogin","blur"),onKeyPress:M})))};export{d as default};
|
|
2
2
|
//# sourceMappingURL=CtPLoginInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage ||
|
|
1
|
+
{"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || (errors.shopperLogin && i18n.get(errors.shopperLogin.errorMessage)) : null}\n classNameModifiers={['shopperLogin']}\n errorLive={true}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n />\n </Field>\n </div>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","useFormWithA11y","schema","rules","loginValidationRules","formHolder","loginInputHandlersRef","validateInput","focusInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","current","errorMessage","setFocusOnField","shopperLogin","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","div","ref","Field","name","label","get","classNameModifiers","errorLive","InputEmail","autocorrect","spellcheck","value","disabled","onInput","on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zC4C,OAAQ5C,EAAgB,eAAgB,QACxC6C,WAAYrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={shopperLogin:{validate:e=>!!e&&e.length>0,errorMessage:"",modes:["blur"]},default:{validate:e=>!!e&&e.length>0,errorMessage:"",modes:["blur"]}};export{e as loginValidationRules};
|
|
1
|
+
const e={shopperLogin:{validate:e=>!!e&&e.length>0,errorMessage:"ctp.errors.INVALID_EMAIL",modes:["blur"]},default:{validate:e=>!!e&&e.length>0,errorMessage:"",modes:["blur"]}};export{e as loginValidationRules};
|
|
2
2
|
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/validate.ts"],"sourcesContent":["import { ValidatorRules } from '../../../../../utils/Validator/types';\n\nexport const loginValidationRules: ValidatorRules = {\n shopperLogin: {\n validate: value => !!value && value.length > 0,\n errorMessage: '',\n modes: ['blur']\n },\n default: {\n validate: value => !!value && value.length > 0,\n errorMessage: '',\n modes: ['blur']\n }\n};\n"],"names":["loginValidationRules","shopperLogin","validate","value","length","errorMessage","modes","default"],"mappings":"MAEaA,EAAuC,CAChDC,aAAc,CACVC,SAAUC,KAAWA,GAASA,EAAMC,OAAS,EAC7CC,aAAc,
|
|
1
|
+
{"version":3,"file":"validate.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/validate.ts"],"sourcesContent":["import { ValidatorRules } from '../../../../../utils/Validator/types';\n\nexport const loginValidationRules: ValidatorRules = {\n shopperLogin: {\n validate: value => !!value && value.length > 0,\n errorMessage: 'ctp.errors.INVALID_EMAIL',\n modes: ['blur']\n },\n default: {\n validate: value => !!value && value.length > 0,\n errorMessage: '',\n modes: ['blur']\n }\n};\n"],"names":["loginValidationRules","shopperLogin","validate","value","length","errorMessage","modes","default"],"mappings":"MAEaA,EAAuC,CAChDC,aAAc,CACVC,SAAUC,KAAWA,GAASA,EAAMC,OAAS,EAC7CC,aAAc,2BACdC,MAAO,CAAC,SAEZC,QAAS,CACLL,SAAUC,KAAWA,GAASA,EAAMC,OAAS,EAC7CC,aAAc,GACdC,MAAO,CAAC"}
|