autoforma 1.0.55 → 1.0.56

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.
Files changed (51) hide show
  1. package/README.md +286 -157
  2. package/dist/components/AutoForm/AutoForm.d.ts +17 -0
  3. package/dist/components/AutoForm/AutoForm.types.d.ts +35 -0
  4. package/dist/components/AutoForm/index.d.ts +0 -0
  5. package/dist/fields/FieldRenderer/DefaultFieldRender.d.ts +10 -0
  6. package/dist/fields/FieldRenderer/FieldLayoutWrapper.d.ts +9 -0
  7. package/dist/fields/FieldRenderer/FieldRenderer.d.ts +3 -0
  8. package/dist/fields/FieldRenderer/FieldRenderer.types.d.ts +7 -0
  9. package/dist/fields/context/RenderersContext.d.ts +7 -0
  10. package/dist/fields/handlers/BuiltInHandler.d.ts +9 -0
  11. package/dist/fields/handlers/CustomTypeRendererResolver.d.ts +10 -0
  12. package/dist/fields/handlers/FieldNameHandler.d.ts +10 -0
  13. package/dist/fields/handlers/FieldTypeHandler.d.ts +10 -0
  14. package/dist/fields/handlers/RendererHandler.d.ts +10 -0
  15. package/dist/fields/renderer.types.d.ts +12 -0
  16. package/dist/fields/renderers/ArrayFieldRenderer.d.ts +4 -0
  17. package/dist/fields/renderers/CheckBoxFieldRenderer.d.ts +4 -0
  18. package/dist/fields/renderers/DateFieldRenderer.d.ts +4 -0
  19. package/dist/fields/renderers/DateTimeFieldRenderer.d.ts +4 -0
  20. package/dist/fields/renderers/NumberFieldRenderer.d.ts +4 -0
  21. package/dist/fields/renderers/ObjectFieldRenderer.d.ts +4 -0
  22. package/dist/fields/renderers/RichTextEditorFieldRenderer.d.ts +4 -0
  23. package/dist/fields/renderers/SelectFieldRenderer.d.ts +4 -0
  24. package/dist/fields/renderers/SwitchFieldRenderer.d.ts +4 -0
  25. package/dist/fields/renderers/TagsFieldRenderer.d.ts +4 -0
  26. package/dist/fields/renderers/TextFieldRenderer.d.ts +4 -0
  27. package/dist/fields/renderers/TimeFieldRenderer.d.ts +4 -0
  28. package/dist/fields/resolver/FieldRendererResolver.d.ts +3 -0
  29. package/dist/fields/types.d.ts +60 -0
  30. package/dist/fields/utils/layout.utils.d.ts +5 -0
  31. package/dist/fields/utils/values.utils.d.ts +4 -0
  32. package/dist/index.cjs.js +143 -62
  33. package/dist/index.d.ts +6 -2
  34. package/dist/index.es.js +22192 -13217
  35. package/dist/theme.d.ts +6 -6
  36. package/package.json +46 -13
  37. package/dist/components/AutoForm.d.ts +0 -18
  38. package/dist/components/FieldRender.d.ts +0 -16
  39. package/dist/components/fields/ArrayField.d.ts +0 -13
  40. package/dist/components/fields/CheckField.d.ts +0 -7
  41. package/dist/components/fields/DateField.d.ts +0 -6
  42. package/dist/components/fields/DateTimeField.d.ts +0 -6
  43. package/dist/components/fields/NumberField.d.ts +0 -6
  44. package/dist/components/fields/ObjectField.d.ts +0 -9
  45. package/dist/components/fields/SelectField.d.ts +0 -10
  46. package/dist/components/fields/TextAreaField.d.ts +0 -6
  47. package/dist/components/fields/TextField.d.ts +0 -6
  48. package/dist/components/fields/TimeField.d.ts +0 -6
  49. package/dist/types/custom-render.d.ts +0 -11
  50. package/dist/types/field.d.ts +0 -30
  51. package/dist/types/form.d.ts +0 -7
