@adyen/adyen-web 5.13.1 → 5.14.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.
Files changed (29) hide show
  1. package/README.md +1 -1
  2. package/dist/adyen.css +6 -6
  3. package/dist/adyen.js +1 -1
  4. package/dist/adyen.js.map +1 -1
  5. package/dist/cjs/adyen.css +6 -6
  6. package/dist/cjs/index.js +1 -1
  7. package/dist/es/adyen.css +6 -6
  8. package/dist/es/index.js +1 -1
  9. package/dist/es.modern/adyen.css +6 -6
  10. package/dist/es.modern/index.js +1 -1
  11. package/dist/types/components/Atome/config.d.ts +2 -2
  12. package/dist/types/components/BankTransfer/types.d.ts +3 -0
  13. package/dist/types/components/Card/components/CardInput/components/CardFieldsWrapper.d.ts +2 -1
  14. package/dist/types/components/Card/components/CardInput/defaultProps.d.ts +2 -0
  15. package/dist/types/components/Card/components/CardInput/types.d.ts +7 -1
  16. package/dist/types/components/Card/components/CardInput/utils.d.ts +9 -1
  17. package/dist/types/components/internal/Address/Specifications.d.ts +9 -0
  18. package/dist/types/components/internal/Address/constants.d.ts +9 -0
  19. package/dist/types/components/internal/Address/types.d.ts +2 -1
  20. package/dist/types/components/internal/IFrame/Iframe.d.ts +1 -3
  21. package/dist/types/components/internal/PhoneInput/types.d.ts +4 -0
  22. package/dist/types/components/internal/SecuredFields/lib/utilities/commonUtils.d.ts +6 -6
  23. package/dist/types/utils/Validator/ValidationRuleResult.d.ts +17 -0
  24. package/dist/types/utils/Validator/Validator.d.ts +5 -18
  25. package/dist/types/utils/Validator/types.d.ts +4 -0
  26. package/dist/types/utils/useForm/reducer.d.ts +4 -2
  27. package/dist/types/utils/useForm/types.d.ts +18 -8
  28. package/dist/types/utils/useForm/useForm.d.ts +2 -18
  29. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
