@formio/js 5.4.0 → 5.4.2

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 (217) hide show
  1. package/README.md +11 -5
  2. package/dist/formio.builder.css +12 -5
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.js +1 -1
  5. package/dist/formio.embed.min.js +1 -1
  6. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.form.css +12 -5
  8. package/dist/formio.form.js +2883 -2867
  9. package/dist/formio.form.min.css +1 -1
  10. package/dist/formio.form.min.js +1 -1
  11. package/dist/formio.form.min.js.LICENSE.txt +2 -2
  12. package/dist/formio.full.css +12 -5
  13. package/dist/formio.full.js +3507 -3491
  14. package/dist/formio.full.min.css +1 -1
  15. package/dist/formio.full.min.js +1 -1
  16. package/dist/formio.full.min.js.LICENSE.txt +2 -2
  17. package/dist/formio.js +1139 -1145
  18. package/dist/formio.min.js +1 -1
  19. package/dist/formio.min.js.LICENSE.txt +2 -2
  20. package/dist/formio.utils.js +1066 -1072
  21. package/dist/formio.utils.min.js +1 -1
  22. package/dist/formio.utils.min.js.LICENSE.txt +2 -2
  23. package/lib/cjs/Embed.js +8 -16
  24. package/lib/cjs/Form.js +4 -4
  25. package/lib/cjs/Formio.js +2 -9
  26. package/lib/cjs/InlineEmbed.js +1 -4
  27. package/lib/cjs/PDF.js +28 -8
  28. package/lib/cjs/PDFBuilder.js +6 -10
  29. package/lib/cjs/Webform.d.ts +1 -0
  30. package/lib/cjs/Webform.js +19 -34
  31. package/lib/cjs/WebformBuilder.js +27 -68
  32. package/lib/cjs/Wizard.d.ts +1 -0
  33. package/lib/cjs/Wizard.js +44 -31
  34. package/lib/cjs/WizardBuilder.js +5 -15
  35. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
  36. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
  37. package/lib/cjs/addons/index.js +1 -3
  38. package/lib/cjs/components/_classes/component/Component.d.ts +10 -5
  39. package/lib/cjs/components/_classes/component/Component.js +76 -134
  40. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
  41. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
  42. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
  43. package/lib/cjs/components/_classes/field/Field.js +1 -4
  44. package/lib/cjs/components/_classes/input/Input.js +2 -2
  45. package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
  46. package/lib/cjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
  47. package/lib/cjs/components/_classes/multivalue/Multivalue.js +8 -26
  48. package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -4
  49. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
  50. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
  51. package/lib/cjs/components/address/Address.js +10 -30
  52. package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -32
  53. package/lib/cjs/components/alert/Alert.js +3 -6
  54. package/lib/cjs/components/button/Button.d.ts +1 -0
  55. package/lib/cjs/components/button/Button.js +31 -17
  56. package/lib/cjs/components/button/editForm/Button.edit.display.js +8 -32
  57. package/lib/cjs/components/checkbox/Checkbox.js +4 -10
  58. package/lib/cjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
  59. package/lib/cjs/components/columns/Columns.js +5 -17
  60. package/lib/cjs/components/container/Container.js +1 -3
  61. package/lib/cjs/components/currency/Currency.js +2 -7
  62. package/lib/cjs/components/datagrid/DataGrid.js +27 -68
  63. package/lib/cjs/components/datamap/DataMap.js +4 -16
  64. package/lib/cjs/components/datetime/DateTime.js +2 -6
  65. package/lib/cjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
  66. package/lib/cjs/components/day/Day.js +12 -70
  67. package/lib/cjs/components/day/editForm/Day.edit.day.js +1 -3
  68. package/lib/cjs/components/day/editForm/Day.edit.month.js +1 -3
  69. package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -0
  70. package/lib/cjs/components/editgrid/EditGrid.js +18 -44
  71. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
  72. package/lib/cjs/components/file/File.js +40 -70
  73. package/lib/cjs/components/file/editForm/File.edit.display.js +1 -5
  74. package/lib/cjs/components/file/editForm/File.edit.file.js +8 -30
  75. package/lib/cjs/components/form/Form.js +5 -7
  76. package/lib/cjs/components/html/HTML.js +1 -5
  77. package/lib/cjs/components/number/Number.js +2 -4
  78. package/lib/cjs/components/panel/editForm/Panel.edit.display.js +3 -12
  79. package/lib/cjs/components/password/Password.js +1 -4
  80. package/lib/cjs/components/radio/Radio.js +7 -17
  81. package/lib/cjs/components/radio/editForm/Radio.edit.data.js +4 -14
  82. package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -6
  83. package/lib/cjs/components/select/Select.js +49 -94
  84. package/lib/cjs/components/select/editForm/Select.edit.data.js +37 -182
  85. package/lib/cjs/components/select/editForm/Select.edit.validation.js +1 -9
  86. package/lib/cjs/components/selectboxes/SelectBoxes.js +3 -6
  87. package/lib/cjs/components/signature/Signature.d.ts +1 -1
  88. package/lib/cjs/components/signature/Signature.js +5 -10
  89. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +2 -6
  90. package/lib/cjs/components/survey/Survey.js +6 -17
  91. package/lib/cjs/components/survey/editForm/Survey.edit.data.js +4 -12
  92. package/lib/cjs/components/table/editForm/Table.edit.display.js +3 -3
  93. package/lib/cjs/components/tabs/Tabs.js +4 -19
  94. package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
  95. package/lib/cjs/components/tags/Tags.js +4 -14
  96. package/lib/cjs/components/textarea/TextArea.js +8 -15
  97. package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
  98. package/lib/cjs/components/textfield/TextField.js +4 -4
  99. package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +2 -8
  100. package/lib/cjs/components/time/Time.js +1 -4
  101. package/lib/cjs/components/time/editForm/Time.edit.display.js +1 -4
  102. package/lib/cjs/formio.form.js +5 -5
  103. package/lib/cjs/package.json +1 -1
  104. package/lib/cjs/providers/address/AddressProvider.js +1 -1
  105. package/lib/cjs/providers/address/GoogleAddressProvider.js +2 -4
  106. package/lib/cjs/providers/processor/fileProcessor.js +1 -3
  107. package/lib/cjs/providers/storage/azure.js +5 -6
  108. package/lib/cjs/providers/storage/indexeddb.js +5 -15
  109. package/lib/cjs/providers/storage/s3.js +3 -14
  110. package/lib/cjs/providers/storage/xhr.js +19 -28
  111. package/lib/cjs/templates/Templates.js +1 -0
  112. package/lib/cjs/translations/en.d.ts +237 -81
  113. package/lib/cjs/translations/en.js +10 -81
  114. package/lib/cjs/utils/ChoicesWrapper.js +1 -1
  115. package/lib/cjs/utils/builder.js +5 -26
  116. package/lib/cjs/utils/i18n.d.ts +5 -2
  117. package/lib/cjs/utils/i18n.js +33 -12
  118. package/lib/cjs/utils/utils.js +42 -52
  119. package/lib/cjs/widgets/CalendarWidget.js +2 -6
  120. package/lib/mjs/Embed.js +8 -16
  121. package/lib/mjs/Form.js +4 -4
  122. package/lib/mjs/Formio.js +2 -9
  123. package/lib/mjs/InlineEmbed.js +1 -4
  124. package/lib/mjs/PDF.js +27 -8
  125. package/lib/mjs/PDFBuilder.js +6 -10
  126. package/lib/mjs/Webform.d.ts +1 -0
  127. package/lib/mjs/Webform.js +19 -31
  128. package/lib/mjs/WebformBuilder.js +27 -68
  129. package/lib/mjs/Wizard.d.ts +1 -0
  130. package/lib/mjs/Wizard.js +39 -27
  131. package/lib/mjs/WizardBuilder.js +5 -15
  132. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
  133. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
  134. package/lib/mjs/addons/index.js +1 -3
  135. package/lib/mjs/components/_classes/component/Component.d.ts +10 -5
  136. package/lib/mjs/components/_classes/component/Component.js +75 -134
  137. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
  138. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
  139. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
  140. package/lib/mjs/components/_classes/field/Field.js +1 -4
  141. package/lib/mjs/components/_classes/input/Input.js +2 -2
  142. package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
  143. package/lib/mjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
  144. package/lib/mjs/components/_classes/multivalue/Multivalue.js +8 -26
  145. package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -4
  146. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
  147. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
  148. package/lib/mjs/components/address/Address.js +10 -30
  149. package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -32
  150. package/lib/mjs/components/alert/Alert.js +3 -6
  151. package/lib/mjs/components/button/Button.d.ts +1 -0
  152. package/lib/mjs/components/button/Button.js +29 -16
  153. package/lib/mjs/components/button/editForm/Button.edit.display.js +8 -32
  154. package/lib/mjs/components/checkbox/Checkbox.js +4 -10
  155. package/lib/mjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
  156. package/lib/mjs/components/columns/Columns.js +5 -17
  157. package/lib/mjs/components/container/Container.js +1 -3
  158. package/lib/mjs/components/currency/Currency.js +2 -7
  159. package/lib/mjs/components/datagrid/DataGrid.js +28 -69
  160. package/lib/mjs/components/datamap/DataMap.js +12 -18
  161. package/lib/mjs/components/datetime/DateTime.js +2 -6
  162. package/lib/mjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
  163. package/lib/mjs/components/day/Day.js +12 -70
  164. package/lib/mjs/components/day/editForm/Day.edit.day.js +1 -3
  165. package/lib/mjs/components/day/editForm/Day.edit.month.js +1 -3
  166. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -0
  167. package/lib/mjs/components/editgrid/EditGrid.js +18 -44
  168. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
  169. package/lib/mjs/components/file/File.js +40 -70
  170. package/lib/mjs/components/file/editForm/File.edit.display.js +1 -5
  171. package/lib/mjs/components/file/editForm/File.edit.file.js +8 -30
  172. package/lib/mjs/components/form/Form.js +5 -7
  173. package/lib/mjs/components/html/HTML.js +1 -5
  174. package/lib/mjs/components/number/Number.js +2 -4
  175. package/lib/mjs/components/panel/editForm/Panel.edit.display.js +3 -12
  176. package/lib/mjs/components/password/Password.js +1 -4
  177. package/lib/mjs/components/radio/Radio.js +7 -17
  178. package/lib/mjs/components/radio/editForm/Radio.edit.data.js +4 -14
  179. package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -6
  180. package/lib/mjs/components/select/Select.js +52 -97
  181. package/lib/mjs/components/select/editForm/Select.edit.data.js +37 -182
  182. package/lib/mjs/components/select/editForm/Select.edit.validation.js +1 -9
  183. package/lib/mjs/components/selectboxes/SelectBoxes.js +3 -6
  184. package/lib/mjs/components/signature/Signature.d.ts +1 -1
  185. package/lib/mjs/components/signature/Signature.js +5 -10
  186. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +2 -6
  187. package/lib/mjs/components/survey/Survey.js +6 -17
  188. package/lib/mjs/components/survey/editForm/Survey.edit.data.js +4 -12
  189. package/lib/mjs/components/table/editForm/Table.edit.display.js +3 -3
  190. package/lib/mjs/components/tabs/Tabs.js +4 -19
  191. package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
  192. package/lib/mjs/components/tags/Tags.js +4 -14
  193. package/lib/mjs/components/textarea/TextArea.js +8 -15
  194. package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
  195. package/lib/mjs/components/textfield/TextField.js +4 -4
  196. package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +2 -8
  197. package/lib/mjs/components/time/Time.js +1 -4
  198. package/lib/mjs/components/time/editForm/Time.edit.display.js +1 -4
  199. package/lib/mjs/formio.form.js +6 -6
  200. package/lib/mjs/package.json +1 -1
  201. package/lib/mjs/providers/address/AddressProvider.js +1 -1
  202. package/lib/mjs/providers/address/GoogleAddressProvider.js +2 -4
  203. package/lib/mjs/providers/processor/fileProcessor.js +1 -3
  204. package/lib/mjs/providers/storage/azure.js +5 -6
  205. package/lib/mjs/providers/storage/indexeddb.js +5 -15
  206. package/lib/mjs/providers/storage/s3.js +3 -14
  207. package/lib/mjs/providers/storage/xhr.js +19 -32
  208. package/lib/mjs/templates/Templates.js +1 -0
  209. package/lib/mjs/translations/en.d.ts +237 -81
  210. package/lib/mjs/translations/en.js +91 -1
  211. package/lib/mjs/utils/ChoicesWrapper.js +1 -1
  212. package/lib/mjs/utils/builder.js +5 -26
  213. package/lib/mjs/utils/i18n.d.ts +5 -2
  214. package/lib/mjs/utils/i18n.js +33 -12
  215. package/lib/mjs/utils/utils.js +42 -52
  216. package/lib/mjs/widgets/CalendarWidget.js +2 -6
  217. package/package.json +8 -6
