@dmitryvim/form-builder 0.1.16 β 0.1.17
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/dist/form-builder.js +15 -1
- package/package.json +1 -1
package/dist/form-builder.js
CHANGED
|
@@ -87,35 +87,45 @@ function validateSchema(schema) {
|
|
|
87
87
|
|
|
88
88
|
// Form rendering
|
|
89
89
|
function renderForm(schema, prefill) {
|
|
90
|
+
console.log('π§ FormBuilder.renderForm called with:', { schema, prefill });
|
|
91
|
+
|
|
90
92
|
const errors = validateSchema(schema);
|
|
91
93
|
if (errors.length > 0) {
|
|
92
94
|
console.error('Schema validation errors:', errors);
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
97
|
+
console.log('β
Schema validation passed');
|
|
95
98
|
|
|
96
99
|
state.schema = schema;
|
|
97
100
|
if (!state.formRoot) {
|
|
98
101
|
console.error('No form root element set. Call setFormRoot() first.');
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
104
|
+
console.log('β
FormRoot is set:', state.formRoot);
|
|
101
105
|
|
|
102
106
|
clear(state.formRoot);
|
|
103
107
|
|
|
104
108
|
const formEl = document.createElement('div');
|
|
105
109
|
formEl.className = 'space-y-6';
|
|
106
110
|
|
|
107
|
-
schema.elements.
|
|
111
|
+
console.log(`π§ Processing ${schema.elements.length} schema elements`);
|
|
112
|
+
schema.elements.forEach((element, index) => {
|
|
113
|
+
console.log(`π§ Rendering element ${index}:`, element);
|
|
108
114
|
const block = renderElement(element, {
|
|
109
115
|
path: '',
|
|
110
116
|
prefill: prefill || {}
|
|
111
117
|
});
|
|
118
|
+
console.log(`β
Element ${index} rendered:`, block);
|
|
112
119
|
formEl.appendChild(block);
|
|
113
120
|
});
|
|
114
121
|
|
|
115
122
|
state.formRoot.appendChild(formEl);
|
|
123
|
+
console.log(`β
Form rendered with ${schema.elements.length} elements`);
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
function renderElement(element, ctx) {
|
|
127
|
+
console.log(`π§ renderElement called:`, { element, ctx });
|
|
128
|
+
|
|
119
129
|
const wrapper = document.createElement('div');
|
|
120
130
|
wrapper.className = 'mb-6';
|
|
121
131
|
|
|
@@ -180,17 +190,21 @@ function renderElement(element, ctx) {
|
|
|
180
190
|
|
|
181
191
|
case 'file':
|
|
182
192
|
// TODO: Extract to renderFileElement() function
|
|
193
|
+
console.log(`π§ Rendering file element '${element.key}':`, { readonly: state.config.readonly, prefill: ctx.prefill[element.key], element });
|
|
183
194
|
if (state.config.readonly) {
|
|
184
195
|
// Readonly mode: use common preview function
|
|
185
196
|
const initial = ctx.prefill[element.key] || element.default;
|
|
197
|
+
console.log(`π§ File initial value:`, initial);
|
|
186
198
|
if (initial) {
|
|
187
199
|
const filePreview = renderFilePreviewReadonly(initial);
|
|
188
200
|
wrapper.appendChild(filePreview);
|
|
201
|
+
console.log(`β
File preview rendered for '${element.key}'`);
|
|
189
202
|
} else {
|
|
190
203
|
const emptyState = document.createElement('div');
|
|
191
204
|
emptyState.className = 'aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500';
|
|
192
205
|
emptyState.innerHTML = '<div class="text-center">ΠΠ΅Ρ ΡΠ°ΠΉΠ»Π°</div>';
|
|
193
206
|
wrapper.appendChild(emptyState);
|
|
207
|
+
console.log(`β No file data for '${element.key}' - showing empty state`);
|
|
194
208
|
}
|
|
195
209
|
} else {
|
|
196
210
|
// Edit mode: normal file input
|