formeo 2.3.0 → 3.0.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/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/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 +359 -0
- package/dist/formeo.cjs.js +3 -3
- package/dist/formeo.es.js +76 -53
- package/dist/formeo.min.css +1 -1
- package/dist/formeo.min.js +3 -3
- package/dist/formeo.umd.js +3 -3
- package/package.json +9 -5
package/dist/formeo.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
3
|
formeo - https://formeo.io
|
|
4
|
-
Version: 2.
|
|
4
|
+
Version: 2.3.1
|
|
5
5
|
Author: Draggable https://draggable.io
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -310,6 +310,8 @@ class SmartTooltip {
|
|
|
310
310
|
setupEventListeners() {
|
|
311
311
|
document.addEventListener("mouseover", this.handleMouseOver);
|
|
312
312
|
document.addEventListener("mouseout", this.handleMouseOut);
|
|
313
|
+
document.addEventListener("touchstart", this.handleMouseOver);
|
|
314
|
+
document.addEventListener("touchend", this.handleMouseOut);
|
|
313
315
|
document.addEventListener("click", this.handleClick);
|
|
314
316
|
window.addEventListener("resize", this.handleResize);
|
|
315
317
|
window.addEventListener("scroll", this.handleScroll, true);
|
|
@@ -420,6 +422,8 @@ class SmartTooltip {
|
|
|
420
422
|
destroy() {
|
|
421
423
|
document.removeEventListener("mouseover", this.handleMouseOver);
|
|
422
424
|
document.removeEventListener("mouseout", this.handleMouseOut);
|
|
425
|
+
document.removeEventListener("touchstart", this.handleMouseOver);
|
|
426
|
+
document.removeEventListener("touchend", this.handleMouseOut);
|
|
423
427
|
document.removeEventListener("click", this.handleClick);
|
|
424
428
|
window.removeEventListener("resize", this.handleResize);
|
|
425
429
|
window.removeEventListener("scroll", this.handleScroll, true);
|
|
@@ -430,7 +434,7 @@ if (window !== void 0) {
|
|
|
430
434
|
window.SmartTooltip = SmartTooltip;
|
|
431
435
|
}
|
|
432
436
|
const name$1 = "formeo";
|
|
433
|
-
const version$2 = "2.
|
|
437
|
+
const version$2 = "2.3.1";
|
|
434
438
|
const type = "module";
|
|
435
439
|
const main = "dist/formeo.cjs.js";
|
|
436
440
|
const module = "dist/formeo.es.js";
|
|
@@ -497,6 +501,7 @@ const scripts = {
|
|
|
497
501
|
"build:lib": "vite build --config vite.config.lib.mjs",
|
|
498
502
|
build: "npm-run-all -p build:icons build:demo",
|
|
499
503
|
prebuild: "npm run build:lib",
|
|
504
|
+
postbuild: "npm run generate:jsonSchema",
|
|
500
505
|
"build:demo": "vite build --mode demo",
|
|
501
506
|
"build:demo:watch": "vite build --mode demo --watch",
|
|
502
507
|
"build:icons": "node ./tools/generate-sprite",
|
|
@@ -511,7 +516,8 @@ const scripts = {
|
|
|
511
516
|
"travis-deploy-once": "travis-deploy-once --pro",
|
|
512
517
|
prepush: "npm test",
|
|
513
518
|
prepare: "lefthook install",
|
|
514
|
-
postmerge: "lefthook install"
|
|
519
|
+
postmerge: "lefthook install",
|
|
520
|
+
"generate:jsonSchema": "node --experimental-strip-types --no-warnings ./tools/generate-json-schema.ts"
|
|
515
521
|
};
|
|
516
522
|
const devDependencies = {
|
|
517
523
|
"@biomejs/biome": "^1.9.3",
|
|
@@ -522,7 +528,7 @@ const devDependencies = {
|
|
|
522
528
|
"@semantic-release/npm": "^12.0.1",
|
|
523
529
|
jsdom: "^25.0.1",
|
|
524
530
|
lefthook: "^1.7.18",
|
|
525
|
-
"npm-run-all": "^
|
|
531
|
+
"npm-run-all": "^2.1.0",
|
|
526
532
|
"sass-embedded": "^1.80.1",
|
|
527
533
|
"semantic-release": "^24.1.2",
|
|
528
534
|
"svg-sprite": "^2.0.4",
|
|
@@ -530,12 +536,14 @@ const devDependencies = {
|
|
|
530
536
|
"vite-plugin-banner": "^0.8.0",
|
|
531
537
|
"vite-plugin-compression": "^0.5.1",
|
|
532
538
|
"vite-plugin-html": "^3.2.2",
|
|
533
|
-
"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"
|
|
534
542
|
};
|
|
535
543
|
const dependencies = {
|
|
536
544
|
"@draggable/formeo-languages": "^3.1.3",
|
|
537
545
|
"@draggable/i18n": "^1.0.7",
|
|
538
|
-
"@draggable/tooltip": "^1.2.
|
|
546
|
+
"@draggable/tooltip": "^1.2.2",
|
|
539
547
|
lodash: "^4.17.21",
|
|
540
548
|
sortablejs: "^1.15.3"
|
|
541
549
|
};
|
|
@@ -1966,21 +1974,6 @@ var get_1 = get$1;
|
|
|
1966
1974
|
const lodashGet = /* @__PURE__ */ getDefaultExportFromCjs(get_1);
|
|
1967
1975
|
const get = lodashGet;
|
|
1968
1976
|
const set = lodashSet;
|
|
1969
|
-
const cleanObj = (obj) => {
|
|
1970
|
-
const fresh = { ...obj };
|
|
1971
|
-
const typeMap = {
|
|
1972
|
-
string: () => "",
|
|
1973
|
-
boolean: () => false,
|
|
1974
|
-
object: (val) => cleanObj(val)
|
|
1975
|
-
};
|
|
1976
|
-
for (const key of Object.keys(obj)) {
|
|
1977
|
-
const valType = typeof obj[key];
|
|
1978
|
-
if (typeMap[valType]) {
|
|
1979
|
-
fresh[key] = typeMap[valType](obj[key]);
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
return fresh;
|
|
1983
|
-
};
|
|
1984
1977
|
const isInt = (n) => Number.isInteger(Number(n));
|
|
1985
1978
|
const indexOfNode = (node, parent) => {
|
|
1986
1979
|
const parentElement = parent || node.parentElement;
|
|
@@ -5054,11 +5047,8 @@ class Panels {
|
|
|
5054
5047
|
action: {
|
|
5055
5048
|
click: (evt) => {
|
|
5056
5049
|
const index2 = indexOfNode(evt.target, evt.target.parentElement);
|
|
5057
|
-
this.
|
|
5058
|
-
|
|
5059
|
-
this.nav.refresh(index2);
|
|
5060
|
-
dom.removeClasses(labels2, "active-tab");
|
|
5061
|
-
evt.target.classList.add("active-tab");
|
|
5050
|
+
this.nav.setTranslateX(index2, false);
|
|
5051
|
+
this.nav.groupChange(index2);
|
|
5062
5052
|
}
|
|
5063
5053
|
},
|
|
5064
5054
|
content: panel.config.label
|
|
@@ -5131,17 +5121,18 @@ class Panels {
|
|
|
5131
5121
|
const action = {};
|
|
5132
5122
|
const groupParent = this.currentPanel.parentElement;
|
|
5133
5123
|
const labelWrap = this.labels.firstChild;
|
|
5124
|
+
const panelTabs = labelWrap.children;
|
|
5134
5125
|
const siblingGroups = this.currentPanel.parentElement.childNodes;
|
|
5135
5126
|
this.activePanelIndex = indexOfNode(this.currentPanel, groupParent);
|
|
5136
5127
|
let offset = { nav: 0, panel: 0 };
|
|
5137
5128
|
let lastOffset = { ...offset };
|
|
5138
5129
|
action.groupChange = (newIndex2) => {
|
|
5139
|
-
|
|
5140
|
-
dom.removeClasses(siblingGroups, "active-panel");
|
|
5141
|
-
dom.removeClasses(labels, "active-tab");
|
|
5130
|
+
this.activePanelIndex = newIndex2;
|
|
5142
5131
|
this.currentPanel = siblingGroups[newIndex2];
|
|
5132
|
+
dom.removeClasses(siblingGroups, "active-panel");
|
|
5133
|
+
dom.removeClasses(panelTabs, "active-tab");
|
|
5143
5134
|
this.currentPanel.classList.add("active-panel");
|
|
5144
|
-
|
|
5135
|
+
panelTabs[newIndex2].classList.add("active-tab");
|
|
5145
5136
|
return this.currentPanel;
|
|
5146
5137
|
};
|
|
5147
5138
|
const getOffset = (index2) => {
|
|
@@ -5181,22 +5172,21 @@ class Panels {
|
|
|
5181
5172
|
};
|
|
5182
5173
|
action.refresh = (newIndex2 = this.activePanelIndex) => {
|
|
5183
5174
|
if (this.activePanelIndex !== newIndex2) {
|
|
5184
|
-
this.activePanelIndex = newIndex2;
|
|
5185
5175
|
action.groupChange(newIndex2);
|
|
5186
5176
|
}
|
|
5187
|
-
action.setTranslateX(this.activePanelIndex);
|
|
5177
|
+
action.setTranslateX(this.activePanelIndex, false);
|
|
5188
5178
|
this.resizePanels();
|
|
5189
5179
|
};
|
|
5190
5180
|
action.nextGroup = () => {
|
|
5191
5181
|
const newIndex2 = this.activePanelIndex + 1;
|
|
5192
5182
|
if (newIndex2 !== siblingGroups.length) {
|
|
5193
|
-
const
|
|
5183
|
+
const nextPanel = siblingGroups[newIndex2];
|
|
5194
5184
|
offset = {
|
|
5195
5185
|
nav: -labelWrap.offsetWidth * newIndex2,
|
|
5196
|
-
panel: -
|
|
5186
|
+
panel: -nextPanel.offsetLeft
|
|
5197
5187
|
};
|
|
5198
5188
|
translateX({ offset });
|
|
5199
|
-
|
|
5189
|
+
action.groupChange(newIndex2);
|
|
5200
5190
|
} else {
|
|
5201
5191
|
offset = {
|
|
5202
5192
|
nav: lastOffset.nav - 8,
|
|
@@ -5209,13 +5199,13 @@ class Panels {
|
|
|
5209
5199
|
action.prevGroup = () => {
|
|
5210
5200
|
if (this.activePanelIndex !== 0) {
|
|
5211
5201
|
const newIndex2 = this.activePanelIndex - 1;
|
|
5212
|
-
const
|
|
5202
|
+
const prevPanel = siblingGroups[newIndex2];
|
|
5213
5203
|
offset = {
|
|
5214
5204
|
nav: -labelWrap.offsetWidth * newIndex2,
|
|
5215
|
-
panel: -
|
|
5205
|
+
panel: -prevPanel.offsetLeft
|
|
5216
5206
|
};
|
|
5217
5207
|
translateX({ offset });
|
|
5218
|
-
|
|
5208
|
+
action.groupChange(newIndex2);
|
|
5219
5209
|
} else {
|
|
5220
5210
|
offset = {
|
|
5221
5211
|
nav: 8,
|
|
@@ -6042,10 +6032,14 @@ class EditPanel {
|
|
|
6042
6032
|
const metaId = this.field.data.meta.id;
|
|
6043
6033
|
const fieldOptionData = this.field.get("options");
|
|
6044
6034
|
const type2 = metaId === "select" ? "option" : metaId;
|
|
6045
|
-
const newOptionLabel = mi18n.get(
|
|
6035
|
+
const newOptionLabel = mi18n.get("newOptionLabel", { type: type2 }) || "New Option";
|
|
6046
6036
|
const itemKey = `options.${this.data.length}`;
|
|
6047
|
-
const
|
|
6048
|
-
const
|
|
6037
|
+
const lastOptionData = fieldOptionData[fieldOptionData.length - 1];
|
|
6038
|
+
const optionTemplate = fieldOptionData.length ? lastOptionData : {};
|
|
6039
|
+
const itemData = { ...optionTemplate, label: newOptionLabel };
|
|
6040
|
+
if (metaId !== "button") {
|
|
6041
|
+
itemData.value = slugify(newOptionLabel);
|
|
6042
|
+
}
|
|
6049
6043
|
const newOption = new EditPanelItem({
|
|
6050
6044
|
key: itemKey,
|
|
6051
6045
|
data: itemData,
|
|
@@ -7448,7 +7442,7 @@ class ButtonControl extends Control {
|
|
|
7448
7442
|
options: [
|
|
7449
7443
|
{
|
|
7450
7444
|
label: mi18n.get("button"),
|
|
7451
|
-
type: ["button", "submit", "reset"].map((buttonType
|
|
7445
|
+
type: ["button", "submit", "reset"].map((buttonType) => ({
|
|
7452
7446
|
label: buttonType,
|
|
7453
7447
|
type: buttonType
|
|
7454
7448
|
})),
|
|
@@ -8581,18 +8575,28 @@ class Column extends Component {
|
|
|
8581
8575
|
super("column", { ...DEFAULT_DATA$1(), ...columnData });
|
|
8582
8576
|
// loops through children and refresh their edit panels
|
|
8583
8577
|
__publicField(this, "refreshFieldPanels", () => {
|
|
8584
|
-
|
|
8578
|
+
for (const field of this.children) {
|
|
8579
|
+
field.panels.nav.refresh();
|
|
8580
|
+
}
|
|
8581
|
+
});
|
|
8582
|
+
/**
|
|
8583
|
+
* Sets the width data and style for the column
|
|
8584
|
+
* @param {string} width - The width value to be set for the column
|
|
8585
|
+
* @returns {void}
|
|
8586
|
+
*/
|
|
8587
|
+
__publicField(this, "setDomWidth", (width) => {
|
|
8588
|
+
this.dom.dataset.colWidth = width;
|
|
8589
|
+
this.dom.style.width = width;
|
|
8585
8590
|
});
|
|
8586
8591
|
/**
|
|
8587
8592
|
* Sets a columns width
|
|
8588
8593
|
* @param {String} width percent or pixel
|
|
8589
8594
|
*/
|
|
8590
8595
|
__publicField(this, "setWidth", (width) => {
|
|
8591
|
-
this.
|
|
8592
|
-
this.dom.style.width = width;
|
|
8596
|
+
this.setDomWidth(width);
|
|
8593
8597
|
return this.set("config.width", width);
|
|
8594
8598
|
});
|
|
8595
|
-
const
|
|
8599
|
+
const childWrap = this.createChildWrap();
|
|
8596
8600
|
this.dom = dom.create({
|
|
8597
8601
|
tag: "li",
|
|
8598
8602
|
className: [COLUMN_CLASSNAME, "empty"],
|
|
@@ -8605,17 +8609,17 @@ class Column extends Component {
|
|
|
8605
8609
|
this.getActionButtons(),
|
|
8606
8610
|
DOM_CONFIGS.editWindow(),
|
|
8607
8611
|
DOM_CONFIGS.resizeHandle(new ResizeColumn()),
|
|
8608
|
-
|
|
8612
|
+
childWrap
|
|
8609
8613
|
]
|
|
8610
8614
|
});
|
|
8611
|
-
this.processConfig(
|
|
8615
|
+
this.processConfig();
|
|
8612
8616
|
events.columnResized = new window.CustomEvent("columnResized", {
|
|
8613
8617
|
detail: {
|
|
8614
8618
|
column: this.dom,
|
|
8615
8619
|
instance: this
|
|
8616
8620
|
}
|
|
8617
8621
|
});
|
|
8618
|
-
Sortable.create(
|
|
8622
|
+
Sortable.create(childWrap, {
|
|
8619
8623
|
animation: 150,
|
|
8620
8624
|
fallbackClass: "field-moving",
|
|
8621
8625
|
forceFallback: true,
|
|
@@ -8644,11 +8648,10 @@ class Column extends Component {
|
|
|
8644
8648
|
* Process column configuration data
|
|
8645
8649
|
* @param {Object} column
|
|
8646
8650
|
*/
|
|
8647
|
-
processConfig(
|
|
8651
|
+
processConfig() {
|
|
8648
8652
|
const columnWidth = helpers.get(this.data, "config.width");
|
|
8649
8653
|
if (columnWidth) {
|
|
8650
|
-
|
|
8651
|
-
column.style.width = columnWidth;
|
|
8654
|
+
this.setDomWidth(columnWidth);
|
|
8652
8655
|
}
|
|
8653
8656
|
}
|
|
8654
8657
|
}
|
|
@@ -8699,6 +8702,23 @@ let Fields$1 = class Fields extends ComponentData {
|
|
|
8699
8702
|
}
|
|
8700
8703
|
return found;
|
|
8701
8704
|
});
|
|
8705
|
+
__publicField(this, "getData", () => {
|
|
8706
|
+
return Object.entries(this.data).reduce((acc, [key, val]) => {
|
|
8707
|
+
const { conditions, ...data } = (val == null ? void 0 : val.getData()) || val;
|
|
8708
|
+
if (conditions == null ? void 0 : conditions.length) {
|
|
8709
|
+
let hasConditions = true;
|
|
8710
|
+
if (conditions.length === 1) {
|
|
8711
|
+
const [firstCondition] = conditions;
|
|
8712
|
+
hasConditions = Boolean(firstCondition.if[0].source && firstCondition.then[0].target);
|
|
8713
|
+
}
|
|
8714
|
+
if (hasConditions) {
|
|
8715
|
+
data.conditions = conditions;
|
|
8716
|
+
}
|
|
8717
|
+
}
|
|
8718
|
+
acc[key] = data;
|
|
8719
|
+
return acc;
|
|
8720
|
+
}, {});
|
|
8721
|
+
});
|
|
8702
8722
|
this.config = { all: DEFAULT_CONFIG };
|
|
8703
8723
|
}
|
|
8704
8724
|
Component(data) {
|
|
@@ -8777,7 +8797,10 @@ class Components extends Data {
|
|
|
8777
8797
|
}, acculumator);
|
|
8778
8798
|
}
|
|
8779
8799
|
get json() {
|
|
8780
|
-
return window.JSON.stringify(
|
|
8800
|
+
return window.JSON.stringify({
|
|
8801
|
+
$schema: `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/formData_schema.json`,
|
|
8802
|
+
...this.formData
|
|
8803
|
+
});
|
|
8781
8804
|
}
|
|
8782
8805
|
get formData() {
|
|
8783
8806
|
return {
|