form-builder-pro 1.2.4 → 1.2.6
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 +29 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -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
|
@@ -8620,13 +8620,17 @@ var SectionList = class {
|
|
|
8620
8620
|
|
|
8621
8621
|
// src/builder/FormBuilder.ts
|
|
8622
8622
|
var advancedCssPanelState = /* @__PURE__ */ new Map();
|
|
8623
|
+
var LABEL_DEBOUNCE_MS = 300;
|
|
8624
|
+
var labelUpdateTimeouts = /* @__PURE__ */ new Map();
|
|
8623
8625
|
var FormBuilder = class {
|
|
8624
|
-
//
|
|
8626
|
+
// For requestAnimationFrame debouncing
|
|
8625
8627
|
constructor(container, options = {}) {
|
|
8626
8628
|
__publicField(this, "container");
|
|
8627
8629
|
__publicField(this, "unsubscribe");
|
|
8628
8630
|
__publicField(this, "options");
|
|
8629
8631
|
__publicField(this, "lastRenderedSchemaHash", "");
|
|
8632
|
+
// Cache to detect meaningful changes
|
|
8633
|
+
__publicField(this, "pendingRenderId", null);
|
|
8630
8634
|
__publicField(this, "activeTab", "fields");
|
|
8631
8635
|
if (!container) {
|
|
8632
8636
|
throw new Error("Builder container not found. Please ensure the container element exists before initializing FormBuilder.");
|
|
@@ -8784,14 +8788,15 @@ var FormBuilder = class {
|
|
|
8784
8788
|
}
|
|
8785
8789
|
setupSubscriptions() {
|
|
8786
8790
|
let lastPreviewMode = null;
|
|
8787
|
-
|
|
8791
|
+
const performRender = () => {
|
|
8792
|
+
this.pendingRenderId = null;
|
|
8788
8793
|
const state = formStore.getState();
|
|
8789
8794
|
const previewModeChanged = lastPreviewMode !== null && lastPreviewMode !== state.isPreviewMode;
|
|
8790
8795
|
lastPreviewMode = state.isPreviewMode;
|
|
8791
8796
|
const schemaHash = JSON.stringify({
|
|
8792
8797
|
sections: state.schema.sections.map((s) => ({
|
|
8793
8798
|
id: s.id,
|
|
8794
|
-
title
|
|
8799
|
+
// Exclude title - prevents re-renders on section name typing
|
|
8795
8800
|
fields: s.fields.map((f) => ({
|
|
8796
8801
|
id: f.id,
|
|
8797
8802
|
type: f.type,
|
|
@@ -8799,21 +8804,29 @@ var FormBuilder = class {
|
|
|
8799
8804
|
layout: f.layout,
|
|
8800
8805
|
width: f.width,
|
|
8801
8806
|
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
8807
|
}))
|
|
8805
8808
|
})),
|
|
8806
8809
|
selectedField: state.selectedFieldId,
|
|
8807
8810
|
isPreviewMode: state.isPreviewMode
|
|
8808
|
-
// Include preview mode in hash
|
|
8809
8811
|
});
|
|
8810
8812
|
if (schemaHash !== this.lastRenderedSchemaHash || previewModeChanged) {
|
|
8811
8813
|
this.lastRenderedSchemaHash = schemaHash;
|
|
8812
8814
|
this.render();
|
|
8813
8815
|
}
|
|
8816
|
+
};
|
|
8817
|
+
this.unsubscribe = formStore.subscribe(() => {
|
|
8818
|
+
if (this.pendingRenderId == null) {
|
|
8819
|
+
this.pendingRenderId = requestAnimationFrame(() => performRender.call(this));
|
|
8820
|
+
}
|
|
8814
8821
|
});
|
|
8815
8822
|
}
|
|
8816
8823
|
destroy() {
|
|
8824
|
+
if (this.pendingRenderId != null) {
|
|
8825
|
+
cancelAnimationFrame(this.pendingRenderId);
|
|
8826
|
+
this.pendingRenderId = null;
|
|
8827
|
+
}
|
|
8828
|
+
labelUpdateTimeouts.forEach((id) => clearTimeout(id));
|
|
8829
|
+
labelUpdateTimeouts.clear();
|
|
8817
8830
|
this.unsubscribe();
|
|
8818
8831
|
this.container.innerHTML = "";
|
|
8819
8832
|
}
|
|
@@ -9245,7 +9258,16 @@ var FormBuilder = class {
|
|
|
9245
9258
|
value: selectedField.label,
|
|
9246
9259
|
"data-focus-id": `field-label-${selectedField.id}`,
|
|
9247
9260
|
oninput: (e) => {
|
|
9248
|
-
|
|
9261
|
+
const fieldId2 = selectedField.id;
|
|
9262
|
+
const value = e.target.value;
|
|
9263
|
+
const existing = labelUpdateTimeouts.get(fieldId2);
|
|
9264
|
+
if (existing)
|
|
9265
|
+
clearTimeout(existing);
|
|
9266
|
+
const timeoutId = setTimeout(() => {
|
|
9267
|
+
labelUpdateTimeouts.delete(fieldId2);
|
|
9268
|
+
formStore.getState().updateField(fieldId2, { label: value });
|
|
9269
|
+
}, LABEL_DEBOUNCE_MS);
|
|
9270
|
+
labelUpdateTimeouts.set(fieldId2, timeoutId);
|
|
9249
9271
|
}
|
|
9250
9272
|
}));
|
|
9251
9273
|
body.appendChild(labelGroup);
|