@dmitryvim/form-builder 0.1.16 β†’ 0.1.18

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.
@@ -87,35 +87,52 @@ 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
+ console.log('πŸ”§ Prefill keys:', Object.keys(prefill || {}));
92
+ console.log('πŸ”§ Schema element keys:', schema.elements?.map(e => e.key));
93
+
90
94
  const errors = validateSchema(schema);
91
95
  if (errors.length > 0) {
92
96
  console.error('Schema validation errors:', errors);
93
97
  return;
94
98
  }
99
+ console.log('βœ… Schema validation passed');
95
100
 
96
101
  state.schema = schema;
97
102
  if (!state.formRoot) {
98
103
  console.error('No form root element set. Call setFormRoot() first.');
99
104
  return;
100
105
  }
106
+ console.log('βœ… FormRoot is set:', state.formRoot);
101
107
 
102
108
  clear(state.formRoot);
103
109
 
104
110
  const formEl = document.createElement('div');
105
111
  formEl.className = 'space-y-6';
106
112
 
107
- schema.elements.forEach(element => {
113
+ console.log(`πŸ”§ Processing ${schema.elements.length} schema elements`);
114
+ schema.elements.forEach((element, index) => {
115
+ console.log(`πŸ”§ Rendering element ${index}:`, element);
108
116
  const block = renderElement(element, {
109
117
  path: '',
110
118
  prefill: prefill || {}
111
119
  });
120
+ console.log(`βœ… Element ${index} rendered:`, block);
112
121
  formEl.appendChild(block);
113
122
  });
114
123
 
115
124
  state.formRoot.appendChild(formEl);
125
+ console.log(`βœ… Form rendered with ${schema.elements.length} elements`);
116
126
  }
117
127
 
118
128
  function renderElement(element, ctx) {
129
+ console.log(`πŸ”§ renderElement called for '${element.key}':`, {
130
+ elementKey: element.key,
131
+ prefillKeys: Object.keys(ctx.prefill || {}),
132
+ prefillValue: ctx.prefill?.[element.key],
133
+ ctx
134
+ });
135
+
119
136
  const wrapper = document.createElement('div');
120
137
  wrapper.className = 'mb-6';
121
138
 
@@ -180,17 +197,21 @@ function renderElement(element, ctx) {
180
197
 
181
198
  case 'file':
182
199
  // TODO: Extract to renderFileElement() function
200
+ console.log(`πŸ”§ Rendering file element '${element.key}':`, { readonly: state.config.readonly, prefill: ctx.prefill[element.key], element });
183
201
  if (state.config.readonly) {
184
202
  // Readonly mode: use common preview function
185
203
  const initial = ctx.prefill[element.key] || element.default;
204
+ console.log(`πŸ”§ File initial value:`, initial);
186
205
  if (initial) {
187
206
  const filePreview = renderFilePreviewReadonly(initial);
188
207
  wrapper.appendChild(filePreview);
208
+ console.log(`βœ… File preview rendered for '${element.key}'`);
189
209
  } else {
190
210
  const emptyState = document.createElement('div');
191
211
  emptyState.className = 'aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500';
192
212
  emptyState.innerHTML = '<div class="text-center">НСт Ρ„Π°ΠΉΠ»Π°</div>';
193
213
  wrapper.appendChild(emptyState);
214
+ console.log(`❌ No file data for '${element.key}' - showing empty state`);
194
215
  }
195
216
  } else {
196
217
  // Edit mode: normal file input
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.16",
6
+ "version": "0.1.18",
7
7
  "description": "A reusable JSON schema form builder library",
8
8
  "main": "dist/form-builder.js",
9
9
  "files": [