@dmitryvim/form-builder 0.1.28 → 0.1.29

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 (2) hide show
  1. package/README.md +155 -22
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  JSON Schema → Dynamic Forms → Structured Output
4
4
 
5
- A reusable, zero-dependency form generation library that converts JSON schemas into dynamic, interactive forms with real-time validation and file upload support.
5
+ A comprehensive, zero-dependency form generation library that converts JSON Schema v0.3 into dynamic, interactive HTML forms with advanced file handling, real-time validation, internationalization, and extensive field type support.
6
6
 
7
7
  ## Live Demo
8
8
 
@@ -37,16 +37,20 @@ npm install @dmitryvim/form-builder
37
37
 
38
38
  ## Core Features
39
39
 
40
- - **Schema-driven forms**: JSON Schema v0.3 → Interactive forms
41
- - **File uploads**: Built-in support with configurable handlers
42
- - **Real-time validation**: Client-side validation with error display
43
- - **Framework agnostic**: Works with any web stack
44
- - **Zero dependencies**: Self-contained HTML/CSS/JavaScript
45
- - **Read-only mode**: Display form data without editing
46
- - **Draft saving**: Save incomplete forms without validation
40
+ - **🎯 Schema-driven forms**: JSON Schema v0.3 → Interactive forms with live preview
41
+ - **📁 Advanced file handling**: Images, videos, documents with drag-and-drop and grid preview
42
+ - **✅ Real-time validation**: Client-side validation with visual feedback and error display
43
+ - **🌍 Internationalization**: Built-in English/Russian support with extensible translation system
44
+ - **🎨 Rich field types**: Text, textarea, number, select, file, files, and nested groups
45
+ - **👁️ Read-only mode**: Display form data without editing capabilities
46
+ - **💾 Draft saving**: Save incomplete forms without validation
47
+ - **🔧 Framework agnostic**: Works with any web stack (React, Vue, Angular, vanilla JS)
48
+ - **📦 Zero dependencies**: Self-contained HTML/CSS/JavaScript
49
+ - **📱 Responsive design**: Mobile-friendly with Tailwind CSS styling
47
50
 
48
- ## Basic Example
51
+ ## Quick Examples
49
52
 
53
+ ### Simple Contact Form
50
54
  ```json
51
55
  {
52
56
  "version": "0.3",
@@ -56,36 +60,165 @@ npm install @dmitryvim/form-builder
56
60
  "type": "text",
57
61
  "key": "name",
58
62
  "label": "Full Name",
59
- "required": true
63
+ "required": true,
64
+ "minLength": 2,
65
+ "maxLength": 50
66
+ },
67
+ {
68
+ "type": "textarea",
69
+ "key": "message",
70
+ "label": "Message",
71
+ "placeholder": "Your message here...",
72
+ "required": true,
73
+ "rows": 4
60
74
  },
61
75
  {
62
76
  "type": "files",
63
77
  "key": "attachments",
64
78
  "label": "Attachments",
79
+ "description": "Upload supporting documents or images",
65
80
  "maxCount": 3,
81
+ "maxSizeMB": 10,
66
82
  "accept": {
67
- "extensions": ["pdf", "jpg", "png"]
83
+ "extensions": ["pdf", "jpg", "png", "docx"]
68
84
  }
69
85
  }
70
86
  ]
71
87
  }
72
88
  ```
73
89
 
74
- ## Integration Options
90
+ ### Advanced Product Form with Groups
91
+ ```json
92
+ {
93
+ "version": "0.3",
94
+ "title": "Product Registration",
95
+ "elements": [
96
+ {
97
+ "type": "file",
98
+ "key": "mainImage",
99
+ "label": "Product Image",
100
+ "required": true,
101
+ "accept": {
102
+ "extensions": ["jpg", "png", "webp"]
103
+ }
104
+ },
105
+ {
106
+ "type": "group",
107
+ "key": "specifications",
108
+ "label": "Product Specifications",
109
+ "repeat": { "min": 1, "max": 10 },
110
+ "elements": [
111
+ {
112
+ "type": "text",
113
+ "key": "name",
114
+ "label": "Specification Name",
115
+ "required": true
116
+ },
117
+ {
118
+ "type": "text",
119
+ "key": "value",
120
+ "label": "Value",
121
+ "required": true
122
+ }
123
+ ]
124
+ }
125
+ ]
126
+ }
127
+ ```
75
128
 
76
- - **CDN**: Direct iframe embedding
77
- - **NPM**: Import as module
78
- - **Direct**: Self-hosted deployment
129
+ ## Integration Methods
79
130
 
