@formitiva/react 0.9.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/LICENSE +21 -0
- package/README.full.md +456 -0
- package/README.md +114 -0
- package/dist/components/fields/advanced/ColorInput.d.ts +5 -0
- package/dist/components/fields/advanced/EmailInput.d.ts +6 -0
- package/dist/components/fields/advanced/FileInput.d.ts +5 -0
- package/dist/components/fields/advanced/PasswordInput.d.ts +6 -0
- package/dist/components/fields/advanced/PhoneInput.d.ts +7 -0
- package/dist/components/fields/advanced/RatingInput.d.ts +9 -0
- package/dist/components/fields/advanced/SliderInput.d.ts +5 -0
- package/dist/components/fields/advanced/UnitValueInput.d.ts +5 -0
- package/dist/components/fields/advanced/UrlInput.d.ts +9 -0
- package/dist/components/fields/base/PopupOptionMenu.d.ts +16 -0
- package/dist/components/fields/base/Tooltip.d.ts +8 -0
- package/dist/components/fields/choices/CheckboxInput.d.ts +5 -0
- package/dist/components/fields/choices/DropdownInput.d.ts +8 -0
- package/dist/components/fields/choices/MultiSelection.d.ts +9 -0
- package/dist/components/fields/choices/RadioInput.d.ts +8 -0
- package/dist/components/fields/choices/SwitchInput.d.ts +5 -0
- package/dist/components/fields/date-time/DateInput.d.ts +6 -0
- package/dist/components/fields/date-time/TimeInput.d.ts +6 -0
- package/dist/components/fields/text-numeric/FloatArrayInput.d.ts +5 -0
- package/dist/components/fields/text-numeric/FloatInput.d.ts +9 -0
- package/dist/components/fields/text-numeric/IntegerArrayInput.d.ts +6 -0
- package/dist/components/fields/text-numeric/IntegerInput.d.ts +6 -0
- package/dist/components/fields/text-numeric/MultilineTextInput.d.ts +6 -0
- package/dist/components/fields/text-numeric/NumericStepperInput.d.ts +6 -0
- package/dist/components/fields/text-numeric/TextInput.d.ts +8 -0
- package/dist/components/fields/ui-elements/Button.d.ts +14 -0
- package/dist/components/fields/ui-elements/Description.d.ts +10 -0
- package/dist/components/fields/ui-elements/ImageDisplay.d.ts +5 -0
- package/dist/components/fields/ui-elements/Separator.d.ts +21 -0
- package/dist/components/form/Formitiva.d.ts +16 -0
- package/dist/components/form/FormitivaProvider.d.ts +18 -0
- package/dist/components/form/FormitivaRenderer.d.ts +20 -0
- package/dist/components/form/SubmissionButton.d.ts +8 -0
- package/dist/components/form/SubmissionMessage.d.ts +7 -0
- package/dist/components/layout/FieldGroup.d.ts +16 -0
- package/dist/components/layout/FieldRenderer.d.ts +14 -0
- package/dist/components/layout/LayoutComponents.d.ts +77 -0
- package/dist/core/env.d.ts +1 -0
- package/dist/core/fieldVisibility.d.ts +13 -0
- package/dist/core/formitivaModel.d.ts +31 -0
- package/dist/core/formitivaTypes.d.ts +128 -0
- package/dist/core/registries/baseRegistry.d.ts +15 -0
- package/dist/core/registries/buttonHandlerRegistry.d.ts +44 -0
- package/dist/core/registries/componentRegistry.d.ts +15 -0
- package/dist/core/registries/pluginRegistry.d.ts +45 -0
- package/dist/core/registries/submissionHandlerRegistry.d.ts +7 -0
- package/dist/core/registries/validationHandlerRegistry.d.ts +20 -0
- package/dist/core/submitForm.d.ts +9 -0
- package/dist/formitiva.cjs.js +404 -0
- package/dist/formitiva.es.js +5626 -0
- package/dist/hooks/useDebouncedCallback.d.ts +27 -0
- package/dist/hooks/useDropdownPosition.d.ts +6 -0
- package/dist/hooks/useFieldValidator.d.ts +3 -0
- package/dist/hooks/useFormitivaContext.d.ts +4 -0
- package/dist/hooks/useUncontrolledValidatedInput.d.ts +21 -0
- package/dist/hooks/useUnitValueField.d.ts +13 -0
- package/dist/index.d.ts +27 -0
- package/dist/react.css +1 -0
- package/dist/styles/cssClasses.d.ts +15 -0
- package/dist/styles/themeUtils.d.ts +31 -0
- package/dist/themes/ant-design-dark.css +31 -0
- package/dist/themes/ant-design.css +42 -0
- package/dist/themes/blueprint-dark.css +31 -0
- package/dist/themes/blueprint.css +43 -0
- package/dist/themes/compact-variant.css +8 -0
- package/dist/themes/fluent.css +40 -0
- package/dist/themes/glass-morphism.css +25 -0
- package/dist/themes/high-contrast-accessible.css +22 -0
- package/dist/themes/ios-mobile.css +32 -0
- package/dist/themes/macos-native.css +32 -0
- package/dist/themes/material-dark.css +27 -0
- package/dist/themes/material.css +46 -0
- package/dist/themes/midnight-dark.css +24 -0
- package/dist/themes/modern-light.css +23 -0
- package/dist/themes/neon-cyber-dark.css +24 -0
- package/dist/themes/shadcn.css +40 -0
- package/dist/themes/soft-pastel.css +24 -0
- package/dist/themes/spacious-variant.css +9 -0
- package/dist/themes/tailwind-dark.css +30 -0
- package/dist/themes/tailwind.css +50 -0
- package/dist/utils/definitionSerializers.d.ts +62 -0
- package/dist/utils/groupingHelpers.d.ts +24 -0
- package/dist/utils/translationUtils.d.ts +52 -0
- package/dist/utils/unitValueMapper.d.ts +14 -0
- package/dist/validation/registerBuiltinTypeValidators.d.ts +11 -0
- package/dist/validation/validation.d.ts +12 -0
- package/dist/validation/validators/validateColorField.d.ts +2 -0
- package/dist/validation/validators/validateDateField.d.ts +2 -0
- package/dist/validation/validators/validateEmailField.d.ts +2 -0
- package/dist/validation/validators/validateFieldPattern.d.ts +3 -0
- package/dist/validation/validators/validateFileField.d.ts +2 -0
- package/dist/validation/validators/validateFloatField.d.ts +3 -0
- package/dist/validation/validators/validateIntegerField.d.ts +3 -0
- package/dist/validation/validators/validatePhoneField.d.ts +2 -0
- package/dist/validation/validators/validateRatingField.d.ts +2 -0
- package/dist/validation/validators/validateSelectionFields.d.ts +3 -0
- package/dist/validation/validators/validateSliderField.d.ts +2 -0
- package/dist/validation/validators/validateTextField.d.ts +2 -0
- package/dist/validation/validators/validateTimeField.d.ts +2 -0
- package/dist/validation/validators/validateUnitValueField.d.ts +2 -0
- package/dist/validation/validators/validateUrlField.d.ts +2 -0
- package/package.json +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 yanggmtl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.full.md
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
# Formitiva
|
|
2
|
+
|
|
3
|
+
> **Build dynamic React forms visually — no JSX, no boilerplate.**
|
|
4
|
+
|
|
5
|
+
**Formitiva is a dynamic, schema-driven form platform for React, built for visual workflows.**
|
|
6
|
+
|
|
7
|
+
Design forms using JSON schemas or a visual builder, render them instantly, and scale complex configurable UIs across multiple applications.
|
|
8
|
+
|
|
9
|
+
✨ Visual Builder included
|
|
10
|
+
✨ Schema-first, no JSX
|
|
11
|
+
✨ Fully extendable (components, themes, validation, i18n)
|
|
12
|
+
✨ TypeScript-first
|
|
13
|
+
✨ Optimized for large, dynamic forms
|
|
14
|
+
|
|
15
|
+
🌐 **Documentation & Demos**
|
|
16
|
+
- **Doc:** https://formitiva.vercel.app
|
|
17
|
+
- **Playground & Demos:** https://formitiva.vercel.app
|
|
18
|
+
- **Builder:** https://formitiva.vercel.app/builder
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Table of Contents
|
|
25
|
+
|
|
26
|
+
- [What is Formitiva?](#what-is-formitiva)
|
|
27
|
+
- [Why Formitiva?](#why-formitiva)
|
|
28
|
+
- [Extensibility](#extensibility)
|
|
29
|
+
- [Formitiva Builder](#formitiva-builder)
|
|
30
|
+
- [Key Features](#key-features)
|
|
31
|
+
- [Installation](#installation)
|
|
32
|
+
- [Quick Start](#quick-start)
|
|
33
|
+
- [Conditional Logic](#conditional-logic)
|
|
34
|
+
- [Validation and Validators](#validation-and-validators)
|
|
35
|
+
- [Documentation](#documentation)
|
|
36
|
+
- [Who Is Formitiva For?](#target-customer)
|
|
37
|
+
- [Roadmap](#roadmap)
|
|
38
|
+
- [Contributing](#contributing)
|
|
39
|
+
- [Learn More](#learn-more)
|
|
40
|
+
- [License](#license)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## <a id="what-is-formitiva"></a> 🤔 What is-Formitiva?
|
|
44
|
+
|
|
45
|
+
Formitiva is not a traditional React form library.
|
|
46
|
+
|
|
47
|
+
Instead of writing forms in JSX, Formitiva treats forms as data:
|
|
48
|
+
|
|
49
|
+
- Defined using JSON schemas
|
|
50
|
+
- Stored in databases or CMSs
|
|
51
|
+
- Rendered dynamically at runtime
|
|
52
|
+
- Editable visually by non-developers
|
|
53
|
+
|
|
54
|
+
This makes Formitiva ideal for applications where forms are configurable, shared, or owned by the backend.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## <a id="why-formitiva"></a> 🤔 Why Formitiva?
|
|
59
|
+
|
|
60
|
+
### Most React form libraries assume:
|
|
61
|
+
|
|
62
|
+
- The form structure is static
|
|
63
|
+
- Developers write every field in JSX
|
|
64
|
+
- Changes require code edits and redeploys
|
|
65
|
+
|
|
66
|
+
### Formitiva is built for cases where forms are:
|
|
67
|
+
- Generated from backend data
|
|
68
|
+
- Configurable at runtime
|
|
69
|
+
- Built visually (low-code / no-code)
|
|
70
|
+
- Shared across multiple apps
|
|
71
|
+
- Highly customizable and themeable
|
|
72
|
+
|
|
73
|
+
### Comparison
|
|
74
|
+
⚠️ Important context
|
|
75
|
+
|
|
76
|
+
Not all form libraries solve the same problem.
|
|
77
|
+
|
|
78
|
+
Libraries like React Hook Form, Formik, and Final Form are code-first form state managers.
|
|
79
|
+
They assume forms are authored in JSX at build time.
|
|
80
|
+
|
|
81
|
+
Formitiva belongs to a different category:
|
|
82
|
+
👉 schema-driven, runtime-configurable form engines.
|
|
83
|
+
|
|
84
|
+
Formitiva vs Schema-Driven Form Libraries
|
|
85
|
+
| Feature | Formitiva | RJSF | JSON Forms | Uniforms | Form.io |
|
|
86
|
+
|------|------|------|------|------|------|
|
|
87
|
+
| Form definition | Custom JSON schema | JSON Schema | JSON Schema + UI schema | Multiple schemas | Platform schema |
|
|
88
|
+
| JSX required | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
89
|
+
| Runtime-configurable | ✔ | ⚠️ | ⚠️ | ⚠️ | ✔ |
|
|
90
|
+
| Conditional logic | ✔ Native | ⚠️ | ⚠️ | ⚠️ | ✔ |
|
|
91
|
+
| Visual builder | ✔ | ❌ | ❌ | ❌ | ✔ |
|
|
92
|
+
| Backend-driven forms | ✔ First-class | ⚠️ | ⚠️ | ⚠️ | ✔ |
|
|
93
|
+
| Plugin architecture | ✔ | ⚠️ | ⚠️ | ✔ | ✔ |
|
|
94
|
+
| Built-in theming | ✔ | ⚠️ | ✔ | ⚠️ | ✔ |
|
|
95
|
+
| Low-code friendly | ✔ | ❌ | ❌ | ❌ | ✔ |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## <a id="extensibility"></a> 🏗 Extensibility
|
|
100
|
+
|
|
101
|
+
Formitiva is designed as an extendable platform, not just a renderer.
|
|
102
|
+
|
|
103
|
+
| Area | Support |
|
|
104
|
+
| --------------------------- | ------------------------------------------ |
|
|
105
|
+
| Field components | ✔ Custom components |
|
|
106
|
+
| Layout & grouping | ✔ Groups, sections (more planned) |
|
|
107
|
+
| Validation logic | ✔ Field, form, and field-type validators |
|
|
108
|
+
| Submission workflows | ✔ Pluggable submission handlers |
|
|
109
|
+
| Themes | ✔ CSS-variable-based theme registry |
|
|
110
|
+
| Internationalization (i18n) | ✔ Custom dictionaries & per-form overrides |
|
|
111
|
+
| Schema model | ✔ Custom field types & metadata |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## <a id="formitiva-builder"></a> 🏗 Formitiva Builder
|
|
116
|
+
|
|
117
|
+
Formitiva includes a drag-and-drop visual builder:
|
|
118
|
+
|
|
119
|
+
- Build forms visually
|
|
120
|
+
- Configure validation & conditional logic
|
|
121
|
+
- Preview instantly
|
|
122
|
+
- Export production-ready JSON schemas
|
|
123
|
+
|
|
124
|
+
<img src="./docs/assets/images/form_builder_ui.png" alt="Formitiva Builder Screenshot" width="900" style="max-width:80%;height:auto;display:block;margin:0.5rem auto;" />
|
|
125
|
+
👉 https://formitiva.vercel.app/builder
|
|
126
|
+
|
|
127
|
+
## <a id="key-features"></a> ✨ Key Features
|
|
128
|
+
|
|
129
|
+
### 🔧 Core Concepts
|
|
130
|
+
| Concept | Description |
|
|
131
|
+
|------|------|
|
|
132
|
+
| Schema-driven | Forms are defined using JSON, not JSX |
|
|
133
|
+
| Runtime rendering | Forms can change without redeploying |
|
|
134
|
+
| Visual-first | Optional drag-and-drop builder |
|
|
135
|
+
| Extendable | Components, themes, validation, and i18n are pluggable |
|
|
136
|
+
| Backend-friendly | Schemas can live in APIs or databases |
|
|
137
|
+
|
|
138
|
+
### 🎨 Theming
|
|
139
|
+
- CSS-variable-based themes
|
|
140
|
+
- Light & dark modes
|
|
141
|
+
- 20+ built-in themes
|
|
142
|
+
|
|
143
|
+
### 🧠 Logic & Validation
|
|
144
|
+
- Conditional visibility
|
|
145
|
+
- Custom validators
|
|
146
|
+
- Custom submission handlers
|
|
147
|
+
|
|
148
|
+
### 🔌 Extensibility
|
|
149
|
+
- Component registry
|
|
150
|
+
- Plugin system
|
|
151
|
+
- Custom fields and workflows
|
|
152
|
+
|
|
153
|
+
### 🌍 i18n
|
|
154
|
+
- Built-in multi-language support
|
|
155
|
+
- Per-form/Per-app translation dictionaries
|
|
156
|
+
- Translation caching
|
|
157
|
+
|
|
158
|
+
### ⚡ Performance & Accessibility
|
|
159
|
+
- Incremental (chunked) mounting.
|
|
160
|
+
- Efficient updates using requestAnimationFrame batching and targeted visibility recomputation.
|
|
161
|
+
- Reduced input overhead with debounced callbacks for expensive handlers.
|
|
162
|
+
- ARIA-compliant by default
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## <a id="installation"></a> 📦 Installation
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
npm install formitiva
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Peer Dependencies**
|
|
173
|
+
- React ^18 || ^19
|
|
174
|
+
- React-DOM ^18 || ^19
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## <a id="quick-start"></a> 🚀 Quick Start
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
import { Formitiva } from 'formitiva';
|
|
182
|
+
|
|
183
|
+
const definition = {
|
|
184
|
+
name: "simpleForm",
|
|
185
|
+
displayName: "Simple Form",
|
|
186
|
+
properties: [
|
|
187
|
+
{ name: "email", type: "email", required: true }
|
|
188
|
+
]
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export default function App() {
|
|
192
|
+
return <Formitiva definitionData={definition} />;
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## <a id="conditional-logic"></a> 🎭 Conditional Logic
|
|
197
|
+
|
|
198
|
+
Dynamically show or hide individual fields or groups based on parent–child rules or group conditions.
|
|
199
|
+
|
|
200
|
+
Parent–child example (schema fragment):
|
|
201
|
+
Parents are defined in the parents field by specifying the parent field name and the corresponding values.
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"properties": [
|
|
206
|
+
{
|
|
207
|
+
"name": "country",
|
|
208
|
+
"displayName": "Country",
|
|
209
|
+
"type": "dropdown",
|
|
210
|
+
"options": [
|
|
211
|
+
{ "label": "United States", "value": "US" },
|
|
212
|
+
{ "label": "Canada", "value": "CA" }
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "state",
|
|
217
|
+
"displayName": "State",
|
|
218
|
+
"type": "dropdown",
|
|
219
|
+
"parents": { "country": ["US"] }
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "province",
|
|
223
|
+
"displayName": "Province",
|
|
224
|
+
"type": "dropdown",
|
|
225
|
+
"parents": { "country": ["CA"] }
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Group support
|
|
232
|
+
|
|
233
|
+
Groups let you treat multiple fields as a unit and control the group's visibility with group name defined in field. Consecutive fields with same group name will be grouped while non consecutive fields with same group name are treated as different groups.
|
|
234
|
+
|
|
235
|
+
Example — `Address` group contains `address1` and `address2`
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
{
|
|
240
|
+
"type": "text",
|
|
241
|
+
"name": "address1",
|
|
242
|
+
"displayName": "Address Line 1",
|
|
243
|
+
"defaultValue": "",
|
|
244
|
+
"group": "Address"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"type": "text",
|
|
248
|
+
"name": "address2",
|
|
249
|
+
"displayName": "Address Line 2",
|
|
250
|
+
"defaultValue": "",
|
|
251
|
+
"group": "Address"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## <a id="validation-and-validators"></a> 🔒 Validation and Validators
|
|
259
|
+
|
|
260
|
+
Formitiva supports both field-level and form-level validation.
|
|
261
|
+
|
|
262
|
+
- Field-level: validation for a single field; can happen while editing, on blur, or on submission.
|
|
263
|
+
- Form-level: cross-field validation performed during submission.
|
|
264
|
+
|
|
265
|
+
### Field validation modes
|
|
266
|
+
|
|
267
|
+
`FieldValidationMode`:
|
|
268
|
+
- `onEdit`: Runs validation while the user edits a field.
|
|
269
|
+
- `onBlur`: Runs validation when the field loses focus.
|
|
270
|
+
- `onSubmission`: Runs validation only when the form is submitted.
|
|
271
|
+
- `realTime`: Deprecated. Same behavior as `onEdit`.
|
|
272
|
+
|
|
273
|
+
### Validators
|
|
274
|
+
|
|
275
|
+
- Field custom validator — register a handler for individual-field logic.
|
|
276
|
+
- Form custom validator — register a handler for cross-field logic (runs during submission).
|
|
277
|
+
- Field type validator — define validation for a custom field/component type.
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Submission Handler
|
|
281
|
+
|
|
282
|
+
Formitiva provide two ways for submission process:
|
|
283
|
+
|
|
284
|
+
- Direct submission callback in Formitiva props
|
|
285
|
+
- Since Formitiva is a dynamic form system, it provides a registration submission mechanism that allows you to define and plug in custom submission logic. This can provide you flexible submission process for different submission logics.
|
|
286
|
+
|
|
287
|
+
Note: In bubmission proces, onSubmit callback will be used if it is provided. Otherwise if submissionHandler in defintion is spcified, the registration handler will be invoked.
|
|
288
|
+
|
|
289
|
+
**How It Works**
|
|
290
|
+
|
|
291
|
+
### Direct submission callback
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
async function submitFunction(definition, instanceName, valuesMap, t) => {
|
|
295
|
+
// send valuesMap to your API
|
|
296
|
+
const res = await fetch('/api/save', { method: 'POST', body: JSON.stringify(valuesMap), headers: { 'Content-Type': 'application/json' } });
|
|
297
|
+
if (!res.ok) return [t('Server error while submitting form')];
|
|
298
|
+
return undefined; // returning undefined (or falsy) means success
|
|
299
|
+
});
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Then in your app, when call Formitiva, pass submitFunction to onSubmit:
|
|
303
|
+
```ts
|
|
304
|
+
<Formitiva
|
|
305
|
+
definition={userDefintion}
|
|
306
|
+
onSubmit= {submitFunction}
|
|
307
|
+
/>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Submission registration handling is configured in two steps:
|
|
311
|
+
|
|
312
|
+
1. Define and Register a Submission Handler
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
import { registerSubmissionHandler } from 'formitiva';
|
|
316
|
+
|
|
317
|
+
registerSubmissionHandler('api:saveForm', async (definition, instanceName, valuesMap, t) => {
|
|
318
|
+
// send valuesMap to your API
|
|
319
|
+
const res = await fetch('/api/save', { method: 'POST', body: JSON.stringify(valuesMap), headers: { 'Content-Type': 'application/json' } });
|
|
320
|
+
if (!res.ok) return [t('Server error while submitting form')];
|
|
321
|
+
return undefined; // returning undefined (or falsy) means success
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
2. Reference the Registered Handler in the Form Definition
|
|
326
|
+
|
|
327
|
+
Schema example (Reference a registered handler using the submitHandlerName property):
|
|
328
|
+
|
|
329
|
+
```json
|
|
330
|
+
{
|
|
331
|
+
"name": "contactForm",
|
|
332
|
+
"version": "1.0",
|
|
333
|
+
"displayName": "Contact",
|
|
334
|
+
"submitHandlerName": "api:saveForm",
|
|
335
|
+
"properties": [ /* ... */ ]
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## <a id="documentation"></a> 📚 Documentation
|
|
340
|
+
|
|
341
|
+
👉 https://formitiva.vercel.app/docs
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## 👥 <a id="target-customer"></a>Who Is Formitiva For?
|
|
346
|
+
|
|
347
|
+
- SaaS settings pages
|
|
348
|
+
- Admin dashboards
|
|
349
|
+
- Product configurators
|
|
350
|
+
- CMS-driven forms
|
|
351
|
+
- Low-code tools
|
|
352
|
+
- Enterprise dynamic UIs
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## <a id="roadmap"></a> 🗺️ Roadmap
|
|
357
|
+
Status Legend:
|
|
358
|
+
- 🟢 Current — available or actively shipping
|
|
359
|
+
- 🔵 Planned — designed and scheduled
|
|
360
|
+
- 🟡 Experimental — under research or prototyping
|
|
361
|
+
|
|
362
|
+
### Core & Standards
|
|
363
|
+
- 🟡 Accessibility certification (WCAG 2.2 AA)
|
|
364
|
+
- 🔵 Performance & accessibility audit tooling
|
|
365
|
+
- 🔵 Schema versioning & migration tools
|
|
366
|
+
- 🔵 Backward-compatible schema evolution
|
|
367
|
+
- 🔵 Form definition linting & diagnostics
|
|
368
|
+
- 🔵 Runtime schema validation & error reporting
|
|
369
|
+
|
|
370
|
+
### Conditional Logic
|
|
371
|
+
- 🟢 Parent–child conditional visibility
|
|
372
|
+
- 🟢 Field grouping
|
|
373
|
+
- 🔵 Logical operators (AND / OR / NOT)
|
|
374
|
+
- 🔵 Multi-field conditions
|
|
375
|
+
- 🔵 Expression-based rules
|
|
376
|
+
|
|
377
|
+
### Layout & Structure
|
|
378
|
+
- 🟢 Collapsible sections - Group
|
|
379
|
+
- 🔵 Multi-step / wizard forms
|
|
380
|
+
- 🔵 Tabbed layouts
|
|
381
|
+
- 🔵 Navigation sections / anchors
|
|
382
|
+
- 🔵 Grid & column layouts
|
|
383
|
+
|
|
384
|
+
### Visual Builders
|
|
385
|
+
- 🟢 Drag-and-drop form builder
|
|
386
|
+
- 🔵 Advanced conditional logic editor
|
|
387
|
+
- 🔵 Validation rule designer
|
|
388
|
+
- 🔵 Submission workflow editor
|
|
389
|
+
- 🔵 Layout editor (nav, tabs, steps, groups)
|
|
390
|
+
- 🔵 Schema version history & rollback
|
|
391
|
+
- 🟡 Builder extensibility API
|
|
392
|
+
|
|
393
|
+
### Theme System
|
|
394
|
+
- 🟢 CSS-variable-based theming
|
|
395
|
+
- 🟢 Light & dark mode support
|
|
396
|
+
- 🟢 Per-form theme customization
|
|
397
|
+
- 🔵 Visual theme builder
|
|
398
|
+
- 🔵 CSS variable editor
|
|
399
|
+
- 🔵 Exportable & versioned theme packages
|
|
400
|
+
- 🔵 Tailwind-compatible themes
|
|
401
|
+
|
|
402
|
+
### Plugin System
|
|
403
|
+
- 🟢 Component registry
|
|
404
|
+
- 🟢 Submission handler registration
|
|
405
|
+
- 🟢 Validation handler registrytion
|
|
406
|
+
- 🔵 Plugin scaffolding CLI
|
|
407
|
+
- 🔵 Custom field plugin builder
|
|
408
|
+
- 🔵 Validator plugin builder
|
|
409
|
+
- 🔵 Submission handler plugins
|
|
410
|
+
|
|
411
|
+
Internationalization (i18n)
|
|
412
|
+
|
|
413
|
+
Current: built-in i18n with per-form dictionaries
|
|
414
|
+
- 🟢 Built-in i18n support
|
|
415
|
+
- 🟢 Per-form translation dictionaries
|
|
416
|
+
- 🔵 Visual translation editor
|
|
417
|
+
- 🔵 Translation key discovery
|
|
418
|
+
- 🔵 Missing translation detection
|
|
419
|
+
- 🔵 Locale fallback strategies
|
|
420
|
+
- 🟡 Async translation loaders
|
|
421
|
+
|
|
422
|
+
### Ecosystem & Marketplace
|
|
423
|
+
- 🟡 Definition templates (community-driven)
|
|
424
|
+
- 🟡 Plugin marketplace (community-driven)
|
|
425
|
+
- 🟡 Theme sharing & presets gallery
|
|
426
|
+
- 🟡 Official plugin & theme collections
|
|
427
|
+
|
|
428
|
+
### Enterprise
|
|
429
|
+
- 🔵 Form analytics & submission insights
|
|
430
|
+
- 🔵 Role-based builder permissions
|
|
431
|
+
- 🔵 Hosted schema & asset management
|
|
432
|
+
- 🔵 Enterprise integrations
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## <a id="contributing"></a> 🤝 Contributing
|
|
437
|
+
|
|
438
|
+
Contributions are welcome!
|
|
439
|
+
Open an issue or submit a pull request.
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## <a id="learn-more"></a> 📘 Learn more
|
|
444
|
+
|
|
445
|
+
- [Full README](https://github.com/formitiva/blob/master/README.full.md)
|
|
446
|
+
- [Formitiva Official Site](http://formitiva.vercel.app)
|
|
447
|
+
- [Documentation](https://formitiva.vercel.app/docs)
|
|
448
|
+
- [Demos](http://formitiva.vercel.app/features#Demos)
|
|
449
|
+
- [Visual Builder](https://formitiva.vercel.app/builder)
|
|
450
|
+
- [Examples](https://github.com/formitiva/tree/master/examples)
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## <a id="license"></a> 📄 License
|
|
455
|
+
|
|
456
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Formitiva
|
|
2
|
+
|
|
3
|
+
Build dynamic React forms visually ??no JSX, no boilerplate.
|
|
4
|
+
|
|
5
|
+
Formitiva is a schema-driven, extendable form platform for React. Define forms as JSON (or visually), render them at runtime, and scale complex, configurable UIs without rewriting JSX.
|
|
6
|
+
|
|
7
|
+
- Visual Form Builder
|
|
8
|
+
- Forms as data (JSON, not JSX)
|
|
9
|
+
- Fully extendable (components, themes, validation, i18n)
|
|
10
|
+
- TypeScript-first
|
|
11
|
+
- Optimized for large, dynamic forms
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## Why Formitiva?
|
|
16
|
+
|
|
17
|
+
Most React form libraries are code-first:
|
|
18
|
+
|
|
19
|
+
- Forms are written in JSX
|
|
20
|
+
- Changes require code edits and redeploys
|
|
21
|
+
|
|
22
|
+
Formitiva is different:
|
|
23
|
+
|
|
24
|
+
- Forms are schema-driven
|
|
25
|
+
- Stored in APIs, databases, or CMSs
|
|
26
|
+
- Editable visually (low-code / no-code)
|
|
27
|
+
- Rendered dynamically at runtime
|
|
28
|
+
|
|
29
|
+
If your forms change often or are backend-owned, Formitiva fits naturally.
|
|
30
|
+
|
|
31
|
+
## Use Cases
|
|
32
|
+
|
|
33
|
+
- SaaS settings & configuration pages
|
|
34
|
+
- Admin dashboards
|
|
35
|
+
- CMS-driven forms
|
|
36
|
+
- Product configurators
|
|
37
|
+
- Low-code / no-code platforms
|
|
38
|
+
- Enterprise dynamic UIs
|
|
39
|
+
|
|
40
|
+
## Quick example
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { Formitiva } from 'formitiva';
|
|
44
|
+
|
|
45
|
+
const definition = {
|
|
46
|
+
name: 'contactForm',
|
|
47
|
+
displayName: 'Contact',
|
|
48
|
+
properties: [
|
|
49
|
+
{ name: 'email', type: 'email', required: true }
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default function App() {
|
|
54
|
+
return <Formitiva definitionData={definition} />;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
No JSX fields. No wiring. Just render.
|
|
59
|
+
|
|
60
|
+
## Key features
|
|
61
|
+
|
|
62
|
+
- Schema-driven rendering (JSON, not JSX)
|
|
63
|
+
- Visual drag-and-drop form builder
|
|
64
|
+
- Runtime-configurable forms
|
|
65
|
+
- Conditional logic & grouping
|
|
66
|
+
- Pluggable validation & submission
|
|
67
|
+
- Themeable via CSS variables
|
|
68
|
+
- Built-in i18n
|
|
69
|
+
- High-performance rendering
|
|
70
|
+
- ARIA-compliant by default
|
|
71
|
+
|
|
72
|
+
## Extensible by design
|
|
73
|
+
|
|
74
|
+
Formitiva is a platform, not just a renderer. You can extend:
|
|
75
|
+
|
|
76
|
+
- Field components
|
|
77
|
+
- Validation logic (field, form, type)
|
|
78
|
+
- Submission workflows
|
|
79
|
+
- Themes & design systems
|
|
80
|
+
- Languages & translations
|
|
81
|
+
- Custom field types & metadata
|
|
82
|
+
|
|
83
|
+
No forks. No hacks.
|
|
84
|
+
|
|
85
|
+
## How it compares
|
|
86
|
+
|
|
87
|
+
- Formik / React Hook Form ??code-first, JSX-based
|
|
88
|
+
- Formitiva ??schema-first, runtime-driven
|
|
89
|
+
|
|
90
|
+
Formitiva doesn��t replace form state libraries ??it replaces hand-coding forms when forms are dynamic.
|
|
91
|
+
|
|
92
|
+
## Installation
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm install formitiva
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Peer dependencies
|
|
99
|
+
|
|
100
|
+
- React ^18 || ^19
|
|
101
|
+
- React DOM ^18 || ^19
|
|
102
|
+
|
|
103
|
+
## Learn more
|
|
104
|
+
|
|
105
|
+
- [Full README](https://github.com/Formitiva/react/blob/master/README.full.md)
|
|
106
|
+
- [Formitiva Official Site](http://formitiva.vercel.app)
|
|
107
|
+
- [Documentation](https://formitiva.vercel.app/docs)
|
|
108
|
+
- [Demos](http://formitiva.vercel.app/features#Demos)
|
|
109
|
+
- [Visual Builder](https://formitiva.vercel.app/builder)
|
|
110
|
+
- [Examples](https://github.com/formitiva/react/tree/master/examples)
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseInputProps, DefinitionPropertyField } from "../../../core/formitivaTypes";
|
|
3
|
+
export type ColorInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
4
|
+
declare const _default: React.NamedExoticComponent<ColorInputProps>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { DefinitionPropertyField, BaseInputProps } from "../../../core/formitivaTypes";
|
|
3
|
+
export type EmailInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
4
|
+
export declare const EmailInput: React.FC<EmailInputProps>;
|
|
5
|
+
declare const _default: React.NamedExoticComponent<EmailInputProps>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseInputProps, DefinitionPropertyField } from "../../../core/formitivaTypes";
|
|
3
|
+
export type FileInputProps = BaseInputProps<File | File[] | null, DefinitionPropertyField>;
|
|
4
|
+
declare const _default: React.NamedExoticComponent<FileInputProps>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../../core/formitivaTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../../core/formitivaTypes";
|
|
4
|
+
type PasswordInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
5
|
+
declare const _default: React.NamedExoticComponent<PasswordInputProps>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../../core/formitivaTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../../core/formitivaTypes";
|
|
4
|
+
export type PhoneInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
5
|
+
export declare const PhoneInput: React.FC<PhoneInputProps>;
|
|
6
|
+
declare const _default: React.NamedExoticComponent<PhoneInputProps>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseInputProps, DefinitionPropertyField } from "../../../core/formitivaTypes";
|
|
3
|
+
type RatingField = DefinitionPropertyField & {
|
|
4
|
+
max?: number;
|
|
5
|
+
icon?: string;
|
|
6
|
+
};
|
|
7
|
+
export type RatingInputProps = BaseInputProps<number, RatingField>;
|
|
8
|
+
declare const _default: React.NamedExoticComponent<RatingInputProps>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseInputProps, DefinitionPropertyField } from "../../../core/formitivaTypes";
|
|
3
|
+
type SliderInputProps = BaseInputProps<string | number, DefinitionPropertyField>;
|
|
4
|
+
declare const _default: React.NamedExoticComponent<SliderInputProps>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseInputProps, DefinitionPropertyField } from "../../../core/formitivaTypes";
|
|
3
|
+
type UnitValueInputProps = BaseInputProps<[string | number, string], DefinitionPropertyField>;
|
|
4
|
+
declare const _default: React.NamedExoticComponent<UnitValueInputProps>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../../core/formitivaTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../../core/formitivaTypes";
|
|
4
|
+
/**
|
|
5
|
+
* UrlInput component
|
|
6
|
+
*/
|
|
7
|
+
export type UrlInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
8
|
+
declare const _default: React.NamedExoticComponent<UrlInputProps>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type PopupOptionMenuPosition = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
export interface PopupOption {
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PopupOptionMenuProps<T extends PopupOption> {
|
|
10
|
+
pos: PopupOptionMenuPosition | null;
|
|
11
|
+
options: T[];
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
onClickOption: (option: T) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function PopupOptionMenu<T extends PopupOption>({ pos, options, onClose, onClickOption }: PopupOptionMenuProps<T>): React.ReactPortal | null;
|
|
16
|
+
export default PopupOptionMenu;
|