form-builder-pro 1.2.6 → 1.2.8
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.js +34 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4319,10 +4319,12 @@ function convertSpanToWidth(span, totalColumns = 12) {
|
|
|
4319
4319
|
function normalizeFieldType(type) {
|
|
4320
4320
|
if (!type)
|
|
4321
4321
|
return "text";
|
|
4322
|
-
const normalized = String(type).toLowerCase();
|
|
4322
|
+
const normalized = String(type).toLowerCase().replace(/_/g, "");
|
|
4323
4323
|
if (normalized === "decimal")
|
|
4324
4324
|
return "number";
|
|
4325
|
-
|
|
4325
|
+
if (["phonenumber", "telephone", "mobile"].includes(normalized))
|
|
4326
|
+
return "phone";
|
|
4327
|
+
return String(type).toLowerCase();
|
|
4326
4328
|
}
|
|
4327
4329
|
function transformField(field) {
|
|
4328
4330
|
const fieldId = field.id || field.fieldId;
|
|
@@ -4467,6 +4469,8 @@ function transformField(field) {
|
|
|
4467
4469
|
transformed.enabled = field.enabled;
|
|
4468
4470
|
if (field.visible !== void 0)
|
|
4469
4471
|
transformed.visible = field.visible;
|
|
4472
|
+
if (field.isd !== void 0)
|
|
4473
|
+
transformed.isd = field.isd;
|
|
4470
4474
|
if (field.css !== void 0)
|
|
4471
4475
|
transformed.css = field.css;
|
|
4472
4476
|
if (field.optionsSource !== void 0)
|
|
@@ -4613,6 +4617,8 @@ function fieldToPayload(field) {
|
|
|
4613
4617
|
payload.css = field.css;
|
|
4614
4618
|
if (field.optionSource !== void 0)
|
|
4615
4619
|
payload.optionSource = field.optionSource;
|
|
4620
|
+
if (field.customOptionsEnabled !== void 0)
|
|
4621
|
+
payload.customOptionsEnabled = field.customOptionsEnabled;
|
|
4616
4622
|
if (field.groupName !== void 0)
|
|
4617
4623
|
payload.groupName = field.groupName;
|
|
4618
4624
|
if (field.masterTypeName !== void 0)
|
|
@@ -4627,8 +4633,8 @@ function fieldToPayload(field) {
|
|
|
4627
4633
|
payload.lookupLabelField = field.lookupLabelField;
|
|
4628
4634
|
if (field.isd !== void 0)
|
|
4629
4635
|
payload.isd = field.isd;
|
|
4630
|
-
if ((field.type === "select" || field.type === "radio" || field.type === "checkbox") && field.options) {
|
|
4631
|
-
payload.options = field.options;
|
|
4636
|
+
if ((field.type === "select" || field.type === "radio" || field.type === "checkbox") && field.options && Array.isArray(field.options)) {
|
|
4637
|
+
payload.options = field.options.map((opt) => ({ label: opt.label, value: opt.value }));
|
|
4632
4638
|
}
|
|
4633
4639
|
return payload;
|
|
4634
4640
|
}
|
|
@@ -9698,6 +9704,11 @@ var FormBuilder = class {
|
|
|
9698
9704
|
const shouldShowOptions = selectedField.type === "select" ? selectedField.customOptionsEnabled && (selectedField.optionSource === "STATIC" || !selectedField.optionSource) : true;
|
|
9699
9705
|
if (shouldShowOptions) {
|
|
9700
9706
|
const options = selectedField.options || [];
|
|
9707
|
+
const fieldId2 = selectedField.id;
|
|
9708
|
+
const getCurrentOptions = () => {
|
|
9709
|
+
const field = formStore.getState().schema.sections.flatMap((s) => s.fields).find((f) => f.id === fieldId2);
|
|
9710
|
+
return field?.options || [];
|
|
9711
|
+
};
|
|
9701
9712
|
const optionsList = createElement("div", { className: "space-y-2 mb-3" });
|
|
9702
9713
|
options.forEach((opt, index2) => {
|
|
9703
9714
|
const optionRow = createElement("div", { className: "flex gap-2 items-center" });
|
|
@@ -9708,9 +9719,12 @@ var FormBuilder = class {
|
|
|
9708
9719
|
placeholder: "Option label",
|
|
9709
9720
|
"data-focus-id": `field-option-label-${selectedField.id}-${index2}`,
|
|
9710
9721
|
oninput: (e) => {
|
|
9711
|
-
const
|
|
9712
|
-
newOptions
|
|
9713
|
-
|
|
9722
|
+
const currentOptions = getCurrentOptions();
|
|
9723
|
+
const newOptions = [...currentOptions];
|
|
9724
|
+
if (newOptions[index2]) {
|
|
9725
|
+
newOptions[index2] = { ...newOptions[index2], label: e.target.value };
|
|
9726
|
+
formStore.getState().updateField(fieldId2, { options: newOptions });
|
|
9727
|
+
}
|
|
9714
9728
|
}
|
|
9715
9729
|
});
|
|
9716
9730
|
const valueInput = createElement("input", {
|
|
@@ -9720,17 +9734,21 @@ var FormBuilder = class {
|
|
|
9720
9734
|
placeholder: "Option value",
|
|
9721
9735
|
"data-focus-id": `field-option-value-${selectedField.id}-${index2}`,
|
|
9722
9736
|
oninput: (e) => {
|
|
9723
|
-
const
|
|
9724
|
-
newOptions
|
|
9725
|
-
|
|
9737
|
+
const currentOptions = getCurrentOptions();
|
|
9738
|
+
const newOptions = [...currentOptions];
|
|
9739
|
+
if (newOptions[index2]) {
|
|
9740
|
+
newOptions[index2] = { ...newOptions[index2], value: e.target.value };
|
|
9741
|
+
formStore.getState().updateField(fieldId2, { options: newOptions });
|
|
9742
|
+
}
|
|
9726
9743
|
}
|
|
9727
9744
|
});
|
|
9728
9745
|
const deleteBtn = createElement("button", {
|
|
9729
9746
|
className: "p-1.5 text-red-600 hover:bg-red-50 rounded transition-colors",
|
|
9730
9747
|
title: "Delete option",
|
|
9731
9748
|
onclick: () => {
|
|
9732
|
-
const
|
|
9733
|
-
|
|
9749
|
+
const currentOptions = getCurrentOptions();
|
|
9750
|
+
const newOptions = currentOptions.filter((_, i) => i !== index2);
|
|
9751
|
+
formStore.getState().updateField(fieldId2, { options: newOptions });
|
|
9734
9752
|
}
|
|
9735
9753
|
}, [getIcon("Trash2", 14)]);
|
|
9736
9754
|
optionRow.appendChild(labelInput);
|
|
@@ -9744,8 +9762,10 @@ var FormBuilder = class {
|
|
|
9744
9762
|
className: "w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-700 rounded-md hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",
|
|
9745
9763
|
text: "Add Option",
|
|
9746
9764
|
onclick: () => {
|
|
9747
|
-
const
|
|
9748
|
-
|
|
9765
|
+
const currentOptions = getCurrentOptions();
|
|
9766
|
+
const newOption = { label: `Option ${currentOptions.length + 1}`, value: `opt${currentOptions.length + 1}` };
|
|
9767
|
+
const newOptions = [...currentOptions, newOption];
|
|
9768
|
+
formStore.getState().updateField(fieldId2, { options: newOptions });
|
|
9749
9769
|
this.render();
|
|
9750
9770
|
}
|
|
9751
9771
|
});
|