form-builder-pro 1.4.2 → 1.4.3
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 +20 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4782,6 +4782,13 @@ function transformField(field) {
|
|
|
4782
4782
|
transformed.nameGeneratorSuffix = field.nameGeneratorSuffix;
|
|
4783
4783
|
if (field.nameGeneratorIdPadding !== void 0)
|
|
4784
4784
|
transformed.nameGeneratorIdPadding = field.nameGeneratorIdPadding;
|
|
4785
|
+
if (field.autoPopulateFields !== void 0 && field.autoPopulateFields !== null) {
|
|
4786
|
+
const apf = field.autoPopulateFields;
|
|
4787
|
+
transformed.autoPopulateFields = {
|
|
4788
|
+
enabled: typeof apf.enabled === "boolean" ? apf.enabled : false,
|
|
4789
|
+
fields: Array.isArray(apf.fields) ? apf.fields : []
|
|
4790
|
+
};
|
|
4791
|
+
}
|
|
4785
4792
|
if (field.css !== void 0)
|
|
4786
4793
|
transformed.css = field.css;
|
|
4787
4794
|
if (field.optionsSource !== void 0)
|
|
@@ -5040,6 +5047,12 @@ function fieldToPayload(field, opts) {
|
|
|
5040
5047
|
parentFieldName: field.lookupParentFieldName ?? null
|
|
5041
5048
|
};
|
|
5042
5049
|
}
|
|
5050
|
+
if (field.optionSource === "LOOKUP" && field.autoPopulateFields !== void 0 && field.autoPopulateFields !== null) {
|
|
5051
|
+
payload.autoPopulateFields = {
|
|
5052
|
+
enabled: field.autoPopulateFields.enabled,
|
|
5053
|
+
fields: Array.isArray(field.autoPopulateFields.fields) ? field.autoPopulateFields.fields : []
|
|
5054
|
+
};
|
|
5055
|
+
}
|
|
5043
5056
|
if (field.isd !== void 0)
|
|
5044
5057
|
payload.isd = field.isd;
|
|
5045
5058
|
if (field.imageUrl !== void 0)
|
|
@@ -13561,6 +13574,84 @@ var FormBuilder = class {
|
|
|
13561
13574
|
});
|
|
13562
13575
|
parentFieldGroup.appendChild(parentFieldSelect);
|
|
13563
13576
|
body.appendChild(parentFieldGroup);
|
|
13577
|
+
const autoPopHeader = createElement("h3", {
|
|
13578
|
+
className: "text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 mt-6",
|
|
13579
|
+
text: "Auto Populate Fields"
|
|
13580
|
+
});
|
|
13581
|
+
body.appendChild(autoPopHeader);
|
|
13582
|
+
const autoPopEnabled = selectedField.autoPopulateFields?.enabled === true;
|
|
13583
|
+
body.appendChild(this.createCheckboxField(
|
|
13584
|
+
"Enable automation for selected records",
|
|
13585
|
+
autoPopEnabled,
|
|
13586
|
+
(checked) => {
|
|
13587
|
+
const current = formStore.getState().schema.sections.flatMap((s) => s.fields).find((f) => f.id === selectedField.id);
|
|
13588
|
+
formStore.getState().updateField(selectedField.id, {
|
|
13589
|
+
autoPopulateFields: {
|
|
13590
|
+
enabled: checked,
|
|
13591
|
+
fields: current?.autoPopulateFields?.fields ?? []
|
|
13592
|
+
}
|
|
13593
|
+
});
|
|
13594
|
+
this.render();
|
|
13595
|
+
},
|
|
13596
|
+
`auto-populate-enabled-${selectedField.id}`
|
|
13597
|
+
));
|
|
13598
|
+
{
|
|
13599
|
+
const autoPopFieldsGroup = createElement("div", { className: "mb-4 mt-2" });
|
|
13600
|
+
autoPopFieldsGroup.appendChild(createElement("label", {
|
|
13601
|
+
className: "block text-sm font-normal text-gray-700 dark:text-gray-300 mb-1",
|
|
13602
|
+
text: "Fields to auto-populate"
|
|
13603
|
+
}));
|
|
13604
|
+
const lookupFieldOptionsMapForAP = formStore.getState().lookupFieldOptionsMap;
|
|
13605
|
+
const availableAutoPopFields = selectedField.lookupSource ? lookupFieldOptionsMapForAP[selectedField.lookupSource] || [] : [];
|
|
13606
|
+
const selectedAutoPopFields = selectedField.autoPopulateFields?.fields ?? [];
|
|
13607
|
+
const isAutoPopDisabled = !autoPopEnabled || !selectedField.lookupSource;
|
|
13608
|
+
if (availableAutoPopFields.length === 0) {
|
|
13609
|
+
const emptyNote = createElement("p", {
|
|
13610
|
+
className: "text-xs text-gray-400 dark:text-gray-500 mt-1",
|
|
13611
|
+
text: selectedField.lookupSource ? "No fields available for this lookup source." : "Select a Lookup Source first."
|
|
13612
|
+
});
|
|
13613
|
+
autoPopFieldsGroup.appendChild(emptyNote);
|
|
13614
|
+
} else {
|
|
13615
|
+
const fieldList = createElement("div", {
|
|
13616
|
+
className: `border border-gray-200 dark:border-gray-700 rounded-md divide-y divide-gray-100 dark:divide-gray-700 overflow-y-auto max-h-40 ${isAutoPopDisabled ? "opacity-50 pointer-events-none" : ""}`
|
|
13617
|
+
});
|
|
13618
|
+
availableAutoPopFields.forEach((fieldKey) => {
|
|
13619
|
+
const isChecked = selectedAutoPopFields.includes(fieldKey);
|
|
13620
|
+
const row = createElement("label", {
|
|
13621
|
+
className: "flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 text-sm text-gray-700 dark:text-gray-300"
|
|
13622
|
+
});
|
|
13623
|
+
const cb = createElement("input", {
|
|
13624
|
+
type: "checkbox",
|
|
13625
|
+
className: "w-4 h-4 accent-blue-600",
|
|
13626
|
+
checked: isChecked,
|
|
13627
|
+
disabled: isAutoPopDisabled,
|
|
13628
|
+
onchange: (e) => {
|
|
13629
|
+
const target = e.target;
|
|
13630
|
+
const latestField = formStore.getState().schema.sections.flatMap((s) => s.fields).find((f) => f.id === selectedField.id);
|
|
13631
|
+
const latestSelected = latestField?.autoPopulateFields?.fields ?? [];
|
|
13632
|
+
const updatedFields = target.checked ? [.../* @__PURE__ */ new Set([...latestSelected, fieldKey])] : latestSelected.filter((k) => k !== fieldKey);
|
|
13633
|
+
formStore.getState().updateField(selectedField.id, {
|
|
13634
|
+
autoPopulateFields: {
|
|
13635
|
+
enabled: latestField?.autoPopulateFields?.enabled ?? true,
|
|
13636
|
+
fields: updatedFields
|
|
13637
|
+
}
|
|
13638
|
+
});
|
|
13639
|
+
}
|
|
13640
|
+
});
|
|
13641
|
+
row.appendChild(cb);
|
|
13642
|
+
row.appendChild(createElement("span", { text: fieldKey }));
|
|
13643
|
+
fieldList.appendChild(row);
|
|
13644
|
+
});
|
|
13645
|
+
autoPopFieldsGroup.appendChild(fieldList);
|
|
13646
|
+
if (selectedAutoPopFields.length > 0) {
|
|
13647
|
+
autoPopFieldsGroup.appendChild(createElement("p", {
|
|
13648
|
+
className: "text-xs text-gray-400 dark:text-gray-500 mt-1",
|
|
13649
|
+
text: `${selectedAutoPopFields.length} field(s) selected`
|
|
13650
|
+
}));
|
|
13651
|
+
}
|
|
13652
|
+
}
|
|
13653
|
+
body.appendChild(autoPopFieldsGroup);
|
|
13654
|
+
}
|
|
13564
13655
|
body.appendChild(this.createCheckboxField(
|
|
13565
13656
|
"Visibility",
|
|
13566
13657
|
selectedField.visible !== false,
|