@form-engine-ts/react 1.0.0 → 1.1.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.
package/dist/index.d.cts CHANGED
@@ -1,14 +1,15 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
- import { FormSchema, TranslationAdapter, FormField, FormValue, ValidationIssue, FormValues, FieldType } from '@form-engine-ts/core';
3
+ import { FormSchema, TranslationAdapter, AsyncTranslationAdapter, FormField, FormValue, ValidationIssue, FormValues, AnswerValidationResult, FieldType } from '@form-engine-ts/core';
4
4
 
5
5
  interface FormBuilderProps {
6
6
  readonly schema: FormSchema;
7
7
  readonly onChange: (newSchema: FormSchema) => void;
8
8
  readonly locale?: string;
9
9
  readonly translator?: TranslationAdapter;
10
+ readonly translationAdapter?: AsyncTranslationAdapter;
10
11
  }
11
- declare function FormBuilder({ schema, onChange, locale, translator }: FormBuilderProps): react.JSX.Element;
12
+ declare function FormBuilder({ schema, onChange, locale, translator, translationAdapter }: FormBuilderProps): react.JSX.Element;
12
13
 
13
14
  type SubmitStatus = "idle" | "submitting" | "success" | "error";
14
15
  interface FormContextValue {
@@ -17,11 +18,14 @@ interface FormContextValue {
17
18
  readonly translator: TranslationAdapter;
18
19
  readonly values: FormValues;
19
20
  readonly visibility: Readonly<Record<string, boolean>>;
21
+ readonly pageVisibility: Readonly<Record<string, boolean>>;
20
22
  readonly errors: Readonly<Record<string, ValidationIssue | undefined>>;
21
23
  readonly submitStatus: SubmitStatus;
22
24
  readonly submitError: Error | null;
23
25
  readonly isSubmitting: boolean;
24
26
  readonly setValue: (fieldId: string, value: FormValue) => void;
27
+ readonly restoreValues: (values: FormValues) => void;
28
+ readonly validatePage: (pageIndex: number) => AnswerValidationResult;
25
29
  readonly reset: () => void;
26
30
  readonly submit: () => Promise<boolean>;
27
31
  readonly translate: (key: string, params?: Readonly<Record<string, string | number>>) => string;
@@ -61,7 +65,8 @@ interface FormRendererProps {
61
65
  readonly className?: string;
62
66
  readonly successMessageKey?: string;
63
67
  readonly errorMessageKey?: string;
68
+ readonly autoSaveKey?: string;
64
69
  }
65
- declare function FormRenderer({ components, className, successMessageKey, errorMessageKey }: FormRendererProps): react.JSX.Element;
70
+ declare function FormRenderer({ components, className, successMessageKey, errorMessageKey, autoSaveKey }: FormRendererProps): react.JSX.Element;
66
71
 
67
72
  export { type FieldComponentProps, type FieldComponents, type FieldState, FormBuilder, type FormBuilderProps, type FormContextValue, FormProvider, type FormProviderProps, FormRenderer, type FormRendererProps, type SubmitStatus, useField, useForm };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
- import { FormSchema, TranslationAdapter, FormField, FormValue, ValidationIssue, FormValues, FieldType } from '@form-engine-ts/core';
3
+ import { FormSchema, TranslationAdapter, AsyncTranslationAdapter, FormField, FormValue, ValidationIssue, FormValues, AnswerValidationResult, FieldType } from '@form-engine-ts/core';
4
4
 
5
5
  interface FormBuilderProps {
6
6
  readonly schema: FormSchema;
7
7
  readonly onChange: (newSchema: FormSchema) => void;
8
8
  readonly locale?: string;
9
9
  readonly translator?: TranslationAdapter;
10
+ readonly translationAdapter?: AsyncTranslationAdapter;
10
11
  }
11
- declare function FormBuilder({ schema, onChange, locale, translator }: FormBuilderProps): react.JSX.Element;
12
+ declare function FormBuilder({ schema, onChange, locale, translator, translationAdapter }: FormBuilderProps): react.JSX.Element;
12
13
 
13
14
  type SubmitStatus = "idle" | "submitting" | "success" | "error";
14
15
  interface FormContextValue {
@@ -17,11 +18,14 @@ interface FormContextValue {
17
18
  readonly translator: TranslationAdapter;
18
19
  readonly values: FormValues;
19
20
  readonly visibility: Readonly<Record<string, boolean>>;
21
+ readonly pageVisibility: Readonly<Record<string, boolean>>;
20
22
  readonly errors: Readonly<Record<string, ValidationIssue | undefined>>;
21
23
  readonly submitStatus: SubmitStatus;
22
24
  readonly submitError: Error | null;
23
25
  readonly isSubmitting: boolean;
24
26
  readonly setValue: (fieldId: string, value: FormValue) => void;
27
+ readonly restoreValues: (values: FormValues) => void;
28
+ readonly validatePage: (pageIndex: number) => AnswerValidationResult;
25
29
  readonly reset: () => void;
26
30
  readonly submit: () => Promise<boolean>;
27
31
  readonly translate: (key: string, params?: Readonly<Record<string, string | number>>) => string;
@@ -61,7 +65,8 @@ interface FormRendererProps {
61
65
  readonly className?: string;
62
66
  readonly successMessageKey?: string;
63
67
  readonly errorMessageKey?: string;
68
+ readonly autoSaveKey?: string;
64
69
  }
65
- declare function FormRenderer({ components, className, successMessageKey, errorMessageKey }: FormRendererProps): react.JSX.Element;
70
+ declare function FormRenderer({ components, className, successMessageKey, errorMessageKey, autoSaveKey }: FormRendererProps): react.JSX.Element;
66
71
 
67
72
  export { type FieldComponentProps, type FieldComponents, type FieldState, FormBuilder, type FormBuilderProps, type FormContextValue, FormProvider, type FormProviderProps, FormRenderer, type FormRendererProps, type SubmitStatus, useField, useForm };