formeo 4.1.4 → 4.2.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/formeo.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 4.1.3
4
+ Version: 4.2.0
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -49,8 +49,8 @@ class I18N {
49
49
  this.config = { location: parsedLocation, ...restOptions };
50
50
  const { override, preloaded = {} } = this.config;
51
51
  const allLangs = Object.entries(this.langs).concat(Object.entries(override || preloaded));
52
- this.langs = allLangs.reduce((acc, [locale, lang]) => {
53
- acc[locale] = this.applyLanguage(locale, lang);
52
+ this.langs = allLangs.reduce((acc, [locale2, lang]) => {
53
+ acc[locale2] = this.applyLanguage(locale2, lang);
54
54
  return acc;
55
55
  }, {});
56
56
  this.locale = this.config.locale || this.config.langs[0];
@@ -69,9 +69,9 @@ class I18N {
69
69
  * @param {String} locale
70
70
  * @param {String|Object} lang
71
71
  */
72
- addLanguage(locale, lang = {}) {
72
+ addLanguage(locale2, lang = {}) {
73
73
  lang = typeof lang === "string" ? I18N.processFile(lang) : lang;
74
- this.applyLanguage(locale, lang);
74
+ this.applyLanguage(locale2, lang);
75
75
  this.config.langs.push("locale");
76
76
  }
77
77
  /**
@@ -80,9 +80,9 @@ class I18N {
80
80
  * @param {String} locale - locale to check for value
81
81
  * @return {String} language string or undefined
82
82
  */
83
- getValue(key, locale = this.locale) {
83
+ getValue(key, locale2 = this.locale) {
84
84
  var _a;
85
- const value = (_a = this.langs[locale]) == null ? void 0 : _a[key];
85
+ const value = (_a = this.langs[locale2]) == null ? void 0 : _a[key];
86
86
  return value || this.getFallbackValue(key);
87
87
  }
88
88
  /**
@@ -159,9 +159,9 @@ class I18N {
159
159
  static fromFile(rawText) {
160
160
  const lines = rawText.split("\n");
161
161
  const lang = {};
162
- for (let matches2, i = 0; i < lines.length; i++) {
162
+ for (let matches2, i2 = 0; i2 < lines.length; i2++) {
163
163
  const regex = /^(.+?) *?= *?([^\n]+)/;
164
- matches2 = regex.exec(lines[i]);
164
+ matches2 = regex.exec(lines[i2]);
165
165
  if (matches2) {
166
166
  lang[matches2[1]] = matches2[2].replace(/(^\s+|\s+$)/g, "");
167
167
  }
@@ -174,22 +174,22 @@ class I18N {
174
174
  * @param {Boolean} useCache
175
175
  * @return {Promise} resolves response
176
176
  */
177
- loadLang(locale, useCache = true) {
177
+ loadLang(locale2, useCache = true) {
178
178
  const _this = this;
179
179
  return new Promise(function(resolve, reject) {
180
- if (_this.loaded.indexOf(locale) !== -1 && useCache) {
181
- _this.applyLanguage(_this.langs[locale]);
182
- return resolve(_this.langs[locale]);
180
+ if (_this.loaded.indexOf(locale2) !== -1 && useCache) {
181
+ _this.applyLanguage(_this.langs[locale2]);
182
+ return resolve(_this.langs[locale2]);
183
183
  } else {
184
- const langFile = [_this.config.location, locale, _this.config.extension].join("");
184
+ const langFile = [_this.config.location, locale2, _this.config.extension].join("");
185
185
  return fetchData(langFile).then((lang) => {
186
186
  const processedFile = I18N.processFile(lang);
187
- _this.applyLanguage(locale, processedFile);
188
- _this.loaded.push(locale);
189
- return resolve(_this.langs[locale]);
187
+ _this.applyLanguage(locale2, processedFile);
188
+ _this.loaded.push(locale2);
189
+ return resolve(_this.langs[locale2]);
190
190
  }).catch((err) => {
191
191
  console.error(err);
192
- const lang = _this.applyLanguage(locale);
192
+ const lang = _this.applyLanguage(locale2);
193
193
  resolve(lang);
194
194
  });
195
195
  }
@@ -201,11 +201,11 @@ class I18N {
201
201
  * @param {Object} lang
202
202
  * @return {Object} overriden language
203
203
  */
204
- applyLanguage(locale, lang = {}) {
205
- const override = this.config.override[locale] || {};
206
- const existingLang = this.langs[locale] || {};
207
- this.langs[locale] = { ...existingLang, ...lang, ...override };
208
- return this.langs[locale];
204
+ applyLanguage(locale2, lang = {}) {
205
+ const override = this.config.override[locale2] || {};
206
+ const existingLang = this.langs[locale2] || {};
207
+ this.langs[locale2] = { ...existingLang, ...lang, ...override };
208
+ return this.langs[locale2];
209
209
  }
210
210
  /**
211
211
  * return currently available languages
@@ -219,10 +219,10 @@ class I18N {
219
219
  * @param {String} locale
220
220
  * @return {Promise} language
221
221
  */
222
- async setCurrent(locale = "en-US") {
223
- await this.loadLang(locale);
224
- this.locale = locale;
225
- this.current = this.langs[locale];
222
+ async setCurrent(locale2 = "en-US") {
223
+ await this.loadLang(locale2);
224
+ this.locale = locale2;
225
+ this.current = this.langs[locale2];
226
226
  return this.current;
227
227
  }
228
228
  }
@@ -255,9 +255,9 @@ class SmartTooltip {
255
255
  __publicField(this, "tooltip");
256
256
  __publicField(this, "activeTriggerType", null);
257
257
  __publicField(this, "spacing", 12);
258
- __publicField(this, "handleClick", (e) => {
258
+ __publicField(this, "handleClick", (e2) => {
259
259
  const triggerName = this.triggerName;
260
- const trigger = e.target.closest(`[${triggerName}][${triggerName}-type="click"]`);
260
+ const trigger = e2.target.closest(`[${triggerName}][${triggerName}-type="click"]`);
261
261
  if (trigger) {
262
262
  if (this.isVisible()) {
263
263
  this.hide();
@@ -270,9 +270,9 @@ class SmartTooltip {
270
270
  this.hide();
271
271
  }
272
272
  });
273
- __publicField(this, "handleMouseOver", (e) => {
273
+ __publicField(this, "handleMouseOver", (e2) => {
274
274
  const triggerName = this.triggerName;
275
- const trigger = e.target.closest(`[${triggerName}]`);
275
+ const trigger = e2.target.closest(`[${triggerName}]`);
276
276
  if (this.activeTriggerType !== "click" && (trigger == null ? void 0 : trigger.getAttribute(`${triggerName}-type`)) !== "click") {
277
277
  const content = trigger == null ? void 0 : trigger.getAttribute(`${triggerName}`);
278
278
  if (content) {
@@ -281,9 +281,9 @@ class SmartTooltip {
281
281
  }
282
282
  }
283
283
  });
284
- __publicField(this, "handleMouseOut", (e) => {
284
+ __publicField(this, "handleMouseOut", (e2) => {
285
285
  const triggerName = this.triggerName;
286
- const trigger = e.target.closest(`[${triggerName}]`);
286
+ const trigger = e2.target.closest(`[${triggerName}]`);
287
287
  if (this.activeTriggerType !== "click" && (trigger == null ? void 0 : trigger.getAttribute(`${triggerName}-type`)) !== "click") {
288
288
  this.hide();
289
289
  }
@@ -431,7 +431,7 @@ if (window !== void 0) {
431
431
  window.SmartTooltip = SmartTooltip;
432
432
  }
433
433
  const name$1 = "formeo";
434
- const version$2 = "4.1.3";
434
+ const version$2 = "4.2.0";
435
435
  const pkg = {
436
436
  name: name$1,
437
437
  version: version$2
@@ -665,7 +665,7 @@ function require_getRawTag() {
665
665
  try {
666
666
  value[symToStringTag] = void 0;
667
667
  var unmasked = true;
668
- } catch (e) {
668
+ } catch (e2) {
669
669
  }
670
670
  var result = nativeObjectToString.call(value);
671
671
  if (unmasked) {
@@ -776,11 +776,11 @@ function require_toSource() {
776
776
  if (func != null) {
777
777
  try {
778
778
  return funcToString.call(func);
779
- } catch (e) {
779
+ } catch (e2) {
780
780
  }
781
781
  try {
782
782
  return func + "";
783
- } catch (e) {
783
+ } catch (e2) {
784
784
  }
785
785
  }
786
786
  return "";
@@ -1126,7 +1126,7 @@ function require_defineProperty() {
1126
1126
  var func = getNative(Object, "defineProperty");
1127
1127
  func({}, "", {});
1128
1128
  return func;
1129
- } catch (e) {
1129
+ } catch (e2) {
1130
1130
  }
1131
1131
  })();
1132
1132
  _defineProperty$1 = defineProperty;
@@ -1537,7 +1537,7 @@ function require_nodeUtil() {
1537
1537
  return types;
1538
1538
  }
1539
1539
  return freeProcess && freeProcess.binding && freeProcess.binding("util");
1540
- } catch (e) {
1540
+ } catch (e2) {
1541
1541
  }
1542
1542
  })();
1543
1543
  module.exports = nodeUtil;
@@ -2070,8 +2070,8 @@ const clone$1 = (obj) => {
2070
2070
  }
2071
2071
  if (Array.isArray(obj)) {
2072
2072
  copy = [];
2073
- for (let i = 0, len = obj.length; i < len; i++) {
2074
- copy[i] = clone$1(obj[i]);
2073
+ for (let i2 = 0, len = obj.length; i2 < len; i2++) {
2074
+ copy[i2] = clone$1(obj[i2]);
2075
2075
  }
2076
2076
  return copy;
2077
2077
  }
@@ -2143,8 +2143,8 @@ function parseData(data = /* @__PURE__ */ Object.create(null)) {
2143
2143
  if (typeof data === "string") {
2144
2144
  try {
2145
2145
  return JSON.parse(data);
2146
- } catch (e) {
2147
- console.error("Invalid JSON string provided:", e);
2146
+ } catch (e2) {
2147
+ console.error("Invalid JSON string provided:", e2);
2148
2148
  return /* @__PURE__ */ Object.create(null);
2149
2149
  }
2150
2150
  }
@@ -2166,20 +2166,17 @@ function buildFlatDataStructure(data, componentId, componentType2, result = {})
2166
2166
  }
2167
2167
  return result;
2168
2168
  }
2169
+ let BUNDLED_SVG_SPRITE = null;
2170
+ try {
2171
+ BUNDLED_SVG_SPRITE = require("../../lib/icons/formeo-sprite.svg?raw");
2172
+ } catch (e2) {
2173
+ }
2169
2174
  const name = pkg.name;
2170
2175
  const version$1 = pkg.version;
2171
2176
  const PACKAGE_NAME = name;
2172
2177
  const formeoSpriteId = "formeo-sprite";
2173
- const POLYFILLS = [
2174
- { name: "cssPreload", src: "//cdnjs.cloudflare.com/ajax/libs/loadCSS/2.0.1/cssrelpreload.min.js" },
2175
- { name: "mutationObserver", src: "//cdn.jsdelivr.net/npm/mutationobserver-shim/dist/mutationobserver.min.js" },
2176
- { name: "fetch", src: "https://unpkg.com/unfetch/polyfill" }
2177
- ];
2178
- const relativeSpritePath = `../../lib/icons/${formeoSpriteId}.svg`;
2179
- const localSpriteUrl = typeof import.meta.resolve === "function" ? import.meta.resolve(relativeSpritePath) : relativeSpritePath;
2180
- const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development" || false;
2181
- const SVG_SPRITE_URL = isDev ? localSpriteUrl : `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/${formeoSpriteId}.svg`;
2182
- const FALLBACK_SVG_SPRITE_URL = `https://draggable.github.io/formeo/assets/img/${formeoSpriteId}.svg`;
2178
+ const SVG_SPRITE_URL = null;
2179
+ const FALLBACK_SVG_SPRITE_URL = `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/${formeoSpriteId}.svg`;
2183
2180
  const CSS_URL = `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/formeo.min.css`;
2184
2181
  const FALLBACK_CSS_URL = "https://draggable.github.io/formeo/assets/css/formeo.min.css";
2185
2182
  const PANEL_CLASSNAME = "f-panel";
@@ -2279,6 +2276,7 @@ const ANIMATION_SPEED_FAST = Math.round(ANIMATION_SPEED_BASE / 2);
2279
2276
  const ANIMATION_SPEED_SLOW = Math.round(ANIMATION_SPEED_BASE * 2);
2280
2277
  const EVENT_FORMEO_SAVED = "formeoSaved";
2281
2278
  const EVENT_FORMEO_UPDATED = "formeoUpdated";
2279
+ const EVENT_FORMEO_CHANGED = "formeoChanged";
2282
2280
  const EVENT_FORMEO_UPDATED_STAGE = "formeoUpdatedStage";
2283
2281
  const EVENT_FORMEO_UPDATED_ROW = "formeoUpdatedRow";
2284
2282
  const EVENT_FORMEO_UPDATED_COLUMN = "formeoUpdatedColumn";
@@ -2286,6 +2284,12 @@ const EVENT_FORMEO_UPDATED_FIELD = "formeoUpdatedField";
2286
2284
  const EVENT_FORMEO_CLEARED = "formeoCleared";
2287
2285
  const EVENT_FORMEO_ON_RENDER = "formeoOnRender";
2288
2286
  const EVENT_FORMEO_CONDITION_UPDATED = "formeoConditionUpdated";
2287
+ const EVENT_FORMEO_ADDED_ROW = "formeoAddedRow";
2288
+ const EVENT_FORMEO_ADDED_COLUMN = "formeoAddedColumn";
2289
+ const EVENT_FORMEO_ADDED_FIELD = "formeoAddedField";
2290
+ const EVENT_FORMEO_REMOVED_ROW = "formeoRemovedRow";
2291
+ const EVENT_FORMEO_REMOVED_COLUMN = "formeoRemovedColumn";
2292
+ const EVENT_FORMEO_REMOVED_FIELD = "formeoRemovedField";
2289
2293
  const COMPARISON_OPERATORS = {
2290
2294
  equals: "==",
2291
2295
  notEquals: "!=",
@@ -3292,6 +3296,18 @@ class Data {
3292
3296
  evtData.previousValue = oldVal;
3293
3297
  }
3294
3298
  events.formeoUpdated(evtData);
3299
+ if (this.name) {
3300
+ const componentEventMap = {
3301
+ stage: EVENT_FORMEO_UPDATED_STAGE,
3302
+ row: EVENT_FORMEO_UPDATED_ROW,
3303
+ column: EVENT_FORMEO_UPDATED_COLUMN,
3304
+ field: EVENT_FORMEO_UPDATED_FIELD
3305
+ };
3306
+ const specificEvent = componentEventMap[this.name];
3307
+ if (specificEvent) {
3308
+ events.formeoUpdated(evtData, specificEvent);
3309
+ }
3310
+ }
3295
3311
  }
3296
3312
  return data;
3297
3313
  }
@@ -3361,6 +3377,23 @@ class ComponentData extends Data {
3361
3377
  const component = this.Component({ ...data, id: elemId });
3362
3378
  this.data[elemId] = component;
3363
3379
  this.active = component;
3380
+ const componentEventMap = {
3381
+ row: EVENT_FORMEO_ADDED_ROW,
3382
+ column: EVENT_FORMEO_ADDED_COLUMN,
3383
+ field: EVENT_FORMEO_ADDED_FIELD
3384
+ };
3385
+ const addEvent = componentEventMap[this.name];
3386
+ if (addEvent) {
3387
+ events.formeoUpdated(
3388
+ {
3389
+ entity: component,
3390
+ componentId: elemId,
3391
+ componentType: this.name,
3392
+ data: component.data
3393
+ },
3394
+ addEvent
3395
+ );
3396
+ }
3364
3397
  return component;
3365
3398
  };
3366
3399
  /**
@@ -3426,9 +3459,9 @@ function ownKeys(object, enumerableOnly) {
3426
3459
  return keys;
3427
3460
  }
3428
3461
  function _objectSpread2(target) {
3429
- for (var i = 1; i < arguments.length; i++) {
3430
- var source = arguments[i] != null ? arguments[i] : {};
3431
- if (i % 2) {
3462
+ for (var i2 = 1; i2 < arguments.length; i2++) {
3463
+ var source = arguments[i2] != null ? arguments[i2] : {};
3464
+ if (i2 % 2) {
3432
3465
  ownKeys(Object(source), true).forEach(function(key) {
3433
3466
  _defineProperty(target, key, source[key]);
3434
3467
  });
@@ -3470,8 +3503,8 @@ function _defineProperty(obj, key, value) {
3470
3503
  }
3471
3504
  function _extends() {
3472
3505
  _extends = Object.assign || function(target) {
3473
- for (var i = 1; i < arguments.length; i++) {
3474
- var source = arguments[i];
3506
+ for (var i2 = 1; i2 < arguments.length; i2++) {
3507
+ var source = arguments[i2];
3475
3508
  for (var key in source) {
3476
3509
  if (Object.prototype.hasOwnProperty.call(source, key)) {
3477
3510
  target[key] = source[key];
@@ -3486,9 +3519,9 @@ function _objectWithoutPropertiesLoose(source, excluded) {
3486
3519
  if (source == null) return {};
3487
3520
  var target = {};
3488
3521
  var sourceKeys = Object.keys(source);
3489
- var key, i;
3490
- for (i = 0; i < sourceKeys.length; i++) {
3491
- key = sourceKeys[i];
3522
+ var key, i2;
3523
+ for (i2 = 0; i2 < sourceKeys.length; i2++) {
3524
+ key = sourceKeys[i2];
3492
3525
  if (excluded.indexOf(key) >= 0) continue;
3493
3526
  target[key] = source[key];
3494
3527
  }
@@ -3497,11 +3530,11 @@ function _objectWithoutPropertiesLoose(source, excluded) {
3497
3530
  function _objectWithoutProperties(source, excluded) {
3498
3531
  if (source == null) return {};
3499
3532
  var target = _objectWithoutPropertiesLoose(source, excluded);
3500
- var key, i;
3533
+ var key, i2;
3501
3534
  if (Object.getOwnPropertySymbols) {
3502
3535
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3503
- for (i = 0; i < sourceSymbolKeys.length; i++) {
3504
- key = sourceSymbolKeys[i];
3536
+ for (i2 = 0; i2 < sourceSymbolKeys.length; i2++) {
3537
+ key = sourceSymbolKeys[i2];
3505
3538
  if (excluded.indexOf(key) >= 0) continue;
3506
3539
  if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3507
3540
  target[key] = source[key];
@@ -3610,10 +3643,10 @@ function matrix(el, selfOnly) {
3610
3643
  }
3611
3644
  function find(ctx, tagName, iterator) {
3612
3645
  if (ctx) {
3613
- var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
3646
+ var list = ctx.getElementsByTagName(tagName), i2 = 0, n = list.length;
3614
3647
  if (iterator) {
3615
- for (; i < n; i++) {
3616
- iterator(list[i], i);
3648
+ for (; i2 < n; i2++) {
3649
+ iterator(list[i2], i2);
3617
3650
  }
3618
3651
  }
3619
3652
  return list;
@@ -3696,15 +3729,15 @@ function isScrolledPast(el, elSide, parentSide) {
3696
3729
  return false;
3697
3730
  }
3698
3731
  function getChild(el, childNum, options, includeDragEl) {
3699
- var currentChild = 0, i = 0, children = el.children;
3700
- while (i < children.length) {
3701
- if (children[i].style.display !== "none" && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
3732
+ var currentChild = 0, i2 = 0, children = el.children;
3733
+ while (i2 < children.length) {
3734
+ if (children[i2].style.display !== "none" && children[i2] !== Sortable.ghost && (includeDragEl || children[i2] !== Sortable.dragged) && closest(children[i2], options.draggable, el, false)) {
3702
3735
  if (currentChild === childNum) {
3703
- return children[i];
3736
+ return children[i2];
3704
3737
  }
3705
3738
  currentChild++;
3706
3739
  }
3707
- i++;
3740
+ i2++;
3708
3741
  }
3709
3742
  return null;
3710
3743
  }
@@ -3739,10 +3772,10 @@ function getRelativeScrollOffset(el) {
3739
3772
  return [offsetLeft, offsetTop];
3740
3773
  }
3741
3774
  function indexOfObject(arr, obj) {
3742
- for (var i in arr) {
3743
- if (!arr.hasOwnProperty(i)) continue;
3775
+ for (var i2 in arr) {
3776
+ if (!arr.hasOwnProperty(i2)) continue;
3744
3777
  for (var key in obj) {
3745
- if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
3778
+ if (obj.hasOwnProperty(key) && obj[key] === arr[i2][key]) return Number(i2);
3746
3779
  }
3747
3780
  }
3748
3781
  return -1;
@@ -4195,9 +4228,9 @@ var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent2(evt)
4195
4228
  var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
4196
4229
  if (nearest) {
4197
4230
  var event = {};
4198
- for (var i in evt) {
4199
- if (evt.hasOwnProperty(i)) {
4200
- event[i] = evt[i];
4231
+ for (var i2 in evt) {
4232
+ if (evt.hasOwnProperty(i2)) {
4233
+ event[i2] = evt[i2];
4201
4234
  }
4202
4235
  }
4203
4236
  event.target = event.rootEl = nearest;
@@ -4446,8 +4479,8 @@ Sortable.prototype = /** @lends Sortable.prototype */
4446
4479
  }
4447
4480
  }
4448
4481
  },
4449
- _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(e) {
4450
- var touch = e.touches ? e.touches[0] : e;
4482
+ _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(e2) {
4483
+ var touch = e2.touches ? e2.touches[0] : e2;
4451
4484
  if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
4452
4485
  this._disableDelayedDrag();
4453
4486
  }
@@ -5048,9 +5081,9 @@ Sortable.prototype = /** @lends Sortable.prototype */
5048
5081
  * @returns {String[]}
5049
5082
  */
5050
5083
  toArray: function toArray() {
5051
- var order = [], el, children = this.el.children, i = 0, n = children.length, options = this.options;
5052
- for (; i < n; i++) {
5053
- el = children[i];
5084
+ var order = [], el, children = this.el.children, i2 = 0, n = children.length, options = this.options;
5085
+ for (; i2 < n; i2++) {
5086
+ el = children[i2];
5054
5087
  if (closest(el, options.draggable, this.el, false)) {
5055
5088
  order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
5056
5089
  }
@@ -5063,8 +5096,8 @@ Sortable.prototype = /** @lends Sortable.prototype */
5063
5096
  */
5064
5097
  sort: function sort(order, useAnimation) {
5065
5098
  var items = {}, rootEl2 = this.el;
5066
- this.toArray().forEach(function(id, i) {
5067
- var el = rootEl2.children[i];
5099
+ this.toArray().forEach(function(id, i2) {
5100
+ var el = rootEl2.children[i2];
5068
5101
  if (closest(el, this.options.draggable, rootEl2, false)) {
5069
5102
  items[id] = el;
5070
5103
  }
@@ -5257,9 +5290,9 @@ function _getInsertDirection(target) {
5257
5290
  }
5258
5291
  }
5259
5292
  function _generateId(el) {
5260
- var str = el.tagName + el.className + el.src + el.href + el.textContent, i = str.length, sum = 0;
5261
- while (i--) {
5262
- sum += str.charCodeAt(i);
5293
+ var str = el.tagName + el.className + el.src + el.href + el.textContent, i2 = str.length, sum = 0;
5294
+ while (i2--) {
5295
+ sum += str.charCodeAt(i2);
5263
5296
  }
5264
5297
  return sum.toString(36);
5265
5298
  }
@@ -5451,9 +5484,9 @@ var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
5451
5484
  var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
5452
5485
  var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
5453
5486
  if (!autoScrolls[layersOut]) {
5454
- for (var i = 0; i <= layersOut; i++) {
5455
- if (!autoScrolls[i]) {
5456
- autoScrolls[i] = {};
5487
+ for (var i2 = 0; i2 <= layersOut; i2++) {
5488
+ if (!autoScrolls[i2]) {
5489
+ autoScrolls[i2] = {};
5457
5490
  }
5458
5491
  }
5459
5492
  }
@@ -5653,13 +5686,13 @@ const orderObjectsBy = (elements, order, path) => {
5653
5686
  return unique(orderedElements);
5654
5687
  };
5655
5688
  const forEach = (arr, cb, scope) => {
5656
- for (let i = 0; i < arr.length; i++) {
5657
- cb.call(scope, arr[i], i);
5689
+ for (let i2 = 0; i2 < arr.length; i2++) {
5690
+ cb.call(scope, arr[i2], i2);
5658
5691
  }
5659
5692
  };
5660
5693
  const map = (arr, cb) => {
5661
5694
  const newArray = [];
5662
- forEach(arr, (elem, i) => newArray.push(cb(elem, i)));
5695
+ forEach(arr, (elem, i2) => newArray.push(cb(elem, i2)));
5663
5696
  return newArray;
5664
5697
  };
5665
5698
  const sanitizedAttributeNames = {};
@@ -5678,7 +5711,6 @@ const safeAttrName = (name2) => {
5678
5711
  const capitalize = (str) => str.replace(/\b\w/g, (m) => m.toUpperCase());
5679
5712
  const copyObj = (obj) => window.JSON.parse(window.JSON.stringify(obj));
5680
5713
  const subtract = (arr, from) => from.filter((a) => !~arr.indexOf(a));
5681
- const isIE = () => window.navigator.userAgent.indexOf("MSIE ") !== -1;
5682
5714
  const helpers = {
5683
5715
  capitalize,
5684
5716
  safeAttrName,
@@ -5690,8 +5722,119 @@ const helpers = {
5690
5722
  indexOfNode,
5691
5723
  isInt,
5692
5724
  get,
5693
- orderObjectsBy,
5694
- isIE
5725
+ orderObjectsBy
5726
+ };
5727
+ const loaded = {
5728
+ js: /* @__PURE__ */ new Set(),
5729
+ css: /* @__PURE__ */ new Set(),
5730
+ formeoSprite: null
5731
+ };
5732
+ const ajax = (fileUrl, callback, onError = noop) => {
5733
+ return new Promise((resolve) => {
5734
+ return fetch(fileUrl).then((data) => {
5735
+ if (!data.ok) {
5736
+ return resolve(onError(data));
5737
+ }
5738
+ resolve(callback ? callback(data) : data);
5739
+ }).catch((err) => onError(err));
5740
+ });
5741
+ };
5742
+ const onLoadStylesheet = (elem, cb) => {
5743
+ elem.removeEventListener("load", onLoadStylesheet);
5744
+ cb(elem.src);
5745
+ };
5746
+ const onLoadJavascript = (elem, cb) => {
5747
+ elem.removeEventListener("load", onLoadJavascript);
5748
+ cb(elem.src);
5749
+ };
5750
+ const insertScript = (src) => {
5751
+ return new Promise((resolve, reject) => {
5752
+ if (loaded.js.has(src)) {
5753
+ return resolve(src);
5754
+ }
5755
+ loaded.js.add(src);
5756
+ const script = dom.create({
5757
+ tag: "script",
5758
+ attrs: {
5759
+ type: "text/javascript",
5760
+ async: true,
5761
+ src
5762
+ },
5763
+ action: {
5764
+ load: () => onLoadJavascript(script, resolve),
5765
+ error: () => reject(new Error(`${src} failed to load.`))
5766
+ }
5767
+ });
5768
+ document.head.appendChild(script);
5769
+ });
5770
+ };
5771
+ const insertStyle = (srcs) => {
5772
+ srcs = Array.isArray(srcs) ? srcs : [srcs];
5773
+ const promises = srcs.map(
5774
+ (src) => new Promise((resolve, reject) => {
5775
+ if (loaded.css.has(src)) {
5776
+ return resolve(src);
5777
+ }
5778
+ loaded.css.add(src);
5779
+ const styleLink = dom.create({
5780
+ tag: "link",
5781
+ attrs: {
5782
+ rel: "stylesheet",
5783
+ href: src
5784
+ },
5785
+ action: {
5786
+ load: () => onLoadStylesheet(styleLink, resolve),
5787
+ error: () => reject(new Error(`${(void 0).src} failed to load.`))
5788
+ }
5789
+ });
5790
+ document.head.appendChild(styleLink);
5791
+ })
5792
+ );
5793
+ return Promise.all(promises);
5794
+ };
5795
+ const insertScripts = (srcs) => {
5796
+ srcs = Array.isArray(srcs) ? srcs : [srcs];
5797
+ const promises = srcs.map((src) => insertScript(src));
5798
+ return Promise.all(promises);
5799
+ };
5800
+ const insertStyles = (srcs) => {
5801
+ srcs = Array.isArray(srcs) ? srcs : [srcs];
5802
+ const promises = srcs.map((src) => insertStyle(src));
5803
+ return Promise.all(promises);
5804
+ };
5805
+ const insertIcons = (iconSvgStr) => {
5806
+ const parser = new DOMParser();
5807
+ const svgDoc = parser.parseFromString(iconSvgStr, "image/svg+xml");
5808
+ loaded.formeoSprite = svgDoc.documentElement;
5809
+ return loaded.formeoSprite;
5810
+ };
5811
+ const fetchIcons = async (iconSpriteUrl = SVG_SPRITE_URL) => {
5812
+ if (loaded.formeoSprite) {
5813
+ return loaded.formeoSprite;
5814
+ }
5815
+ if (!iconSpriteUrl) {
5816
+ return insertIcons(BUNDLED_SVG_SPRITE);
5817
+ }
5818
+ const parseResp = async (resp) => insertIcons(await resp.text());
5819
+ return ajax(iconSpriteUrl, parseResp, () => ajax(FALLBACK_SVG_SPRITE_URL, parseResp));
5820
+ };
5821
+ const LOADER_MAP = {
5822
+ js: insertScripts,
5823
+ css: insertStyles
5824
+ };
5825
+ const fetchDependencies = (dependencies) => {
5826
+ const promises = Object.entries(dependencies).map(([type, src]) => {
5827
+ return LOADER_MAP[type](src);
5828
+ });
5829
+ return Promise.all(promises);
5830
+ };
5831
+ const fetchFormeoStyle = async (cssUrl) => {
5832
+ if (!loaded.css.has(cssUrl)) {
5833
+ await insertStyle(cssUrl);
5834
+ if (!loaded.css.has(FALLBACK_CSS_URL)) {
5835
+ return await insertStyle(FALLBACK_CSS_URL);
5836
+ }
5837
+ }
5695
5838
  };
5696
5839
  const iconFontTemplates = {
5697
5840
  glyphicons: (icon) => `<span class="glyphicon glyphicon-${icon}" aria-hidden="true"></span>`,
@@ -5786,7 +5929,7 @@ class DOM {
5786
5929
  processed.push("tag");
5787
5930
  let childType;
5788
5931
  const { tag } = elem;
5789
- let i;
5932
+ let i2;
5790
5933
  const wrap = {
5791
5934
  attrs: {},
5792
5935
  className: [helpers.get(elem, "config.inputWrap")],
@@ -5880,8 +6023,8 @@ class DOM {
5880
6023
  processed.push("action");
5881
6024
  }
5882
6025
  const remaining = helpers.subtract(processed, Object.keys(elem));
5883
- for (i = remaining.length - 1; i >= 0; i--) {
5884
- element[remaining[i]] = elem[remaining[i]];
6026
+ for (i2 = remaining.length - 1; i2 >= 0; i2--) {
6027
+ element[remaining[i2]] = elem[remaining[i2]];
5885
6028
  }
5886
6029
  if (wrap.children.length) {
5887
6030
  element = this.create(wrap);
@@ -5921,25 +6064,26 @@ class DOM {
5921
6064
  if (this.iconSymbols) {
5922
6065
  return this.iconSymbols;
5923
6066
  }
5924
- const iconSymbolNodes = document.querySelectorAll(`#${formeoSpriteId} svg symbol`);
5925
- const createSvgIconConfig = (symbolId) => ({
5926
- tag: "svg",
5927
- attrs: {
5928
- className: ["svg-icon", symbolId]
5929
- },
5930
- children: [
5931
- {
5932
- tag: "use",
5933
- attrs: {
5934
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
5935
- "xlink:href": `#${symbolId}`
5936
- }
5937
- }
5938
- ]
5939
- });
6067
+ const iconSymbolNodes = loaded.formeoSprite.querySelectorAll("svg symbol");
6068
+ const createSvgIconConfig = (symbol) => {
6069
+ const viewBox = symbol.getAttribute("viewBox") || "0 0 24 24";
6070
+ const children = Array.from(symbol.children).map((child) => {
6071
+ const clonedNode = child.cloneNode(true);
6072
+ return clonedNode.outerHTML;
6073
+ }).join("");
6074
+ return {
6075
+ tag: "svg",
6076
+ attrs: {
6077
+ className: ["svg-icon", symbol.id],
6078
+ viewBox,
6079
+ xmlns: "http://www.w3.org/2000/svg"
6080
+ },
6081
+ children
6082
+ };
6083
+ };
5940
6084
  this.iconSymbols = Array.from(iconSymbolNodes).reduce((acc, symbol) => {
5941
6085
  const name2 = symbol.id.replace(iconPrefix, "");
5942
- acc[name2] = createSvgIconConfig(symbol.id);
6086
+ acc[name2] = createSvgIconConfig(symbol);
5943
6087
  return acc;
5944
6088
  }, {});
5945
6089
  this.cachedIcons = {};
@@ -6047,19 +6191,19 @@ class DOM {
6047
6191
  });
6048
6192
  return elementsContainingText;
6049
6193
  };
6050
- generateOption = ({ type = "option", label, value, i = 0, selected }) => {
6194
+ generateOption = ({ type = "option", label, value, i: i2 = 0, selected }) => {
6051
6195
  const isOption = type === "option";
6052
6196
  return {
6053
6197
  tag: isOption ? "option" : "input",
6054
6198
  attrs: {
6055
6199
  type,
6056
- value: value || `${type}-${i}`,
6057
- [type === "option" ? "selected" : "checked"]: selected || !i
6200
+ value: value || `${type}-${i2}`,
6201
+ [type === "option" ? "selected" : "checked"]: selected || !i2
6058
6202
  },
6059
6203
  config: {
6060
6204
  label: label || mi18n.get("labelCount", {
6061
6205
  label: mi18n.get("option"),
6062
- count: i
6206
+ count: i2
6063
6207
  })
6064
6208
  }
6065
6209
  };
@@ -6075,7 +6219,7 @@ class DOM {
6075
6219
  const { action, attrs = {} } = elem;
6076
6220
  const fieldType = attrs.type || elem.tag;
6077
6221
  const id = attrs.id || elem.id;
6078
- const optionMap = (option2, i) => {
6222
+ const optionMap = (option2, i2) => {
6079
6223
  const { label, value, ...rest } = option2;
6080
6224
  const defaultInput = () => {
6081
6225
  const input = {
@@ -6084,7 +6228,7 @@ class DOM {
6084
6228
  name: id,
6085
6229
  type: fieldType,
6086
6230
  value: value || "",
6087
- id: `${id}-${i}`,
6231
+ id: `${id}-${i2}`,
6088
6232
  ...rest
6089
6233
  },
6090
6234
  action
@@ -6092,7 +6236,7 @@ class DOM {
6092
6236
  const optionLabel = {
6093
6237
  tag: "label",
6094
6238
  attrs: {
6095
- for: `${id}-${i}`
6239
+ for: `${id}-${i2}`
6096
6240
  },
6097
6241
  children: label
6098
6242
  };
@@ -6625,7 +6769,7 @@ class Autocomplete {
6625
6769
  * @return {Object} DOM Element to be injected into the form.
6626
6770
  */
6627
6771
  build() {
6628
- const keyboardNav = (e) => {
6772
+ const keyboardNav = (e2) => {
6629
6773
  const list = this.list;
6630
6774
  const activeOption = this.getActiveOption();
6631
6775
  const keyCodeMap = /* @__PURE__ */ new Map([
@@ -6662,7 +6806,7 @@ class Autocomplete {
6662
6806
  this.hideList();
6663
6807
  }
6664
6808
  }
6665
- e.preventDefault();
6809
+ e2.preventDefault();
6666
6810
  }
6667
6811
  ],
6668
6812
  [
@@ -6673,7 +6817,7 @@ class Autocomplete {
6673
6817
  }
6674
6818
  ]
6675
6819
  ]);
6676
- let direction = keyCodeMap.get(e.keyCode);
6820
+ let direction = keyCodeMap.get(e2.keyCode);
6677
6821
  if (!direction) {
6678
6822
  direction = () => false;
6679
6823
  }
@@ -7566,7 +7710,7 @@ class EditPanel {
7566
7710
  };
7567
7711
  const editPanelButtons = [];
7568
7712
  if (type === "conditions") {
7569
- if (!mi18n.current.clearAll) {
7713
+ if (mi18n.current && !mi18n.current.clearAll) {
7570
7714
  mi18n.put("clearAll", "Clear All");
7571
7715
  }
7572
7716
  const clearAllBtn = {
@@ -7862,7 +8006,7 @@ class Panels {
7862
8006
  placement: "top"
7863
8007
  },
7864
8008
  action: {
7865
- click: (e) => this.nav.nextGroup(e)
8009
+ click: (e2) => this.nav.nextGroup(e2)
7866
8010
  },
7867
8011
  content: dom.icon("triangle-right")
7868
8012
  };
@@ -7878,7 +8022,7 @@ class Panels {
7878
8022
  placement: "top"
7879
8023
  },
7880
8024
  action: {
7881
- click: (e) => this.nav.prevGroup(e)
8025
+ click: (e2) => this.nav.prevGroup(e2)
7882
8026
  },
7883
8027
  content: dom.icon("triangle-left")
7884
8028
  };
@@ -8060,6 +8204,7 @@ class Component extends Data {
8060
8204
  dispatchComponentEvent(eventName, eventData = {}) {
8061
8205
  const fullEventData = {
8062
8206
  component: this,
8207
+ target: this,
8063
8208
  type: eventName,
8064
8209
  timestamp: Date.now(),
8065
8210
  ...eventData
@@ -8145,6 +8290,22 @@ class Component extends Data {
8145
8290
  if (parent.name === "row") {
8146
8291
  parent.autoColumnWidths();
8147
8292
  }
8293
+ const componentEventMap = {
8294
+ row: EVENT_FORMEO_REMOVED_ROW,
8295
+ column: EVENT_FORMEO_REMOVED_COLUMN,
8296
+ field: EVENT_FORMEO_REMOVED_FIELD
8297
+ };
8298
+ const removeEvent = componentEventMap[this.name];
8299
+ if (removeEvent) {
8300
+ events.formeoUpdated(
8301
+ {
8302
+ componentId: this.id,
8303
+ componentType: this.name,
8304
+ parent
8305
+ },
8306
+ removeEvent
8307
+ );
8308
+ }
8148
8309
  return components[`${this.name}s`].delete(this.id);
8149
8310
  };
8150
8311
  /**
@@ -8198,12 +8359,7 @@ class Component extends Data {
8198
8359
  return dom.create({
8199
8360
  tag: "span",
8200
8361
  className: ["component-tag", `${this.name}-tag`],
8201
- children: [
8202
- (this.isColumn || this.isField) && dom.icon("component-corner", { className: "bottom-left" }),
8203
- dom.icon(`handle-${this.name}`),
8204
- toTitleCase(this.name),
8205
- (this.isColumn || this.isRow) && dom.icon("component-corner", { className: "bottom-right" })
8206
- ].filter(Boolean)
8362
+ children: [dom.icon(`handle-${this.name}`), toTitleCase(this.name)].filter(Boolean)
8207
8363
  });
8208
8364
  };
8209
8365
  /**
@@ -9267,8 +9423,8 @@ class Row extends Component {
9267
9423
  if (typeof widths === "string") {
9268
9424
  widths = widths.split(",");
9269
9425
  }
9270
- this.children.forEach((column, i) => {
9271
- column.setWidth(`${widths[i]}%`);
9426
+ this.children.forEach((column, i2) => {
9427
+ column.setWidth(`${widths[i2]}%`);
9272
9428
  column.refreshFieldPanels();
9273
9429
  });
9274
9430
  };
@@ -9441,7 +9597,7 @@ class Stage extends Component {
9441
9597
  }
9442
9598
  onAdd(...args) {
9443
9599
  const component = super.onAdd(...args);
9444
- if (component && component.name === "column") {
9600
+ if (component?.name === "column") {
9445
9601
  component.parent.autoColumnWidths();
9446
9602
  }
9447
9603
  }
@@ -9469,133 +9625,6 @@ let Stages$1 = class Stages extends ComponentData {
9469
9625
  }
9470
9626
  };
9471
9627
  const stages = new Stages$1();
9472
- const loaded = {
9473
- js: /* @__PURE__ */ new Set(),
9474
- css: /* @__PURE__ */ new Set()
9475
- };
9476
- const ajax = (fileUrl, callback, onError = noop) => {
9477
- return new Promise((resolve) => {
9478
- return fetch(fileUrl).then((data) => {
9479
- if (!data.ok) {
9480
- return resolve(onError(data));
9481
- }
9482
- resolve(callback ? callback(data) : data);
9483
- }).catch((err) => onError(err));
9484
- });
9485
- };
9486
- const onLoadStylesheet = (elem, cb) => {
9487
- elem.removeEventListener("load", onLoadStylesheet);
9488
- cb(elem.src);
9489
- };
9490
- const onLoadJavascript = (elem, cb) => {
9491
- elem.removeEventListener("load", onLoadJavascript);
9492
- cb(elem.src);
9493
- };
9494
- const insertScript = (src) => {
9495
- return new Promise((resolve, reject) => {
9496
- if (loaded.js.has(src)) {
9497
- return resolve(src);
9498
- }
9499
- loaded.js.add(src);
9500
- const script = dom.create({
9501
- tag: "script",
9502
- attrs: {
9503
- type: "text/javascript",
9504
- async: true,
9505
- src
9506
- },
9507
- action: {
9508
- load: () => onLoadJavascript(script, resolve),
9509
- error: () => reject(new Error(`${src} failed to load.`))
9510
- }
9511
- });
9512
- document.head.appendChild(script);
9513
- });
9514
- };
9515
- const insertStyle = (srcs) => {
9516
- srcs = Array.isArray(srcs) ? srcs : [srcs];
9517
- const promises = srcs.map(
9518
- (src) => new Promise((resolve, reject) => {
9519
- if (loaded.css.has(src)) {
9520
- return resolve(src);
9521
- }
9522
- loaded.css.add(src);
9523
- const styleLink = dom.create({
9524
- tag: "link",
9525
- attrs: {
9526
- rel: "stylesheet",
9527
- href: src
9528
- },
9529
- action: {
9530
- load: () => onLoadStylesheet(styleLink, resolve),
9531
- error: () => reject(new Error(`${(void 0).src} failed to load.`))
9532
- }
9533
- });
9534
- document.head.appendChild(styleLink);
9535
- })
9536
- );
9537
- return Promise.all(promises);
9538
- };
9539
- const insertScripts = (srcs) => {
9540
- srcs = Array.isArray(srcs) ? srcs : [srcs];
9541
- const promises = srcs.map((src) => insertScript(src));
9542
- return Promise.all(promises);
9543
- };
9544
- const insertStyles = (srcs) => {
9545
- srcs = Array.isArray(srcs) ? srcs : [srcs];
9546
- const promises = srcs.map((src) => insertStyle(src));
9547
- return Promise.all(promises);
9548
- };
9549
- const insertIcons = (iconSvgStr) => {
9550
- let iconSpriteWrap = document.getElementById(formeoSpriteId);
9551
- if (!iconSpriteWrap) {
9552
- iconSpriteWrap = dom.create({
9553
- id: formeoSpriteId,
9554
- children: iconSvgStr,
9555
- attrs: {
9556
- hidden: true,
9557
- style: "display: none;"
9558
- }
9559
- });
9560
- document.body.insertBefore(iconSpriteWrap, document.body.childNodes[0]);
9561
- }
9562
- return iconSpriteWrap;
9563
- };
9564
- const fetchIcons = async (iconSpriteUrl = SVG_SPRITE_URL) => {
9565
- const formeoSprite = document.getElementById(formeoSpriteId);
9566
- if (formeoSprite) {
9567
- return;
9568
- }
9569
- const parseResp = async (resp) => insertIcons(await resp.text());
9570
- return ajax(iconSpriteUrl, parseResp, () => ajax(FALLBACK_SVG_SPRITE_URL, parseResp));
9571
- };
9572
- const loadPolyfills = (polyfillConfig) => {
9573
- const polyfills = Array.isArray(polyfillConfig) ? POLYFILLS.filter(({ name: name2 }) => polyfillConfig.indexOf(name2) !== -1) : POLYFILLS;
9574
- return Promise.all(polyfills.map(({ src }) => insertScript(src)));
9575
- };
9576
- const LOADER_MAP = {
9577
- js: insertScripts,
9578
- css: insertStyles
9579
- };
9580
- const fetchDependencies = (dependencies) => {
9581
- const promises = Object.entries(dependencies).map(([type, src]) => {
9582
- return LOADER_MAP[type](src);
9583
- });
9584
- return Promise.all(promises);
9585
- };
9586
- const isCssLoaded = () => {
9587
- const formeoSprite = document.getElementById(formeoSpriteId);
9588
- const computedStyle = window.getComputedStyle(formeoSprite);
9589
- return computedStyle.visibility === "hidden";
9590
- };
9591
- const fetchFormeoStyle = async (cssUrl) => {
9592
- if (!isCssLoaded()) {
9593
- await insertStyle(cssUrl);
9594
- if (!isCssLoaded()) {
9595
- return await insertStyle(FALLBACK_CSS_URL);
9596
- }
9597
- }
9598
- };
9599
9628
  class Control {
9600
9629
  controlCache = /* @__PURE__ */ new Set();
9601
9630
  /**
@@ -9664,9 +9693,9 @@ class Control {
9664
9693
  * @return {String} the translated label
9665
9694
  */
9666
9695
  i18n(lookup, args) {
9667
- const locale = mi18n.locale;
9696
+ const locale2 = mi18n.locale;
9668
9697
  const controlTranslations = this.definition?.i18n;
9669
- const localeTranslations = controlTranslations?.[locale] || {};
9698
+ const localeTranslations = controlTranslations?.[locale2] || {};
9670
9699
  return (localeTranslations[lookup]?.() ?? localeTranslations[lookup]) || mi18n.get(lookup, args);
9671
9700
  }
9672
9701
  }
@@ -9917,12 +9946,12 @@ let Controls$1 = class Controls {
9917
9946
  // @todo finish the addGroup method
9918
9947
  addGroup: (group) => console.log(group)
9919
9948
  };
9920
- for (let i = groups.length - 1; i >= 0; i--) {
9921
- const storeID = `formeo-controls-${groups[i]}`;
9949
+ for (let i2 = groups.length - 1; i2 >= 0; i2--) {
9950
+ const storeID = `formeo-controls-${groups[i2]}`;
9922
9951
  if (!this.options.sortable) {
9923
9952
  window.localStorage.removeItem(storeID);
9924
9953
  }
9925
- Sortable.create(groups[i], {
9954
+ Sortable.create(groups[i2], {
9926
9955
  animation: 150,
9927
9956
  forceFallback: true,
9928
9957
  fallbackClass: "control-moving",
@@ -10394,12 +10423,18 @@ const defaults$1 = {
10394
10423
  },
10395
10424
  onAdd: () => {
10396
10425
  },
10397
- onChange: (...args) => defaults$1.onUpdate(...args),
10426
+ onChange: (evt) => events.opts?.debug && console.log(evt),
10398
10427
  onUpdate: (evt) => events.opts?.debug && console.log(evt),
10399
10428
  onUpdateStage: (evt) => events.opts?.debug && console.log(evt),
10400
10429
  onUpdateRow: (evt) => events.opts?.debug && console.log(evt),
10401
10430
  onUpdateColumn: (evt) => events.opts?.debug && console.log(evt),
10402
10431
  onUpdateField: (evt) => events.opts?.debug && console.log(evt),
10432
+ onAddRow: (evt) => events.opts?.debug && console.log(evt),
10433
+ onAddColumn: (evt) => events.opts?.debug && console.log(evt),
10434
+ onAddField: (evt) => events.opts?.debug && console.log(evt),
10435
+ onRemoveRow: (evt) => events.opts?.debug && console.log(evt),
10436
+ onRemoveColumn: (evt) => events.opts?.debug && console.log(evt),
10437
+ onRemoveField: (evt) => events.opts?.debug && console.log(evt),
10403
10438
  onRender: (evt) => events.opts?.debug && console.log(evt),
10404
10439
  onSave: (_evt) => {
10405
10440
  },
@@ -10415,6 +10450,13 @@ const defaultCustomEvent = ({ src, ...evtData }, type = EVENT_FORMEO_UPDATED) =>
10415
10450
  bubbles: events.opts?.debug || events.opts?.bubbles
10416
10451
  });
10417
10452
  evt.data = (src || document).dispatchEvent(evt);
10453
+ if (type === EVENT_FORMEO_UPDATED) {
10454
+ const changedEvt = new window.CustomEvent(EVENT_FORMEO_CHANGED, {
10455
+ detail: evtData,
10456
+ bubbles: events.opts?.debug || events.opts?.bubbles
10457
+ });
10458
+ (src || document).dispatchEvent(changedEvt);
10459
+ }
10418
10460
  return evt;
10419
10461
  };
10420
10462
  const events = {
@@ -10423,50 +10465,82 @@ const events = {
10423
10465
  return this;
10424
10466
  },
10425
10467
  formeoSaved: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_SAVED),
10426
- formeoUpdated: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_UPDATED),
10468
+ formeoUpdated: (evt, eventType) => defaultCustomEvent(evt, eventType || EVENT_FORMEO_UPDATED),
10427
10469
  formeoCleared: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_CLEARED),
10428
10470
  formeoOnRender: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_ON_RENDER),
10429
- formeoConditionUpdated: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_CONDITION_UPDATED)
10471
+ formeoConditionUpdated: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_CONDITION_UPDATED),
10472
+ formeoAddedRow: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_ADDED_ROW),
10473
+ formeoAddedColumn: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_ADDED_COLUMN),
10474
+ formeoAddedField: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_ADDED_FIELD),
10475
+ formeoRemovedRow: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_REMOVED_ROW),
10476
+ formeoRemovedColumn: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_REMOVED_COLUMN),
10477
+ formeoRemovedField: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_REMOVED_FIELD)
10430
10478
  };
10431
10479
  const formeoUpdatedThrottled = throttle$1(() => {
10432
- events.opts.onUpdate({
10480
+ const eventData = {
10433
10481
  timeStamp: window.performance.now(),
10434
10482
  type: EVENT_FORMEO_UPDATED,
10435
10483
  detail: components.formData
10436
- });
10484
+ };
10485
+ events.opts.onUpdate(eventData);
10486
+ if (events.opts.onChange !== events.opts.onUpdate) {
10487
+ events.opts.onChange(eventData);
10488
+ }
10437
10489
  }, ANIMATION_SPEED_FAST);
10438
10490
  document.addEventListener(EVENT_FORMEO_UPDATED, formeoUpdatedThrottled);
10439
10491
  document.addEventListener(EVENT_FORMEO_UPDATED_STAGE, (evt) => {
10440
10492
  const { timeStamp, type, detail } = evt;
10441
- events.opts.onUpdate({
10442
- timeStamp,
10443
- type,
10444
- detail
10445
- });
10493
+ const eventData = { timeStamp, type, detail };
10494
+ events.opts.onUpdate(eventData);
10495
+ events.opts.onUpdateStage(eventData);
10446
10496
  });
10447
10497
  document.addEventListener(EVENT_FORMEO_UPDATED_ROW, (evt) => {
10448
10498
  const { timeStamp, type, detail } = evt;
10449
- events.opts.onUpdate({
10450
- timeStamp,
10451
- type,
10452
- detail
10453
- });
10499
+ const eventData = { timeStamp, type, detail };
10500
+ events.opts.onUpdate(eventData);
10501
+ events.opts.onUpdateRow(eventData);
10454
10502
  });
10455
10503
  document.addEventListener(EVENT_FORMEO_UPDATED_COLUMN, (evt) => {
10456
10504
  const { timeStamp, type, detail } = evt;
10457
- events.opts.onUpdate({
10458
- timeStamp,
10459
- type,
10460
- detail
10461
- });
10505
+ const eventData = { timeStamp, type, detail };
10506
+ events.opts.onUpdate(eventData);
10507
+ events.opts.onUpdateColumn(eventData);
10462
10508
  });
10463
10509
  document.addEventListener(EVENT_FORMEO_UPDATED_FIELD, (evt) => {
10464
10510
  const { timeStamp, type, detail } = evt;
10465
- events.opts.onUpdate({
10466
- timeStamp,
10467
- type,
10468
- detail
10469
- });
10511
+ const eventData = { timeStamp, type, detail };
10512
+ events.opts.onUpdate(eventData);
10513
+ events.opts.onUpdateField(eventData);
10514
+ });
10515
+ document.addEventListener(EVENT_FORMEO_ADDED_ROW, (evt) => {
10516
+ const { timeStamp, type, detail } = evt;
10517
+ const eventData = { timeStamp, type, detail };
10518
+ events.opts.onAddRow(eventData);
10519
+ });
10520
+ document.addEventListener(EVENT_FORMEO_ADDED_COLUMN, (evt) => {
10521
+ const { timeStamp, type, detail } = evt;
10522
+ const eventData = { timeStamp, type, detail };
10523
+ events.opts.onAddColumn(eventData);
10524
+ });
10525
+ document.addEventListener(EVENT_FORMEO_ADDED_FIELD, (evt) => {
10526
+ const { timeStamp, type, detail } = evt;
10527
+ const eventData = { timeStamp, type, detail };
10528
+ events.opts.onAddField(eventData);
10529
+ });
10530
+ document.addEventListener(EVENT_FORMEO_REMOVED_ROW, (evt) => {
10531
+ const { timeStamp, type, detail } = evt;
10532
+ const eventData = { timeStamp, type, detail };
10533
+ events.opts.onRemoveRow(eventData);
10534
+ });
10535
+ document.addEventListener(EVENT_FORMEO_REMOVED_COLUMN, (evt) => {
10536
+ const { timeStamp, type, detail } = evt;
10537
+ const eventData = { timeStamp, type, detail };
10538
+ events.opts.onRemoveColumn(eventData);
10539
+ });
10540
+ document.addEventListener(EVENT_FORMEO_REMOVED_FIELD, (evt) => {
10541
+ const { timeStamp, type, detail } = evt;
10542
+ const eventData = { timeStamp, type, detail };
10543
+ events.opts.onRemoveField(eventData);
10470
10544
  });
10471
10545
  document.addEventListener(EVENT_FORMEO_ON_RENDER, (evt) => {
10472
10546
  const { timeStamp, type, detail } = evt;
@@ -10598,8 +10672,10 @@ const actions = {
10598
10672
  }
10599
10673
  }
10600
10674
  };
10601
- const enUS = void 0;
10602
- mi18n.addLanguage("en-US", enUS);
10675
+ const e = { "en-US": { "en-US": "English", dir: "ltr", "af-ZA": "Afrikaans (South Africa)", "ar-TN": "Arabic (Tunisia)", "cs-CZ": "Czech (Czechia)", "de-DE": "German (Germany)", "es-ES": "European Spanish", "fa-IR": "Persian (Iran)", "fi-FI": "Finnish (Finland)", "fr-FR": "French (France)", "hu-HU": "Hungarian (Hungary)", "it-IT": "Italian (Italy)", "ja-JP": "Japanese (Japan)", "nb-NO": "Norwegian Bokmål (Norway)", "pl-PL": "Polish (Poland)", "pt-BR": "Brazilian Portuguese", "pt-PT": "European Portuguese", "ro-RO": "Romanian (Romania)", "ru-RU": "Russian (Russia)", "th-TH": "Thai (Thailand)", "tr-TR": "Turkish (Türkiye)", "zh-CN": "Chinese (China)", "zh-HK": "Chinese (Hong Kong SAR China)", "action.add.attrs.attr": "What attribute would you like to add?", "action.add.attrs.value": "Default Value", addOption: "Add Option", allFieldsRemoved: "All fields were removed.", allowSelect: "Allow Select", and: "and", attribute: "Attribute", attributeNotPermitted: 'Attribute "{attribute}" is not permitted, please choose another.', attributes: "Attributes", "attrs.class": "Class", "attrs.className": "Class", "attrs.dir": "Direction", "attrs.id": "Id", "attrs.required": "Required", "attrs.style": "Style", "attrs.title": "Title", "attrs.type": "Type", "attrs.value": "Value", autocomplete: "Autocomplete", button: "Button", cannotBeEmpty: "This field cannot be empty", cannotClearFields: "There are no fields to clear", checkbox: "Checkbox", checkboxes: "Checkboxes", class: "Class", clear: "Clear", clearAllMessage: "Are you sure you want to clear all fields?", close: "Close", column: "Column", "condition.target.placeholder": "target", "condition.type.and": "And", "condition.type.if": "If", "condition.type.or": "Or", "condition.type.then": "Then", "condition.value.placeholder": "value", confirmClearAll: "Are you sure you want to remove all fields?", content: "Content", control: "Control", "controlGroups.nextGroup": "Next Group", "controlGroups.prevGroup": "Previous Group", "controls.filteringTerm": 'Filtering "{term}"', "controls.form.button": "Button", "controls.form.checkbox-group": "Checkbox Group", "controls.form.input.date": "Date", "controls.form.input.email": "Email", "controls.form.input.file": "File Upload", "controls.form.input.hidden": "Hidden Input", "controls.form.input.number": "Number", "controls.form.input.text": "Text Input", "controls.form.radio-group": "Radio Group", "controls.form.select": "Select", "controls.form.textarea": "TextArea", "controls.groups.form": "Form Fields", "controls.groups.html": "HTML Elements", "controls.groups.layout": "Layout", "controls.html.divider": "Divider", "controls.html.header": "Header", "controls.html.paragraph": "Paragraph", "controls.layout.column": "Column", "controls.layout.row": "Row", copy: "Copy To Clipboard", danger: "Danger", defineColumnLayout: "Define a column layout", defineColumnWidths: "Define column widths", description: "Help Text", descriptionField: "Description", "editing.row": "Editing Row", editorTitle: "Form Elements", field: "Field", "field.property.invalid": "not valid", "field.property.isChecked": "is checked", "field.property.isNotVisible": "is not visible", "field.property.isVisible": "is visible", "field.property.label": "label", "field.property.valid": "valid", "field.property.value": "value", fieldNonEditable: "This field cannot be edited.", fieldRemoveWarning: "Are you sure you want to remove this field?", fileUpload: "File Upload", formUpdated: "Form Updated", getStarted: "Drag a field from the right to get started.", group: "Group", grouped: "Grouped", hidden: "Hidden Input", hide: "Edit", htmlElements: "HTML Elements", if: "If", "if.condition.source.placeholder": "source", "if.condition.target.placeholder": "target / value", info: "Info", "input.date": "Date", "input.text": "Text", label: "Label", labelCount: "{label} {count}", labelEmpty: "Field Label cannot be empty", "lang.af": "Afrikaans", "lang.ar": "Arabic", "lang.cs": "Czech", "lang.de": "German", "lang.en": "English", "lang.es": "Spanish", "lang.fa": "Persian", "lang.fi": "Finnish", "lang.fr": "French", "lang.hu": "Hungarian", "lang.it": "Italian", "lang.ja": "Japanese", "lang.nb": "Norwegian Bokmål", "lang.pl": "Polish", "lang.pt": "Portuguese", "lang.ro": "Romanian", "lang.ru": "Russian", "lang.th": "Thai", "lang.tr": "Turkish", "lang.zh": "Chinese", layout: "Layout", limitRole: "Limit access to one or more of the following roles:", mandatory: "Mandatory", maxlength: "Max Length", "meta.group": "Group", "meta.icon": "Ico", "meta.label": "Label", minOptionMessage: "This field requires a minimum of 2 options", name: "Name", newOptionLabel: "New {type}", no: "No", number: "Number", off: "Off", on: "On", "operator.contains": "contains", "operator.equals": "equals", "operator.notContains": "not contains", "operator.notEquals": "not equal", "operator.notVisible": "not visible", "operator.visible": "visible", option: "Option", optional: "optional", optionEmpty: "Option value required", optionLabel: "Option {count}", options: "Options", or: "or", order: "Order", "panel.label.attrs": "Attributes", "panel.label.conditions": "Conditions", "panel.label.config": "Configuration", "panel.label.meta": "Meta", "panel.label.options": "Options", "panelEditButtons.attrs": "+ Attribute", "panelEditButtons.conditions": "+ Condition", "panelEditButtons.options": "+ Option", placeholder: "Placeholder", "placeholder.className": "space separated classes", "placeholder.email": "Enter you email", "placeholder.label": "Label", "placeholder.password": "Enter your password", "placeholder.placeholder": "Placeholder", "placeholder.text": "Enter some Text", "placeholder.textarea": "Enter a lot of text", "placeholder.value": "Value", preview: "Preview", primary: "Primary", remove: "Remove", removeMessage: "Remove Element", removeType: "Remove {type}", required: "Required", reset: "Reset", richText: "Rich Text Editor", roles: "Access", row: "Row", "row.makeInputGroup": "Make this row an input group.", "row.makeInputGroupDesc": "Input Groups enable users to add sets of inputs at a time.", "row.settings.fieldsetWrap": "Wrap row in a &lt;fieldset&gt; tag", "row.settings.fieldsetWrap.aria": "Wrap Row in Fieldset", save: "Save", secondary: "Secondary", select: "Select", selectColor: "Select Color", selectionsMessage: "Allow Multiple Selections", selectOptions: "Options", separator: "Separator", settings: "Settings", size: "Size", sizes: "Sizes", "sizes.lg": "Large", "sizes.m": "Default", "sizes.sm": "Small", "sizes.xs": "Extra Small", style: "Style", styles: "Styles", "styles.btn": "Button Style", "styles.btn.danger": "Danger", "styles.btn.default": "Default", "styles.btn.info": "Info", "styles.btn.primary": "Primary", "styles.btn.success": "Success", "styles.btn.warning": "Warning", subtype: "Type", success: "Success", text: "Text Field", then: "Then", "then.condition.target.placeholder": "target", toggle: "Toggle", ungrouped: "Un-Grouped", warning: "Warning", yes: "Yes" } }, i = e["en-US"];
10676
+ const locale = "en-US";
10677
+ mi18n.addLanguage(locale, i);
10678
+ mi18n.setCurrent(locale);
10603
10679
  const defaults = {
10604
10680
  get editor() {
10605
10681
  return {
@@ -10610,8 +10686,8 @@ const defaults = {
10610
10686
  sessionStorage: false,
10611
10687
  editorContainer: null,
10612
10688
  // element or selector to attach editor to
10613
- svgSprite: SVG_SPRITE_URL,
10614
- // change to null
10689
+ svgSprite: null,
10690
+ // null = use bundled sprite, or provide custom URL
10615
10691
  style: CSS_URL,
10616
10692
  // change to null
10617
10693
  iconFont: null,
@@ -10621,8 +10697,6 @@ const defaults = {
10621
10697
  events: {},
10622
10698
  actions: {},
10623
10699
  controls: {},
10624
- polyfills: isIE(),
10625
- // loads csspreloadrel
10626
10700
  i18n: {
10627
10701
  location: "https://draggable.github.io/formeo/assets/lang/"
10628
10702
  },
@@ -10631,6 +10705,7 @@ const defaults = {
10631
10705
  };
10632
10706
  }
10633
10707
  };
10708
+ new SmartTooltip();
10634
10709
  let FormeoEditor$1 = class FormeoEditor {
10635
10710
  /**
10636
10711
  * @param {Object} options formeo options
@@ -10651,7 +10726,6 @@ let FormeoEditor$1 = class FormeoEditor {
10651
10726
  this.dom = dom;
10652
10727
  events.init({ debug, ...events$1 });
10653
10728
  actions.init({ debug, sessionStorage: opts.sessionStorage, ...actions$1 });
10654
- this.tooltip = new SmartTooltip();
10655
10729
  if (document.readyState === "loading") {
10656
10730
  document.addEventListener("DOMContentLoaded", this.loadResources.bind(this));
10657
10731
  } else {
@@ -10665,6 +10739,9 @@ let FormeoEditor$1 = class FormeoEditor {
10665
10739
  this.userFormData = cleanFormData(data);
10666
10740
  this.load(this.userFormData, this.opts);
10667
10741
  }
10742
+ loadData(data = {}) {
10743
+ this.formData = data;
10744
+ }
10668
10745
  get json() {
10669
10746
  return this.Components.json;
10670
10747
  }
@@ -10684,17 +10761,15 @@ let FormeoEditor$1 = class FormeoEditor {
10684
10761
  async loadResources() {
10685
10762
  document.removeEventListener("DOMContentLoaded", this.loadResources);
10686
10763
  const promises = [];
10687
- if (this.opts.polyfills) {
10688
- loadPolyfills(this.opts.polyfills);
10689
- }
10690
- await fetchIcons(this.opts.svgSprite);
10691
- promises.push(fetchFormeoStyle(this.opts.style));
10692
- promises.push(mi18n.init({ ...this.opts.i18n, locale: window.sessionStorage?.getItem(SESSION_LOCALE_KEY) }));
10693
- const resolvedPromises = await Promise.all(promises);
10764
+ promises.push(
10765
+ fetchIcons(this.opts.svgSprite),
10766
+ fetchFormeoStyle(this.opts.style),
10767
+ mi18n.init({ ...this.opts.i18n, locale: globalThis.sessionStorage?.getItem(SESSION_LOCALE_KEY) })
10768
+ );
10769
+ await Promise.all(promises);
10694
10770
  if (this.opts.allowEdit) {
10695
10771
  this.init();
10696
10772
  }
10697
- return resolvedPromises;
10698
10773
  }
10699
10774
  /**
10700
10775
  * Formeo initializer
@@ -10754,7 +10829,7 @@ let FormeoEditor$1 = class FormeoEditor {
10754
10829
  dom.empty(this.editorContainer);
10755
10830
  this.editorContainer.appendChild(this.editor);
10756
10831
  }
10757
- events.formeoLoaded = new window.CustomEvent("formeoLoaded", {
10832
+ events.formeoLoaded = new globalThis.CustomEvent("formeoLoaded", {
10758
10833
  detail: {
10759
10834
  formeo: this
10760
10835
  }
@@ -11010,8 +11085,8 @@ let FormeoRenderer$1 = class FormeoRenderer {
11010
11085
  },
11011
11086
  children: "Add +",
11012
11087
  action: {
11013
- click: (e) => {
11014
- const fInputGroup = e.target.parentElement;
11088
+ click: (e2) => {
11089
+ const fInputGroup = e2.target.parentElement;
11015
11090
  const elem = dom.create(this.cloneComponentData(id));
11016
11091
  fInputGroup.insertBefore(elem, fInputGroup.lastChild);
11017
11092
  const removeButton = dom.create(createRemoveButton());
@@ -11244,15 +11319,15 @@ class ButtonControl extends Control {
11244
11319
  super(mergedConfig);
11245
11320
  }
11246
11321
  }
11247
- const generateOptionConfig = ({ type, isMultiple = false, count = 3 }) => Array.from({ length: count }, (_v, k) => k + 1).map((i) => {
11322
+ const generateOptionConfig = ({ type, isMultiple = false, count = 3 }) => Array.from({ length: count }, (_v, k) => k + 1).map((i2) => {
11248
11323
  const selectedKey = type === "checkbox" || isMultiple ? "checked" : "selected";
11249
11324
  return {
11250
11325
  label: mi18n.get("labelCount", {
11251
11326
  label: toTitleCase(type),
11252
- count: i
11327
+ count: i2
11253
11328
  }),
11254
- value: `${type}-${i}`,
11255
- [selectedKey]: !i
11329
+ value: `${type}-${i2}`,
11330
+ [selectedKey]: !i2
11256
11331
  };
11257
11332
  });
11258
11333
  class CheckboxGroupControl extends Control {