- export declare const ALLOWED_COUNTRIES: string[];
1
+ export declare const ATOME_SUPPORTED_COUNTRIES: string[];
2
2
  /**
3
- * Creates Address Specification for each country that Atome supports.
3
+ * Creates Address Specification according to the Atome UI. This specification overrides all available specifications
4
4
  *
5
5
  * This custom specification is needed in order to create the desired layout of the Atome billing address part. The usage of the
6
6
  * 'default' layout specification from the Address component does not align correctly the available fields, therefore we need to
@@ -13,3 +13,6 @@ export interface BankTransferState extends UIElementProps {
13
13
  };
14
14
  isValid: boolean;
15
15
  }
16
+ export interface BankTransferSchema {
17
+ shopperEmail?: string;
18
+ }
@@ -1,5 +1,5 @@
1
1
  import { h } from 'preact';
2
- export declare const CardFieldsWrapper: ({ data, valid, errors, handleChangeFor, sfpState, setFocusOn, collateErrors, errorFieldId, cvcPolicy, focusedElement, hasInstallments, handleInstallments, showAmountsInInstallments, brandsIcons, mergedSRErrors, moveFocus, showPanel, handleErrorPanelFocus, formData, formErrors, formValid, expiryDatePolicy, dualBrandSelectElements, extensions, selectedBrandValue, showKCP, showBrazilianSSN, socialSecurityNumber, handleOnStoreDetails, billingAddress, handleAddress, billingAddressRef, amount, billingAddressRequired, billingAddressRequiredFields, billingAddressAllowedCountries, brandsConfiguration, enableStoreDetails, hasCVC, hasHolderName, holderNameRequired, installmentOptions, placeholders, positionHolderNameOnTop, showBrandIcon, showBrandsUnderCardNumber }: {
2
+ export declare const CardFieldsWrapper: ({ data, valid, errors, handleChangeFor, sfpState, setFocusOn, collateErrors, errorFieldId, cvcPolicy, focusedElement, hasInstallments, handleInstallments, showAmountsInInstallments, brandsIcons, mergedSRErrors, moveFocus, showPanel, handleErrorPanelFocus, formData, formErrors, formValid, expiryDatePolicy, dualBrandSelectElements, extensions, selectedBrandValue, showKCP, showBrazilianSSN, socialSecurityNumber, handleOnStoreDetails, billingAddress, handleAddress, billingAddressRef, partialAddressSchema, amount, billingAddressRequired, billingAddressRequiredFields, billingAddressAllowedCountries, brandsConfiguration, enableStoreDetails, hasCVC, hasHolderName, holderNameRequired, installmentOptions, placeholders, positionHolderNameOnTop, showBrandIcon, showBrandsUnderCardNumber }: {
3
3
  data: any;
4
4
  valid: any;
5
5
  errors: any;
@@ -32,6 +32,7 @@ export declare const CardFieldsWrapper: ({ data, valid, errors, handleChangeFor,
32
32
  billingAddress: any;
33
33
  handleAddress: any;
34
34
  billingAddressRef: any;
35
+ partialAddressSchema: any;
35
36
  amount: any;
36
37
  billingAddressRequired: any;
37
38
  billingAddressRequiredFields: any;
@@ -1,4 +1,5 @@
1
1
  import { SocialSecurityMode } from '../../types';
2
+ import { AddressModeOptions } from './types';
2
3
  declare const _default: {
3
4
  type: string;
4
5
  setComponentRef: () => void;
@@ -10,6 +11,7 @@ declare const _default: {
10
11
  showBrandsUnderCardNumber: boolean;
11
12
  positionHolderNameOnTop: boolean;
12
13
  billingAddressRequired: boolean;
14
+ billingAddressMode: AddressModeOptions;
13
15
  billingAddressRequiredFields: string[];
14
16
  installmentOptions: {};
15
17
  configuration: {
@@ -4,7 +4,7 @@ import { PaymentAmount } from '../../../../types';
4
4
  import { InstallmentOptions } from './components/types';
5
5
  import { ValidationResult } from '../../../internal/PersonalDetails/types';
6
6
  import { CVCPolicyType, DatePolicyType } from '../../../internal/SecuredFields/lib/types';
7
- import { ValidationRuleResult } from '../../../../utils/Validator/Validator';
7
+ import { ValidationRuleResult } from '../../../../utils/Validator/ValidationRuleResult';
8
8
  import Specifications from '../../../internal/Address/Specifications';
9
9
  import { AddressSchema, StringObject } from '../../../internal/Address/types';
10
10
  import { CbObjOnError, StylesObject } from '../../../internal/SecuredFields/lib/types';
@@ -49,6 +49,7 @@ export interface CardInputProps {
49
49
  billingAddressAllowedCountries?: string[];
50
50
  billingAddressRequired?: boolean;
51
51
  billingAddressRequiredFields?: string[];
52
+ billingAddressMode?: AddressModeOptions;
52
53
  brand?: string;
53
54
  brands?: string[];
54
55
  brandsConfiguration?: CardBrandsConfiguration;
@@ -163,4 +164,9 @@ export interface SortErrorsObj {
163
164
  i18n: Language;
164
165
  countrySpecificLabels: StringObject;
165
166
  }
167
+ export declare enum AddressModeOptions {
168
+ full = "full",
169
+ partial = "partial",
170
+ none = "none"
171
+ }
166
172
  export {};
@@ -1,5 +1,5 @@
1
1
  import { ErrorPanelObj } from '../../../../core/Errors/ErrorPanel';
2
- import { CardInputProps, LayoutObj, SortErrorsObj } from './types';
2
+ import { AddressModeOptions, CardInputProps, LayoutObj, SortErrorsObj } from './types';
3
3
  import { InstallmentsObj } from './components/Installments/Installments';
4
4
  import { SFPProps } from '../../../internal/SecuredFields/SFP/types';
5
5
  export declare const getCardImageUrl: (brand: string, loadingContext: string) => string;
@@ -32,3 +32,11 @@ export declare const extractPropsForCardFields: (props: CardInputProps) => {
32
32
  expiryYear: string;
33
33
  };
34
34
  export declare const extractPropsForSFP: (props: CardInputProps) => SFPProps;
35
+ export declare const handlePartialAddressMode: (addressMode: AddressModeOptions) => any[] | {
36
+ default: {
37
+ labels: {
38
+ postalCode: string;
39
+ };
40
+ schema: "postalCode"[];
41
+ };
42
+ };
@@ -1,4 +1,5 @@
1
1
  import { AddressSchema, StringObject } from './types';
2
+ import { AddressField } from 'src/types';
2
3
  declare class Specifications {
3
4
  private specifications;
4
5
  constructor(specifications?: any);
@@ -45,5 +46,13 @@ declare class Specifications {
45
46
  * @param country - The selected country
46
47
  */
