formeo 5.1.1 → 5.1.3

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.
Files changed (78) hide show
  1. package/README.md +3 -3
  2. package/dist/demo/assets/css/demo.min.css +1 -1
  3. package/dist/demo/assets/css/demo.min.css.gz +0 -0
  4. package/dist/demo/assets/css/formeo.min.css +1 -1
  5. package/dist/demo/assets/js/demo.min.js +55 -55
  6. package/dist/demo/assets/js/demo.min.js.gz +0 -0
  7. package/dist/demo/assets/js/form.min.js +1 -1
  8. package/dist/demo/assets/js/formeo.cjs.js +92 -38
  9. package/dist/demo/assets/js/formeo.es.js +92 -38
  10. package/dist/demo/assets/js/formeo.min.cjs.js +2 -2
  11. package/dist/demo/assets/js/formeo.min.es.js +2 -2
  12. package/dist/demo/assets/js/formeo.min.js +92 -38
  13. package/dist/demo/assets/js/formeo.min.umd.js +2 -2
  14. package/dist/demo/assets/js/formeo.umd.js +92 -38
  15. package/dist/demo/assets/js/html.min.js +1 -1
  16. package/dist/demo/assets/js/layout.min.js +1 -1
  17. package/dist/demo/assets/js/mode-json.min.js +1 -1
  18. package/dist/demo/assets/js/mode-json.min.js.gz +0 -0
  19. package/dist/demo/assets/js/theme-github_light_default.min.js +1 -1
  20. package/dist/demo/index.html +1 -1
  21. package/dist/formeo.cjs.js +92 -38
  22. package/dist/formeo.css +1 -1
  23. package/dist/formeo.es.js +92 -38
  24. package/dist/formeo.min.cjs.js +2 -2
  25. package/dist/formeo.min.css +1 -1
  26. package/dist/formeo.min.es.js +2 -2
  27. package/dist/formeo.min.js +92 -38
  28. package/dist/formeo.min.umd.js +2 -2
  29. package/dist/formeo.umd.js +92 -38
  30. package/package.json +1 -1
  31. package/dist/demo/assets/lang/af-ZA.json +0 -1
  32. package/dist/demo/assets/lang/af-ZA.lang +0 -238
  33. package/dist/demo/assets/lang/ar-TN.json +0 -1
  34. package/dist/demo/assets/lang/ar-TN.lang +0 -238
  35. package/dist/demo/assets/lang/cs-CZ.json +0 -1
  36. package/dist/demo/assets/lang/cs-CZ.lang +0 -238
  37. package/dist/demo/assets/lang/de-DE.json +0 -1
  38. package/dist/demo/assets/lang/de-DE.lang +0 -238
  39. package/dist/demo/assets/lang/en-US.json +0 -1
  40. package/dist/demo/assets/lang/en-US.lang +0 -234
  41. package/dist/demo/assets/lang/es-ES.json +0 -1
  42. package/dist/demo/assets/lang/es-ES.lang +0 -238
  43. package/dist/demo/assets/lang/fa-IR.json +0 -1
  44. package/dist/demo/assets/lang/fa-IR.lang +0 -238
  45. package/dist/demo/assets/lang/fi-FI.json +0 -1
  46. package/dist/demo/assets/lang/fi-FI.lang +0 -238
  47. package/dist/demo/assets/lang/fr-FR.json +0 -1
  48. package/dist/demo/assets/lang/fr-FR.lang +0 -238
  49. package/dist/demo/assets/lang/he-IL.json +0 -1
  50. package/dist/demo/assets/lang/he-IL.lang +0 -238
  51. package/dist/demo/assets/lang/hi-IN.json +0 -1
  52. package/dist/demo/assets/lang/hi-IN.lang +0 -238
  53. package/dist/demo/assets/lang/hu-HU.json +0 -1
  54. package/dist/demo/assets/lang/hu-HU.lang +0 -238
  55. package/dist/demo/assets/lang/it-IT.json +0 -1
  56. package/dist/demo/assets/lang/it-IT.lang +0 -238
  57. package/dist/demo/assets/lang/ja-JP.json +0 -1
  58. package/dist/demo/assets/lang/ja-JP.lang +0 -238
  59. package/dist/demo/assets/lang/nb-NO.json +0 -1
  60. package/dist/demo/assets/lang/nb-NO.lang +0 -238
  61. package/dist/demo/assets/lang/pl-PL.json +0 -1
  62. package/dist/demo/assets/lang/pl-PL.lang +0 -238
  63. package/dist/demo/assets/lang/pt-BR.json +0 -1
  64. package/dist/demo/assets/lang/pt-BR.lang +0 -238
  65. package/dist/demo/assets/lang/pt-PT.json +0 -1
  66. package/dist/demo/assets/lang/pt-PT.lang +0 -238
  67. package/dist/demo/assets/lang/ro-RO.json +0 -1
  68. package/dist/demo/assets/lang/ro-RO.lang +0 -238
  69. package/dist/demo/assets/lang/ru-RU.json +0 -1
  70. package/dist/demo/assets/lang/ru-RU.lang +0 -238
  71. package/dist/demo/assets/lang/th-TH.json +0 -1
  72. package/dist/demo/assets/lang/th-TH.lang +0 -238
  73. package/dist/demo/assets/lang/tr-TR.json +0 -1
  74. package/dist/demo/assets/lang/tr-TR.lang +0 -238
  75. package/dist/demo/assets/lang/zh-CN.json +0 -1
  76. package/dist/demo/assets/lang/zh-CN.lang +0 -238
  77. package/dist/demo/assets/lang/zh-HK.json +0 -1
  78. package/dist/demo/assets/lang/zh-HK.lang +0 -238
