form-builder-pro 1.0.2 → 1.0.4
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 +43 -0
- package/dist/index.d.mts +54 -36
- package/dist/index.d.ts +54 -36
- package/dist/index.js +397 -210
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +397 -210
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4110,17 +4110,17 @@ var FIELD_TYPES = [
|
|
|
4110
4110
|
{ type: "file", label: "File Upload", icon: "Upload" }
|
|
4111
4111
|
];
|
|
4112
4112
|
var DEFAULT_FIELD_CONFIG = {
|
|
4113
|
-
text: { label: "Text Input", placeholder: "Enter text...", width: "100%" },
|
|
4114
|
-
textarea: { label: "Text Area", placeholder: "Enter description...", width: "100%" },
|
|
4115
|
-
number: { label: "Number", placeholder: "0", width: "50%" },
|
|
4116
|
-
email: { label: "Email", placeholder: "example@email.com", width: "100%", validation: [{ type: "email", message: "Invalid email" }] },
|
|
4117
|
-
phone: { label: "Phone", placeholder: "+1 234 567 8900", width: "100%" },
|
|
4118
|
-
date: { label: "Date", width: "50%" },
|
|
4119
|
-
select: { label: "Dropdown", options: [{ label: "Option 1", value: "opt1" }, { label: "Option 2", value: "opt2" }], width: "100%" },
|
|
4120
|
-
checkbox: { label: "Checkbox", width: "100%" },
|
|
4121
|
-
radio: { label: "Radio Group", options: [{ label: "Option 1", value: "opt1" }, { label: "Option 2", value: "opt2" }], width: "100%" },
|
|
4122
|
-
toggle: { label: "Toggle", width: "50%" },
|
|
4123
|
-
file: { label: "File Upload", width: "100%" }
|
|
4113
|
+
text: { label: "Text Input", placeholder: "Enter text...", width: "100%", enabled: true, visible: true },
|
|
4114
|
+
textarea: { label: "Text Area", placeholder: "Enter description...", width: "100%", enabled: true, visible: true },
|
|
4115
|
+
number: { label: "Number", placeholder: "0", width: "50%", enabled: true, visible: true },
|
|
4116
|
+
email: { label: "Email", placeholder: "example@email.com", width: "100%", validation: [{ type: "email", message: "Invalid email" }], enabled: true, visible: true },
|
|
4117
|
+
phone: { label: "Phone", placeholder: "+1 234 567 8900", width: "100%", enabled: true, visible: true },
|
|
4118
|
+
date: { label: "Date", width: "50%", enabled: true, visible: true },
|
|
4119
|
+
select: { label: "Dropdown", options: [{ label: "Option 1", value: "opt1" }, { label: "Option 2", value: "opt2" }], width: "100%", enabled: true, visible: true },
|
|
4120
|
+
checkbox: { label: "Checkbox", width: "100%", enabled: true, visible: true },
|
|
4121
|
+
radio: { label: "Radio Group", options: [{ label: "Option 1", value: "opt1" }, { label: "Option 2", value: "opt2" }], width: "100%", enabled: true, visible: true },
|
|
4122
|
+
toggle: { label: "Toggle", width: "50%", enabled: true, visible: true },
|
|
4123
|
+
file: { label: "File Upload", width: "100%", enabled: true, visible: true }
|
|
4124
4124
|
};
|
|
4125
4125
|
|
|
4126
4126
|
// src/utils/clone.ts
|
|
@@ -4155,13 +4155,7 @@ var INITIAL_SCHEMA = {
|
|
|
4155
4155
|
id: "form_1",
|
|
4156
4156
|
title: "My New Form",
|
|
4157
4157
|
formName: "myNewForm",
|
|
4158
|
-
sections: [
|
|
4159
|
-
{
|
|
4160
|
-
id: generateId(),
|
|
4161
|
-
title: "Section 1",
|
|
4162
|
-
fields: []
|
|
4163
|
-
}
|
|
4164
|
-
]
|
|
4158
|
+
sections: []
|
|
4165
4159
|
};
|
|
4166
4160
|
var formStore = createStore((set, get) => ({
|
|
4167
4161
|
schema: INITIAL_SCHEMA,
|
|
@@ -4171,11 +4165,13 @@ var formStore = createStore((set, get) => ({
|
|
|
4171
4165
|
isPreviewMode: false,
|
|
4172
4166
|
existingForms: [],
|
|
4173
4167
|
templates: [],
|
|
4168
|
+
masterTypes: [],
|
|
4174
4169
|
setSchema: (schema) => set({ schema }),
|
|
4175
4170
|
togglePreview: () => set((state) => ({ isPreviewMode: !state.isPreviewMode })),
|
|
4176
4171
|
// New Actions
|
|
4177
4172
|
setExistingForms: (forms) => set({ existingForms: forms }),
|
|
4178
4173
|
setTemplates: (templates) => set({ templates }),
|
|
4174
|
+
setMasterTypes: (masterTypes) => set({ masterTypes }),
|
|
4179
4175
|
loadForm: (formId) => {
|
|
4180
4176
|
const { existingForms, history, historyIndex } = get();
|
|
4181
4177
|
const found = existingForms.find((f) => f.id === formId);
|
|
@@ -4270,20 +4266,39 @@ var formStore = createStore((set, get) => ({
|
|
|
4270
4266
|
type,
|
|
4271
4267
|
...DEFAULT_FIELD_CONFIG[type]
|
|
4272
4268
|
};
|
|
4269
|
+
let newSections = [...schema.sections];
|
|
4270
|
+
if (newSections.length === 0 || sectionId === null) {
|
|
4271
|
+
const defaultSection = {
|
|
4272
|
+
id: generateId(),
|
|
4273
|
+
title: "Default Section",
|
|
4274
|
+
fields: [],
|
|
4275
|
+
columns: 1
|
|
4276
|
+
};
|
|
4277
|
+
newSections.push(defaultSection);
|
|
4278
|
+
sectionId = defaultSection.id;
|
|
4279
|
+
}
|
|
4280
|
+
const sectionIndex = newSections.findIndex((s) => s.id === sectionId);
|
|
4281
|
+
if (sectionIndex !== -1) {
|
|
4282
|
+
const section = newSections[sectionIndex];
|
|
4283
|
+
const newFields = [...section.fields];
|
|
4284
|
+
if (typeof index2 === "number") {
|
|
4285
|
+
newFields.splice(index2, 0, newField);
|
|
4286
|
+
} else {
|
|
4287
|
+
newFields.push(newField);
|
|
4288
|
+
}
|
|
4289
|
+
newSections[sectionIndex] = { ...section, fields: newFields };
|
|
4290
|
+
} else {
|
|
4291
|
+
const defaultSection = {
|
|
4292
|
+
id: generateId(),
|
|
4293
|
+
title: "Default Section",
|
|
4294
|
+
fields: [newField],
|
|
4295
|
+
columns: 1
|
|
4296
|
+
};
|
|
4297
|
+
newSections.push(defaultSection);
|
|
4298
|
+
}
|
|
4273
4299
|
const newSchema = {
|
|
4274
4300
|
...schema,
|
|
4275
|
-
sections:
|
|
4276
|
-
if (s.id === sectionId) {
|
|
4277
|
-
const newFields = [...s.fields];
|
|
4278
|
-
if (typeof index2 === "number") {
|
|
4279
|
-
newFields.splice(index2, 0, newField);
|
|
4280
|
-
} else {
|
|
4281
|
-
newFields.push(newField);
|
|
4282
|
-
}
|
|
4283
|
-
return { ...s, fields: newFields };
|
|
4284
|
-
}
|
|
4285
|
-
return s;
|
|
4286
|
-
})
|
|
4301
|
+
sections: newSections
|
|
4287
4302
|
};
|
|
4288
4303
|
set({
|
|
4289
4304
|
schema: newSchema,
|
|
@@ -4339,6 +4354,16 @@ var formStore = createStore((set, get) => ({
|
|
|
4339
4354
|
});
|
|
4340
4355
|
if (!field)
|
|
4341
4356
|
return;
|
|
4357
|
+
if (targetSectionId === null || newSections.length === 0) {
|
|
4358
|
+
const defaultSection = {
|
|
4359
|
+
id: generateId(),
|
|
4360
|
+
title: "Default Section",
|
|
4361
|
+
fields: [],
|
|
4362
|
+
columns: 1
|
|
4363
|
+
};
|
|
4364
|
+
newSections.push(defaultSection);
|
|
4365
|
+
targetSectionId = defaultSection.id;
|
|
4366
|
+
}
|
|
4342
4367
|
const targetSectionIndex = newSections.findIndex((s) => s.id === targetSectionId);
|
|
4343
4368
|
if (targetSectionIndex !== -1) {
|
|
4344
4369
|
const targetSection = newSections[targetSectionIndex];
|
|
@@ -4497,6 +4522,7 @@ function getIcon(name, size = 20) {
|
|
|
4497
4522
|
var FieldRenderer = class {
|
|
4498
4523
|
static render(field, value, onChange, readOnly = false) {
|
|
4499
4524
|
const wrapper = createElement("div", { className: "w-full" });
|
|
4525
|
+
const isEnabled = field.enabled !== false && !readOnly;
|
|
4500
4526
|
if (field.type !== "checkbox") {
|
|
4501
4527
|
const label = createElement("label", {
|
|
4502
4528
|
className: "text-xs sm:text-sm font-medium leading-none mb-2 block text-gray-900 dark:text-gray-100",
|
|
@@ -4523,7 +4549,7 @@ var FieldRenderer = class {
|
|
|
4523
4549
|
className: "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm sm:text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4524
4550
|
placeholder: field.placeholder,
|
|
4525
4551
|
value: value || "",
|
|
4526
|
-
disabled:
|
|
4552
|
+
disabled: !isEnabled,
|
|
4527
4553
|
oninput: (e) => onChange?.(e.target.value)
|
|
4528
4554
|
});
|
|
4529
4555
|
break;
|
|
@@ -4531,7 +4557,7 @@ var FieldRenderer = class {
|
|
|
4531
4557
|
input = createElement("select", {
|
|
4532
4558
|
className: "flex min-h-touch w-full rounded-md border border-input bg-background px-3 py-2 text-sm sm:text-base ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4533
4559
|
value: value || "",
|
|
4534
|
-
disabled:
|
|
4560
|
+
disabled: !isEnabled,
|
|
4535
4561
|
onchange: (e) => onChange?.(e.target.value)
|
|
4536
4562
|
});
|
|
4537
4563
|
input.appendChild(createElement("option", { value: "", text: "Select an option", disabled: true, selected: !value }));
|
|
@@ -4545,7 +4571,7 @@ var FieldRenderer = class {
|
|
|
4545
4571
|
type: "checkbox",
|
|
4546
4572
|
className: "h-5 w-5 sm:h-6 sm:w-6 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer",
|
|
4547
4573
|
checked: !!value,
|
|
4548
|
-
disabled:
|
|
4574
|
+
disabled: !isEnabled,
|
|
4549
4575
|
onchange: (e) => onChange?.(e.target.checked)
|
|
4550
4576
|
});
|
|
4551
4577
|
input.appendChild(checkbox);
|
|
@@ -4559,7 +4585,7 @@ var FieldRenderer = class {
|
|
|
4559
4585
|
name: field.id,
|
|
4560
4586
|
value: opt.value,
|
|
4561
4587
|
checked: value === opt.value,
|
|
4562
|
-
disabled:
|
|
4588
|
+
disabled: !isEnabled,
|
|
4563
4589
|
className: "aspect-square h-4 w-4 sm:h-5 sm:w-5 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4564
4590
|
onchange: (e) => onChange?.(e.target.value)
|
|
4565
4591
|
});
|
|
@@ -4578,7 +4604,7 @@ var FieldRenderer = class {
|
|
|
4578
4604
|
className: "flex min-h-touch w-full rounded-md border border-input bg-background px-3 py-2 text-sm sm:text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4579
4605
|
placeholder: field.placeholder,
|
|
4580
4606
|
value: value || "",
|
|
4581
|
-
disabled:
|
|
4607
|
+
disabled: !isEnabled,
|
|
4582
4608
|
oninput: (e) => onChange?.(e.target.value)
|
|
4583
4609
|
});
|
|
4584
4610
|
}
|
|
@@ -4615,6 +4641,10 @@ var FormRenderer = class {
|
|
|
4615
4641
|
sectionEl.appendChild(createElement("h2", { className: "text-lg md:text-xl font-semibold text-gray-800 dark:text-gray-200 border-b pb-2", text: section.title }));
|
|
4616
4642
|
const grid = createElement("div", { className: "form-builder-grid" });
|
|
4617
4643
|
section.fields.forEach((field) => {
|
|
4644
|
+
const isVisible = field.visible !== false;
|
|
4645
|
+
if (!isVisible) {
|
|
4646
|
+
return;
|
|
4647
|
+
}
|
|
4618
4648
|
const fieldWrapper = createElement("div");
|
|
4619
4649
|
let spanClass = "col-span-12";
|
|
4620
4650
|
if (field.width === "50%")
|
|
@@ -6900,6 +6930,266 @@ Sortable.mount(new AutoScrollPlugin());
|
|
|
6900
6930
|
Sortable.mount(Remove, Revert);
|
|
6901
6931
|
var sortable_esm_default = Sortable;
|
|
6902
6932
|
|
|
6933
|
+
// src/builder/FieldWrapper.ts
|
|
6934
|
+
var FieldWrapper = class {
|
|
6935
|
+
static render(field, isSelected) {
|
|
6936
|
+
const isVisible = field.visible !== false;
|
|
6937
|
+
let spanClass = "col-span-12";
|
|
6938
|
+
if (field.width === "50%")
|
|
6939
|
+
spanClass = "col-span-6";
|
|
6940
|
+
else if (field.width === "33%")
|
|
6941
|
+
spanClass = "col-span-4";
|
|
6942
|
+
else if (field.width === "25%")
|
|
6943
|
+
spanClass = "col-span-3";
|
|
6944
|
+
else if (field.width === "66%")
|
|
6945
|
+
spanClass = "col-span-8";
|
|
6946
|
+
else if (field.width === "75%")
|
|
6947
|
+
spanClass = "col-span-9";
|
|
6948
|
+
const fieldWrapper = createElement("div", {
|
|
6949
|
+
className: `form-builder-field-wrapper ${isSelected ? "selected-field" : ""} ${spanClass} relative group border border-transparent hover:border-blue-200 rounded-md transition-all ${!isVisible ? "hidden" : ""}`,
|
|
6950
|
+
"data-id": field.id,
|
|
6951
|
+
onclick: (e) => {
|
|
6952
|
+
e.stopPropagation();
|
|
6953
|
+
formStore.getState().selectField(field.id);
|
|
6954
|
+
}
|
|
6955
|
+
});
|
|
6956
|
+
if (isSelected) {
|
|
6957
|
+
fieldWrapper.classList.add("ring-2", "ring-blue-500", "bg-blue-50", "dark:bg-blue-900/20");
|
|
6958
|
+
}
|
|
6959
|
+
fieldWrapper.appendChild(createElement("div", {
|
|
6960
|
+
className: `absolute top-2 left-2 cursor-move p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 opacity-0 group-hover:opacity-100 transition-opacity field-handle z-10 ${isSelected ? "opacity-100" : ""}`
|
|
6961
|
+
}, [getIcon("GripVertical", 16)]));
|
|
6962
|
+
fieldWrapper.appendChild(createElement("button", {
|
|
6963
|
+
className: `absolute top-2 right-2 p-1 rounded hover:bg-red-50 text-red-400 hover:text-red-600 opacity-0 group-hover:opacity-100 transition-opacity z-10 ${isSelected ? "opacity-100" : ""}`,
|
|
6964
|
+
onclick: (e) => {
|
|
6965
|
+
e.stopPropagation();
|
|
6966
|
+
if (confirm("Delete this field?")) {
|
|
6967
|
+
formStore.getState().removeField(field.id);
|
|
6968
|
+
}
|
|
6969
|
+
}
|
|
6970
|
+
}, [getIcon("Trash2", 16)]));
|
|
6971
|
+
const content = createElement("div", { className: "p-4 pointer-events-none" });
|
|
6972
|
+
content.appendChild(FieldRenderer.render(field, null, void 0, true));
|
|
6973
|
+
fieldWrapper.appendChild(content);
|
|
6974
|
+
return fieldWrapper;
|
|
6975
|
+
}
|
|
6976
|
+
};
|
|
6977
|
+
|
|
6978
|
+
// src/builder/Section.ts
|
|
6979
|
+
var Section = class {
|
|
6980
|
+
constructor(section, isSelectedField) {
|
|
6981
|
+
__publicField(this, "container");
|
|
6982
|
+
__publicField(this, "section");
|
|
6983
|
+
__publicField(this, "isSelectedField");
|
|
6984
|
+
this.section = section;
|
|
6985
|
+
this.isSelectedField = isSelectedField;
|
|
6986
|
+
this.container = this.render();
|
|
6987
|
+
}
|
|
6988
|
+
getElement() {
|
|
6989
|
+
return this.container;
|
|
6990
|
+
}
|
|
6991
|
+
render() {
|
|
6992
|
+
const sectionEl = createElement("div", {
|
|
6993
|
+
className: "mb-6 rounded-lg border bg-white dark:bg-gray-900 shadow-sm transition-all border-gray-200 dark:border-gray-800",
|
|
6994
|
+
"data-id": this.section.id
|
|
6995
|
+
});
|
|
6996
|
+
const header = createElement("div", { className: "flex items-center justify-between p-2 border-b border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-800/50 rounded-t-lg" });
|
|
6997
|
+
const headerLeft = createElement("div", { className: "flex items-center flex-1" });
|
|
6998
|
+
headerLeft.appendChild(createElement("div", { className: "cursor-move mr-3 text-gray-400 hover:text-gray-600 section-handle" }, [getIcon("GripVertical", 20)]));
|
|
6999
|
+
headerLeft.appendChild(createElement("input", {
|
|
7000
|
+
className: "bg-transparent font-semibold text-gray-700 dark:text-gray-200 focus:outline-none focus:border-b border-blue-500",
|
|
7001
|
+
value: this.section.title,
|
|
7002
|
+
"data-focus-id": `section-title-${this.section.id}`,
|
|
7003
|
+
oninput: (e) => formStore.getState().updateSection(this.section.id, { title: e.target.value })
|
|
7004
|
+
}));
|
|
7005
|
+
header.appendChild(headerLeft);
|
|
7006
|
+
const actions = createElement("div", { className: "flex items-center space-x-1" });
|
|
7007
|
+
const colSelect = createElement("select", {
|
|
7008
|
+
className: "text-xs border rounded bg-transparent mr-2 p-1 text-gray-600",
|
|
7009
|
+
title: "Section Columns",
|
|
7010
|
+
onchange: (e) => {
|
|
7011
|
+
formStore.getState().updateSection(this.section.id, { columns: parseInt(e.target.value) });
|
|
7012
|
+
}
|
|
7013
|
+
});
|
|
7014
|
+
[1, 2, 3].forEach((c) => {
|
|
7015
|
+
colSelect.appendChild(createElement("option", { value: c.toString(), text: `${c} Col`, selected: (this.section.columns || 1) === c }));
|
|
7016
|
+
});
|
|
7017
|
+
actions.appendChild(colSelect);
|
|
7018
|
+
actions.appendChild(createElement("button", {
|
|
7019
|
+
className: "text-gray-600 hover:text-red-500 transition-colors p-1",
|
|
7020
|
+
onclick: () => {
|
|
7021
|
+
if (confirm("Delete this section and all its fields?")) {
|
|
7022
|
+
formStore.getState().removeSection(this.section.id);
|
|
7023
|
+
}
|
|
7024
|
+
}
|
|
7025
|
+
}, [getIcon("Trash2", 18)]));
|
|
7026
|
+
header.appendChild(actions);
|
|
7027
|
+
sectionEl.appendChild(header);
|
|
7028
|
+
const fieldsGrid = createElement("div", {
|
|
7029
|
+
className: "form-builder-grid p-4 min-h-[100px] fields-list",
|
|
7030
|
+
"data-section-id": this.section.id
|
|
7031
|
+
});
|
|
7032
|
+
if (this.section.fields.length === 0) {
|
|
7033
|
+
fieldsGrid.classList.add("flex", "justify-center", "items-center", "border-2", "border-dashed", "border-gray-100", "dark:border-gray-800", "m-4", "rounded");
|
|
7034
|
+
fieldsGrid.appendChild(createElement("div", { className: "text-gray-400 text-sm py-4", text: "Drop fields here" }));
|
|
7035
|
+
}
|
|
7036
|
+
this.section.fields.forEach((field) => {
|
|
7037
|
+
const isSelected = this.isSelectedField(field.id);
|
|
7038
|
+
fieldsGrid.appendChild(FieldWrapper.render(field, isSelected));
|
|
7039
|
+
});
|
|
7040
|
+
sectionEl.appendChild(fieldsGrid);
|
|
7041
|
+
this.initFieldSortable(fieldsGrid);
|
|
7042
|
+
return sectionEl;
|
|
7043
|
+
}
|
|
7044
|
+
initFieldSortable(element) {
|
|
7045
|
+
new sortable_esm_default(element, {
|
|
7046
|
+
group: {
|
|
7047
|
+
name: "shared-fields",
|
|
7048
|
+
put: ["shared-fields", "shared-templates"]
|
|
7049
|
+
// Allow dropping templates to merge fields
|
|
7050
|
+
},
|
|
7051
|
+
handle: ".field-handle",
|
|
7052
|
+
animation: 150,
|
|
7053
|
+
ghostClass: "bg-blue-50",
|
|
7054
|
+
// Class to apply to the drag ghost
|
|
7055
|
+
onAdd: (evt) => {
|
|
7056
|
+
const item = evt.item;
|
|
7057
|
+
const type = item.getAttribute("data-type");
|
|
7058
|
+
evt.from.getAttribute("data-section-id");
|
|
7059
|
+
const toSectionId = this.section.id;
|
|
7060
|
+
if (type && !item.hasAttribute("data-id")) {
|
|
7061
|
+
item.remove();
|
|
7062
|
+
if (type === "template-section") {
|
|
7063
|
+
const templateId = item.getAttribute("data-template-id");
|
|
7064
|
+
const templates = formStore.getState().templates;
|
|
7065
|
+
const template = templates.find((t) => t.id === templateId);
|
|
7066
|
+
if (template) {
|
|
7067
|
+
formStore.getState().addTemplateFields(toSectionId, template, evt.newIndex);
|
|
7068
|
+
}
|
|
7069
|
+
return;
|
|
7070
|
+
}
|
|
7071
|
+
formStore.getState().addField(toSectionId, type, evt.newIndex);
|
|
7072
|
+
} else {
|
|
7073
|
+
const fieldId = item.getAttribute("data-id");
|
|
7074
|
+
if (fieldId) {
|
|
7075
|
+
formStore.getState().moveField(fieldId, toSectionId, evt.newIndex);
|
|
7076
|
+
item.remove();
|
|
7077
|
+
}
|
|
7078
|
+
}
|
|
7079
|
+
},
|
|
7080
|
+
onUpdate: (evt) => {
|
|
7081
|
+
const item = evt.item;
|
|
7082
|
+
const fieldId = item.getAttribute("data-id");
|
|
7083
|
+
if (fieldId && evt.newIndex !== void 0) {
|
|
7084
|
+
formStore.getState().moveField(fieldId, this.section.id, evt.newIndex);
|
|
7085
|
+
}
|
|
7086
|
+
}
|
|
7087
|
+
});
|
|
7088
|
+
}
|
|
7089
|
+
};
|
|
7090
|
+
|
|
7091
|
+
// src/builder/SectionList.ts
|
|
7092
|
+
var SectionList = class {
|
|
7093
|
+
constructor(schema, selectedFieldId) {
|
|
7094
|
+
__publicField(this, "container");
|
|
7095
|
+
__publicField(this, "schema");
|
|
7096
|
+
__publicField(this, "selectedFieldId");
|
|
7097
|
+
this.schema = schema;
|
|
7098
|
+
this.selectedFieldId = selectedFieldId;
|
|
7099
|
+
this.container = this.render();
|
|
7100
|
+
}
|
|
7101
|
+
getElement() {
|
|
7102
|
+
return this.container;
|
|
7103
|
+
}
|
|
7104
|
+
render() {
|
|
7105
|
+
const listContainer = createElement("div", {
|
|
7106
|
+
className: "space-y-6 min-h-[200px] pb-20",
|
|
7107
|
+
// pb-20 for extra scrolling space
|
|
7108
|
+
id: "sections-list",
|
|
7109
|
+
"data-drop-zone": "sections"
|
|
7110
|
+
});
|
|
7111
|
+
const hasNoSections = this.schema.sections.length === 0;
|
|
7112
|
+
if (hasNoSections) {
|
|
7113
|
+
const placeholder = createElement("div", {
|
|
7114
|
+
className: "border-2 border-dashed border-gray-300 dark:border-gray-700 rounded-lg p-8 text-center text-gray-500 flex flex-col items-center justify-center min-h-[200px] bg-gray-50 dark:bg-gray-800/50 empty-fields-dropzone",
|
|
7115
|
+
id: "empty-fields-dropzone"
|
|
7116
|
+
});
|
|
7117
|
+
placeholder.appendChild(createElement("div", { className: "font-medium mb-2", text: "Start Building Your Form" }));
|
|
7118
|
+
placeholder.appendChild(createElement("div", { className: "text-sm text-gray-400", text: 'Drag fields from the sidebar or click "Add Section" below.' }));
|
|
7119
|
+
listContainer.appendChild(placeholder);
|
|
7120
|
+
}
|
|
7121
|
+
this.schema.sections.forEach((section) => {
|
|
7122
|
+
const sectionComponent = new Section(section, (id) => id === this.selectedFieldId);
|
|
7123
|
+
listContainer.appendChild(sectionComponent.getElement());
|
|
7124
|
+
});
|
|
7125
|
+
this.initSectionSortable(listContainer, hasNoSections);
|
|
7126
|
+
return listContainer;
|
|
7127
|
+
}
|
|
7128
|
+
initSectionSortable(element, hasNoSections) {
|
|
7129
|
+
if (hasNoSections) {
|
|
7130
|
+
const emptyDropzone = element.querySelector("#empty-fields-dropzone");
|
|
7131
|
+
if (emptyDropzone) {
|
|
7132
|
+
new sortable_esm_default(emptyDropzone, {
|
|
7133
|
+
group: {
|
|
7134
|
+
name: "shared-fields",
|
|
7135
|
+
put: ["shared-fields", "shared-templates"]
|
|
7136
|
+
},
|
|
7137
|
+
animation: 150,
|
|
7138
|
+
ghostClass: "bg-blue-50",
|
|
7139
|
+
onAdd: (evt) => {
|
|
7140
|
+
const item = evt.item;
|
|
7141
|
+
const type = item.getAttribute("data-type");
|
|
7142
|
+
const templateId = item.getAttribute("data-template-id");
|
|
7143
|
+
item.remove();
|
|
7144
|
+
if (templateId) {
|
|
7145
|
+
const templates = formStore.getState().templates;
|
|
7146
|
+
const template = templates.find((t) => t.id === templateId);
|
|
7147
|
+
if (template) {
|
|
7148
|
+
formStore.getState().importSection(template);
|
|
7149
|
+
}
|
|
7150
|
+
} else if (type && !item.hasAttribute("data-id")) {
|
|
7151
|
+
formStore.getState().addField(null, type, evt.newIndex);
|
|
7152
|
+
} else {
|
|
7153
|
+
const fieldId = item.getAttribute("data-id");
|
|
7154
|
+
if (fieldId) {
|
|
7155
|
+
formStore.getState().moveField(fieldId, null, evt.newIndex || 0);
|
|
7156
|
+
}
|
|
7157
|
+
}
|
|
7158
|
+
}
|
|
7159
|
+
});
|
|
7160
|
+
}
|
|
7161
|
+
} else {
|
|
7162
|
+
new sortable_esm_default(element, {
|
|
7163
|
+
group: {
|
|
7164
|
+
name: "shared-sections",
|
|
7165
|
+
put: ["shared-templates"]
|
|
7166
|
+
// Allow dropping templates here
|
|
7167
|
+
},
|
|
7168
|
+
handle: ".section-handle",
|
|
7169
|
+
animation: 150,
|
|
7170
|
+
ghostClass: "opacity-50",
|
|
7171
|
+
onAdd: (evt) => {
|
|
7172
|
+
const item = evt.item;
|
|
7173
|
+
const templateId = item.getAttribute("data-template-id");
|
|
7174
|
+
if (templateId) {
|
|
7175
|
+
const templates = formStore.getState().templates;
|
|
7176
|
+
const template = templates.find((t) => t.id === templateId);
|
|
7177
|
+
item.remove();
|
|
7178
|
+
if (template) {
|
|
7179
|
+
formStore.getState().importSection(template);
|
|
7180
|
+
}
|
|
7181
|
+
}
|
|
7182
|
+
},
|
|
7183
|
+
onUpdate: (evt) => {
|
|
7184
|
+
if (evt.oldIndex !== void 0 && evt.newIndex !== void 0) {
|
|
7185
|
+
formStore.getState().moveSection(evt.oldIndex, evt.newIndex);
|
|
7186
|
+
}
|
|
7187
|
+
}
|
|
7188
|
+
});
|
|
7189
|
+
}
|
|
7190
|
+
}
|
|
7191
|
+
};
|
|
7192
|
+
|
|
6903
7193
|
// src/builder/FormBuilder.ts
|
|
6904
7194
|
var FormBuilder = class {
|
|
6905
7195
|
constructor(container, options = {}) {
|
|
@@ -6933,6 +7223,9 @@ var FormBuilder = class {
|
|
|
6933
7223
|
if (options.formJson) {
|
|
6934
7224
|
formStore.getState().setSchema(options.formJson);
|
|
6935
7225
|
} else if (options.mode === "create") ;
|
|
7226
|
+
if (options.data?.masterTypes) {
|
|
7227
|
+
formStore.getState().setMasterTypes(options.data.masterTypes);
|
|
7228
|
+
}
|
|
6936
7229
|
this.render();
|
|
6937
7230
|
this.setupSubscriptions();
|
|
6938
7231
|
}
|
|
@@ -7037,7 +7330,7 @@ var FormBuilder = class {
|
|
|
7037
7330
|
}, 0);
|
|
7038
7331
|
}
|
|
7039
7332
|
if (!state.isPreviewMode) {
|
|
7040
|
-
this.
|
|
7333
|
+
this.initSidebarSortables();
|
|
7041
7334
|
}
|
|
7042
7335
|
}
|
|
7043
7336
|
renderToolbar(state) {
|
|
@@ -7234,98 +7527,8 @@ var FormBuilder = class {
|
|
|
7234
7527
|
oninput: (e) => formStore.getState().setSchema({ ...state.schema, formName: e.target.value })
|
|
7235
7528
|
});
|
|
7236
7529
|
inner.appendChild(formNameInput);
|
|
7237
|
-
const
|
|
7238
|
-
|
|
7239
|
-
id: "sections-list",
|
|
7240
|
-
"data-drop-zone": "sections"
|
|
7241
|
-
});
|
|
7242
|
-
state.schema.sections.forEach((section) => {
|
|
7243
|
-
const sectionEl = createElement("div", {
|
|
7244
|
-
className: "mb-6 rounded-lg border bg-white dark:bg-gray-900 shadow-sm transition-all border-gray-200 dark:border-gray-800",
|
|
7245
|
-
"data-id": section.id
|
|
7246
|
-
});
|
|
7247
|
-
const header = createElement("div", { className: "flex items-center justify-between p-2 border-b border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-800/50 rounded-t-lg" });
|
|
7248
|
-
const headerLeft = createElement("div", { className: "flex items-center flex-1" });
|
|
7249
|
-
headerLeft.appendChild(createElement("div", { className: "cursor-move mr-3 text-gray-400 hover:text-gray-600 section-handle" }, [getIcon("GripVertical", 20)]));
|
|
7250
|
-
headerLeft.appendChild(createElement("input", {
|
|
7251
|
-
className: "bg-transparent font-semibold text-gray-700 dark:text-gray-200 focus:outline-none focus:border-b border-blue-500",
|
|
7252
|
-
value: section.title,
|
|
7253
|
-
"data-focus-id": `section-title-${section.id}`,
|
|
7254
|
-
oninput: (e) => formStore.getState().updateSection(section.id, { title: e.target.value })
|
|
7255
|
-
}));
|
|
7256
|
-
header.appendChild(headerLeft);
|
|
7257
|
-
const actions = createElement("div", { className: "flex items-center space-x-1" });
|
|
7258
|
-
const colSelect = createElement("select", {
|
|
7259
|
-
className: "text-xs border rounded bg-transparent mr-2 p-1 text-gray-600",
|
|
7260
|
-
title: "Section Columns",
|
|
7261
|
-
onchange: (e) => {
|
|
7262
|
-
formStore.getState().updateSection(section.id, { columns: parseInt(e.target.value) });
|
|
7263
|
-
}
|
|
7264
|
-
});
|
|
7265
|
-
[1, 2, 3].forEach((c) => {
|
|
7266
|
-
colSelect.appendChild(createElement("option", { value: c.toString(), text: `${c} Col`, selected: (section.columns || 1) === c }));
|
|
7267
|
-
});
|
|
7268
|
-
actions.appendChild(colSelect);
|
|
7269
|
-
actions.appendChild(createElement("button", {
|
|
7270
|
-
className: "text-gray-600 hover:text-blue-500 transition-colors p-1",
|
|
7271
|
-
title: "Save as Template",
|
|
7272
|
-
onclick: () => {
|
|
7273
|
-
const name = prompt("Enter template name:", section.title);
|
|
7274
|
-
if (name) {
|
|
7275
|
-
this.saveSectionAsTemplate({ ...section, title: name });
|
|
7276
|
-
}
|
|
7277
|
-
}
|
|
7278
|
-
}, [getIcon("Save", 18)]));
|
|
7279
|
-
actions.appendChild(createElement("button", {
|
|
7280
|
-
className: "text-gray-600 hover:text-red-500 transition-colors p-1",
|
|
7281
|
-
onclick: () => formStore.getState().removeSection(section.id)
|
|
7282
|
-
}, [getIcon("Trash2", 18)]));
|
|
7283
|
-
header.appendChild(actions);
|
|
7284
|
-
sectionEl.appendChild(header);
|
|
7285
|
-
const fieldsGrid = createElement("div", {
|
|
7286
|
-
className: "form-builder-grid p-4 min-h-[100px] fields-list",
|
|
7287
|
-
"data-section-id": section.id
|
|
7288
|
-
});
|
|
7289
|
-
section.fields.forEach((field) => {
|
|
7290
|
-
const isSelected = state.selectedFieldId === field.id;
|
|
7291
|
-
let spanClass = "col-span-12";
|
|
7292
|
-
if (field.width === "50%")
|
|
7293
|
-
spanClass = "col-span-6";
|
|
7294
|
-
else if (field.width === "33%")
|
|
7295
|
-
spanClass = "col-span-4";
|
|
7296
|
-
else if (field.width === "25%")
|
|
7297
|
-
spanClass = "col-span-3";
|
|
7298
|
-
else if (field.width === "66%")
|
|
7299
|
-
spanClass = "col-span-8";
|
|
7300
|
-
else if (field.width === "75%")
|
|
7301
|
-
spanClass = "col-span-9";
|
|
7302
|
-
const fieldWrapper = createElement("div", {
|
|
7303
|
-
className: `form-builder-field-wrapper ${isSelected ? "selected-field" : ""} ${spanClass}`,
|
|
7304
|
-
"data-id": field.id,
|
|
7305
|
-
onclick: (e) => {
|
|
7306
|
-
e.stopPropagation();
|
|
7307
|
-
formStore.getState().selectField(field.id);
|
|
7308
|
-
}
|
|
7309
|
-
});
|
|
7310
|
-
fieldWrapper.appendChild(createElement("div", {
|
|
7311
|
-
className: `absolute top-2 left-2 cursor-move p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 opacity-0 group-hover:opacity-100 transition-opacity field-handle ${isSelected ? "opacity-100" : ""}`
|
|
7312
|
-
}, [getIcon("GripVertical", 16)]));
|
|
7313
|
-
fieldWrapper.appendChild(createElement("button", {
|
|
7314
|
-
className: `absolute top-2 right-2 p-1 rounded hover:bg-red-50 text-red-400 hover:text-red-600 opacity-0 group-hover:opacity-100 transition-opacity ${isSelected ? "opacity-100" : ""}`,
|
|
7315
|
-
onclick: (e) => {
|
|
7316
|
-
e.stopPropagation();
|
|
7317
|
-
formStore.getState().removeField(field.id);
|
|
7318
|
-
}
|
|
7319
|
-
}, [getIcon("Trash2", 16)]));
|
|
7320
|
-
const content = createElement("div", { className: "p-4 pointer-events-none" });
|
|
7321
|
-
content.appendChild(FieldRenderer.render(field, null, void 0, true));
|
|
7322
|
-
fieldWrapper.appendChild(content);
|
|
7323
|
-
fieldsGrid.appendChild(fieldWrapper);
|
|
7324
|
-
});
|
|
7325
|
-
sectionEl.appendChild(fieldsGrid);
|
|
7326
|
-
sectionsContainer.appendChild(sectionEl);
|
|
7327
|
-
});
|
|
7328
|
-
inner.appendChild(sectionsContainer);
|
|
7530
|
+
const sectionList = new SectionList(state.schema, state.selectedFieldId);
|
|
7531
|
+
inner.appendChild(sectionList.getElement());
|
|
7329
7532
|
const addSectionBtn = createElement("button", {
|
|
7330
7533
|
className: "w-full mt-6 py-4 border-2 border-dashed border-gray-300 dark:border-gray-700 rounded-lg text-gray-500 hover:border-blue-500 hover:text-blue-500 transition-colors flex items-center justify-center font-medium",
|
|
7331
7534
|
onclick: () => formStore.getState().addSection()
|
|
@@ -7387,6 +7590,68 @@ var FormBuilder = class {
|
|
|
7387
7590
|
onchange: (e) => formStore.getState().updateField(selectedField.id, { required: e.target.checked })
|
|
7388
7591
|
}));
|
|
7389
7592
|
body.appendChild(requiredGroup);
|
|
7593
|
+
const enabledGroup = createElement("div", { className: "flex items-center justify-between mb-4" });
|
|
7594
|
+
enabledGroup.appendChild(createElement("label", { className: "text-sm text-gray-700 dark:text-gray-300", text: "Enabled" }));
|
|
7595
|
+
enabledGroup.appendChild(createElement("input", {
|
|
7596
|
+
type: "checkbox",
|
|
7597
|
+
className: "h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",
|
|
7598
|
+
checked: selectedField.enabled !== false,
|
|
7599
|
+
// Default to true if not specified
|
|
7600
|
+
onchange: (e) => formStore.getState().updateField(selectedField.id, { enabled: e.target.checked })
|
|
7601
|
+
}));
|
|
7602
|
+
body.appendChild(enabledGroup);
|
|
7603
|
+
const visibleGroup = createElement("div", { className: "flex items-center justify-between mb-4" });
|
|
7604
|
+
visibleGroup.appendChild(createElement("label", { className: "text-sm text-gray-700 dark:text-gray-300", text: "Visible" }));
|
|
7605
|
+
visibleGroup.appendChild(createElement("input", {
|
|
7606
|
+
type: "checkbox",
|
|
7607
|
+
className: "h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",
|
|
7608
|
+
checked: selectedField.visible !== false,
|
|
7609
|
+
// Default to true if not specified
|
|
7610
|
+
onchange: (e) => formStore.getState().updateField(selectedField.id, { visible: e.target.checked })
|
|
7611
|
+
}));
|
|
7612
|
+
body.appendChild(visibleGroup);
|
|
7613
|
+
if (selectedField.type === "select") {
|
|
7614
|
+
const masterTypes = formStore.getState().masterTypes;
|
|
7615
|
+
const activeMasterTypes = masterTypes.filter((mt) => mt.active === true);
|
|
7616
|
+
if (activeMasterTypes.length > 0) {
|
|
7617
|
+
const groupNameGroup = createElement("div", { className: "mb-4" });
|
|
7618
|
+
groupNameGroup.appendChild(createElement("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1", text: "Group Name" }));
|
|
7619
|
+
const groupNameSelect = createElement("select", {
|
|
7620
|
+
className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-md bg-transparent",
|
|
7621
|
+
onchange: (e) => {
|
|
7622
|
+
const selectedValue = e.target.value;
|
|
7623
|
+
if (selectedValue) {
|
|
7624
|
+
const selectedMasterType = activeMasterTypes.find((mt) => mt.id === selectedValue || mt.name === selectedValue);
|
|
7625
|
+
if (selectedMasterType) {
|
|
7626
|
+
formStore.getState().updateField(selectedField.id, {
|
|
7627
|
+
groupName: {
|
|
7628
|
+
id: selectedMasterType.id,
|
|
7629
|
+
name: selectedMasterType.name
|
|
7630
|
+
}
|
|
7631
|
+
});
|
|
7632
|
+
}
|
|
7633
|
+
} else {
|
|
7634
|
+
formStore.getState().updateField(selectedField.id, { groupName: void 0 });
|
|
7635
|
+
}
|
|
7636
|
+
}
|
|
7637
|
+
});
|
|
7638
|
+
groupNameSelect.appendChild(createElement("option", {
|
|
7639
|
+
value: "",
|
|
7640
|
+
text: "None",
|
|
7641
|
+
selected: !selectedField.groupName
|
|
7642
|
+
}));
|
|
7643
|
+
activeMasterTypes.forEach((mt) => {
|
|
7644
|
+
const isSelected = selectedField.groupName && (selectedField.groupName.id === mt.id || selectedField.groupName.name === mt.name);
|
|
7645
|
+
groupNameSelect.appendChild(createElement("option", {
|
|
7646
|
+
value: mt.id || mt.name,
|
|
7647
|
+
text: mt.displayName || mt.name,
|
|
7648
|
+
selected: !!isSelected
|
|
7649
|
+
}));
|
|
7650
|
+
});
|
|
7651
|
+
groupNameGroup.appendChild(groupNameSelect);
|
|
7652
|
+
body.appendChild(groupNameGroup);
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7390
7655
|
const validationHeader = createElement("h3", { className: "text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 mt-6", text: "Validation Rules" });
|
|
7391
7656
|
body.appendChild(validationHeader);
|
|
7392
7657
|
const validations = selectedField.validation || [];
|
|
@@ -7513,12 +7778,13 @@ var FormBuilder = class {
|
|
|
7513
7778
|
panel.appendChild(body);
|
|
7514
7779
|
return panel;
|
|
7515
7780
|
}
|
|
7516
|
-
|
|
7781
|
+
initSidebarSortables() {
|
|
7517
7782
|
const toolboxList = document.getElementById("toolbox-list");
|
|
7518
7783
|
if (toolboxList) {
|
|
7519
7784
|
new sortable_esm_default(toolboxList, {
|
|
7520
7785
|
group: {
|
|
7521
|
-
name: "shared",
|
|
7786
|
+
name: "shared-fields",
|
|
7787
|
+
// Matches the group in Section.ts
|
|
7522
7788
|
pull: "clone",
|
|
7523
7789
|
put: false
|
|
7524
7790
|
},
|
|
@@ -7530,7 +7796,7 @@ var FormBuilder = class {
|
|
|
7530
7796
|
if (templatesList) {
|
|
7531
7797
|
new sortable_esm_default(templatesList, {
|
|
7532
7798
|
group: {
|
|
7533
|
-
name: "shared",
|
|
7799
|
+
name: "shared-templates",
|
|
7534
7800
|
pull: "clone",
|
|
7535
7801
|
put: false
|
|
7536
7802
|
},
|
|
@@ -7540,85 +7806,6 @@ var FormBuilder = class {
|
|
|
7540
7806
|
forceFallback: true
|
|
7541
7807
|
});
|
|
7542
7808
|
}
|
|
7543
|
-
const sectionsList = document.getElementById("sections-list");
|
|
7544
|
-
if (sectionsList) {
|
|
7545
|
-
new sortable_esm_default(sectionsList, {
|
|
7546
|
-
group: "shared",
|
|
7547
|
-
handle: ".section-handle",
|
|
7548
|
-
animation: 150,
|
|
7549
|
-
onAdd: (evt) => {
|
|
7550
|
-
const item = evt.item;
|
|
7551
|
-
const templateId = item.getAttribute("data-template-id");
|
|
7552
|
-
const isTemplate = item.getAttribute("data-type") === "template-section";
|
|
7553
|
-
if (templateId && isTemplate) {
|
|
7554
|
-
const templates = formStore.getState().templates;
|
|
7555
|
-
const template = templates.find((t) => t.id === templateId);
|
|
7556
|
-
if (template) {
|
|
7557
|
-
item.remove();
|
|
7558
|
-
formStore.getState().importSection(template);
|
|
7559
|
-
return;
|
|
7560
|
-
}
|
|
7561
|
-
}
|
|
7562
|
-
},
|
|
7563
|
-
onEnd: (evt) => {
|
|
7564
|
-
const item = evt.item;
|
|
7565
|
-
const templateId = item.getAttribute("data-template-id");
|
|
7566
|
-
const isTemplate = item.getAttribute("data-type") === "template-section";
|
|
7567
|
-
if (!templateId && !isTemplate && evt.oldIndex !== void 0 && evt.newIndex !== void 0 && evt.oldIndex !== evt.newIndex) {
|
|
7568
|
-
formStore.getState().moveSection(evt.oldIndex, evt.newIndex);
|
|
7569
|
-
}
|
|
7570
|
-
}
|
|
7571
|
-
});
|
|
7572
|
-
}
|
|
7573
|
-
const fieldLists = document.querySelectorAll(".fields-list");
|
|
7574
|
-
fieldLists.forEach((list) => {
|
|
7575
|
-
new sortable_esm_default(list, {
|
|
7576
|
-
group: "shared",
|
|
7577
|
-
handle: ".field-handle",
|
|
7578
|
-
animation: 150,
|
|
7579
|
-
onAdd: (evt) => {
|
|
7580
|
-
const item = evt.item;
|
|
7581
|
-
const type = item.getAttribute("data-type");
|
|
7582
|
-
const sectionId = list.getAttribute("data-section-id");
|
|
7583
|
-
if (type && sectionId) {
|
|
7584
|
-
if (type === "template-section") {
|
|
7585
|
-
const templateId = item.getAttribute("data-template-id");
|
|
7586
|
-
const templates = formStore.getState().templates;
|
|
7587
|
-
const template = templates.find((t) => t.id === templateId);
|
|
7588
|
-
item.remove();
|
|
7589
|
-
if (template) {
|
|
7590
|
-
formStore.getState().addTemplateFields(sectionId, template, evt.newIndex);
|
|
7591
|
-
}
|
|
7592
|
-
return;
|
|
7593
|
-
}
|
|
7594
|
-
item.remove();
|
|
7595
|
-
formStore.getState().addField(sectionId, type, evt.newIndex);
|
|
7596
|
-
} else if (sectionId) {
|
|
7597
|
-
item.getAttribute("data-id");
|
|
7598
|
-
}
|
|
7599
|
-
},
|
|
7600
|
-
onUpdate: (evt) => {
|
|
7601
|
-
const item = evt.item;
|
|
7602
|
-
const fieldId = item.getAttribute("data-id");
|
|
7603
|
-
const sectionId = list.getAttribute("data-section-id");
|
|
7604
|
-
if (fieldId && sectionId && evt.newIndex !== void 0) {
|
|
7605
|
-
formStore.getState().moveField(fieldId, sectionId, evt.newIndex);
|
|
7606
|
-
}
|
|
7607
|
-
},
|
|
7608
|
-
onEnd: (evt) => {
|
|
7609
|
-
const item = evt.item;
|
|
7610
|
-
const fromList = evt.from;
|
|
7611
|
-
const toList = evt.to;
|
|
7612
|
-
if (fromList !== toList && fromList.classList.contains("fields-list") && toList.classList.contains("fields-list")) {
|
|
7613
|
-
const fieldId = item.getAttribute("data-id");
|
|
7614
|
-
const targetSectionId = toList.getAttribute("data-section-id");
|
|
7615
|
-
if (fieldId && targetSectionId && evt.newIndex !== void 0) {
|
|
7616
|
-
formStore.getState().moveField(fieldId, targetSectionId, evt.newIndex);
|
|
7617
|
-
}
|
|
7618
|
-
}
|
|
7619
|
-
}
|
|
7620
|
-
});
|
|
7621
|
-
});
|
|
7622
7809
|
}
|
|
7623
7810
|
};
|
|
7624
7811
|
|