47
48
  getPlaceholderKeyForField(fieldName: string, country: string): string;
49
+ /**
50
+ * Returns an array with the address schema of the selected country or the default address schema
51
+ * Flat version of getAddressSchemaForCountry
52
+ * @param country - The selected country
53
+ * @param mode - Address schema mode, can be 'full', 'partial' or 'none'
54
+ * @returns Array
55
+ */
56
+ getAddressSchemaForCountryFlat(country: string): AddressField[];
48
57
  }
49
58
  export default Specifications;
@@ -3,3 +3,12 @@ export declare const FALLBACK_VALUE = "N/A";
3
3
  export declare const ADDRESS_SCHEMA: readonly ["street", "houseNumberOrName", "postalCode", "city", "stateOrProvince", "country"];
4
4
  export declare const STREET: "street", HOUSE_NUMBER_OR_NAME: "houseNumberOrName", POSTAL_CODE: "postalCode", CITY: "city", STATE_OR_PROVINCE: "stateOrProvince", COUNTRY: "country";
5
5
  export declare const ADDRESS_SPECIFICATIONS: AddressSpecifications;
6
+ export declare const PARTIAL_ADDRESS_SCHEMA: {
7
+ default: {
8
+ labels: {
9
+ postalCode: string;
10
+ };
11
+ schema: "postalCode"[];
12
+ };
13
+ };
14
+ export declare const COUNTRIES_WITH_CUSTOM_SPECIFICATION: string[];
@@ -1,7 +1,7 @@
1
1
  import { AddressField, AddressData } from '../../../types';
2
2
  import Specifications from './Specifications';
3
3
  import { ValidatorRules } from '../../../utils/Validator/types';
4
- import { ValidationRuleResult } from '../../../utils/Validator/Validator';
4
+ import { ValidationRuleResult } from '../../../utils/Validator/ValidationRuleResult';
5
5
  export declare type StringObject = {
6
6
  [key: string]: string;
7
7
  };
@@ -16,6 +16,7 @@ export interface AddressProps {
16
16
  specifications?: AddressSpecifications;
17
17
  validationRules?: ValidatorRules;
18
18
  visibility?: string;
19
+ overrideSchema?: AddressSpecifications;
19
20
  }