Binary file
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 5.1.0
4
+ Version: 5.1.2
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: 5.1.0
4
+ Version: 5.1.2
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -71,7 +71,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
71
71
  allowSelect: "Laat Kies toe",
72
72
  and: "en",
73
73
  attribute: "kenmerk",
74
- attributeNotPermitted: `Attribuut "{attribuut}" is nie toegelaat nie, kies asseblief 'n ander.`,
74
+ attributeNotPermitted: "Attribuut \"{attribuut}\" is nie toegelaat nie, kies asseblief 'n ander.",
75
75
  attributes: "eienskappe",
76
76
  "attrs.class": "klas",
77
77
  "attrs.className": "klas",
@@ -2124,7 +2124,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
2124
2124
  "row.makeInputGroup": "Définir cette ligne comme groupe de saisie.",
2125
2125
  "row.makeInputGroupDesc": "Les groupes de saisie permettent aux usagers de rajouter de multiples champs à la fois.",
2126
2126
  "row.settings.fieldsetWrap": "Entourer le champ d'un élément <fieldset>",
2127
- "row.settings.fieldsetWrap.aria": `Entourer le champ d'un "Fieldset"`,
2127
+ "row.settings.fieldsetWrap.aria": "Entourer le champ d'un \"Fieldset\"",
2128
2128
  save: "Sauvegarder",
2129
2129
  secondary: "Secondaire",
2130
2130
  select: "Sélection",
@@ -2899,7 +2899,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
2899
2899
  allowSelect: "Consenti selezione",
2900
2900
  and: "e",
2901
2901
  attribute: "Attributo",
2902
- attributeNotPermitted: `L'attributo "{attribute}" non è permesso, per favore sceglierne un altro.`,
2902
+ attributeNotPermitted: "L'attributo \"{attribute}\" non è permesso, per favore sceglierne un altro.",
2903
2903
  attributes: "attributi",
2904
2904
  "attrs.class": "Classe",
2905
2905
  "attrs.className": "Classe",
@@ -5708,10 +5708,10 @@ e$1["de-DE"];
5708
5708
  //#region node_modules/@draggable/formeo-languages/dist/formeo-languages.es.js
5709
5709
  /**
5710
5710
  @draggable/formeo-languages - https://github.com/Draggable/formeo-languages#readme
5711
- Version: 3.4.1
5711
+ Version: 3.5.0
5712
5712
  Author: Kevin Chappell <kevin.b.chappell@gmail.com> (https://kevin-chappell.com)
5713
5713
  */
5714
- var i = e$1["en-US"];
5714
+ var s$1 = e$1["en-US"];
5715
5715
  e$1["es-ES"];
5716
5716
  e$1["fa-IR"];
5717
5717
  e$1["fi-FI"];
@@ -6061,7 +6061,7 @@ if (globalThis !== void 0) globalThis.SmartTooltip = SmartTooltip;
6061
6061
  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;
