@dmitryvim/form-builder 0.3.1 → 0.3.2

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
@@ -289,6 +289,32 @@ Download and serve the `dist/` folder contents.
289
289
 
290
290
  See [Integration Guide](docs/integration.md) for detailed setup instructions.
291
291
 
292
+ ## Hosting Requirements
293
+
294
+ ### Mounting inside hidden or deferred-layout containers
295
+
296
+ `text` and `textarea` (with `autoExpand: true`) fields measure their content height on mount to set an initial size. If the host mounts the form inside a container that has **no real layout at that moment** — e.g. `display: none`, `visibility: hidden`, `width: 0`, an inactive tab, a collapsed accordion, a not-yet-opened modal — the initial measurement reads `scrollHeight === 0` and the textarea would otherwise collapse to its borders (~2 px).
297
+
298
+ **Since v0.3.2 the library recovers automatically**: a width-keyed `ResizeObserver` is attached to every auto-expanding textarea and re-runs the height calculation when the host reveals the container (width transitions `0 → real`) or resizes its column.
299
+
300
+ You still get the smoothest UX by mounting the form **after** the container has its final layout. Two reliable patterns:
301
+
302
+ ```javascript
303
+ // Pattern A — mount on tab/modal open, not on page load
304
+ modal.addEventListener("shown", () => {
305
+ formBuilder.renderForm(rootElement, schema, prefill);
306
+ });
307
+
308
+ // Pattern B — already mounted? Force a re-measure by re-applying prefill.
309
+ // Each updateField call dispatches an `input` event that re-runs
310
+ // the height calculation, even outside of ResizeObserver support.
311
+ panel.addEventListener("visible", () => {
312
+ formBuilder.setFormData(currentValues);
313
+ });
314
+ ```
315
+
316
+ If you are stuck on a browser without `ResizeObserver` (very old) and cannot defer mounting, calling `formBuilder.setFormData(...)` once the form becomes visible is the supported workaround — it triggers a fresh measurement of every text/textarea field.
317
+
292
318
  ## Complete Feature Set
293
319
 
294
320
  ### Field Types
@@ -848,12 +874,12 @@ A display-only element that renders markdown as safe HTML. It never appears in `
848
874
 
849
875
  **Properties:**
850
876
 
851
- | Property | Type | Required | Description |
852
- | ----------- | -------- | -------- | -------------------------------------------------------- |
853
- | `type` | `string` | Yes | Must be `"markdown"` |
854
- | `content` | `string` | Yes | Markdown source text |
855
- | `key` | `string` | No | Optional identifier; field never contributes to form data |
856
- | `enableIf` | object | No | Conditional visibility (same as other field types) |
877
+ | Property | Type | Required | Description |
878
+ | ---------- | -------- | -------- | --------------------------------------------------------- |
879
+ | `type` | `string` | Yes | Must be `"markdown"` |
880
+ | `content` | `string` | Yes | Markdown source text |
881
+ | `key` | `string` | No | Optional identifier; field never contributes to form data |
882
+ | `enableIf` | object | No | Conditional visibility (same as other field types) |
857
883
 
858
884
  **Supported markdown syntax:**
859
885