20
21
  export interface AddressStateError {
21
22
  street?: ValidationRuleResult;
@@ -17,7 +17,6 @@ declare class Iframe extends Component<IframeProps> {
17
17
  height: string;
18
18
  minWidth: string;
19
19
  minHeight: string;
20
- border: string;
21
20
  src: any;
22
21
  allow: any;
23
22
  title: string;
@@ -26,14 +25,13 @@ declare class Iframe extends Component<IframeProps> {
26
25
  iframeOnLoad(): void;
27
26
  componentDidMount(): void;
28
27
  componentWillUnmount(): void;
29
- render({ name, src, width, height, minWidth, minHeight, border, allow, title }: {
28
+ render({ name, src, width, height, minWidth, minHeight, allow, title }: {
30
29
  name: any;
31
30
  src: any;
32
31
  width: any;
33
32
  height: any;
34
33
  minWidth: any;
35
34
  minHeight: any;
36
- border: any;
37
35
  allow: any;
38
36
  title: any;
39
37
  }): h.JSX.Element;
@@ -27,3 +27,7 @@ export interface PhoneInputState {
27
27
  };
28
28
  isValid?: boolean;
29
29
  }
30
+ export interface PhoneInputSchema {
31
+ phoneNumber?: string;
32
+ phonePrefix?: string;
33
+ }
@@ -3,11 +3,11 @@
3
3
  *
4
4
  * @returns Number
5
5
  */
6
- declare function generateRandomNumber(): number;
6
+ export declare function generateRandomNumber(): number;
7
7
  /**
8
8
  * Recursively compare 2 objects
9
9
  */
10
- declare function objectsDeepEqual(x: any, y: any): any;
10
+ export declare function objectsDeepEqual(x: any, y: any): any;
11
11
  /**
12
12
  * Returns true if x is:
13
13
  * null, undefined, false, 0, NaN, empty object or array, empty string
@@ -30,15 +30,15 @@ declare function objectsDeepEqual(x: any, y: any): any;
30
30
  * falsy(true) // => false
31
31
  * ```
32
32
  */
33
- declare function falsy(x: any): boolean;
33
+ export declare function falsy(x: any): boolean;
34
34
  /**
35
35
  * Inverse of falsy - returns true if x is NOT null, undefined, false, 0, NaN, empty object or array, empty string
36
36
  * @param x -
37
37
  */
38
- declare function notFalsy(x: any): boolean;
38
+ export declare function notFalsy(x: any): boolean;
39
39
  /**
40
40
  * This function allows us to partially apply any number of variables to functions that take any number of parameters.
41
41
  * @returns \{function(): *\}
42
42
  */
43
- declare function partial(...args: any[]): (...args2: any[]) => any;
44
- export { generateRandomNumber, existy, falsy, isArray, objectsDeepEqual, notFalsy, partial, truthy };
43
+ export declare function partial(...args: any[]): (...args2: any[]) => any;
44
+ export declare const isEmpty: (input: any) => boolean;
@@ -0,0 +1,17 @@
1
+ import { ErrorMessageObject } from './types';
2
+ /**
3
+ * Holds the result of a validation
4
+ */
5
+ export declare class ValidationRuleResult {
6
+ private readonly shouldValidate;
7
+ isValid: boolean;
8
+ errorMessage: string | ErrorMessageObject;
9
+ constructor(rule: any, value: any, mode: any, context: any);
10
+ /**
11
+ * Whether the validation is considered an error.
12
+ * A field is only considered to be an error if the validation rule applies to the current mode i.e. 'blur' or 'input'.
13
+ * Also, if a validation function returns a null value e.g. when the field is empty, then the field will not be considered to be in error
14
+ * unless the whole form is being validated
15
+ */
16
+ hasError(isValidatingForm?: boolean): boolean;
17
+ }
@@ -1,33 +1,20 @@
1
- import { ErrorMessageObject, FieldContext, FieldData, ValidatorRules } from './types';
2
- /**
3
- * Holds the result of a validation
4
- */
5
- export declare class ValidationRuleResult {
6
- private readonly shouldValidate;
7
- isValid: boolean;
8
- errorMessage: string | ErrorMessageObject;
9
- constructor(rule: any, value: any, mode: any, context: any);
10
- /**
11
- * Whether the validation is considered an error.
12
- * A field is only considered to be an error if the validation rule applies to the current mode.
13
- */
14
- hasError(): boolean;
15
- }
1
+ import { ValidatorRules, FieldContext, FieldData } from './types';
2
+ import { ValidationRuleResult } from './ValidationRuleResult';
16
3
  declare class ValidationResult {
17
4
  private validationResults;
18
5
  constructor(results: ValidationRuleResult[]);
19
6
  /** Checks if all validation rules have passed */
20
7
  get isValid(): boolean;
21
8
  /** Checks if any validation rule returned an error */
22
- hasError(): boolean;
9
+ hasError(isValidatingForm?: boolean): boolean;
23
10
  /** Returns the first validation result that returned an error */
24
- getError(): ValidationRuleResult;
11
+ getError(isValidatingForm?: boolean): ValidationRuleResult;
25
12
  /** Returns all validation results that returned an error */
26
13
  getAllErrors(): ValidationRuleResult[];
27
14
  }
28
15
  declare class Validator {
29
16
  rules: ValidatorRules;
30
- constructor(rules?: {});
17
+ constructor(rules: any);
31
18
  setRules(newRules: any): void;
32
19
  /**
33
20
  * Get all validation rules for a field
@@ -1,3 +1,4 @@
1
+ import { ValidationRuleResult } from './ValidationRuleResult';
1
2
  declare type ValidatorMode = 'blur' | 'input';
2
3
  export declare type ErrorMessageObject = {
3
4
  translationKey: string;
@@ -42,4 +43,7 @@ export interface FieldContext {
42
43
  [key: string]: any;
43
44
  };
44
45
  }
46
+ export declare type ValidationRuleResults = {
47
+ [key: string]: ValidationRuleResult;
48
+ };
45
49
  export {};
@@ -1,14 +1,16 @@
1
1
  /**
2
2
  * Processes default data and sets as default in state
3
3
  */
4
- export declare function init({ schema, defaultData, processField }: {
4
+ export declare function init({ schema, defaultData, processField, fieldProblems }: {
5
5
  schema: any;
6
6
  defaultData: any;
7
7
  processField: any;
8
+ fieldProblems: any;
8
9
  }): {
9
10
  schema: any;
10
11
  data: any;
11
12
  valid: any;
12
13
  errors: any;
14
+ fieldProblems: any;
13
15
  };
14
- export declare function getReducer(processField: any): (state: any, { type, key, value, mode, defaultData, schema }: any) => any;
16
+ export declare function getReducer(processField: any): (state: any, { type, key, value, mode, schema, defaultData, formValue, selectedSchema, fieldProblems }: any) => any;
@@ -1,19 +1,29 @@
1
- import { ValidationResult } from '../../components/internal/PersonalDetails/types';
2
1
  import { ValidatorRules } from '../Validator/types';
3
- export declare type FormState<DataState> = {
4
- schema: string[];
5
- data: DataState;
2
+ export declare type FormState<FormSchema> = {
3
+ schema?: string[];
4
+ data: FormSchema;
6
5
  errors: {
7
- [key: string]: ValidationResult;
6
+ [key: string]: any;
8
7
  };
9
8
  valid: {
10
9
  [key: string]: boolean;
11
10
  };
11
+ fieldProblems?: {
12
+ [key: string]: any;
13
+ };
14
+ isValid?: boolean;
12
15
  };
13
16
  export declare type FormProps = {
14
17
  rules?: ValidatorRules;
15
18
  [key: string]: any;
16
19
  };
17
- export declare type DefaultDataState = {
18
- [key: string]: any;
19
- };
20
+ export interface Form<FormSchema> extends FormState<FormSchema> {
21
+ handleChangeFor: (key: string, mode?: string) => (e: any) => void;
22
+ triggerValidation: (schema?: any) => void;
23
+ setSchema: (schema: any) => void;
24
+ setData: (key: string, value: any) => void;
25
+ setValid: (key: string, value: any) => void;
26
+ setErrors: (key: string, value: any) => void;
27
+ mergeForm: (formValue: any) => void;
28
+ setFieldProblems: (fieldProblems: any) => void;
29
+ }
@@ -1,19 +1,3 @@
1
- import { FormProps, DefaultDataState } from './types';
2
- declare function useForm<DataState = DefaultDataState>(props: FormProps): {
3
- handleChangeFor: (key: any, mode?: string) => (e: any) => void;
4
- triggerValidation: () => void;
5
- setSchema: (schema: any) => void;
6
- setData: (key: any, value: any) => void;
7
- setValid: (key: any, value: any) => void;
8
- setErrors: (key: any, value: any) => void;
9
- isValid: boolean;
10
- schema: string[];
11
- valid: {
12
- [key: string]: boolean;
13
- };
14
- errors: {
15
- [key: string]: import("../../components/internal/PersonalDetails/types").ValidationResult;
16
- };
17
- data: DataState;
18
- };
1
+ import { Form, FormProps } from './types';
2
+ declare function useForm<FormSchema>(props: FormProps): Form<FormSchema>;
19
3
  export default useForm;
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "./dist/adyen.css": "./dist/adyen.css",
24
24
  "./package.json": "./package.json"
25
25
  },
26
- "version": "5.13.1",
26
+ "version": "5.14.0",
27
27
  "license": "MIT",
28
28
  "homepage": "https://docs.adyen.com/checkout",
29
29
  "repository": "github:Adyen/adyen-web",
@@ -51,12 +51,12 @@
51
51
  "@babel/cli": "^7.17.6",
52
52
  "@babel/core": "^7.16.0",
53
53
  "@babel/plugin-transform-runtime": "^7.17.0",
54
- "@babel/preset-env": "^7.16.0",
54
+ "@babel/preset-env": "^7.16.11",
55
55
  "@babel/preset-react": "^7.14.5",
56
56
  "@babel/preset-typescript": "^7.15.0",
57
57
  "@babel/runtime-corejs3": "^7.16.3",
58
58
  "@rollup/plugin-babel": "^5.3.0",
59
- "@rollup/plugin-commonjs": "^21.0.1",
59
+ "@rollup/plugin-commonjs": "^21.0.3",
60
60
  "@rollup/plugin-eslint": "^8.0.1",
61
61
  "@rollup/plugin-json": "^4.1.0",
62
62
  "@rollup/plugin-node-resolve": "^13.1.3",