@arturton/react-form-constructor 0.1.3 → 0.1.5

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.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Control, UseFormRegister, FieldErrors } from 'react-hook-form';
2
+ import { FieldValues, UseFormRegister, FieldErrors, Control } from 'react-hook-form';
3
+ import React$1, { ReactNode } from 'react';
3
4
 
4
5
  type FormField<T extends object = any> = {
5
6
  label: string;
@@ -37,22 +38,24 @@ type FormLayoutProps<T extends object = any> = {
37
38
  funSubmit: (data: T) => void;
38
39
  formClass?: string;
39
40
  buttonClass?: string;
40
- } & ({
41
+ buttonName?: string;
41
42
  formData: FormField<T>[];
42
- children?: never;
43
- } | {
44
- formData?: never;
43
+ };
44
+ type FormProviderProps<T extends object = any> = {
45
+ setFormApi?: (formMethods: any) => void;
45
46
  children: React.ReactNode;
46
- });
47
-
48
- declare function FormLayout<T extends object = any>({ formData, funSubmit, formClass, buttonClass, children, }: FormLayoutProps<T>): react_jsx_runtime.JSX.Element;
49
-
50
- interface FormContextValue<T extends object = any> {
51
- control: Control<T>;
47
+ funSubmit: (data: T) => void;
48
+ className?: string;
49
+ };
50
+ type FormContextType<T extends FieldValues = any> = {
52
51
  register: UseFormRegister<T>;
53
52
  errors: FieldErrors<T>;
54
- }
55
- declare function useFormContext<T extends object = any>(): FormContextValue<T>;
53
+ control: Control<T>;
54
+ defaultValues?: T;
55
+ values?: T;
56
+ };
57
+
58
+ declare function FormLayout<T extends object = any>({ formData, funSubmit, formClass, buttonClass, buttonName, }: FormLayoutProps<T>): react_jsx_runtime.JSX.Element;
56
59
 
