formeo 3.1.0 → 3.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/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/assets/js/index.min.js +8 -0
- package/dist/demo/assets/js/index.min2.js +8 -0
- package/dist/demo/assets/js/index.min3.js +8 -0
- 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 +3 -3
- package/dist/formeo.es.js +1112 -1103
- package/dist/formeo.min.css +1 -1
- package/dist/formeo.min.js +3 -3
- package/dist/formeo.umd.js +3 -3
- package/package.json +1 -1
package/dist/formeo.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
3
|
formeo - https://formeo.io
|
|
4
|
-
Version: 3.0
|
|
4
|
+
Version: 3.1.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 = "3.0
|
|
437
|
+
const version$2 = "3.1.0";
|
|
438
438
|
const type = "module";
|
|
439
439
|
const main = "dist/formeo.cjs.js";
|
|
440
440
|
const module = "dist/formeo.es.js";
|
|
@@ -3050,7 +3050,7 @@ function lastChild(el, selector) {
|
|
|
3050
3050
|
}
|
|
3051
3051
|
return last || null;
|
|
3052
3052
|
}
|
|
3053
|
-
function index(el, selector) {
|
|
3053
|
+
function index$6(el, selector) {
|
|
3054
3054
|
var index2 = 0;
|
|
3055
3055
|
if (!el || !el.parentNode) {
|
|
3056
3056
|
return -1;
|
|
@@ -3661,8 +3661,8 @@ Sortable.prototype = /** @lends Sortable.prototype */
|
|
|
3661
3661
|
if (lastDownEl === target) {
|
|
3662
3662
|
return;
|
|
3663
3663
|
}
|
|
3664
|
-
oldIndex = index(target);
|
|
3665
|
-
oldDraggableIndex = index(target, options.draggable);
|
|
3664
|
+
oldIndex = index$6(target);
|
|
3665
|
+
oldDraggableIndex = index$6(target, options.draggable);
|
|
3666
3666
|
if (typeof filter === "function") {
|
|
3667
3667
|
if (filter.call(this, evt, target, this)) {
|
|
3668
3668
|
_dispatchEvent({
|
|
@@ -4082,8 +4082,8 @@ Sortable.prototype = /** @lends Sortable.prototype */
|
|
|
4082
4082
|
return completedFired = true;
|
|
4083
4083
|
}
|
|
4084
4084
|
function changed() {
|
|
4085
|
-
newIndex = index(dragEl);
|
|
4086
|
-
newDraggableIndex = index(dragEl, options.draggable);
|
|
4085
|
+
newIndex = index$6(dragEl);
|
|
4086
|
+
newDraggableIndex = index$6(dragEl, options.draggable);
|
|
4087
4087
|
_dispatchEvent({
|
|
4088
4088
|
sortable: _this,
|
|
4089
4089
|
name: "change",
|
|
@@ -4169,7 +4169,7 @@ Sortable.prototype = /** @lends Sortable.prototype */
|
|
|
4169
4169
|
direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
|
|
4170
4170
|
var sibling;
|
|
4171
4171
|
if (direction !== 0) {
|
|
4172
|
-
var dragIndex = index(dragEl);
|
|
4172
|
+
var dragIndex = index$6(dragEl);
|
|
4173
4173
|
do {
|
|
4174
4174
|
dragIndex -= direction;
|
|
4175
4175
|
sibling = parentEl.children[dragIndex];
|
|
@@ -4231,14 +4231,14 @@ Sortable.prototype = /** @lends Sortable.prototype */
|
|
|
4231
4231
|
},
|
|
4232
4232
|
_onDrop: function _onDrop(evt) {
|
|
4233
4233
|
var el = this.el, options = this.options;
|
|
4234
|
-
newIndex = index(dragEl);
|
|
4235
|
-
newDraggableIndex = index(dragEl, options.draggable);
|
|
4234
|
+
newIndex = index$6(dragEl);
|
|
4235
|
+
newDraggableIndex = index$6(dragEl, options.draggable);
|
|
4236
4236
|
pluginEvent2("drop", this, {
|
|
4237
4237
|
evt
|
|
4238
4238
|
});
|
|
4239
4239
|
parentEl = dragEl && dragEl.parentNode;
|
|
4240
|
-
newIndex = index(dragEl);
|
|
4241
|
-
newDraggableIndex = index(dragEl, options.draggable);
|
|
4240
|
+
newIndex = index$6(dragEl);
|
|
4241
|
+
newDraggableIndex = index$6(dragEl, options.draggable);
|
|
4242
4242
|
if (Sortable.eventCanceled) {
|
|
4243
4243
|
this._nulling();
|
|
4244
4244
|
return;
|
|
@@ -4585,7 +4585,7 @@ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, inv
|
|
|
4585
4585
|
return 0;
|
|
4586
4586
|
}
|
|
4587
4587
|
function _getInsertDirection(target) {
|
|
4588
|
-
if (index(dragEl) < index(target)) {
|
|
4588
|
+
if (index$6(dragEl) < index$6(target)) {
|
|
4589
4589
|
return 1;
|
|
4590
4590
|
} else {
|
|
4591
4591
|
return -1;
|
|
@@ -4633,7 +4633,7 @@ Sortable.utils = {
|
|
|
4633
4633
|
closest,
|
|
4634
4634
|
toggleClass,
|
|
4635
4635
|
clone,
|
|
4636
|
-
index,
|
|
4636
|
+
index: index$6,
|
|
4637
4637
|
nextTick: _nextTick,
|
|
4638
4638
|
cancelNextTick: _cancelNextTick,
|
|
4639
4639
|
detectDirection: _detectDirection,
|
|
@@ -6777,6 +6777,9 @@ class Field extends Component {
|
|
|
6777
6777
|
*/
|
|
6778
6778
|
constructor(fieldData = /* @__PURE__ */ Object.create(null)) {
|
|
6779
6779
|
super("field", { ...DEFAULT_DATA$3(), ...fieldData });
|
|
6780
|
+
__publicField(this, "setData", (path, value) => {
|
|
6781
|
+
return super.set(path, value);
|
|
6782
|
+
});
|
|
6780
6783
|
/**
|
|
6781
6784
|
* Updates the conditions panel when linked field data changes
|
|
6782
6785
|
*/
|
|
@@ -6962,9 +6965,8 @@ class Field extends Component {
|
|
|
6962
6965
|
/**
|
|
6963
6966
|
* wrapper for Data.set
|
|
6964
6967
|
*/
|
|
6965
|
-
set(
|
|
6966
|
-
const
|
|
6967
|
-
const data = super.set(path, value);
|
|
6968
|
+
set(path, value) {
|
|
6969
|
+
const data = this.setData(path, value);
|
|
6968
6970
|
this.updatePreview();
|
|
6969
6971
|
return data;
|
|
6970
6972
|
}
|
|
@@ -7056,7 +7058,10 @@ class Field extends Component {
|
|
|
7056
7058
|
const prevData = clone$1(this.data);
|
|
7057
7059
|
const { action = {} } = Controls$2.get(prevData.config.controlId);
|
|
7058
7060
|
prevData.id = `prev-${this.id}`;
|
|
7059
|
-
prevData.action = action
|
|
7061
|
+
prevData.action = Object.entries(action).reduce((acc, [key, value]) => {
|
|
7062
|
+
acc[key] = value.bind(this);
|
|
7063
|
+
return acc;
|
|
7064
|
+
}, {});
|
|
7060
7065
|
if ((_a = this.data) == null ? void 0 : _a.config.editableContent) {
|
|
7061
7066
|
prevData.attrs = { ...prevData.attrs, contenteditable: true };
|
|
7062
7067
|
}
|
|
@@ -7268,1008 +7273,578 @@ class Control {
|
|
|
7268
7273
|
return (((_b = localeTranslations[lookup]) == null ? void 0 : _b.call(localeTranslations)) ?? localeTranslations[lookup]) || mi18n.get(lookup, args);
|
|
7269
7274
|
}
|
|
7270
7275
|
}
|
|
7271
|
-
const
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
}
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7276
|
+
const defaultOptions = Object.freeze({
|
|
7277
|
+
sortable: true,
|
|
7278
|
+
elementOrder: {},
|
|
7279
|
+
groupOrder: [],
|
|
7280
|
+
groups: [
|
|
7281
|
+
{
|
|
7282
|
+
id: "layout",
|
|
7283
|
+
label: "controls.groups.layout",
|
|
7284
|
+
elementOrder: ["row", "column"]
|
|
7285
|
+
},
|
|
7286
|
+
{
|
|
7287
|
+
id: "common",
|
|
7288
|
+
label: "controls.groups.form",
|
|
7289
|
+
elementOrder: ["button", "checkbox"]
|
|
7290
|
+
},
|
|
7291
|
+
{
|
|
7292
|
+
id: "html",
|
|
7293
|
+
label: "controls.groups.html",
|
|
7294
|
+
elementOrder: ["header", "block-text"]
|
|
7295
|
+
}
|
|
7296
|
+
],
|
|
7297
|
+
disable: {
|
|
7298
|
+
groups: [],
|
|
7299
|
+
elements: [],
|
|
7300
|
+
formActions: []
|
|
7284
7301
|
},
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
};
|
|
7291
|
-
const layoutControls = [rowControl, columnControl];
|
|
7292
|
-
class HiddenControl extends Control {
|
|
7302
|
+
elements: [],
|
|
7303
|
+
container: null,
|
|
7304
|
+
panels: { displayType: "slider" }
|
|
7305
|
+
});
|
|
7306
|
+
let Controls$1 = class Controls {
|
|
7293
7307
|
constructor() {
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
+
__publicField(this, "groupLabel", (key) => mi18n.get(key) || key || "");
|
|
7309
|
+
__publicField(this, "layoutTypes", {
|
|
7310
|
+
row: () => Stages2.active.addChild(),
|
|
7311
|
+
column: () => this.layoutTypes.row().addChild(),
|
|
7312
|
+
field: (controlData) => this.layoutTypes.column().addChild(controlData)
|
|
7313
|
+
});
|
|
7314
|
+
/**
|
|
7315
|
+
* Append an element to the stage
|
|
7316
|
+
* @param {String} id of elements
|
|
7317
|
+
*/
|
|
7318
|
+
__publicField(this, "addElement", (id) => {
|
|
7319
|
+
const {
|
|
7320
|
+
meta: { group, id: metaId },
|
|
7321
|
+
...elementData
|
|
7322
|
+
} = get(this.get(id), "controlData");
|
|
7323
|
+
set(elementData, "config.controlId", metaId);
|
|
7324
|
+
if (group === "layout") {
|
|
7325
|
+
return this.layoutTypes[metaId.replace("layout-", "")]();
|
|
7308
7326
|
}
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
}
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7327
|
+
return this.layoutTypes.field(elementData);
|
|
7328
|
+
});
|
|
7329
|
+
__publicField(this, "applyOptions", async (controlOptions = {}) => {
|
|
7330
|
+
const { container, elements, groupOrder, ...options } = merge(defaultOptions, controlOptions);
|
|
7331
|
+
this.container = container;
|
|
7332
|
+
this.groupOrder = unique(groupOrder.concat(["common", "html", "layout"]));
|
|
7333
|
+
this.options = options;
|
|
7334
|
+
const [layoutControls, formControls, htmlControls] = await Promise.all([
|
|
7335
|
+
Promise.resolve().then(() => index$5),
|
|
7336
|
+
Promise.resolve().then(() => index$3),
|
|
7337
|
+
Promise.resolve().then(() => index$1)
|
|
7338
|
+
]);
|
|
7339
|
+
const allControls = [layoutControls.default, formControls.default, htmlControls.default].flat();
|
|
7340
|
+
return Promise.all(this.registerControls([...allControls, ...elements]));
|
|
7341
|
+
});
|
|
7342
|
+
this.data = /* @__PURE__ */ new Map();
|
|
7343
|
+
this.buttonActions = {
|
|
7344
|
+
// this is used for keyboard navigation. when tabbing through controls it
|
|
7345
|
+
// will auto navigated between the groups
|
|
7346
|
+
focus: ({ target }) => {
|
|
7347
|
+
const group = target.closest(`.${CONTROL_GROUP_CLASSNAME}`);
|
|
7348
|
+
return group && this.panels.nav.refresh(indexOfNode(group));
|
|
7324
7349
|
},
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
icon: "hash",
|
|
7328
|
-
id: "number"
|
|
7350
|
+
click: ({ target }) => {
|
|
7351
|
+
this.addElement(target.parentElement.id);
|
|
7329
7352
|
}
|
|
7330
7353
|
};
|
|
7331
|
-
super(numberInput);
|
|
7332
7354
|
}
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
// This is the beginning of actions being supported for render
|
|
7342
|
-
// editor field actions should be in config.action
|
|
7343
|
-
// action: {
|
|
7344
|
-
// mousedown: function(evt) {
|
|
7345
|
-
// let {target} = evt;
|
|
7346
|
-
// let startHeight = target.style.height;
|
|
7347
|
-
// const onMouseup = evt => {
|
|
7348
|
-
// let {target} = evt;
|
|
7349
|
-
// let endHeight = target.style.height;
|
|
7350
|
-
// if (startHeight !== endHeight) {
|
|
7351
|
-
// //eslint-disable-next-line
|
|
7352
|
-
// let fieldId = closest(target, '.stage-field').id;
|
|
7353
|
-
// const field = d.fields.get(fieldId).instance;
|
|
7354
|
-
// field.addAttribute('style', `height: ${endHeight}`);
|
|
7355
|
-
// }
|
|
7356
|
-
// target.removeEventListener('mouseup', onMouseup);
|
|
7357
|
-
// };
|
|
7358
|
-
// target.addEventListener('mouseup', onMouseup);
|
|
7359
|
-
// }
|
|
7360
|
-
// },
|
|
7361
|
-
meta: {
|
|
7362
|
-
group: "common",
|
|
7363
|
-
icon: "textarea",
|
|
7364
|
-
id: "textarea"
|
|
7365
|
-
},
|
|
7366
|
-
attrs: {
|
|
7367
|
-
required: false
|
|
7368
|
-
}
|
|
7369
|
-
};
|
|
7370
|
-
super(textAreaConfig);
|
|
7355
|
+
/**
|
|
7356
|
+
* Methods to be called on initialization
|
|
7357
|
+
* @param {Object} controlOptions
|
|
7358
|
+
*/
|
|
7359
|
+
async init(controlOptions, sticky = false) {
|
|
7360
|
+
await this.applyOptions(controlOptions);
|
|
7361
|
+
this.buildDOM(sticky);
|
|
7362
|
+
return this;
|
|
7371
7363
|
}
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
meta: {
|
|
7386
|
-
group: "common",
|
|
7387
|
-
icon: "text-input",
|
|
7388
|
-
id: "text-input"
|
|
7364
|
+
/**
|
|
7365
|
+
* Generate control config for UI and bind actions
|
|
7366
|
+
* @return {Array} elementControls
|
|
7367
|
+
*/
|
|
7368
|
+
registerControls(elements) {
|
|
7369
|
+
this.controls = [];
|
|
7370
|
+
return elements.map(async (Element) => {
|
|
7371
|
+
const isControl = typeof Element === "function";
|
|
7372
|
+
let control;
|
|
7373
|
+
if (isControl) {
|
|
7374
|
+
control = new Element();
|
|
7375
|
+
} else {
|
|
7376
|
+
control = new Control(Element);
|
|
7389
7377
|
}
|
|
7390
|
-
|
|
7391
|
-
|
|
7378
|
+
this.add(control);
|
|
7379
|
+
this.controls.push(control.dom);
|
|
7380
|
+
return control.promise();
|
|
7381
|
+
});
|
|
7392
7382
|
}
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7383
|
+
/**
|
|
7384
|
+
* Group elements into their respective control group
|
|
7385
|
+
* @return {Array} allGroups
|
|
7386
|
+
*/
|
|
7387
|
+
groupElements() {
|
|
7388
|
+
let groups = this.options.groups.slice();
|
|
7389
|
+
let elements = this.controls.slice();
|
|
7390
|
+
let allGroups = [];
|
|
7391
|
+
const usedElementIds = [];
|
|
7392
|
+
groups = orderObjectsBy(groups, this.groupOrder, "id");
|
|
7393
|
+
groups = groups.filter((group) => match(group.id, this.options.disable.groups));
|
|
7394
|
+
allGroups = groups.map((group) => {
|
|
7395
|
+
const groupConfig = {
|
|
7396
|
+
tag: "ul",
|
|
7397
|
+
attrs: {
|
|
7398
|
+
className: CONTROL_GROUP_CLASSNAME,
|
|
7399
|
+
id: `${group.id}-${CONTROL_GROUP_CLASSNAME}`
|
|
7400
|
+
},
|
|
7401
|
+
config: {
|
|
7402
|
+
label: this.groupLabel(group.label)
|
|
7403
|
+
}
|
|
7404
|
+
};
|
|
7405
|
+
if (this.options.elementOrder[group.id]) {
|
|
7406
|
+
const userOrder = this.options.elementOrder[group.id];
|
|
7407
|
+
const newOrder = unique(userOrder.concat(group.elementOrder));
|
|
7408
|
+
group.elementOrder = newOrder;
|
|
7409
7409
|
}
|
|
7410
|
-
|
|
7411
|
-
|
|
7410
|
+
elements = orderObjectsBy(elements, group.elementOrder, "meta.id");
|
|
7411
|
+
groupConfig.content = elements.filter((control) => {
|
|
7412
|
+
const { controlData: field } = this.get(control.id);
|
|
7413
|
+
const controlId = field.meta.id || "";
|
|
7414
|
+
const filters = [
|
|
7415
|
+
match(controlId, this.options.disable.elements),
|
|
7416
|
+
field.meta.group === group.id,
|
|
7417
|
+
!usedElementIds.includes(controlId)
|
|
7418
|
+
];
|
|
7419
|
+
let shouldFilter = true;
|
|
7420
|
+
shouldFilter = filters.every((val) => val === true);
|
|
7421
|
+
if (shouldFilter) {
|
|
7422
|
+
usedElementIds.push(controlId);
|
|
7423
|
+
}
|
|
7424
|
+
return shouldFilter;
|
|
7425
|
+
});
|
|
7426
|
+
return groupConfig;
|
|
7427
|
+
});
|
|
7428
|
+
return allGroups;
|
|
7412
7429
|
}
|
|
7413
|
-
|
|
7414
|
-
const
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
}),
|
|
7421
|
-
value: `${type2}-${i}`,
|
|
7422
|
-
[selectedKey]: !i
|
|
7423
|
-
};
|
|
7424
|
-
});
|
|
7425
|
-
class SelectControl extends Control {
|
|
7426
|
-
constructor() {
|
|
7427
|
-
const selectConfig = {
|
|
7428
|
-
tag: "select",
|
|
7429
|
-
config: {
|
|
7430
|
-
label: mi18n.get("controls.form.select")
|
|
7431
|
-
},
|
|
7432
|
-
attrs: {
|
|
7433
|
-
required: false,
|
|
7434
|
-
className: ""
|
|
7435
|
-
},
|
|
7436
|
-
meta: {
|
|
7437
|
-
group: "common",
|
|
7438
|
-
icon: "select",
|
|
7439
|
-
id: "select"
|
|
7440
|
-
},
|
|
7441
|
-
options: generateOptionConfig("option")
|
|
7442
|
-
};
|
|
7443
|
-
super(selectConfig);
|
|
7444
|
-
}
|
|
7445
|
-
}
|
|
7446
|
-
class CheckboxGroupControl extends Control {
|
|
7447
|
-
constructor() {
|
|
7448
|
-
const checkboxGroup = {
|
|
7449
|
-
tag: "input",
|
|
7450
|
-
attrs: {
|
|
7451
|
-
type: "checkbox",
|
|
7452
|
-
required: false
|
|
7453
|
-
},
|
|
7454
|
-
config: {
|
|
7455
|
-
label: mi18n.get("controls.form.checkbox-group"),
|
|
7456
|
-
disabledAttrs: ["type"]
|
|
7457
|
-
},
|
|
7458
|
-
meta: {
|
|
7459
|
-
group: "common",
|
|
7460
|
-
icon: "checkbox",
|
|
7461
|
-
id: "checkbox"
|
|
7462
|
-
},
|
|
7463
|
-
options: generateOptionConfig("checkbox", 1)
|
|
7464
|
-
};
|
|
7465
|
-
super(checkboxGroup);
|
|
7430
|
+
add(control = /* @__PURE__ */ Object.create(null)) {
|
|
7431
|
+
const controlConfig = clone$1(control);
|
|
7432
|
+
this.data.set(controlConfig.id, controlConfig);
|
|
7433
|
+
if (controlConfig.controlData.meta.id) {
|
|
7434
|
+
this.data.set(controlConfig.controlData.meta.id, controlConfig.controlData);
|
|
7435
|
+
}
|
|
7436
|
+
return controlConfig;
|
|
7466
7437
|
}
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
constructor() {
|
|
7470
|
-
const radioGroup = {
|
|
7471
|
-
tag: "input",
|
|
7472
|
-
attrs: {
|
|
7473
|
-
type: "radio",
|
|
7474
|
-
required: false
|
|
7475
|
-
},
|
|
7476
|
-
config: {
|
|
7477
|
-
label: mi18n.get("controls.form.radio-group"),
|
|
7478
|
-
disabledAttrs: ["type"]
|
|
7479
|
-
},
|
|
7480
|
-
meta: {
|
|
7481
|
-
group: "common",
|
|
7482
|
-
icon: "radio-group",
|
|
7483
|
-
id: "radio"
|
|
7484
|
-
},
|
|
7485
|
-
options: generateOptionConfig("radio")
|
|
7486
|
-
};
|
|
7487
|
-
super(radioGroup);
|
|
7438
|
+
get(controlId) {
|
|
7439
|
+
return clone$1(this.data.get(controlId));
|
|
7488
7440
|
}
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
value: "primary"
|
|
7522
|
-
},
|
|
7523
|
-
{
|
|
7524
|
-
label: "danger",
|
|
7525
|
-
value: "error"
|
|
7526
|
-
},
|
|
7527
|
-
{
|
|
7528
|
-
label: "success",
|
|
7529
|
-
value: "success"
|
|
7530
|
-
},
|
|
7531
|
-
{
|
|
7532
|
-
label: "warning",
|
|
7533
|
-
value: "warning"
|
|
7534
|
-
}
|
|
7535
|
-
]
|
|
7441
|
+
/**
|
|
7442
|
+
* Generate the DOM config for form actions like settings, save and clear
|
|
7443
|
+
* @return {Object} form action buttons config
|
|
7444
|
+
*/
|
|
7445
|
+
formActions() {
|
|
7446
|
+
if (this.options.disable.formActions === true) {
|
|
7447
|
+
return null;
|
|
7448
|
+
}
|
|
7449
|
+
const clearBtn = {
|
|
7450
|
+
...dom.btnTemplate({ content: [dom.icon("bin"), mi18n.get("clear")], title: mi18n.get("clearAll") }),
|
|
7451
|
+
className: ["clear-form"],
|
|
7452
|
+
action: {
|
|
7453
|
+
click: (evt) => {
|
|
7454
|
+
if (Rows2.size) {
|
|
7455
|
+
events.confirmClearAll = new window.CustomEvent("confirmClearAll", {
|
|
7456
|
+
detail: {
|
|
7457
|
+
confirmationMessage: mi18n.get("confirmClearAll"),
|
|
7458
|
+
clearAllAction: () => {
|
|
7459
|
+
Stages2.clearAll().then(() => {
|
|
7460
|
+
const evtData = {
|
|
7461
|
+
src: evt.target
|
|
7462
|
+
};
|
|
7463
|
+
events.formeoCleared(evtData);
|
|
7464
|
+
});
|
|
7465
|
+
},
|
|
7466
|
+
btnCoords: dom.coords(evt.target)
|
|
7467
|
+
}
|
|
7468
|
+
});
|
|
7469
|
+
document.dispatchEvent(events.confirmClearAll);
|
|
7470
|
+
} else {
|
|
7471
|
+
window.alert(mi18n.get("cannotClearFields"));
|
|
7472
|
+
}
|
|
7536
7473
|
}
|
|
7537
|
-
]
|
|
7538
|
-
};
|
|
7539
|
-
super(buttonConfig);
|
|
7540
|
-
}
|
|
7541
|
-
}
|
|
7542
|
-
class DateControl extends Control {
|
|
7543
|
-
constructor() {
|
|
7544
|
-
const dateInput = {
|
|
7545
|
-
tag: "input",
|
|
7546
|
-
attrs: {
|
|
7547
|
-
type: "date",
|
|
7548
|
-
required: false,
|
|
7549
|
-
className: ""
|
|
7550
|
-
},
|
|
7551
|
-
config: {
|
|
7552
|
-
label: mi18n.get("controls.form.input.date")
|
|
7553
|
-
},
|
|
7554
|
-
meta: {
|
|
7555
|
-
group: "common",
|
|
7556
|
-
icon: "calendar",
|
|
7557
|
-
id: "date-input"
|
|
7558
7474
|
}
|
|
7559
7475
|
};
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
const formControls = [
|
|
7564
|
-
ButtonControl,
|
|
7565
|
-
DateControl,
|
|
7566
|
-
HiddenControl,
|
|
7567
|
-
NumberControl,
|
|
7568
|
-
TextAreaControl,
|
|
7569
|
-
TextControl,
|
|
7570
|
-
FileControl,
|
|
7571
|
-
SelectControl,
|
|
7572
|
-
CheckboxGroupControl,
|
|
7573
|
-
RadioGroupControl
|
|
7574
|
-
];
|
|
7575
|
-
const headerTags = Array.from(Array(5).keys()).slice(1).map((key) => `h${key}`);
|
|
7576
|
-
const headerKey = "controls.html.header";
|
|
7577
|
-
class HeaderControl extends Control {
|
|
7578
|
-
constructor() {
|
|
7579
|
-
const header = {
|
|
7580
|
-
tag: headerTags[0],
|
|
7581
|
-
attrs: {
|
|
7582
|
-
tag: headerTags.map((tag, index2) => ({
|
|
7583
|
-
label: tag.toUpperCase(),
|
|
7584
|
-
value: tag,
|
|
7585
|
-
selected: !index2
|
|
7586
|
-
})),
|
|
7587
|
-
className: ""
|
|
7588
|
-
},
|
|
7589
|
-
config: {
|
|
7590
|
-
label: mi18n.get(headerKey),
|
|
7591
|
-
hideLabel: true,
|
|
7592
|
-
editableContent: true
|
|
7593
|
-
},
|
|
7594
|
-
meta: {
|
|
7595
|
-
group: "html",
|
|
7596
|
-
icon: "header",
|
|
7597
|
-
id: "html.header"
|
|
7598
|
-
},
|
|
7599
|
-
content: mi18n.get(headerKey),
|
|
7476
|
+
const saveBtn = {
|
|
7477
|
+
...dom.btnTemplate({ content: [dom.icon("floppy-disk"), mi18n.get("save")], title: mi18n.get("save") }),
|
|
7478
|
+
className: ["save-form"],
|
|
7600
7479
|
action: {
|
|
7601
|
-
|
|
7602
|
-
|
|
7480
|
+
click: ({ target }) => {
|
|
7481
|
+
const { formData } = components;
|
|
7482
|
+
const saveEvt = {
|
|
7483
|
+
action: () => {
|
|
7484
|
+
},
|
|
7485
|
+
coords: dom.coords(target),
|
|
7486
|
+
message: "",
|
|
7487
|
+
button: target
|
|
7488
|
+
};
|
|
7489
|
+
actions.click.btn(saveEvt);
|
|
7490
|
+
return actions.save.form(formData);
|
|
7491
|
+
}
|
|
7603
7492
|
}
|
|
7604
7493
|
};
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
static get definition() {
|
|
7611
|
-
return {
|
|
7612
|
-
// i18n custom mappings (defaults to camelCase type)
|
|
7613
|
-
i18n: {
|
|
7614
|
-
"en-US": {
|
|
7615
|
-
header: "Custom English Header"
|
|
7494
|
+
const formActions = {
|
|
7495
|
+
className: "form-actions f-btn-group",
|
|
7496
|
+
content: Object.entries({ clearBtn, saveBtn }).reduce((acc, [key, value]) => {
|
|
7497
|
+
if (!this.options.disable.formActions.includes(key)) {
|
|
7498
|
+
acc.push(value);
|
|
7616
7499
|
}
|
|
7617
|
-
|
|
7500
|
+
return acc;
|
|
7501
|
+
}, [])
|
|
7618
7502
|
};
|
|
7503
|
+
return formActions;
|
|
7619
7504
|
}
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
const
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7505
|
+
/**
|
|
7506
|
+
* Returns the markup for the form controls/fields
|
|
7507
|
+
* @return {DOM}
|
|
7508
|
+
*/
|
|
7509
|
+
buildDOM(sticky) {
|
|
7510
|
+
const groupedFields = this.groupElements();
|
|
7511
|
+
const formActions = this.formActions();
|
|
7512
|
+
const { displayType } = this.options.panels;
|
|
7513
|
+
this.panels = new Panels({ panels: groupedFields, type: "controls", displayType });
|
|
7514
|
+
const groupsWrapClasses = ["control-groups", "formeo-panels-wrap", `panel-count-${groupedFields.length}`];
|
|
7515
|
+
const groupsWrap = dom.create({
|
|
7516
|
+
className: groupsWrapClasses,
|
|
7517
|
+
content: [this.panels.panelNav, this.panels.panelsWrap]
|
|
7518
|
+
});
|
|
7519
|
+
const controlClasses = ["formeo-controls"];
|
|
7520
|
+
if (sticky) {
|
|
7521
|
+
controlClasses.push("formeo-sticky");
|
|
7522
|
+
}
|
|
7523
|
+
const element = dom.create({
|
|
7524
|
+
className: controlClasses,
|
|
7525
|
+
content: [groupsWrap, formActions]
|
|
7526
|
+
});
|
|
7527
|
+
const groups = element.getElementsByClassName("control-group");
|
|
7528
|
+
this.dom = element;
|
|
7529
|
+
this.groups = groups;
|
|
7530
|
+
const [firstGroup] = groups;
|
|
7531
|
+
this.currentGroup = firstGroup;
|
|
7532
|
+
this.actions = {
|
|
7533
|
+
filter: (term) => {
|
|
7534
|
+
const filtering = term !== "";
|
|
7535
|
+
const fields2 = this.controls;
|
|
7536
|
+
let filteredTerm = groupsWrap.querySelector(".filtered-term");
|
|
7537
|
+
dom.toggleElementsByStr(fields2, term);
|
|
7538
|
+
if (filtering) {
|
|
7539
|
+
const filteredStr = mi18n.get("controls.filteringTerm", term);
|
|
7540
|
+
element.classList.add("filtered");
|
|
7541
|
+
if (filteredTerm) {
|
|
7542
|
+
filteredTerm.textContent = filteredStr;
|
|
7543
|
+
} else {
|
|
7544
|
+
filteredTerm = dom.create({
|
|
7545
|
+
tag: "h5",
|
|
7546
|
+
className: "filtered-term",
|
|
7547
|
+
content: filteredStr
|
|
7548
|
+
});
|
|
7549
|
+
groupsWrap.insertBefore(filteredTerm, groupsWrap.firstChild);
|
|
7550
|
+
}
|
|
7551
|
+
} else if (filteredTerm) {
|
|
7552
|
+
element.classList.remove("filtered");
|
|
7553
|
+
filteredTerm.remove();
|
|
7554
|
+
}
|
|
7640
7555
|
},
|
|
7641
|
-
|
|
7642
|
-
|
|
7556
|
+
addElement: this.addElement,
|
|
7557
|
+
// @todo finish the addGroup method
|
|
7558
|
+
addGroup: (group) => console.log(group)
|
|
7643
7559
|
};
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
constructor() {
|
|
7649
|
-
const hrConfig = {
|
|
7650
|
-
tag: "hr",
|
|
7651
|
-
config: {
|
|
7652
|
-
label: mi18n.get("controls.html.divider"),
|
|
7653
|
-
hideLabel: true
|
|
7654
|
-
},
|
|
7655
|
-
meta: {
|
|
7656
|
-
group: "html",
|
|
7657
|
-
icon: "divider",
|
|
7658
|
-
id: "divider"
|
|
7560
|
+
for (let i = groups.length - 1; i >= 0; i--) {
|
|
7561
|
+
const storeID = `formeo-controls-${groups[i]}`;
|
|
7562
|
+
if (!this.options.sortable) {
|
|
7563
|
+
window.localStorage.removeItem(storeID);
|
|
7659
7564
|
}
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
label: "WYSIWYG",
|
|
7670
|
-
editableContent: true
|
|
7671
|
-
},
|
|
7672
|
-
meta: {
|
|
7673
|
-
group: "html",
|
|
7674
|
-
icon: "rich-text",
|
|
7675
|
-
id: "tinymce"
|
|
7676
|
-
},
|
|
7677
|
-
attrs: {
|
|
7678
|
-
required: false
|
|
7679
|
-
},
|
|
7680
|
-
dependencies: { js: "https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.9.11/tinymce.min.js" },
|
|
7681
|
-
// this action is passed to the rendered control/element
|
|
7682
|
-
// useful for actions and events on the control preview
|
|
7683
|
-
action: {
|
|
7684
|
-
onRender: (elem) => {
|
|
7685
|
-
const selector = `#${elem.id}`;
|
|
7686
|
-
window.tinymce.remove(selector);
|
|
7687
|
-
window.tinymce.init({
|
|
7688
|
-
selector
|
|
7689
|
-
});
|
|
7690
|
-
}
|
|
7691
|
-
},
|
|
7692
|
-
controlAction: {
|
|
7693
|
-
// callback when control is clicked
|
|
7694
|
-
click: () => {
|
|
7565
|
+
Sortable.create(groups[i], {
|
|
7566
|
+
animation: 150,
|
|
7567
|
+
forceFallback: true,
|
|
7568
|
+
fallbackClass: "control-moving",
|
|
7569
|
+
fallbackOnBody: true,
|
|
7570
|
+
group: {
|
|
7571
|
+
name: "controls",
|
|
7572
|
+
pull: "clone",
|
|
7573
|
+
put: false
|
|
7695
7574
|
},
|
|
7696
|
-
|
|
7697
|
-
|
|
7575
|
+
onStart: ({ item }) => {
|
|
7576
|
+
const { controlData } = this.get(item.id);
|
|
7577
|
+
if (this.options.ghostPreview) {
|
|
7578
|
+
item.innerHTML = "";
|
|
7579
|
+
item.appendChild(new Field(controlData).preview);
|
|
7580
|
+
}
|
|
7581
|
+
},
|
|
7582
|
+
onEnd: ({ from, item, clone: clone2 }) => {
|
|
7583
|
+
if (from.contains(clone2)) {
|
|
7584
|
+
from.replaceChild(item, clone2);
|
|
7585
|
+
}
|
|
7586
|
+
},
|
|
7587
|
+
sort: this.options.sortable,
|
|
7588
|
+
store: {
|
|
7589
|
+
/**
|
|
7590
|
+
* Get the order of elements.
|
|
7591
|
+
* @param {Sortable} sortable
|
|
7592
|
+
* @return {Array}
|
|
7593
|
+
*/
|
|
7594
|
+
get: () => {
|
|
7595
|
+
const order = window.localStorage.getItem(storeID);
|
|
7596
|
+
return order ? order.split("|") : [];
|
|
7597
|
+
},
|
|
7598
|
+
/**
|
|
7599
|
+
* Save the order of elements.
|
|
7600
|
+
* @param {Sortable} sortable
|
|
7601
|
+
*/
|
|
7602
|
+
set: (sortable) => {
|
|
7603
|
+
const order = sortable.toArray();
|
|
7604
|
+
window.localStorage.setItem(storeID, order.join("|"));
|
|
7605
|
+
}
|
|
7698
7606
|
}
|
|
7699
|
-
}
|
|
7700
|
-
};
|
|
7701
|
-
const mergedOptions = merge(textAreaConfig, options);
|
|
7702
|
-
super(mergedOptions);
|
|
7703
|
-
}
|
|
7704
|
-
}
|
|
7705
|
-
const htmlControls = [HeaderControl, ParagraphControl, HRControl, TinyMCEControl];
|
|
7706
|
-
const defaultOptions = Object.freeze({
|
|
7707
|
-
sortable: true,
|
|
7708
|
-
elementOrder: {},
|
|
7709
|
-
groupOrder: [],
|
|
7710
|
-
groups: [
|
|
7711
|
-
{
|
|
7712
|
-
id: "layout",
|
|
7713
|
-
label: "controls.groups.layout",
|
|
7714
|
-
elementOrder: ["row", "column"]
|
|
7715
|
-
},
|
|
7716
|
-
{
|
|
7717
|
-
id: "common",
|
|
7718
|
-
label: "controls.groups.form",
|
|
7719
|
-
elementOrder: ["button", "checkbox"]
|
|
7720
|
-
},
|
|
7721
|
-
{
|
|
7722
|
-
id: "html",
|
|
7723
|
-
label: "controls.groups.html",
|
|
7724
|
-
elementOrder: ["header", "block-text"]
|
|
7607
|
+
});
|
|
7725
7608
|
}
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
},
|
|
7732
|
-
elements: [],
|
|
7733
|
-
container: null,
|
|
7734
|
-
panels: { displayType: "slider" }
|
|
7735
|
-
});
|
|
7736
|
-
const defaultElements = [...formControls, ...htmlControls, ...layoutControls];
|
|
7737
|
-
let Controls$1 = class Controls {
|
|
7609
|
+
return element;
|
|
7610
|
+
}
|
|
7611
|
+
};
|
|
7612
|
+
const Controls$2 = new Controls$1();
|
|
7613
|
+
class ComponentData extends Data {
|
|
7738
7614
|
constructor() {
|
|
7739
|
-
|
|
7740
|
-
__publicField(this, "
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7615
|
+
super(...arguments);
|
|
7616
|
+
__publicField(this, "load", (dataArg) => {
|
|
7617
|
+
const data = parseData(dataArg);
|
|
7618
|
+
this.empty();
|
|
7619
|
+
for (const [key, val] of Object.entries(data)) {
|
|
7620
|
+
this.add(key, val);
|
|
7621
|
+
}
|
|
7622
|
+
return this.data;
|
|
7744
7623
|
});
|
|
7745
7624
|
/**
|
|
7746
|
-
*
|
|
7747
|
-
*
|
|
7625
|
+
* Retrieves data from the specified path or adds new data if no path is provided.
|
|
7626
|
+
*
|
|
7627
|
+
* @param {string} [path] - The path to retrieve data from. If not provided, new data will be added.
|
|
7628
|
+
* @returns {*} The data retrieved from the specified path or the result of adding new data.
|
|
7748
7629
|
*/
|
|
7749
|
-
__publicField(this, "
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7630
|
+
__publicField(this, "get", (path) => path ? get(this.data, path) : this.add());
|
|
7631
|
+
/**
|
|
7632
|
+
* Adds a new component with the given id and data.
|
|
7633
|
+
*
|
|
7634
|
+
* @param {string} id - The unique identifier for the component. If not provided, a new UUID will be generated.
|
|
7635
|
+
* @param {Object} [data=Object.create(null)] - The data to initialize the component with.
|
|
7636
|
+
* @returns {Object} The newly created component.
|
|
7637
|
+
*/
|
|
7638
|
+
__publicField(this, "add", (id, data = /* @__PURE__ */ Object.create(null)) => {
|
|
7639
|
+
const elemId = id || uuid();
|
|
7640
|
+
const component = this.Component({ ...data, id: elemId });
|
|
7641
|
+
this.set(elemId, component);
|
|
7642
|
+
this.active = component;
|
|
7643
|
+
return component;
|
|
7759
7644
|
});
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
focus: ({ target }) => {
|
|
7772
|
-
const group = target.closest(`.${CONTROL_GROUP_CLASSNAME}`);
|
|
7773
|
-
return group && this.panels.nav.refresh(indexOfNode(group));
|
|
7774
|
-
},
|
|
7775
|
-
click: ({ target }) => {
|
|
7776
|
-
this.addElement(target.parentElement.id);
|
|
7645
|
+
/**
|
|
7646
|
+
* removes a component form the index
|
|
7647
|
+
* @param {String|Array} componentId
|
|
7648
|
+
*/
|
|
7649
|
+
__publicField(this, "remove", (componentId) => {
|
|
7650
|
+
if (Array.isArray(componentId)) {
|
|
7651
|
+
for (const id of componentId) {
|
|
7652
|
+
this.get(id).remove();
|
|
7653
|
+
}
|
|
7654
|
+
} else {
|
|
7655
|
+
this.get(componentId).remove();
|
|
7777
7656
|
}
|
|
7778
|
-
|
|
7657
|
+
return this.data;
|
|
7658
|
+
});
|
|
7659
|
+
/**
|
|
7660
|
+
* Deletes a component from the data object.
|
|
7661
|
+
*
|
|
7662
|
+
* @param {string} componentId - The ID of the component to delete.
|
|
7663
|
+
* @returns {string} The ID of the deleted component.
|
|
7664
|
+
*/
|
|
7665
|
+
__publicField(this, "delete", (componentId) => {
|
|
7666
|
+
delete this.data[componentId];
|
|
7667
|
+
return componentId;
|
|
7668
|
+
});
|
|
7669
|
+
/**
|
|
7670
|
+
* Clears all instances from the store
|
|
7671
|
+
* @param {Object} evt
|
|
7672
|
+
*/
|
|
7673
|
+
__publicField(this, "clearAll", (isAnimated = true) => {
|
|
7674
|
+
const promises = Object.values(this.data).map((component) => component.empty(isAnimated));
|
|
7675
|
+
return Promise.all(promises);
|
|
7676
|
+
});
|
|
7677
|
+
__publicField(this, "conditionMap", /* @__PURE__ */ new Map());
|
|
7779
7678
|
}
|
|
7780
7679
|
/**
|
|
7781
|
-
*
|
|
7782
|
-
*
|
|
7680
|
+
* Extends the configVal for a component type,
|
|
7681
|
+
* eventually read by Component
|
|
7682
|
+
* @return {Object} configVal
|
|
7783
7683
|
*/
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
this.buildDOM(sticky);
|
|
7787
|
-
return this;
|
|
7684
|
+
set config(config2) {
|
|
7685
|
+
this.configVal = merge(this.configVal, clone$1(config2));
|
|
7788
7686
|
}
|
|
7789
7687
|
/**
|
|
7790
|
-
*
|
|
7791
|
-
* @return {
|
|
7688
|
+
* Reads configVal for a component type
|
|
7689
|
+
* @return {Object} configVal
|
|
7792
7690
|
*/
|
|
7793
|
-
|
|
7794
|
-
this.
|
|
7795
|
-
return elements.map(async (Element) => {
|
|
7796
|
-
const isControl = typeof Element === "function";
|
|
7797
|
-
let control;
|
|
7798
|
-
if (isControl) {
|
|
7799
|
-
control = new Element();
|
|
7800
|
-
} else {
|
|
7801
|
-
control = new Control(Element);
|
|
7802
|
-
}
|
|
7803
|
-
this.add(control);
|
|
7804
|
-
this.controls.push(control.dom);
|
|
7805
|
-
return control.promise();
|
|
7806
|
-
});
|
|
7691
|
+
get config() {
|
|
7692
|
+
return this.configVal;
|
|
7807
7693
|
}
|
|
7694
|
+
}
|
|
7695
|
+
const DEFAULT_DATA$2 = () => Object.freeze({ children: [] });
|
|
7696
|
+
class Stage extends Component {
|
|
7808
7697
|
/**
|
|
7809
|
-
*
|
|
7810
|
-
* @
|
|
7698
|
+
* Process options and load existing fields from data to the stage
|
|
7699
|
+
* @param {Object} formeoOptions
|
|
7700
|
+
* @param {String} stageData uuid
|
|
7701
|
+
* @return {Object} DOM element
|
|
7811
7702
|
*/
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7703
|
+
constructor(stageData, render) {
|
|
7704
|
+
super("stage", { ...DEFAULT_DATA$2(), ...stageData }, render);
|
|
7705
|
+
const children = this.createChildWrap();
|
|
7706
|
+
this.dom = dom.create({
|
|
7707
|
+
attrs: {
|
|
7708
|
+
className: [STAGE_CLASSNAME, "empty"],
|
|
7709
|
+
id: this.id
|
|
7710
|
+
},
|
|
7711
|
+
children
|
|
7712
|
+
});
|
|
7713
|
+
Sortable.create(children, {
|
|
7714
|
+
animation: 150,
|
|
7715
|
+
fallbackClass: "row-moving",
|
|
7716
|
+
forceFallback: true,
|
|
7717
|
+
group: {
|
|
7718
|
+
name: "stage",
|
|
7719
|
+
pull: true,
|
|
7720
|
+
put: ["row", "column", "controls"]
|
|
7721
|
+
},
|
|
7722
|
+
sort: true,
|
|
7723
|
+
disabled: false,
|
|
7724
|
+
onAdd: this.onAdd.bind(this),
|
|
7725
|
+
onRemove: this.onRemove.bind(this),
|
|
7726
|
+
onStart: () => {
|
|
7727
|
+
stages.active = this;
|
|
7728
|
+
},
|
|
7729
|
+
onSort: this.onSort.bind(this),
|
|
7730
|
+
draggable: `.${ROW_CLASSNAME}`,
|
|
7731
|
+
handle: ".item-move"
|
|
7732
|
+
});
|
|
7733
|
+
}
|
|
7734
|
+
empty(isAnimated = true) {
|
|
7735
|
+
return new Promise((resolve) => {
|
|
7736
|
+
if (isAnimated) {
|
|
7737
|
+
this.dom.classList.add("removing-all-fields");
|
|
7738
|
+
animate.slideUp(this.dom, ANIMATION_SPEED_BASE, () => {
|
|
7739
|
+
resolve(super.empty(isAnimated));
|
|
7740
|
+
this.dom.classList.remove("removing-all-fields");
|
|
7741
|
+
animate.slideDown(this.dom, ANIMATION_SPEED_BASE);
|
|
7742
|
+
});
|
|
7743
|
+
} else {
|
|
7744
|
+
resolve(super.empty());
|
|
7834
7745
|
}
|
|
7835
|
-
elements = orderObjectsBy(elements, group.elementOrder, "meta.id");
|
|
7836
|
-
groupConfig.content = elements.filter((control) => {
|
|
7837
|
-
const { controlData: field } = this.get(control.id);
|
|
7838
|
-
const controlId = field.meta.id || "";
|
|
7839
|
-
const filters = [
|
|
7840
|
-
match(controlId, this.options.disable.elements),
|
|
7841
|
-
field.meta.group === group.id,
|
|
7842
|
-
!usedElementIds.includes(controlId)
|
|
7843
|
-
];
|
|
7844
|
-
let shouldFilter = true;
|
|
7845
|
-
shouldFilter = filters.every((val) => val === true);
|
|
7846
|
-
if (shouldFilter) {
|
|
7847
|
-
usedElementIds.push(controlId);
|
|
7848
|
-
}
|
|
7849
|
-
return shouldFilter;
|
|
7850
|
-
});
|
|
7851
|
-
return groupConfig;
|
|
7852
7746
|
});
|
|
7853
|
-
return allGroups;
|
|
7854
7747
|
}
|
|
7855
|
-
|
|
7856
|
-
const
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
this.data.set(controlConfig.controlData.meta.id, controlConfig.controlData);
|
|
7748
|
+
onAdd(...args) {
|
|
7749
|
+
const component = super.onAdd(...args);
|
|
7750
|
+
if (component && component.name === "column") {
|
|
7751
|
+
component.parent.autoColumnWidths();
|
|
7860
7752
|
}
|
|
7861
|
-
return controlConfig;
|
|
7862
7753
|
}
|
|
7863
|
-
|
|
7864
|
-
|
|
7754
|
+
}
|
|
7755
|
+
let Stages$1 = class Stages extends ComponentData {
|
|
7756
|
+
constructor(stageData) {
|
|
7757
|
+
super("stages", stageData);
|
|
7758
|
+
}
|
|
7759
|
+
Component(data) {
|
|
7760
|
+
return new Stage(data);
|
|
7865
7761
|
}
|
|
7762
|
+
};
|
|
7763
|
+
const stages = new Stages$1();
|
|
7764
|
+
const DEFAULT_DATA$1 = () => Object.freeze({
|
|
7765
|
+
config: {
|
|
7766
|
+
fieldset: false,
|
|
7767
|
+
// wrap contents of row in fieldset
|
|
7768
|
+
legend: "",
|
|
7769
|
+
// Legend for fieldset
|
|
7770
|
+
inputGroup: false
|
|
7771
|
+
// is repeatable input-group?
|
|
7772
|
+
},
|
|
7773
|
+
children: [],
|
|
7774
|
+
className: [ROW_CLASSNAME]
|
|
7775
|
+
});
|
|
7776
|
+
class Row extends Component {
|
|
7866
7777
|
/**
|
|
7867
|
-
*
|
|
7868
|
-
* @
|
|
7778
|
+
* Set default and generate dom for row in editor
|
|
7779
|
+
* @param {String} dataID
|
|
7780
|
+
* @return {Object}
|
|
7869
7781
|
*/
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
events.confirmClearAll = new window.CustomEvent("confirmClearAll", {
|
|
7881
|
-
detail: {
|
|
7882
|
-
confirmationMessage: mi18n.get("confirmClearAll"),
|
|
7883
|
-
clearAllAction: () => {
|
|
7884
|
-
Stages2.clearAll().then(() => {
|
|
7885
|
-
const evtData = {
|
|
7886
|
-
src: evt.target
|
|
7887
|
-
};
|
|
7888
|
-
events.formeoCleared(evtData);
|
|
7889
|
-
});
|
|
7890
|
-
},
|
|
7891
|
-
btnCoords: dom.coords(evt.target)
|
|
7892
|
-
}
|
|
7893
|
-
});
|
|
7894
|
-
document.dispatchEvent(events.confirmClearAll);
|
|
7895
|
-
} else {
|
|
7896
|
-
window.alert(mi18n.get("cannotClearFields"));
|
|
7897
|
-
}
|
|
7898
|
-
}
|
|
7782
|
+
constructor(rowData) {
|
|
7783
|
+
super("row", { ...DEFAULT_DATA$1(), ...rowData });
|
|
7784
|
+
/**
|
|
7785
|
+
* Read columns and generate bootstrap cols
|
|
7786
|
+
* @param {Object} row DOM element
|
|
7787
|
+
*/
|
|
7788
|
+
__publicField(this, "autoColumnWidths", () => {
|
|
7789
|
+
const columns2 = this.children;
|
|
7790
|
+
if (!columns2.length) {
|
|
7791
|
+
return;
|
|
7899
7792
|
}
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
};
|
|
7914
|
-
actions.click.btn(saveEvt);
|
|
7915
|
-
return actions.save.form(formData);
|
|
7916
|
-
}
|
|
7917
|
-
}
|
|
7918
|
-
};
|
|
7919
|
-
const formActions = {
|
|
7920
|
-
className: "form-actions f-btn-group",
|
|
7921
|
-
content: Object.entries({ clearBtn, saveBtn }).reduce((acc, [key, value]) => {
|
|
7922
|
-
if (!this.options.disable.formActions.includes(key)) {
|
|
7923
|
-
acc.push(value);
|
|
7924
|
-
}
|
|
7925
|
-
return acc;
|
|
7926
|
-
}, [])
|
|
7927
|
-
};
|
|
7928
|
-
return formActions;
|
|
7929
|
-
}
|
|
7930
|
-
/**
|
|
7931
|
-
* Returns the markup for the form controls/fields
|
|
7932
|
-
* @return {DOM}
|
|
7933
|
-
*/
|
|
7934
|
-
buildDOM(sticky) {
|
|
7935
|
-
const groupedFields = this.groupElements();
|
|
7936
|
-
const formActions = this.formActions();
|
|
7937
|
-
const { displayType } = this.options.panels;
|
|
7938
|
-
this.panels = new Panels({ panels: groupedFields, type: "controls", displayType });
|
|
7939
|
-
const groupsWrapClasses = ["control-groups", "formeo-panels-wrap", `panel-count-${groupedFields.length}`];
|
|
7940
|
-
const groupsWrap = dom.create({
|
|
7941
|
-
className: groupsWrapClasses,
|
|
7942
|
-
content: [this.panels.panelNav, this.panels.panelsWrap]
|
|
7943
|
-
});
|
|
7944
|
-
const controlClasses = ["formeo-controls"];
|
|
7945
|
-
if (sticky) {
|
|
7946
|
-
controlClasses.push("formeo-sticky");
|
|
7947
|
-
}
|
|
7948
|
-
const element = dom.create({
|
|
7949
|
-
className: controlClasses,
|
|
7950
|
-
content: [groupsWrap, formActions]
|
|
7951
|
-
});
|
|
7952
|
-
const groups = element.getElementsByClassName("control-group");
|
|
7953
|
-
this.dom = element;
|
|
7954
|
-
this.groups = groups;
|
|
7955
|
-
const [firstGroup] = groups;
|
|
7956
|
-
this.currentGroup = firstGroup;
|
|
7957
|
-
this.actions = {
|
|
7958
|
-
filter: (term) => {
|
|
7959
|
-
const filtering = term !== "";
|
|
7960
|
-
const fields2 = this.controls;
|
|
7961
|
-
let filteredTerm = groupsWrap.querySelector(".filtered-term");
|
|
7962
|
-
dom.toggleElementsByStr(fields2, term);
|
|
7963
|
-
if (filtering) {
|
|
7964
|
-
const filteredStr = mi18n.get("controls.filteringTerm", term);
|
|
7965
|
-
element.classList.add("filtered");
|
|
7966
|
-
if (filteredTerm) {
|
|
7967
|
-
filteredTerm.textContent = filteredStr;
|
|
7968
|
-
} else {
|
|
7969
|
-
filteredTerm = dom.create({
|
|
7970
|
-
tag: "h5",
|
|
7971
|
-
className: "filtered-term",
|
|
7972
|
-
content: filteredStr
|
|
7973
|
-
});
|
|
7974
|
-
groupsWrap.insertBefore(filteredTerm, groupsWrap.firstChild);
|
|
7975
|
-
}
|
|
7976
|
-
} else if (filteredTerm) {
|
|
7977
|
-
element.classList.remove("filtered");
|
|
7978
|
-
filteredTerm.remove();
|
|
7979
|
-
}
|
|
7980
|
-
},
|
|
7981
|
-
addElement: this.addElement,
|
|
7982
|
-
// @todo finish the addGroup method
|
|
7983
|
-
addGroup: (group) => console.log(group)
|
|
7984
|
-
};
|
|
7985
|
-
for (let i = groups.length - 1; i >= 0; i--) {
|
|
7986
|
-
const storeID = `formeo-controls-${groups[i]}`;
|
|
7987
|
-
if (!this.options.sortable) {
|
|
7988
|
-
window.localStorage.removeItem(storeID);
|
|
7989
|
-
}
|
|
7990
|
-
Sortable.create(groups[i], {
|
|
7991
|
-
animation: 150,
|
|
7992
|
-
forceFallback: true,
|
|
7993
|
-
fallbackClass: "control-moving",
|
|
7994
|
-
fallbackOnBody: true,
|
|
7995
|
-
group: {
|
|
7996
|
-
name: "controls",
|
|
7997
|
-
pull: "clone",
|
|
7998
|
-
put: false
|
|
7999
|
-
},
|
|
8000
|
-
onStart: ({ item }) => {
|
|
8001
|
-
const { controlData } = this.get(item.id);
|
|
8002
|
-
if (this.options.ghostPreview) {
|
|
8003
|
-
item.innerHTML = "";
|
|
8004
|
-
item.appendChild(new Field(controlData).preview);
|
|
8005
|
-
}
|
|
8006
|
-
},
|
|
8007
|
-
onEnd: ({ from, item, clone: clone2 }) => {
|
|
8008
|
-
if (from.contains(clone2)) {
|
|
8009
|
-
from.replaceChild(item, clone2);
|
|
8010
|
-
}
|
|
8011
|
-
},
|
|
8012
|
-
sort: this.options.sortable,
|
|
8013
|
-
store: {
|
|
8014
|
-
/**
|
|
8015
|
-
* Get the order of elements.
|
|
8016
|
-
* @param {Sortable} sortable
|
|
8017
|
-
* @return {Array}
|
|
8018
|
-
*/
|
|
8019
|
-
get: () => {
|
|
8020
|
-
const order = window.localStorage.getItem(storeID);
|
|
8021
|
-
return order ? order.split("|") : [];
|
|
8022
|
-
},
|
|
8023
|
-
/**
|
|
8024
|
-
* Save the order of elements.
|
|
8025
|
-
* @param {Sortable} sortable
|
|
8026
|
-
*/
|
|
8027
|
-
set: (sortable) => {
|
|
8028
|
-
const order = sortable.toArray();
|
|
8029
|
-
window.localStorage.setItem(storeID, order.join("|"));
|
|
8030
|
-
}
|
|
8031
|
-
}
|
|
8032
|
-
});
|
|
8033
|
-
}
|
|
8034
|
-
return element;
|
|
8035
|
-
}
|
|
8036
|
-
};
|
|
8037
|
-
const Controls$2 = new Controls$1();
|
|
8038
|
-
class ComponentData extends Data {
|
|
8039
|
-
constructor() {
|
|
8040
|
-
super(...arguments);
|
|
8041
|
-
__publicField(this, "load", (dataArg) => {
|
|
8042
|
-
const data = parseData(dataArg);
|
|
8043
|
-
this.empty();
|
|
8044
|
-
for (const [key, val] of Object.entries(data)) {
|
|
8045
|
-
this.add(key, val);
|
|
7793
|
+
const width = Number.parseFloat((100 / columns2.length).toFixed(1)) / 1;
|
|
7794
|
+
for (const column of columns2) {
|
|
7795
|
+
column.removeClasses(bsColRegExp);
|
|
7796
|
+
const colDom = column.dom;
|
|
7797
|
+
const newColWidth = numToPercent(width);
|
|
7798
|
+
column.set("config.width", newColWidth);
|
|
7799
|
+
colDom.style.width = newColWidth;
|
|
7800
|
+
colDom.dataset.colWidth = newColWidth;
|
|
7801
|
+
const refreshTimeout = setTimeout(() => {
|
|
7802
|
+
clearTimeout(refreshTimeout);
|
|
7803
|
+
column.refreshFieldPanels();
|
|
7804
|
+
}, ANIMATION_SPEED_FAST);
|
|
7805
|
+
document.dispatchEvent(events.columnResized);
|
|
8046
7806
|
}
|
|
8047
|
-
|
|
7807
|
+
this.updateColumnPreset();
|
|
8048
7808
|
});
|
|
8049
7809
|
/**
|
|
8050
|
-
*
|
|
8051
|
-
*
|
|
8052
|
-
* @param {string} [path] - The path to retrieve data from. If not provided, new data will be added.
|
|
8053
|
-
* @returns {*} The data retrieved from the specified path or the result of adding new data.
|
|
8054
|
-
*/
|
|
8055
|
-
__publicField(this, "get", (path) => path ? get(this.data, path) : this.add());
|
|
8056
|
-
/**
|
|
8057
|
-
* Adds a new component with the given id and data.
|
|
8058
|
-
*
|
|
8059
|
-
* @param {string} id - The unique identifier for the component. If not provided, a new UUID will be generated.
|
|
8060
|
-
* @param {Object} [data=Object.create(null)] - The data to initialize the component with.
|
|
8061
|
-
* @returns {Object} The newly created component.
|
|
7810
|
+
* Updates the column preset <select>
|
|
7811
|
+
* @return {Object} columnPresetConfig
|
|
8062
7812
|
*/
|
|
8063
|
-
__publicField(this, "
|
|
8064
|
-
|
|
8065
|
-
const
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
7813
|
+
__publicField(this, "updateColumnPreset", () => {
|
|
7814
|
+
this.columnPresetControl.innerHTML = "";
|
|
7815
|
+
const presetOptions = this.getColumnPresetOptions.map(
|
|
7816
|
+
({ label, ...attrs }) => dom.create({
|
|
7817
|
+
tag: "option",
|
|
7818
|
+
content: label,
|
|
7819
|
+
attrs
|
|
7820
|
+
})
|
|
7821
|
+
);
|
|
7822
|
+
this.columnPresetControl.append(...presetOptions);
|
|
8069
7823
|
});
|
|
8070
7824
|
/**
|
|
8071
|
-
*
|
|
8072
|
-
* @param {
|
|
7825
|
+
* Set the widths of columns in a row
|
|
7826
|
+
* @param {Object} row DOM element
|
|
7827
|
+
* @param {String} widths
|
|
8073
7828
|
*/
|
|
8074
|
-
__publicField(this, "
|
|
8075
|
-
if (
|
|
8076
|
-
|
|
8077
|
-
this.get(id).remove();
|
|
8078
|
-
}
|
|
8079
|
-
} else {
|
|
8080
|
-
this.get(componentId).remove();
|
|
7829
|
+
__publicField(this, "setColumnWidths", (widths) => {
|
|
7830
|
+
if (typeof widths === "string") {
|
|
7831
|
+
widths = widths.split(",");
|
|
8081
7832
|
}
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
*
|
|
8087
|
-
* @param {string} componentId - The ID of the component to delete.
|
|
8088
|
-
* @returns {string} The ID of the deleted component.
|
|
8089
|
-
*/
|
|
8090
|
-
__publicField(this, "delete", (componentId) => {
|
|
8091
|
-
delete this.data[componentId];
|
|
8092
|
-
return componentId;
|
|
8093
|
-
});
|
|
8094
|
-
/**
|
|
8095
|
-
* Clears all instances from the store
|
|
8096
|
-
* @param {Object} evt
|
|
8097
|
-
*/
|
|
8098
|
-
__publicField(this, "clearAll", (isAnimated = true) => {
|
|
8099
|
-
const promises = Object.values(this.data).map((component) => component.empty(isAnimated));
|
|
8100
|
-
return Promise.all(promises);
|
|
7833
|
+
this.children.forEach((column, i) => {
|
|
7834
|
+
column.setWidth(`${widths[i]}%`);
|
|
7835
|
+
column.refreshFieldPanels();
|
|
7836
|
+
});
|
|
8101
7837
|
});
|
|
8102
|
-
__publicField(this, "conditionMap", /* @__PURE__ */ new Map());
|
|
8103
|
-
}
|
|
8104
|
-
/**
|
|
8105
|
-
* Extends the configVal for a component type,
|
|
8106
|
-
* eventually read by Component
|
|
8107
|
-
* @return {Object} configVal
|
|
8108
|
-
*/
|
|
8109
|
-
set config(config2) {
|
|
8110
|
-
this.configVal = merge(this.configVal, clone$1(config2));
|
|
8111
|
-
}
|
|
8112
|
-
/**
|
|
8113
|
-
* Reads configVal for a component type
|
|
8114
|
-
* @return {Object} configVal
|
|
8115
|
-
*/
|
|
8116
|
-
get config() {
|
|
8117
|
-
return this.configVal;
|
|
8118
|
-
}
|
|
8119
|
-
}
|
|
8120
|
-
const DEFAULT_DATA$2 = () => Object.freeze({ children: [] });
|
|
8121
|
-
class Stage extends Component {
|
|
8122
|
-
/**
|
|
8123
|
-
* Process options and load existing fields from data to the stage
|
|
8124
|
-
* @param {Object} formeoOptions
|
|
8125
|
-
* @param {String} stageData uuid
|
|
8126
|
-
* @return {Object} DOM element
|
|
8127
|
-
*/
|
|
8128
|
-
constructor(stageData, render) {
|
|
8129
|
-
super("stage", { ...DEFAULT_DATA$2(), ...stageData }, render);
|
|
8130
7838
|
const children = this.createChildWrap();
|
|
8131
7839
|
this.dom = dom.create({
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
7840
|
+
tag: "li",
|
|
7841
|
+
className: [ROW_CLASSNAME, "empty"],
|
|
7842
|
+
dataset: {
|
|
7843
|
+
hoverTag: mi18n.get("row"),
|
|
7844
|
+
editingHoverTag: mi18n.get("editing.row")
|
|
8135
7845
|
},
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
Sortable.create(children, {
|
|
8139
|
-
animation: 150,
|
|
8140
|
-
fallbackClass: "row-moving",
|
|
8141
|
-
forceFallback: true,
|
|
8142
|
-
group: {
|
|
8143
|
-
name: "stage",
|
|
8144
|
-
pull: true,
|
|
8145
|
-
put: ["row", "column", "controls"]
|
|
8146
|
-
},
|
|
8147
|
-
sort: true,
|
|
8148
|
-
disabled: false,
|
|
8149
|
-
onAdd: this.onAdd.bind(this),
|
|
8150
|
-
onRemove: this.onRemove.bind(this),
|
|
8151
|
-
onStart: () => {
|
|
8152
|
-
stages.active = this;
|
|
8153
|
-
},
|
|
8154
|
-
onSort: this.onSort.bind(this),
|
|
8155
|
-
draggable: `.${ROW_CLASSNAME}`,
|
|
8156
|
-
handle: ".item-move"
|
|
8157
|
-
});
|
|
8158
|
-
}
|
|
8159
|
-
empty(isAnimated = true) {
|
|
8160
|
-
return new Promise((resolve) => {
|
|
8161
|
-
if (isAnimated) {
|
|
8162
|
-
this.dom.classList.add("removing-all-fields");
|
|
8163
|
-
animate.slideUp(this.dom, ANIMATION_SPEED_BASE, () => {
|
|
8164
|
-
resolve(super.empty(isAnimated));
|
|
8165
|
-
this.dom.classList.remove("removing-all-fields");
|
|
8166
|
-
animate.slideDown(this.dom, ANIMATION_SPEED_BASE);
|
|
8167
|
-
});
|
|
8168
|
-
} else {
|
|
8169
|
-
resolve(super.empty());
|
|
8170
|
-
}
|
|
8171
|
-
});
|
|
8172
|
-
}
|
|
8173
|
-
onAdd(...args) {
|
|
8174
|
-
const component = super.onAdd(...args);
|
|
8175
|
-
if (component && component.name === "column") {
|
|
8176
|
-
component.parent.autoColumnWidths();
|
|
8177
|
-
}
|
|
8178
|
-
}
|
|
8179
|
-
}
|
|
8180
|
-
let Stages$1 = class Stages extends ComponentData {
|
|
8181
|
-
constructor(stageData) {
|
|
8182
|
-
super("stages", stageData);
|
|
8183
|
-
}
|
|
8184
|
-
Component(data) {
|
|
8185
|
-
return new Stage(data);
|
|
8186
|
-
}
|
|
8187
|
-
};
|
|
8188
|
-
const stages = new Stages$1();
|
|
8189
|
-
const DEFAULT_DATA$1 = () => Object.freeze({
|
|
8190
|
-
config: {
|
|
8191
|
-
fieldset: false,
|
|
8192
|
-
// wrap contents of row in fieldset
|
|
8193
|
-
legend: "",
|
|
8194
|
-
// Legend for fieldset
|
|
8195
|
-
inputGroup: false
|
|
8196
|
-
// is repeatable input-group?
|
|
8197
|
-
},
|
|
8198
|
-
children: [],
|
|
8199
|
-
className: [ROW_CLASSNAME]
|
|
8200
|
-
});
|
|
8201
|
-
class Row extends Component {
|
|
8202
|
-
/**
|
|
8203
|
-
* Set default and generate dom for row in editor
|
|
8204
|
-
* @param {String} dataID
|
|
8205
|
-
* @return {Object}
|
|
8206
|
-
*/
|
|
8207
|
-
constructor(rowData) {
|
|
8208
|
-
super("row", { ...DEFAULT_DATA$1(), ...rowData });
|
|
8209
|
-
/**
|
|
8210
|
-
* Read columns and generate bootstrap cols
|
|
8211
|
-
* @param {Object} row DOM element
|
|
8212
|
-
*/
|
|
8213
|
-
__publicField(this, "autoColumnWidths", () => {
|
|
8214
|
-
const columns2 = this.children;
|
|
8215
|
-
if (!columns2.length) {
|
|
8216
|
-
return;
|
|
8217
|
-
}
|
|
8218
|
-
const width = Number.parseFloat((100 / columns2.length).toFixed(1)) / 1;
|
|
8219
|
-
for (const column of columns2) {
|
|
8220
|
-
column.removeClasses(bsColRegExp);
|
|
8221
|
-
const colDom = column.dom;
|
|
8222
|
-
const newColWidth = numToPercent(width);
|
|
8223
|
-
column.set("config.width", newColWidth);
|
|
8224
|
-
colDom.style.width = newColWidth;
|
|
8225
|
-
colDom.dataset.colWidth = newColWidth;
|
|
8226
|
-
const refreshTimeout = setTimeout(() => {
|
|
8227
|
-
clearTimeout(refreshTimeout);
|
|
8228
|
-
column.refreshFieldPanels();
|
|
8229
|
-
}, ANIMATION_SPEED_FAST);
|
|
8230
|
-
document.dispatchEvent(events.columnResized);
|
|
8231
|
-
}
|
|
8232
|
-
this.updateColumnPreset();
|
|
8233
|
-
});
|
|
8234
|
-
/**
|
|
8235
|
-
* Updates the column preset <select>
|
|
8236
|
-
* @return {Object} columnPresetConfig
|
|
8237
|
-
*/
|
|
8238
|
-
__publicField(this, "updateColumnPreset", () => {
|
|
8239
|
-
this.columnPresetControl.innerHTML = "";
|
|
8240
|
-
const presetOptions = this.getColumnPresetOptions.map(
|
|
8241
|
-
({ label, ...attrs }) => dom.create({
|
|
8242
|
-
tag: "option",
|
|
8243
|
-
content: label,
|
|
8244
|
-
attrs
|
|
8245
|
-
})
|
|
8246
|
-
);
|
|
8247
|
-
this.columnPresetControl.append(...presetOptions);
|
|
8248
|
-
});
|
|
8249
|
-
/**
|
|
8250
|
-
* Set the widths of columns in a row
|
|
8251
|
-
* @param {Object} row DOM element
|
|
8252
|
-
* @param {String} widths
|
|
8253
|
-
*/
|
|
8254
|
-
__publicField(this, "setColumnWidths", (widths) => {
|
|
8255
|
-
if (typeof widths === "string") {
|
|
8256
|
-
widths = widths.split(",");
|
|
8257
|
-
}
|
|
8258
|
-
this.children.forEach((column, i) => {
|
|
8259
|
-
column.setWidth(`${widths[i]}%`);
|
|
8260
|
-
column.refreshFieldPanels();
|
|
8261
|
-
});
|
|
8262
|
-
});
|
|
8263
|
-
const children = this.createChildWrap();
|
|
8264
|
-
this.dom = dom.create({
|
|
8265
|
-
tag: "li",
|
|
8266
|
-
className: [ROW_CLASSNAME, "empty"],
|
|
8267
|
-
dataset: {
|
|
8268
|
-
hoverTag: mi18n.get("row"),
|
|
8269
|
-
editingHoverTag: mi18n.get("editing.row")
|
|
8270
|
-
},
|
|
8271
|
-
id: this.id,
|
|
8272
|
-
content: [this.getComponentTag(), this.getActionButtons(), this.editWindow, children]
|
|
7846
|
+
id: this.id,
|
|
7847
|
+
content: [this.getComponentTag(), this.getActionButtons(), this.editWindow, children]
|
|
8273
7848
|
});
|
|
8274
7849
|
Sortable.create(children, {
|
|
8275
7850
|
animation: 150,
|
|
@@ -9945,164 +9520,598 @@ let FormeoRenderer$1 = class FormeoRenderer {
|
|
|
9945
9520
|
className: "add-input-group btn pull-right",
|
|
9946
9521
|
type: "button"
|
|
9947
9522
|
},
|
|
9948
|
-
children: "Add +",
|
|
9523
|
+
children: "Add +",
|
|
9524
|
+
action: {
|
|
9525
|
+
click: (e) => {
|
|
9526
|
+
const fInputGroup = e.target.parentElement;
|
|
9527
|
+
const elem = dom.render(this.cloneComponentData(id));
|
|
9528
|
+
fInputGroup.insertBefore(elem, fInputGroup.lastChild);
|
|
9529
|
+
elem.appendChild(createRemoveButton());
|
|
9530
|
+
}
|
|
9531
|
+
}
|
|
9532
|
+
}));
|
|
9533
|
+
__publicField(this, "processColumns", (rowId) => {
|
|
9534
|
+
return this.orderChildren("columns", this.form.rows[rowId].children).map(
|
|
9535
|
+
(column) => this.cacheComponent(this.processColumn(column))
|
|
9536
|
+
);
|
|
9537
|
+
});
|
|
9538
|
+
__publicField(this, "processFields", (fieldIds) => this.orderChildren("fields", fieldIds).map(({ id, ...field }) => {
|
|
9539
|
+
var _a, _b;
|
|
9540
|
+
const controlId = ((_a = field.config) == null ? void 0 : _a.controlId) || ((_b = field.meta) == null ? void 0 : _b.id);
|
|
9541
|
+
const { action = {}, dependencies: dependencies2 = {} } = this.elements[controlId] || {};
|
|
9542
|
+
if (dependencies2) {
|
|
9543
|
+
fetchDependencies(dependencies2);
|
|
9544
|
+
}
|
|
9545
|
+
const mergedFieldData = merge({ action }, field);
|
|
9546
|
+
return this.cacheComponent({ ...mergedFieldData, id: this.prefixId(id) });
|
|
9547
|
+
}));
|
|
9548
|
+
/**
|
|
9549
|
+
* Evaulate and execute conditions for fields by creating listeners for input and changes
|
|
9550
|
+
* @return {Array} flattened array of conditions
|
|
9551
|
+
*/
|
|
9552
|
+
__publicField(this, "handleComponentCondition", (component, ifRest, thenConditions) => {
|
|
9553
|
+
const listenerEvent = LISTEN_TYPE_MAP(component);
|
|
9554
|
+
if (listenerEvent) {
|
|
9555
|
+
component.addEventListener(
|
|
9556
|
+
listenerEvent,
|
|
9557
|
+
(evt) => {
|
|
9558
|
+
if (this.evaluateCondition(ifRest, evt)) {
|
|
9559
|
+
for (const thenCondition of thenConditions) {
|
|
9560
|
+
this.execResult(thenCondition, evt);
|
|
9561
|
+
}
|
|
9562
|
+
}
|
|
9563
|
+
},
|
|
9564
|
+
false
|
|
9565
|
+
);
|
|
9566
|
+
}
|
|
9567
|
+
const fakeEvt = { target: component };
|
|
9568
|
+
if (this.evaluateCondition(ifRest, fakeEvt)) {
|
|
9569
|
+
for (const thenCondition of thenConditions) {
|
|
9570
|
+
this.execResult(thenCondition, fakeEvt);
|
|
9571
|
+
}
|
|
9572
|
+
}
|
|
9573
|
+
});
|
|
9574
|
+
__publicField(this, "applyConditions", () => {
|
|
9575
|
+
for (const { conditions } of Object.values(this.components)) {
|
|
9576
|
+
if (conditions) {
|
|
9577
|
+
for (const condition of conditions) {
|
|
9578
|
+
const { if: ifConditions, then: thenConditions } = condition;
|
|
9579
|
+
for (const ifCondition of ifConditions) {
|
|
9580
|
+
const { source, ...ifRest } = ifCondition;
|
|
9581
|
+
if (isAddress(source)) {
|
|
9582
|
+
const components2 = this.getComponents(source);
|
|
9583
|
+
for (const component of components2) {
|
|
9584
|
+
this.handleComponentCondition(component, ifRest, thenConditions);
|
|
9585
|
+
}
|
|
9586
|
+
}
|
|
9587
|
+
}
|
|
9588
|
+
}
|
|
9589
|
+
}
|
|
9590
|
+
}
|
|
9591
|
+
});
|
|
9592
|
+
/**
|
|
9593
|
+
* Evaulate conditions
|
|
9594
|
+
*/
|
|
9595
|
+
__publicField(this, "evaluateCondition", ({ sourceProperty, targetProperty, comparison, target }, evt) => {
|
|
9596
|
+
var _a;
|
|
9597
|
+
const comparisonMap = {
|
|
9598
|
+
equals: isEqual$1,
|
|
9599
|
+
notEquals: (source, target2) => !isEqual$1(source, target2),
|
|
9600
|
+
contains: (source, target2) => source.includes(target2),
|
|
9601
|
+
notContains: (source, target2) => !source.includes(target2)
|
|
9602
|
+
};
|
|
9603
|
+
const sourceValue = String(evt.target[sourceProperty]);
|
|
9604
|
+
const targetValue = String(isAddress(target) ? this.getComponent(target)[targetProperty] : target);
|
|
9605
|
+
return (_a = comparisonMap[comparison]) == null ? void 0 : _a.call(comparisonMap, sourceValue, targetValue);
|
|
9606
|
+
});
|
|
9607
|
+
__publicField(this, "execResult", ({ assignment, target, targetProperty, value }) => {
|
|
9608
|
+
var _a;
|
|
9609
|
+
const assignMap = {
|
|
9610
|
+
equals: (elem) => {
|
|
9611
|
+
var _a2;
|
|
9612
|
+
const propMap = {
|
|
9613
|
+
value: () => {
|
|
9614
|
+
elem[targetProperty] = value;
|
|
9615
|
+
},
|
|
9616
|
+
isNotVisible: () => {
|
|
9617
|
+
elem.parentElement.setAttribute("hidden", true);
|
|
9618
|
+
elem.required = false;
|
|
9619
|
+
},
|
|
9620
|
+
isVisible: () => {
|
|
9621
|
+
elem.parentElement.removeAttribute("hidden");
|
|
9622
|
+
elem.required = elem._required;
|
|
9623
|
+
}
|
|
9624
|
+
};
|
|
9625
|
+
(_a2 = propMap[targetProperty]) == null ? void 0 : _a2.call(propMap);
|
|
9626
|
+
}
|
|
9627
|
+
};
|
|
9628
|
+
if (isAddress(target)) {
|
|
9629
|
+
const elem = this.getComponent(target);
|
|
9630
|
+
if (elem && elem._required === void 0) {
|
|
9631
|
+
elem._required = elem.required;
|
|
9632
|
+
}
|
|
9633
|
+
(_a = assignMap[assignment]) == null ? void 0 : _a.call(assignMap, elem);
|
|
9634
|
+
}
|
|
9635
|
+
});
|
|
9636
|
+
__publicField(this, "getComponent", (address) => {
|
|
9637
|
+
const componentId = address.slice(address.indexOf(".") + 1);
|
|
9638
|
+
const component = isExternalAddress(address) ? this.external[componentId] : this.renderedForm.querySelector(`#f-${componentId}`);
|
|
9639
|
+
return component;
|
|
9640
|
+
});
|
|
9641
|
+
__publicField(this, "getComponents", (address) => {
|
|
9642
|
+
const components2 = [];
|
|
9643
|
+
const componentId = address.slice(address.indexOf(".") + 1);
|
|
9644
|
+
if (isExternalAddress(address)) {
|
|
9645
|
+
components2.push(this.external[componentId]);
|
|
9646
|
+
} else {
|
|
9647
|
+
components2.push(...this.renderedForm.querySelectorAll(`[name=f-${componentId}]`));
|
|
9648
|
+
}
|
|
9649
|
+
return components2;
|
|
9650
|
+
});
|
|
9651
|
+
const { renderContainer, external, elements, formData } = processOptions(opts);
|
|
9652
|
+
this.container = renderContainer;
|
|
9653
|
+
this.form = cleanFormData(formDataArg || formData);
|
|
9654
|
+
this.external = external;
|
|
9655
|
+
this.dom = dom;
|
|
9656
|
+
this.components = /* @__PURE__ */ Object.create(null);
|
|
9657
|
+
this.elements = elements;
|
|
9658
|
+
}
|
|
9659
|
+
get processedData() {
|
|
9660
|
+
return Object.values(this.form.stages).map((stage) => {
|
|
9661
|
+
stage.children = this.processRows(stage.id);
|
|
9662
|
+
stage.className = STAGE_CLASSNAME;
|
|
9663
|
+
return dom.render(stage);
|
|
9664
|
+
});
|
|
9665
|
+
}
|
|
9666
|
+
};
|
|
9667
|
+
const LISTEN_TYPE_MAP = (component) => {
|
|
9668
|
+
const typesMap = [
|
|
9669
|
+
["input", (c) => ["textarea", "text"].includes(c.type)],
|
|
9670
|
+
["change", (c) => ["select"].includes(c.tagName.toLowerCase()) || ["checkbox", "radio"].includes(c.type)]
|
|
9671
|
+
];
|
|
9672
|
+
const [listenerEvent] = typesMap.find((typeMap) => typeMap[1](component)) || [false];
|
|
9673
|
+
return listenerEvent;
|
|
9674
|
+
};
|
|
9675
|
+
if (window !== void 0) {
|
|
9676
|
+
window.FormeoEditor = FormeoEditor$1;
|
|
9677
|
+
window.FormeoRenderer = FormeoRenderer$1;
|
|
9678
|
+
}
|
|
9679
|
+
const FormeoEditor2 = FormeoEditor$1;
|
|
9680
|
+
const FormeoRenderer2 = FormeoRenderer$1;
|
|
9681
|
+
const rowControl = {
|
|
9682
|
+
config: {
|
|
9683
|
+
label: "row"
|
|
9684
|
+
},
|
|
9685
|
+
meta: {
|
|
9686
|
+
group: "layout",
|
|
9687
|
+
icon: "rows",
|
|
9688
|
+
id: "layout-row"
|
|
9689
|
+
}
|
|
9690
|
+
};
|
|
9691
|
+
const columnControl = {
|
|
9692
|
+
config: {
|
|
9693
|
+
label: "column"
|
|
9694
|
+
},
|
|
9695
|
+
meta: {
|
|
9696
|
+
group: "layout",
|
|
9697
|
+
icon: "columns",
|
|
9698
|
+
id: "layout-column"
|
|
9699
|
+
}
|
|
9700
|
+
};
|
|
9701
|
+
const index$4 = [rowControl, columnControl];
|
|
9702
|
+
const index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9703
|
+
__proto__: null,
|
|
9704
|
+
default: index$4
|
|
9705
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
9706
|
+
class HiddenControl extends Control {
|
|
9707
|
+
constructor() {
|
|
9708
|
+
const hiddenInput = {
|
|
9709
|
+
tag: "input",
|
|
9710
|
+
attrs: {
|
|
9711
|
+
type: "hidden",
|
|
9712
|
+
value: ""
|
|
9713
|
+
},
|
|
9714
|
+
config: {
|
|
9715
|
+
label: mi18n.get("hidden"),
|
|
9716
|
+
hideLabel: true
|
|
9717
|
+
},
|
|
9718
|
+
meta: {
|
|
9719
|
+
group: "common",
|
|
9720
|
+
icon: "hidden",
|
|
9721
|
+
id: "hidden"
|
|
9722
|
+
}
|
|
9723
|
+
};
|
|
9724
|
+
super(hiddenInput);
|
|
9725
|
+
}
|
|
9726
|
+
}
|
|
9727
|
+
class NumberControl extends Control {
|
|
9728
|
+
constructor() {
|
|
9729
|
+
const numberInput = {
|
|
9730
|
+
tag: "input",
|
|
9731
|
+
attrs: {
|
|
9732
|
+
type: "number",
|
|
9733
|
+
required: false,
|
|
9734
|
+
className: ""
|
|
9735
|
+
},
|
|
9736
|
+
config: {
|
|
9737
|
+
label: mi18n.get("number")
|
|
9738
|
+
},
|
|
9739
|
+
meta: {
|
|
9740
|
+
group: "common",
|
|
9741
|
+
icon: "hash",
|
|
9742
|
+
id: "number"
|
|
9743
|
+
}
|
|
9744
|
+
};
|
|
9745
|
+
super(numberInput);
|
|
9746
|
+
}
|
|
9747
|
+
}
|
|
9748
|
+
class TextAreaControl extends Control {
|
|
9749
|
+
constructor() {
|
|
9750
|
+
const textAreaConfig = {
|
|
9751
|
+
tag: "textarea",
|
|
9752
|
+
config: {
|
|
9753
|
+
label: mi18n.get("controls.form.textarea")
|
|
9754
|
+
},
|
|
9755
|
+
// actions here will be applied to the preview in the editor
|
|
9756
|
+
action: {
|
|
9757
|
+
input: function({ target: { value } }) {
|
|
9758
|
+
var _a;
|
|
9759
|
+
(_a = this.setData) == null ? void 0 : _a.call(this, "value", value);
|
|
9760
|
+
}
|
|
9761
|
+
},
|
|
9762
|
+
meta: {
|
|
9763
|
+
group: "common",
|
|
9764
|
+
icon: "textarea",
|
|
9765
|
+
id: "textarea"
|
|
9766
|
+
},
|
|
9767
|
+
attrs: {
|
|
9768
|
+
required: false
|
|
9769
|
+
}
|
|
9770
|
+
};
|
|
9771
|
+
super(textAreaConfig);
|
|
9772
|
+
}
|
|
9773
|
+
}
|
|
9774
|
+
class TextControl extends Control {
|
|
9775
|
+
constructor() {
|
|
9776
|
+
const textInput = {
|
|
9777
|
+
tag: "input",
|
|
9778
|
+
attrs: {
|
|
9779
|
+
required: false,
|
|
9780
|
+
type: "text",
|
|
9781
|
+
className: ""
|
|
9782
|
+
},
|
|
9783
|
+
config: {
|
|
9784
|
+
label: mi18n.get("controls.form.input.text")
|
|
9785
|
+
},
|
|
9786
|
+
meta: {
|
|
9787
|
+
group: "common",
|
|
9788
|
+
icon: "text-input",
|
|
9789
|
+
id: "text-input"
|
|
9790
|
+
}
|
|
9791
|
+
};
|
|
9792
|
+
super(textInput);
|
|
9793
|
+
}
|
|
9794
|
+
}
|
|
9795
|
+
class FileControl extends Control {
|
|
9796
|
+
constructor() {
|
|
9797
|
+
const fileInput = {
|
|
9798
|
+
tag: "input",
|
|
9799
|
+
attrs: {
|
|
9800
|
+
type: "file",
|
|
9801
|
+
required: false
|
|
9802
|
+
},
|
|
9803
|
+
config: {
|
|
9804
|
+
label: mi18n.get("fileUpload")
|
|
9805
|
+
},
|
|
9806
|
+
meta: {
|
|
9807
|
+
group: "common",
|
|
9808
|
+
icon: "upload",
|
|
9809
|
+
id: "upload"
|
|
9810
|
+
}
|
|
9811
|
+
};
|
|
9812
|
+
super(fileInput);
|
|
9813
|
+
}
|
|
9814
|
+
}
|
|
9815
|
+
const generateOptionConfig = (type2, count = 3) => Array.from({ length: count }, (v, k) => k + 1).map((i) => {
|
|
9816
|
+
const selectedKey = type2 === "checkbox" ? "checked" : "selected";
|
|
9817
|
+
return {
|
|
9818
|
+
label: mi18n.get("labelCount", {
|
|
9819
|
+
label: toTitleCase(type2),
|
|
9820
|
+
count: i
|
|
9821
|
+
}),
|
|
9822
|
+
value: `${type2}-${i}`,
|
|
9823
|
+
[selectedKey]: !i
|
|
9824
|
+
};
|
|
9825
|
+
});
|
|
9826
|
+
class SelectControl extends Control {
|
|
9827
|
+
constructor() {
|
|
9828
|
+
const selectConfig = {
|
|
9829
|
+
tag: "select",
|
|
9830
|
+
config: {
|
|
9831
|
+
label: mi18n.get("controls.form.select")
|
|
9832
|
+
},
|
|
9833
|
+
attrs: {
|
|
9834
|
+
required: false,
|
|
9835
|
+
className: ""
|
|
9836
|
+
},
|
|
9837
|
+
meta: {
|
|
9838
|
+
group: "common",
|
|
9839
|
+
icon: "select",
|
|
9840
|
+
id: "select"
|
|
9841
|
+
},
|
|
9842
|
+
options: generateOptionConfig("option")
|
|
9843
|
+
};
|
|
9844
|
+
super(selectConfig);
|
|
9845
|
+
}
|
|
9846
|
+
}
|
|
9847
|
+
class CheckboxGroupControl extends Control {
|
|
9848
|
+
constructor() {
|
|
9849
|
+
const checkboxGroup = {
|
|
9850
|
+
tag: "input",
|
|
9851
|
+
attrs: {
|
|
9852
|
+
type: "checkbox",
|
|
9853
|
+
required: false
|
|
9854
|
+
},
|
|
9855
|
+
config: {
|
|
9856
|
+
label: mi18n.get("controls.form.checkbox-group"),
|
|
9857
|
+
disabledAttrs: ["type"]
|
|
9858
|
+
},
|
|
9859
|
+
meta: {
|
|
9860
|
+
group: "common",
|
|
9861
|
+
icon: "checkbox",
|
|
9862
|
+
id: "checkbox"
|
|
9863
|
+
},
|
|
9864
|
+
options: generateOptionConfig("checkbox", 1)
|
|
9865
|
+
};
|
|
9866
|
+
super(checkboxGroup);
|
|
9867
|
+
}
|
|
9868
|
+
}
|
|
9869
|
+
class RadioGroupControl extends Control {
|
|
9870
|
+
constructor() {
|
|
9871
|
+
const radioGroup = {
|
|
9872
|
+
tag: "input",
|
|
9873
|
+
attrs: {
|
|
9874
|
+
type: "radio",
|
|
9875
|
+
required: false
|
|
9876
|
+
},
|
|
9877
|
+
config: {
|
|
9878
|
+
label: mi18n.get("controls.form.radio-group"),
|
|
9879
|
+
disabledAttrs: ["type"]
|
|
9880
|
+
},
|
|
9881
|
+
meta: {
|
|
9882
|
+
group: "common",
|
|
9883
|
+
icon: "radio-group",
|
|
9884
|
+
id: "radio"
|
|
9885
|
+
},
|
|
9886
|
+
options: generateOptionConfig("radio")
|
|
9887
|
+
};
|
|
9888
|
+
super(radioGroup);
|
|
9889
|
+
}
|
|
9890
|
+
}
|
|
9891
|
+
class ButtonControl extends Control {
|
|
9892
|
+
constructor() {
|
|
9893
|
+
const buttonConfig = {
|
|
9894
|
+
tag: "button",
|
|
9895
|
+
attrs: {
|
|
9896
|
+
className: [{ label: "grouped", value: "f-btn-group" }, { label: "ungrouped", value: "f-field-group" }]
|
|
9897
|
+
},
|
|
9898
|
+
config: {
|
|
9899
|
+
label: mi18n.get("controls.form.button"),
|
|
9900
|
+
hideLabel: true
|
|
9901
|
+
},
|
|
9902
|
+
meta: {
|
|
9903
|
+
group: "common",
|
|
9904
|
+
icon: "button",
|
|
9905
|
+
id: "button"
|
|
9906
|
+
},
|
|
9907
|
+
options: [
|
|
9908
|
+
{
|
|
9909
|
+
label: mi18n.get("button"),
|
|
9910
|
+
type: ["button", "submit", "reset"].map((buttonType) => ({
|
|
9911
|
+
label: buttonType,
|
|
9912
|
+
type: buttonType
|
|
9913
|
+
})),
|
|
9914
|
+
className: [
|
|
9915
|
+
{
|
|
9916
|
+
label: "default",
|
|
9917
|
+
value: "",
|
|
9918
|
+
selected: true
|
|
9919
|
+
},
|
|
9920
|
+
{
|
|
9921
|
+
label: "primary",
|
|
9922
|
+
value: "primary"
|
|
9923
|
+
},
|
|
9924
|
+
{
|
|
9925
|
+
label: "danger",
|
|
9926
|
+
value: "error"
|
|
9927
|
+
},
|
|
9928
|
+
{
|
|
9929
|
+
label: "success",
|
|
9930
|
+
value: "success"
|
|
9931
|
+
},
|
|
9932
|
+
{
|
|
9933
|
+
label: "warning",
|
|
9934
|
+
value: "warning"
|
|
9935
|
+
}
|
|
9936
|
+
]
|
|
9937
|
+
}
|
|
9938
|
+
]
|
|
9939
|
+
};
|
|
9940
|
+
super(buttonConfig);
|
|
9941
|
+
}
|
|
9942
|
+
}
|
|
9943
|
+
class DateControl extends Control {
|
|
9944
|
+
constructor() {
|
|
9945
|
+
const dateInput = {
|
|
9946
|
+
tag: "input",
|
|
9947
|
+
attrs: {
|
|
9948
|
+
type: "date",
|
|
9949
|
+
required: false,
|
|
9950
|
+
className: ""
|
|
9951
|
+
},
|
|
9952
|
+
config: {
|
|
9953
|
+
label: mi18n.get("controls.form.input.date")
|
|
9954
|
+
},
|
|
9955
|
+
meta: {
|
|
9956
|
+
group: "common",
|
|
9957
|
+
icon: "calendar",
|
|
9958
|
+
id: "date-input"
|
|
9959
|
+
}
|
|
9960
|
+
};
|
|
9961
|
+
super(dateInput);
|
|
9962
|
+
}
|
|
9963
|
+
}
|
|
9964
|
+
const index$2 = [
|
|
9965
|
+
ButtonControl,
|
|
9966
|
+
DateControl,
|
|
9967
|
+
HiddenControl,
|
|
9968
|
+
NumberControl,
|
|
9969
|
+
TextAreaControl,
|
|
9970
|
+
TextControl,
|
|
9971
|
+
FileControl,
|
|
9972
|
+
SelectControl,
|
|
9973
|
+
CheckboxGroupControl,
|
|
9974
|
+
RadioGroupControl
|
|
9975
|
+
];
|
|
9976
|
+
const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9977
|
+
__proto__: null,
|
|
9978
|
+
default: index$2
|
|
9979
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
9980
|
+
const headerTags = Array.from(Array(5).keys()).slice(1).map((key) => `h${key}`);
|
|
9981
|
+
const headerKey = "controls.html.header";
|
|
9982
|
+
class HeaderControl extends Control {
|
|
9983
|
+
constructor() {
|
|
9984
|
+
const header = {
|
|
9985
|
+
tag: headerTags[0],
|
|
9986
|
+
attrs: {
|
|
9987
|
+
tag: headerTags.map((tag, index2) => ({
|
|
9988
|
+
label: tag.toUpperCase(),
|
|
9989
|
+
value: tag,
|
|
9990
|
+
selected: !index2
|
|
9991
|
+
})),
|
|
9992
|
+
className: ""
|
|
9993
|
+
},
|
|
9994
|
+
config: {
|
|
9995
|
+
label: mi18n.get(headerKey),
|
|
9996
|
+
hideLabel: true,
|
|
9997
|
+
editableContent: true
|
|
9998
|
+
},
|
|
9999
|
+
meta: {
|
|
10000
|
+
group: "html",
|
|
10001
|
+
icon: "header",
|
|
10002
|
+
id: "html.header"
|
|
10003
|
+
},
|
|
10004
|
+
content: mi18n.get(headerKey),
|
|
9949
10005
|
action: {
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
const elem = dom.render(this.cloneComponentData(id));
|
|
9953
|
-
fInputGroup.insertBefore(elem, fInputGroup.lastChild);
|
|
9954
|
-
elem.appendChild(createRemoveButton());
|
|
9955
|
-
}
|
|
9956
|
-
}
|
|
9957
|
-
}));
|
|
9958
|
-
__publicField(this, "processColumns", (rowId) => {
|
|
9959
|
-
return this.orderChildren("columns", this.form.rows[rowId].children).map(
|
|
9960
|
-
(column) => this.cacheComponent(this.processColumn(column))
|
|
9961
|
-
);
|
|
9962
|
-
});
|
|
9963
|
-
__publicField(this, "processFields", (fieldIds) => this.orderChildren("fields", fieldIds).map(({ id, ...field }) => {
|
|
9964
|
-
var _a, _b;
|
|
9965
|
-
const controlId = ((_a = field.config) == null ? void 0 : _a.controlId) || ((_b = field.meta) == null ? void 0 : _b.id);
|
|
9966
|
-
const { action = {}, dependencies: dependencies2 = {} } = this.elements[controlId] || {};
|
|
9967
|
-
if (dependencies2) {
|
|
9968
|
-
fetchDependencies(dependencies2);
|
|
9969
|
-
}
|
|
9970
|
-
const mergedFieldData = merge({ action }, field);
|
|
9971
|
-
return this.cacheComponent({ ...mergedFieldData, id: this.prefixId(id) });
|
|
9972
|
-
}));
|
|
9973
|
-
/**
|
|
9974
|
-
* Evaulate and execute conditions for fields by creating listeners for input and changes
|
|
9975
|
-
* @return {Array} flattened array of conditions
|
|
9976
|
-
*/
|
|
9977
|
-
__publicField(this, "handleComponentCondition", (component, ifRest, thenConditions) => {
|
|
9978
|
-
const listenerEvent = LISTEN_TYPE_MAP(component);
|
|
9979
|
-
if (listenerEvent) {
|
|
9980
|
-
component.addEventListener(
|
|
9981
|
-
listenerEvent,
|
|
9982
|
-
(evt) => {
|
|
9983
|
-
if (this.evaluateCondition(ifRest, evt)) {
|
|
9984
|
-
for (const thenCondition of thenConditions) {
|
|
9985
|
-
this.execResult(thenCondition, evt);
|
|
9986
|
-
}
|
|
9987
|
-
}
|
|
9988
|
-
},
|
|
9989
|
-
false
|
|
9990
|
-
);
|
|
10006
|
+
// onRender: evt => {},
|
|
10007
|
+
// click: evt => {},
|
|
9991
10008
|
}
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
10009
|
+
};
|
|
10010
|
+
super(header);
|
|
10011
|
+
}
|
|
10012
|
+
/**
|
|
10013
|
+
* class configuration
|
|
10014
|
+
*/
|
|
10015
|
+
static get definition() {
|
|
10016
|
+
return {
|
|
10017
|
+
// i18n custom mappings (defaults to camelCase type)
|
|
10018
|
+
i18n: {
|
|
10019
|
+
"en-US": {
|
|
10020
|
+
header: "Custom English Header"
|
|
9996
10021
|
}
|
|
9997
10022
|
}
|
|
9998
|
-
}
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10023
|
+
};
|
|
10024
|
+
}
|
|
10025
|
+
get content() {
|
|
10026
|
+
return super.i18n(headerKey);
|
|
10027
|
+
}
|
|
10028
|
+
}
|
|
10029
|
+
class ParagraphControl extends Control {
|
|
10030
|
+
constructor() {
|
|
10031
|
+
const paragraphConfig = {
|
|
10032
|
+
tag: "p",
|
|
10033
|
+
attrs: {
|
|
10034
|
+
className: ""
|
|
10035
|
+
},
|
|
10036
|
+
config: {
|
|
10037
|
+
label: mi18n.get("controls.html.paragraph"),
|
|
10038
|
+
hideLabel: true,
|
|
10039
|
+
editableContent: true
|
|
10040
|
+
},
|
|
10041
|
+
meta: {
|
|
10042
|
+
group: "html",
|
|
10043
|
+
icon: "paragraph",
|
|
10044
|
+
id: "paragraph"
|
|
10045
|
+
},
|
|
10046
|
+
// eslint-disable-next-line
|
|
10047
|
+
content: "Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment."
|
|
10048
|
+
};
|
|
10049
|
+
super(paragraphConfig);
|
|
10050
|
+
}
|
|
10051
|
+
}
|
|
10052
|
+
class HRControl extends Control {
|
|
10053
|
+
constructor() {
|
|
10054
|
+
const hrConfig = {
|
|
10055
|
+
tag: "hr",
|
|
10056
|
+
config: {
|
|
10057
|
+
label: mi18n.get("controls.html.divider"),
|
|
10058
|
+
hideLabel: true
|
|
10059
|
+
},
|
|
10060
|
+
meta: {
|
|
10061
|
+
group: "html",
|
|
10062
|
+
icon: "divider",
|
|
10063
|
+
id: "divider"
|
|
10015
10064
|
}
|
|
10016
|
-
}
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
}
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
elem.parentElement.removeAttribute("hidden");
|
|
10047
|
-
elem.required = elem._required;
|
|
10048
|
-
}
|
|
10049
|
-
};
|
|
10050
|
-
(_a2 = propMap[targetProperty]) == null ? void 0 : _a2.call(propMap);
|
|
10065
|
+
};
|
|
10066
|
+
super(hrConfig);
|
|
10067
|
+
}
|
|
10068
|
+
}
|
|
10069
|
+
class TinyMCEControl extends Control {
|
|
10070
|
+
constructor(options) {
|
|
10071
|
+
const textAreaConfig = {
|
|
10072
|
+
tag: "textarea",
|
|
10073
|
+
config: {
|
|
10074
|
+
label: "WYSIWYG",
|
|
10075
|
+
editableContent: true
|
|
10076
|
+
},
|
|
10077
|
+
meta: {
|
|
10078
|
+
group: "html",
|
|
10079
|
+
icon: "rich-text",
|
|
10080
|
+
id: "tinymce"
|
|
10081
|
+
},
|
|
10082
|
+
attrs: {
|
|
10083
|
+
required: false
|
|
10084
|
+
},
|
|
10085
|
+
dependencies: { js: "https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.9.11/tinymce.min.js" },
|
|
10086
|
+
// this action is passed to the rendered control/element
|
|
10087
|
+
// useful for actions and events on the control preview
|
|
10088
|
+
action: {
|
|
10089
|
+
onRender: (elem) => {
|
|
10090
|
+
const selector = `#${elem.id}`;
|
|
10091
|
+
window.tinymce.remove(selector);
|
|
10092
|
+
window.tinymce.init({
|
|
10093
|
+
selector
|
|
10094
|
+
});
|
|
10051
10095
|
}
|
|
10052
|
-
}
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10096
|
+
},
|
|
10097
|
+
controlAction: {
|
|
10098
|
+
// callback when control is clicked
|
|
10099
|
+
click: () => {
|
|
10100
|
+
},
|
|
10101
|
+
// callback for when control is rendered
|
|
10102
|
+
onRender: () => {
|
|
10057
10103
|
}
|
|
10058
|
-
(_a = assignMap[assignment]) == null ? void 0 : _a.call(assignMap, elem);
|
|
10059
|
-
}
|
|
10060
|
-
});
|
|
10061
|
-
__publicField(this, "getComponent", (address) => {
|
|
10062
|
-
const componentId = address.slice(address.indexOf(".") + 1);
|
|
10063
|
-
const component = isExternalAddress(address) ? this.external[componentId] : this.renderedForm.querySelector(`#f-${componentId}`);
|
|
10064
|
-
return component;
|
|
10065
|
-
});
|
|
10066
|
-
__publicField(this, "getComponents", (address) => {
|
|
10067
|
-
const components2 = [];
|
|
10068
|
-
const componentId = address.slice(address.indexOf(".") + 1);
|
|
10069
|
-
if (isExternalAddress(address)) {
|
|
10070
|
-
components2.push(this.external[componentId]);
|
|
10071
|
-
} else {
|
|
10072
|
-
components2.push(...this.renderedForm.querySelectorAll(`[name=f-${componentId}]`));
|
|
10073
10104
|
}
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
this.container = renderContainer;
|
|
10078
|
-
this.form = cleanFormData(formDataArg || formData);
|
|
10079
|
-
this.external = external;
|
|
10080
|
-
this.dom = dom;
|
|
10081
|
-
this.components = /* @__PURE__ */ Object.create(null);
|
|
10082
|
-
this.elements = elements;
|
|
10083
|
-
}
|
|
10084
|
-
get processedData() {
|
|
10085
|
-
return Object.values(this.form.stages).map((stage) => {
|
|
10086
|
-
stage.children = this.processRows(stage.id);
|
|
10087
|
-
stage.className = STAGE_CLASSNAME;
|
|
10088
|
-
return dom.render(stage);
|
|
10089
|
-
});
|
|
10105
|
+
};
|
|
10106
|
+
const mergedOptions = merge(textAreaConfig, options);
|
|
10107
|
+
super(mergedOptions);
|
|
10090
10108
|
}
|
|
10091
|
-
};
|
|
10092
|
-
const LISTEN_TYPE_MAP = (component) => {
|
|
10093
|
-
const typesMap = [
|
|
10094
|
-
["input", (c) => ["textarea", "text"].includes(c.type)],
|
|
10095
|
-
["change", (c) => ["select"].includes(c.tagName.toLowerCase()) || ["checkbox", "radio"].includes(c.type)]
|
|
10096
|
-
];
|
|
10097
|
-
const [listenerEvent] = typesMap.find((typeMap) => typeMap[1](component)) || [false];
|
|
10098
|
-
return listenerEvent;
|
|
10099
|
-
};
|
|
10100
|
-
if (window !== void 0) {
|
|
10101
|
-
window.FormeoEditor = FormeoEditor$1;
|
|
10102
|
-
window.FormeoRenderer = FormeoRenderer$1;
|
|
10103
10109
|
}
|
|
10104
|
-
const
|
|
10105
|
-
const
|
|
10110
|
+
const index = [HeaderControl, ParagraphControl, HRControl, TinyMCEControl];
|
|
10111
|
+
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
10112
|
+
__proto__: null,
|
|
10113
|
+
default: index
|
|
10114
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
10106
10115
|
export {
|
|
10107
10116
|
FormeoEditor2 as FormeoEditor,
|
|
10108
10117
|
FormeoRenderer2 as FormeoRenderer
|