@mieweb/forms-editor 0.1.10 → 0.1.12

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 CHANGED
@@ -6,35 +6,101 @@ Embeddable questionnaire editor with FHIR export and conditional logic.
6
6
  npm install @mieweb/forms-editor react react-dom
7
7
  ```
8
8
 
9
+ ## 🆕 New Features
10
+
11
+ ### YAML & JSON Import
12
+ Import questionnaires from YAML or JSON with automatic format detection:
13
+ - Drag and drop `.json`, `.yaml`, or `.yml` files
14
+ - Auto-detects MIE Forms vs SurveyJS schemas
15
+ - Preserves metadata (title, description, etc.)
16
+
17
+ ### Auto-Parsing on Initialization
18
+ Pass YAML strings, JSON strings, or objects directly:
19
+ ```jsx
20
+ // YAML string
21
+ const yamlData = `
22
+ schemaType: mieforms-v1.0
23
+ fields:
24
+ - id: name
25
+ fieldType: text
26
+ question: Name?
27
+ `;
28
+
29
+ <QuestionnaireEditor initialFormData={yamlData} />
30
+
31
+ // Or JSON string, or parsed object - all work!
32
+ ```
33
+
9
34
  ## Quick Start
10
35
 
11
36
  ```jsx
12
37
  import { QuestionnaireEditor } from '@mieweb/forms-editor';
13
38
 
14
39
  function App() {
15
- const [fields, setFields] = React.useState([
16
- { id: 'section-1', fieldType: 'section', title: 'Section 1', fields: [] },
17
- { id: 'name', fieldType: 'text', question: 'Your Name', required: true },
18
- { id: 'gender', fieldType: 'radio', question: 'Gender',
19
- options: [{ value: 'Male' }, { value: 'Female' }], selected: null },
20
- ]);
40
+ const [formData, setFormData] = React.useState({
41
+ schemaType: 'mieforms-v1.0',
42
+ title: 'Patient Intake',
43
+ fields: [
44
+ { id: 'section-1', fieldType: 'section', title: 'Section 1', fields: [] },
45
+ { id: 'name', fieldType: 'text', question: 'Your Name', required: true },
46
+ { id: 'gender', fieldType: 'radio', question: 'Gender',
47
+ options: [{ value: 'Male' }, { value: 'Female' }], selected: null },
48
+ ]
49
+ });
21
50
 
22
51
  return (
23
- <QuestionnaireEditor initialFields={fields} onChange={setFields} />
52
+ <QuestionnaireEditor
53
+ initialFormData={formData}
54
+ onChange={setFormData}
55
+ />
24
56
  );
25
57
  }
26
58
  ```
27
59
 
28
60
  ## Props
29
61
 
30
- - `initialFields` - Array of field objects
31
- - `onChange` - Callback when fields change
62
+ - `initialFormData` - Form data object or YAML/JSON string (supports auto-parsing)
63
+ - `schemaType` - Optional: `'mieforms'` or `'surveyjs'` (auto-detected if not provided)
64
+ - `onChange` - Callback when form data changes (receives complete form object with metadata)
32
65
  - `startInPreview` - Start in preview mode (default: false)
33
66
  - `hideUnsupportedFields` - Hide unsupported field types (default: false)
34
67
  - `showHeader` - Show editor header (default: true)
35
68
  - `showMobileToolbar` - Show mobile toolbar (default: true)
36
69
  - `className` - Additional CSS classes
37
70
 
71
+ ## 🔄 Breaking Changes (v0.1.1)
72
+
73
+ ### Prop Rename
74
+ ```jsx
75
+ // ❌ Before
76
+ <QuestionnaireEditor initialFields={fields} />
77
+
78
+ // ✅ After
79
+ <QuestionnaireEditor initialFormData={formData} />
80
+ ```
81
+
82
+ ### onChange Callback
83
+ Now receives complete form data object instead of just fields array:
84
+ ```jsx
85
+ // ❌ Before
86
+ onChange={(fields) => console.log(fields)}
87
+
88
+ // ✅ After
89
+ onChange={(formData) => {
90
+ console.log(formData);
91
+ // { schemaType: 'mieforms-v1.0', title: '...', fields: [...] }
92
+ }}
93
+ ```
94
+
95
+ ### Schema Type Required
96
+ Form data must include `schemaType` field:
97
+ ```jsx
98
+ const formData = {
99
+ schemaType: 'mieforms-v1.0', // Required!
100
+ fields: [...]
101
+ };
102
+ ```
103
+
38
104
  ## Features
39
105
 
40
106
  ### Field Types
@@ -52,7 +118,9 @@ function App() {
52
118
  Show/hide fields based on answers via the Logic panel.
53
119
 
54
120
  ### Import/Export
55
- - JSON, YAML, FHIR formats
121
+ - JSON, YAML formats with auto-detection
122
+ - SurveyJS schema import with conversion report
123
+ - FHIR export (via forms-engine)
56
124
 
57
125
  ### Mobile Support
58
126
  Responsive with swipeable modal editing.