formeo 4.0.0 → 4.1.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/README.md +2 -2
- 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 +2 -2
- package/dist/demo/assets/js/demo.min.js.gz +0 -0
- package/dist/demo/assets/js/formeo.cjs.js +218 -95
- package/dist/demo/assets/js/formeo.es.js +134 -12
- package/dist/demo/assets/js/formeo.min.cjs.js +3 -3
- package/dist/demo/assets/js/formeo.min.es.js +134 -12
- package/dist/demo/assets/js/formeo.min.js +218 -95
- package/dist/demo/assets/js/formeo.min.umd.js +3 -3
- package/dist/demo/assets/js/formeo.umd.js +218 -95
- package/dist/demo/assets/js/index.min.js +1 -1
- package/dist/demo/assets/js/index.min2.js +1 -1
- package/dist/demo/assets/js/index.min3.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 +218 -95
- package/dist/formeo.css +1 -1
- package/dist/formeo.es.js +134 -12
- package/dist/formeo.min.cjs.js +3 -3
- package/dist/formeo.min.css +1 -1
- package/dist/formeo.min.es.js +134 -12
- package/dist/formeo.min.js +218 -95
- package/dist/formeo.min.umd.js +3 -3
- package/dist/formeo.umd.js +218 -95
- package/package.json +2 -2
package/dist/formeo.css
CHANGED
package/dist/formeo.es.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
3
|
formeo - https://formeo.io
|
|
4
|
-
Version:
|
|
4
|
+
Version: 4.1.0
|
|
5
5
|
Author: Draggable https://draggable.io
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
9
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
10
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
-
var _a, _b;
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
async function fetchData(url) {
|
|
13
13
|
try {
|
|
14
14
|
const response = await fetch(url);
|
|
@@ -435,7 +435,7 @@ if (window !== void 0) {
|
|
|
435
435
|
window.SmartTooltip = SmartTooltip;
|
|
436
436
|
}
|
|
437
437
|
const name$1 = "formeo";
|
|
438
|
-
const version$2 = "
|
|
438
|
+
const version$2 = "4.1.0";
|
|
439
439
|
const type = "module";
|
|
440
440
|
const main = "dist/formeo.cjs.js";
|
|
441
441
|
const module = "dist/formeo.es.js";
|
|
@@ -566,7 +566,7 @@ const dependencies = {
|
|
|
566
566
|
sortablejs: "^1.15.3"
|
|
567
567
|
};
|
|
568
568
|
const release = {
|
|
569
|
-
branch: "
|
|
569
|
+
branch: "main",
|
|
570
570
|
verifyConditions: [
|
|
571
571
|
"@semantic-release/changelog",
|
|
572
572
|
"@semantic-release/npm",
|
|
@@ -1706,7 +1706,7 @@ const POLYFILLS = [
|
|
|
1706
1706
|
];
|
|
1707
1707
|
const relativeSpritePath = `../../lib/icons/${formeoSpriteId}.svg`;
|
|
1708
1708
|
const localSpriteUrl = typeof import.meta.resolve === "function" ? import.meta.resolve(relativeSpritePath) : relativeSpritePath;
|
|
1709
|
-
const isDev = ((_b = (_a = import.meta) == null ? void 0 : _a.env) == null ? void 0 : _b.DEV) || process.env.NODE_ENV === "development" || false;
|
|
1709
|
+
const isDev = ((_b = (_a = import.meta) == null ? void 0 : _a.env) == null ? void 0 : _b.DEV) || typeof process !== "undefined" && ((_c = process.env) == null ? void 0 : _c.NODE_ENV) === "development" || false;
|
|
1710
1710
|
const SVG_SPRITE_URL = isDev ? localSpriteUrl : `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/${formeoSpriteId}.svg`;
|
|
1711
1711
|
const FALLBACK_SVG_SPRITE_URL = `https://draggable.github.io/formeo/assets/img/${formeoSpriteId}.svg`;
|
|
1712
1712
|
const CSS_URL = `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/formeo.min.css`;
|
|
@@ -4953,13 +4953,13 @@ const iconFontTemplates = {
|
|
|
4953
4953
|
};
|
|
4954
4954
|
const inputTags = /* @__PURE__ */ new Set(["input", "textarea", "select"]);
|
|
4955
4955
|
const getName = (elem = {}) => {
|
|
4956
|
-
var _a2, _b2,
|
|
4956
|
+
var _a2, _b2, _c2;
|
|
4957
4957
|
let name2 = ((_a2 = elem == null ? void 0 : elem.attrs) == null ? void 0 : _a2.name) || (elem == null ? void 0 : elem.name);
|
|
4958
4958
|
if (name2) {
|
|
4959
4959
|
return name2;
|
|
4960
4960
|
}
|
|
4961
4961
|
const id = uuid(elem);
|
|
4962
|
-
let label = ((_b2 = elem.config) == null ? void 0 : _b2.label) || ((
|
|
4962
|
+
let label = ((_b2 = elem.config) == null ? void 0 : _b2.label) || ((_c2 = elem.attrs) == null ? void 0 : _c2.label) || (elem == null ? void 0 : elem.label);
|
|
4963
4963
|
if (label) {
|
|
4964
4964
|
if (typeof label === "object") {
|
|
4965
4965
|
label = dom.create(label).textContent;
|
|
@@ -5000,7 +5000,7 @@ class DOM {
|
|
|
5000
5000
|
}
|
|
5001
5001
|
const _this = this;
|
|
5002
5002
|
const processed = ["children", "content"];
|
|
5003
|
-
const { className, options, dataset,
|
|
5003
|
+
const { className, options, dataset, ...elem } = this.processElemArg(elemArg);
|
|
5004
5004
|
processed.push("tag");
|
|
5005
5005
|
let childType;
|
|
5006
5006
|
const { tag } = elem;
|
|
@@ -7032,7 +7032,7 @@ class Panels {
|
|
|
7032
7032
|
}
|
|
7033
7033
|
getPanelDisplay() {
|
|
7034
7034
|
const column = this.panelsWrap;
|
|
7035
|
-
const width = Number.parseInt(dom.getStyle(column, "width"));
|
|
7035
|
+
const width = Number.parseInt(dom.getStyle(column, "width"), 10);
|
|
7036
7036
|
const autoDisplayType = width > 390 ? "tabbed" : "slider";
|
|
7037
7037
|
const isAuto = this.opts.displayType === "auto";
|
|
7038
7038
|
this.panelDisplay = isAuto ? autoDisplayType : this.opts.displayType || defaults$2.displayType;
|
|
@@ -7288,6 +7288,12 @@ class Component extends Data {
|
|
|
7288
7288
|
}
|
|
7289
7289
|
const parent = this.parent;
|
|
7290
7290
|
const children = this.children;
|
|
7291
|
+
this.dispatchComponentEvent("onRemove", {
|
|
7292
|
+
path,
|
|
7293
|
+
parent,
|
|
7294
|
+
children: [...children]
|
|
7295
|
+
// copy array since children will be modified
|
|
7296
|
+
});
|
|
7291
7297
|
forEach(children, (child) => child.remove());
|
|
7292
7298
|
this.dom.parentElement.removeChild(this.dom);
|
|
7293
7299
|
remove(components.getAddress(`${parent.name}s.${parent.id}.children`), this.id);
|
|
@@ -7429,6 +7435,11 @@ class Component extends Data {
|
|
|
7429
7435
|
if (this.name !== "field") {
|
|
7430
7436
|
this.cloneChildren(newClone);
|
|
7431
7437
|
}
|
|
7438
|
+
this.dispatchComponentEvent("onClone", {
|
|
7439
|
+
original: this,
|
|
7440
|
+
clone: newClone,
|
|
7441
|
+
parent
|
|
7442
|
+
});
|
|
7432
7443
|
return newClone;
|
|
7433
7444
|
});
|
|
7434
7445
|
__publicField(this, "createChildWrap", (children) => dom.create({
|
|
@@ -7500,11 +7511,91 @@ class Component extends Data {
|
|
|
7500
7511
|
this.address = `${this.name}s.${this.id}`;
|
|
7501
7512
|
this.dataPath = `${this.address}.`;
|
|
7502
7513
|
this.editPanels = /* @__PURE__ */ new Map();
|
|
7514
|
+
this.eventListeners = /* @__PURE__ */ new Map();
|
|
7515
|
+
this.initEventHandlers();
|
|
7516
|
+
}
|
|
7517
|
+
/**
|
|
7518
|
+
* Initialize event handlers based on config
|
|
7519
|
+
*/
|
|
7520
|
+
initEventHandlers() {
|
|
7521
|
+
if (!this.config.events) {
|
|
7522
|
+
return;
|
|
7523
|
+
}
|
|
7524
|
+
Object.entries(this.config.events).forEach(([eventName, handler]) => {
|
|
7525
|
+
this.addEventListener(eventName, handler);
|
|
7526
|
+
});
|
|
7527
|
+
}
|
|
7528
|
+
/**
|
|
7529
|
+
* Add an event listener to this component
|
|
7530
|
+
* @param {string} eventName - Name of the event
|
|
7531
|
+
* @param {function} handler - Event handler function
|
|
7532
|
+
*/
|
|
7533
|
+
addEventListener(eventName, handler) {
|
|
7534
|
+
if (!this.eventListeners.has(eventName)) {
|
|
7535
|
+
this.eventListeners.set(eventName, []);
|
|
7536
|
+
}
|
|
7537
|
+
this.eventListeners.get(eventName).push(handler);
|
|
7538
|
+
}
|
|
7539
|
+
/**
|
|
7540
|
+
* Remove an event listener from this component
|
|
7541
|
+
* @param {string} eventName - Name of the event
|
|
7542
|
+
* @param {function} handler - Event handler function to remove
|
|
7543
|
+
*/
|
|
7544
|
+
removeEventListener(eventName, handler) {
|
|
7545
|
+
var _a2;
|
|
7546
|
+
if (!((_a2 = this.eventListeners) == null ? void 0 : _a2.has(eventName))) {
|
|
7547
|
+
return;
|
|
7548
|
+
}
|
|
7549
|
+
const handlers = this.eventListeners.get(eventName);
|
|
7550
|
+
const index2 = handlers.indexOf(handler);
|
|
7551
|
+
if (index2 > -1) {
|
|
7552
|
+
handlers.splice(index2, 1);
|
|
7553
|
+
}
|
|
7554
|
+
}
|
|
7555
|
+
/**
|
|
7556
|
+
* Dispatch a component event to all registered listeners
|
|
7557
|
+
* @param {string} eventName - Name of the event to dispatch
|
|
7558
|
+
* @param {object} eventData - Data to pass to event handlers
|
|
7559
|
+
*/
|
|
7560
|
+
dispatchComponentEvent(eventName, eventData = {}) {
|
|
7561
|
+
var _a2;
|
|
7562
|
+
const fullEventData = {
|
|
7563
|
+
component: this,
|
|
7564
|
+
type: eventName,
|
|
7565
|
+
timestamp: Date.now(),
|
|
7566
|
+
...eventData
|
|
7567
|
+
};
|
|
7568
|
+
if ((_a2 = this.eventListeners) == null ? void 0 : _a2.has(eventName)) {
|
|
7569
|
+
this.eventListeners.get(eventName).forEach((handler) => {
|
|
7570
|
+
try {
|
|
7571
|
+
if (typeof handler === "function") {
|
|
7572
|
+
handler(fullEventData);
|
|
7573
|
+
}
|
|
7574
|
+
} catch (error) {
|
|
7575
|
+
console.error(`Error in ${eventName} event handler for ${this.name} ${this.id}:`, error);
|
|
7576
|
+
}
|
|
7577
|
+
});
|
|
7578
|
+
}
|
|
7579
|
+
return fullEventData;
|
|
7580
|
+
}
|
|
7581
|
+
/**
|
|
7582
|
+
* Override Data.set to dispatch component update events
|
|
7583
|
+
*/
|
|
7584
|
+
set(path, newVal) {
|
|
7585
|
+
const oldVal = this.get(path);
|
|
7586
|
+
const result = super.set(path, newVal);
|
|
7587
|
+
if (oldVal !== newVal && this.dom) {
|
|
7588
|
+
this.dispatchComponentEvent("onUpdate", {
|
|
7589
|
+
path,
|
|
7590
|
+
oldValue: oldVal,
|
|
7591
|
+
newValue: newVal
|
|
7592
|
+
});
|
|
7593
|
+
}
|
|
7594
|
+
return result;
|
|
7503
7595
|
}
|
|
7504
7596
|
// mutationHandler = mutations =>
|
|
7505
7597
|
// mutations.map(mutation => {
|
|
7506
|
-
// @todo pull handler form config
|
|
7507
|
-
// see dom.create.onRender for implementation pattern
|
|
7598
|
+
// @todo pull handler form config see dom.create.onRender for implementation pattern
|
|
7508
7599
|
// })
|
|
7509
7600
|
// observe(container) {
|
|
7510
7601
|
// this.observer.disconnect()
|
|
@@ -7707,7 +7798,24 @@ class Component extends Data {
|
|
|
7707
7798
|
}
|
|
7708
7799
|
const childComponentType = `${childGroup}s`;
|
|
7709
7800
|
const child = components.getAddress(`${childComponentType}.${childId}`) || components[childComponentType].add(childId, data);
|
|
7710
|
-
|
|
7801
|
+
if (index2 >= childWrap.children.length) {
|
|
7802
|
+
childWrap.appendChild(child.dom);
|
|
7803
|
+
} else {
|
|
7804
|
+
childWrap.children[index2].before(child.dom);
|
|
7805
|
+
}
|
|
7806
|
+
this.dispatchComponentEvent("onAddChild", {
|
|
7807
|
+
parent: this,
|
|
7808
|
+
target: child,
|
|
7809
|
+
child,
|
|
7810
|
+
index: index2
|
|
7811
|
+
});
|
|
7812
|
+
child.dispatchComponentEvent("onAdd", {
|
|
7813
|
+
parent: this,
|
|
7814
|
+
target: child,
|
|
7815
|
+
index: index2,
|
|
7816
|
+
addedVia: "addChild"
|
|
7817
|
+
// indicate how the component was added
|
|
7818
|
+
});
|
|
7711
7819
|
(_b2 = (_a2 = this.config.events) == null ? void 0 : _a2.onAddChild) == null ? void 0 : _b2.call(_a2, { parent: this, child });
|
|
7712
7820
|
const grandChildren = child.get("children");
|
|
7713
7821
|
if (grandChildren == null ? void 0 : grandChildren.length) {
|
|
@@ -7816,6 +7924,17 @@ class Component extends Data {
|
|
|
7816
7924
|
}
|
|
7817
7925
|
};
|
|
7818
7926
|
const component = (_a2 = onAddConditions[fromType]) == null ? void 0 : _a2.call(onAddConditions, item, newIndex2);
|
|
7927
|
+
this.dispatchComponentEvent("onAdd", {
|
|
7928
|
+
from,
|
|
7929
|
+
to,
|
|
7930
|
+
item,
|
|
7931
|
+
newIndex: newIndex2,
|
|
7932
|
+
fromType,
|
|
7933
|
+
toType,
|
|
7934
|
+
addedComponent: component,
|
|
7935
|
+
addedVia: "dragDrop"
|
|
7936
|
+
// indicate how the component was added
|
|
7937
|
+
});
|
|
7819
7938
|
defaultOnAdd();
|
|
7820
7939
|
return component;
|
|
7821
7940
|
}
|
|
@@ -7838,6 +7957,9 @@ class Component extends Data {
|
|
|
7838
7957
|
* Callback for onRender, executes any defined onRender for component
|
|
7839
7958
|
*/
|
|
7840
7959
|
onRender() {
|
|
7960
|
+
this.dispatchComponentEvent("onRender", {
|
|
7961
|
+
dom: this.dom
|
|
7962
|
+
});
|
|
7841
7963
|
const { events: events2 } = this.config;
|
|
7842
7964
|
if (!events2) {
|
|
7843
7965
|
return null;
|