formeo 5.0.3 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 5.0.2
4
+ Version: 5.1.0
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -6064,7 +6064,7 @@ Author: Draggable https://draggable.io
6064
6064
  var name$1, version$2, type, main, module$1, unpkg, exports$1, files, homepage, repository, author, contributors, bugs, description, keywords, ignore, config, scripts, devDependencies, dependencies, release, commitlint, package_default;
6065
6065
  var init_package = __esmMin((() => {
6066
6066
  name$1 = "formeo";
6067
- version$2 = "5.0.2";
6067
+ version$2 = "5.1.0";
6068
6068
  type = "module";
6069
6069
  main = "dist/formeo.cjs.js";
6070
6070
  module$1 = "dist/formeo.es.js";
@@ -11984,7 +11984,7 @@ Author: Draggable https://draggable.io
11984
11984
  }));
11985
11985
  //#endregion
11986
11986
  //#region src/lib/js/common/loaders.js
11987
- var loaded, ajax, onLoadStylesheet, onLoadJavascript, insertScript, insertStyle, insertScripts, insertStyles, insertIcons, fetchIcons, LOADER_MAP, fetchDependencies, fetchFormeoStyle;
11987
+ var loaded, AJAX_TIMEOUT_MS, ajax, onLoadStylesheet, onLoadJavascript, insertScript, insertStyle, insertScripts, insertStyles, insertIcons, fetchIcons, LOADER_MAP, fetchDependencies, fetchFormeoStyle;
11988
11988
  var init_loaders = __esmMin((() => {
11989
11989
  init_constants();
11990
11990
  init_dom();
@@ -11994,12 +11994,14 @@ Author: Draggable https://draggable.io
11994
11994
  css: /* @__PURE__ */ new Set(),
11995
11995
  formeoSprite: null
11996
11996
  };
11997
- ajax = (fileUrl, callback, onError = noop) => {
11997
+ AJAX_TIMEOUT_MS = 1e4;
11998
+ ajax = (fileUrl, callback, onError = noop, timeoutMs = AJAX_TIMEOUT_MS) => {
11998
11999
  return new Promise((resolve) => {
11999
- return fetch(fileUrl).then((data) => {
12000
+ const signal = typeof AbortSignal !== "undefined" && AbortSignal.timeout ? AbortSignal.timeout(timeoutMs) : void 0;
12001
+ return fetch(fileUrl, signal ? { signal } : void 0).then((data) => {
12000
12002
  if (!data.ok) return resolve(onError(data));
12001
12003
  resolve(callback ? callback(data) : data);
12002
- }).catch((err) => onError(err));
12004
+ }).catch((err) => resolve(onError(err)));
12003
12005
  });
12004
12006
  };
12005
12007
  onLoadStylesheet = (elem, cb) => {
@@ -12782,6 +12784,9 @@ Author: Draggable https://draggable.io
12782
12784
  isDOMElement(variable) {
12783
12785
  return variable instanceof window.Element || variable instanceof window.HTMLElement || !!(variable && typeof variable === "object" && variable.nodeType === 1 && typeof variable.nodeName === "string");
12784
12786
  }
12787
+ resolveContainer(container) {
12788
+ return typeof container === "string" ? document.querySelector(container) : container;
12789
+ }
12785
12790
  };
12786
12791
  dom = new DOM();
12787
12792
  }));
@@ -16251,7 +16256,7 @@ Author: Draggable https://draggable.io
16251
16256
  };
16252
16257
  applyOptions = async (controlOptions = {}) => {
16253
16258
  const { container, elements, groupOrder, ...options } = merge(defaultOptions, controlOptions);
16254
- this.container = container;
16259
+ this.container = dom.resolveContainer(container);
16255
16260
  this.groupOrder = unique(groupOrder.concat([
16256
16261
  "common",
16257
16262
  "html",
@@ -17796,7 +17801,7 @@ Author: Draggable https://draggable.io
17796
17801
  config: {},
17797
17802
  events: {},
17798
17803
  actions: {},
17799
- controls: {},
17804
+ controls: { container: null },
17800
17805
  i18n: { location: "https://draggable.github.io/formeo/assets/lang/" },
17801
17806
  onLoad: () => {}
17802
17807
  };
@@ -17837,7 +17842,7 @@ Author: Draggable https://draggable.io
17837
17842
  */
17838
17843
  constructor({ formData, ...options }, userFormData) {
17839
17844
  const { actions: actions$1, events: events$1, debug, config, editorContainer, ...opts } = merge(defaults.editor, options);
17840
- if (editorContainer) this.editorContainer = typeof editorContainer === "string" ? document.querySelector(editorContainer) : editorContainer;
17845
+ if (editorContainer) this.editorContainer = dom.resolveContainer(editorContainer) || null;
17841
17846
  this.opts = opts;
17842
17847
  dom.setOptions = opts;
17843
17848
  components.config = config;
@@ -18034,7 +18039,11 @@ Author: Draggable https://draggable.io
18034
18039
  dom.dir = s.current.dir;
18035
18040
  }
18036
18041
  this.editor = dom.create(elemConfig);
18037
- (this.controls.container || this.editor).appendChild(this.controls.dom);
18042
+ const controlsContainer = this.controls.container || this.editor;
18043
+ if (controlsContainer) {
18044
+ if (controlsContainer !== this.editor) dom.empty(controlsContainer);
18045
+ controlsContainer.appendChild(this.controls.dom);
18046
+ }
18038
18047
  if (this.editorContainer) {
18039
18048
  dom.empty(this.editorContainer);
18040
18049
  this.editorContainer.appendChild(this.editor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formeo",
3
- "version": "5.0.3",
3
+ "version": "5.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/formeo.cjs.js",
6
6
  "module": "dist/formeo.es.js",