react-form-dto 0.0.7 → 0.0.9

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/README.md CHANGED
@@ -216,9 +216,9 @@ const profileForm: FormDTO = {
216
216
 
217
217
  ## 🌍 Internationalization (I18n)
218
218
 
219
- React Form DTO has built-in support for multi-language forms through `I18nText` and `I18nOption` types.
219
+ React Form DTO has built-in support for multi-language forms through `I18String` and `I18nOption` types.
220
220
 
221
- ### Using I18nText
221
+ ### Using I18String
222
222
 
223
223
  Any text property (`label`, `placeholder`, `title`, `description`, validation messages) can be either a plain string or a locale map:
224
224
 
@@ -11,6 +11,7 @@ export interface FieldRendererProps {
11
11
  /** Callback function to update the field value */
12
12
  onChange: (val: any) => void;
13
13
  error?: string | null;
14
+ locale: string;
14
15
  }
15
16
  /**
16
17
  * Props for the Field component.
@@ -23,6 +23,8 @@ type FormBuilderProps = {
23
23
  dto: FormDTO;
24
24
  /** Optional custom renderers for specific field types */
25
25
  renderers?: Record<string, React.ComponentType<any>>;
26
+ /** Current locale for i18n string resolution (default: 'en') */
27
+ locale?: string;
26
28
  };
27
29
  /**
28
30
  * FormBuilder component that dynamically renders a form based on a FormDTO definition.
@@ -13,6 +13,8 @@ type SectionProps = {
13
13
  /** Optional custom renderers for specific field types */
14
14
  renderers?: Record<string, React.ComponentType<any>>;
15
15
  validateField: (id: string) => string[];
16
+ /** Current locale for i18n string resolution (default: 'en') */
17
+ locale?: string;
16
18
  };
17
19
  /**
18
20
  * Section component that renders a form section with its heading, description, and fields.
@@ -5,6 +5,7 @@ type AutoCompleteFieldProps = {
5
5
  value: any;
6
6
  onChange: (val: any) => void;
7
7
  error?: string | null;
8
+ locale?: string;
8
9
  };
9
10
  export declare const AutoCompleteField: React.FC<AutoCompleteFieldProps>;
10
11
  export {};
@@ -13,4 +13,4 @@ import { FieldRendererProps } from '../../components/Field';
13
13
  * onChange={handleChange}
14
14
  * />
15
15
  */
16
- export declare function CheckBoxInput({ field, value, onChange, error, }: FieldRendererProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function CheckBoxInput({ field, value, onChange, error, locale, }: FieldRendererProps): import("react/jsx-runtime").JSX.Element;
@@ -5,6 +5,7 @@ type MultiAutoCompleteFieldProps = {
5
5
  value: any[];
6
6
  onChange: (val: any) => void;
7
7
  error?: string | null;
8
+ locale?: string;
8
9
  };
9
10
  export declare const MultiAutoCompleteField: React.FC<MultiAutoCompleteFieldProps>;
10
11
  export {};
@@ -5,6 +5,7 @@ type RadioInputProps = {
5
5
  value: any;
6
6
  onChange: (val: any) => void;
7
7
  error?: string | null;
8
+ locale?: string;
8
9
  };
9
10
  export declare const RadioInput: React.FC<RadioInputProps>;
10
11
  export {};
@@ -13,4 +13,4 @@ import { FieldRendererProps } from '../../components/Field';
13
13
  * onChange={handleChange}
14
14
  * />
15
15
  */
16
- export declare function SelectInput({ field, value, onChange, error, }: FieldRendererProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function SelectInput({ field, value, onChange, error, locale, }: FieldRendererProps): import("react/jsx-runtime").JSX.Element;
@@ -13,4 +13,4 @@ import { FieldRendererProps } from '../../components/Field';
13
13
  * onChange={handleChange}
14
14
  * />
15
15
  */
16
- export declare function TextInput({ field, value, onChange, error, }: FieldRendererProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function TextInput({ field, value, onChange, error, locale, }: FieldRendererProps): import("react/jsx-runtime").JSX.Element;
@@ -5,6 +5,7 @@ type TextAreaInputProps = {
5
5
  value: any;
6
6
  onChange: (val: any) => void;
7
7
  error?: string | null;
8
+ locale?: string;
8
9
  };
9
10
  export declare const TextAreaInput: React.FC<TextAreaInputProps>;
10
11
  export {};
@@ -1,2 +1,3 @@
1
1
  import { FormDTO } from '../types';
2
2
  export declare const profileForm: FormDTO;
3
+ export declare const profileFormI18n: FormDTO;
@@ -12,7 +12,7 @@ type Errors = Record<string, string | null>;
12
12
  * form.handleChange('email', 'user@example.com');
13
13
  * const errors = form.validateAll();
14
14
  */
15
- export declare function useFormBuilder(dto: FormDTO): {
15
+ export declare function useFormBuilder(dto: FormDTO, locale?: string): {
16
16
  /** Current form values for all fields */
17
17
  values: Record<string, any>;
18
18
  /** Function to update a field value */