@dmitryvim/form-builder 0.1.37 → 0.1.38
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 +10 -5
- package/dist/demo.js +60 -74
- package/dist/form-builder.js +201 -85
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/docs/13_form_builder.html +0 -1337
- package/docs/REQUIREMENTS.md +0 -313
- package/docs/integration.md +0 -480
- package/docs/schema.md +0 -433
package/docs/REQUIREMENTS.md
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
# Product & Business Requirements
|
|
2
|
-
|
|
3
|
-
Core requirements and specifications for the Form Builder library.
|
|
4
|
-
|
|
5
|
-
## Product Overview
|
|
6
|
-
|
|
7
|
-
**Form Builder** transforms JSON schemas into dynamic, interactive web forms with real-time validation and structured data output. Designed as a framework-agnostic, zero-dependency library for easy integration.
|
|
8
|
-
|
|
9
|
-
**Primary Goal**: Provide a reusable form generation solution that eliminates custom form development overhead.
|
|
10
|
-
|
|
11
|
-
## Business Requirements
|
|
12
|
-
|
|
13
|
-
### Core Value Propositions
|
|
14
|
-
|
|
15
|
-
1. **Rapid Form Development**: Schema → Form in minutes, not hours
|
|
16
|
-
2. **Consistent UX**: Standardized form behavior across applications
|
|
17
|
-
3. **Zero Dependencies**: No framework lock-in or bundle bloat
|
|
18
|
-
4. **File Upload Ready**: Built-in support for modern file workflows
|
|
19
|
-
5. **Deployment Flexibility**: CDN, NPM, or self-hosted options
|
|
20
|
-
|
|
21
|
-
### Target Users
|
|
22
|
-
|
|
23
|
-
- **Developers**: Need forms for SPA applications
|
|
24
|
-
- **Product Teams**: Require consistent form experiences
|
|
25
|
-
- **Startups**: Want rapid prototyping capabilities
|
|
26
|
-
- **Enterprise**: Need standardized form solutions
|
|
27
|
-
|
|
28
|
-
## Functional Requirements
|
|
29
|
-
|
|
30
|
-
### 1. Form Generation Engine
|
|
31
|
-
|
|
32
|
-
**MUST support field types:**
|
|
33
|
-
|
|
34
|
-
- `text` - Single line input with validation
|
|
35
|
-
- `textarea` - Multi-line text input
|
|
36
|
-
- `number` - Numeric input with constraints
|
|
37
|
-
- `select` - Dropdown with options
|
|
38
|
-
- `file` - Single file upload with preview
|
|
39
|
-
- `files` - Multiple file upload with limits
|
|
40
|
-
- `group` - Nested objects with repeat support
|
|
41
|
-
|
|
42
|
-
```javascript
|
|
43
|
-
// Example schema
|
|
44
|
-
{
|
|
45
|
-
"version": "0.3",
|
|
46
|
-
"title": "Asset Upload",
|
|
47
|
-
"elements": [
|
|
48
|
-
{
|
|
49
|
-
"type": "files",
|
|
50
|
-
"key": "assets",
|
|
51
|
-
"label": "Images",
|
|
52
|
-
"maxCount": 10,
|
|
53
|
-
"accept": { "extensions": ["jpg", "png"] }
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### 2. Validation System
|
|
60
|
-
|
|
61
|
-
**MUST provide:**
|
|
62
|
-
|
|
63
|
-
- Real-time field validation
|
|
64
|
-
- Required field checking
|
|
65
|
-
- String length limits (minLength/maxLength)
|
|
66
|
-
- Numeric ranges (min/max)
|
|
67
|
-
- Pattern matching (regex)
|
|
68
|
-
- File type restrictions
|
|
69
|
-
- Custom validation rules
|
|
70
|
-
|
|
71
|
-
**MUST support:**
|
|
72
|
-
|
|
73
|
-
- Form submission with full validation
|
|
74
|
-
- Draft saving without validation
|
|
75
|
-
- Field-level error display
|
|
76
|
-
|
|
77
|
-
### 3. File Upload System
|
|
78
|
-
|
|
79
|
-
**Upload Handler Requirements:**
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
// Handler MUST return resource ID for download/submission
|
|
83
|
-
uploadHandler: async (file) => {
|
|
84
|
-
// Upload logic...
|
|
85
|
-
return resourceId; // NOT file URL
|
|
86
|
-
};
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**MUST provide:**
|
|
90
|
-
|
|
91
|
-
- Visual file previews (thumbnails + icons)
|
|
92
|
-
- Upload progress indicators
|
|
93
|
-
- Individual file removal
|
|
94
|
-
- Drag & drop support
|
|
95
|
-
- File metadata display (name, size, type)
|
|
96
|
-
|
|
97
|
-
### 4. Form Modes
|
|
98
|
-
|
|
99
|
-
**Submission Mode** (default):
|
|
100
|
-
|
|
101
|
-
- Full editing capabilities
|
|
102
|
-
- Real-time validation
|
|
103
|
-
- Submit button requires all validation to pass
|
|
104
|
-
|
|
105
|
-
**Read-Only Mode**:
|
|
106
|
-
|
|
107
|
-
- Display form data without editing
|
|
108
|
-
- Show file download links
|
|
109
|
-
- Disable all form interactions
|
|
110
|
-
- Support nested object display
|
|
111
|
-
|
|
112
|
-
**Draft Mode**:
|
|
113
|
-
|
|
114
|
-
- Save incomplete forms
|
|
115
|
-
- Skip required field validation
|
|
116
|
-
- Preserve user input
|
|
117
|
-
- Enable resume functionality
|
|
118
|
-
|
|
119
|
-
### 5. Integration Capabilities
|
|
120
|
-
|
|
121
|
-
**MUST support:**
|
|
122
|
-
|
|
123
|
-
- CDN via iframe embedding
|
|
124
|
-
- NPM package installation
|
|
125
|
-
- Direct HTML integration
|
|
126
|
-
- Schema loading via URL parameters
|
|
127
|
-
- Form data prefilling
|
|
128
|
-
- Event-based communication
|
|
129
|
-
|
|
130
|
-
```html
|
|
131
|
-
<!-- CDN Integration -->
|
|
132
|
-
<iframe
|
|
133
|
-
src="https://picazru.github.io/form-builder/dist/index.html"
|
|
134
|
-
width="100%"
|
|
135
|
-
height="600px"
|
|
136
|
-
></iframe>
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### 6. Styling System
|
|
140
|
-
|
|
141
|
-
**MUST use Tailwind CSS** for all styling:
|
|
142
|
-
|
|
143
|
-
- Consistent design system
|
|
144
|
-
- Responsive layouts
|
|
145
|
-
- Dark/light theme support
|
|
146
|
-
- Custom CSS property integration
|
|
147
|
-
- Framework compatibility
|
|
148
|
-
|
|
149
|
-
## Technical Requirements
|
|
150
|
-
|
|
151
|
-
### 1. Architecture
|
|
152
|
-
|
|
153
|
-
**Core Stack:**
|
|
154
|
-
|
|
155
|
-
- HTML5 semantic markup
|
|
156
|
-
- CSS3 with custom properties
|
|
157
|
-
- Vanilla JavaScript (ES6+)
|
|
158
|
-
- Web APIs (FormData, PostMessage, Crypto)
|
|
159
|
-
|
|
160
|
-
**Performance:**
|
|
161
|
-
|
|
162
|
-
- Library size <500KB uncompressed
|
|
163
|
-
- Form rendering <2s for 1000 fields
|
|
164
|
-
- Real-time validation without UI blocking
|
|
165
|
-
|
|
166
|
-
### 2. Browser Support
|
|
167
|
-
|
|
168
|
-
**MUST support:**
|
|
169
|
-
|
|
170
|
-
- Chrome 80+, Firefox 75+, Safari 13+, Edge 80+
|
|
171
|
-
- Mobile browsers with touch interfaces
|
|
172
|
-
- Progressive enhancement for older browsers
|
|
173
|
-
|
|
174
|
-
### 3. Security
|
|
175
|
-
|
|
176
|
-
**MUST implement:**
|
|
177
|
-
|
|
178
|
-
- Input sanitization for all user data
|
|
179
|
-
- File type validation (MIME + extension)
|
|
180
|
-
- Secure resource ID generation
|
|
181
|
-
- CSP-compatible code (no inline scripts)
|
|
182
|
-
- Origin validation for iframe communication
|
|
183
|
-
|
|
184
|
-
### 4. Data Formats
|
|
185
|
-
|
|
186
|
-
**Schema Format (v0.3):**
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
interface FormSchema {
|
|
190
|
-
version: "0.3";
|
|
191
|
-
title: string;
|
|
192
|
-
elements: FormElement[];
|
|
193
|
-
}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
**Output Format:**
|
|
197
|
-
|
|
198
|
-
```json
|
|
199
|
-
{
|
|
200
|
-
"textField": "value",
|
|
201
|
-
"fileField": "res_abc123",
|
|
202
|
-
"multipleFiles": ["res_def456", "res_ghi789"],
|
|
203
|
-
"nestedGroup": {
|
|
204
|
-
"subField": "value"
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## Quality Requirements
|
|
210
|
-
|
|
211
|
-
### Performance Metrics
|
|
212
|
-
|
|
213
|
-
- **Form Rendering**: <2 seconds for 1000 fields
|
|
214
|
-
- **File Upload**: >95% success rate under size limits
|
|
215
|
-
- **Validation Speed**: <100ms per field
|
|
216
|
-
- **Memory Usage**: <50MB for large forms
|
|
217
|
-
|
|
218
|
-
### Reliability
|
|
219
|
-
|
|
220
|
-
- **Browser Compatibility**: >99% success rate on target browsers
|
|
221
|
-
- **Error Recovery**: Graceful fallback for all error conditions
|
|
222
|
-
- **Data Integrity**: No data loss during form interactions
|
|
223
|
-
|
|
224
|
-
### Usability
|
|
225
|
-
|
|
226
|
-
- **Accessibility**: WCAG 2.1 AA compliance
|
|
227
|
-
- **Mobile Support**: Touch-friendly interfaces
|
|
228
|
-
- **Error Messages**: Clear, actionable feedback
|
|
229
|
-
- **Loading States**: Visual feedback for all operations
|
|
230
|
-
|
|
231
|
-
## Deployment Requirements
|
|
232
|
-
|
|
233
|
-
### 1. CDN Distribution
|
|
234
|
-
|
|
235
|
-
- GitHub Pages hosting for global availability
|
|
236
|
-
- Versioned URLs for stable integration
|
|
237
|
-
- Automatic deployment on releases
|
|
238
|
-
|
|
239
|
-
### 2. NPM Package
|
|
240
|
-
|
|
241
|
-
- Published as `@dmitryvim/form-builder`
|
|
242
|
-
- ES6 module support
|
|
243
|
-
- CommonJS compatibility
|
|
244
|
-
- TypeScript definitions
|
|
245
|
-
|
|
246
|
-
### 3. Versioning
|
|
247
|
-
|
|
248
|
-
- Semantic versioning (SemVer)
|
|
249
|
-
- Backwards compatibility within major versions
|
|
250
|
-
- Migration guides for breaking changes
|
|
251
|
-
|
|
252
|
-
## Success Criteria
|
|
253
|
-
|
|
254
|
-
### Acceptance Criteria
|
|
255
|
-
|
|
256
|
-
- [ ] All field types render and validate correctly
|
|
257
|
-
- [ ] File uploads work with custom handlers
|
|
258
|
-
- [ ] Read-only mode displays data properly
|
|
259
|
-
- [ ] Draft saving works without validation
|
|
260
|
-
- [ ] Tailwind CSS styling applies correctly
|
|
261
|
-
- [ ] Cross-browser compatibility verified
|
|
262
|
-
- [ ] > 80% test coverage achieved
|
|
263
|
-
- [ ] Performance benchmarks met
|
|
264
|
-
|
|
265
|
-
### Business Metrics
|
|
266
|
-
|
|
267
|
-
- **Developer Adoption**: Measurable NPM downloads
|
|
268
|
-
- **Integration Success**: Working implementations in production
|
|
269
|
-
- **Performance Goals**: Sub-2-second form rendering
|
|
270
|
-
- **Error Rates**: <1% form submission failures
|
|
271
|
-
|
|
272
|
-
## Constraints & Assumptions
|
|
273
|
-
|
|
274
|
-
### Technical Constraints
|
|
275
|
-
|
|
276
|
-
- No external dependencies allowed
|
|
277
|
-
- Must work in iframe sandboxes
|
|
278
|
-
- File handling delegated to integrating application
|
|
279
|
-
- Cannot make direct network requests (CORS limitations)
|
|
280
|
-
|
|
281
|
-
### Business Constraints
|
|
282
|
-
|
|
283
|
-
- Open source MIT license
|
|
284
|
-
- Community-driven development
|
|
285
|
-
- GitHub-only deployment pipeline
|
|
286
|
-
- No specific backend requirements
|
|
287
|
-
|
|
288
|
-
### Assumptions
|
|
289
|
-
|
|
290
|
-
- Integrating applications handle file storage
|
|
291
|
-
- Modern browser environment (ES6+ support)
|
|
292
|
-
- Developers familiar with JSON Schema concepts
|
|
293
|
-
- Basic understanding of iframe communication
|
|
294
|
-
|
|
295
|
-
## Future Considerations
|
|
296
|
-
|
|
297
|
-
### Potential Enhancements
|
|
298
|
-
|
|
299
|
-
- Conditional field logic (show/hide based on values)
|
|
300
|
-
- Custom field type plugins
|
|
301
|
-
- Advanced file processing (image cropping, etc.)
|
|
302
|
-
- Internationalization support
|
|
303
|
-
- Real-time collaboration features
|
|
304
|
-
|
|
305
|
-
### Not In Scope
|
|
306
|
-
|
|
307
|
-
- Backend file storage implementation
|
|
308
|
-
- Database integration
|
|
309
|
-
- User authentication/authorization
|
|
310
|
-
- Advanced form analytics
|
|
311
|
-
- Multi-page form wizards
|
|
312
|
-
|
|
313
|
-
This requirements document defines the core functionality and quality standards for the Form Builder library, ensuring it meets both current needs and provides a foundation for future growth.
|