formeo 5.3.1 → 5.3.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/demo/assets/css/demo.min.css +1 -1
- package/dist/demo/assets/css/demo.min.css.gz +0 -0
- package/dist/demo/assets/css/formeo.min.css +1 -1
- package/dist/demo/assets/js/demo.min.js +48 -48
- package/dist/demo/assets/js/demo.min.js.gz +0 -0
- package/dist/demo/assets/js/form.min.js +2 -2
- package/dist/demo/assets/js/formeo.cjs.js +47 -13
- package/dist/demo/assets/js/formeo.es.js +47 -13
- package/dist/demo/assets/js/formeo.min.cjs.js +2 -2
- package/dist/demo/assets/js/formeo.min.es.js +2 -2
- package/dist/demo/assets/js/formeo.min.js +47 -13
- package/dist/demo/assets/js/formeo.min.umd.js +2 -2
- package/dist/demo/assets/js/formeo.umd.js +47 -13
- package/dist/demo/assets/js/html.min.js +1 -1
- package/dist/demo/assets/js/layout.min.js +1 -1
- package/dist/demo/assets/js/mode-json.min.js +1 -1
- package/dist/demo/assets/js/mode-json.min.js.gz +0 -0
- package/dist/demo/assets/js/theme-github_light_default.min.js +1 -1
- package/dist/demo/index.html +1 -1
- package/dist/formeo.cjs.js +47 -13
- package/dist/formeo.css +1 -1
- package/dist/formeo.es.js +47 -13
- package/dist/formeo.min.cjs.js +2 -2
- package/dist/formeo.min.css +1 -1
- package/dist/formeo.min.es.js +2 -2
- package/dist/formeo.min.js +47 -13
- package/dist/formeo.min.umd.js +2 -2
- package/dist/formeo.umd.js +47 -13
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
3
|
formeo - https://formeo.io
|
|
4
|
-
Version: 5.3.
|
|
4
|
+
Version: 5.3.2
|
|
5
5
|
Author: Draggable https://draggable.io
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -8068,7 +8068,7 @@ Author: Draggable https://draggable.io
|
|
|
8068
8068
|
})), name$1, version$2, type, main, module$1, unpkg, exports$1, files, homepage, repository, author, contributors, bugs, description, keywords, ignore, config, scripts, devDependencies, dependencies, release, commitlint, package_default;
|
|
8069
8069
|
var init_package = __esmMin((() => {
|
|
8070
8070
|
name$1 = "formeo";
|
|
8071
|
-
version$2 = "5.3.
|
|
8071
|
+
version$2 = "5.3.2";
|
|
8072
8072
|
type = "module";
|
|
8073
8073
|
main = "dist/formeo.cjs.js";
|
|
8074
8074
|
module$1 = "dist/formeo.es.js";
|
|
@@ -8681,7 +8681,7 @@ Author: Draggable https://draggable.io
|
|
|
8681
8681
|
function trimKeyPrefix(key) {
|
|
8682
8682
|
return key.replaceAll(keyPrefixRegex, "");
|
|
8683
8683
|
}
|
|
8684
|
-
var toTitleCaseLowers, toTitleCaseRegex, regexSpace, slugify, splitAddress, slugifyAddress, extractTextFromHtml, truncateByWord, keyPrefixRegex;
|
|
8684
|
+
var toTitleCaseLowers, toTitleCaseRegex, regexSpace, slugify, splitAddress, slugifyAddress, extractTextFromHtml, truncateByWord, keyPrefixRegex, groupInputName;
|
|
8685
8685
|
var init_string = __esmMin((() => {
|
|
8686
8686
|
toTitleCaseLowers = "a an and as at but by for for from in into near nor of on onto or the to with".split(" ").map((lower) => String.raw`\s${lower}\s`);
|
|
8687
8687
|
toTitleCaseRegex = new RegExp(String.raw`(?!${toTitleCaseLowers.join("|")})\w\S*`, "g");
|
|
@@ -8718,6 +8718,7 @@ Author: Draggable https://draggable.io
|
|
|
8718
8718
|
return truncatedWord;
|
|
8719
8719
|
};
|
|
8720
8720
|
keyPrefixRegex = /^attrs\.|^meta\.|^options\.|^config\./g;
|
|
8721
|
+
groupInputName = (name, fieldType, optionCount) => fieldType === "checkbox" && optionCount > 1 && name && !name.endsWith("[]") ? `${name}[]` : name;
|
|
8721
8722
|
}));
|
|
8722
8723
|
//#endregion
|
|
8723
8724
|
//#region src/lib/js/common/events.js
|
|
@@ -14525,6 +14526,23 @@ Author: Draggable https://draggable.io
|
|
|
14525
14526
|
});
|
|
14526
14527
|
}));
|
|
14527
14528
|
//#endregion
|
|
14529
|
+
//#region src/lib/js/components/fields/control-attr-config.mjs
|
|
14530
|
+
var getControlConfig, controlAttrPanelConfig;
|
|
14531
|
+
var init_control_attr_config = __esmMin((() => {
|
|
14532
|
+
init_utils();
|
|
14533
|
+
getControlConfig = (control) => control?.controlData?.config ?? control?.config;
|
|
14534
|
+
controlAttrPanelConfig = (...sources) => {
|
|
14535
|
+
const collect = (key) => unique(sources.flatMap((source) => Array.isArray(source?.[key]) ? source[key] : []));
|
|
14536
|
+
const disabled = collect("disabledAttrs");
|
|
14537
|
+
const locked = collect("lockedAttrs");
|
|
14538
|
+
if (!disabled.length && !locked.length) return null;
|
|
14539
|
+
return { panels: { attrs: {
|
|
14540
|
+
disabled,
|
|
14541
|
+
locked
|
|
14542
|
+
} } };
|
|
14543
|
+
};
|
|
14544
|
+
}));
|
|
14545
|
+
//#endregion
|
|
14528
14546
|
//#region src/lib/js/components/fields/field.js
|
|
14529
14547
|
var field_exports = /* @__PURE__ */ __exportAll({ default: () => Field });
|
|
14530
14548
|
var checkableTypes, isSelectableType, Field;
|
|
@@ -14535,6 +14553,8 @@ Author: Draggable https://draggable.io
|
|
|
14535
14553
|
init_utils();
|
|
14536
14554
|
init_constants();
|
|
14537
14555
|
init_component();
|
|
14556
|
+
init_components();
|
|
14557
|
+
init_control_attr_config();
|
|
14538
14558
|
checkableTypes = new Set(["checkbox", "radio"]);
|
|
14539
14559
|
isSelectableType = new Set([
|
|
14540
14560
|
"radio",
|
|
@@ -14550,11 +14570,12 @@ Author: Draggable https://draggable.io
|
|
|
14550
14570
|
*/
|
|
14551
14571
|
constructor(fieldData = Object.create(null)) {
|
|
14552
14572
|
super("field", fieldData);
|
|
14573
|
+
this.controlId = this.get("config.controlId") || this.get("meta.id");
|
|
14574
|
+
this.applyControlAttrConfig();
|
|
14553
14575
|
this.debouncedUpdateEditPanels = debounce(this.updateEditPanels);
|
|
14554
14576
|
this.debouncedUpdatePreview = debounce(this.updatePreview);
|
|
14555
14577
|
this.label = dom.create(this.labelConfig);
|
|
14556
14578
|
this.preview = this.fieldPreview();
|
|
14557
|
-
this.controlId = this.get("config.controlId") || this.get("meta.id");
|
|
14558
14579
|
const actionButtons = this.getActionButtons();
|
|
14559
14580
|
const hasEditButton = this.actionButtons.some((child) => child.meta?.id === "edit");
|
|
14560
14581
|
this.updateEditPanels();
|
|
@@ -14575,6 +14596,15 @@ Author: Draggable https://draggable.io
|
|
|
14575
14596
|
this.dom = field;
|
|
14576
14597
|
this.isEditing = false;
|
|
14577
14598
|
}
|
|
14599
|
+
/**
|
|
14600
|
+
* Honour control-level `disabledAttrs` / `lockedAttrs` by merging them into this field's
|
|
14601
|
+
* panels.attrs config. Reads both the registered control definition and the field's own
|
|
14602
|
+
* saved config so forms saved before a control changed still pick up its rules.
|
|
14603
|
+
*/
|
|
14604
|
+
applyControlAttrConfig() {
|
|
14605
|
+
const attrConfig = controlAttrPanelConfig(getControlConfig(components.controls?.get(this.controlId)), this.get("config"));
|
|
14606
|
+
if (attrConfig) this.config = { [this.id]: attrConfig };
|
|
14607
|
+
}
|
|
14578
14608
|
get labelConfig() {
|
|
14579
14609
|
if (!!this.get("config.hideLabel")) return null;
|
|
14580
14610
|
const { label, editorLabel, disableHtmlLabel, helpText, tooltip } = this.get("config");
|
|
@@ -15018,7 +15048,7 @@ Author: Draggable https://draggable.io
|
|
|
15018
15048
|
},
|
|
15019
15049
|
config: {
|
|
15020
15050
|
label: s.get("controls.form.radio-group"),
|
|
15021
|
-
|
|
15051
|
+
disabledAttrs: ["type"]
|
|
15022
15052
|
},
|
|
15023
15053
|
meta: {
|
|
15024
15054
|
group: "common",
|
|
@@ -17191,7 +17221,7 @@ Author: Draggable https://draggable.io
|
|
|
17191
17221
|
const { action, attrs = {} } = elem;
|
|
17192
17222
|
const fieldType = attrs.type || elem.tag;
|
|
17193
17223
|
const id = attrs.id || elem.id;
|
|
17194
|
-
const name =
|
|
17224
|
+
const name = isPreview ? id : groupInputName(attrs.name || id, fieldType, options.length);
|
|
17195
17225
|
const sharedInputAttrs = Object.fromEntries(OPTION_INPUT_ATTRS.filter((key) => key in attrs).map((key) => [key, attrs[key]]));
|
|
17196
17226
|
if (attrs.required) sharedInputAttrs.required = fieldType !== "checkbox" || !options.some(({ selected, checked }) => selected || checked);
|
|
17197
17227
|
const optionMap = (option, i) => {
|
|
@@ -18457,12 +18487,12 @@ Author: Draggable https://draggable.io
|
|
|
18457
18487
|
* @return {Object|undefined}
|
|
18458
18488
|
*/
|
|
18459
18489
|
componentByName(name) {
|
|
18460
|
-
return this.components[baseId(name)] || Object.values(this.components).find((component) => component.attrs?.name === name);
|
|
18490
|
+
return this.components[baseId(name)] || Object.values(this.components).find((component) => component.attrs?.name === name || component.attrs?.name === `${name}[]`);
|
|
18461
18491
|
}
|
|
18462
18492
|
set userData(data = {}) {
|
|
18463
18493
|
const form = this.container.querySelector("form");
|
|
18464
18494
|
for (const key of Object.keys(data)) {
|
|
18465
|
-
const fields = form.elements[key];
|
|
18495
|
+
const fields = form.elements[key] ?? form.elements[`${key}[]`];
|
|
18466
18496
|
const checkables = checkableInputs(fields);
|
|
18467
18497
|
if (checkables?.[0].type === "checkbox") {
|
|
18468
18498
|
const values = Array.isArray(data[key]) ? data[key] : [data[key]];
|
|
@@ -18748,11 +18778,12 @@ Author: Draggable https://draggable.io
|
|
|
18748
18778
|
};
|
|
18749
18779
|
getComponents = (address) => {
|
|
18750
18780
|
const components = [];
|
|
18751
|
-
const
|
|
18752
|
-
components.push(...this.renderedForm.querySelectorAll(`[name=
|
|
18781
|
+
const name = `f-${address.slice(address.indexOf(".") + 1)}`;
|
|
18782
|
+
components.push(...this.renderedForm.querySelectorAll(`[name="${name}"], [name="${name}[]"]`));
|
|
18753
18783
|
return components;
|
|
18754
18784
|
};
|
|
18755
18785
|
};
|
|
18786
|
+
var fieldKey = (key) => key.endsWith("[]") ? key.slice(0, -2) : key;
|
|
18756
18787
|
/**
|
|
18757
18788
|
* Converts a rendered form's fields to a plain object, the same shape the `userData`
|
|
18758
18789
|
* getter exposes. Handles multiple values for the same key by converting them to arrays.
|
|
@@ -18763,9 +18794,12 @@ Author: Draggable https://draggable.io
|
|
|
18763
18794
|
if (!form) return {};
|
|
18764
18795
|
const formEntries = new FormData(form);
|
|
18765
18796
|
const formDataObj = {};
|
|
18766
|
-
for (const [
|
|
18767
|
-
|
|
18768
|
-
|
|
18797
|
+
for (const [rawKey, value] of formEntries.entries()) {
|
|
18798
|
+
const key = fieldKey(rawKey);
|
|
18799
|
+
if (Object.hasOwn(formDataObj, key)) if (Array.isArray(formDataObj[key])) formDataObj[key].push(value);
|
|
18800
|
+
else formDataObj[key] = [formDataObj[key], value];
|
|
18801
|
+
else formDataObj[key] = value;
|
|
18802
|
+
}
|
|
18769
18803
|
return formDataObj;
|
|
18770
18804
|
};
|
|
18771
18805
|
var isCheckable = (elem) => ["checkbox", "radio"].includes(elem?.type);
|