package/README.md CHANGED
@@ -1,157 +1,286 @@
1
-
2
- # AutoForm
3
-
4
- AutoForm is a dynamic form builder component for React applications, using **Mantine**. It generates forms dynamically based on a schema definition. This allows for faster form creation and less repetitive code when working with forms in your React applications.
5
-
6
- ## Features
7
-
8
- - **Dynamic Form Rendering**: AutoForm renders fields based on the provided schema, making form generation easy.
9
- - **Field Types Support**: Supports various input types like `text`, `number`, `password`, `select`, `checkbox`, etc.
10
- - **Validation Support**: Integrates with form validation mechanisms.
11
- - **Custom Layout**: Supports custom layout rendering via the `container` and `fieldContainer` props.
12
- - **Read-Only Mode**: Option to set the form in read-only mode.
13
- - **Field Customization**: Easily customize field rendering for different input types.
14
- - **Conditional Rendering**: Hide fields or conditionally render based on certain conditions.
15
-
16
- ## Installation
17
-
18
- To install `AutoForm`, you can use npm or yarn:
19
-
20
- ```bash
21
- npm install @mantine/core react
22
- ```
23
-
24
- ## Usage
25
-
26
- ### Example Usage
27
-
28
- ```tsx
29
- import React from 'react';
30
- import AutoForm from './AutoForm'; // Path to your AutoForm component
31
- import { Button, Grid, Group } from '@mantine/core';
32
-
33
- const schema = [
34
- { name: 'firstName', label: 'First Name', type: 'text' },
35
- { name: 'age', label: 'Age', type: 'number' },
36
- { name: 'subscribe', label: 'Subscribe?', type: 'checkbox' },
37
- { name: 'role', label: 'Role', type: 'select', options: ['User', 'Admin'] },
38
- ];
39
-
40
- const MyForm = () => {
41
- const onSubmit = (values) => {
42
- alert(JSON.stringify(values, null, 2));
43
- };
44
-
45
- return (
46
- <AutoForm
47
- schema={schema}
48
- onSubmit={onSubmit}
49
- container={(form, onSubmit, readOnly) => (
50
- <>
51
- <Grid>{form}</Grid>
52
- {!readOnly && (
53
- <Group justify="flex-end">
54
- <Button onClick={onSubmit}>Submit</Button>
55
- </Group>
56
- )}
57
- </>
58
- )}
59
- />
60
- );
61
- };
62
- ```
63
-
64
- ### Props
65
-
66
- | Prop | Type | Description |
67
- |------------------|--------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
68
- | `schema` | `FieldSchema[]` | List of field definitions to render. Each field specifies `name`, `type`, etc. |
69
- | `values` | `Record<string, any>` | Initial values for the form fields. Optional. |
70
- | `onSubmit` | `(values: Record<string, any>) => void` | Callback triggered on form submission with current form values. |
71
- | `container` | `(form: ReactNode, onSubmit: () => void, readOnly?: true) => ReactNode` | Custom render wrapper around the form and submit button. |
72
- | `fieldContainer` | `(field: ReactNode, fieldSchema: FieldSchema) => ReactNode` | Optional. Custom layout for each field (e.g., grid wrappers). |
73
- | `customRender` | `FieldRenderCustomRender` | Optional. Override how specific field types are rendered. |
74
- | `validate` | `FormValidateInput<Record<string, any>>` | Optional validation logic. Uses Mantine-compatible validation. |
75
- | `readOnly` | `true` | Optional. When true, disables all inputs (read-only mode). |
76
- | `onFieldChange` | `(name: string, value: any, values: Record<string, any>) => Record<string, any>` | Optional. Modify or transform values when a field changes. |
77
-
78
- ### Custom Layout
79
-
80
- You can customize the layout of the entire form or specific fields by using the `container` and `fieldContainer` props.
81
-
82
- #### Example: Customizing the Form Layout
83
-
84
- ```tsx
85
- const customLayout = (form, onSubmit, readOnly) => (
86
- <>
87
- <div className="form-container">{form}</div>
88
- {!readOnly && <button onClick={onSubmit}>Submit</button>}
89
- </>
90
- );
91
- ```
92
-
93
- #### Example: Customizing Field Layout
94
-
95
- ```tsx
96
- const customFieldLayout = (field, fieldSchema) => (
97
- <div className="custom-field">{field}</div>
98
- );
99
- ```
100
-
101
- ### Validation
102
-
103
- AutoForm supports validation through the `validate` prop. You can pass a validation function that returns an object of validation errors.
104
-
105
- Example:
106
-
107
- ```tsx
108
- const validateForm = (values) => {
109
- const errors = {};
110
- if (!values.firstName) errors.firstName = 'First name is required';
111
- if (!values.age) errors.age = 'Age is required';
112
- return errors;
113
- };
114
-
115
- <AutoForm
116
- schema={schema}
117
- validate={validateForm}
118
- onSubmit={(values) => console.log(values)}
119
- container={(form, onSubmit) => (
120
- <>
121
- <Grid>{form}</Grid>
122
- <Button onClick={onSubmit}>Submit</Button>
123
- </>
124
- )}
125
- />
126
- ```
127
-
128
- ### Hide Fields
129
-
130
- To hide a field from rendering, you can set the `hidden` property in the schema.
131
-
132
- Example:
133
-
134
- ```tsx
135
- const schema = [
136
- { name: 'firstName', label: 'First Name', type: 'text' },
137
- { name: 'internalCode', label: 'Internal Code', type: 'text', hidden: true },
138
- ];
139
- ```
140
-
141
- This will ensure the "Internal Code" field is not rendered.
142
-
143
- ---
144
-
145
- ## Contributing
146
-
147
- 1. Fork the repository
148
- 2. Create a new branch (`git checkout -b feature-branch`)
149
- 3. Commit your changes (`git commit -am 'Add feature'`)
150
- 4. Push to the branch (`git push origin feature-branch`)
151
- 5. Create a new Pull Request
152
-
153
- ---
154
-
155
- ## License
156
-
157
- Distributed under the MIT License. See `LICENSE` for more information.
1
+ # 🚀 AutoForma
2
+
3
+ **AutoForma** is a powerful and flexible **dynamic form builder** for React. It allows developers to build complex forms from simple schema definitions without writing repetitive boilerplate code. With AutoForma, you can focus on the logic and behavior of your forms — not the UI details.
4
+
5
+ ---
6
+
7
+ ## ✨ Features
8
+
9
+ - **Fast form building:** Generate forms instantly from JSON schema.
10
+ - 🧩 **Rich field types:** Text, Select, Checkbox, Date, Time, Switch, Tags, Array, Object, and more.
11
+ - 🎨 **Full UI control:** Customize how each field looks and behaves.
12
+ - 🔄 **Dynamic behavior:** Show/hide fields, enable/disable them, or update their properties based on form values.
13
+ - 🪄 **Custom renderers:** Replace any field’s renderer with your own component.
14
+ - 🧠 **Validation support:** Built-in and custom validation supported out of the box.
15
+ - 📐 **Multiple layouts:** Vertical, horizontal, or grid layouts.
16
+ - 🧪 **Extendable:** Easily integrate with any backend and add your own field types.
17
+
18
+ ---
19
+
20
+ ## 📦 Installation
21
+
22
+ Install AutoForma **and the exact peer dependencies** required for it to work properly:
23
+
24
+ ```bash
25
+ npm install autoforma @mantine/core@^7.17.5 @mantine/hooks@^7.17.5 @mantine/form@^7.17.5 @mantine/dates@^7.17.5 @mantine/tiptap@^7.17.5 @tiptap/react@^3.6.6 react@^18.0.0 react-dom@^18.0.0
26
+ ```
27
+
28
+ ---
29
+
30
+ ## ⚙️ Requirements
31
+
32
+ Before using `AutoForma`, make sure to wrap your application with `MantineProvider` and import Mantine's base styles:
33
+
34
+ ```tsx
35
+ import { MantineProvider } from "@mantine/core";
36
+ import "@mantine/core/styles.css";
37
+ import "@mantine/dates/styles.css";
38
+ import "@mantine/tiptap/styles.css";
39
+
40
+ const Root = () => (
41
+ <MantineProvider>
42
+ <App />
43
+ </MantineProvider>
44
+ );
45
+ ```
46
+
47
+ > ✅ Without `MantineProvider`, the components might not render or style correctly.
48
+
49
+ ---
50
+
51
+ ## 🛠️ Usage
52
+
53
+ Here's a complete example showing how to use **AutoForma** with a custom field type (`newText`):
54
+
55
+ ```tsx
56
+ import { MantineProvider } from "@mantine/core";
57
+ import "@mantine/core/styles.css";
58
+ import "@mantine/dates/styles.css";
59
+ import "@mantine/tiptap/styles.css";
60
+ import ReactDOM from "react-dom/client";
61
+ import AutoForm from "autoforma";
62
+ import { FieldSchema } from "autoforma";
63
+
64
+ interface DemoFormValues {
65
+ fullName: string;
66
+ email: string;
67
+ age: number;
68
+ subscribe: boolean;
69
+ birthDate: string | null;
70
+ appointment: string | null;
71
+ contacts: { type: string; value: string }[];
72
+ gender: string;
73
+ bio: string;
74
+ }
75
+
76
+ const schema: FieldSchema[] = [
77
+ {
78
+ name: "fullName",
79
+ label: "Full Name",
80
+ type: "newText",
81
+ placeholder: "Enter your full name",
82
+ required: true,
83
+ },
84
+ {
85
+ name: "age",
86
+ label: "Age",
87
+ type: "number",
88
+ placeholder: "Enter your age",
89
+ },
90
+ {
91
+ name: "gender",
92
+ label: "Gender",
93
+ type: "select",
94
+ placeholder: "Select your gender",
95
+ data: [
96
+ { label: "Male", value: "M" },
97
+ { label: "Female", value: "F" },
98
+ { label: "Prefer not to say", value: "N" },
99
+ ],
100
+ },
101
+ {
102
+ name: "subscribe",
103
+ label: "Subscribe to newsletter",
104
+ type: "checkbox",
105
+ description: "Receive updates by email",
106
+ },
107
+ {
108
+ name: "birthDate",
109
+ label: "Birth Date",
110
+ type: "date",
111
+ placeholder: "Pick your birth date",
112
+ },
113
+ {
114
+ name: "appointment",
115
+ label: "Appointment",
116
+ type: "datetime",
117
+ placeholder: "Select date and time",
118
+ },
119
+ {
120
+ name: "contacts",
121
+ label: "Contacts",
122
+ type: "array",
123
+ fields: [
124
+ {
125
+ name: "type",
126
+ label: "Contact Type",
127
+ type: "select",
128
+ data: [
129
+ { label: "Email", value: "email" },
130
+ { label: "Phone", value: "phone" },
131
+ ],
132
+ },
133
+ {
134
+ name: "value",
135
+ label: "Contact Value",
136
+ type: "text",
137
+ },
138
+ ],
139
+ },
140
+ {
141
+ name: "bio",
142
+ label: "Bio",
143
+ type: "text",
144
+ placeholder: "Tell us about yourself",
145
+ },
146
+ ];
147
+
148
+ const App = () => {
149
+ return (
150
+ <AutoForm<DemoFormValues>
151
+ layout="grid"
152
+ schema={schema}
153
+ customFieldTypes={{
154
+ newText: (field, form) => (
155
+ <div>
156
+ <label htmlFor={field.name}>{field.label}</label>
157
+ <input {...form.getInputProps(field.name)} />
158
+ </div>
159
+ ),
160
+ }}
161
+ onSubmit={(values) => alert(JSON.stringify(values))}
162
+ />
163
+ );
164
+ };
165
+
166
+ ReactDOM.createRoot(document.getElementById("root")!).render(
167
+ <MantineProvider>
168
+ <App />
169
+ </MantineProvider>
170
+ );
171
+ ```
172
+
173
+ ---
174
+
175
+ ## 🔧 Props / API Reference
176
+
177
+ | Prop | Type | Description |
178
+ | ----------------------- | -------------------------------------------- | --------------------------------------------------------- |
179
+ | `schema` | `FieldSchema[]` | The form schema definition. |
180
+ | `values` | `TValues` | Initial form values. |
181
+ | `onSubmit` | `(values: TValues) => void` | Callback triggered when the form is submitted. |
182
+ | `transformBeforeSubmit` | `(values: TValues) => TValues` | Optional function to transform form values before submit. |
183
+ | `transformAfterSubmit` | `(values: TValues) => void \| Promise<void>` | Optional function called after form submission. |
184
+ | `validate` | `FormValidateInput<TValues>` | Validation configuration. |
185
+ | `readOnly` | `boolean` | Makes the entire form read-only. |
186
+ | `onFieldChange` | `OnFieldChangeMap<TValues>` | Trigger callbacks when specific fields change. |
187
+ | `layout` | `"vertical" \| "horizontal" \| "grid"` | Form layout type. |
188
+ | `customFieldRenderers` | `CustomRenderersMap<TValues>` | Override default field renderers. |
189
+ | `customFieldTypes` | `CustomFieldTypes<TValues>` | Add new field types dynamically and render them. |
190
+ | `updateFieldSchema` | `UpdateFieldSchemaMap<TValues>` | Dynamically update field definitions based on values. |
191
+ | `submitButton` | `boolean \| ReactNode` | Show or customize the submit button. |
192
+
193
+ ---
194
+
195
+ ## 🧩 Field Types
196
+
197
+ AutoForma supports a variety of field types out-of-the-box:
198
+
199
+ - `text`
200
+ - `number`
201
+ - `select`
202
+ - `checkbox`
203
+ - `date`
204
+ - `datetime`
205
+ - `time`
206
+ - `object`
207
+ - `array`
208
+ - `switch`
209
+ - `texteditor`
210
+ - `tags`
211
+
212
+ ✅ **Plus any custom type** you add through `customFieldTypes`.
213
+
214
+ ---
215
+
216
+ ## ⚙️ Advanced Usage
217
+
218
+ You can control the behavior of fields dynamically based on form values **and** extend the form with new field types:
219
+
220
+ ```tsx
221
+ <AutoForm
222
+ schema={schema}
223
+ updateFieldSchema={{
224
+ gender: (field, values) => {
225
+ if (values.age && values.age < 18) {
226
+ return { ...field, data: [{ label: "Prefer not to say", value: "N" }] };
227
+ }
228
+ return field;
229
+ },
230
+ appointment: (field, values) => ({
231
+ ...field,
232
+ disabled: !values.birthDate,
233
+ }),
234
+ }}
235
+ customFieldTypes={{
236
+ newText: (field, form) => (
237
+ <div>
238
+ <label htmlFor={field.name}>{field.label}</label>
239
+ <input {...form.getInputProps(field.name)} />
240
+ </div>
241
+ ),
242
+ }}
243
+ />
244
+ ```
245
+
246
+ ✅ This gives you full power to:
247
+
248
+ - Dynamically adjust schema behavior.
249
+ - Inject custom field types without touching the library core.
250
+
251
+ ---
252
+
253
+ ## 🧪 Development
254
+
255
+ If you want to contribute or run AutoForma locally:
256
+
257
+ ```bash
258
+ git clone https://github.com/your-username/AutoForma.git
259
+ cd AutoForma
260
+ npm install
261
+ npm run dev
262
+ ```
263
+
264
+ ---
265
+
266
+ ## 🤝 Contributing
267
+
268
+ Contributions are welcome! 🎉
269
+ If you'd like to help improve AutoForma:
270
+
271
+ 1. Fork the repository
272
+ 2. Create a new feature branch
273
+ 3. Commit your changes
274
+ 4. Submit a pull request 🚀
275
+
276
+ ---
277
+
278
+ ## 📜 License
279
+
280
+ This project is licensed under the **MIT License**.
281
+
282
+ ---
283
+
284
+ ## ⭐ Support
285
+
286
+ If you find AutoForma helpful, please consider giving it a ⭐ on [GitHub](https://github.com/your-username/AutoForma) — it helps the project grow!
@@ -0,0 +1,17 @@
1
+ import { AutoFormRef } from './AutoForm.types';
2
+ export declare const AutoForm: import('react').ForwardRefExoticComponent<import('../../fields/renderer.types').CustomRenderersConfig<Record<string, any>> & {
3
+ schema: import('../..').FieldSchema<Record<string, any>>[];
4
+ values?: Partial<Record<string, any>> | undefined;
5
+ getInitialValues?: (() => Partial<Record<string, any>> | Promise<Partial<Record<string, any>>>) | undefined;
6
+ onSubmit: (values: Record<string, any>) => void | Promise<void>;
7
+ transformBeforeSubmit?: ((values: Record<string, any>) => Record<string, any> | Promise<Record<string, any>>) | undefined;
8
+ transformAfterSubmit?: ((values: Record<string, any>) => void | Promise<void>) | undefined;
9
+ validate?: import('@mantine/form').FormValidateInput<Record<string, any>> | undefined;
10
+ readOnly?: boolean;
11
+ onFieldChange?: import('./AutoForm.types').OnFieldChangeMap<Record<string, any>> | undefined;
12
+ layout?: "vertical" | "horizontal" | "grid";
13
+ updateFieldSchema?: import('./AutoForm.types').UpdateFieldSchemaMap<Record<string, any>> | undefined;
14
+ submitButton?: boolean | React.ReactNode;
15
+ loading?: boolean;
16
+ } & import('react').RefAttributes<AutoFormRef<Record<string, any>>>>;
17
+ export default AutoForm;
@@ -0,0 +1,35 @@
1
+ import { CustomRenderersConfig } from '../../fields/renderer.types';
2
+ import { FieldSchema } from '../../fields/types';
3
+ import { FormValidateInput, UseFormReturnType } from '@mantine/form';
4
+ export type AutoFormProps<TValues extends Record<string, any> = Record<string, any>> = CustomRenderersConfig<TValues> & {
5
+ schema: FieldSchema<TValues>[];
6
+ values?: Partial<TValues>;
7
+ getInitialValues?: () => Partial<TValues> | Promise<Partial<TValues>>;
8
+ onSubmit: (values: TValues) => void | Promise<void>;
9
+ transformBeforeSubmit?: (values: TValues) => TValues | Promise<TValues>;
10
+ transformAfterSubmit?: (values: TValues) => void | Promise<void>;
11
+ validate?: FormValidateInput<TValues>;
12
+ readOnly?: boolean;
13
+ onFieldChange?: OnFieldChangeMap<TValues>;
14
+ layout?: "vertical" | "horizontal" | "grid";
15
+ updateFieldSchema?: UpdateFieldSchemaMap<TValues>;
16
+ submitButton?: boolean | React.ReactNode;
17
+ loading?: boolean;
18
+ };
19
+ export type UpdateFieldSchemaMap<TValues extends Record<string, any> = Record<string, any>> = {
20
+ [K in keyof TValues]?: (schema: FieldSchema<TValues>, values: TValues) => FieldSchema<TValues>;
21
+ };
22
+ export type OnFieldChangeMap<TValues extends Record<string, any> = Record<string, any>> = {
23
+ [K in keyof TValues]?: (value: TValues[K], form: UseFormReturnType<TValues>) => void | Promise<void>;
24
+ };
25
+ export interface AutoFormRef<TValues extends Record<string, any> = Record<string, any>> {
26
+ submit: () => void;
27
+ reset: (values?: Partial<TValues>) => void;
28
+ validate: () => boolean;
29
+ getValues: () => TValues;
30
+ setValues: (values: Partial<TValues>) => void;
31
+ getFieldValue: (path: string) => any;
32
+ setFieldValue: (path: string, value: any) => void;
33
+ isValid: () => boolean;
34
+ isDirty: () => boolean;
35
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { UseFormReturnType } from '@mantine/form';
3
+ import { FieldSchema } from '../types';
4
+ type DefaultFieldRenderProps<TValues extends Record<string, any>> = {
5
+ field: FieldSchema<TValues>;
6
+ form: UseFormReturnType<TValues>;
7
+ children: React.ReactNode;
8
+ };
9
+ export declare function DefaultFieldRender<TValues extends Record<string, any>>({ field, form, children, }: DefaultFieldRenderProps<TValues>): import("react/jsx-runtime").JSX.Element;
10
+ export default DefaultFieldRender;
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { FieldSchema } from '../types';
3
+ type FieldLayoutWrapperProps = {
4
+ field: FieldSchema;
5
+ layout: "vertical" | "horizontal" | "grid";
6
+ children: React.ReactNode;
7
+ };
8
+ export declare function FieldLayoutWrapper({ field, layout, children, }: FieldLayoutWrapperProps): import("react/jsx-runtime").JSX.Element;
9
+ export default FieldLayoutWrapper;
@@ -0,0 +1,3 @@
1
+ import { FieldRendererProps } from './FieldRenderer.types';
2
+ export declare function FieldRenderer<TValues extends Record<string, any> = Record<string, any>>(props: FieldRendererProps<TValues>): import("react/jsx-runtime").JSX.Element;
3
+ export default FieldRenderer;
@@ -0,0 +1,7 @@
1
+ import { UseFormReturnType } from '@mantine/form';
2
+ import { FieldSchema } from '../types';
3
+ export interface FieldRendererProps<TValues extends Record<string, any> = Record<string, any>> {
4
+ field: FieldSchema<TValues>;
5
+ form: UseFormReturnType<TValues>;
6
+ layout?: "vertical" | "horizontal" | "grid";
7
+ }
@@ -0,0 +1,7 @@
1
+ import { CustomRenderersConfig } from '../renderer.types';
2
+ export declare const RenderersContext: import('react').Context<CustomRenderersConfig<any> | null>;
3
+ export declare const RenderersProvider: <TValues extends Record<string, any> = Record<string, any>>({ children, value, }: {
4
+ children: React.ReactNode;
5
+ value: CustomRenderersConfig<TValues>;
6
+ }) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const useRenderers: <TValues extends Record<string, any> = Record<string, any>>() => CustomRenderersConfig<TValues>;
@@ -0,0 +1,9 @@
1
+ import { UseFormReturnType } from '@mantine/form';
2
+ import { FieldSchema } from '../types';
3
+ import { RendererHandler } from './RendererHandler';
4
+ export declare class BuiltInHandler<TValues extends Record<string, any>> extends RendererHandler<TValues> {
5
+ private layout;
6
+ constructor(layout: "vertical" | "horizontal" | "grid");
7
+ canHandle(): boolean;
8
+ render(field: FieldSchema<TValues>, form: UseFormReturnType<TValues>): import("react/jsx-runtime").JSX.Element;
9
+ }
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { RendererHandler } from './RendererHandler';
3
+ import { FieldSchema } from '../types';
4
+ import { UseFormReturnType } from '@mantine/form';
5
+ export declare class CustomTypeRendererResolver<TValues extends Record<string, any>> extends RendererHandler<TValues> {
6
+ private customFieldTypes;
7
+ constructor(customFieldTypes: Record<string, (field: FieldSchema<TValues>, form: UseFormReturnType<TValues>) => React.ReactNode>);
8
+ canHandle(field: FieldSchema<TValues>): boolean;
9
+ render(field: FieldSchema<TValues>, form: UseFormReturnType<TValues>): React.ReactNode;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { RendererHandler } from './RendererHandler';
3
+ import { FieldSchema } from '../types';
4
+ import { UseFormReturnType } from '@mantine/form';
5
+ export declare class FieldNameHandler<TValues extends Record<string, any>> extends RendererHandler<TValues> {
6
+ private fieldRenderers;
7
+ constructor(fieldRenderers: Record<string, (field: any, form: any) => React.ReactNode>);
8
+ canHandle(field: FieldSchema<TValues>): boolean;
9
+ render(field: FieldSchema<TValues>, form: UseFormReturnType<TValues>): React.ReactNode;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { RendererHandler } from './RendererHandler';
3
+ import { FieldSchema } from '../types';
4
+ import { UseFormReturnType } from '@mantine/form';
5
+ export declare class FieldTypeHandler<TValues extends Record<string, any>> extends RendererHandler<TValues> {
6
+ private typeRenderers;
7
+ constructor(typeRenderers: Record<string, (field: any, form: any) => React.ReactNode>);
8
+ canHandle(field: FieldSchema<TValues>): boolean;
9
+ render(field: FieldSchema<TValues>, form: UseFormReturnType<TValues>): React.ReactNode;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { FieldSchema } from '../types';
2
+ import { UseFormReturnType } from '@mantine/form';
3
+ import { default as React } from 'react';
4
+ export declare abstract class RendererHandler<TValues extends Record<string, any>> {
5
+ private next?;
6
+ setNext(handler: RendererHandler<TValues>): RendererHandler<TValues>;
7
+ handle(field: FieldSchema<TValues>, form: UseFormReturnType<TValues>): React.ReactNode;
8
+ abstract canHandle(field: FieldSchema<TValues>): boolean;
9
+ abstract render(field: FieldSchema<TValues>, form: UseFormReturnType<TValues>): React.ReactNode;
10
+ }
@@ -0,0 +1,12 @@
1
+ import { UseFormReturnType } from '@mantine/form';
2
+ import { FieldSchema } from './types';
3
+ export type FieldRendererResolverProps<TValues extends Record<string, any> = Record<string, any>> = CustomRenderersConfig<TValues> & {
4
+ field: FieldSchema<TValues>;
5
+ form: UseFormReturnType<TValues>;
6
+ layout?: "vertical" | "horizontal" | "grid";
7
+ };
8
+ export type CustomRenderersConfig<TValues extends Record<string, any> = Record<string, any>> = {
9
+ customFieldRenderers?: Record<string, (field: FieldSchema<TValues>, form: UseFormReturnType<TValues>) => React.ReactNode>;
10
+ customTypeRenderers?: Record<string, (field: FieldSchema<TValues>, form: UseFormReturnType<TValues>) => React.ReactNode>;
11
+ customFieldTypes?: Record<string, (field: FieldSchema<TValues>, form: UseFormReturnType<TValues>) => React.ReactNode>;
12
+ };
@@ -0,0 +1,4 @@
1
+ import { FieldRendererProps } from '../FieldRenderer/FieldRenderer.types';
2
+ type ArrayFieldRendererProps<TValues extends Record<string, any> = Record<string, any>> = FieldRendererProps<TValues>;
3
+ export declare function ArrayFieldRenderer<TValues extends Record<string, any> = Record<string, any>>({ field, form, layout }: ArrayFieldRendererProps<TValues>): import("react/jsx-runtime").JSX.Element;
4
+ export default ArrayFieldRenderer;
@@ -0,0 +1,4 @@
1
+ import { FieldRendererProps } from '../FieldRenderer/FieldRenderer.types';
2
+ type CheckBoxFieldRendererProps<TValues extends Record<string, any> = Record<string, any>> = FieldRendererProps<TValues>;
3
+ export declare function CheckBoxFieldRenderer<TValues extends Record<string, any> = Record<string, any>>({ field, form }: CheckBoxFieldRendererProps<TValues>): import("react/jsx-runtime").JSX.Element;
4
+ export default CheckBoxFieldRenderer;
@@ -0,0 +1,4 @@
1
+ import { FieldRendererProps } from '../FieldRenderer/FieldRenderer.types';
2
+ type DateFieldRendererProps<TValues extends Record<string, any> = Record<string, any>> = FieldRendererProps<TValues>;
3
+ export declare function DateFieldRenderer<TValues extends Record<string, any> = Record<string, any>>({ field, form }: DateFieldRendererProps<TValues>): import("react/jsx-runtime").JSX.Element;
4
+ export default DateFieldRenderer;
@@ -0,0 +1,4 @@
1
+ import { FieldRendererProps } from '../FieldRenderer/FieldRenderer.types';
2
+ type DateTimeFieldRendererProps<TValues extends Record<string, any> = Record<string, any>> = FieldRendererProps<TValues>;
3
+ export declare function DateTimeFieldRenderer<TValues extends Record<string, any> = Record<string, any>>({ field, form }: DateTimeFieldRendererProps<TValues>): import("react/jsx-runtime").JSX.Element;
4
+ export default DateTimeFieldRenderer;