form-builder-pro 1.2.9 → 1.3.0
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 +114 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -115
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4610,10 +4610,12 @@ function transformField(field) {
|
|
|
4610
4610
|
transformed.optionsSource = field.optionsSource;
|
|
4611
4611
|
if (field.customOptionsEnabled !== void 0)
|
|
4612
4612
|
transformed.customOptionsEnabled = field.customOptionsEnabled;
|
|
4613
|
-
if (
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4613
|
+
if (transformed.optionSource === "MASTER") {
|
|
4614
|
+
if (field.groupName !== void 0)
|
|
4615
|
+
transformed.groupName = field.groupName;
|
|
4616
|
+
if (field.masterTypeName !== void 0)
|
|
4617
|
+
transformed.masterTypeName = field.masterTypeName;
|
|
4618
|
+
}
|
|
4617
4619
|
if ((normalizedType === "select" || normalizedType === "radio" || normalizedType === "checkbox") && field.options && Array.isArray(field.options)) {
|
|
4618
4620
|
transformed.options = field.options.map((opt, idx) => {
|
|
4619
4621
|
if (opt && typeof opt === "object" && "label" in opt && "value" in opt) {
|
|
@@ -4778,10 +4780,12 @@ function fieldToPayload(field) {
|
|
|
4778
4780
|
payload.optionSource = field.optionSource;
|
|
4779
4781
|
if (field.customOptionsEnabled !== void 0)
|
|
4780
4782
|
payload.customOptionsEnabled = field.customOptionsEnabled;
|
|
4781
|
-
if (field.
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4783
|
+
if (field.optionSource === "MASTER") {
|
|
4784
|
+
if (field.groupName !== void 0)
|
|
4785
|
+
payload.groupName = field.groupName;
|
|
4786
|
+
if (field.masterTypeName !== void 0)
|
|
4787
|
+
payload.masterTypeName = field.masterTypeName;
|
|
4788
|
+
}
|
|
4785
4789
|
if (field.lookupSourceType !== void 0)
|
|
4786
4790
|
payload.lookupSourceType = field.lookupSourceType;
|
|
4787
4791
|
if (field.lookupSource !== void 0)
|
|
@@ -10161,112 +10165,6 @@ var FormBuilder = class {
|
|
|
10161
10165
|
`show-country-name-${selectedField.id}`
|
|
10162
10166
|
));
|
|
10163
10167
|
}
|
|
10164
|
-
if (selectedField.type === "select" && selectedField.optionSource === "MASTER") {
|
|
10165
|
-
const masterTypes = formStore.getState().masterTypes;
|
|
10166
|
-
const activeMasterTypes = masterTypes.filter((mt) => mt.active === true);
|
|
10167
|
-
const dropdownOptionsMap = formStore.getState().dropdownOptionsMap;
|
|
10168
|
-
const convertIndexesToOptions = (indexes) => {
|
|
10169
|
-
if (!indexes || !Array.isArray(indexes) || indexes.length === 0) {
|
|
10170
|
-
return [];
|
|
10171
|
-
}
|
|
10172
|
-
return indexes.map((item, index2) => {
|
|
10173
|
-
if (typeof item === "string") {
|
|
10174
|
-
return { label: item, value: item };
|
|
10175
|
-
}
|
|
10176
|
-
if (typeof item === "object" && item !== null) {
|
|
10177
|
-
const label = item.label || item.name || item.displayName || item.text || `Option ${index2 + 1}`;
|
|
10178
|
-
const value = item.value || item.id || item.name || String(index2);
|
|
10179
|
-
return { label, value };
|
|
10180
|
-
}
|
|
10181
|
-
return { label: String(item), value: String(item) };
|
|
10182
|
-
});
|
|
10183
|
-
};
|
|
10184
|
-
if (activeMasterTypes.length > 0) {
|
|
10185
|
-
const groupNameGroup = createElement("div", { className: "mb-4" });
|
|
10186
|
-
groupNameGroup.appendChild(createElement("label", { className: "block text-sm font-normal text-gray-700 dark:text-gray-300 mb-1", text: "Master List" }));
|
|
10187
|
-
const groupNameSelect = createElement("select", {
|
|
10188
|
-
className: "w-full px-3 py-2 border border-gray-200 dark:border-gray-700 rounded-md bg-transparent",
|
|
10189
|
-
onchange: (e) => {
|
|
10190
|
-
const selectedEnumName = e.target.value;
|
|
10191
|
-
if (selectedEnumName) {
|
|
10192
|
-
const selectedMasterType = activeMasterTypes.find((mt) => mt.enumName === selectedEnumName);
|
|
10193
|
-
if (selectedMasterType) {
|
|
10194
|
-
let options = [];
|
|
10195
|
-
if (dropdownOptionsMap && dropdownOptionsMap[selectedEnumName]) {
|
|
10196
|
-
options = dropdownOptionsMap[selectedEnumName];
|
|
10197
|
-
} else if (selectedMasterType.indexes && selectedMasterType.indexes.length > 0) {
|
|
10198
|
-
options = convertIndexesToOptions(selectedMasterType.indexes);
|
|
10199
|
-
}
|
|
10200
|
-
formStore.getState().updateField(selectedField.id, {
|
|
10201
|
-
groupName: {
|
|
10202
|
-
id: selectedMasterType.id,
|
|
10203
|
-
name: selectedMasterType.name
|
|
10204
|
-
},
|
|
10205
|
-
masterTypeName: selectedEnumName,
|
|
10206
|
-
options: options.length > 0 ? options : void 0
|
|
10207
|
-
});
|
|
10208
|
-
if (this.options.onGroupSelectionChange) {
|
|
10209
|
-
this.options.onGroupSelectionChange({
|
|
10210
|
-
fieldId: selectedField.id,
|
|
10211
|
-
groupEnumName: selectedEnumName
|
|
10212
|
-
});
|
|
10213
|
-
}
|
|
10214
|
-
}
|
|
10215
|
-
} else {
|
|
10216
|
-
formStore.getState().updateField(selectedField.id, {
|
|
10217
|
-
groupName: void 0,
|
|
10218
|
-
masterTypeName: void 0,
|
|
10219
|
-
options: void 0
|
|
10220
|
-
// Clear options when groupName is cleared
|
|
10221
|
-
});
|
|
10222
|
-
}
|
|
10223
|
-
}
|
|
10224
|
-
});
|
|
10225
|
-
let currentMasterType;
|
|
10226
|
-
if (selectedField.masterTypeName) {
|
|
10227
|
-
currentMasterType = activeMasterTypes.find((mt) => mt.enumName === selectedField.masterTypeName);
|
|
10228
|
-
} else if (selectedField.groupName) {
|
|
10229
|
-
currentMasterType = activeMasterTypes.find(
|
|
10230
|
-
(mt) => mt.id === selectedField.groupName?.id || mt.name === selectedField.groupName?.name
|
|
10231
|
-
);
|
|
10232
|
-
}
|
|
10233
|
-
groupNameSelect.appendChild(createElement("option", {
|
|
10234
|
-
value: "",
|
|
10235
|
-
text: "None",
|
|
10236
|
-
selected: !currentMasterType
|
|
10237
|
-
}));
|
|
10238
|
-
activeMasterTypes.forEach((mt) => {
|
|
10239
|
-
const isSelected = currentMasterType && (selectedField.masterTypeName && mt.enumName === selectedField.masterTypeName || selectedField.groupName && (mt.id === selectedField.groupName?.id || mt.name === selectedField.groupName?.name));
|
|
10240
|
-
const optionValue = mt.enumName || mt.id || mt.name;
|
|
10241
|
-
groupNameSelect.appendChild(createElement("option", {
|
|
10242
|
-
value: optionValue,
|
|
10243
|
-
text: mt.displayName || mt.name,
|
|
10244
|
-
selected: !!isSelected
|
|
10245
|
-
}));
|
|
10246
|
-
});
|
|
10247
|
-
groupNameGroup.appendChild(groupNameSelect);
|
|
10248
|
-
body.appendChild(groupNameGroup);
|
|
10249
|
-
if (currentMasterType && (!selectedField.options || selectedField.options.length === 0)) {
|
|
10250
|
-
let options = [];
|
|
10251
|
-
if (currentMasterType.enumName && dropdownOptionsMap && dropdownOptionsMap[currentMasterType.enumName]) {
|
|
10252
|
-
options = dropdownOptionsMap[currentMasterType.enumName];
|
|
10253
|
-
} else if (currentMasterType.indexes && currentMasterType.indexes.length > 0) {
|
|
10254
|
-
options = convertIndexesToOptions(currentMasterType.indexes);
|
|
10255
|
-
}
|
|
10256
|
-
if (options.length > 0) {
|
|
10257
|
-
formStore.getState().updateField(selectedField.id, { options });
|
|
10258
|
-
}
|
|
10259
|
-
if (selectedField.masterTypeName && !selectedField.groupName) {
|
|
10260
|
-
formStore.getState().updateField(selectedField.id, {
|
|
10261
|
-
groupName: {
|
|
10262
|
-
id: currentMasterType.id,
|
|
10263
|
-
name: currentMasterType.name
|
|
10264
|
-
}
|
|
10265
|
-
});
|
|
10266
|
-
}
|
|
10267
|
-
}
|
|
10268
|
-
}
|
|
10269
|
-
}
|
|
10270
10168
|
if (["select", "checkbox", "radio"].includes(selectedField.type)) {
|
|
10271
10169
|
const optionSourceHeader = createElement("h3", { className: "text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 mt-6", text: "Option Source" });
|
|
10272
10170
|
body.appendChild(optionSourceHeader);
|
|
@@ -10278,12 +10176,18 @@ var FormBuilder = class {
|
|
|
10278
10176
|
onchange: (e) => {
|
|
10279
10177
|
const source = e.target.value;
|
|
10280
10178
|
const updates = { optionSource: source };
|
|
10281
|
-
if (source === "MASTER"
|
|
10179
|
+
if (source === "MASTER") ; else if (source === "STATIC") {
|
|
10282
10180
|
updates.customOptionsEnabled = true;
|
|
10181
|
+
updates.groupName = void 0;
|
|
10182
|
+
updates.masterTypeName = void 0;
|
|
10183
|
+
updates.options = void 0;
|
|
10283
10184
|
} else if (source === "LOOKUP") {
|
|
10284
10185
|
if (!selectedField.lookupSourceType) {
|
|
10285
10186
|
updates.lookupSourceType = "MODULE";
|
|
10286
10187
|
}
|
|
10188
|
+
updates.groupName = void 0;
|
|
10189
|
+
updates.masterTypeName = void 0;
|
|
10190
|
+
updates.options = void 0;
|
|
10287
10191
|
}
|
|
10288
10192
|
formStore.getState().updateField(selectedField.id, updates);
|
|
10289
10193
|
this.render();
|
|
@@ -10296,6 +10200,101 @@ var FormBuilder = class {
|
|
|
10296
10200
|
}
|
|
10297
10201
|
optionSourceGroup.appendChild(optionSourceSelect);
|
|
10298
10202
|
body.appendChild(optionSourceGroup);
|
|
10203
|
+
if (selectedField.type === "select" && selectedField.optionSource === "MASTER") {
|
|
10204
|
+
const masterTypes = formStore.getState().masterTypes;
|
|
10205
|
+
const activeMasterTypes = masterTypes.filter((mt) => mt.active === true);
|
|
10206
|
+
const dropdownOptionsMap = formStore.getState().dropdownOptionsMap;
|
|
10207
|
+
const convertIndexesToOptions = (indexes) => {
|
|
10208
|
+
if (!indexes || !Array.isArray(indexes) || indexes.length === 0) {
|
|
10209
|
+
return [];
|
|
10210
|
+
}
|
|
10211
|
+
return indexes.map((item, index2) => {
|
|
10212
|
+
if (typeof item === "string") {
|
|
10213
|
+
return { label: item, value: item };
|
|
10214
|
+
}
|
|
10215
|
+
if (typeof item === "object" && item !== null) {
|
|
10216
|
+
const label = item.label || item.name || item.displayName || item.text || `Option ${index2 + 1}`;
|
|
10217
|
+
const value = item.value || item.id || item.name || String(index2);
|
|
10218
|
+
return { label, value };
|
|
10219
|
+
}
|
|
10220
|
+
return { label: String(item), value: String(item) };
|
|
10221
|
+
});
|
|
10222
|
+
};
|
|
10223
|
+
if (activeMasterTypes.length > 0) {
|
|
10224
|
+
const groupNameGroup = createElement("div", { className: "mb-4" });
|
|
10225
|
+
groupNameGroup.appendChild(createElement("label", { className: "block text-sm font-normal text-gray-700 dark:text-gray-300 mb-1", text: "Master List" }));
|
|
10226
|
+
const groupNameSelect = createElement("select", {
|
|
10227
|
+
className: "w-full px-3 py-2 border border-gray-200 dark:border-gray-700 rounded-md bg-transparent",
|
|
10228
|
+
onchange: (e) => {
|
|
10229
|
+
const selectedEnumName = e.target.value;
|
|
10230
|
+
if (selectedEnumName) {
|
|
10231
|
+
const selectedMasterType = activeMasterTypes.find((mt) => mt.enumName === selectedEnumName);
|
|
10232
|
+
if (selectedMasterType) {
|
|
10233
|
+
let options = [];
|
|
10234
|
+
if (dropdownOptionsMap && dropdownOptionsMap[selectedEnumName]) {
|
|
10235
|
+
options = dropdownOptionsMap[selectedEnumName];
|
|
10236
|
+
} else if (selectedMasterType.indexes && selectedMasterType.indexes.length > 0) {
|
|
10237
|
+
options = convertIndexesToOptions(selectedMasterType.indexes);
|
|
10238
|
+
}
|
|
10239
|
+
formStore.getState().updateField(selectedField.id, {
|
|
10240
|
+
groupName: { id: selectedMasterType.id, name: selectedMasterType.name },
|
|
10241
|
+
masterTypeName: selectedEnumName,
|
|
10242
|
+
options: options.length > 0 ? options : void 0
|
|
10243
|
+
});
|
|
10244
|
+
if (this.options.onGroupSelectionChange) {
|
|
10245
|
+
this.options.onGroupSelectionChange({
|
|
10246
|
+
fieldId: selectedField.id,
|
|
10247
|
+
groupEnumName: selectedEnumName
|
|
10248
|
+
});
|
|
10249
|
+
}
|
|
10250
|
+
}
|
|
10251
|
+
} else {
|
|
10252
|
+
formStore.getState().updateField(selectedField.id, {
|
|
10253
|
+
groupName: void 0,
|
|
10254
|
+
masterTypeName: void 0,
|
|
10255
|
+
options: void 0
|
|
10256
|
+
});
|
|
10257
|
+
}
|
|
10258
|
+
}
|
|
10259
|
+
});
|
|
10260
|
+
let currentMasterType;
|
|
10261
|
+
if (selectedField.masterTypeName) {
|
|
10262
|
+
currentMasterType = activeMasterTypes.find((mt) => mt.enumName === selectedField.masterTypeName);
|
|
10263
|
+
} else if (selectedField.groupName) {
|
|
10264
|
+
currentMasterType = activeMasterTypes.find(
|
|
10265
|
+
(mt) => mt.id === selectedField.groupName?.id || mt.name === selectedField.groupName?.name
|
|
10266
|
+
);
|
|
10267
|
+
}
|
|
10268
|
+
groupNameSelect.appendChild(createElement("option", { value: "", text: "None", selected: !currentMasterType }));
|
|
10269
|
+
activeMasterTypes.forEach((mt) => {
|
|
10270
|
+
const isSelected = currentMasterType && (selectedField.masterTypeName && mt.enumName === selectedField.masterTypeName || selectedField.groupName && (mt.id === selectedField.groupName?.id || mt.name === selectedField.groupName?.name));
|
|
10271
|
+
const optionValue = mt.enumName || mt.id || mt.name;
|
|
10272
|
+
groupNameSelect.appendChild(createElement("option", {
|
|
10273
|
+
value: optionValue,
|
|
10274
|
+
text: mt.displayName || mt.name,
|
|
10275
|
+
selected: !!isSelected
|
|
10276
|
+
}));
|
|
10277
|
+
});
|
|
10278
|
+
groupNameGroup.appendChild(groupNameSelect);
|
|
10279
|
+
body.appendChild(groupNameGroup);
|
|
10280
|
+
if (currentMasterType && (!selectedField.options || selectedField.options.length === 0)) {
|
|
10281
|
+
let options = [];
|
|
10282
|
+
if (currentMasterType.enumName && dropdownOptionsMap && dropdownOptionsMap[currentMasterType.enumName]) {
|
|
10283
|
+
options = dropdownOptionsMap[currentMasterType.enumName];
|
|
10284
|
+
} else if (currentMasterType.indexes && currentMasterType.indexes.length > 0) {
|
|
10285
|
+
options = convertIndexesToOptions(currentMasterType.indexes);
|
|
10286
|
+
}
|
|
10287
|
+
if (options.length > 0) {
|
|
10288
|
+
formStore.getState().updateField(selectedField.id, { options });
|
|
10289
|
+
}
|
|
10290
|
+
if (selectedField.masterTypeName && !selectedField.groupName) {
|
|
10291
|
+
formStore.getState().updateField(selectedField.id, {
|
|
10292
|
+
groupName: { id: currentMasterType.id, name: currentMasterType.name }
|
|
10293
|
+
});
|
|
10294
|
+
}
|
|
10295
|
+
}
|
|
10296
|
+
}
|
|
10297
|
+
}
|
|
10299
10298
|
if (selectedField.type === "select" && selectedField.optionSource === "LOOKUP") {
|
|
10300
10299
|
const lookupSourceTypeGroup = createElement("div", { className: "mb-4" });
|
|
10301
10300
|
lookupSourceTypeGroup.appendChild(createElement("label", { className: "block text-sm font-normal text-gray-700 dark:text-gray-300 mb-1", text: "Lookup Source Type" }));
|