@adyen/kyc-components
Version:
`adyen-kyc-components` provides the required pieces to build an onboarding flow based on a legal entity. To onboard and verify users, you need to create a user interface (UI) to collect user data. To speed up building your integration, Adyen offers onboar
34 lines (33 loc) • 3.11 kB
TypeScript
import type { BaseInnerFormProps, FieldData, MaskSettings } from '../core/hooks/useForm/types';
import type { FieldMetadata } from '../core/models/country-config';
import type { Language } from '../language/Language';
import type { TranslationKey } from '../language/types';
import type { ValidationRuleResult, ValidationRuleResults } from './validation/types';
export type FormUtils<Schema> = {
getLabel: (field: keyof Schema | string, fallbackLabelKey?: TranslationKey) => string;
getPlaceholder: (field: keyof Schema, fallbackPlaceholderKey?: TranslationKey) => string;
getHelperText: (field: keyof Schema, fallbackHelperTextKey?: TranslationKey) => string;
getGuidanceText: (field: keyof Schema, fallbackHelperTextKey?: TranslationKey) => string | undefined;
getMask: (field: keyof Schema) => MaskSettings | undefined;
isObscured: (field: keyof Schema) => boolean;
isRequiredField: (field: keyof Schema, showIfNotInRequiredFields?: boolean) => boolean;
isOptionalField: (field: keyof Schema) => boolean;
isVisibleField: (field: keyof Schema, showIfNotInRequiredFields?: boolean) => boolean;
isReadOnly: (field: keyof Schema) => boolean;
isTrusted: (field: keyof Schema) => boolean;
getErrorMessage: (field: keyof Schema, errors: ValidationRuleResults<Schema> | null | undefined, fieldProblems: Partial<Record<keyof Schema, boolean>> | undefined) => string | boolean;
getFieldData: <Fields extends Array<keyof Schema>, FieldSchema extends {
[field in keyof Schema]: Schema[field];
}>(formData: Schema, fieldKeys: Fields) => FieldData<FieldSchema>;
getFieldValid: (formValid: Partial<Record<keyof Schema, boolean>>, fieldKeys: Array<keyof Schema>) => Record<keyof Schema, boolean>;
getFieldErrors: (formErrors: Partial<Record<keyof Schema, ValidationRuleResult | null>>, fieldProblems: Partial<Record<keyof Schema, boolean>> | undefined, fieldKeys: Array<keyof Schema>) => Record<keyof Schema, string | boolean>;
getFieldLabels: (fieldKeys: Array<keyof Schema>, fallbackLabelKeys?: Partial<Record<keyof Schema, TranslationKey>>) => Partial<Record<keyof Schema, string>>;
getFieldPlaceholders: (fieldKeys: Array<keyof Schema>, fallbackPlaceholderKeys?: Partial<Record<keyof Schema, TranslationKey>>) => Partial<Record<keyof Schema, string>>;
getFieldHelperText: (fieldKeys: Array<keyof Schema>, fallbackHelperTextKeys?: Partial<Record<keyof Schema, TranslationKey>>) => Partial<Record<keyof Schema, string>>;
getFieldGuidanceText: (fieldKeys: Array<keyof Schema>, fallbackGuidanceTextKeys?: Partial<Record<keyof Schema, TranslationKey>>) => Partial<Record<keyof Schema, string>>;
};
export interface FormUtilsProps<Schema> extends BaseInnerFormProps<Schema> {
taskType?: string;
}
export declare const createFormUtils: <Schema>(props: FormUtilsProps<Schema>, i18n: Language) => FormUtils<Schema>;
export declare const mergeFieldMetadataIntoProps: <Schema, FieldName extends keyof Schema>(fieldName: FieldName, metadata: FieldMetadata<Schema, FieldName>, otherProps?: FormUtilsProps<Schema>) => FormUtilsProps<Schema>;