UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

28 lines (27 loc) 2.4 kB
import type { BaseInnerFormProps, FieldData, MaskSettings } from '../hooks/useForm/types'; import type { Namespace, NsTranslationKey, TFunction, Translatable } from '../../types'; import type { FieldMetadata } from './fieldConfigurations'; import type { ValidationRuleResult, ValidationRuleResults } from './validation/types'; export type FormUtils<Schema> = { /** @deprecated use translations functions directly */ getLabel: (field: keyof Schema | string, fallbackLabelKey?: NsTranslationKey<'common'>) => string; 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) => Translatable | 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, Translatable | boolean>; getFieldLabels: (fieldKeys: Array<keyof Schema>, fallbackLabelKeys?: Partial<Record<keyof Schema, NsTranslationKey<'common'>>>) => Partial<Record<keyof Schema, string>>; }; export interface FormUtilsProps<Schema> extends BaseInnerFormProps<Schema> { taskType?: string; } export declare const createFormUtils: <Schema>(props: FormUtilsProps<Schema>, t: TFunction<"common">) => FormUtils<Schema>; export declare const mergeFieldMetadataIntoProps: <Schema, FieldName extends keyof Schema, Ns extends Namespace = "common">(fieldName: FieldName, metadata: FieldMetadata<Schema, FieldName, Ns>, otherProps?: FormUtilsProps<Schema>) => FormUtilsProps<Schema>;