import { JSX } from '../../stencil-public-runtime'; import { AnyObjectSchema } from 'yup'; import { FormHook } from "./form-hook"; import { LanguageKeys } from "../multi-lingual/index"; export type FormElementStructureComponents = { id?: string; step?: number; type?: string; class?: string; staticValue?: any; isHidden?: boolean; isDisabled?: boolean; children?: (FormElementStructureComponents | T)[]; } & ({ tag?: string; name: T; } | { tag: string; name?: T; }); export type Step = { back?: string; title: string; stepCell?: string; stepTitle?: string; submitButton?: string; }; export type FormElementStructure = { steps?: Record[]; data?: Record; requiredContext?: Record; } & FormElementStructureComponents; export interface FormHookInterface { locale?: any; gistId?: string; el: HTMLElement; isDev?: boolean; today?: string; isLoading: boolean; extraHeader?: object; errorMessage?: string; extraPayload?: object; isMobileForm?: boolean; localeLanguage?: string; language?: LanguageKeys; renderedFields?: string[]; structureRendered?: boolean; getMobileToken?: () => string; structure?: FormElementStructure; formSubmit: (formValues: T) => void; setIsLoading?: (loading: boolean) => void; loadingChanges?: (loading: boolean) => void; setErrorCallback?: (error: any) => void | boolean; setSuccessCallback?: (data: any) => void | boolean; errorCallback?: (error: any, message?: string) => void; successCallback?: (data: any, message?: string) => void; stepChangeCallback?: (step: number, currentForm?: any) => void; } export type ValidationType = 'onSubmit' | 'always'; export interface Field { name: string; meta?: MetaType; isError: boolean; disabled: boolean; isRequired: boolean; errorMessage: string; continuousValidation: boolean; } export type FieldControllers = Record>; export interface FormStateOptions { validationType?: ValidationType; } export type LocaleFormKeys = string; export type Params = { [key: string]: any; formLocaleName: LocaleFormKeys; }; export type FormFieldParams = Record; export interface FormElement { getValue?: () => any; validate?: () => AnyObjectSchema; reset: (newValue?: unknown) => void; partialValidation?: (validation: AnyObjectSchema) => AnyObjectSchema; } export type Subscribers = { name: string; context: FormElement; }[]; export type WatchCallback = (props: { form: FormHook; values: Record; }) => void; export type Watchers = Record; export type FormElementMapperFunctionProps = { form: FormHook; isLoading: boolean; props: any; language: LanguageKeys; locale: T; }; type FormElementMapperFunction = (ElementContext: FormElementMapperFunctionProps) => JSX.Element; export type FormElementMapper = { [K in keyof T]: FormElementMapperFunction; } & { [K in Extra]: FormElementMapperFunction; }; export {};