@@ -159,7 +159,7 @@ function getConditionalPathsRecursive(conditionPaths, data) {
159
159
  }
160
160
  else {
161
161
  currentData.forEach((x, index) => {
162
- if (!lodash_1.default.isNil(x[conditionPaths[currentLocalIndex]])) {
162
+ if (x && conditionPaths && !lodash_1.default.isNil(x[conditionPaths[currentLocalIndex]])) {
163
163
  const compDataPath = `${currentPath}[${index}].${conditionPaths[currentLocalIndex]}`;
164
164
  conditionalPathsArray.push(compDataPath);
165
165
  }
@@ -1045,9 +1045,7 @@ function fieldData(data, component) {
1045
1045
  }
1046
1046
  // Convert old single field data in submissions to multiple
1047
1047
  if (key === parts[parts.length - 1] && component.multiple && !Array.isArray(value[key])) {
1048
- value[key] = [
1049
- value[key],
1050
- ];
1048
+ value[key] = [value[key]];
1051
1049
  }
1052
1050
  // Set the value of this key.
1053
1051
  value = value[key];
@@ -1057,9 +1055,7 @@ function fieldData(data, component) {
1057
1055
  else {
1058
1056
  // Convert old single field data in submissions to multiple
1059
1057
  if (component.multiple && !Array.isArray(data[component.key])) {
1060
- data[component.key] = [
1061
- data[component.key],
1062
- ];
1058
+ data[component.key] = [data[component.key]];
1063
1059
  }
1064
1060
  // Fix for checkbox type radio submission values in tableView
1065
1061
  if (component.type === 'checkbox' && component.inputType === 'radio') {
@@ -1189,10 +1185,7 @@ function withSwitch(a, b) {
1189
1185
  state = next;
1190
1186
  next = prev;
1191
1187
  }
1192
- return [
1193
- get,
1194
- toggle,
1195
- ];
1188
+ return [get, toggle];
1196
1189
  }
1197
1190
  exports.withSwitch = withSwitch;
1198
1191
  /**
@@ -1323,9 +1316,7 @@ function translateElemValue(elem, translate) {
1323
1316
  * @returns {void}
1324
1317
  */
1325
1318
  function translateDeepTag(tag, translate) {
1326
- const children = tag.children.length && [
1327
- ...tag.children,
1328
- ];
1319
+ const children = tag.children.length && [...tag.children];
1329
1320
  const shouldTranslateEntireContent = children &&
1330
1321
  children.every((child) => child.children.length === 0 && inTextTags.some((tag) => child.nodeName === tag));
1331
1322
  if (!children || shouldTranslateEntireContent) {
@@ -1367,10 +1358,7 @@ function sanitize(string, options) {
1367
1358
  }
1368
1359
  // Dompurify configuration
1369
1360
  const sanitizeOptions = {
1370
- ADD_ATTR: [
1371
- 'ref',
1372
- 'target',
1373
- ],
1361
+ ADD_ATTR: ['ref', 'target'],
1374
1362
  USE_PROFILES: { html: true },
1375
1363
  };
1376
1364
  // Use profiles
@@ -1463,9 +1451,7 @@ exports.isInputComponent = isInputComponent;
1463
1451
  function getArrayFromComponentPath(pathStr) {
1464
1452
  if (!pathStr || !lodash_1.default.isString(pathStr)) {
1465
1453
  if (!lodash_1.default.isArray(pathStr)) {
1466
- return [
1467
- pathStr,
1468
- ];
1454
+ return [pathStr];
1469
1455
  }
1470
1456
  return pathStr;
1471
1457
  }
@@ -1666,9 +1652,7 @@ function getComponentSavedTypes(fullSchema) {
1666
1652
  return [];
1667
1653
  }
1668
1654
  if (schema.multiple) {
1669
- return [
1670
- exports.componentValueTypes.array,
1671
- ];
1655
+ return [exports.componentValueTypes.array];
1672
1656
  }
1673
1657
  return null;
1674
1658
  }
@@ -1709,11 +1693,17 @@ function hasEncodedTimezone(value) {
1709
1693
  }
1710
1694
  exports.hasEncodedTimezone = hasEncodedTimezone;
1711
1695
  // Types for min max validation if value = string
1712
- const TYPES = new Map([["char", "Length"], ["word", "Words"]]);
1696
+ const TYPES = new Map([
1697
+ ['char', 'Length'],
1698
+ ['word', 'Words'],
1699
+ ]);
1713
1700
  // The number from which the remaining character(words) count message starts being read
1714
- const REMAIN_COUNT = new Map([["char", 10], ["word", 5]]);
1701
+ const REMAIN_COUNT = new Map([
1702
+ ['char', 10],
1703
+ ['word', 5],
1704
+ ]);
1715
1705
  function getWordOrCharacterLabel(isWordType, count) {
1716
- const base = isWordType ? "word" : "character";
1706
+ const base = isWordType ? 'word' : 'character';
1717
1707
  return Math.abs(count) === 1 ? base : `${base}s`;
1718
1708
  }
1719
1709
  /**
@@ -1725,17 +1715,17 @@ function getWordOrCharacterLabel(isWordType, count) {
1725
1715
  * @returns {string} - The messsage string
1726
1716
  */
1727
1717
  function getScreenReaderMessage(component, type, value) {
1728
- const isWordType = type === "word";
1729
- const maxKey = typeof value === "string" && (type === "char" || isWordType)
1718
+ const isWordType = type === 'word';
1719
+ const maxKey = typeof value === 'string' && (type === 'char' || isWordType)
1730
1720
  ? `validate.max${TYPES.get(type)}`
1731
- : "validate.max";
1732
- const minKey = typeof value === "string" && (type === "char" || isWordType)
1721
+ : 'validate.max';
1722
+ const minKey = typeof value === 'string' && (type === 'char' || isWordType)
1733
1723
  ? `validate.min${TYPES.get(type)}`
1734
- : "validate.min";
1724
+ : 'validate.min';
1735
1725
  const max = lodash_1.default.parseInt(lodash_1.default.get(component.component, maxKey), 10);
1736
1726
  const min = lodash_1.default.parseInt(lodash_1.default.get(component.component, minKey), 10);
1737
- let message = "";
1738
- if (typeof value === "string") {
1727
+ let message = '';
1728
+ if (typeof value === 'string') {
1739
1729
  const currentLength = isWordType ? component.getWordCount(value) : value.length;
1740
1730
  if (!isNaN(max)) {
1741
1731
  const remains = max - currentLength;
@@ -1771,8 +1761,8 @@ function getScreenReaderMessage(component, type, value) {
1771
1761
  }
1772
1762
  }
1773
1763
  }
1774
- else if (typeof value === "number" || value === null) {
1775
- if (value != null && value !== "") {
1764
+ else if (typeof value === 'number' || value === null) {
1765
+ if (value != null && value !== '') {
1776
1766
  if (!isNaN(max) && value > max) {
1777
1767
  message += `Number cannot be greater than ${max}. `;
1778
1768
  }
@@ -1798,11 +1788,11 @@ function getScreenReaderMessage(component, type, value) {
1798
1788
  * @returns {undefined}
1799
1789
  */
1800
1790
  function announceScreenReaderMessage(component, value, index = 0, forFocus = false) {
1801
- if (typeof value !== "string" && typeof value !== "number" && value !== null) {
1791
+ if (typeof value !== 'string' && typeof value !== 'number' && value !== null) {
1802
1792
  return;
1803
1793
  }
1804
1794
  // The ref for announcing messages
1805
- const messageSpan = "announceMessage";
1795
+ const messageSpan = 'announceMessage';
1806
1796
  if (!component.refs[messageSpan])
1807
1797
  return;
1808
1798
  const el = component.refs[messageSpan][index];
@@ -1810,31 +1800,31 @@ function announceScreenReaderMessage(component, value, index = 0, forFocus = fal
1810
1800
  return;
1811
1801
  // Define types for validation
1812
1802
  const typesToCheck = [];
1813
- if (typeof value === "string")
1814
- typesToCheck.push("char", "word");
1815
- if (typeof value === "number" || value === null)
1816
- typesToCheck.push("number");
1803
+ if (typeof value === 'string')
1804
+ typesToCheck.push('char', 'word');
1805
+ if (typeof value === 'number' || value === null)
1806
+ typesToCheck.push('number');
1817
1807
  // Construct the combined message
1818
1808
  const combinedMessage = typesToCheck
1819
- .map(type => getScreenReaderMessage(component, type, value))
1820
- .filter(msg => msg)
1821
- .join(" ")
1809
+ .map((type) => getScreenReaderMessage(component, type, value))
1810
+ .filter((msg) => msg)
1811
+ .join(' ')
1822
1812
  .trim();
1823
1813
  if (forFocus) {
1824
1814
  setTimeout(() => {
1825
- el.textContent = "";
1826
- requestAnimationFrame(() => {
1815
+ el.textContent = '';
1816
+ setTimeout(() => {
1827
1817
  el.textContent = combinedMessage;
1828
- });
1818
+ }, 50);
1829
1819
  }, 150);
1830
1820
  return;
1831
1821
  }
1832
1822
  clearTimeout(el._announceTimer);
1833
1823
  el._announceTimer = setTimeout(() => {
1834
- el.textContent = "";
1835
- requestAnimationFrame(() => {
1824
+ el.textContent = '';
1825
+ setTimeout(() => {
1836
1826
  el.textContent = combinedMessage;
1837
- });
1827
+ }, 50);
1838
1828
  }, 500);
1839
1829
  }
1840
1830
  exports.announceScreenReaderMessage = announceScreenReaderMessage;
@@ -1844,7 +1834,7 @@ exports.announceScreenReaderMessage = announceScreenReaderMessage;
1844
1834
  */
1845
1835
  function screenReaderSpeech(text) {
1846
1836
  const ariaSpeechElement = document.createElement('div');
1847
- ariaSpeechElement.setAttribute("style", "border: 0;clip: rect(0 0 0 0);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;white-space: nowrap;");
1837
+ ariaSpeechElement.setAttribute('style', 'border: 0;clip: rect(0 0 0 0);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;white-space: nowrap;');
1848
1838
  document.body.append(ariaSpeechElement);
1849
1839
  ariaSpeechElement.ariaLive = 'assertive';
1850
1840
  setTimeout(() => {
@@ -128,9 +128,7 @@ class CalendarWidget extends InputWidget_1.default {
128
128
  this.emit('blur');
129
129
  }
130
130
  };
131
- Formio_1.Formio.requireLibrary('flatpickr-css', 'flatpickr', [
132
- { type: 'styles', src: `${Formio_1.Formio.cdn['flatpickr-formio']}/flatpickr.min.css` },
133
- ], true);
131
+ Formio_1.Formio.requireLibrary('flatpickr-css', 'flatpickr', [{ type: 'styles', src: `${Formio_1.Formio.cdn['flatpickr-formio']}/flatpickr.min.css` }], true);
134
132
  if (this.component.shortcutButtons) {
135
133
  this.component.shortcutButtons = this.component.shortcutButtons.filter((btn) => btn.label && btn.onClick);
136
134
  }
@@ -390,9 +388,7 @@ class CalendarWidget extends InputWidget_1.default {
390
388
  this._input.removeAttribute('id');
391
389
  this._input.removeAttribute('aria-labelledby');
392
390
  this._input.removeAttribute('aria-required');
393
- const excludedFromMaskFormats = [
394
- 'MMMM',
395
- ];
391
+ const excludedFromMaskFormats = ['MMMM'];
396
392
  if (!this.settings.readOnly &&
397
393
  !lodash_1.default.some(excludedFromMaskFormats, (format) => lodash_1.default.includes(this.settings.format, format))) {
398
394
  // Enforce the input mask of the format.
package/lib/mjs/Embed.js CHANGED
@@ -14,7 +14,7 @@ export class Formio {
14
14
  Formio._formioReady = ready;
15
15
  Formio._formioReadyReject = reject;
16
16
  });
17
- static version = '5.4.0';
17
+ static version = '5.4.2';
18
18
  static setLicense(license, norecurse = false) {
19
19
  Formio.license = license;
20
20
  if (!norecurse && Formio.FormioClass) {
@@ -155,10 +155,10 @@ export class Formio {
155
155
  if (!liveRegion) {
156
156
  liveRegion = Formio.createElement('div', {
157
157
  id: 'formio-announcements',
158
- 'role': 'status',
158
+ role: 'status',
159
159
  'aria-live': 'polite',
160
160
  'aria-atomic': 'true',
161
- style: 'position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);'
161
+ style: 'position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);',
162
162
  });
163
163
  document.body.appendChild(liveRegion);
164
164
  }
@@ -265,9 +265,7 @@ export class Formio {
265
265
  Formio.cdn = new CDN(Formio.config.cdn, Formio.config.cdnUrls || {});
266
266
  Formio.config.libs = Formio.config.libs || {
267
267
  uswds: {
268
- dependencies: [
269
- 'fontawesome',
270
- ],
268
+ dependencies: ['fontawesome'],
271
269
  js: `${Formio.cdn.uswds}/uswds.min.js`,
272
270
  css: `${Formio.cdn.uswds}/uswds.min.css`,
273
271
  use: true,
@@ -285,15 +283,11 @@ export class Formio {
285
283
  }`,
286
284
  },
287
285
  bootstrap4: {
288
- dependencies: [
289
- 'fontawesome',
290
- ],
286
+ dependencies: ['fontawesome'],
291
287
  css: `${Formio.cdn.bootstrap4}/css/bootstrap.min.css`,
292
288
  },
293
289
  bootstrap: {
294
- dependencies: [
295
- 'bootstrap-icons',
296
- ],
290
+ dependencies: ['bootstrap-icons'],
297
291
  css: `${Formio.cdn.bootstrap}/css/bootstrap.min.css`,
298
292
  },
299
293
  'bootstrap-icons': {
@@ -333,9 +327,7 @@ export class Formio {
333
327
  'yeti',
334
328
  ].forEach((template) => {
335
329
  Formio.config.libs[template] = {
336
- dependencies: [
337
- 'bootstrap-icons',
338
- ],
330
+ dependencies: ['bootstrap-icons'],
339
331
  css: `${Formio.cdn.bootswatch}/dist/${template}/bootstrap.min.css`,
340
332
  };
341
333
  });
@@ -376,7 +368,7 @@ export class Formio {
376
368
  // Due to an issue with quill not loading styles in the shadowdom, we need to add quill styles and js to the shadowdom
377
369
  const quill = {
378
370
  js: `${Formio.cdn.quill}/quill.js`,
379
- css: `${Formio.cdn.quill}/quill.snow.css`
371
+ css: `${Formio.cdn.quill}/quill.snow.css`,
380
372
  };
381
373
  await Formio.addLibrary(wrapper, quill, 'quill');
382
374
  }
package/lib/mjs/Form.js CHANGED
@@ -414,10 +414,10 @@ export default class Form extends Element {
414
414
  */
415
415
  build() {
416
416
  if (!this.instance) {
417
- return Promise.reject('Form not ready. Use form.ready promise');
417
+ return Promise.reject(this.t('formNotReady'));
418
418
  }
419
419
  if (!this.element) {
420
- return Promise.reject('No DOM element for form.');
420
+ return Promise.reject(this.t('noFormElement'));
421
421
  }
422
422
  // Add temporary loader.
423
423
  const template = this.options && this.options.template ? this.options.template : 'bootstrap';
@@ -435,7 +435,7 @@ export default class Form extends Element {
435
435
  }
436
436
  render() {
437
437
  if (!this.instance) {
438
- return Promise.reject('Form not ready. Use form.ready promise');
438
+ return Promise.reject(this.t('formNotReady'));
439
439
  }
440
440
  return Promise.resolve(this.instance.render()).then((param) => {
441
441
  this.emit('render', param);
@@ -444,7 +444,7 @@ export default class Form extends Element {
444
444
  }
445
445
  attach(element) {
446
446
  if (!this.instance) {
447
- return Promise.reject('Form not ready. Use form.ready promise');
447
+ return Promise.reject(this.t('formNotReady'));
448
448
  }
449
449
  if (this.element) {
450
450
  delete this.element.component;
package/lib/mjs/Formio.js CHANGED
@@ -4,7 +4,7 @@ import CDN from './CDN';
4
4
  import Providers from './providers';
5
5
  FormioCore.cdn = new CDN();
6
6
  FormioCore.Providers = Providers;
7
- FormioCore.version = '5.4.0';
7
+ FormioCore.version = '5.4.2';
8
8
  CDN.defaultCDN = FormioCore.version.includes('rc')
9
9
  ? 'https://cdn.test-form.io'
10
10
  : 'https://cdn.form.io';
@@ -83,14 +83,7 @@ FormioCore.prototype.deleteFile = function (file, options) {
83
83
  return FormioCore.pluginAlter('wrapFileRequestPromise', request, requestArgs);
84
84
  };
85
85
  // Esnure we proxy the following methods to the FormioEmbed class.
86
- [
87
- 'setBaseUrl',
88
- 'setApiUrl',
89
- 'setAppUrl',
90
- 'setProjectUrl',
91
- 'setPathType',
92
- 'setLicense',
93
- ].forEach((fn) => {
86
+ ['setBaseUrl', 'setApiUrl', 'setAppUrl', 'setProjectUrl', 'setPathType', 'setLicense'].forEach((fn) => {
94
87
  const baseFn = FormioCore[fn];
95
88
  FormioCore[fn] = function (arg) {
96
89
  const retVal = FormioEmbed[fn](arg, true);
@@ -27,10 +27,7 @@ export function embed(config = {}) {
27
27
  let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
28
28
  scriptSrc.pop();
29
29
  let cdnSrc = '';
30
- if ([
31
- 'js',
32
- 'offline',
33
- ].includes(scriptSrc[scriptSrc.length - 1])) {
30
+ if (['js', 'offline'].includes(scriptSrc[scriptSrc.length - 1])) {
34
31
  scriptSrc.pop();
35
32
  scriptSrc = cdnSrc = scriptSrc.join('/');
36
33
  scriptSrc += '/js';
package/lib/mjs/PDF.js CHANGED
@@ -1,6 +1,23 @@
1
1
  import { Formio } from './Formio';
2
2
  import Webform from './Webform';
3
3
  import { fastCloneDeep, eachComponent } from './utils';
4
+ const getIframeOrigin = (iframeElement) => {
5
+ try {
6
+ const origin = new URL(iframeElement.src, window.location.href).origin;
7
+ return origin === 'null' ? null : origin;
8
+ }
9
+ catch (ignoreErr) {
10
+ return null;
11
+ }
12
+ };
13
+ const isTrustedIframeMessage = (event, form) => {
14
+ const iframeWindow = form?.iframeElement?.contentWindow;
15
+ const iframeOrigin = form?.iframeElement && getIframeOrigin(form.iframeElement);
16
+ return Boolean(iframeWindow &&
17
+ iframeOrigin &&
18
+ event.source === iframeWindow &&
19
+ event.origin === iframeOrigin);
20
+ };
4
21
  export default class PDF extends Webform {
5
22
  constructor(element, options) {
6
23
  options.display = 'pdf';
@@ -12,11 +29,11 @@ export default class PDF extends Webform {
12
29
  // Handle an iframe submission.
13
30
  this.on('iframe-submission', (submission) => this.setValue(submission, {
14
31
  fromIframe: true,
15
- noDefault: true
32
+ noDefault: true,
16
33
  }), true);
17
34
  this.on('iframe-change', (submission) => this.setValue(submission, {
18
35
  fromIframe: true,
19
- noDefault: true
36
+ noDefault: true,
20
37
  }), true);
21
38
  this.on('iframe-getIframePositions', (query) => {
22
39
  const iframe = document.getElementById(`iframe-${query.formId}`);
@@ -162,9 +179,7 @@ export default class PDF extends Webform {
162
179
  return '';
163
180
  }
164
181
  let iframeSrc = `${this._form.settings.pdf.src}.html`;
165
- const params = [
166
- `id=${this.id}`,
167
- ];
182
+ const params = [`id=${this.id}`];
168
183
  if (this.options.showCheckboxBackground || this._form.settings.showCheckboxBackground) {
169
184
  params.push('checkboxbackground=1');
170
185
  }
@@ -276,19 +291,23 @@ if (typeof window !== 'undefined') {
276
291
  catch (ignoreErr) {
277
292
  eventData = null;
278
293
  }
279
- // If this form exists, then emit the event within this form.
294
+ // If this form exists and the message came from its PDF iframe, emit the event within this form.
280
295
  if (eventData &&
281
296
  eventData.name &&
282
297
  eventData.formId &&
283
298
  Formio.forms.hasOwnProperty(eventData.formId)) {
299
+ const form = Formio.forms[eventData.formId];
300
+ if (!isTrustedIframeMessage(event, form)) {
301
+ return;
302
+ }
284
303
  if (eventData.compPath) {
285
- const comp = Formio.forms[eventData.formId].getComponent(eventData.compPath);
304
+ const comp = form.getComponent(eventData.compPath);
286
305
  if (comp) {
287
306
  comp.emit(eventData.name, eventData.data);
288
307
  }
289
308
  }
290
309
  else {
291
- Formio.forms[eventData.formId].emit(`iframe-${eventData.name}`, eventData.data);
310
+ form.emit(`iframe-${eventData.name}`, eventData.data);
292
311
  }
293
312
  }
294
313
  });
@@ -194,10 +194,10 @@ export default class PDFBuilder extends WebformBuilder {
194
194
  const progress = Math.floor((event.loaded / event.total) * 100);
195
195
  this.refs.uploadProgress.style.width = `${progress}%`;
196
196
  if (progress > 98) {
197
- this.refs.uploadProgress.innerHTML = this.t('Converting PDF. Please wait.');
197
+ this.refs.uploadProgress.innerHTML = this.t('waitPdfConverting');
198
198
  }
199
199
  else {
200
- this.refs.uploadProgress.innerHTML = `${this.t('Uploading')} ${progress}%`;
200
+ this.refs.uploadProgress.innerHTML = `${this.t('uploading')} ${progress}%`;
201
201
  }
202
202
  }
203
203
  }, `${this.projectUrl}/upload`, {}, 'file')
@@ -241,7 +241,7 @@ export default class PDFBuilder extends WebformBuilder {
241
241
  return;
242
242
  }
243
243
  this.refs.uploadError.style.display = message ? '' : 'none';
244
- this.refs.uploadError.innerHTML = message;
244
+ this.refs.uploadError.innerHTML = this.t(`${message}`);
245
245
  }
246
246
  createForm(options) {
247
247
  // Instantiate the webform from the PDF class instead of Webform
@@ -251,9 +251,7 @@ export default class PDFBuilder extends WebformBuilder {
251
251
  this.webform.on('attach', () => {
252
252
  // If the dropzone exists but has been removed in a PDF rebuild, reinstate it
253
253
  if (this.refs.iframeDropzone &&
254
- ![
255
- ...this.refs.form.children,
256
- ].includes(this.refs.iframeDropzone)) {
254
+ ![...this.refs.form.children].includes(this.refs.iframeDropzone)) {
257
255
  this.prependTo(this.refs.iframeDropzone, this.refs.form);
258
256
  }
259
257
  });
@@ -369,9 +367,7 @@ export default class PDFBuilder extends WebformBuilder {
369
367
  return;
370
368
  }
371
369
  this.refs['sidebar-container'].forEach((container) => {
372
- [
373
- ...container.children,
374
- ].forEach((el) => {
370
+ [...container.children].forEach((el) => {
375
371
  el.draggable = true;
376
372
  el.setAttribute('draggable', true);
377
373
  this.removeEventListener(el, 'dragstart');
@@ -485,7 +481,7 @@ export default class PDFBuilder extends WebformBuilder {
485
481
  name: 'showBuilderErrors',
486
482
  data: {
487
483
  compId: comp.component.id,
488
- errorMessage: `API Key is not unique: ${comp.key}`,
484
+ errorMessage: `${this.t('notUniqueKey')}: ${comp.key}`,
489
485
  },
490
486
  });
491
487
  }
@@ -269,6 +269,7 @@ declare class Webform extends NestedDataComponent {
269
269
  get schema(): any;
270
270
  mergeData(_this: any, _that: any): void;
271
271
  editing: boolean | undefined;
272
+ subFromServer: any;
272
273
  _submission: any;
273
274
  /**
274
275
  * Build the form.
@@ -265,11 +265,7 @@ export default class Webform extends NestedDataComponent {
265
265
  return false;
266
266
  }
267
267
  if (element.nodeName === 'INPUT') {
268
- return ([
269
- 'text',
270
- 'email',
271
- 'password',
272
- ].indexOf(element.type) === -1);
268
+ return ['text', 'email', 'password'].indexOf(element.type) === -1;
273
269
  }
274
270
  return true;
275
271
  }
@@ -542,7 +538,7 @@ export default class Webform extends NestedDataComponent {
542
538
  }
543
539
  if ('schema' in form && compareVersions(form.schema, '1.x') > 0) {
544
540
  this.ready.then(() => {
545
- this.setAlert('alert alert-danger', 'Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.');
541
+ this.setAlert('alert alert-danger', this.t('newFormSchema'));
546
542
  });
547
543
  }
548
544
  // See if they pass a module, and evaluate it if so.
@@ -739,9 +735,7 @@ export default class Webform extends NestedDataComponent {
739
735
  });
740
736
  }
741
737
  get schema() {
742
- const schema = fastCloneDeep(_.omit(this._form, [
743
- 'components',
744
- ]));
738
+ const schema = fastCloneDeep(_.omit(this._form, ['components']));
745
739
  schema.components = [];
746
740
  this.eachComponent((component) => schema.components.push(component.schema));
747
741
  return schema;
@@ -768,10 +762,12 @@ export default class Webform extends NestedDataComponent {
768
762
  if (!this.options.submissionTimezone && submission.metadata && submission.metadata.timezone) {
769
763
  this.options.submissionTimezone = submission.metadata.timezone;
770
764
  }
765
+ this.subFromServer = _.cloneDeep(submission.data);
771
766
  const changed = super.setValue(submission.data, flags);
772
767
  if (!flags.sanitize) {
773
768
  this.mergeData(this.data, submission.data);
774
769
  }
770
+ // GOTCHA(G-FJS01)
775
771
  submission.data = this.data;
776
772
  this._submission = submission;
777
773
  return changed;
@@ -1008,6 +1004,7 @@ export default class Webform extends NestedDataComponent {
1008
1004
  const component = this.getComponent(key);
1009
1005
  if (component) {
1010
1006
  component.focus();
1007
+ component.scrollIntoView();
1011
1008
  }
1012
1009
  }
1013
1010
  }
@@ -1031,9 +1028,7 @@ export default class Webform extends NestedDataComponent {
1031
1028
  showErrors(errors, triggerEvent) {
1032
1029
  this.loading = false;
1033
1030
  if (!Array.isArray(errors)) {
1034
- errors = [
1035
- errors,
1036
- ];
1031
+ errors = [errors];
1037
1032
  }
1038
1033
  if (Array.isArray(this.errors) &&
1039
1034
  // do not show components validation errors in alert for draft submission
@@ -1065,11 +1060,7 @@ export default class Webform extends NestedDataComponent {
1065
1060
  }
1066
1061
  const displayedErrors = [];
1067
1062
  if (errors.length) {
1068
- errors = _.uniqBy(errors, (error) => [
1069
- error.message,
1070
- error.component?.id,
1071
- error.context?.path,
1072
- ].join());
1063
+ errors = _.uniqBy(errors, (error) => [error.message, error.component?.id, error.context?.path].join());
1073
1064
  const createListItem = (message, index) => {
1074
1065
  const err = errors[index];
1075
1066
  const messageFromIndex = !_.isUndefined(index) && errors && errors[index];
@@ -1096,6 +1087,7 @@ export default class Webform extends NestedDataComponent {
1096
1087
  });
1097
1088
  }
1098
1089
  const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
1090
+ // GOTCHA(G-FJS02)
1099
1091
  // Only paint the alert from a subform when the root won't double paint it to avoid a painful flicker
1100
1092
  if (this === this.root || !this.root?.submitted) {
1101
1093
  this.root?.setAlert('danger', errorsList);
@@ -1136,7 +1128,8 @@ export default class Webform extends NestedDataComponent {
1136
1128
  liveRegion.setAttribute('role', 'status');
1137
1129
  liveRegion.setAttribute('aria-live', 'polite');
1138
1130
  liveRegion.setAttribute('aria-atomic', 'true');
1139
- liveRegion.style.cssText = 'position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);';
1131
+ liveRegion.style.cssText =
1132
+ 'position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);';
1140
1133
  document.body.appendChild(liveRegion);
1141
1134
  }
1142
1135
  // Announce the submission completion using VPAT clear-and-reset technique
@@ -1352,11 +1345,7 @@ export default class Webform extends NestedDataComponent {
1352
1345
  };
1353
1346
  }
1354
1347
  // Ensure err is an array.
1355
- err = Array.isArray(err)
1356
- ? err
1357
- : [
1358
- err,
1359
- ];
1348
+ err = Array.isArray(err) ? err : [err];
1360
1349
  return reject(err);
1361
1350
  }
1362
1351
  this.loading = true;
@@ -1407,9 +1396,7 @@ export default class Webform extends NestedDataComponent {
1407
1396
  });
1408
1397
  }
1409
1398
  else if (typeof error === 'string') {
1410
- this.serverErrors = [
1411
- { fromServer: true, level: 'error', message: error },
1412
- ];
1399
+ this.serverErrors = [{ fromServer: true, level: 'error', message: error }];
1413
1400
  }
1414
1401
  }
1415
1402
  executeSubmit(options) {
@@ -1467,7 +1454,7 @@ export default class Webform extends NestedDataComponent {
1467
1454
  }
1468
1455
  submitUrl(URL, headers) {
1469
1456
  if (!URL) {
1470
- return console.warn('Missing URL argument');
1457
+ return console.warn(this.t('missingUrl'));
1471
1458
  }
1472
1459
  const submission = this.submission || {};
1473
1460
  const API_URL = URL;
@@ -1488,7 +1475,7 @@ export default class Webform extends NestedDataComponent {
1488
1475
  })
1489
1476
  .then(() => {
1490
1477
  this.emit('requestDone');
1491
- this.setAlert('success', '<p> Success </p>');
1478
+ this.setAlert('success', `<p> ${this.t('success')} </p>`);
1492
1479
  })
1493
1480
  .catch((e) => {
1494
1481
  const message = `${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`;
@@ -1499,9 +1486,10 @@ export default class Webform extends NestedDataComponent {
1499
1486
  });
1500
1487
  }
1501
1488
  else {
1502
- this.emit('error', 'You should add a URL to this button.');
1503
- this.setAlert('warning', 'You should add a URL to this button.');
1504
- return console.warn('You should add a URL to this button.');
1489
+ const message = this.t('urlNotAttachedToBtn');
1490
+ this.emit('error', message);
1491
+ this.setAlert('warning', message);
1492
+ return console.warn(message);
1505
1493
  }
1506
1494
  }
1507
1495
  triggerCaptcha(components = null) {