form-builder-pro 0.0.10 → 1.0.1
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.css +467 -248
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
- package/dist/index.css.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -4353,6 +4353,29 @@ var formStore = createStore((set, get) => ({
|
|
|
4353
4353
|
historyIndex: historyIndex + 1
|
|
4354
4354
|
});
|
|
4355
4355
|
},
|
|
4356
|
+
addTemplateFields: (targetSectionId, template, index2) => {
|
|
4357
|
+
set((state) => {
|
|
4358
|
+
const sectionIndex = state.schema.sections.findIndex((s) => s.id === targetSectionId);
|
|
4359
|
+
if (sectionIndex === -1)
|
|
4360
|
+
return state;
|
|
4361
|
+
const section = state.schema.sections[sectionIndex];
|
|
4362
|
+
const newFields = template.fields.map(cloneField);
|
|
4363
|
+
const currentFields = [...section.fields];
|
|
4364
|
+
if (typeof index2 === "number" && index2 >= 0) {
|
|
4365
|
+
currentFields.splice(index2, 0, ...newFields);
|
|
4366
|
+
} else {
|
|
4367
|
+
currentFields.push(...newFields);
|
|
4368
|
+
}
|
|
4369
|
+
const newSection = { ...section, fields: currentFields };
|
|
4370
|
+
const newSections = [...state.schema.sections];
|
|
4371
|
+
newSections[sectionIndex] = newSection;
|
|
4372
|
+
return {
|
|
4373
|
+
schema: { ...state.schema, sections: newSections },
|
|
4374
|
+
history: [...state.history.slice(0, state.historyIndex + 1), { ...state.schema, sections: newSections }],
|
|
4375
|
+
historyIndex: state.historyIndex + 1
|
|
4376
|
+
};
|
|
4377
|
+
});
|
|
4378
|
+
},
|
|
4356
4379
|
undo: () => {
|
|
4357
4380
|
const { history, historyIndex } = get();
|
|
4358
4381
|
if (historyIndex > 0) {
|
|
@@ -7552,6 +7575,16 @@ var FormBuilder = class {
|
|
|
7552
7575
|
const type = item.getAttribute("data-type");
|
|
7553
7576
|
const sectionId = list.getAttribute("data-section-id");
|
|
7554
7577
|
if (type && sectionId) {
|
|
7578
|
+
if (type === "template-section") {
|
|
7579
|
+
const templateId = item.getAttribute("data-template-id");
|
|
7580
|
+
const templates = formStore.getState().templates;
|
|
7581
|
+
const template = templates.find((t) => t.id === templateId);
|
|
7582
|
+
item.remove();
|
|
7583
|
+
if (template) {
|
|
7584
|
+
formStore.getState().addTemplateFields(sectionId, template, evt.newIndex);
|
|
7585
|
+
}
|
|
7586
|
+
return;
|
|
7587
|
+
}
|
|
7555
7588
|
item.remove();
|
|
7556
7589
|
formStore.getState().addField(sectionId, type, evt.newIndex);
|
|
7557
7590
|
} else if (sectionId) {
|