formeo 2.3.1 → 3.0.1
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 +2 -2
- package/dist/demo/assets/css/demo.min.css.gz +0 -0
- package/dist/demo/assets/css/formeo.min.css +2 -2
- package/dist/demo/assets/css/formeo.min.css.gz +0 -0
- package/dist/demo/assets/js/demo.min.js +2 -2
- package/dist/demo/assets/js/demo.min.js.gz +0 -0
- package/dist/demo/assets/js/formeo.min.js +3 -3
- package/dist/demo/assets/js/formeo.min.js.gz +0 -0
- package/dist/demo/index.html +1 -1
- package/dist/formData_schema.json +363 -0
- package/dist/formeo.cjs.js +3 -3
- package/dist/formeo.es.js +193 -82
- package/dist/formeo.min.css +2 -2
- package/dist/formeo.min.js +3 -3
- package/dist/formeo.umd.js +3 -3
- package/package.json +8 -4
package/dist/formeo.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
3
|
formeo - https://formeo.io
|
|
4
|
-
Version:
|
|
4
|
+
Version: 3.0.0
|
|
5
5
|
Author: Draggable https://draggable.io
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -434,7 +434,7 @@ if (window !== void 0) {
|
|
|
434
434
|
window.SmartTooltip = SmartTooltip;
|
|
435
435
|
}
|
|
436
436
|
const name$1 = "formeo";
|
|
437
|
-
const version$2 = "
|
|
437
|
+
const version$2 = "3.0.0";
|
|
438
438
|
const type = "module";
|
|
439
439
|
const main = "dist/formeo.cjs.js";
|
|
440
440
|
const module = "dist/formeo.es.js";
|
|
@@ -501,6 +501,7 @@ const scripts = {
|
|
|
501
501
|
"build:lib": "vite build --config vite.config.lib.mjs",
|
|
502
502
|
build: "npm-run-all -p build:icons build:demo",
|
|
503
503
|
prebuild: "npm run build:lib",
|
|
504
|
+
postbuild: "npm run generate:jsonSchema",
|
|
504
505
|
"build:demo": "vite build --mode demo",
|
|
505
506
|
"build:demo:watch": "vite build --mode demo --watch",
|
|
506
507
|
"build:icons": "node ./tools/generate-sprite",
|
|
@@ -515,7 +516,8 @@ const scripts = {
|
|
|
515
516
|
"travis-deploy-once": "travis-deploy-once --pro",
|
|
516
517
|
prepush: "npm test",
|
|
517
518
|
prepare: "lefthook install",
|
|
518
|
-
postmerge: "lefthook install"
|
|
519
|
+
postmerge: "lefthook install",
|
|
520
|
+
"generate:jsonSchema": "node --experimental-strip-types --no-warnings ./tools/generate-json-schema.ts"
|
|
519
521
|
};
|
|
520
522
|
const devDependencies = {
|
|
521
523
|
"@biomejs/biome": "^1.9.3",
|
|
@@ -526,7 +528,7 @@ const devDependencies = {
|
|
|
526
528
|
"@semantic-release/npm": "^12.0.1",
|
|
527
529
|
jsdom: "^25.0.1",
|
|
528
530
|
lefthook: "^1.7.18",
|
|
529
|
-
"npm-run-all": "^
|
|
531
|
+
"npm-run-all": "^2.1.0",
|
|
530
532
|
"sass-embedded": "^1.80.1",
|
|
531
533
|
"semantic-release": "^24.1.2",
|
|
532
534
|
"svg-sprite": "^2.0.4",
|
|
@@ -534,7 +536,9 @@ const devDependencies = {
|
|
|
534
536
|
"vite-plugin-banner": "^0.8.0",
|
|
535
537
|
"vite-plugin-compression": "^0.5.1",
|
|
536
538
|
"vite-plugin-html": "^3.2.2",
|
|
537
|
-
"vite-plugin-static-copy": "^2.0.0"
|
|
539
|
+
"vite-plugin-static-copy": "^2.0.0",
|
|
540
|
+
zod: "^3.23.8",
|
|
541
|
+
"zod-to-json-schema": "^3.23.5"
|
|
538
542
|
};
|
|
539
543
|
const dependencies = {
|
|
540
544
|
"@draggable/formeo-languages": "^3.1.3",
|
|
@@ -2658,6 +2662,25 @@ class Data {
|
|
|
2658
2662
|
});
|
|
2659
2663
|
__publicField(this, "setCallbacks", {});
|
|
2660
2664
|
__publicField(this, "configVal", /* @__PURE__ */ Object.create(null));
|
|
2665
|
+
/**
|
|
2666
|
+
* Parses the provided data argument. If the argument is a string, it attempts to parse it as JSON.
|
|
2667
|
+
* If the parsing fails, it logs an error and returns an empty object.
|
|
2668
|
+
* If the argument is not a string, it returns the argument as is.
|
|
2669
|
+
*
|
|
2670
|
+
* @param {string|Object} dataArg - The data to be parsed. Can be a JSON string or an object.
|
|
2671
|
+
* @returns {Object} - The parsed object or the original object if the input was not a string.
|
|
2672
|
+
*/
|
|
2673
|
+
__publicField(this, "parseformData", (dataArg = /* @__PURE__ */ Object.create(null)) => {
|
|
2674
|
+
if (typeof dataArg === "string") {
|
|
2675
|
+
try {
|
|
2676
|
+
return JSON.parse(dataArg);
|
|
2677
|
+
} catch (e) {
|
|
2678
|
+
console.error("Invalid JSON string provided:", e);
|
|
2679
|
+
return /* @__PURE__ */ Object.create(null);
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
return dataArg;
|
|
2683
|
+
});
|
|
2661
2684
|
this.name = name2;
|
|
2662
2685
|
this.data = data;
|
|
2663
2686
|
this.dataPath = "";
|
|
@@ -5242,10 +5265,10 @@ const labelCount = (arr, label) => {
|
|
|
5242
5265
|
return count > 1 ? `(${count})` : "";
|
|
5243
5266
|
};
|
|
5244
5267
|
const getComponentLabel = ({ name: name2, id, ...component }) => {
|
|
5245
|
-
const labelPaths = ["config.label", "
|
|
5268
|
+
const labelPaths = ["config.label", "config.controlId", "meta.id", "attrs.id"];
|
|
5246
5269
|
const label = labelPaths.reduce((acc, cur) => {
|
|
5247
5270
|
if (!acc) {
|
|
5248
|
-
|
|
5271
|
+
return component.get(cur);
|
|
5249
5272
|
}
|
|
5250
5273
|
return acc;
|
|
5251
5274
|
}, null);
|
|
@@ -6002,7 +6025,8 @@ class EditPanel {
|
|
|
6002
6025
|
* @param {String} attr
|
|
6003
6026
|
* @param {String|Array} val
|
|
6004
6027
|
*/
|
|
6005
|
-
__publicField(this, "addAttribute", (attr,
|
|
6028
|
+
__publicField(this, "addAttribute", (attr, valArg) => {
|
|
6029
|
+
let val = valArg;
|
|
6006
6030
|
const safeAttr = slugify(attr);
|
|
6007
6031
|
const itemKey = `attrs.${safeAttr}`;
|
|
6008
6032
|
if (!mi18n.current[itemKey]) {
|
|
@@ -6025,15 +6049,15 @@ class EditPanel {
|
|
|
6025
6049
|
* Add option to options panel
|
|
6026
6050
|
*/
|
|
6027
6051
|
__publicField(this, "addOption", () => {
|
|
6028
|
-
const
|
|
6052
|
+
const controlId = this.field.data.config.controlId;
|
|
6029
6053
|
const fieldOptionData = this.field.get("options");
|
|
6030
|
-
const type2 =
|
|
6054
|
+
const type2 = controlId === "select" ? "option" : controlId;
|
|
6031
6055
|
const newOptionLabel = mi18n.get("newOptionLabel", { type: type2 }) || "New Option";
|
|
6032
6056
|
const itemKey = `options.${this.data.length}`;
|
|
6033
6057
|
const lastOptionData = fieldOptionData[fieldOptionData.length - 1];
|
|
6034
6058
|
const optionTemplate = fieldOptionData.length ? lastOptionData : {};
|
|
6035
6059
|
const itemData = { ...optionTemplate, label: newOptionLabel };
|
|
6036
|
-
if (
|
|
6060
|
+
if (controlId !== "button") {
|
|
6037
6061
|
itemData.value = slugify(newOptionLabel);
|
|
6038
6062
|
}
|
|
6039
6063
|
const newOption = new EditPanelItem({
|
|
@@ -6547,6 +6571,7 @@ class Component extends Data {
|
|
|
6547
6571
|
}
|
|
6548
6572
|
/**
|
|
6549
6573
|
* Method for handling onAdd for all components
|
|
6574
|
+
* @todo improve readability of this method
|
|
6550
6575
|
* @param {Object} evt
|
|
6551
6576
|
* @return {Object} Component
|
|
6552
6577
|
*/
|
|
@@ -6588,10 +6613,13 @@ class Component extends Data {
|
|
|
6588
6613
|
]);
|
|
6589
6614
|
const onAddConditions = {
|
|
6590
6615
|
controls: () => {
|
|
6591
|
-
const { controlData } = Controls$2.get(item.id);
|
|
6592
6616
|
const {
|
|
6593
|
-
|
|
6594
|
-
|
|
6617
|
+
controlData: {
|
|
6618
|
+
meta: { id: metaId },
|
|
6619
|
+
...elementData
|
|
6620
|
+
}
|
|
6621
|
+
} = Controls$2.get(item.id);
|
|
6622
|
+
set(elementData, "config.controlId", metaId);
|
|
6595
6623
|
const controlType = metaId.startsWith("layout-") ? metaId.replace(/^layout-/, "") : "field";
|
|
6596
6624
|
const targets = {
|
|
6597
6625
|
stage: {
|
|
@@ -6614,7 +6642,7 @@ class Component extends Data {
|
|
|
6614
6642
|
const depth = get(targets, `${this.name}.${controlType}`);
|
|
6615
6643
|
const action = depthMap.get(depth)();
|
|
6616
6644
|
dom.remove(item);
|
|
6617
|
-
const component2 = action(
|
|
6645
|
+
const component2 = action(elementData, newIndex2);
|
|
6618
6646
|
return component2;
|
|
6619
6647
|
},
|
|
6620
6648
|
row: () => {
|
|
@@ -6664,10 +6692,23 @@ class Component extends Data {
|
|
|
6664
6692
|
}
|
|
6665
6693
|
events2.onRender && dom.onRender(this.dom, events2.onRender);
|
|
6666
6694
|
}
|
|
6695
|
+
/**
|
|
6696
|
+
* Sets the configuration for the component. See src/demo/js/options/config.js for example
|
|
6697
|
+
* @param {Object} config - Configuration object with possible structures:
|
|
6698
|
+
* @param {Object} [config.all] - Global configuration applied to all components
|
|
6699
|
+
* @param {Object} [config[controlId]] - Configuration specific to a control type
|
|
6700
|
+
* @param {Object} [config[id]] - Configuration specific to a component instance
|
|
6701
|
+
* @description Merges configurations in order of precedence:
|
|
6702
|
+
* 1. Existing config (this.configVal)
|
|
6703
|
+
* 2. Global config (all)
|
|
6704
|
+
* 3. Control type specific config
|
|
6705
|
+
* 4. Instance specific config
|
|
6706
|
+
* The merged result is stored in this.configVal
|
|
6707
|
+
*/
|
|
6667
6708
|
set config(config2) {
|
|
6668
|
-
const metaId = get(this.data, "meta.id");
|
|
6669
6709
|
const allConfig = get(config2, "all");
|
|
6670
|
-
const
|
|
6710
|
+
const controlId = get(this.data, "config.controlId");
|
|
6711
|
+
const typeConfig = controlId && get(config2, controlId);
|
|
6671
6712
|
const idConfig = get(config2, this.id);
|
|
6672
6713
|
const mergedConfig = [allConfig, typeConfig, idConfig].reduce(
|
|
6673
6714
|
(acc, cur) => cur ? merge(acc, cur) : acc,
|
|
@@ -6834,7 +6875,7 @@ class Field extends Component {
|
|
|
6834
6875
|
get labelConfig() {
|
|
6835
6876
|
const hideLabel = !!this.get("config.hideLabel");
|
|
6836
6877
|
if (hideLabel) {
|
|
6837
|
-
return;
|
|
6878
|
+
return null;
|
|
6838
6879
|
}
|
|
6839
6880
|
const labelVal = this.get("config.editorLabel") || this.get("config.label");
|
|
6840
6881
|
const required = this.get("attrs.required");
|
|
@@ -6986,7 +7027,7 @@ class Field extends Component {
|
|
|
6986
7027
|
fieldPreview() {
|
|
6987
7028
|
var _a;
|
|
6988
7029
|
const prevData = clone$1(this.data);
|
|
6989
|
-
const { action = {} } = Controls$2.get(prevData.
|
|
7030
|
+
const { action = {} } = Controls$2.get(prevData.config.controlId);
|
|
6990
7031
|
prevData.id = `prev-${this.id}`;
|
|
6991
7032
|
prevData.action = action;
|
|
6992
7033
|
if ((_a = this.data) == null ? void 0 : _a.config.editableContent) {
|
|
@@ -7438,7 +7479,7 @@ class ButtonControl extends Control {
|
|
|
7438
7479
|
options: [
|
|
7439
7480
|
{
|
|
7440
7481
|
label: mi18n.get("button"),
|
|
7441
|
-
type: ["button", "submit", "reset"].map((buttonType
|
|
7482
|
+
type: ["button", "submit", "reset"].map((buttonType) => ({
|
|
7442
7483
|
label: buttonType,
|
|
7443
7484
|
type: buttonType
|
|
7444
7485
|
})),
|
|
@@ -7669,21 +7710,25 @@ const defaultElements = [...formControls, ...htmlControls, ...layoutControls];
|
|
|
7669
7710
|
let Controls$1 = class Controls {
|
|
7670
7711
|
constructor() {
|
|
7671
7712
|
__publicField(this, "groupLabel", (key) => mi18n.get(key) || key || "");
|
|
7713
|
+
__publicField(this, "layoutTypes", {
|
|
7714
|
+
row: () => Stages2.active.addChild(),
|
|
7715
|
+
column: () => this.layoutTypes.row().addChild(),
|
|
7716
|
+
field: (controlData) => this.layoutTypes.column().addChild(controlData)
|
|
7717
|
+
});
|
|
7672
7718
|
/**
|
|
7673
7719
|
* Append an element to the stage
|
|
7674
7720
|
* @param {String} id of elements
|
|
7675
7721
|
*/
|
|
7676
7722
|
__publicField(this, "addElement", (id) => {
|
|
7677
|
-
const controlData = get(this.get(id), "controlData");
|
|
7678
7723
|
const {
|
|
7679
|
-
meta: { group, id: metaId }
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
}
|
|
7686
|
-
return
|
|
7724
|
+
meta: { group, id: metaId },
|
|
7725
|
+
...elementData
|
|
7726
|
+
} = get(this.get(id), "controlData");
|
|
7727
|
+
set(elementData, "config.controlId", metaId);
|
|
7728
|
+
if (group === "layout") {
|
|
7729
|
+
return this.layoutTypes[metaId.replace("layout-", "")]();
|
|
7730
|
+
}
|
|
7731
|
+
return this.layoutTypes.field(elementData);
|
|
7687
7732
|
});
|
|
7688
7733
|
__publicField(this, "applyOptions", async (controlOptions = {}) => {
|
|
7689
7734
|
const { container, elements, groupOrder, ...options } = merge(defaultOptions, controlOptions);
|
|
@@ -7763,16 +7808,16 @@ let Controls$1 = class Controls {
|
|
|
7763
7808
|
elements = orderObjectsBy(elements, group.elementOrder, "meta.id");
|
|
7764
7809
|
groupConfig.content = elements.filter((control) => {
|
|
7765
7810
|
const { controlData: field } = this.get(control.id);
|
|
7766
|
-
const
|
|
7811
|
+
const controlId = field.meta.id || "";
|
|
7767
7812
|
const filters = [
|
|
7768
|
-
match(
|
|
7813
|
+
match(controlId, this.options.disable.elements),
|
|
7769
7814
|
field.meta.group === group.id,
|
|
7770
|
-
!usedElementIds.includes(
|
|
7815
|
+
!usedElementIds.includes(controlId)
|
|
7771
7816
|
];
|
|
7772
7817
|
let shouldFilter = true;
|
|
7773
7818
|
shouldFilter = filters.every((val) => val === true);
|
|
7774
7819
|
if (shouldFilter) {
|
|
7775
|
-
usedElementIds.push(
|
|
7820
|
+
usedElementIds.push(controlId);
|
|
7776
7821
|
}
|
|
7777
7822
|
return shouldFilter;
|
|
7778
7823
|
});
|
|
@@ -7966,15 +8011,28 @@ const Controls$2 = new Controls$1();
|
|
|
7966
8011
|
class ComponentData extends Data {
|
|
7967
8012
|
constructor() {
|
|
7968
8013
|
super(...arguments);
|
|
7969
|
-
__publicField(this, "load", (
|
|
8014
|
+
__publicField(this, "load", (dataArg) => {
|
|
8015
|
+
const data = this.parseformData(dataArg);
|
|
7970
8016
|
this.empty();
|
|
7971
|
-
|
|
7972
|
-
|
|
8017
|
+
for (const [key, val] of Object.entries(data)) {
|
|
8018
|
+
this.add(key, val);
|
|
7973
8019
|
}
|
|
7974
|
-
Object.entries(data).forEach(([key, val]) => this.add(key, val));
|
|
7975
8020
|
return this.data;
|
|
7976
8021
|
});
|
|
8022
|
+
/**
|
|
8023
|
+
* Retrieves data from the specified path or adds new data if no path is provided.
|
|
8024
|
+
*
|
|
8025
|
+
* @param {string} [path] - The path to retrieve data from. If not provided, new data will be added.
|
|
8026
|
+
* @returns {*} The data retrieved from the specified path or the result of adding new data.
|
|
8027
|
+
*/
|
|
7977
8028
|
__publicField(this, "get", (path) => path ? get(this.data, path) : this.add());
|
|
8029
|
+
/**
|
|
8030
|
+
* Adds a new component with the given id and data.
|
|
8031
|
+
*
|
|
8032
|
+
* @param {string} id - The unique identifier for the component. If not provided, a new UUID will be generated.
|
|
8033
|
+
* @param {Object} [data=Object.create(null)] - The data to initialize the component with.
|
|
8034
|
+
* @returns {Object} The newly created component.
|
|
8035
|
+
*/
|
|
7978
8036
|
__publicField(this, "add", (id, data = /* @__PURE__ */ Object.create(null)) => {
|
|
7979
8037
|
const elemId = id || uuid();
|
|
7980
8038
|
const component = this.Component({ ...data, id: elemId });
|
|
@@ -7988,14 +8046,20 @@ class ComponentData extends Data {
|
|
|
7988
8046
|
*/
|
|
7989
8047
|
__publicField(this, "remove", (componentId) => {
|
|
7990
8048
|
if (Array.isArray(componentId)) {
|
|
7991
|
-
|
|
8049
|
+
for (const id of componentId) {
|
|
7992
8050
|
this.get(id).remove();
|
|
7993
|
-
}
|
|
8051
|
+
}
|
|
7994
8052
|
} else {
|
|
7995
8053
|
this.get(componentId).remove();
|
|
7996
8054
|
}
|
|
7997
8055
|
return this.data;
|
|
7998
8056
|
});
|
|
8057
|
+
/**
|
|
8058
|
+
* Deletes a component from the data object.
|
|
8059
|
+
*
|
|
8060
|
+
* @param {string} componentId - The ID of the component to delete.
|
|
8061
|
+
* @returns {string} The ID of the deleted component.
|
|
8062
|
+
*/
|
|
7999
8063
|
__publicField(this, "delete", (componentId) => {
|
|
8000
8064
|
delete this.data[componentId];
|
|
8001
8065
|
return componentId;
|
|
@@ -8575,16 +8639,24 @@ class Column extends Component {
|
|
|
8575
8639
|
field.panels.nav.refresh();
|
|
8576
8640
|
}
|
|
8577
8641
|
});
|
|
8642
|
+
/**
|
|
8643
|
+
* Sets the width data and style for the column
|
|
8644
|
+
* @param {string} width - The width value to be set for the column
|
|
8645
|
+
* @returns {void}
|
|
8646
|
+
*/
|
|
8647
|
+
__publicField(this, "setDomWidth", (width) => {
|
|
8648
|
+
this.dom.dataset.colWidth = width;
|
|
8649
|
+
this.dom.style.width = width;
|
|
8650
|
+
});
|
|
8578
8651
|
/**
|
|
8579
8652
|
* Sets a columns width
|
|
8580
8653
|
* @param {String} width percent or pixel
|
|
8581
8654
|
*/
|
|
8582
8655
|
__publicField(this, "setWidth", (width) => {
|
|
8583
|
-
this.
|
|
8584
|
-
this.dom.style.width = width;
|
|
8656
|
+
this.setDomWidth(width);
|
|
8585
8657
|
return this.set("config.width", width);
|
|
8586
8658
|
});
|
|
8587
|
-
const
|
|
8659
|
+
const childWrap = this.createChildWrap();
|
|
8588
8660
|
this.dom = dom.create({
|
|
8589
8661
|
tag: "li",
|
|
8590
8662
|
className: [COLUMN_CLASSNAME, "empty"],
|
|
@@ -8597,17 +8669,17 @@ class Column extends Component {
|
|
|
8597
8669
|
this.getActionButtons(),
|
|
8598
8670
|
DOM_CONFIGS.editWindow(),
|
|
8599
8671
|
DOM_CONFIGS.resizeHandle(new ResizeColumn()),
|
|
8600
|
-
|
|
8672
|
+
childWrap
|
|
8601
8673
|
]
|
|
8602
8674
|
});
|
|
8603
|
-
this.processConfig(
|
|
8675
|
+
this.processConfig();
|
|
8604
8676
|
events.columnResized = new window.CustomEvent("columnResized", {
|
|
8605
8677
|
detail: {
|
|
8606
8678
|
column: this.dom,
|
|
8607
8679
|
instance: this
|
|
8608
8680
|
}
|
|
8609
8681
|
});
|
|
8610
|
-
Sortable.create(
|
|
8682
|
+
Sortable.create(childWrap, {
|
|
8611
8683
|
animation: 150,
|
|
8612
8684
|
fallbackClass: "field-moving",
|
|
8613
8685
|
forceFallback: true,
|
|
@@ -8636,11 +8708,10 @@ class Column extends Component {
|
|
|
8636
8708
|
* Process column configuration data
|
|
8637
8709
|
* @param {Object} column
|
|
8638
8710
|
*/
|
|
8639
|
-
processConfig(
|
|
8711
|
+
processConfig() {
|
|
8640
8712
|
const columnWidth = helpers.get(this.data, "config.width");
|
|
8641
8713
|
if (columnWidth) {
|
|
8642
|
-
|
|
8643
|
-
column.style.width = columnWidth;
|
|
8714
|
+
this.setDomWidth(columnWidth);
|
|
8644
8715
|
}
|
|
8645
8716
|
}
|
|
8646
8717
|
}
|
|
@@ -8691,6 +8762,35 @@ let Fields$1 = class Fields extends ComponentData {
|
|
|
8691
8762
|
}
|
|
8692
8763
|
return found;
|
|
8693
8764
|
});
|
|
8765
|
+
__publicField(this, "getData", () => {
|
|
8766
|
+
return Object.entries(this.data).reduce((acc, [key, val]) => {
|
|
8767
|
+
const { conditions, ...data } = (val == null ? void 0 : val.getData()) || val;
|
|
8768
|
+
if (conditions == null ? void 0 : conditions.length) {
|
|
8769
|
+
let hasConditions = true;
|
|
8770
|
+
if (conditions.length === 1) {
|
|
8771
|
+
const [firstCondition] = conditions;
|
|
8772
|
+
hasConditions = Boolean(firstCondition.if[0].source && firstCondition.then[0].target);
|
|
8773
|
+
}
|
|
8774
|
+
if (hasConditions) {
|
|
8775
|
+
data.conditions = conditions;
|
|
8776
|
+
}
|
|
8777
|
+
}
|
|
8778
|
+
acc[key] = data;
|
|
8779
|
+
return acc;
|
|
8780
|
+
}, {});
|
|
8781
|
+
});
|
|
8782
|
+
__publicField(this, "load", (dataArg = /* @__PURE__ */ Object.create(null)) => {
|
|
8783
|
+
const allFieldData = this.parseformData(dataArg);
|
|
8784
|
+
this.empty();
|
|
8785
|
+
for (const [key, val] of Object.entries(allFieldData)) {
|
|
8786
|
+
const { meta, ...data } = val;
|
|
8787
|
+
if (meta == null ? void 0 : meta.id) {
|
|
8788
|
+
set(data, "config.controlId", meta == null ? void 0 : meta.id);
|
|
8789
|
+
}
|
|
8790
|
+
this.add(key, data);
|
|
8791
|
+
}
|
|
8792
|
+
return this.data;
|
|
8793
|
+
});
|
|
8694
8794
|
this.config = { all: DEFAULT_CONFIG };
|
|
8695
8795
|
}
|
|
8696
8796
|
Component(data) {
|
|
@@ -8769,7 +8869,10 @@ class Components extends Data {
|
|
|
8769
8869
|
}, acculumator);
|
|
8770
8870
|
}
|
|
8771
8871
|
get json() {
|
|
8772
|
-
return window.JSON.stringify(
|
|
8872
|
+
return window.JSON.stringify({
|
|
8873
|
+
$schema: `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/formData_schema.json`,
|
|
8874
|
+
...this.formData
|
|
8875
|
+
});
|
|
8773
8876
|
}
|
|
8774
8877
|
get formData() {
|
|
8775
8878
|
return {
|
|
@@ -9826,51 +9929,59 @@ let FormeoRenderer$1 = class FormeoRenderer {
|
|
|
9826
9929
|
(column) => this.cacheComponent(this.processColumn(column))
|
|
9827
9930
|
);
|
|
9828
9931
|
});
|
|
9829
|
-
__publicField(this, "
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
}
|
|
9840
|
-
const mergedFieldData = merge({ action }, field);
|
|
9841
|
-
return this.cacheComponent({ ...mergedFieldData, id: this.prefixId(id) });
|
|
9842
|
-
});
|
|
9843
|
-
});
|
|
9932
|
+
__publicField(this, "processFields", (fieldIds) => this.orderChildren("fields", fieldIds).map(({ id, ...field }) => {
|
|
9933
|
+
var _a, _b;
|
|
9934
|
+
const controlId = ((_a = field.config) == null ? void 0 : _a.controlId) || ((_b = field.meta) == null ? void 0 : _b.id);
|
|
9935
|
+
const { action = {}, dependencies: dependencies2 = {} } = this.elements[controlId] || {};
|
|
9936
|
+
if (dependencies2) {
|
|
9937
|
+
fetchDependencies(dependencies2);
|
|
9938
|
+
}
|
|
9939
|
+
const mergedFieldData = merge({ action }, field);
|
|
9940
|
+
return this.cacheComponent({ ...mergedFieldData, id: this.prefixId(id) });
|
|
9941
|
+
}));
|
|
9844
9942
|
/**
|
|
9845
9943
|
* Evaulate and execute conditions for fields by creating listeners for input and changes
|
|
9846
9944
|
* @return {Array} flattened array of conditions
|
|
9847
9945
|
*/
|
|
9946
|
+
__publicField(this, "handleComponentCondition", (component, ifRest, thenConditions) => {
|
|
9947
|
+
const listenerEvent = LISTEN_TYPE_MAP(component);
|
|
9948
|
+
if (listenerEvent) {
|
|
9949
|
+
component.addEventListener(
|
|
9950
|
+
listenerEvent,
|
|
9951
|
+
(evt) => {
|
|
9952
|
+
if (this.evaluateCondition(ifRest, evt)) {
|
|
9953
|
+
for (const thenCondition of thenConditions) {
|
|
9954
|
+
this.execResult(thenCondition, evt);
|
|
9955
|
+
}
|
|
9956
|
+
}
|
|
9957
|
+
},
|
|
9958
|
+
false
|
|
9959
|
+
);
|
|
9960
|
+
}
|
|
9961
|
+
const fakeEvt = { target: component };
|
|
9962
|
+
if (this.evaluateCondition(ifRest, fakeEvt)) {
|
|
9963
|
+
for (const thenCondition of thenConditions) {
|
|
9964
|
+
this.execResult(thenCondition, fakeEvt);
|
|
9965
|
+
}
|
|
9966
|
+
}
|
|
9967
|
+
});
|
|
9848
9968
|
__publicField(this, "applyConditions", () => {
|
|
9849
|
-
Object.values(this.components)
|
|
9969
|
+
for (const { conditions } of Object.values(this.components)) {
|
|
9850
9970
|
if (conditions) {
|
|
9851
|
-
|
|
9971
|
+
for (const condition of conditions) {
|
|
9852
9972
|
const { if: ifConditions, then: thenConditions } = condition;
|
|
9853
|
-
|
|
9973
|
+
for (const ifCondition of ifConditions) {
|
|
9854
9974
|
const { source, ...ifRest } = ifCondition;
|
|
9855
9975
|
if (isAddress(source)) {
|
|
9856
9976
|
const components2 = this.getComponents(source);
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
component.addEventListener(
|
|
9861
|
-
listenerEvent,
|
|
9862
|
-
(evt) => this.evaluateCondition(ifRest, evt) && thenConditions.forEach((thenCondition) => this.execResult(thenCondition, evt)),
|
|
9863
|
-
false
|
|
9864
|
-
);
|
|
9865
|
-
}
|
|
9866
|
-
const fakeEvt = { target: component };
|
|
9867
|
-
this.evaluateCondition(ifRest, fakeEvt) && thenConditions.forEach((thenCondition) => this.execResult(thenCondition, fakeEvt));
|
|
9868
|
-
});
|
|
9977
|
+
for (const component of components2) {
|
|
9978
|
+
this.handleComponentCondition(component, ifRest, thenConditions);
|
|
9979
|
+
}
|
|
9869
9980
|
}
|
|
9870
|
-
}
|
|
9871
|
-
}
|
|
9981
|
+
}
|
|
9982
|
+
}
|
|
9872
9983
|
}
|
|
9873
|
-
}
|
|
9984
|
+
}
|
|
9874
9985
|
});
|
|
9875
9986
|
/**
|
|
9876
9987
|
* Evaulate conditions
|