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.
@@ -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
 
@@ -53,8 +53,8 @@ Author: Draggable https://draggable.io
53
53
  this.config = { location: parsedLocation, ...restOptions };
54
54
  const { override, preloaded = {} } = this.config;
55
55
  const allLangs = Object.entries(this.langs).concat(Object.entries(override || preloaded));
56
- this.langs = allLangs.reduce((acc, [locale, lang]) => {
57
- acc[locale] = this.applyLanguage(locale, lang);
56
+ this.langs = allLangs.reduce((acc, [locale2, lang]) => {
57
+ acc[locale2] = this.applyLanguage(locale2, lang);
58
58
  return acc;
59
59
  }, {});
60
60
  this.locale = this.config.locale || this.config.langs[0];
@@ -73,9 +73,9 @@ Author: Draggable https://draggable.io
73
73
  * @param {String} locale
74
74
  * @param {String|Object} lang
75
75
  */
76
- addLanguage(locale, lang = {}) {
76
+ addLanguage(locale2, lang = {}) {
77
77
  lang = typeof lang === "string" ? I18N.processFile(lang) : lang;
78
- this.applyLanguage(locale, lang);
78
+ this.applyLanguage(locale2, lang);
79
79
  this.config.langs.push("locale");
80
80
  }
81
81
  /**
@@ -84,9 +84,9 @@ Author: Draggable https://draggable.io
84
84
  * @param {String} locale - locale to check for value
85
85
  * @return {String} language string or undefined
86
86
  */
87
- getValue(key, locale = this.locale) {
87
+ getValue(key, locale2 = this.locale) {
88
88
  var _a;
89
- const value = (_a = this.langs[locale]) == null ? void 0 : _a[key];
89
+ const value = (_a = this.langs[locale2]) == null ? void 0 : _a[key];
90
90
  return value || this.getFallbackValue(key);
91
91
  }
92
92
  /**
@@ -163,9 +163,9 @@ Author: Draggable https://draggable.io
163
163
  static fromFile(rawText) {
164
164
  const lines = rawText.split("\n");
165
165
  const lang = {};
166
- for (let matches2, i = 0; i < lines.length; i++) {
166
+ for (let matches2, i2 = 0; i2 < lines.length; i2++) {
167
167
  const regex = /^(.+?) *?= *?([^\n]+)/;
168
- matches2 = regex.exec(lines[i]);
168
+ matches2 = regex.exec(lines[i2]);
169
169
  if (matches2) {
170
170
  lang[matches2[1]] = matches2[2].replace(/(^\s+|\s+$)/g, "");
171
171
  }
@@ -178,22 +178,22 @@ Author: Draggable https://draggable.io
178
178
  * @param {Boolean} useCache
179
179
  * @return {Promise} resolves response
180
180
  */
181
- loadLang(locale, useCache = true) {
181
+ loadLang(locale2, useCache = true) {
182
182
  const _this = this;
183
183
  return new Promise(function(resolve, reject) {
184
- if (_this.loaded.indexOf(locale) !== -1 && useCache) {
185
- _this.applyLanguage(_this.langs[locale]);
186
- return resolve(_this.langs[locale]);
184
+ if (_this.loaded.indexOf(locale2) !== -1 && useCache) {
185
+ _this.applyLanguage(_this.langs[locale2]);
186
+ return resolve(_this.langs[locale2]);
187
187
  } else {
188
- const langFile = [_this.config.location, locale, _this.config.extension].join("");
188
+ const langFile = [_this.config.location, locale2, _this.config.extension].join("");
189
189
  return fetchData(langFile).then((lang) => {
190
190
  const processedFile = I18N.processFile(lang);
191
- _this.applyLanguage(locale, processedFile);
192
- _this.loaded.push(locale);
193
- return resolve(_this.langs[locale]);
191
+ _this.applyLanguage(locale2, processedFile);
192
+ _this.loaded.push(locale2);
193
+ return resolve(_this.langs[locale2]);
194
194
  }).catch((err) => {
195
195
  console.error(err);
196
- const lang = _this.applyLanguage(locale);
196
+ const lang = _this.applyLanguage(locale2);
197
197
  resolve(lang);
198
198
  });
199
199
  }
@@ -205,11 +205,11 @@ Author: Draggable https://draggable.io
205
205
  * @param {Object} lang
206
206
  * @return {Object} overriden language
207
207
  */
208
- applyLanguage(locale, lang = {}) {
209
- const override = this.config.override[locale] || {};
210
- const existingLang = this.langs[locale] || {};
211
- this.langs[locale] = { ...existingLang, ...lang, ...override };
212
- return this.langs[locale];
208
+ applyLanguage(locale2, lang = {}) {
209
+ const override = this.config.override[locale2] || {};
210
+ const existingLang = this.langs[locale2] || {};
211
+ this.langs[locale2] = { ...existingLang, ...lang, ...override };
212
+ return this.langs[locale2];
213
213
  }
214
214
  /**
215
215
  * return currently available languages
@@ -223,10 +223,10 @@ Author: Draggable https://draggable.io
223
223
  * @param {String} locale
224
224
  * @return {Promise} language
225
225
  */
226
- async setCurrent(locale = "en-US") {
227
- await this.loadLang(locale);
228
- this.locale = locale;
229
- this.current = this.langs[locale];
226
+ async setCurrent(locale2 = "en-US") {
227
+ await this.loadLang(locale2);
228
+ this.locale = locale2;
229
+ this.current = this.langs[locale2];
230
230
  return this.current;
231
231
  }
232
232
  }
@@ -259,9 +259,9 @@ Author: Draggable https://draggable.io
259
259
  __publicField(this, "tooltip");
260
260
  __publicField(this, "activeTriggerType", null);
261
261
  __publicField(this, "spacing", 12);
262
- __publicField(this, "handleClick", (e) => {
262
+ __publicField(this, "handleClick", (e2) => {
263
263
  const triggerName = this.triggerName;
264
- const trigger = e.target.closest(`[${triggerName}][${triggerName}-type="click"]`);
264
+ const trigger = e2.target.closest(`[${triggerName}][${triggerName}-type="click"]`);
265
265
  if (trigger) {
266
266
  if (this.isVisible()) {
267
267
  this.hide();
@@ -274,9 +274,9 @@ Author: Draggable https://draggable.io
274
274
  this.hide();
275
275
  }
276
276
  });
277
- __publicField(this, "handleMouseOver", (e) => {
277
+ __publicField(this, "handleMouseOver", (e2) => {
278
278
  const triggerName = this.triggerName;
279
- const trigger = e.target.closest(`[${triggerName}]`);
279
+ const trigger = e2.target.closest(`[${triggerName}]`);
280
280
  if (this.activeTriggerType !== "click" && (trigger == null ? void 0 : trigger.getAttribute(`${triggerName}-type`)) !== "click") {
281
281
  const content = trigger == null ? void 0 : trigger.getAttribute(`${triggerName}`);
282
282
  if (content) {
@@ -285,9 +285,9 @@ Author: Draggable https://draggable.io
285
285
  }
286
286
  }
287
287
  });
288
- __publicField(this, "handleMouseOut", (e) => {
288
+ __publicField(this, "handleMouseOut", (e2) => {
289
289
  const triggerName = this.triggerName;
290
- const trigger = e.target.closest(`[${triggerName}]`);
290
+ const trigger = e2.target.closest(`[${triggerName}]`);
291
291
  if (this.activeTriggerType !== "click" && (trigger == null ? void 0 : trigger.getAttribute(`${triggerName}-type`)) !== "click") {
292
292
  this.hide();
293
293
  }
@@ -435,7 +435,7 @@ Author: Draggable https://draggable.io
435
435
  window.SmartTooltip = SmartTooltip;
436
436
  }
437
437
  const name$1 = "formeo";
438
- const version$2 = "4.1.3";
438
+ const version$2 = "4.2.0";
439
439
  const pkg = {
440
440
  name: name$1,
441
441
  version: version$2
@@ -669,7 +669,7 @@ Author: Draggable https://draggable.io
669
669
  try {
670
670
  value[symToStringTag] = void 0;
671
671
  var unmasked = true;
672
- } catch (e) {
672
+ } catch (e2) {
673
673
  }
674
674
  var result = nativeObjectToString.call(value);
675
675
  if (unmasked) {
@@ -780,11 +780,11 @@ Author: Draggable https://draggable.io
780
780
  if (func != null) {
781
781
  try {
782
782
  return funcToString.call(func);
783
- } catch (e) {
783
+ } catch (e2) {
784
784
  }
785
785
  try {
786
786
  return func + "";
787
- } catch (e) {
787
+ } catch (e2) {
788
788
  }
789
789
  }
790
790
  return "";
@@ -1130,7 +1130,7 @@ Author: Draggable https://draggable.io
1130
1130
  var func = getNative(Object, "defineProperty");
1131
1131
  func({}, "", {});
1132
1132
  return func;
1133
- } catch (e) {
1133
+ } catch (e2) {
1134
1134
  }
1135
1135
  })();
1136
1136
  _defineProperty$1 = defineProperty;
@@ -1541,7 +1541,7 @@ Author: Draggable https://draggable.io
1541
1541
  return types;
1542
1542
  }
1543
1543
  return freeProcess && freeProcess.binding && freeProcess.binding("util");
1544
- } catch (e) {
1544
+ } catch (e2) {
1545
1545
  }
1546
1546
  })();
1547
1547
  module2.exports = nodeUtil;
@@ -2074,8 +2074,8 @@ Author: Draggable https://draggable.io
2074
2074
  }
2075
2075
  if (Array.isArray(obj)) {
2076
2076
  copy = [];
2077
- for (let i = 0, len = obj.length; i < len; i++) {
2078
- copy[i] = clone$1(obj[i]);
2077
+ for (let i2 = 0, len = obj.length; i2 < len; i2++) {
2078
+ copy[i2] = clone$1(obj[i2]);
2079
2079
  }
2080
2080
  return copy;
2081
2081
  }
@@ -2147,8 +2147,8 @@ Author: Draggable https://draggable.io
2147
2147
  if (typeof data === "string") {
2148
2148
  try {
2149
2149
  return JSON.parse(data);
2150
- } catch (e) {
2151
- console.error("Invalid JSON string provided:", e);
2150
+ } catch (e2) {
2151
+ console.error("Invalid JSON string provided:", e2);
2152
2152
  return /* @__PURE__ */ Object.create(null);
2153
2153
  }
2154
2154
  }
@@ -2170,20 +2170,17 @@ Author: Draggable https://draggable.io
2170
2170
  }
2171
2171
  return result;
2172
2172
  }
2173
+ let BUNDLED_SVG_SPRITE = null;
2174
+ try {
2175
+ BUNDLED_SVG_SPRITE = require("../../lib/icons/formeo-sprite.svg?raw");
2176
+ } catch (e2) {
2177
+ }
2173
2178
  const name = pkg.name;
2174
2179
  const version$1 = pkg.version;
2175
2180
  const PACKAGE_NAME = name;
2176
2181
  const formeoSpriteId = "formeo-sprite";
2177
- const POLYFILLS = [
2178
- { name: "cssPreload", src: "//cdnjs.cloudflare.com/ajax/libs/loadCSS/2.0.1/cssrelpreload.min.js" },
2179
- { name: "mutationObserver", src: "//cdn.jsdelivr.net/npm/mutationobserver-shim/dist/mutationobserver.min.js" },
2180
- { name: "fetch", src: "https://unpkg.com/unfetch/polyfill" }
2181
- ];
2182
- const relativeSpritePath = `../../lib/icons/${formeoSpriteId}.svg`;
2183
- const localSpriteUrl = false ? (void 0)(relativeSpritePath) : relativeSpritePath;
2184
- const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development" || false;
2185
- const SVG_SPRITE_URL = isDev ? localSpriteUrl : `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/${formeoSpriteId}.svg`;
2186
- const FALLBACK_SVG_SPRITE_URL = `https://draggable.github.io/formeo/assets/img/${formeoSpriteId}.svg`;
2182
+ const SVG_SPRITE_URL = null;
2183
+ const FALLBACK_SVG_SPRITE_URL = `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/${formeoSpriteId}.svg`;
2187
2184
  const CSS_URL = `https://cdn.jsdelivr.net/npm/formeo@${version$1}/dist/formeo.min.css`;
2188
2185
  const FALLBACK_CSS_URL = "https://draggable.github.io/formeo/assets/css/formeo.min.css";
2189
2186
  const PANEL_CLASSNAME = "f-panel";
@@ -2283,6 +2280,7 @@ Author: Draggable https://draggable.io
2283
2280
  const ANIMATION_SPEED_SLOW = Math.round(ANIMATION_SPEED_BASE * 2);
2284
2281
  const EVENT_FORMEO_SAVED = "formeoSaved";
2285
2282
  const EVENT_FORMEO_UPDATED = "formeoUpdated";
2283
+ const EVENT_FORMEO_CHANGED = "formeoChanged";
2286
2284
  const EVENT_FORMEO_UPDATED_STAGE = "formeoUpdatedStage";
2287
2285
  const EVENT_FORMEO_UPDATED_ROW = "formeoUpdatedRow";
2288
2286
  const EVENT_FORMEO_UPDATED_COLUMN = "formeoUpdatedColumn";
@@ -2290,6 +2288,12 @@ Author: Draggable https://draggable.io
2290
2288
  const EVENT_FORMEO_CLEARED = "formeoCleared";
2291
2289
  const EVENT_FORMEO_ON_RENDER = "formeoOnRender";
2292
2290
  const EVENT_FORMEO_CONDITION_UPDATED = "formeoConditionUpdated";
2291
+ const EVENT_FORMEO_ADDED_ROW = "formeoAddedRow";
2292
+ const EVENT_FORMEO_ADDED_COLUMN = "formeoAddedColumn";
2293
+ const EVENT_FORMEO_ADDED_FIELD = "formeoAddedField";
2294
+ const EVENT_FORMEO_REMOVED_ROW = "formeoRemovedRow";
2295
+ const EVENT_FORMEO_REMOVED_COLUMN = "formeoRemovedColumn";
2296
+ const EVENT_FORMEO_REMOVED_FIELD = "formeoRemovedField";
2293
2297
  const COMPARISON_OPERATORS = {
2294
2298
  equals: "==",
2295
2299
  notEquals: "!=",
@@ -3296,6 +3300,18 @@ Author: Draggable https://draggable.io
3296
3300
  evtData.previousValue = oldVal;
3297
3301
  }
3298
3302
  events.formeoUpdated(evtData);
3303
+ if (this.name) {
3304
+ const componentEventMap = {
3305
+ stage: EVENT_FORMEO_UPDATED_STAGE,
3306
+ row: EVENT_FORMEO_UPDATED_ROW,
3307
+ column: EVENT_FORMEO_UPDATED_COLUMN,
3308
+ field: EVENT_FORMEO_UPDATED_FIELD
3309
+ };
3310
+ const specificEvent = componentEventMap[this.name];
3311
+ if (specificEvent) {
3312
+ events.formeoUpdated(evtData, specificEvent);
3313
+ }
3314
+ }
3299
3315
  }
3300
3316
  return data;
3301
3317
  }
@@ -3365,6 +3381,23 @@ Author: Draggable https://draggable.io
3365
3381
  const component = this.Component({ ...data, id: elemId });
3366
3382
  this.data[elemId] = component;
3367
3383
  this.active = component;
3384
+ const componentEventMap = {
3385
+ row: EVENT_FORMEO_ADDED_ROW,
3386
+ column: EVENT_FORMEO_ADDED_COLUMN,
3387
+ field: EVENT_FORMEO_ADDED_FIELD
3388
+ };
3389
+ const addEvent = componentEventMap[this.name];
3390
+ if (addEvent) {
3391
+ events.formeoUpdated(
3392
+ {
3393
+ entity: component,
3394
+ componentId: elemId,
3395
+ componentType: this.name,
3396
+ data: component.data
3397
+ },
3398
+ addEvent
3399
+ );
3400
+ }
3368
3401
  return component;
3369
3402
  };
3370
3403
  /**
@@ -3430,9 +3463,9 @@ Author: Draggable https://draggable.io
3430
3463
  return keys;
3431
3464
  }
3432
3465
  function _objectSpread2(target) {
3433
- for (var i = 1; i < arguments.length; i++) {
3434
- var source = arguments[i] != null ? arguments[i] : {};
3435
- if (i % 2) {
3466
+ for (var i2 = 1; i2 < arguments.length; i2++) {
3467
+ var source = arguments[i2] != null ? arguments[i2] : {};
3468
+ if (i2 % 2) {
3436
3469
  ownKeys(Object(source), true).forEach(function(key) {
3437
3470
  _defineProperty(target, key, source[key]);
3438
3471
  });
@@ -3474,8 +3507,8 @@ Author: Draggable https://draggable.io
3474
3507
  }
3475
3508
  function _extends() {
3476
3509
  _extends = Object.assign || function(target) {
3477
- for (var i = 1; i < arguments.length; i++) {
3478
- var source = arguments[i];
3510
+ for (var i2 = 1; i2 < arguments.length; i2++) {
3511
+ var source = arguments[i2];
3479
3512
  for (var key in source) {
3480
3513
  if (Object.prototype.hasOwnProperty.call(source, key)) {
3481
3514
  target[key] = source[key];
@@ -3490,9 +3523,9 @@ Author: Draggable https://draggable.io
3490
3523
  if (source == null) return {};
3491
3524
  var target = {};
3492
3525
  var sourceKeys = Object.keys(source);
3493
- var key, i;
3494
- for (i = 0; i < sourceKeys.length; i++) {
3495
- key = sourceKeys[i];
3526
+ var key, i2;
3527
+ for (i2 = 0; i2 < sourceKeys.length; i2++) {
3528
+ key = sourceKeys[i2];
3496
3529
  if (excluded.indexOf(key) >= 0) continue;
3497
3530
  target[key] = source[key];
3498
3531
  }
@@ -3501,11 +3534,11 @@ Author: Draggable https://draggable.io
3501
3534
  function _objectWithoutProperties(source, excluded) {
3502
3535
  if (source == null) return {};
3503
3536
  var target = _objectWithoutPropertiesLoose(source, excluded);
3504
- var key, i;
3537
+ var key, i2;
3505
3538
  if (Object.getOwnPropertySymbols) {
3506
3539
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3507
- for (i = 0; i < sourceSymbolKeys.length; i++) {
3508
- key = sourceSymbolKeys[i];
3540
+ for (i2 = 0; i2 < sourceSymbolKeys.length; i2++) {
3541
+ key = sourceSymbolKeys[i2];
3509
3542
  if (excluded.indexOf(key) >= 0) continue;
3510
3543
  if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3511
3544
  target[key] = source[key];
@@ -3614,10 +3647,10 @@ Author: Draggable https://draggable.io
3614
3647
  }
3615
3648
  function find(ctx, tagName, iterator) {
3616
3649
  if (ctx) {
3617
- var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
3650
+ var list = ctx.getElementsByTagName(tagName), i2 = 0, n = list.length;
3618
3651
  if (iterator) {
3619
- for (; i < n; i++) {
3620
- iterator(list[i], i);
3652
+ for (; i2 < n; i2++) {
3653
+ iterator(list[i2], i2);
3621
3654
  }
3622
3655
  }
3623
3656
  return list;
@@ -3700,15 +3733,15 @@ Author: Draggable https://draggable.io
3700
3733
  return false;
3701
3734
  }
3702
3735
  function getChild(el, childNum, options, includeDragEl) {
3703
- var currentChild = 0, i = 0, children = el.children;
3704
- while (i < children.length) {
3705
- if (children[i].style.display !== "none" && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
3736
+ var currentChild = 0, i2 = 0, children = el.children;
3737
+ while (i2 < children.length) {
3738
+ if (children[i2].style.display !== "none" && children[i2] !== Sortable.ghost && (includeDragEl || children[i2] !== Sortable.dragged) && closest(children[i2], options.draggable, el, false)) {
3706
3739
  if (currentChild === childNum) {
3707
- return children[i];
3740
+ return children[i2];
3708
3741
  }
3709
3742
  currentChild++;
3710
3743
  }
3711
- i++;
3744
+ i2++;
3712
3745
  }
3713
3746
  return null;
3714
3747
  }
@@ -3743,10 +3776,10 @@ Author: Draggable https://draggable.io
3743
3776
  return [offsetLeft, offsetTop];
3744
3777
  }
3745
3778
  function indexOfObject(arr, obj) {
3746
- for (var i in arr) {
3747
- if (!arr.hasOwnProperty(i)) continue;
3779
+ for (var i2 in arr) {
3780
+ if (!arr.hasOwnProperty(i2)) continue;
3748
3781
  for (var key in obj) {
3749
- if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
3782
+ if (obj.hasOwnProperty(key) && obj[key] === arr[i2][key]) return Number(i2);
3750
3783
  }
3751
3784
  }
3752
3785
  return -1;
@@ -4199,9 +4232,9 @@ Author: Draggable https://draggable.io
4199
4232
  var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
4200
4233
  if (nearest) {
4201
4234
  var event = {};
4202
- for (var i in evt) {
4203
- if (evt.hasOwnProperty(i)) {
4204
- event[i] = evt[i];
4235
+ for (var i2 in evt) {
4236
+ if (evt.hasOwnProperty(i2)) {
4237
+ event[i2] = evt[i2];
4205
4238
  }
4206
4239
  }
4207
4240
  event.target = event.rootEl = nearest;
@@ -4450,8 +4483,8 @@ Author: Draggable https://draggable.io
4450
4483
  }
4451
4484
  }
4452
4485
  },
4453
- _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(e) {
4454
- var touch = e.touches ? e.touches[0] : e;
4486
+ _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(e2) {
4487
+ var touch = e2.touches ? e2.touches[0] : e2;
4455
4488
  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))) {
4456
4489
  this._disableDelayedDrag();
4457
4490
  }
@@ -5052,9 +5085,9 @@ Author: Draggable https://draggable.io
5052
5085
  * @returns {String[]}
5053
5086
  */
5054
5087
  toArray: function toArray() {
5055
- var order = [], el, children = this.el.children, i = 0, n = children.length, options = this.options;
5056
- for (; i < n; i++) {
5057
- el = children[i];
5088
+ var order = [], el, children = this.el.children, i2 = 0, n = children.length, options = this.options;
5089
+ for (; i2 < n; i2++) {
5090
+ el = children[i2];
5058
5091
  if (closest(el, options.draggable, this.el, false)) {
5059
5092
  order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
5060
5093
  }
@@ -5067,8 +5100,8 @@ Author: Draggable https://draggable.io
5067
5100
  */
5068
5101
  sort: function sort(order, useAnimation) {
5069
5102
  var items = {}, rootEl2 = this.el;
5070
- this.toArray().forEach(function(id, i) {
5071
- var el = rootEl2.children[i];
5103
+ this.toArray().forEach(function(id, i2) {
5104
+ var el = rootEl2.children[i2];
5072
5105
  if (closest(el, this.options.draggable, rootEl2, false)) {
5073
5106
  items[id] = el;
5074
5107
  }
@@ -5261,9 +5294,9 @@ Author: Draggable https://draggable.io
5261
5294
  }
5262
5295
  }
5263
5296
  function _generateId(el) {
5264
- var str = el.tagName + el.className + el.src + el.href + el.textContent, i = str.length, sum = 0;
5265
- while (i--) {
5266
- sum += str.charCodeAt(i);
5297
+ var str = el.tagName + el.className + el.src + el.href + el.textContent, i2 = str.length, sum = 0;
5298
+ while (i2--) {
5299
+ sum += str.charCodeAt(i2);
5267
5300
  }
5268
5301
  return sum.toString(36);
5269
5302
  }
@@ -5455,9 +5488,9 @@ Author: Draggable https://draggable.io
5455
5488
  var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
5456
5489
  var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
5457
5490
  if (!autoScrolls[layersOut]) {
5458
- for (var i = 0; i <= layersOut; i++) {
5459
- if (!autoScrolls[i]) {
5460
- autoScrolls[i] = {};
5491
+ for (var i2 = 0; i2 <= layersOut; i2++) {
5492
+ if (!autoScrolls[i2]) {
5493
+ autoScrolls[i2] = {};
5461
5494
  }
5462
5495
  }
5463
5496
  }
@@ -5657,13 +5690,13 @@ Author: Draggable https://draggable.io
5657
5690
  return unique(orderedElements);
5658
5691
  };
5659
5692
  const forEach = (arr, cb, scope) => {
5660
- for (let i = 0; i < arr.length; i++) {
5661
- cb.call(scope, arr[i], i);
5693
+ for (let i2 = 0; i2 < arr.length; i2++) {
5694
+ cb.call(scope, arr[i2], i2);
5662
5695
  }
5663
5696
  };
5664
5697
  const map = (arr, cb) => {
5665
5698
  const newArray = [];
5666
- forEach(arr, (elem, i) => newArray.push(cb(elem, i)));
5699
+ forEach(arr, (elem, i2) => newArray.push(cb(elem, i2)));
5667
5700
  return newArray;
5668
5701
  };
5669
5702
  const sanitizedAttributeNames = {};
@@ -5682,7 +5715,6 @@ Author: Draggable https://draggable.io
5682
5715
  const capitalize = (str) => str.replace(/\b\w/g, (m) => m.toUpperCase());
5683
5716
  const copyObj = (obj) => window.JSON.parse(window.JSON.stringify(obj));
5684
5717
  const subtract = (arr, from) => from.filter((a) => !~arr.indexOf(a));
5685
- const isIE = () => window.navigator.userAgent.indexOf("MSIE ") !== -1;
5686
5718
  const helpers = {
5687
5719
  capitalize,
5688
5720
  safeAttrName,
@@ -5694,8 +5726,119 @@ Author: Draggable https://draggable.io
5694
5726
  indexOfNode,
5695
5727
  isInt,
5696
5728
  get,
5697
- orderObjectsBy,
5698
- isIE
5729
+ orderObjectsBy
5730
+ };
5731
+ const loaded = {
5732
+ js: /* @__PURE__ */ new Set(),
5733
+ css: /* @__PURE__ */ new Set(),
5734
+ formeoSprite: null
5735
+ };
5736
+ const ajax = (fileUrl, callback, onError = noop) => {
5737
+ return new Promise((resolve) => {
5738
+ return fetch(fileUrl).then((data) => {
5739
+ if (!data.ok) {
5740
+ return resolve(onError(data));
5741
+ }
5742
+ resolve(callback ? callback(data) : data);
5743
+ }).catch((err) => onError(err));
5744
+ });
5745
+ };
5746
+ const onLoadStylesheet = (elem, cb) => {
5747
+ elem.removeEventListener("load", onLoadStylesheet);
5748
+ cb(elem.src);
5749
+ };
5750
+ const onLoadJavascript = (elem, cb) => {
5751
+ elem.removeEventListener("load", onLoadJavascript);
5752
+ cb(elem.src);
5753
+ };
5754
+ const insertScript = (src) => {
5755
+ return new Promise((resolve, reject) => {
5756
+ if (loaded.js.has(src)) {
5757
+ return resolve(src);
5758
+ }
5759
+ loaded.js.add(src);
5760
+ const script = dom.create({
5761
+ tag: "script",
5762
+ attrs: {
5763
+ type: "text/javascript",
5764
+ async: true,
5765
+ src
5766
+ },
5767
+ action: {
5768
+ load: () => onLoadJavascript(script, resolve),
5769
+ error: () => reject(new Error(`${src} failed to load.`))
5770
+ }
5771
+ });
5772
+ document.head.appendChild(script);
5773
+ });
5774
+ };
5775
+ const insertStyle = (srcs) => {
5776
+ srcs = Array.isArray(srcs) ? srcs : [srcs];
5777
+ const promises = srcs.map(
5778
+ (src) => new Promise((resolve, reject) => {
5779
+ if (loaded.css.has(src)) {
5780
+ return resolve(src);
5781
+ }
5782
+ loaded.css.add(src);
5783
+ const styleLink = dom.create({
5784
+ tag: "link",
5785
+ attrs: {
5786
+ rel: "stylesheet",
5787
+ href: src
5788
+ },
5789
+ action: {
5790
+ load: () => onLoadStylesheet(styleLink, resolve),
5791
+ error: () => reject(new Error(`${(void 0).src} failed to load.`))
5792
+ }
5793
+ });
5794
+ document.head.appendChild(styleLink);
5795
+ })
5796
+ );
5797
+ return Promise.all(promises);
5798
+ };
5799
+ const insertScripts = (srcs) => {
5800
+ srcs = Array.isArray(srcs) ? srcs : [srcs];
5801
+ const promises = srcs.map((src) => insertScript(src));
5802
+ return Promise.all(promises);
5803
+ };
5804
+ const insertStyles = (srcs) => {
5805
+ srcs = Array.isArray(srcs) ? srcs : [srcs];
5806
+ const promises = srcs.map((src) => insertStyle(src));
5807
+ return Promise.all(promises);
5808
+ };
5809
+ const insertIcons = (iconSvgStr) => {
5810
+ const parser = new DOMParser();
5811
+ const svgDoc = parser.parseFromString(iconSvgStr, "image/svg+xml");
5812
+ loaded.formeoSprite = svgDoc.documentElement;
5813
+ return loaded.formeoSprite;
5814
+ };
5815
+ const fetchIcons = async (iconSpriteUrl = SVG_SPRITE_URL) => {
5816
+ if (loaded.formeoSprite) {
5817
+ return loaded.formeoSprite;
5818
+ }
5819
+ if (!iconSpriteUrl) {
5820
+ return insertIcons(BUNDLED_SVG_SPRITE);
5821
+ }
5822
+ const parseResp = async (resp) => insertIcons(await resp.text());
5823
+ return ajax(iconSpriteUrl, parseResp, () => ajax(FALLBACK_SVG_SPRITE_URL, parseResp));
5824
+ };
5825
+ const LOADER_MAP = {
5826
+ js: insertScripts,
5827
+ css: insertStyles
5828
+ };
5829
+ const fetchDependencies = (dependencies) => {
5830
+ const promises = Object.entries(dependencies).map(([type, src]) => {
5831
+ return LOADER_MAP[type](src);
5832
+ });
5833
+ return Promise.all(promises);
5834
+ };
5835
+ const fetchFormeoStyle = async (cssUrl) => {
5836
+ if (!loaded.css.has(cssUrl)) {
5837
+ await insertStyle(cssUrl);
5838
+ if (!loaded.css.has(FALLBACK_CSS_URL)) {
5839
+ return await insertStyle(FALLBACK_CSS_URL);
5840
+ }
5841
+ }
5699
5842
  };
5700
5843
  const iconFontTemplates = {
5701
5844
  glyphicons: (icon) => `<span class="glyphicon glyphicon-${icon}" aria-hidden="true"></span>`,
@@ -5790,7 +5933,7 @@ Author: Draggable https://draggable.io
5790
5933
  processed.push("tag");
5791
5934
  let childType;
5792
5935
  const { tag } = elem;
5793
- let i;
5936
+ let i2;
5794
5937
  const wrap = {
5795
5938
  attrs: {},
5796
5939
  className: [helpers.get(elem, "config.inputWrap")],
@@ -5884,8 +6027,8 @@ Author: Draggable https://draggable.io
5884
6027
  processed.push("action");
5885
6028
  }
5886
6029
  const remaining = helpers.subtract(processed, Object.keys(elem));
5887
- for (i = remaining.length - 1; i >= 0; i--) {
5888
- element[remaining[i]] = elem[remaining[i]];
6030
+ for (i2 = remaining.length - 1; i2 >= 0; i2--) {
6031
+ element[remaining[i2]] = elem[remaining[i2]];
5889
6032
  }
5890
6033
  if (wrap.children.length) {
5891
6034
  element = this.create(wrap);
@@ -5925,25 +6068,26 @@ Author: Draggable https://draggable.io
5925
6068
  if (this.iconSymbols) {
5926
6069
  return this.iconSymbols;
5927
6070
  }
5928
- const iconSymbolNodes = document.querySelectorAll(`#${formeoSpriteId} svg symbol`);
5929
- const createSvgIconConfig = (symbolId) => ({
5930
- tag: "svg",
5931
- attrs: {
5932
- className: ["svg-icon", symbolId]
5933
- },
5934
- children: [
5935
- {
5936
- tag: "use",
5937
- attrs: {
5938
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
5939
- "xlink:href": `#${symbolId}`
5940
- }
5941
- }
5942
- ]
5943
- });
6071
+ const iconSymbolNodes = loaded.formeoSprite.querySelectorAll("svg symbol");
6072
+ const createSvgIconConfig = (symbol) => {
6073
+ const viewBox = symbol.getAttribute("viewBox") || "0 0 24 24";
6074
+ const children = Array.from(symbol.children).map((child) => {
6075
+ const clonedNode = child.cloneNode(true);
6076
+ return clonedNode.outerHTML;
6077
+ }).join("");
6078
+ return {
6079
+ tag: "svg",
6080
+ attrs: {
6081
+ className: ["svg-icon", symbol.id],
6082
+ viewBox,
6083
+ xmlns: "http://www.w3.org/2000/svg"
6084
+ },
6085
+ children
6086
+ };
6087
+ };
5944
6088
  this.iconSymbols = Array.from(iconSymbolNodes).reduce((acc, symbol) => {
5945
6089
  const name2 = symbol.id.replace(iconPrefix, "");
5946
- acc[name2] = createSvgIconConfig(symbol.id);
6090
+ acc[name2] = createSvgIconConfig(symbol);
5947
6091
  return acc;
5948
6092
  }, {});
5949
6093
  this.cachedIcons = {};
@@ -6051,19 +6195,19 @@ Author: Draggable https://draggable.io
6051
6195
  });
6052
6196
  return elementsContainingText;
6053
6197
  };
6054
- generateOption = ({ type = "option", label, value, i = 0, selected }) => {
6198
+ generateOption = ({ type = "option", label, value, i: i2 = 0, selected }) => {
6055
6199
  const isOption = type === "option";
6056
6200
  return {
6057
6201
  tag: isOption ? "option" : "input",
6058
6202
  attrs: {
6059
6203
  type,
6060
- value: value || `${type}-${i}`,
6061
- [type === "option" ? "selected" : "checked"]: selected || !i
6204
+ value: value || `${type}-${i2}`,
6205
+ [type === "option" ? "selected" : "checked"]: selected || !i2
6062
6206
  },
6063
6207
  config: {
6064
6208
  label: label || mi18n.get("labelCount", {
6065
6209
  label: mi18n.get("option"),
6066
- count: i
6210
+ count: i2
6067
6211
  })
6068
6212
  }
6069
6213
  };
@@ -6079,7 +6223,7 @@ Author: Draggable https://draggable.io
6079
6223
  const { action, attrs = {} } = elem;
6080
6224
  const fieldType = attrs.type || elem.tag;
6081
6225
  const id = attrs.id || elem.id;
6082
- const optionMap = (option, i) => {
6226
+ const optionMap = (option, i2) => {
6083
6227
  const { label, value, ...rest } = option;
6084
6228
  const defaultInput = () => {
6085
6229
  const input = {
@@ -6088,7 +6232,7 @@ Author: Draggable https://draggable.io
6088
6232
  name: id,
6089
6233
  type: fieldType,
6090
6234
  value: value || "",
6091
- id: `${id}-${i}`,
6235
+ id: `${id}-${i2}`,
6092
6236
  ...rest
6093
6237
  },
6094
6238
  action
@@ -6096,7 +6240,7 @@ Author: Draggable https://draggable.io
6096
6240
  const optionLabel = {
6097
6241
  tag: "label",
6098
6242
  attrs: {
6099
- for: `${id}-${i}`
6243
+ for: `${id}-${i2}`
6100
6244
  },
6101
6245
  children: label
6102
6246
  };
@@ -6629,7 +6773,7 @@ Author: Draggable https://draggable.io
6629
6773
  * @return {Object} DOM Element to be injected into the form.
6630
6774
  */
6631
6775
  build() {
6632
- const keyboardNav = (e) => {
6776
+ const keyboardNav = (e2) => {
6633
6777
  const list = this.list;
6634
6778
  const activeOption = this.getActiveOption();
6635
6779
  const keyCodeMap = /* @__PURE__ */ new Map([
@@ -6666,7 +6810,7 @@ Author: Draggable https://draggable.io
6666
6810
  this.hideList();
6667
6811
  }
6668
6812
  }
6669
- e.preventDefault();
6813
+ e2.preventDefault();
6670
6814
  }
6671
6815
  ],
6672
6816
  [
@@ -6677,7 +6821,7 @@ Author: Draggable https://draggable.io
6677
6821
  }
6678
6822
  ]
6679
6823
  ]);
6680
- let direction = keyCodeMap.get(e.keyCode);
6824
+ let direction = keyCodeMap.get(e2.keyCode);
6681
6825
  if (!direction) {
6682
6826
  direction = () => false;
6683
6827
  }
@@ -7570,7 +7714,7 @@ Author: Draggable https://draggable.io
7570
7714
  };
7571
7715
  const editPanelButtons = [];
7572
7716
  if (type === "conditions") {
7573
- if (!mi18n.current.clearAll) {
7717
+ if (mi18n.current && !mi18n.current.clearAll) {
7574
7718
  mi18n.put("clearAll", "Clear All");
7575
7719
  }
7576
7720
  const clearAllBtn = {
@@ -7866,7 +8010,7 @@ Author: Draggable https://draggable.io
7866
8010
  placement: "top"
7867
8011
  },
7868
8012
  action: {
7869
- click: (e) => this.nav.nextGroup(e)
8013
+ click: (e2) => this.nav.nextGroup(e2)
7870
8014
  },
7871
8015
  content: dom.icon("triangle-right")
7872
8016
  };
@@ -7882,7 +8026,7 @@ Author: Draggable https://draggable.io
7882
8026
  placement: "top"
7883
8027
  },
7884
8028
  action: {
7885
- click: (e) => this.nav.prevGroup(e)
8029
+ click: (e2) => this.nav.prevGroup(e2)
7886
8030
  },
7887
8031
  content: dom.icon("triangle-left")
7888
8032
  };
@@ -8064,6 +8208,7 @@ Author: Draggable https://draggable.io
8064
8208
  dispatchComponentEvent(eventName, eventData = {}) {
8065
8209
  const fullEventData = {
8066
8210
  component: this,
8211
+ target: this,
8067
8212
  type: eventName,
8068
8213
  timestamp: Date.now(),
8069
8214
  ...eventData
@@ -8149,6 +8294,22 @@ Author: Draggable https://draggable.io
8149
8294
  if (parent.name === "row") {
8150
8295
  parent.autoColumnWidths();
8151
8296
  }
8297
+ const componentEventMap = {
8298
+ row: EVENT_FORMEO_REMOVED_ROW,
8299
+ column: EVENT_FORMEO_REMOVED_COLUMN,
8300
+ field: EVENT_FORMEO_REMOVED_FIELD
8301
+ };
8302
+ const removeEvent = componentEventMap[this.name];
8303
+ if (removeEvent) {
8304
+ events.formeoUpdated(
8305
+ {
8306
+ componentId: this.id,
8307
+ componentType: this.name,
8308
+ parent
8309
+ },
8310
+ removeEvent
8311
+ );
8312
+ }
8152
8313
  return components[`${this.name}s`].delete(this.id);
8153
8314
  };
8154
8315
  /**
@@ -8202,12 +8363,7 @@ Author: Draggable https://draggable.io
8202
8363
  return dom.create({
8203
8364
  tag: "span",
8204
8365
  className: ["component-tag", `${this.name}-tag`],
8205
- children: [
8206
- (this.isColumn || this.isField) && dom.icon("component-corner", { className: "bottom-left" }),
8207
- dom.icon(`handle-${this.name}`),
8208
- toTitleCase(this.name),
8209
- (this.isColumn || this.isRow) && dom.icon("component-corner", { className: "bottom-right" })
8210
- ].filter(Boolean)
8366
+ children: [dom.icon(`handle-${this.name}`), toTitleCase(this.name)].filter(Boolean)
8211
8367
  });
8212
8368
  };
8213
8369
  /**
@@ -9271,8 +9427,8 @@ Author: Draggable https://draggable.io
9271
9427
  if (typeof widths === "string") {
9272
9428
  widths = widths.split(",");
9273
9429
  }
9274
- this.children.forEach((column, i) => {
9275
- column.setWidth(`${widths[i]}%`);
9430
+ this.children.forEach((column, i2) => {
9431
+ column.setWidth(`${widths[i2]}%`);
9276
9432
  column.refreshFieldPanels();
9277
9433
  });
9278
9434
  };
@@ -9445,7 +9601,7 @@ Author: Draggable https://draggable.io
9445
9601
  }
9446
9602
  onAdd(...args) {
9447
9603
  const component = super.onAdd(...args);
9448
- if (component && component.name === "column") {
9604
+ if (component?.name === "column") {
9449
9605
  component.parent.autoColumnWidths();
9450
9606
  }
9451
9607
  }
@@ -9473,133 +9629,6 @@ Author: Draggable https://draggable.io
9473
9629
  }
9474
9630
  };
9475
9631
  const stages = new Stages$1();
9476
- const loaded = {
9477
- js: /* @__PURE__ */ new Set(),
9478
- css: /* @__PURE__ */ new Set()
9479
- };
9480
- const ajax = (fileUrl, callback, onError = noop) => {
9481
- return new Promise((resolve) => {
9482
- return fetch(fileUrl).then((data) => {
9483
- if (!data.ok) {
9484
- return resolve(onError(data));
9485
- }
9486
- resolve(callback ? callback(data) : data);
9487
- }).catch((err) => onError(err));
9488
- });
9489
- };
9490
- const onLoadStylesheet = (elem, cb) => {
9491
- elem.removeEventListener("load", onLoadStylesheet);
9492
- cb(elem.src);
9493
- };
9494
- const onLoadJavascript = (elem, cb) => {
9495
- elem.removeEventListener("load", onLoadJavascript);
9496
- cb(elem.src);
9497
- };
9498
- const insertScript = (src) => {
9499
- return new Promise((resolve, reject) => {
9500
- if (loaded.js.has(src)) {
9501
- return resolve(src);
9502
- }
9503
- loaded.js.add(src);
9504
- const script = dom.create({
9505
- tag: "script",
9506
- attrs: {
9507
- type: "text/javascript",
9508
- async: true,
9509
- src
9510
- },
9511
- action: {
9512
- load: () => onLoadJavascript(script, resolve),
9513
- error: () => reject(new Error(`${src} failed to load.`))
9514
- }
9515
- });
9516
- document.head.appendChild(script);
9517
- });
9518
- };
9519
- const insertStyle = (srcs) => {
9520
- srcs = Array.isArray(srcs) ? srcs : [srcs];
9521
- const promises = srcs.map(
9522
- (src) => new Promise((resolve, reject) => {
9523
- if (loaded.css.has(src)) {
9524
- return resolve(src);
9525
- }
9526
- loaded.css.add(src);
9527
- const styleLink = dom.create({
9528
- tag: "link",
9529
- attrs: {
9530
- rel: "stylesheet",
9531
- href: src
9532
- },
9533
- action: {
9534
- load: () => onLoadStylesheet(styleLink, resolve),
9535
- error: () => reject(new Error(`${(void 0).src} failed to load.`))
9536
- }
9537
- });
9538
- document.head.appendChild(styleLink);
9539
- })
9540
- );
9541
- return Promise.all(promises);
9542
- };
9543
- const insertScripts = (srcs) => {
9544
- srcs = Array.isArray(srcs) ? srcs : [srcs];
9545
- const promises = srcs.map((src) => insertScript(src));
9546
- return Promise.all(promises);
9547
- };
9548
- const insertStyles = (srcs) => {
9549
- srcs = Array.isArray(srcs) ? srcs : [srcs];
9550
- const promises = srcs.map((src) => insertStyle(src));
9551
- return Promise.all(promises);
9552
- };
9553
- const insertIcons = (iconSvgStr) => {
9554
- let iconSpriteWrap = document.getElementById(formeoSpriteId);
9555
- if (!iconSpriteWrap) {
9556
- iconSpriteWrap = dom.create({
9557
- id: formeoSpriteId,
9558
- children: iconSvgStr,
9559
- attrs: {
9560
- hidden: true,
9561
- style: "display: none;"
9562
- }
9563
- });
9564
- document.body.insertBefore(iconSpriteWrap, document.body.childNodes[0]);
9565
- }
9566
- return iconSpriteWrap;
9567
- };
9568
- const fetchIcons = async (iconSpriteUrl = SVG_SPRITE_URL) => {
9569
- const formeoSprite = document.getElementById(formeoSpriteId);
9570
- if (formeoSprite) {
9571
- return;
9572
- }
9573
- const parseResp = async (resp) => insertIcons(await resp.text());
9574
- return ajax(iconSpriteUrl, parseResp, () => ajax(FALLBACK_SVG_SPRITE_URL, parseResp));
9575
- };
9576
- const loadPolyfills = (polyfillConfig) => {
9577
- const polyfills = Array.isArray(polyfillConfig) ? POLYFILLS.filter(({ name: name2 }) => polyfillConfig.indexOf(name2) !== -1) : POLYFILLS;
9578
- return Promise.all(polyfills.map(({ src }) => insertScript(src)));
9579
- };
9580
- const LOADER_MAP = {
9581
- js: insertScripts,
9582
- css: insertStyles
9583
- };
9584
- const fetchDependencies = (dependencies) => {
9585
- const promises = Object.entries(dependencies).map(([type, src]) => {
9586
- return LOADER_MAP[type](src);
9587
- });
9588
- return Promise.all(promises);
9589
- };
9590
- const isCssLoaded = () => {
9591
- const formeoSprite = document.getElementById(formeoSpriteId);
9592
- const computedStyle = window.getComputedStyle(formeoSprite);
9593
- return computedStyle.visibility === "hidden";
9594
- };
9595
- const fetchFormeoStyle = async (cssUrl) => {
9596
- if (!isCssLoaded()) {
9597
- await insertStyle(cssUrl);
9598
- if (!isCssLoaded()) {
9599
- return await insertStyle(FALLBACK_CSS_URL);
9600
- }
9601
- }
9602
- };
9603
9632
  class Control {
9604
9633
  controlCache = /* @__PURE__ */ new Set();
9605
9634
  /**
@@ -9668,9 +9697,9 @@ Author: Draggable https://draggable.io
9668
9697
  * @return {String} the translated label
9669
9698
  */
9670
9699
  i18n(lookup, args) {
9671
- const locale = mi18n.locale;
9700
+ const locale2 = mi18n.locale;
9672
9701
  const controlTranslations = this.definition?.i18n;
9673
- const localeTranslations = controlTranslations?.[locale] || {};
9702
+ const localeTranslations = controlTranslations?.[locale2] || {};
9674
9703
  return (localeTranslations[lookup]?.() ?? localeTranslations[lookup]) || mi18n.get(lookup, args);
9675
9704
  }
9676
9705
  }
@@ -9921,12 +9950,12 @@ Author: Draggable https://draggable.io
9921
9950
  // @todo finish the addGroup method
9922
9951
  addGroup: (group) => console.log(group)
9923
9952
  };
9924
- for (let i = groups.length - 1; i >= 0; i--) {
9925
- const storeID = `formeo-controls-${groups[i]}`;
9953
+ for (let i2 = groups.length - 1; i2 >= 0; i2--) {
9954
+ const storeID = `formeo-controls-${groups[i2]}`;
9926
9955
  if (!this.options.sortable) {
9927
9956
  window.localStorage.removeItem(storeID);
9928
9957
  }
9929
- Sortable.create(groups[i], {
9958
+ Sortable.create(groups[i2], {
9930
9959
  animation: 150,
9931
9960
  forceFallback: true,
9932
9961
  fallbackClass: "control-moving",
@@ -10398,12 +10427,18 @@ Author: Draggable https://draggable.io
10398
10427
  },
10399
10428
  onAdd: () => {
10400
10429
  },
10401
- onChange: (...args) => defaults$1.onUpdate(...args),
10430
+ onChange: (evt) => events.opts?.debug && console.log(evt),
10402
10431
  onUpdate: (evt) => events.opts?.debug && console.log(evt),
10403
10432
  onUpdateStage: (evt) => events.opts?.debug && console.log(evt),
10404
10433
  onUpdateRow: (evt) => events.opts?.debug && console.log(evt),
10405
10434
  onUpdateColumn: (evt) => events.opts?.debug && console.log(evt),
10406
10435
  onUpdateField: (evt) => events.opts?.debug && console.log(evt),
10436
+ onAddRow: (evt) => events.opts?.debug && console.log(evt),
10437
+ onAddColumn: (evt) => events.opts?.debug && console.log(evt),
10438
+ onAddField: (evt) => events.opts?.debug && console.log(evt),
10439
+ onRemoveRow: (evt) => events.opts?.debug && console.log(evt),
10440
+ onRemoveColumn: (evt) => events.opts?.debug && console.log(evt),
10441
+ onRemoveField: (evt) => events.opts?.debug && console.log(evt),
10407
10442
  onRender: (evt) => events.opts?.debug && console.log(evt),
10408
10443
  onSave: (_evt) => {
10409
10444
  },
@@ -10419,6 +10454,13 @@ Author: Draggable https://draggable.io
10419
10454
  bubbles: events.opts?.debug || events.opts?.bubbles
10420
10455
  });
10421
10456
  evt.data = (src || document).dispatchEvent(evt);
10457
+ if (type === EVENT_FORMEO_UPDATED) {
10458
+ const changedEvt = new window.CustomEvent(EVENT_FORMEO_CHANGED, {
10459
+ detail: evtData,
10460
+ bubbles: events.opts?.debug || events.opts?.bubbles
10461
+ });
10462
+ (src || document).dispatchEvent(changedEvt);
10463
+ }
10422
10464
  return evt;
10423
10465
  };
10424
10466
  const events = {
@@ -10427,50 +10469,82 @@ Author: Draggable https://draggable.io
10427
10469
  return this;
10428
10470
  },
10429
10471
  formeoSaved: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_SAVED),
10430
- formeoUpdated: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_UPDATED),
10472
+ formeoUpdated: (evt, eventType) => defaultCustomEvent(evt, eventType || EVENT_FORMEO_UPDATED),
10431
10473
  formeoCleared: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_CLEARED),
10432
10474
  formeoOnRender: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_ON_RENDER),
10433
- formeoConditionUpdated: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_CONDITION_UPDATED)
10475
+ formeoConditionUpdated: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_CONDITION_UPDATED),
10476
+ formeoAddedRow: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_ADDED_ROW),
10477
+ formeoAddedColumn: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_ADDED_COLUMN),
10478
+ formeoAddedField: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_ADDED_FIELD),
10479
+ formeoRemovedRow: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_REMOVED_ROW),
10480
+ formeoRemovedColumn: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_REMOVED_COLUMN),
10481
+ formeoRemovedField: (evt) => defaultCustomEvent(evt, EVENT_FORMEO_REMOVED_FIELD)
10434
10482
  };
10435
10483
  const formeoUpdatedThrottled = throttle$1(() => {
10436
- events.opts.onUpdate({
10484
+ const eventData = {
10437
10485
  timeStamp: window.performance.now(),
10438
10486
  type: EVENT_FORMEO_UPDATED,
10439
10487
  detail: components.formData
10440
- });
10488
+ };
10489
+ events.opts.onUpdate(eventData);
10490
+ if (events.opts.onChange !== events.opts.onUpdate) {
10491
+ events.opts.onChange(eventData);
10492
+ }
10441
10493
  }, ANIMATION_SPEED_FAST);
10442
10494
  document.addEventListener(EVENT_FORMEO_UPDATED, formeoUpdatedThrottled);
10443
10495
  document.addEventListener(EVENT_FORMEO_UPDATED_STAGE, (evt) => {
10444
10496
  const { timeStamp, type, detail } = evt;
10445
- events.opts.onUpdate({
10446
- timeStamp,
10447
- type,
10448
- detail
10449
- });
10497
+ const eventData = { timeStamp, type, detail };
10498
+ events.opts.onUpdate(eventData);
10499
+ events.opts.onUpdateStage(eventData);
10450
10500
  });
10451
10501
  document.addEventListener(EVENT_FORMEO_UPDATED_ROW, (evt) => {
10452
10502
  const { timeStamp, type, detail } = evt;
10453
- events.opts.onUpdate({
10454
- timeStamp,
10455
- type,
10456
- detail
10457
- });
10503
+ const eventData = { timeStamp, type, detail };
10504
+ events.opts.onUpdate(eventData);
10505
+ events.opts.onUpdateRow(eventData);
10458
10506
  });
10459
10507
  document.addEventListener(EVENT_FORMEO_UPDATED_COLUMN, (evt) => {
10460
10508
  const { timeStamp, type, detail } = evt;
10461
- events.opts.onUpdate({
10462
- timeStamp,
10463
- type,
10464
- detail
10465
- });
10509
+ const eventData = { timeStamp, type, detail };
10510
+ events.opts.onUpdate(eventData);
10511
+ events.opts.onUpdateColumn(eventData);
10466
10512
  });
10467
10513
  document.addEventListener(EVENT_FORMEO_UPDATED_FIELD, (evt) => {
10468
10514
  const { timeStamp, type, detail } = evt;
10469
- events.opts.onUpdate({
10470
- timeStamp,
10471
- type,
10472
- detail
10473
- });
10515
+ const eventData = { timeStamp, type, detail };
10516
+ events.opts.onUpdate(eventData);
10517
+ events.opts.onUpdateField(eventData);
10518
+ });
10519
+ document.addEventListener(EVENT_FORMEO_ADDED_ROW, (evt) => {
10520
+ const { timeStamp, type, detail } = evt;
10521
+ const eventData = { timeStamp, type, detail };
10522
+ events.opts.onAddRow(eventData);
10523
+ });
10524
+ document.addEventListener(EVENT_FORMEO_ADDED_COLUMN, (evt) => {
10525
+ const { timeStamp, type, detail } = evt;
10526
+ const eventData = { timeStamp, type, detail };
10527
+ events.opts.onAddColumn(eventData);
10528
+ });
10529
+ document.addEventListener(EVENT_FORMEO_ADDED_FIELD, (evt) => {
10530
+ const { timeStamp, type, detail } = evt;
10531
+ const eventData = { timeStamp, type, detail };
10532
+ events.opts.onAddField(eventData);
10533
+ });
10534
+ document.addEventListener(EVENT_FORMEO_REMOVED_ROW, (evt) => {
10535
+ const { timeStamp, type, detail } = evt;
10536
+ const eventData = { timeStamp, type, detail };
10537
+ events.opts.onRemoveRow(eventData);
10538
+ });
10539
+ document.addEventListener(EVENT_FORMEO_REMOVED_COLUMN, (evt) => {
10540
+ const { timeStamp, type, detail } = evt;
10541
+ const eventData = { timeStamp, type, detail };
10542
+ events.opts.onRemoveColumn(eventData);
10543
+ });
10544
+ document.addEventListener(EVENT_FORMEO_REMOVED_FIELD, (evt) => {
10545
+ const { timeStamp, type, detail } = evt;
10546
+ const eventData = { timeStamp, type, detail };
10547
+ events.opts.onRemoveField(eventData);
10474
10548
  });
10475
10549
  document.addEventListener(EVENT_FORMEO_ON_RENDER, (evt) => {
10476
10550
  const { timeStamp, type, detail } = evt;
@@ -10602,8 +10676,10 @@ Author: Draggable https://draggable.io
10602
10676
  }
10603
10677
  }
10604
10678
  };
10605
- const enUS = void 0;
10606
- mi18n.addLanguage("en-US", enUS);
10679
+ 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"];
10680
+ const locale = "en-US";
10681
+ mi18n.addLanguage(locale, i);
10682
+ mi18n.setCurrent(locale);
10607
10683
  const defaults = {
10608
10684
  get editor() {
10609
10685
  return {
@@ -10614,8 +10690,8 @@ Author: Draggable https://draggable.io
10614
10690
  sessionStorage: false,
10615
10691
  editorContainer: null,
10616
10692
  // element or selector to attach editor to
10617
- svgSprite: SVG_SPRITE_URL,
10618
- // change to null
10693
+ svgSprite: null,
10694
+ // null = use bundled sprite, or provide custom URL
10619
10695
  style: CSS_URL,
10620
10696
  // change to null
10621
10697
  iconFont: null,
@@ -10625,8 +10701,6 @@ Author: Draggable https://draggable.io
10625
10701
  events: {},
10626
10702
  actions: {},
10627
10703
  controls: {},
10628
- polyfills: isIE(),
10629
- // loads csspreloadrel
10630
10704
  i18n: {
10631
10705
  location: "https://draggable.github.io/formeo/assets/lang/"
10632
10706
  },
@@ -10635,6 +10709,7 @@ Author: Draggable https://draggable.io
10635
10709
  };
10636
10710
  }
10637
10711
  };
10712
+ new SmartTooltip();
10638
10713
  let FormeoEditor$1 = class FormeoEditor {
10639
10714
  /**
10640
10715
  * @param {Object} options formeo options
@@ -10655,7 +10730,6 @@ Author: Draggable https://draggable.io
10655
10730
  this.dom = dom;
10656
10731
  events.init({ debug, ...events$1 });
10657
10732
  actions.init({ debug, sessionStorage: opts.sessionStorage, ...actions$1 });
10658
- this.tooltip = new SmartTooltip();
10659
10733
  if (document.readyState === "loading") {
10660
10734
  document.addEventListener("DOMContentLoaded", this.loadResources.bind(this));
10661
10735
  } else {
@@ -10669,6 +10743,9 @@ Author: Draggable https://draggable.io
10669
10743
  this.userFormData = cleanFormData(data);
10670
10744
  this.load(this.userFormData, this.opts);
10671
10745
  }
10746
+ loadData(data = {}) {
10747
+ this.formData = data;
10748
+ }
10672
10749
  get json() {
10673
10750
  return this.Components.json;
10674
10751
  }
@@ -10688,17 +10765,15 @@ Author: Draggable https://draggable.io
10688
10765
  async loadResources() {
10689
10766
  document.removeEventListener("DOMContentLoaded", this.loadResources);
10690
10767
  const promises = [];
10691
- if (this.opts.polyfills) {
10692
- loadPolyfills(this.opts.polyfills);
10693
- }
10694
- await fetchIcons(this.opts.svgSprite);
10695
- promises.push(fetchFormeoStyle(this.opts.style));
10696
- promises.push(mi18n.init({ ...this.opts.i18n, locale: window.sessionStorage?.getItem(SESSION_LOCALE_KEY) }));
10697
- const resolvedPromises = await Promise.all(promises);
10768
+ promises.push(
10769
+ fetchIcons(this.opts.svgSprite),
10770
+ fetchFormeoStyle(this.opts.style),
10771
+ mi18n.init({ ...this.opts.i18n, locale: globalThis.sessionStorage?.getItem(SESSION_LOCALE_KEY) })
10772
+ );
10773
+ await Promise.all(promises);
10698
10774
  if (this.opts.allowEdit) {
10699
10775
  this.init();
10700
10776
  }
10701
- return resolvedPromises;
10702
10777
  }
10703
10778
  /**
10704
10779
  * Formeo initializer
@@ -10758,7 +10833,7 @@ Author: Draggable https://draggable.io
10758
10833
  dom.empty(this.editorContainer);
10759
10834
  this.editorContainer.appendChild(this.editor);
10760
10835
  }
10761
- events.formeoLoaded = new window.CustomEvent("formeoLoaded", {
10836
+ events.formeoLoaded = new globalThis.CustomEvent("formeoLoaded", {
10762
10837
  detail: {
10763
10838
  formeo: this
10764
10839
  }
@@ -11014,8 +11089,8 @@ Author: Draggable https://draggable.io
11014
11089
  },
11015
11090
  children: "Add +",
11016
11091
  action: {
11017
- click: (e) => {
11018
- const fInputGroup = e.target.parentElement;
11092
+ click: (e2) => {
11093
+ const fInputGroup = e2.target.parentElement;
11019
11094
  const elem = dom.create(this.cloneComponentData(id));
11020
11095
  fInputGroup.insertBefore(elem, fInputGroup.lastChild);
11021
11096
  const removeButton = dom.create(createRemoveButton());
@@ -11248,15 +11323,15 @@ Author: Draggable https://draggable.io
11248
11323
  super(mergedConfig);
11249
11324
  }
11250
11325
  }
11251
- const generateOptionConfig = ({ type, isMultiple = false, count = 3 }) => Array.from({ length: count }, (_v, k) => k + 1).map((i) => {
11326
+ const generateOptionConfig = ({ type, isMultiple = false, count = 3 }) => Array.from({ length: count }, (_v, k) => k + 1).map((i2) => {
11252
11327
  const selectedKey = type === "checkbox" || isMultiple ? "checked" : "selected";
11253
11328
  return {
11254
11329
  label: mi18n.get("labelCount", {
11255
11330
  label: toTitleCase(type),
11256
- count: i
11331
+ count: i2
11257
11332
  }),
11258
- value: `${type}-${i}`,
11259
- [selectedKey]: !i
11333
+ value: `${type}-${i2}`,
11334
+ [selectedKey]: !i2
11260
11335
  };
11261
11336
  });
11262
11337
  class CheckboxGroupControl extends Control {