form-builder-pro 1.2.4 → 1.2.5
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/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -262,6 +262,7 @@ declare class FormBuilder {
|
|
|
262
262
|
private unsubscribe;
|
|
263
263
|
private options;
|
|
264
264
|
private lastRenderedSchemaHash;
|
|
265
|
+
private pendingRenderId;
|
|
265
266
|
constructor(container: HTMLElement, options?: FormBuilderOptions);
|
|
266
267
|
loadForm(json: FormSchema): void;
|
|
267
268
|
cloneForm(json: FormSchema): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -262,6 +262,7 @@ declare class FormBuilder {
|
|
|
262
262
|
private unsubscribe;
|
|
263
263
|
private options;
|
|
264
264
|
private lastRenderedSchemaHash;
|
|
265
|
+
private pendingRenderId;
|
|
265
266
|
constructor(container: HTMLElement, options?: FormBuilderOptions);
|
|
266
267
|
loadForm(json: FormSchema): void;
|
|
267
268
|
cloneForm(json: FormSchema): void;
|
package/dist/index.js
CHANGED
|
@@ -8621,12 +8621,14 @@ var SectionList = class {
|
|
|
8621
8621
|
// src/builder/FormBuilder.ts
|
|
8622
8622
|
var advancedCssPanelState = /* @__PURE__ */ new Map();
|
|
8623
8623
|
var FormBuilder = class {
|
|
8624
|
-
//
|
|
8624
|
+
// For requestAnimationFrame debouncing
|
|
8625
8625
|
constructor(container, options = {}) {
|
|
8626
8626
|
__publicField(this, "container");
|
|
8627
8627
|
__publicField(this, "unsubscribe");
|
|
8628
8628
|
__publicField(this, "options");
|
|
8629
8629
|
__publicField(this, "lastRenderedSchemaHash", "");
|
|
8630
|
+
// Cache to detect meaningful changes
|
|
8631
|
+
__publicField(this, "pendingRenderId", null);
|
|
8630
8632
|
__publicField(this, "activeTab", "fields");
|
|
8631
8633
|
if (!container) {
|
|
8632
8634
|
throw new Error("Builder container not found. Please ensure the container element exists before initializing FormBuilder.");
|
|
@@ -8784,36 +8786,43 @@ var FormBuilder = class {
|
|
|
8784
8786
|
}
|
|
8785
8787
|
setupSubscriptions() {
|
|
8786
8788
|
let lastPreviewMode = null;
|
|
8787
|
-
|
|
8789
|
+
const performRender = () => {
|
|
8790
|
+
this.pendingRenderId = null;
|
|
8788
8791
|
const state = formStore.getState();
|
|
8789
8792
|
const previewModeChanged = lastPreviewMode !== null && lastPreviewMode !== state.isPreviewMode;
|
|
8790
8793
|
lastPreviewMode = state.isPreviewMode;
|
|
8791
8794
|
const schemaHash = JSON.stringify({
|
|
8792
8795
|
sections: state.schema.sections.map((s) => ({
|
|
8793
8796
|
id: s.id,
|
|
8794
|
-
title
|
|
8797
|
+
// Exclude title - prevents re-renders on section name typing
|
|
8795
8798
|
fields: s.fields.map((f) => ({
|
|
8796
8799
|
id: f.id,
|
|
8797
8800
|
type: f.type,
|
|
8798
|
-
label
|
|
8801
|
+
// Exclude label - prevents re-renders on field name typing
|
|
8799
8802
|
layout: f.layout,
|
|
8800
8803
|
width: f.width,
|
|
8801
8804
|
css: f.css
|
|
8802
|
-
// Include css so style changes (textAlign, backgroundColor, etc.) trigger re-render
|
|
8803
|
-
// Exclude frequently changing text (placeholder, etc.) to prevent re-renders on typing
|
|
8804
8805
|
}))
|
|
8805
8806
|
})),
|
|
8806
8807
|
selectedField: state.selectedFieldId,
|
|
8807
8808
|
isPreviewMode: state.isPreviewMode
|
|
8808
|
-
// Include preview mode in hash
|
|
8809
8809
|
});
|
|
8810
8810
|
if (schemaHash !== this.lastRenderedSchemaHash || previewModeChanged) {
|
|
8811
8811
|
this.lastRenderedSchemaHash = schemaHash;
|
|
8812
8812
|
this.render();
|
|
8813
8813
|
}
|
|
8814
|
+
};
|
|
8815
|
+
this.unsubscribe = formStore.subscribe(() => {
|
|
8816
|
+
if (this.pendingRenderId == null) {
|
|
8817
|
+
this.pendingRenderId = requestAnimationFrame(() => performRender.call(this));
|
|
8818
|
+
}
|
|
8814
8819
|
});
|
|
8815
8820
|
}
|
|
8816
8821
|
destroy() {
|
|
8822
|
+
if (this.pendingRenderId != null) {
|
|
8823
|
+
cancelAnimationFrame(this.pendingRenderId);
|
|
8824
|
+
this.pendingRenderId = null;
|
|
8825
|
+
}
|
|
8817
8826
|
this.unsubscribe();
|
|
8818
8827
|
this.container.innerHTML = "";
|
|
8819
8828
|
}
|