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.

72 lines (71 loc) 3.47 kB
try { let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack; n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "048d53fc-dfcd-498d-8d7f-31d687118f16", e._sentryDebugIdIdentifier = "sentry-dbid-048d53fc-dfcd-498d-8d7f-31d687118f16"); } catch (e) {} function getFormProps(props, innerFormId) { if (!innerFormId) return null; const activeFormId = props.activeForm?.formId; const trustedFields = props.trustedFields?.[innerFormId] ?? []; const readOnlyFields = props.readOnlyFields?.[innerFormId] ?? []; return { labels: props.labels?.[innerFormId] ?? {}, masks: props.masks?.[innerFormId] ?? {}, data: props.data?.[innerFormId] ?? {}, allFields: props.allFields?.[innerFormId] ?? [], readOnlyFields: [...readOnlyFields, ...trustedFields], requiredFields: props.requiredFields?.[innerFormId] ?? [], optionalFields: props.optionalFields?.[innerFormId] ?? [], obscuredFields: props.obscuredFields?.[innerFormId] ?? [], verifyFields: props.verifyFields?.[innerFormId] ?? [], trustedFields, trustedFieldsProvider: props.trustedFields, formVerificationErrors: props.problems?.verificationErrors?.[innerFormId] ?? {}, fieldValidationErrors: props.problems?.validationErrors?.[innerFormId] ?? {}, validators: props.validators?.[innerFormId] ? { ...props.validators?.[innerFormId] } : null, shouldValidate: (activeFormId ? activeFormId === innerFormId : true) && props.shouldValidate }; } function getFieldProps(props, innerFormFields) { if (innerFormFields) { const nestedFormProps = { labels: {}, masks: {}, data: {}, allFields: [], requiredFields: [], obscuredFields: [], optionalFields: [], readOnlyFields: [], verifyFields: [], trustedFields: [], fieldValidationErrors: {}, errors: {}, valid: {} }; innerFormFields.forEach((field) => { nestedFormProps.labels[field] = props.labels?.[field]; nestedFormProps.masks[field] = props.masks?.[field]; nestedFormProps.data[field] = props.data?.[field]; if (props.allFields?.includes(field)) nestedFormProps.allFields.push(field); if (props.readOnlyFields?.includes(field)) nestedFormProps.readOnlyFields.push(field); if (props.requiredFields?.includes(field)) nestedFormProps.requiredFields.push(field); if (props.optionalFields?.includes(field)) nestedFormProps.optionalFields.push(field); if (props.verifyFields?.includes(field)) nestedFormProps.verifyFields.push(field); if (props.fieldValidationErrors?.[field]) nestedFormProps.fieldValidationErrors[field] = props.fieldValidationErrors[field]; if (props.obscuredFields?.includes(field)) nestedFormProps.obscuredFields.push(field); if (props.trustedFields?.includes(field)) nestedFormProps.trustedFields.push(field); if (props.validators?.[field]) { if (!nestedFormProps?.validators) nestedFormProps.validators = {}; nestedFormProps.validators[field] = props.validators?.[field]; } if (props.errors?.[field]) nestedFormProps.errors[field] = props.errors?.[field]; if (props.valid?.[field]) nestedFormProps.valid[field] = props.valid?.[field]; }); nestedFormProps.shouldValidate = props.shouldValidate; nestedFormProps.handleFieldChange = props.handleFieldChange; return nestedFormProps; } return null; } //#endregion export { getFormProps as n, getFieldProps as t };