6062
6062
  var init_package = __esmMin((() => {
6063
6063
  name$1 = "formeo";
6064
- version$2 = "5.1.0";
6064
+ version$2 = "5.1.2";
6065
6065
  type = "module";
6066
6066
  main = "dist/formeo.cjs.js";
6067
6067
  module$1 = "dist/formeo.es.js";
@@ -10067,7 +10067,7 @@ function _typeof(o) {
10067
10067
  }, _typeof(o);
10068
10068
  }
10069
10069
  function userAgent(pattern) {
10070
- if (typeof window !== "undefined" && window.navigator) return !!/* @__PURE__ */ navigator.userAgent.match(pattern);
10070
+ if (typeof window !== "undefined" && window.navigator) return !!/*@__PURE__*/ navigator.userAgent.match(pattern);
10071
10071
  }
10072
10072
  function on(el, event, fn) {
10073
10073
  el.addEventListener(event, fn, !IE11OrLess && captureMode);
@@ -16668,7 +16668,9 @@ var init_component = __esmMin((() => {
16668
16668
  }
16669
16669
  const { controlData: { meta: { id: metaId }, ...elementData } } = Controls$1.get(item.id);
16670
16670
  set(elementData, "config.controlId", metaId);
16671
- const controlType = metaId.startsWith("layout-") ? metaId.replace(/^layout-/, "") : "field";
16671
+ const isLayoutControl = metaId.startsWith("layout-");
16672
+ const controlType = isLayoutControl ? metaId.replace(/^layout-/, "") : "field";
16673
+ const componentData = isLayoutControl ? {} : elementData;
16672
16674
  const depth = get({
16673
16675
  stage: {
16674
16676
  row: 0,
@@ -16689,7 +16691,7 @@ var init_component = __esmMin((() => {
16689
16691
  }, `${this.name}.${controlType}`);
16690
16692
  const action = depthMap.get(depth)();
16691
16693
  dom.remove(item);
16692
- return action(elementData, newIndex);
16694
+ return action(componentData, newIndex);
16693
16695
  },
16694
16696
  row: () => {
16695
16697
  return (depthMap.get({
@@ -17897,7 +17899,7 @@ var FormeoEditor$1 = class {
17897
17899
  fetchIcons(this.opts.svgSprite),
17898
17900
  fetchFormeoStyle(this.opts.style),
17899
17901
  s.init({
17900
- preloaded: { "en-US": i },
17902
+ preloaded: { "en-US": s$1 },
17901
17903
  ...this.opts.i18n,
17902
17904
  locale: globalThis.sessionStorage?.getItem(SESSION_LOCALE_KEY)
17903
17905
  })
@@ -18073,20 +18075,56 @@ var baseId = (id) => {
18073
18075
  };
18074
18076
  var isVisible = (elem) => {
18075
18077
  if (!elem) return false;
18076
- if (elem.hasAttribute("hidden") || elem.parentElement.hasAttribute("hidden")) return false;
18078
+ if (elem.hasAttribute("hidden") || elem.parentElement?.hasAttribute("hidden")) return false;
18077
18079
  const computedStyle = window.getComputedStyle(elem);
18078
18080
  return !(computedStyle.display === "none" || computedStyle.visibility === "hidden" || computedStyle.opacity === "0");
18079
18081
  };
18082
+ var CHECKABLE_INPUT_SELECTOR = "input[type=\"checkbox\"], input[type=\"radio\"]";
18083
+ var CHECKABLE_TYPES = new Set(["checkbox", "radio"]);
18084
+ var tagName$1 = (elem) => elem?.tagName?.toLowerCase();
18085
+ var isCheckableInput = (elem) => tagName$1(elem) === "input" && CHECKABLE_TYPES.has(elem.type);
18086
+ /**
18087
+ * Radio and checkbox fields render as a wrapper holding one input per option, so a
18088
+ * field address resolves to the wrapper rather than to anything carrying a value.
18089
+ * @param {Element} elem
18090
+ * @return {Array<Element>|null} option inputs, or null when elem is not a group
18091
+ */
18092
+ var checkableGroupInputs = (elem) => {
18093
+ if (!elem || isCheckableInput(elem) || typeof elem.querySelectorAll !== "function") return null;
18094
+ const inputs = elem.querySelectorAll(CHECKABLE_INPUT_SELECTOR);
18095
+ return inputs.length ? Array.from(inputs) : null;
18096
+ };
18097
+ var isCheckableGroup = (elem) => Boolean(checkableGroupInputs(elem));
18098
+ /**
18099
+ * Value a condition compares against. Controls that can hold several values at once
18100
+ * yield an array so that a single selection still matches an `equals` comparison.
18101
+ * @param {Element} elem
18102
+ * @return {String|Array<String>|undefined}
18103
+ */
18104
+ var elementValue = (elem) => {
18105
+ if (!elem) return;
18106
+ const groupInputs = checkableGroupInputs(elem);
18107
+ if (groupInputs) {
18108
+ const checkedValues = groupInputs.filter((input) => input.checked).map((input) => input.value);
18109
+ return groupInputs.every((input) => input.type === "radio") ? checkedValues[0] ?? "" : checkedValues;
18110
+ }
18111
+ if (tagName$1(elem) === "select" && elem.multiple) return Array.from(elem.selectedOptions, (option) => option.value);
18112
+ if (isCheckableInput(elem)) return elem.checked ? elem.value : "";
18113
+ return elem.value;
18114
+ };
18115
+ var isChecked = (elem) => {
18116
+ const groupInputs = checkableGroupInputs(elem);
18117
+ return groupInputs ? groupInputs.some((input) => input.checked) : Boolean(elem?.checked);
18118
+ };
18080
18119
  var propertyMap = {
18081
18120
  isChecked: (elem) => {
18082
- return elem.checked;
18121
+ return isChecked(elem);
18083
18122
  },
18084
18123
  isNotChecked: (elem) => {
18085
- return !elem.checked;
18086
- },
18087
- value: (elem) => {
18088
- return elem.value;
18124
+ return !isChecked(elem);
18089
18125
  },
18126
+ value: elementValue,
18127
+ checked: elementValue,
18090
18128
  isVisible: (elem) => {
18091
18129
  return isVisible(elem);
18092
18130
  },
@@ -18103,11 +18141,16 @@ var createRemoveButton = () => dom.btnTemplate({
18103
18141
  click: ({ target }) => target.parentElement.remove()
18104
18142
  }
18105
18143
  });
18144
+ var equals = (source, target) => Array.isArray(source) ? source.some((value) => (0, import_isEqual.default)(value, target)) : (0, import_isEqual.default)(source, target);
18145
+ var contains = (source, target) => {
18146
+ if (source == null) return false;
18147
+ return Array.isArray(source) ? source.includes(target) : String(source).includes(target);
18148
+ };
18106
18149
  var comparisonHandlers = {
18107
- equals: import_isEqual.default,
18108
- notEquals: (source, target) => !(0, import_isEqual.default)(source, target),
18109
- contains: (source, target) => source.includes(target),
18110
- notContains: (source, target) => !source.includes(target)
18150
+ equals,
18151
+ notEquals: (source, target) => !equals(source, target),
18152
+ contains,
18153
+ notContains: (source, target) => !contains(source, target)
18111
18154
  };
18112
18155
  var comparisonMap = Object.entries(COMPARISON_OPERATORS).reduce((acc, [key, value]) => {
18113
18156
  acc[value] = comparisonHandlers[key];
@@ -18375,7 +18418,8 @@ var FormeoRenderer$1 = class {
18375
18418
  * @return {Array} flattened array of conditions
18376
18419
  */
18377
18420
  handleComponentCondition = (component, ifRest, thenConditions) => {
18378
- if (component.length) {
18421
+ if (!component) return;
18422
+ if (isNodeCollection(component)) {
18379
18423
  for (const elem of component) this.handleComponentCondition(elem, ifRest, thenConditions);
18380
18424
  return;
18381
18425
  }
@@ -18387,23 +18431,25 @@ var FormeoRenderer$1 = class {
18387
18431
  if (this.evaluateCondition(ifRest, fakeEvt)) for (const thenCondition of thenConditions) this.execResult(thenCondition, fakeEvt);
18388
18432
  };
18389
18433
  applyConditions = () => {
18390
- for (const { conditions } of Object.values(this.components)) if (conditions) for (const condition of conditions) {
18391
- const { if: ifConditions, then: thenConditions } = condition;
18392
- for (const ifCondition of ifConditions) {
18393
- const { source, target } = ifCondition;
18394
- if (isAddress(source)) {
18395
- const { component, options } = this.getComponent(source);
18396
- const sourceComponent = options || component;
18397
- this.handleComponentCondition(sourceComponent, ifCondition, thenConditions);
18398
- }
18399
- if (isAddress(target)) {
18400
- const { component, options } = this.getComponent(target);
18401
- const targetComponent = options || component;
18402
- this.handleComponentCondition(targetComponent, ifCondition, thenConditions);
18434
+ for (const { conditions } of Object.values(this.components)) {
18435
+ if (!conditions) continue;
18436
+ for (const condition of conditions) {
18437
+ const { if: ifConditions = [], then: thenConditions = [] } = condition;
18438
+ for (const ifCondition of ifConditions) try {
18439
+ this.applyCondition(ifCondition, thenConditions);
18440
+ } catch (err) {
18441
+ console.error("formeo: condition skipped", ifCondition, err);
18403
18442
  }
18404
18443
  }
18405
18444
  }
18406
18445
  };
18446
+ applyCondition = (ifCondition, thenConditions) => {
18447
+ for (const address of [ifCondition.source, ifCondition.target]) {
18448
+ if (!isAddress(address)) continue;
18449
+ const { component, options } = this.getComponent(address);
18450
+ this.handleComponentCondition(options || component, ifCondition, thenConditions);
18451
+ }
18452
+ };
18407
18453
  /**
18408
18454
  * Evaulate conditions
18409
18455
  */
@@ -18425,9 +18471,10 @@ var FormeoRenderer$1 = class {
18425
18471
  }
18426
18472
  };
18427
18473
  getComponentProperty = (address, propertyName) => {
18428
- const { component, option } = this.getComponent(address);
18474
+ const { component, option } = this.getComponent(address) || {};
18429
18475
  const elem = option || component;
18430
- return propertyMap[propertyName]?.(elem) || elem[propertyName];
18476
+ if (!elem) return;
18477
+ return propertyMap[propertyName] ? propertyMap[propertyName](elem) : elem[propertyName];
18431
18478
  };
18432
18479
  getComponent = (address) => {
18433
18480
  const result = { component: null };
@@ -18452,7 +18499,14 @@ var FormeoRenderer$1 = class {
18452
18499
  return components;
18453
18500
  };
18454
18501
  };
18455
- var listenTypeMap = [["input", (c) => ["textarea", "text"].includes(c.type)], ["change", (c) => ["select"].includes(c.tagName.toLowerCase()) || ["checkbox", "radio"].includes(c.type)]];
18502
+ var isDomNode = (value) => Boolean(value) && typeof value.nodeType === "number";
18503
+ var isNodeCollection = (value) => Boolean(value) && !isDomNode(value) && typeof value.length === "number";
18504
+ var tagName = (component) => component.tagName?.toLowerCase();
18505
+ var listenTypeMap = [
18506
+ ["change", (component) => isCheckableGroup(component)],
18507
+ ["change", (component) => tagName(component) === "select" || ["checkbox", "radio"].includes(component.type)],
18508
+ ["input", (component) => ["input", "textarea"].includes(tagName(component))]
18509
+ ];
18456
18510
  var LISTEN_TYPE_MAP = (component) => {
18457
18511
  const [listenerEvent] = listenTypeMap.find((typeMap) => typeMap[1](component)) || [false];
18458
18512
  return listenerEvent;
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  formeo - https://formeo.io
4
- Version: 5.1.0
4
+ Version: 5.1.2
5
5
  Author: Draggable https://draggable.io
6
6
  */
7
7
 
@@ -70,7 +70,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
70
70
  allowSelect: "Laat Kies toe",
71
71
  and: "en",
72
72
  attribute: "kenmerk",
73
- attributeNotPermitted: `Attribuut "{attribuut}" is nie toegelaat nie, kies asseblief 'n ander.`,
73
+ attributeNotPermitted: "Attribuut \"{attribuut}\" is nie toegelaat nie, kies asseblief 'n ander.",
74
74
  attributes: "eienskappe",
75
75
  "attrs.class": "klas",
76
76
  "attrs.className": "klas",
@@ -2123,7 +2123,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
2123
2123
  "row.makeInputGroup": "Définir cette ligne comme groupe de saisie.",
2124
2124
  "row.makeInputGroupDesc": "Les groupes de saisie permettent aux usagers de rajouter de multiples champs à la fois.",
2125
2125
  "row.settings.fieldsetWrap": "Entourer le champ d'un élément &lt;fieldset&gt;",
2126
- "row.settings.fieldsetWrap.aria": `Entourer le champ d'un "Fieldset"`,
2126
+ "row.settings.fieldsetWrap.aria": "Entourer le champ d'un \"Fieldset\"",
2127
2127
  save: "Sauvegarder",
2128
2128
  secondary: "Secondaire",
2129
2129
  select: "Sélection",
@@ -2898,7 +2898,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
2898
2898
  allowSelect: "Consenti selezione",
2899
2899
  and: "e",
2900
2900
  attribute: "Attributo",
2901
- attributeNotPermitted: `L'attributo "{attribute}" non è permesso, per favore sceglierne un altro.`,
2901
+ attributeNotPermitted: "L'attributo \"{attribute}\" non è permesso, per favore sceglierne un altro.",
2902
2902
  attributes: "attributi",
2903
2903
  "attrs.class": "Classe",
2904
2904
  "attrs.className": "Classe",
@@ -5707,10 +5707,10 @@ e$1["de-DE"];
5707
5707
  //#region node_modules/@draggable/formeo-languages/dist/formeo-languages.es.js
5708
5708
  /**
5709
5709
  @draggable/formeo-languages - https://github.com/Draggable/formeo-languages#readme
5710
- Version: 3.4.1
5710
+ Version: 3.5.0
5711
5711
  Author: Kevin Chappell <kevin.b.chappell@gmail.com> (https://kevin-chappell.com)
5712
5712
  */
5713
- var i = e$1["en-US"];
5713
+ var s$1 = e$1["en-US"];
5714
5714
  e$1["es-ES"];
5715
5715
  e$1["fa-IR"];
5716
5716
  e$1["fi-FI"];
@@ -6060,7 +6060,7 @@ if (globalThis !== void 0) globalThis.SmartTooltip = SmartTooltip;
6060
6060
  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;
6061
6061
  var init_package = __esmMin((() => {
6062
6062
  name$1 = "formeo";
6063
- version$2 = "5.1.0";
6063
+ version$2 = "5.1.2";
6064
6064
  type = "module";
6065
6065
  main = "dist/formeo.cjs.js";
6066
6066
  module$1 = "dist/formeo.es.js";
@@ -10066,7 +10066,7 @@ function _typeof(o) {
10066
10066
  }, _typeof(o);
10067
10067
  }
10068
10068
  function userAgent(pattern) {
10069
- if (typeof window !== "undefined" && window.navigator) return !!/* @__PURE__ */ navigator.userAgent.match(pattern);
10069
+ if (typeof window !== "undefined" && window.navigator) return !!/*@__PURE__*/ navigator.userAgent.match(pattern);
10070
10070
  }
10071
10071
  function on(el, event, fn) {
10072
10072
  el.addEventListener(event, fn, !IE11OrLess && captureMode);
@@ -16667,7 +16667,9 @@ var init_component = __esmMin((() => {
16667
16667
  }
16668
16668
  const { controlData: { meta: { id: metaId }, ...elementData } } = Controls$1.get(item.id);
16669
16669
  set(elementData, "config.controlId", metaId);
16670
- const controlType = metaId.startsWith("layout-") ? metaId.replace(/^layout-/, "") : "field";
16670
+ const isLayoutControl = metaId.startsWith("layout-");
16671
+ const controlType = isLayoutControl ? metaId.replace(/^layout-/, "") : "field";
16672
+ const componentData = isLayoutControl ? {} : elementData;
16671
16673
  const depth = get({
16672
16674
  stage: {
16673
16675
  row: 0,
@@ -16688,7 +16690,7 @@ var init_component = __esmMin((() => {
16688
16690
  }, `${this.name}.${controlType}`);
16689
16691
  const action = depthMap.get(depth)();
16690
16692
  dom.remove(item);
16691
- return action(elementData, newIndex);
16693
+ return action(componentData, newIndex);
16692
16694
  },
16693
16695
  row: () => {
16694
16696
  return (depthMap.get({
@@ -17896,7 +17898,7 @@ var FormeoEditor$1 = class {
17896
17898
  fetchIcons(this.opts.svgSprite),
17897
17899
  fetchFormeoStyle(this.opts.style),
17898
17900
  s.init({
17899
- preloaded: { "en-US": i },
17901
+ preloaded: { "en-US": s$1 },
17900
17902
  ...this.opts.i18n,
17901
17903
  locale: globalThis.sessionStorage?.getItem(SESSION_LOCALE_KEY)
17902
17904
  })
@@ -18072,20 +18074,56 @@ var baseId = (id) => {
18072
18074
  };
18073
18075
  var isVisible = (elem) => {
18074
18076
  if (!elem) return false;
18075
- if (elem.hasAttribute("hidden") || elem.parentElement.hasAttribute("hidden")) return false;
18077
+ if (elem.hasAttribute("hidden") || elem.parentElement?.hasAttribute("hidden")) return false;
18076
18078
  const computedStyle = window.getComputedStyle(elem);
18077
18079
  return !(computedStyle.display === "none" || computedStyle.visibility === "hidden" || computedStyle.opacity === "0");
18078
18080
  };
18081
+ var CHECKABLE_INPUT_SELECTOR = "input[type=\"checkbox\"], input[type=\"radio\"]";
18082
+ var CHECKABLE_TYPES = new Set(["checkbox", "radio"]);
18083
+ var tagName$1 = (elem) => elem?.tagName?.toLowerCase();
18084
+ var isCheckableInput = (elem) => tagName$1(elem) === "input" && CHECKABLE_TYPES.has(elem.type);
18085
+ /**
18086
+ * Radio and checkbox fields render as a wrapper holding one input per option, so a
18087
+ * field address resolves to the wrapper rather than to anything carrying a value.
18088
+ * @param {Element} elem
18089
+ * @return {Array<Element>|null} option inputs, or null when elem is not a group
18090
+ */
18091
+ var checkableGroupInputs = (elem) => {
18092
+ if (!elem || isCheckableInput(elem) || typeof elem.querySelectorAll !== "function") return null;
18093
+ const inputs = elem.querySelectorAll(CHECKABLE_INPUT_SELECTOR);
18094
+ return inputs.length ? Array.from(inputs) : null;
18095
+ };
18096
+ var isCheckableGroup = (elem) => Boolean(checkableGroupInputs(elem));
18097
+ /**
18098
+ * Value a condition compares against. Controls that can hold several values at once
18099
+ * yield an array so that a single selection still matches an `equals` comparison.
18100
+ * @param {Element} elem
18101
+ * @return {String|Array<String>|undefined}
18102
+ */
18103
+ var elementValue = (elem) => {
18104
+ if (!elem) return;
18105
+ const groupInputs = checkableGroupInputs(elem);
18106
+ if (groupInputs) {
18107
+ const checkedValues = groupInputs.filter((input) => input.checked).map((input) => input.value);
18108
+ return groupInputs.every((input) => input.type === "radio") ? checkedValues[0] ?? "" : checkedValues;
18109
+ }
18110
+ if (tagName$1(elem) === "select" && elem.multiple) return Array.from(elem.selectedOptions, (option) => option.value);
18111
+ if (isCheckableInput(elem)) return elem.checked ? elem.value : "";
18112
+ return elem.value;
18113
+ };
18114
+ var isChecked = (elem) => {
18115
+ const groupInputs = checkableGroupInputs(elem);
18116
+ return groupInputs ? groupInputs.some((input) => input.checked) : Boolean(elem?.checked);
18117
+ };
18079
18118
  var propertyMap = {
18080
18119
  isChecked: (elem) => {
18081
- return elem.checked;
18120
+ return isChecked(elem);
18082
18121
  },
18083
18122
  isNotChecked: (elem) => {
18084
- return !elem.checked;
18085
- },
18086
- value: (elem) => {
18087
- return elem.value;
18123
+ return !isChecked(elem);
18088
18124
  },
18125
+ value: elementValue,
18126
+ checked: elementValue,
18089
18127
  isVisible: (elem) => {
18090
18128
  return isVisible(elem);
18091
18129
  },
@@ -18102,11 +18140,16 @@ var createRemoveButton = () => dom.btnTemplate({
18102
18140
  click: ({ target }) => target.parentElement.remove()
18103
18141
  }
18104
18142
  });
18143
+ var equals = (source, target) => Array.isArray(source) ? source.some((value) => (0, import_isEqual.default)(value, target)) : (0, import_isEqual.default)(source, target);
18144
+ var contains = (source, target) => {
18145
+ if (source == null) return false;
18146
+ return Array.isArray(source) ? source.includes(target) : String(source).includes(target);
18147
+ };
18105
18148
  var comparisonHandlers = {
18106
- equals: import_isEqual.default,
18107
- notEquals: (source, target) => !(0, import_isEqual.default)(source, target),
18108
- contains: (source, target) => source.includes(target),
18109
- notContains: (source, target) => !source.includes(target)
18149
+ equals,
18150
+ notEquals: (source, target) => !equals(source, target),
18151
+ contains,
18152
+ notContains: (source, target) => !contains(source, target)
18110
18153
  };
18111
18154
  var comparisonMap = Object.entries(COMPARISON_OPERATORS).reduce((acc, [key, value]) => {
18112
18155
  acc[value] = comparisonHandlers[key];
@@ -18374,7 +18417,8 @@ var FormeoRenderer$1 = class {
18374
18417
  * @return {Array} flattened array of conditions
18375
18418
  */
18376
18419
  handleComponentCondition = (component, ifRest, thenConditions) => {
18377
- if (component.length) {
18420
+ if (!component) return;
18421
+ if (isNodeCollection(component)) {
18378
18422
  for (const elem of component) this.handleComponentCondition(elem, ifRest, thenConditions);
18379
18423
  return;
18380
18424
  }
@@ -18386,23 +18430,25 @@ var FormeoRenderer$1 = class {
18386
18430
  if (this.evaluateCondition(ifRest, fakeEvt)) for (const thenCondition of thenConditions) this.execResult(thenCondition, fakeEvt);
18387
18431
  };
18388
18432
  applyConditions = () => {
18389
- for (const { conditions } of Object.values(this.components)) if (conditions) for (const condition of conditions) {
18390
- const { if: ifConditions, then: thenConditions } = condition;
18391
- for (const ifCondition of ifConditions) {
18392
- const { source, target } = ifCondition;
18393
- if (isAddress(source)) {
18394
- const { component, options } = this.getComponent(source);
18395
- const sourceComponent = options || component;
18396
- this.handleComponentCondition(sourceComponent, ifCondition, thenConditions);
18397
- }
18398
- if (isAddress(target)) {
18399
- const { component, options } = this.getComponent(target);
18400
- const targetComponent = options || component;
18401
- this.handleComponentCondition(targetComponent, ifCondition, thenConditions);
18433
+ for (const { conditions } of Object.values(this.components)) {
18434
+ if (!conditions) continue;
18435
+ for (const condition of conditions) {
18436
+ const { if: ifConditions = [], then: thenConditions = [] } = condition;
18437
+ for (const ifCondition of ifConditions) try {
18438
+ this.applyCondition(ifCondition, thenConditions);
18439
+ } catch (err) {
18440
+ console.error("formeo: condition skipped", ifCondition, err);
18402
18441
  }
18403
18442
  }
18404
18443
  }
18405
18444
  };
18445
+ applyCondition = (ifCondition, thenConditions) => {
18446
+ for (const address of [ifCondition.source, ifCondition.target]) {
18447
+ if (!isAddress(address)) continue;
18448
+ const { component, options } = this.getComponent(address);
18449
+ this.handleComponentCondition(options || component, ifCondition, thenConditions);
18450
+ }
18451
+ };
18406
18452
  /**
18407
18453
  * Evaulate conditions
18408
18454
  */
@@ -18424,9 +18470,10 @@ var FormeoRenderer$1 = class {
18424
18470
  }
18425
18471
  };
18426
18472
  getComponentProperty = (address, propertyName) => {
18427
- const { component, option } = this.getComponent(address);
18473
+ const { component, option } = this.getComponent(address) || {};
18428
18474
  const elem = option || component;
18429
- return propertyMap[propertyName]?.(elem) || elem[propertyName];
18475
+ if (!elem) return;
18476
+ return propertyMap[propertyName] ? propertyMap[propertyName](elem) : elem[propertyName];
18430
18477
  };
18431
18478
  getComponent = (address) => {
18432
18479
  const result = { component: null };
@@ -18451,7 +18498,14 @@ var FormeoRenderer$1 = class {
18451
18498
  return components;
18452
18499
  };
18453
18500
  };
18454
- var listenTypeMap = [["input", (c) => ["textarea", "text"].includes(c.type)], ["change", (c) => ["select"].includes(c.tagName.toLowerCase()) || ["checkbox", "radio"].includes(c.type)]];
18501
+ var isDomNode = (value) => Boolean(value) && typeof value.nodeType === "number";
18502
+ var isNodeCollection = (value) => Boolean(value) && !isDomNode(value) && typeof value.length === "number";
18503
+ var tagName = (component) => component.tagName?.toLowerCase();
18504
+ var listenTypeMap = [
18505
+ ["change", (component) => isCheckableGroup(component)],
18506
+ ["change", (component) => tagName(component) === "select" || ["checkbox", "radio"].includes(component.type)],
18507
+ ["input", (component) => ["input", "textarea"].includes(tagName(component))]
18508
+ ];
18455
18509
  var LISTEN_TYPE_MAP = (component) => {
18456
18510
  const [listenerEvent] = listenTypeMap.find((typeMap) => typeMap[1](component)) || [false];
18457
18511
  return listenerEvent;