57
60
  declare function InputForm({ register, type, placeholder, error, name, label, required, control, maska, inputClass, labelClass, errorClass, }: {
58
61
  register: any;
@@ -73,4 +76,150 @@ declare function InputForm({ register, type, placeholder, error, name, label, re
73
76
  errorClass?: any;
74
77
  }): react_jsx_runtime.JSX.Element;
75
78
 
76
- export { type FormContextValue, type FormField, FormLayout, type FormLayoutProps, InputForm, useFormContext };
79
+ declare function FormProvider<T extends object = any>({ setFormApi, children, funSubmit, className, }: FormProviderProps<T>): react_jsx_runtime.JSX.Element;
80
+
81
+ declare function useFormContext<T extends Record<string, any> = any>(): FormContextType<T>;
82
+
83
+ interface FormInputProps {
84
+ name: string;
85
+ minLength?: {
86
+ value: number;
87
+ message: string;
88
+ };
89
+ maxLength?: {
90
+ value: number;
91
+ message: string;
92
+ };
93
+ pattern?: {
94
+ value: RegExp;
95
+ message: string;
96
+ };
97
+ required?: string;
98
+ validate?: (value: any) => boolean | string;
99
+ children: React$1.ReactNode;
100
+ labelClass?: string;
101
+ errorClass?: string;
102
+ className?: string;
103
+ maska?: {
104
+ required: string;
105
+ format: string;
106
+ mask: string;
107
+ };
108
+ }
109
+ declare function FormInputLayout({ name, minLength, maxLength, pattern, required, validate, children, className, maska, }: FormInputProps): react_jsx_runtime.JSX.Element;
110
+
111
+ declare function FormInput({ placeholder, className, classNameError, type, }: {
112
+ placeholder?: string;
113
+ className?: string;
114
+ classNameError?: string;
115
+ type?: string;
116
+ }): react_jsx_runtime.JSX.Element;
117
+
118
+ interface FormPasswordInputProps {
119
+ placeholder?: string;
120
+ className?: string;
121
+ inputClassName?: string;
122
+ classNameError?: string;
123
+ visibleIcon?: ReactNode;
124
+ hiddenIcon?: ReactNode;
125
+ iconClassName?: string;
126
+ iconWrapperClassName?: string;
127
+ }
128
+ declare function FormPasswordInput({ placeholder, className, inputClassName, classNameError, visibleIcon, hiddenIcon, iconClassName, iconWrapperClassName, }: FormPasswordInputProps): react_jsx_runtime.JSX.Element;
129
+
130
+ declare function FormTextarea({ placeholder, className, classNameError, rows, cols, }: {
131
+ placeholder?: string;
132
+ className?: string;
133
+ classNameError?: string;
134
+ rows?: number;
135
+ cols?: number;
136
+ }): react_jsx_runtime.JSX.Element;
137
+
138
+ declare function FormMaskedInput({ placeholder, className, classNameError, }: {
139
+ placeholder?: string;
140
+ className?: string;
141
+ classNameError?: string;
142
+ }): react_jsx_runtime.JSX.Element | null;
143
+
144
+ interface SelectOption {
145
+ value: string | number;
146
+ label: string;
147
+ }
148
+ declare function FormSelect({ options, className, classNameError, multiple, placeholder, }: {
149
+ options: SelectOption[];
150
+ className?: string;
151
+ classNameError?: string;
152
+ multiple?: boolean;
153
+ placeholder?: string;
154
+ }): react_jsx_runtime.JSX.Element;
155
+
156
+ declare function FormNumber({ placeholder, className, classNameError, min, max, step, }: {
157
+ placeholder?: string;
158
+ className?: string;
159
+ classNameError?: string;
160
+ min?: number;
161
+ max?: number;
162
+ step?: number;
163
+ }): react_jsx_runtime.JSX.Element;
164
+
165
+ declare function FormDate({ placeholder, className, classNameError, min, max, type, }: {
166
+ placeholder?: string;
167
+ className?: string;
168
+ classNameError?: string;
169
+ min?: string;
170
+ max?: string;
171
+ type?: "date" | "datetime-local" | "time" | "month" | "week";
172
+ }): react_jsx_runtime.JSX.Element;
173
+
174
+ declare function FormRange({ className, classNameError, min, max, step, range, showValue, containerClassName, }: {
175
+ className?: string;
176
+ classNameError?: string;
177
+ min?: number;
178
+ max?: number;
179
+ step?: number;
180
+ range?: "single" | "double";
181
+ showValue?: boolean;
182
+ containerClassName?: string;
183
+ }): react_jsx_runtime.JSX.Element;
184
+
185
+ declare function FormFileInput({ className, classNameError, accept, multiple, }: {
186
+ className?: string;
187
+ classNameError?: string;
188
+ accept?: string;
189
+ multiple?: boolean;
190
+ }): react_jsx_runtime.JSX.Element;
191
+
192
+ declare function FormCheckbox({ className, classNameError, value, defaultChecked, disabled, }: {
193
+ className?: string;
194
+ classNameError?: string;
195
+ value?: string | number | boolean;
196
+ defaultChecked?: boolean;
197
+ disabled?: boolean;
198
+ }): react_jsx_runtime.JSX.Element;
199
+
200
+ declare function FormRadio({ className, classNameError, value, defaultChecked, disabled, }: {
201
+ className?: string;
202
+ classNameError?: string;
203
+ value: string | number;
204
+ defaultChecked?: boolean;
205
+ disabled?: boolean;
206
+ }): react_jsx_runtime.JSX.Element;
207
+
208
+ declare function FormButton({ children, className, disabledError, ...props }: {
209
+ children?: React.ReactNode;
210
+ className?: string;
211
+ disabledError?: boolean;
212
+ [key: string]: any;
213
+ }): react_jsx_runtime.JSX.Element;
214
+
215
+ declare function FormError({ ...props }: {
216
+ [x: string]: any;
217
+ }): react_jsx_runtime.JSX.Element | null;
218
+
219
+ declare function FormLabel({ children, className, classNameError, }: {
220
+ children: React.ReactNode;
221
+ className?: string;
222
+ classNameError?: string;
223
+ }): react_jsx_runtime.JSX.Element;
224
+
225
+ export { FormButton, FormCheckbox, type FormContextType, FormDate, FormError, type FormField, FormFileInput, FormInput, FormInputLayout, FormLabel, FormLayout, type FormLayoutProps, FormMaskedInput, FormNumber, FormPasswordInput, FormProvider, FormRadio, FormRange, FormSelect, FormTextarea, InputForm, useFormContext };