formeo 4.2.3 → 4.2.5

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.2.2
4
+ Version: 4.2.4
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -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.2.2";
438
+ const version$2 = "4.2.4";
439
439
  const pkg = {
440
440
  name: name$1,
441
441
  version: version$2
@@ -5845,6 +5845,12 @@ Author: Draggable https://draggable.io
5845
5845
  fontello: (icon) => `<i class="${iconPrefix}${icon}">${icon}</i>`
5846
5846
  };
5847
5847
  const inputTags = /* @__PURE__ */ new Set(["input", "textarea", "select"]);
5848
+ const stripOn = (str) => str.replace(/^on([A-Z])/, (_, l) => l.toLowerCase());
5849
+ const useCaptureEvts = /* @__PURE__ */ new Set(["focus", "blur"]);
5850
+ const defaultActionHandler = (event) => {
5851
+ const eventName = stripOn(event);
5852
+ return (node, cb) => node.addEventListener(eventName, cb, useCaptureEvts.has(eventName));
5853
+ };
5848
5854
  const getName = (elem = {}) => {
5849
5855
  let name2 = elem?.attrs?.name || elem?.name;
5850
5856
  if (name2) {
@@ -6050,12 +6056,10 @@ Author: Draggable https://draggable.io
6050
6056
  onRender: dom.onRender,
6051
6057
  render: dom.onRender
6052
6058
  };
6053
- const useCaptureEvts = ["focus", "blur"];
6054
- const defaultHandler = (event) => (node2, cb) => node2.addEventListener(event, cb, useCaptureEvts.includes(event));
6055
6059
  return Object.entries(actions2).map(([event, cb]) => {
6056
6060
  const cbs = Array.isArray(cb) ? cb : [cb];
6057
6061
  return cbs.map((cb2) => {
6058
- const action = handlers[event] || defaultHandler(event);
6062
+ const action = handlers[event] || defaultActionHandler(event);
6059
6063
  return action(node, cb2);
6060
6064
  });
6061
6065
  });
@@ -9149,6 +9153,7 @@ Author: Draggable https://draggable.io
9149
9153
  Sortable.create(childWrap, {
9150
9154
  animation: 150,
9151
9155
  fallbackClass: "field-moving",
9156
+ forceFallback: true,
9152
9157
  group: {
9153
9158
  name: "column",
9154
9159
  pull: true,
@@ -9254,6 +9259,7 @@ Author: Draggable https://draggable.io
9254
9259
  Sortable.create(children, {
9255
9260
  animation: 150,
9256
9261
  fallbackClass: "column-moving",
9262
+ forceFallback: true,
9257
9263
  group: {
9258
9264
  name: "row",
9259
9265
  pull: true,
@@ -9949,30 +9955,37 @@ Author: Draggable https://draggable.io
9949
9955
  for (let i2 = groups.length - 1; i2 >= 0; i2--) {
9950
9956
  const storeID = `formeo-controls-${groups[i2]}`;
9951
9957
  if (!this.options.sortable) {
9952
- window.localStorage.removeItem(storeID);
9958
+ globalThis.localStorage.removeItem(storeID);
9953
9959
  }
9954
9960
  Sortable.create(groups[i2], {
9955
9961
  animation: 150,
9956
- forceFallback: true,
9957
9962
  fallbackClass: "control-moving",
9958
9963
  fallbackOnBody: true,
9964
+ forceFallback: true,
9965
+ fallbackTolerance: 5,
9959
9966
  group: {
9960
9967
  name: "controls",
9961
9968
  pull: "clone",
9962
- put: false
9969
+ put: false,
9970
+ revertClone: true
9963
9971
  },
9964
- onStart: async ({ item }) => {
9965
- const { controlData } = this.get(item.id);
9972
+ onClone: ({ clone: clone2, item }) => {
9973
+ clone2.id = item.id;
9966
9974
  if (this.options.ghostPreview) {
9967
- const { default: Field2 } = await Promise.resolve().then(() => field);
9968
- item.innerHTML = "";
9969
- item.appendChild(new Field2(controlData).preview);
9975
+ const { controlData } = this.get(item.id);
9976
+ Promise.resolve().then(() => field).then(({ default: Field2 }) => {
9977
+ clone2.innerHTML = "";
9978
+ clone2.appendChild(new Field2(controlData).preview);
9979
+ });
9970
9980
  }
9971
9981
  },
9972
- onEnd: ({ from, item, clone: clone2 }) => {
9973
- if (from.contains(clone2)) {
9974
- from.replaceChild(item, clone2);
9975
- }
9982
+ onStart: () => {
9983
+ this.originalDocumentOverflow = document.documentElement.style.overflow;
9984
+ document.documentElement.style.overflow = "hidden";
9985
+ },
9986
+ onEnd: () => {
9987
+ document.documentElement.style.overflow = this.originalDocumentOverflow;
9988
+ this.originalDocumentOverflow = null;
9976
9989
  },
9977
9990
  sort: this.options.sortable,
9978
9991
  store: {
@@ -9982,7 +9995,7 @@ Author: Draggable https://draggable.io
9982
9995
  * @return {Array}
9983
9996
  */
9984
9997
  get: () => {
9985
- const order = window.localStorage.getItem(storeID);
9998
+ const order = globalThis.localStorage.getItem(storeID);
9986
9999
  return order ? order.split("|") : [];
9987
10000
  },
9988
10001
  /**
@@ -9991,7 +10004,7 @@ Author: Draggable https://draggable.io
9991
10004
  */
9992
10005
  set: (sortable) => {
9993
10006
  const order = sortable.toArray();
9994
- window.localStorage.setItem(storeID, order.join("|"));
10007
+ globalThis.localStorage.setItem(storeID, order.join("|"));
9995
10008
  }
9996
10009
  }
9997
10010
  });
@@ -10849,7 +10862,7 @@ Author: Draggable https://draggable.io
10849
10862
  };
10850
10863
  const baseId = (id) => {
10851
10864
  const match2 = id.match(UUID_REGEXP);
10852
- return match2?.[0] || id``;
10865
+ return match2?.[0] || id;
10853
10866
  };
10854
10867
  const isVisible = (elem) => {
10855
10868
  if (!elem) return false;
@@ -10934,12 +10947,13 @@ Author: Draggable https://draggable.io
10934
10947
  };
10935
10948
  let FormeoRenderer$1 = class FormeoRenderer {
10936
10949
  constructor(opts, formDataArg) {
10937
- const { renderContainer, elements, formData } = processOptions(opts);
10938
- this.container = renderContainer;
10950
+ const { renderContainer: container, elements, formData, config } = processOptions(opts);
10951
+ this.container = container;
10939
10952
  this.form = cleanFormData(formDataArg || formData);
10940
- this.dom = dom;
10941
- this.components = /* @__PURE__ */ Object.create(null);
10942
10953
  this.elements = elements;
10954
+ this.config = config;
10955
+ this.components = /* @__PURE__ */ Object.create(null);
10956
+ this.dom = dom;
10943
10957
  }
10944
10958
  get formData() {
10945
10959
  return this.form;
@@ -10947,10 +10961,30 @@ Author: Draggable https://draggable.io
10947
10961
  set formData(data) {
10948
10962
  this.form = cleanFormData(data);
10949
10963
  }
10964
+ /**
10965
+ * Gets the user data from the rendered form as a plain object.
10966
+ * Converts FormData to an object, handling multiple values for the same key
10967
+ * by converting them into arrays.
10968
+ *
10969
+ * @returns {Object.<string, string|string[]>} An object containing form field names as keys
10970
+ * and their values. Fields with multiple values are stored as arrays.
10971
+ *
10972
+ * @example
10973
+ * // Form with single values
10974
+ * { username: 'john', email: 'john@example.com' }
10975
+ *
10976
+ * @example
10977
+ * // Form with multiple values for same key
10978
+ * { username: 'john', hobbies: ['reading', 'gaming'] }
10979
+ */
10950
10980
  get userData() {
10951
- const userData = new FormData(this.renderedForm);
10981
+ const form = this.container.querySelector(".formeo-render") || this.renderedForm;
10982
+ if (!form) {
10983
+ return {};
10984
+ }
10985
+ const formEntries = new FormData(form);
10952
10986
  const formDataObj = {};
10953
- for (const [key, value] of userData.entries()) {
10987
+ for (const [key, value] of formEntries.entries()) {
10954
10988
  if (formDataObj[key]) {
10955
10989
  if (Array.isArray(formDataObj[key])) {
10956
10990
  formDataObj[key].push(value);
@@ -10963,6 +10997,27 @@ Author: Draggable https://draggable.io
10963
10997
  }
10964
10998
  return formDataObj;
10965
10999
  }
11000
+ /**
11001
+ * Gets the user form data as an array of field objects.
11002
+ * Combines user input values with component metadata to create structured field data.
11003
+ *
11004
+ * @returns {Array<{key: string, value: any, label: string}>} An array of field data objects, where each object contains:
11005
+ * - key: The field identifier
11006
+ * - value: The user's input value for the field
11007
+ * - label: The field's label from component configuration (empty string if not found)
11008
+ */
11009
+ get userFormData() {
11010
+ const userFormData = [];
11011
+ for (const [key, value] of Object.entries(this.userData)) {
11012
+ const fieldData = {
11013
+ key,
11014
+ value,
11015
+ label: this.components[baseId(key)]?.config?.label || ""
11016
+ };
11017
+ userFormData.push(fieldData);
11018
+ }
11019
+ return userFormData;
11020
+ }
10966
11021
  set userData(data = {}) {
10967
11022
  const form = this.container.querySelector("form");
10968
11023
  for (const key of Object.keys(data)) {
@@ -10986,6 +11041,7 @@ Author: Draggable https://draggable.io
10986
11041
  * @param {Object} formData
10987
11042
  */
10988
11043
  render(formData = this.form) {
11044
+ this.form = cleanFormData(formData);
10989
11045
  const renderedForm = this.getRenderedForm(formData);
10990
11046
  const existingRenderedForm = this.container.querySelector(".formeo-render");
10991
11047
  if (existingRenderedForm) {
@@ -10998,6 +11054,7 @@ Author: Draggable https://draggable.io
10998
11054
  this.form = cleanFormData(formData);
10999
11055
  const renderCount = document.getElementsByClassName("formeo-render").length;
11000
11056
  const config = {
11057
+ ...this.config,
11001
11058
  tag: "form",
11002
11059
  id: this.form.id,
11003
11060
  className: `formeo-render formeo formeo-rendered-${renderCount}`,
@@ -11023,11 +11080,9 @@ Author: Draggable https://draggable.io
11023
11080
  */
11024
11081
  processColumn = ({ id, ...columnData }) => ({
11025
11082
  ...columnData,
11026
- ...{
11027
- id: this.prefixId(id),
11028
- children: this.processFields(columnData.children),
11029
- style: `width: ${columnData.config.width || "100%"}`
11030
- }
11083
+ id: this.prefixId(id),
11084
+ children: this.processFields(columnData.children),
11085
+ style: `width: ${columnData.config.width || "100%"}`
11031
11086
  });
11032
11087
  processRows = (stageId) => this.orderChildren("rows", this.form.stages[stageId].children).reduce((acc, row) => {
11033
11088
  if (row) {
@@ -11070,11 +11125,16 @@ Author: Draggable https://draggable.io
11070
11125
  };
11071
11126
  };
11072
11127
  cloneComponentData = (componentId) => {
11073
- const { children = [], id, ...rest } = this.components[componentId];
11128
+ const { children = [], id, attrs = {}, ...rest } = this.components[componentId];
11129
+ const updatedAttrs = { ...attrs, "data-clone-of": id };
11130
+ if (rest.tag === "input") {
11131
+ updatedAttrs.name = getName(this.components[componentId]);
11132
+ }
11074
11133
  return {
11075
11134
  ...rest,
11076
- id: uuid(id),
11077
- children: children?.length && children.map(({ id: id2 }) => this.cloneComponentData(baseId(id2)))
11135
+ id: RENDER_PREFIX + uuid(id),
11136
+ children: children?.length && children.map(({ id: id2 }) => this.cloneComponentData(baseId(id2))),
11137
+ attrs: updatedAttrs
11078
11138
  };
11079
11139
  };
11080
11140
  addButton = (id) => ({
@@ -11222,12 +11282,12 @@ Author: Draggable https://draggable.io
11222
11282
  return components2;
11223
11283
  };
11224
11284
  };
11285
+ const listenTypeMap = [
11286
+ ["input", (c) => ["textarea", "text"].includes(c.type)],
11287
+ ["change", (c) => ["select"].includes(c.tagName.toLowerCase()) || ["checkbox", "radio"].includes(c.type)]
11288
+ ];
11225
11289
  const LISTEN_TYPE_MAP = (component) => {
11226
- const typesMap = [
11227
- ["input", (c) => ["textarea", "text"].includes(c.type)],
11228
- ["change", (c) => ["select"].includes(c.tagName.toLowerCase()) || ["checkbox", "radio"].includes(c.type)]
11229
- ];
11230
- const [listenerEvent] = typesMap.find((typeMap) => typeMap[1](component)) || [false];
11290
+ const [listenerEvent] = listenTypeMap.find((typeMap) => typeMap[1](component)) || [false];
11231
11291
  return listenerEvent;
11232
11292
  };
11233
11293
  if (window !== void 0) {
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 4.2.2
4
+ Version: 4.2.4
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 4.2.2
4
+ Version: 4.2.4
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 4.2.2
4
+ Version: 4.2.4
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 4.2.2
4
+ Version: 4.2.4
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 4.2.2
4
+ Version: 4.2.4
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -1 +1 @@
1
- <!doctype html><html lang="en" xml:lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="chrome=1"><meta name="viewport" content="user-scalable=no,width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1"><meta name="description" content="Vanilla Javascript form building module"><meta name="theme-color" content="#232323"><title>Formeo | Drag &amp; Drop Form Creation</title><script type="module" crossorigin src="/formeo/assets/js/demo.min.js"></script><link rel="stylesheet" crossorigin href="/formeo/assets/css/demo.min.css"></head><body><div class="site-wrap"><header id="demo-header"><div class="header-inner"><img id="formeo-logo" src="/formeo/assets/img/formeo-logo.svg" alt="Formeo Logo" width="100"><nav aria-label="Framework navigation"><ul><li><label for="framework-select">Framework:</label> <select name="framework-select" id="framework-select" class="form-control"><option value="vanilla">Vanilla JavaScript</option><option value="angular">Angular</option><option value="react">React</option></select></li><li><label for="locale">Language</label> <select name="locale" id="locale" class="form-control"><option value="af-ZA" dir="ltr">Afrikaans (Suid-Afrika)</option><option value="ar-TN" dir="rtl">العربية (تونس)</option><option value="cs-CZ" dir="ltr">čeština (Česko)</option><option value="de-DE" dir="ltr">Deutsch (Deutschland)</option><option value="en-US" dir="ltr">English</option><option value="es-ES" dir="ltr">español de España</option><option value="fa-IR" dir="rtl">فارسی (ایران)</option><option value="fi-FI" dir="ltr">suomi (Suomi)</option><option value="fr-FR" dir="ltr">français (France)</option><option value="he-IL" dir="rtl">עברית (ישראל)</option><option value="hi-IN" dir="ltr">हिन्दी (भारत)</option><option value="hu-HU" dir="ltr">magyar (Magyarország)</option><option value="it-IT" dir="ltr">italiano (Italia)</option><option value="ja-JP" dir="ltr">日本語 (日本)</option><option value="nb-NO" dir="ltr">norsk bokmål (Norge)</option><option value="pl-PL" dir="ltr">polski (Polska)</option><option value="pt-BR" dir="ltr">português (Brasil)</option><option value="pt-PT" dir="ltr">português europeu</option><option value="ro-RO" dir="ltr">română (România)</option><option value="ru-RU" dir="ltr">русский (Россия)</option><option value="th-TH" dir="ltr">ไทย (ไทย)</option><option value="tr-TR" dir="ltr">Türkçe (Türkiye)</option><option value="zh-CN" dir="ltr">中文(中国)</option><option value="zh-HK" dir="ltr">中文(中國香港特別行政區)</option></select></li><li><label for="control-filter">Control Filter:</label> <input id="control-filter" placeholder="ex. text" class="form-control"></li><li style="float:right">v4.2.2</li></ul></nav></div></header><section id="main_content" class="inner"><div id="framework-container"></div></section><div class="container render-btn-wrap" id="editor-action-buttons"></div><div id="formData-popover" popover><div class="popover-header"><h3>Test formData</h3><div><button type="button" id="format-json">Format</button> <button type="button" id="collapse-json">Collapse</button> <button type="button" id="copy-json">Copy to Clipboard</button></div></div><pre id="formData-editor"></pre><div class="formData-actions"><button popovertarget="formData-popover" popovertargetaction="hide" type="button">Cancel</button> <button id="submit-formData" type="button">Submit</button></div></div><footer id="demo-footer"><nav aria-label="Footer navigation"><ul><li><a href="https://github.com/Draggable/formeo" target="_blank" title="View project on GitHub"><img src="/formeo/assets/img/github.png" width="77" alt="GitHub"></a></li></ul></nav></footer></div></body></html>
1
+ <!doctype html><html lang="en" xml:lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="chrome=1"><meta name="viewport" content="user-scalable=no,width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1"><meta name="description" content="Vanilla Javascript form building module"><meta name="theme-color" content="#232323"><title>Formeo | Drag &amp; Drop Form Creation</title><script type="module" crossorigin src="/formeo/assets/js/demo.min.js"></script><link rel="stylesheet" crossorigin href="/formeo/assets/css/demo.min.css"></head><body><div class="site-wrap"><header id="demo-header"><div class="header-inner"><img id="formeo-logo" src="/formeo/assets/img/formeo-logo.svg" alt="Formeo Logo" width="100"><nav aria-label="Framework navigation"><ul><li><label for="framework-select">Framework:</label> <select name="framework-select" id="framework-select" class="form-control"><option value="vanilla">Vanilla JavaScript</option><option value="angular">Angular</option><option value="react">React</option></select></li><li><label for="locale">Language</label> <select name="locale" id="locale" class="form-control"><option value="af-ZA" dir="ltr">Afrikaans (Suid-Afrika)</option><option value="ar-TN" dir="rtl">العربية (تونس)</option><option value="cs-CZ" dir="ltr">čeština (Česko)</option><option value="de-DE" dir="ltr">Deutsch (Deutschland)</option><option value="en-US" dir="ltr">English</option><option value="es-ES" dir="ltr">español de España</option><option value="fa-IR" dir="rtl">فارسی (ایران)</option><option value="fi-FI" dir="ltr">suomi (Suomi)</option><option value="fr-FR" dir="ltr">français (France)</option><option value="he-IL" dir="rtl">עברית (ישראל)</option><option value="hi-IN" dir="ltr">हिन्दी (भारत)</option><option value="hu-HU" dir="ltr">magyar (Magyarország)</option><option value="it-IT" dir="ltr">italiano (Italia)</option><option value="ja-JP" dir="ltr">日本語 (日本)</option><option value="nb-NO" dir="ltr">norsk bokmål (Norge)</option><option value="pl-PL" dir="ltr">polski (Polska)</option><option value="pt-BR" dir="ltr">português (Brasil)</option><option value="pt-PT" dir="ltr">português europeu</option><option value="ro-RO" dir="ltr">română (România)</option><option value="ru-RU" dir="ltr">русский (Россия)</option><option value="th-TH" dir="ltr">ไทย (ไทย)</option><option value="tr-TR" dir="ltr">Türkçe (Türkiye)</option><option value="zh-CN" dir="ltr">中文(中国)</option><option value="zh-HK" dir="ltr">中文(中國香港特別行政區)</option></select></li><li><label for="control-filter">Control Filter:</label> <input id="control-filter" placeholder="ex. text" class="form-control"></li><li style="float:right">v4.2.4</li></ul></nav></div></header><section id="main_content" class="inner"><div id="framework-container"></div></section><div class="container render-btn-wrap" id="editor-action-buttons"></div><div id="formData-popover" popover><div class="popover-header"><h3>Test formData</h3><div><button type="button" id="format-json">Format</button> <button type="button" id="collapse-json">Collapse</button> <button type="button" id="copy-json">Copy to Clipboard</button></div></div><pre id="formData-editor"></pre><div class="formData-actions"><button popovertarget="formData-popover" popovertargetaction="hide" type="button">Cancel</button> <button id="submit-formData" type="button">Submit</button></div></div><footer id="demo-footer"><nav aria-label="Footer navigation"><ul><li><a href="https://github.com/Draggable/formeo" target="_blank" title="View project on GitHub"><img src="/formeo/assets/img/github.png" width="77" alt="GitHub"></a></li></ul></nav></footer></div></body></html>
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 4.2.2
4
+ Version: 4.2.4
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -433,7 +433,7 @@ if (window !== void 0) {
433
433
  window.SmartTooltip = SmartTooltip;
434
434
  }
435
435
  const name$1 = "formeo";
436
- const version$2 = "4.2.2";
436
+ const version$2 = "4.2.4";
437
437
  const pkg = {
438
438
  name: name$1,
439
439
  version: version$2
@@ -5843,6 +5843,12 @@ const iconFontTemplates = {
5843
5843
  fontello: (icon) => `<i class="${iconPrefix}${icon}">${icon}</i>`
5844
5844
  };
5845
5845
  const inputTags = /* @__PURE__ */ new Set(["input", "textarea", "select"]);
5846
+ const stripOn = (str) => str.replace(/^on([A-Z])/, (_, l) => l.toLowerCase());
5847
+ const useCaptureEvts = /* @__PURE__ */ new Set(["focus", "blur"]);
5848
+ const defaultActionHandler = (event) => {
5849
+ const eventName = stripOn(event);
5850
+ return (node, cb) => node.addEventListener(eventName, cb, useCaptureEvts.has(eventName));
5851
+ };
5846
5852
  const getName = (elem = {}) => {
5847
5853
  let name2 = elem?.attrs?.name || elem?.name;
5848
5854
  if (name2) {
@@ -6048,12 +6054,10 @@ class DOM {
6048
6054
  onRender: dom.onRender,
6049
6055
  render: dom.onRender
6050
6056
  };
6051
- const useCaptureEvts = ["focus", "blur"];
6052
- const defaultHandler = (event) => (node2, cb) => node2.addEventListener(event, cb, useCaptureEvts.includes(event));
6053
6057
  return Object.entries(actions2).map(([event, cb]) => {
6054
6058
  const cbs = Array.isArray(cb) ? cb : [cb];
6055
6059
  return cbs.map((cb2) => {
6056
- const action = handlers[event] || defaultHandler(event);
6060
+ const action = handlers[event] || defaultActionHandler(event);
6057
6061
  return action(node, cb2);
6058
6062
  });
6059
6063
  });
@@ -9147,6 +9151,7 @@ class Column extends Component {
9147
9151
  Sortable.create(childWrap, {
9148
9152
  animation: 150,
9149
9153
  fallbackClass: "field-moving",
9154
+ forceFallback: true,
9150
9155
  group: {
9151
9156
  name: "column",
9152
9157
  pull: true,
@@ -9252,6 +9257,7 @@ class Row extends Component {
9252
9257
  Sortable.create(children, {
9253
9258
  animation: 150,
9254
9259
  fallbackClass: "column-moving",
9260
+ forceFallback: true,
9255
9261
  group: {
9256
9262
  name: "row",
9257
9263
  pull: true,
@@ -9947,30 +9953,37 @@ let Controls$1 = class Controls {
9947
9953
  for (let i2 = groups.length - 1; i2 >= 0; i2--) {
9948
9954
  const storeID = `formeo-controls-${groups[i2]}`;
9949
9955
  if (!this.options.sortable) {
9950
- window.localStorage.removeItem(storeID);
9956
+ globalThis.localStorage.removeItem(storeID);
9951
9957
  }
9952
9958
  Sortable.create(groups[i2], {
9953
9959
  animation: 150,
9954
- forceFallback: true,
9955
9960
  fallbackClass: "control-moving",
9956
9961
  fallbackOnBody: true,
9962
+ forceFallback: true,
9963
+ fallbackTolerance: 5,
9957
9964
  group: {
9958
9965
  name: "controls",
9959
9966
  pull: "clone",
9960
- put: false
9967
+ put: false,
9968
+ revertClone: true
9961
9969
  },
9962
- onStart: async ({ item }) => {
9963
- const { controlData } = this.get(item.id);
9970
+ onClone: ({ clone: clone2, item }) => {
9971
+ clone2.id = item.id;
9964
9972
  if (this.options.ghostPreview) {
9965
- const { default: Field2 } = await Promise.resolve().then(() => field);
9966
- item.innerHTML = "";
9967
- item.appendChild(new Field2(controlData).preview);
9973
+ const { controlData } = this.get(item.id);
9974
+ Promise.resolve().then(() => field).then(({ default: Field2 }) => {
9975
+ clone2.innerHTML = "";
9976
+ clone2.appendChild(new Field2(controlData).preview);
9977
+ });
9968
9978
  }
9969
9979
  },
9970
- onEnd: ({ from, item, clone: clone2 }) => {
9971
- if (from.contains(clone2)) {
9972
- from.replaceChild(item, clone2);
9973
- }
9980
+ onStart: () => {
9981
+ this.originalDocumentOverflow = document.documentElement.style.overflow;
9982
+ document.documentElement.style.overflow = "hidden";
9983
+ },
9984
+ onEnd: () => {
9985
+ document.documentElement.style.overflow = this.originalDocumentOverflow;
9986
+ this.originalDocumentOverflow = null;
9974
9987
  },
9975
9988
  sort: this.options.sortable,
9976
9989
  store: {
@@ -9980,7 +9993,7 @@ let Controls$1 = class Controls {
9980
9993
  * @return {Array}
9981
9994
  */
9982
9995
  get: () => {
9983
- const order = window.localStorage.getItem(storeID);
9996
+ const order = globalThis.localStorage.getItem(storeID);
9984
9997
  return order ? order.split("|") : [];
9985
9998
  },
9986
9999
  /**
@@ -9989,7 +10002,7 @@ let Controls$1 = class Controls {
9989
10002
  */
9990
10003
  set: (sortable) => {
9991
10004
  const order = sortable.toArray();
9992
- window.localStorage.setItem(storeID, order.join("|"));
10005
+ globalThis.localStorage.setItem(storeID, order.join("|"));
9993
10006
  }
9994
10007
  }
9995
10008
  });
@@ -10847,7 +10860,7 @@ const processOptions = ({ editorContainer, renderContainer, formData, ...opts })
10847
10860
  };
10848
10861
  const baseId = (id) => {
10849
10862
  const match2 = id.match(UUID_REGEXP);
10850
- return match2?.[0] || id``;
10863
+ return match2?.[0] || id;
10851
10864
  };
10852
10865
  const isVisible = (elem) => {
10853
10866
  if (!elem) return false;
@@ -10932,12 +10945,13 @@ const targetPropertyMap = {
10932
10945
  };
10933
10946
  let FormeoRenderer$1 = class FormeoRenderer {
10934
10947
  constructor(opts, formDataArg) {
10935
- const { renderContainer, elements, formData } = processOptions(opts);
10936
- this.container = renderContainer;
10948
+ const { renderContainer: container, elements, formData, config } = processOptions(opts);
10949
+ this.container = container;
10937
10950
  this.form = cleanFormData(formDataArg || formData);
10938
- this.dom = dom;
10939
- this.components = /* @__PURE__ */ Object.create(null);
10940
10951
  this.elements = elements;
10952
+ this.config = config;
10953
+ this.components = /* @__PURE__ */ Object.create(null);
10954
+ this.dom = dom;
10941
10955
  }
10942
10956
  get formData() {
10943
10957
  return this.form;
@@ -10945,10 +10959,30 @@ let FormeoRenderer$1 = class FormeoRenderer {
10945
10959
  set formData(data) {
10946
10960
  this.form = cleanFormData(data);
10947
10961
  }
10962
+ /**
10963
+ * Gets the user data from the rendered form as a plain object.
10964
+ * Converts FormData to an object, handling multiple values for the same key
10965
+ * by converting them into arrays.
10966
+ *
10967
+ * @returns {Object.<string, string|string[]>} An object containing form field names as keys
10968
+ * and their values. Fields with multiple values are stored as arrays.
10969
+ *
10970
+ * @example
10971
+ * // Form with single values
10972
+ * { username: 'john', email: 'john@example.com' }
10973
+ *
10974
+ * @example
10975
+ * // Form with multiple values for same key
10976
+ * { username: 'john', hobbies: ['reading', 'gaming'] }
10977
+ */
10948
10978
  get userData() {
10949
- const userData = new FormData(this.renderedForm);
10979
+ const form = this.container.querySelector(".formeo-render") || this.renderedForm;
10980
+ if (!form) {
10981
+ return {};
10982
+ }
10983
+ const formEntries = new FormData(form);
10950
10984
  const formDataObj = {};
10951
- for (const [key, value] of userData.entries()) {
10985
+ for (const [key, value] of formEntries.entries()) {
10952
10986
  if (formDataObj[key]) {
10953
10987
  if (Array.isArray(formDataObj[key])) {
10954
10988
  formDataObj[key].push(value);
@@ -10961,6 +10995,27 @@ let FormeoRenderer$1 = class FormeoRenderer {
10961
10995
  }
10962
10996
  return formDataObj;
10963
10997
  }
10998
+ /**
10999
+ * Gets the user form data as an array of field objects.
11000
+ * Combines user input values with component metadata to create structured field data.
11001
+ *
11002
+ * @returns {Array<{key: string, value: any, label: string}>} An array of field data objects, where each object contains:
11003
+ * - key: The field identifier
11004
+ * - value: The user's input value for the field
11005
+ * - label: The field's label from component configuration (empty string if not found)
11006
+ */
11007
+ get userFormData() {
11008
+ const userFormData = [];
11009
+ for (const [key, value] of Object.entries(this.userData)) {
11010
+ const fieldData = {
11011
+ key,
11012
+ value,
11013
+ label: this.components[baseId(key)]?.config?.label || ""
11014
+ };
11015
+ userFormData.push(fieldData);
11016
+ }
11017
+ return userFormData;
11018
+ }
10964
11019
  set userData(data = {}) {
10965
11020
  const form = this.container.querySelector("form");
10966
11021
  for (const key of Object.keys(data)) {
@@ -10984,6 +11039,7 @@ let FormeoRenderer$1 = class FormeoRenderer {
10984
11039
  * @param {Object} formData
10985
11040
  */
10986
11041
  render(formData = this.form) {
11042
+ this.form = cleanFormData(formData);
10987
11043
  const renderedForm = this.getRenderedForm(formData);
10988
11044
  const existingRenderedForm = this.container.querySelector(".formeo-render");
10989
11045
  if (existingRenderedForm) {
@@ -10996,6 +11052,7 @@ let FormeoRenderer$1 = class FormeoRenderer {
10996
11052
  this.form = cleanFormData(formData);
10997
11053
  const renderCount = document.getElementsByClassName("formeo-render").length;
10998
11054
  const config = {
11055
+ ...this.config,
10999
11056
  tag: "form",
11000
11057
  id: this.form.id,
11001
11058
  className: `formeo-render formeo formeo-rendered-${renderCount}`,
@@ -11021,11 +11078,9 @@ let FormeoRenderer$1 = class FormeoRenderer {
11021
11078
  */
11022
11079
  processColumn = ({ id, ...columnData }) => ({
11023
11080
  ...columnData,
11024
- ...{
11025
- id: this.prefixId(id),
11026
- children: this.processFields(columnData.children),
11027
- style: `width: ${columnData.config.width || "100%"}`
11028
- }
11081
+ id: this.prefixId(id),
11082
+ children: this.processFields(columnData.children),
11083
+ style: `width: ${columnData.config.width || "100%"}`
11029
11084
  });
11030
11085
  processRows = (stageId) => this.orderChildren("rows", this.form.stages[stageId].children).reduce((acc, row) => {
11031
11086
  if (row) {
@@ -11068,11 +11123,16 @@ let FormeoRenderer$1 = class FormeoRenderer {
11068
11123
  };
11069
11124
  };
11070
11125
  cloneComponentData = (componentId) => {
11071
- const { children = [], id, ...rest } = this.components[componentId];
11126
+ const { children = [], id, attrs = {}, ...rest } = this.components[componentId];
11127
+ const updatedAttrs = { ...attrs, "data-clone-of": id };
11128
+ if (rest.tag === "input") {
11129
+ updatedAttrs.name = getName(this.components[componentId]);
11130
+ }
11072
11131
  return {
11073
11132
  ...rest,
11074
- id: uuid(id),
11075
- children: children?.length && children.map(({ id: id2 }) => this.cloneComponentData(baseId(id2)))
11133
+ id: RENDER_PREFIX + uuid(id),
11134
+ children: children?.length && children.map(({ id: id2 }) => this.cloneComponentData(baseId(id2))),
11135
+ attrs: updatedAttrs
11076
11136
  };
11077
11137
  };
11078
11138
  addButton = (id) => ({
@@ -11220,12 +11280,12 @@ let FormeoRenderer$1 = class FormeoRenderer {
11220
11280
  return components2;
11221
11281
  };
11222
11282
  };
11283
+ const listenTypeMap = [
11284
+ ["input", (c) => ["textarea", "text"].includes(c.type)],
11285
+ ["change", (c) => ["select"].includes(c.tagName.toLowerCase()) || ["checkbox", "radio"].includes(c.type)]
11286
+ ];
11223
11287
  const LISTEN_TYPE_MAP = (component) => {
11224
- const typesMap = [
11225
- ["input", (c) => ["textarea", "text"].includes(c.type)],
11226
- ["change", (c) => ["select"].includes(c.tagName.toLowerCase()) || ["checkbox", "radio"].includes(c.type)]
11227
- ];
11228
- const [listenerEvent] = typesMap.find((typeMap) => typeMap[1](component)) || [false];
11288
+ const [listenerEvent] = listenTypeMap.find((typeMap) => typeMap[1](component)) || [false];
11229
11289
  return listenerEvent;
11230
11290
  };
11231
11291
  if (window !== void 0) {
package/dist/formeo.css CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 4.2.2
4
+ Version: 4.2.4
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -1542,6 +1542,7 @@ button[class*=-clone]:hover .svg-icon {
1542
1542
  flex-direction: column;
1543
1543
  justify-content: flex-start;
1544
1544
  gap: 16px;
1545
+ min-height: 100%;
1545
1546
  }
1546
1547
  .formeo.formeo-editor .formeo-stage.removing-all-fields .formeo-row {
1547
1548
  transition: margin-top 250ms ease-in;