@formio/js 5.4.1 → 5.4.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 (227) hide show
  1. package/README.md +11 -5
  2. package/dist/formio.builder.css +1 -0
  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 +1 -0
  8. package/dist/formio.form.js +137 -115
  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 +1 -0
  13. package/dist/formio.full.js +161 -139
  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 +27 -27
  18. package/dist/formio.min.js +1 -1
  19. package/dist/formio.min.js.LICENSE.txt +2 -2
  20. package/dist/formio.utils.js +19 -19
  21. package/dist/formio.utils.min.js +1 -1
  22. package/dist/formio.utils.min.js.LICENSE.txt +2 -2
  23. package/lib/cjs/Element.js +1 -1
  24. package/lib/cjs/Embed.js +8 -16
  25. package/lib/cjs/Form.js +4 -4
  26. package/lib/cjs/Formio.js +2 -9
  27. package/lib/cjs/InlineEmbed.js +1 -4
  28. package/lib/cjs/PDF.js +28 -8
  29. package/lib/cjs/PDFBuilder.js +6 -10
  30. package/lib/cjs/Webform.d.ts +1 -0
  31. package/lib/cjs/Webform.js +19 -34
  32. package/lib/cjs/WebformBuilder.js +27 -68
  33. package/lib/cjs/Wizard.d.ts +2 -0
  34. package/lib/cjs/Wizard.js +59 -31
  35. package/lib/cjs/WizardBuilder.js +5 -15
  36. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
  37. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
  38. package/lib/cjs/addons/index.js +1 -3
  39. package/lib/cjs/components/_classes/component/Component.d.ts +5 -5
  40. package/lib/cjs/components/_classes/component/Component.js +60 -132
  41. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
  42. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
  43. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
  44. package/lib/cjs/components/_classes/field/Field.js +1 -4
  45. package/lib/cjs/components/_classes/input/Input.js +2 -2
  46. package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
  47. package/lib/cjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
  48. package/lib/cjs/components/_classes/multivalue/Multivalue.js +8 -26
  49. package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -4
  50. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
  51. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
  52. package/lib/cjs/components/address/Address.js +10 -30
  53. package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -32
  54. package/lib/cjs/components/alert/Alert.js +3 -6
  55. package/lib/cjs/components/button/Button.js +10 -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 +31 -63
  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 +52 -75
  73. package/lib/cjs/components/file/editForm/File.edit.display.js +1 -5
  74. package/lib/cjs/components/file/editForm/File.edit.file.d.ts +9 -3
  75. package/lib/cjs/components/file/editForm/File.edit.file.js +27 -52
  76. package/lib/cjs/components/form/Form.js +5 -7
  77. package/lib/cjs/components/html/HTML.d.ts +1 -1
  78. package/lib/cjs/components/html/HTML.js +8 -10
  79. package/lib/cjs/components/number/Number.js +7 -5
  80. package/lib/cjs/components/panel/editForm/Panel.edit.display.js +3 -12
  81. package/lib/cjs/components/password/Password.js +1 -4
  82. package/lib/cjs/components/radio/Radio.js +17 -17
  83. package/lib/cjs/components/radio/editForm/Radio.edit.data.js +4 -14
  84. package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -6
  85. package/lib/cjs/components/select/Select.js +48 -92
  86. package/lib/cjs/components/select/editForm/Select.edit.data.js +37 -182
  87. package/lib/cjs/components/select/editForm/Select.edit.validation.js +1 -9
  88. package/lib/cjs/components/selectboxes/SelectBoxes.js +3 -6
  89. package/lib/cjs/components/signature/Signature.d.ts +1 -1
  90. package/lib/cjs/components/signature/Signature.js +21 -24
  91. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +4 -10
  92. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +8 -12
  93. package/lib/cjs/components/survey/Survey.js +6 -17
  94. package/lib/cjs/components/survey/editForm/Survey.edit.data.js +4 -12
  95. package/lib/cjs/components/table/editForm/Table.edit.display.js +3 -3
  96. package/lib/cjs/components/tabs/Tabs.js +4 -19
  97. package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
  98. package/lib/cjs/components/tags/Tags.js +4 -14
  99. package/lib/cjs/components/textarea/TextArea.js +8 -15
  100. package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
  101. package/lib/cjs/components/textfield/TextField.js +4 -4
  102. package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +2 -8
  103. package/lib/cjs/components/time/Time.js +1 -4
  104. package/lib/cjs/components/time/editForm/Time.edit.display.js +1 -4
  105. package/lib/cjs/formio.form.js +5 -5
  106. package/lib/cjs/package.json +1 -1
  107. package/lib/cjs/providers/address/AddressProvider.js +1 -1
  108. package/lib/cjs/providers/address/GoogleAddressProvider.js +1 -3
  109. package/lib/cjs/providers/processor/fileProcessor.js +1 -3
  110. package/lib/cjs/providers/storage/azure.js +5 -6
  111. package/lib/cjs/providers/storage/indexeddb.js +17 -18
  112. package/lib/cjs/providers/storage/s3.js +3 -14
  113. package/lib/cjs/providers/storage/url.js +13 -2
  114. package/lib/cjs/providers/storage/xhr.js +19 -28
  115. package/lib/cjs/templates/Templates.js +1 -0
  116. package/lib/cjs/templates/index.d.ts +1 -0
  117. package/lib/cjs/translations/en.d.ts +237 -82
  118. package/lib/cjs/translations/en.js +9 -82
  119. package/lib/cjs/utils/ChoicesWrapper.js +1 -1
  120. package/lib/cjs/utils/builder.js +5 -26
  121. package/lib/cjs/utils/i18n.d.ts +5 -2
  122. package/lib/cjs/utils/i18n.js +33 -12
  123. package/lib/cjs/utils/utils.js +37 -47
  124. package/lib/cjs/widgets/CalendarWidget.js +2 -6
  125. package/lib/mjs/Element.js +1 -1
  126. package/lib/mjs/Embed.js +8 -16
  127. package/lib/mjs/Form.js +4 -4
  128. package/lib/mjs/Formio.js +2 -9
  129. package/lib/mjs/InlineEmbed.js +1 -4
  130. package/lib/mjs/PDF.js +27 -8
  131. package/lib/mjs/PDFBuilder.js +6 -10
  132. package/lib/mjs/Webform.d.ts +1 -0
  133. package/lib/mjs/Webform.js +19 -31
  134. package/lib/mjs/WebformBuilder.js +27 -68
  135. package/lib/mjs/Wizard.d.ts +2 -0
  136. package/lib/mjs/Wizard.js +54 -27
  137. package/lib/mjs/WizardBuilder.js +5 -15
  138. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
  139. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
  140. package/lib/mjs/addons/index.js +1 -3
  141. package/lib/mjs/components/_classes/component/Component.d.ts +5 -5
  142. package/lib/mjs/components/_classes/component/Component.js +59 -132
  143. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
  144. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
  145. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
  146. package/lib/mjs/components/_classes/field/Field.js +1 -4
  147. package/lib/mjs/components/_classes/input/Input.js +2 -2
  148. package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
  149. package/lib/mjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
  150. package/lib/mjs/components/_classes/multivalue/Multivalue.js +8 -26
  151. package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -4
  152. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
  153. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
  154. package/lib/mjs/components/address/Address.js +10 -30
  155. package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -32
  156. package/lib/mjs/components/alert/Alert.js +3 -6
  157. package/lib/mjs/components/button/Button.js +9 -16
  158. package/lib/mjs/components/button/editForm/Button.edit.display.js +8 -32
  159. package/lib/mjs/components/checkbox/Checkbox.js +4 -10
  160. package/lib/mjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
  161. package/lib/mjs/components/columns/Columns.js +5 -17
  162. package/lib/mjs/components/container/Container.js +1 -3
  163. package/lib/mjs/components/currency/Currency.js +2 -7
  164. package/lib/mjs/components/datagrid/DataGrid.js +30 -63
  165. package/lib/mjs/components/datamap/DataMap.js +12 -18
  166. package/lib/mjs/components/datetime/DateTime.js +2 -6
  167. package/lib/mjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
  168. package/lib/mjs/components/day/Day.js +12 -70
  169. package/lib/mjs/components/day/editForm/Day.edit.day.js +1 -3
  170. package/lib/mjs/components/day/editForm/Day.edit.month.js +1 -3
  171. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -0
  172. package/lib/mjs/components/editgrid/EditGrid.js +18 -44
  173. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
  174. package/lib/mjs/components/file/File.js +52 -75
  175. package/lib/mjs/components/file/editForm/File.edit.display.js +1 -5
  176. package/lib/mjs/components/file/editForm/File.edit.file.d.ts +9 -3
  177. package/lib/mjs/components/file/editForm/File.edit.file.js +27 -52
  178. package/lib/mjs/components/form/Form.js +5 -7
  179. package/lib/mjs/components/html/HTML.d.ts +1 -1
  180. package/lib/mjs/components/html/HTML.js +8 -10
  181. package/lib/mjs/components/number/Number.js +7 -5
  182. package/lib/mjs/components/panel/editForm/Panel.edit.display.js +3 -12
  183. package/lib/mjs/components/password/Password.js +1 -4
  184. package/lib/mjs/components/radio/Radio.js +17 -17
  185. package/lib/mjs/components/radio/editForm/Radio.edit.data.js +4 -14
  186. package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -6
  187. package/lib/mjs/components/select/Select.js +51 -95
  188. package/lib/mjs/components/select/editForm/Select.edit.data.js +37 -182
  189. package/lib/mjs/components/select/editForm/Select.edit.validation.js +1 -9
  190. package/lib/mjs/components/selectboxes/SelectBoxes.js +3 -6
  191. package/lib/mjs/components/signature/Signature.d.ts +1 -1
  192. package/lib/mjs/components/signature/Signature.js +20 -23
  193. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +4 -10
  194. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +6 -12
  195. package/lib/mjs/components/survey/Survey.js +6 -17
  196. package/lib/mjs/components/survey/editForm/Survey.edit.data.js +4 -12
  197. package/lib/mjs/components/table/editForm/Table.edit.display.js +3 -3
  198. package/lib/mjs/components/tabs/Tabs.js +4 -19
  199. package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
  200. package/lib/mjs/components/tags/Tags.js +4 -14
  201. package/lib/mjs/components/textarea/TextArea.js +8 -15
  202. package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
  203. package/lib/mjs/components/textfield/TextField.js +4 -4
  204. package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +2 -8
  205. package/lib/mjs/components/time/Time.js +1 -4
  206. package/lib/mjs/components/time/editForm/Time.edit.display.js +1 -4
  207. package/lib/mjs/formio.form.js +6 -6
  208. package/lib/mjs/package.json +1 -1
  209. package/lib/mjs/providers/address/AddressProvider.js +1 -1
  210. package/lib/mjs/providers/address/GoogleAddressProvider.js +1 -3
  211. package/lib/mjs/providers/processor/fileProcessor.js +1 -3
  212. package/lib/mjs/providers/storage/azure.js +5 -6
  213. package/lib/mjs/providers/storage/indexeddb.js +17 -18
  214. package/lib/mjs/providers/storage/s3.js +3 -14
  215. package/lib/mjs/providers/storage/url.js +13 -2
  216. package/lib/mjs/providers/storage/xhr.js +19 -32
  217. package/lib/mjs/templates/Templates.js +1 -0
  218. package/lib/mjs/templates/index.d.ts +1 -0
  219. package/lib/mjs/translations/en.d.ts +237 -82
  220. package/lib/mjs/translations/en.js +88 -0
  221. package/lib/mjs/utils/ChoicesWrapper.js +1 -1
  222. package/lib/mjs/utils/builder.js +5 -26
  223. package/lib/mjs/utils/i18n.d.ts +5 -2
  224. package/lib/mjs/utils/i18n.js +33 -12
  225. package/lib/mjs/utils/utils.js +37 -47
  226. package/lib/mjs/widgets/CalendarWidget.js +2 -6
  227. package/package.json +6 -4
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.I18n = void 0;
7
7
  const Evaluator_1 = require("./Evaluator");