80
- See [Integration Guide](docs/integration.md) for complete setup instructions.
131
+ ### 1. NPM Package (Recommended)
132
+ ```bash
133
+ npm install @dmitryvim/form-builder
134
+ ```
135
+
136
+ ```javascript
137
+ // ES6 imports
138
+ import FormBuilder from '@dmitryvim/form-builder';
139
+
140
+ // Configure and use
141
+ FormBuilder.setFormRoot(document.getElementById('form-container'));
142
+ FormBuilder.setUploadHandler(async (file) => {
143
+ // Your upload logic - return resource ID
144
+ return 'resource-123';
145
+ });
146
+ FormBuilder.renderForm(schema, prefillData);
147
+ ```
148
+
149
+ ### 2. CDN Integration
150
+ ```html
151
+ <!-- Direct script include (npm CDN) -->
152
+ <script src="https://cdn.jsdelivr.net/npm/@dmitryvim/form-builder@latest/dist/form-builder.js"></script>
153
+ <script>
154
+ window.FormBuilder.renderForm(schema);
155
+ </script>
156
+
157
+ <!-- Or use our S3 CDN -->
158
+ <script src="https://picaz-form-builder.website.yandexcloud.net/form-builder/latest/form-builder.js"></script>
159
+
160
+ <!-- Embed complete demo -->
161
+ <iframe
162
+ src="https://picaz-form-builder.website.yandexcloud.net/form-builder/latest/index.html"
163
+ width="100%" height="600px" frameborder="0">
164
+ </iframe>
165
+ ```
166
+
167
+ ### 3. Self-Hosted Deployment
168
+ Download and serve the `dist/` folder contents.
169
+
170
+ See [Integration Guide](docs/integration.md) for detailed setup instructions.
171
+
172
+ ## Complete Feature Set
173
+
174
+ ### Field Types
175
+ - **Text**: Single-line with pattern validation, length limits
176
+ - **Textarea**: Multi-line with configurable rows
177
+ - **Number**: Numeric input with min/max/step/decimals
178
+ - **Select**: Dropdown with options and default values
179
+ - **File**: Single file upload with preview and type restrictions
180
+ - **Files**: Multiple file upload with grid layout and drag-and-drop
181
+ - **Group**: Nested objects with repeatable array support
182
+
183
+ ### File Handling
184
+ - **Supported formats**: Images (jpg, png, gif, webp), Videos (mp4, webm, mov), Documents (pdf, docx, etc.)
185
+ - **Preview system**: Thumbnails for images, video players, document icons
186
+ - **Drag-and-drop**: Visual feedback and multi-file support
187
+ - **Validation**: File size, type, and count restrictions
188
+ - **Resource management**: Metadata tracking and automatic cleanup
189
+
190
+ ### Validation & UX
191
+ - **Real-time validation**: As-you-type with visual feedback
192
+ - **Schema validation**: Comprehensive error reporting
193
+ - **Internationalization**: English/Russian built-in, extensible
194
+ - **Tooltips**: Field descriptions and hints
195
+ - **Responsive design**: Mobile-friendly interface
196
+ - **Read-only mode**: Display data without editing
81
197
 
82
198
  ## Documentation
83
199
 
84
- - [Integration Guide](docs/integration.md) - How to use and integrate
85
- - [Schema Reference](docs/schema.md) - Complete schema documentation
86
- - [Requirements](docs/requirements.md) - Product and business requirements
87
- - [Development Guide](development.md) - Development and testing
200
+ - [Integration Guide](docs/integration.md) - Complete setup and usage
201
+ - [Schema Reference](docs/schema.md) - Field types and validation rules
202
+ - [API Documentation](docs/api.md) - Method reference and examples
203
+ - [Development Guide](CLAUDE.md) - Architecture and development workflow
204
+
205
+ ## Live Demo
206
+
207
+ **Try it now**: [https://picaz-form-builder.website.yandexcloud.net/form-builder/latest/index.html](https://picaz-form-builder.website.yandexcloud.net/form-builder/latest/index.html)
208
+
209
+ **Version Index**: [https://picaz-form-builder.website.yandexcloud.net/index.html](https://picaz-form-builder.website.yandexcloud.net/index.html)
210
+
211
+ Features a 3-column interface:
212
+ - **Schema Editor**: Edit JSON schema with validation
213
+ - **Live Preview**: See form render in real-time
214
+ - **Data Output**: View/export form data as JSON
215
+
216
+ ## Support & Contributing
88
217
 
89
- ## License
218
+ - **GitHub**: [picazru/form-builder](https://github.com/picazru/form-builder)
219
+ - **NPM Package**: [@dmitryvim/form-builder](https://www.npmjs.com/package/@dmitryvim/form-builder)
220
+ - **CDN**: [picaz-form-builder.website.yandexcloud.net](https://picaz-form-builder.website.yandexcloud.net/)
221
+ - **Version**: 0.1.28
222
+ - **License**: MIT - see [LICENSE](LICENSE) file
90
223
 
91
- MIT - see [LICENSE](LICENSE) file.
224
+ Built with ❤️ for the web development community.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.28",
6
+ "version": "0.1.29",
7
7
  "description": "A reusable JSON schema form builder library",
8
8
  "main": "dist/form-builder.js",
9
9
  "module": "dist/form-builder.js",