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