8
8
  const i18n_1 = __importDefault(require("../i18n"));
9
+ const lodash_1 = require("lodash");
10
+ const core_1 = require("@formio/core");
9
11
  const i18Defaults = {};
10
12
  for (const lang in i18n_1.default.resources) {
11
13
  if (i18n_1.default.resources.hasOwnProperty(lang)) {
@@ -17,14 +19,29 @@ for (const lang in i18n_1.default.resources) {
17
19
  */
18
20
  class I18n {
19
21
  constructor(languages = {}) {
20
- this.languages = i18Defaults;
22
+ var _a;
23
+ this.languages = (0, core_1.fastCloneDeep)(I18n.languages || {});
24
+ this.defaultKeys = ((_a = I18n.languages) === null || _a === void 0 ? void 0 : _a.en) || {};
21
25
  this.language = 'en';
22
26
  this.originalLanguage = 'en';
23
27
  this.currentLanguage = i18Defaults.en;
24
28
  this.setLanguages(languages);
25
29
  this.changeLanguage(this.language);
26
30
  }
27
- setLanguages(languages) {
31
+ static setDefaultTranslations(languages) {
32
+ if ((0, lodash_1.isEmpty)(languages)) {
33
+ return;
34
+ }
35
+ for (const lang in languages) {
36
+ if (lang !== 'language' && languages.hasOwnProperty(lang)) {
37
+ if (!this.languages[lang]) {
38
+ this.languages[lang] = {};
39
+ }
40
+ this.languages[lang] = Object.assign(Object.assign({}, languages[lang]), this.languages[lang]);
41
+ }
42
+ }
43
+ }
44
+ setLanguages(languages, noDefaultOverride) {
28
45
  if (languages.resources) {
29
46
  for (const lang in languages.resources) {
30
47
  if (languages.resources.hasOwnProperty(lang)) {
@@ -51,7 +68,8 @@ class I18n {
51
68
  if (!this.languages[lang]) {
52
69
  this.languages[lang] = {};
53
70
  }
54
- this.languages[lang] = Object.assign(Object.assign({}, this.languages[lang]), languages[lang]);
71
+ this.languages[lang] = noDefaultOverride
72
+ ? Object.assign(Object.assign({}, languages[lang]), this.languages[lang]) : Object.assign(Object.assign({}, this.languages[lang]), languages[lang]);
55
73
  }
56
74
  }
57
75
  }
@@ -60,13 +78,7 @@ class I18n {
60
78
  }
61
79
  dir(lang = '') {
62
80
  lang = lang || this.language;
63
- const rtls = [
64
- 'ar',
65
- 'he',
66
- 'fa',
67
- 'ps',
68
- 'ur',
69
- ];
81
+ const rtls = ['ar', 'he', 'fa', 'ps', 'ur'];
70
82
  return rtls.includes(lang) ? 'rtl' : 'ltr';
71
83
  }
72
84
  static createInstance() {
@@ -88,14 +100,23 @@ class I18n {
88
100
  }
89
101
  t(text, ...args) {
90
102
  var _a;
91
- if (this.currentLanguage[text]) {
103
+ let currentTranslation = this.currentLanguage[text];
104
+ // provide compatibility with cases where the entire phrase is used as a key
105
+ // get the phrase that is possibly being used as a key
106
+ const defaultKey = this.defaultKeys[text];
107
+ if (defaultKey && this.currentLanguage[defaultKey]) {
108
+ // get translation using the phrase as a key
109
+ currentTranslation = this.currentLanguage[defaultKey];
110
+ }
111
+ if (currentTranslation) {
92
112
  const customTranslationFieldName = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.field;
93
113
  if (customTranslationFieldName && this.currentLanguage[customTranslationFieldName]) {
94
114
  args[0].field = this.currentLanguage[customTranslationFieldName];
95
115
  }
96
- return Evaluator_1.Evaluator.interpolateString(this.currentLanguage[text], ...args);
116
+ return Evaluator_1.Evaluator.interpolateString(currentTranslation, ...args);
97
117
  }
98
118
  return Evaluator_1.Evaluator.interpolateString(text, ...args);
99
119
  }
100
120
  }
101
121
  exports.I18n = I18n;
122
+ I18n.languages = i18Defaults;
@@ -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,19 +1800,19 @@ 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 = "";
1815
+ el.textContent = '';
1826
1816
  setTimeout(() => {
1827
1817
  el.textContent = combinedMessage;
1828
1818
  }, 50);
@@ -1831,7 +1821,7 @@ function announceScreenReaderMessage(component, value, index = 0, forFocus = fal
1831
1821
  }
1832
1822
  clearTimeout(el._announceTimer);
1833
1823
  el._announceTimer = setTimeout(() => {
1834
- el.textContent = "";
1824
+ el.textContent = '';
1835
1825
  setTimeout(() => {
1836
1826
  el.textContent = combinedMessage;
1837
1827
  }, 50);
@@ -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.
@@ -546,7 +546,7 @@ export default class Element {
546
546
  interpolate(string, data, options = {}) {
547
547
  if (typeof string !== 'function' &&
548
548
  (this.component.content || this.component.html) &&
549
- !FormioUtils.Evaluator.templateSettings.interpolate.test(string)) {
549
+ !(new RegExp(FormioUtils.Evaluator.templateSettings.interpolate)).test(string)) {
550
550
  string = FormioUtils.translateHTMLTemplate(String(string), (value) => this.t(value));
551
551
  }
552
552
  if (this.component.filter === string && !this.options.building) {
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.1';
17
+ static version = '5.4.3';
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.1';
7
+ FormioCore.version = '5.4.3';
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.