@formio/js 5.0.0-rc.39 → 5.0.0-rc.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. package/dist/formio.builder.css +2 -2
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.js +1 -1
  4. package/dist/formio.embed.min.js +1 -1
  5. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  6. package/dist/formio.form.css +2 -2
  7. package/dist/formio.form.js +5335 -2376
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.form.min.js.LICENSE.txt +23 -5
  11. package/dist/formio.full.css +2 -2
  12. package/dist/formio.full.js +5663 -2696
  13. package/dist/formio.full.min.css +1 -1
  14. package/dist/formio.full.min.js +1 -1
  15. package/dist/formio.full.min.js.LICENSE.txt +23 -5
  16. package/dist/formio.js +72 -62
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +1 -1
  19. package/dist/formio.utils.js +105 -96
  20. package/dist/formio.utils.min.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +4 -4
  22. package/lib/cjs/Element.js +1 -0
  23. package/lib/cjs/Embed.js +131 -131
  24. package/lib/cjs/Webform.js +36 -13
  25. package/lib/cjs/WebformBuilder.js +4 -2
  26. package/lib/cjs/Wizard.js +6 -1
  27. package/lib/cjs/components/_classes/component/Component.js +33 -22
  28. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  29. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +8 -0
  30. package/lib/cjs/components/_classes/component/fixtures/comp5.js +2 -2
  31. package/lib/cjs/components/_classes/multivalue/Multivalue.js +2 -2
  32. package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -2
  33. package/lib/cjs/components/address/fixtures/comp3.js +1 -1
  34. package/lib/cjs/components/builder.js +0 -2
  35. package/lib/cjs/components/button/Button.js +7 -1
  36. package/lib/cjs/components/datagrid/DataGrid.js +16 -3
  37. package/lib/cjs/components/datagrid/fixtures/comp-with-allow-calculate-override.js +68 -0
  38. package/lib/cjs/components/datagrid/fixtures/comp6.js +1 -1
  39. package/lib/cjs/components/datagrid/fixtures/index.js +5 -1
  40. package/lib/cjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.js +104 -0
  41. package/lib/cjs/components/editgrid/EditGrid.js +11 -4
  42. package/lib/cjs/components/editgrid/fixtures/formsWithEditGridAndConditions.js +923 -0
  43. package/lib/cjs/components/file/File.js +2 -2
  44. package/lib/cjs/components/file/editForm/File.edit.file.js +1 -1
  45. package/lib/cjs/components/form/Form.js +1 -1
  46. package/lib/cjs/components/html/HTML.js +11 -2
  47. package/lib/cjs/components/html/fixtures/index.js +1 -3
  48. package/lib/cjs/components/index.js +0 -2
  49. package/lib/cjs/components/recaptcha/ReCaptcha.js +46 -46
  50. package/lib/cjs/components/select/Select.js +3 -1
  51. package/lib/cjs/components/select/fixtures/comp20.js +46 -0
  52. package/lib/cjs/components/select/fixtures/comp21.js +106 -0
  53. package/lib/cjs/components/select/fixtures/index.js +5 -1
  54. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  55. package/lib/cjs/components/textfield/TextField.js +63 -3
  56. package/lib/cjs/providers/storage/s3.js +5 -3
  57. package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
  58. package/lib/cjs/providers/storage/url.js +19 -13
  59. package/lib/cjs/providers/storage/util.js +2 -2
  60. package/lib/cjs/templates/Templates.js +4 -4
  61. package/lib/cjs/translations/en.js +10 -6
  62. package/lib/cjs/utils/Evaluator.js +1 -1
  63. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +1 -1
  64. package/lib/cjs/utils/formUtils.js +3 -3
  65. package/lib/cjs/utils/utils.js +4 -19
  66. package/lib/cjs/widgets/CalendarWidget.js +1 -1
  67. package/lib/mjs/Element.js +1 -0
  68. package/lib/mjs/Embed.js +1 -2
  69. package/lib/mjs/FormBuilder.js +1 -2
  70. package/lib/mjs/Webform.js +36 -13
  71. package/lib/mjs/WebformBuilder.js +4 -2
  72. package/lib/mjs/Wizard.js +6 -1
  73. package/lib/mjs/builders/Builders.js +1 -2
  74. package/lib/mjs/components/Components.js +1 -2
  75. package/lib/mjs/components/_classes/component/Component.js +33 -24
  76. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  77. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +8 -0
  78. package/lib/mjs/components/_classes/component/fixtures/comp5.js +2 -2
  79. package/lib/mjs/components/_classes/multivalue/Multivalue.js +2 -2
  80. package/lib/mjs/components/_classes/nested/NestedComponent.js +2 -2
  81. package/lib/mjs/components/address/fixtures/comp3.js +1 -1
  82. package/lib/mjs/components/builder.js +0 -2
  83. package/lib/mjs/components/button/Button.js +7 -1
  84. package/lib/mjs/components/datagrid/DataGrid.js +15 -3
  85. package/lib/mjs/components/datagrid/fixtures/comp-with-allow-calculate-override.js +66 -0
  86. package/lib/mjs/components/datagrid/fixtures/comp6.js +1 -1
  87. package/lib/mjs/components/datagrid/fixtures/index.js +3 -1
  88. package/lib/mjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.js +102 -0
  89. package/lib/mjs/components/editgrid/EditGrid.js +11 -4
  90. package/lib/mjs/components/editgrid/fixtures/formsWithEditGridAndConditions.js +921 -0
  91. package/lib/mjs/components/file/File.js +2 -2
  92. package/lib/mjs/components/file/editForm/File.edit.file.js +1 -1
  93. package/lib/mjs/components/form/Form.js +1 -1
  94. package/lib/mjs/components/html/HTML.js +10 -2
  95. package/lib/mjs/components/html/fixtures/index.js +1 -2
  96. package/lib/mjs/components/index.js +0 -2
  97. package/lib/mjs/components/recaptcha/ReCaptcha.js +32 -43
  98. package/lib/mjs/components/select/Select.js +3 -1
  99. package/lib/mjs/components/select/fixtures/comp20.js +44 -0
  100. package/lib/mjs/components/select/fixtures/comp21.js +104 -0
  101. package/lib/mjs/components/select/fixtures/index.js +3 -1
  102. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  103. package/lib/mjs/components/textfield/TextField.js +62 -3
  104. package/lib/mjs/displays/Displays.js +1 -2
  105. package/lib/mjs/licenses/Licenses.js +1 -2
  106. package/lib/mjs/providers/Providers.js +1 -2
  107. package/lib/mjs/providers/storage/s3.js +5 -3
  108. package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
  109. package/lib/mjs/providers/storage/url.js +19 -13
  110. package/lib/mjs/templates/Templates.js +1 -1
  111. package/lib/mjs/translations/en.js +10 -6
  112. package/lib/mjs/utils/Evaluator.js +1 -1
  113. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  114. package/lib/mjs/utils/formUtils.js +3 -3
  115. package/lib/mjs/utils/utils.js +2 -16
  116. package/lib/mjs/widgets/CalendarWidget.js +1 -1
  117. package/package.json +21 -20
  118. package/lib/cjs/components/html/fixtures/comp3.js +0 -31
  119. package/lib/cjs/components/resource/Resource.form.js +0 -16
  120. package/lib/cjs/components/resource/Resource.js +0 -39
  121. package/lib/cjs/components/resource/editForm/Resource.edit.display.js +0 -102
  122. package/lib/cjs/components/resource/fixtures/comp1.js +0 -30
  123. package/lib/cjs/components/resource/fixtures/comp2.js +0 -31
  124. package/lib/cjs/components/resource/fixtures/index.js +0 -10
  125. package/lib/mjs/components/html/fixtures/comp3.js +0 -29
  126. package/lib/mjs/components/resource/Resource.form.js +0 -10
  127. package/lib/mjs/components/resource/Resource.js +0 -33
  128. package/lib/mjs/components/resource/editForm/Resource.edit.display.js +0 -100
  129. package/lib/mjs/components/resource/fixtures/comp1.js +0 -28
  130. package/lib/mjs/components/resource/fixtures/comp2.js +0 -29
  131. package/lib/mjs/components/resource/fixtures/index.js +0 -3
@@ -10,11 +10,11 @@
10
10
  * MIT licensed
11
11
  */
12
12
 
13
- /*! @license DOMPurify 3.0.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.7/LICENSE */
14
-
15
13
  /*! @license DOMPurify 3.0.8 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.8/LICENSE */
16
14
 
17
- /*! formiojs v5.0.0-rc.39 | https://unpkg.com/formiojs@5.0.0-rc.39/LICENSE.txt */
15
+ /*! @license DOMPurify 3.0.9 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.9/LICENSE */
16
+
17
+ /*! formiojs v5.0.0-rc.40 | https://unpkg.com/formiojs@5.0.0-rc.40/LICENSE.txt */
18
18
 
19
19
  /**
20
20
  * @license
@@ -35,4 +35,4 @@
35
35
 
36
36
  //! moment.js
37
37
 
38
- //! version : 0.5.44
38
+ //! version : 0.5.45
@@ -539,6 +539,7 @@ class Element {
539
539
  token: Formio_1.Formio.getToken({
540
540
  decode: true
541
541
  }),
542
+ options: this.options,
542
543
  config: this.root && this.root.form && this.root.form.config
543
544
  ? this.root.form.config
544
545
  : ((_a = this.options) === null || _a === void 0 ? void 0 : _a.formConfig)
package/lib/cjs/Embed.js CHANGED
@@ -17,49 +17,49 @@ exports.FormBuilder = exports.Form = exports.Formio = void 0;
17
17
  const CDN_js_1 = __importDefault(require("./CDN.js"));
18
18
  class Formio {
19
19
  static setLicense(license, norecurse = false) {
20
- Formio.license = license;
21
- if (!norecurse && Formio.FormioClass) {
22
- Formio.FormioClass.setLicense(license);
20
+ _a.license = license;
21
+ if (!norecurse && _a.FormioClass) {
22
+ _a.FormioClass.setLicense(license);
23
23
  }
24
24
  }
25
25
  static setBaseUrl(url, norecurse = false) {
26
- Formio.baseUrl = url;
27
- if (!norecurse && Formio.FormioClass) {
28
- Formio.FormioClass.setBaseUrl(url);
26
+ _a.baseUrl = url;
27
+ if (!norecurse && _a.FormioClass) {
28
+ _a.FormioClass.setBaseUrl(url);
29
29
  }
30
30
  }
31
31
  static setApiUrl(url, norecurse = false) {
32
- Formio.baseUrl = url;
33
- if (!norecurse && Formio.FormioClass) {
34
- Formio.FormioClass.setApiUrl(url);
32
+ _a.baseUrl = url;
33
+ if (!norecurse && _a.FormioClass) {
34
+ _a.FormioClass.setApiUrl(url);
35
35
  }
36
36
  }
37
37
  static setProjectUrl(url, norecurse = false) {
38
- Formio.projectUrl = url;
39
- if (!norecurse && Formio.FormioClass) {
40
- Formio.FormioClass.setProjectUrl(url);
38
+ _a.projectUrl = url;
39
+ if (!norecurse && _a.FormioClass) {
40
+ _a.FormioClass.setProjectUrl(url);
41
41
  }
42
42
  }
43
43
  static setAppUrl(url, norecurse = false) {
44
- Formio.projectUrl = url;
45
- if (!norecurse && Formio.FormioClass) {
46
- Formio.FormioClass.setAppUrl(url);
44
+ _a.projectUrl = url;
45
+ if (!norecurse && _a.FormioClass) {
46
+ _a.FormioClass.setAppUrl(url);
47
47
  }
48
48
  }
49
49
  static setPathType(type, norecurse = false) {
50
- Formio.pathType = type;
51
- if (!norecurse && Formio.FormioClass) {
52
- Formio.FormioClass.setPathType(type);
50
+ _a.pathType = type;
51
+ if (!norecurse && _a.FormioClass) {
52
+ _a.FormioClass.setPathType(type);
53
53
  }
54
54
  }
55
55
  static debug(...args) {
56
- if (Formio.config.debug) {
56
+ if (_a.config.debug) {
57
57
  console.log(...args);
58
58
  }
59
59
  }
60
60
  static clearCache() {
61
- if (Formio.FormioClass) {
62
- Formio.FormioClass.clearCache();
61
+ if (_a.FormioClass) {
62
+ _a.FormioClass.clearCache();
63
63
  }
64
64
  }
65
65
  static global(prop, flag = '') {
@@ -67,15 +67,15 @@ class Formio {
67
67
  if (flag && globalValue && !globalValue[flag]) {
68
68
  return null;
69
69
  }
70
- Formio.debug(`Getting global ${prop}`, globalValue);
70
+ _a.debug(`Getting global ${prop}`, globalValue);
71
71
  return globalValue;
72
72
  }
73
73
  static use(module) {
74
- if (Formio.FormioClass && Formio.FormioClass.isRenderer) {
75
- Formio.FormioClass.use(module);
74
+ if (_a.FormioClass && _a.FormioClass.isRenderer) {
75
+ _a.FormioClass.use(module);
76
76
  }
77
77
  else {
78
- Formio.modules.push(module);
78
+ _a.modules.push(module);
79
79
  }
80
80
  }
81
81
  static createElement(type, attrs, children) {
@@ -84,42 +84,42 @@ class Formio {
84
84
  element.setAttribute(key, attrs[key]);
85
85
  });
86
86
  (children || []).forEach(child => {
87
- element.appendChild(Formio.createElement(child.tag, child.attrs, child.children));
87
+ element.appendChild(_a.createElement(child.tag, child.attrs, child.children));
88
88
  });
89
89
  return element;
90
90
  }
91
- static addScript(wrapper, src, name, flag = '') {
92
- return __awaiter(this, void 0, void 0, function* () {
91
+ static addScript(wrapper_1, src_1, name_1) {
92
+ return __awaiter(this, arguments, void 0, function* (wrapper, src, name, flag = '') {
93
93
  if (!src) {
94
94
  return Promise.resolve();
95
95
  }
96
96
  if (typeof src !== 'string' && src.length) {
97
- return Promise.all(src.map(ref => Formio.addScript(wrapper, ref)));
97
+ return Promise.all(src.map(ref => _a.addScript(wrapper, ref)));
98
98
  }
99
- if (name && Formio.global(name, flag)) {
100
- Formio.debug(`${name} already loaded.`);
101
- return Promise.resolve(Formio.global(name));
99
+ if (name && _a.global(name, flag)) {
100
+ _a.debug(`${name} already loaded.`);
101
+ return Promise.resolve(_a.global(name));
102
102
  }
103
- Formio.debug('Adding Script', src);
103
+ _a.debug('Adding Script', src);
104
104
  try {
105
- wrapper.appendChild(Formio.createElement('script', {
105
+ wrapper.appendChild(_a.createElement('script', {
106
106
  src
107
107
  }));
108
108
  }
109
109
  catch (err) {
110
- Formio.debug(err);
110
+ _a.debug(err);
111
111
  return Promise.resolve();
112
112
  }
113
113
  if (!name) {
114
114
  return Promise.resolve();
115
115
  }
116
116
  return new Promise((resolve) => {
117
- Formio.debug(`Waiting to load ${name}`);
117
+ _a.debug(`Waiting to load ${name}`);
118
118
  const wait = setInterval(() => {
119
- if (Formio.global(name, flag)) {
119
+ if (_a.global(name, flag)) {
120
120
  clearInterval(wait);
121
- Formio.debug(`${name} loaded.`);
122
- resolve(Formio.global(name));
121
+ _a.debug(`${name} loaded.`);
122
+ resolve(_a.global(name));
123
123
  }
124
124
  }, 100);
125
125
  });
@@ -131,11 +131,11 @@ class Formio {
131
131
  return;
132
132
  }
133
133
  if (typeof href !== 'string' && href.length) {
134
- href.forEach(ref => Formio.addStyles(wrapper, ref));
134
+ href.forEach(ref => _a.addStyles(wrapper, ref));
135
135
  return;
136
136
  }
137
- Formio.debug('Adding Styles', href);
138
- wrapper.appendChild(Formio.createElement('link', {
137
+ _a.debug('Adding Styles', href);
138
+ wrapper.appendChild(_a.createElement('link', {
139
139
  rel: 'stylesheet',
140
140
  href
141
141
  }));
@@ -143,19 +143,19 @@ class Formio {
143
143
  }
144
144
  static submitDone(instance, submission) {
145
145
  return __awaiter(this, void 0, void 0, function* () {
146
- Formio.debug('Submision Complete', submission);
147
- const successMessage = (Formio.config.success || '').toString();
146
+ _a.debug('Submision Complete', submission);
147
+ const successMessage = (_a.config.success || '').toString();
148
148
  if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {
149
149
  instance.element.innerHTML = `<div class="alert-success" role="alert">${successMessage}</div>`;
150
150
  }
151
- let returnUrl = Formio.config.redirect;
151
+ let returnUrl = _a.config.redirect;
152
152
  // Allow form based configuration for return url.
153
153
  if (!returnUrl &&
154
154
  (instance._form &&
155
155
  instance._form.settings &&
156
156
  (instance._form.settings.returnUrl ||
157
157
  instance._form.settings.redirect))) {
158
- Formio.debug('Return url found in form configuration');
158
+ _a.debug('Return url found in form configuration');
159
159
  returnUrl = instance._form.settings.returnUrl || instance._form.settings.redirect;
160
160
  }
161
161
  if (returnUrl) {
@@ -167,7 +167,7 @@ class Formio {
167
167
  if (!isOrigin && formSrc) {
168
168
  returnUrl += `&form=${encodeURIComponent(formSrc)}`;
169
169
  }
170
- Formio.debug('Return URL', returnUrl);
170
+ _a.debug('Return URL', returnUrl);
171
171
  window.location.href = returnUrl;
172
172
  if (isOrigin) {
173
173
  window.location.reload();
@@ -177,9 +177,9 @@ class Formio {
177
177
  }
178
178
  // Return the full script if the builder is being used.
179
179
  static formioScript(script, builder) {
180
- builder = builder || Formio.config.includeBuilder;
181
- if (Formio.fullAdded || builder) {
182
- Formio.fullAdded = true;
180
+ builder = builder || _a.config.includeBuilder;
181
+ if (_a.fullAdded || builder) {
182
+ _a.fullAdded = true;
183
183
  return script.replace('formio.form', 'formio.full');
184
184
  }
185
185
  return script;
@@ -191,28 +191,28 @@ class Formio {
191
191
  }
192
192
  if (lib.dependencies) {
193
193
  for (let i = 0; i < lib.dependencies.length; i++) {
194
- yield Formio.addLibrary(wrapper, Formio.cdn.libs[lib.dependencies[i]]);
194
+ yield _a.addLibrary(wrapper, _a.cdn.libs[lib.dependencies[i]]);
195
195
  }
196
196
  }
197
197
  if (lib.css) {
198
- yield Formio.addStyles(wrapper, lib.css);
198
+ yield _a.addStyles(wrapper, lib.css);
199
199
  }
200
200
  if (lib.js) {
201
- const module = yield Formio.addScript(wrapper, lib.js, lib.use ? name : false);
201
+ const module = yield _a.addScript(wrapper, lib.js, lib.use ? name : false);
202
202
  if (lib.use) {
203
- Formio.debug(`Using ${name}`);
203
+ _a.debug(`Using ${name}`);
204
204
  const options = lib.options || {};
205
- if (!options.license && Formio.license) {
206
- options.license = Formio.license;
205
+ if (!options.license && _a.license) {
206
+ options.license = _a.license;
207
207
  }
208
- Formio.use((typeof lib.use === 'function' ? lib.use(module) : module), options);
208
+ _a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);
209
209
  }
210
210
  }
211
211
  });
212
212
  }
213
213
  static addLoader(wrapper) {
214
214
  return __awaiter(this, void 0, void 0, function* () {
215
- wrapper.appendChild(Formio.createElement('div', {
215
+ wrapper.appendChild(_a.createElement('div', {
216
216
  'class': 'formio-loader'
217
217
  }, [{
218
218
  tag: 'div',
@@ -229,39 +229,39 @@ class Formio {
229
229
  });
230
230
  }
231
231
  // eslint-disable-next-line max-statements
232
- static init(element, options = {}, builder = false) {
233
- return __awaiter(this, void 0, void 0, function* () {
234
- Formio.cdn = new CDN_js_1.default(Formio.config.cdn, Formio.config.cdnUrls || {});
235
- Formio.config.libs = Formio.config.libs || {
232
+ static init(element_1) {
233
+ return __awaiter(this, arguments, void 0, function* (element, options = {}, builder = false) {
234
+ _a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});
235
+ _a.config.libs = _a.config.libs || {
236
236
  uswds: {
237
237
  dependencies: ['fontawesome'],
238
- js: `${Formio.cdn.uswds}/uswds.min.js`,
239
- css: `${Formio.cdn.uswds}/uswds.min.css`,
238
+ js: `${_a.cdn.uswds}/uswds.min.js`,
239
+ css: `${_a.cdn.uswds}/uswds.min.css`,
240
240
  use: true
241
241
  },
242
242
  fontawesome: {
243
- css: `${Formio.cdn['font-awesome']}/css/font-awesome.min.css`
243
+ css: `${_a.cdn['font-awesome']}/css/font-awesome.min.css`
244
244
  },
245
245
  bootstrap4: {
246
246
  dependencies: ['fontawesome'],
247
- css: `${Formio.cdn.bootstrap4}/css/bootstrap.min.css`
247
+ css: `${_a.cdn.bootstrap4}/css/bootstrap.min.css`
248
248
  },
249
249
  bootstrap: {
250
250
  dependencies: ['bootstrap-icons'],
251
- css: `${Formio.cdn.bootstrap}/css/bootstrap.min.css`
251
+ css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`
252
252
  },
253
253
  'bootstrap-icons': {
254
- css: `${Formio.cdn['bootstrap-icons']}/css/bootstrap-icons.css`
254
+ css: `${_a.cdn['bootstrap-icons']}/css/bootstrap-icons.css`
255
255
  }
256
256
  };
257
- const id = Formio.config.id || `formio-${Math.random().toString(36).substring(7)}`;
257
+ const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;
258
258
  // Create a new wrapper and add the element inside of a new wrapper.
259
- let wrapper = Formio.createElement('div', {
259
+ let wrapper = _a.createElement('div', {
260
260
  'id': `${id}-wrapper`
261
261
  });
262
262
  element.parentNode.insertBefore(wrapper, element);
263
263
  // If we include the libraries, then we will attempt to run this in shadow dom.
264
- const useShadowDom = Formio.config.includeLibs && (typeof wrapper.attachShadow === 'function');
264
+ const useShadowDom = _a.config.includeLibs && (typeof wrapper.attachShadow === 'function');
265
265
  if (useShadowDom) {
266
266
  wrapper = wrapper.attachShadow({
267
267
  mode: 'open'
@@ -273,48 +273,48 @@ class Formio {
273
273
  // If this is inside of shadow dom, then we need to add the styles and scripts to the shadow dom.
274
274
  const libWrapper = useShadowDom ? wrapper : document.body;
275
275
  // Load the renderer styles.
276
- yield Formio.addStyles(libWrapper, Formio.config.embedCSS || `${Formio.cdn.js}/formio.embed.css`);
276
+ yield _a.addStyles(libWrapper, _a.config.embedCSS || `${_a.cdn.js}/formio.embed.css`);
277
277
  // Add a loader.
278
- Formio.addLoader(wrapper);
279
- const formioSrc = Formio.config.full ? 'formio.full' : 'formio.form';
280
- const renderer = Formio.config.debug ? formioSrc : `${formioSrc}.min`;
281
- Formio.FormioClass = yield Formio.addScript(libWrapper, Formio.formioScript(Formio.config.script || `${Formio.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');
282
- Formio.FormioClass.cdn = Formio.cdn;
283
- Formio.FormioClass.setBaseUrl(options.baseUrl || Formio.baseUrl || Formio.config.base);
284
- Formio.FormioClass.setProjectUrl(options.projectUrl || Formio.projectUrl || Formio.config.project);
285
- Formio.FormioClass.language = Formio.language;
286
- Formio.setLicense(Formio.license || Formio.config.license || false);
287
- Formio.modules.forEach((module) => {
288
- Formio.FormioClass.use(module);
278
+ _a.addLoader(wrapper);
279
+ const formioSrc = _a.config.full ? 'formio.full' : 'formio.form';
280
+ const renderer = _a.config.debug ? formioSrc : `${formioSrc}.min`;
281
+ _a.FormioClass = yield _a.addScript(libWrapper, _a.formioScript(_a.config.script || `${_a.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');
282
+ _a.FormioClass.cdn = _a.cdn;
283
+ _a.FormioClass.setBaseUrl(options.baseUrl || _a.baseUrl || _a.config.base);
284
+ _a.FormioClass.setProjectUrl(options.projectUrl || _a.projectUrl || _a.config.project);
285
+ _a.FormioClass.language = _a.language;
286
+ _a.setLicense(_a.license || _a.config.license || false);
287
+ _a.modules.forEach((module) => {
288
+ _a.FormioClass.use(module);
289
289
  });
290
- if (Formio.icons) {
291
- Formio.FormioClass.icons = Formio.icons;
290
+ if (_a.icons) {
291
+ _a.FormioClass.icons = _a.icons;
292
292
  }
293
- if (Formio.pathType) {
294
- Formio.FormioClass.setPathType(Formio.pathType);
293
+ if (_a.pathType) {
294
+ _a.FormioClass.setPathType(_a.pathType);
295
295
  }
296
296
  // Add libraries if they wish to include the libs.
297
- if (Formio.config.template && Formio.config.includeLibs) {
298
- yield Formio.addLibrary(libWrapper, Formio.config.libs[Formio.config.template], Formio.config.template);
297
+ if (_a.config.template && _a.config.includeLibs) {
298
+ yield _a.addLibrary(libWrapper, _a.config.libs[_a.config.template], _a.config.template);
299
299
  }
300
300
  // Add the premium modules.
301
- if (Formio.config.premium) {
302
- Formio.config.modules.premium = Formio.config.premium;
301
+ if (_a.config.premium) {
302
+ _a.config.modules.premium = _a.config.premium;
303
303
  }
304
304
  // Allow adding dynamic modules.
305
- if (Formio.config.modules) {
306
- for (const name in Formio.config.modules) {
307
- const lib = Formio.config.modules[name];
305
+ if (_a.config.modules) {
306
+ for (const name in _a.config.modules) {
307
+ const lib = _a.config.modules[name];
308
308
  lib.use = lib.use || true;
309
- yield Formio.addLibrary(libWrapper, lib, name);
309
+ yield _a.addLibrary(libWrapper, lib, name);
310
310
  }
311
311
  }
312
- yield Formio.addStyles(libWrapper, Formio.formioScript(Formio.config.style || `${Formio.cdn.js}/${renderer}.css`, builder));
313
- if (Formio.config.before) {
314
- yield Formio.config.before(Formio.FormioClass, element, Formio.config);
312
+ yield _a.addStyles(libWrapper, _a.formioScript(_a.config.style || `${_a.cdn.js}/${renderer}.css`, builder));
313
+ if (_a.config.before) {
314
+ yield _a.config.before(_a.FormioClass, element, _a.config);
315
315
  }
316
- Formio.FormioClass.license = true;
317
- Formio._formioReady(Formio.FormioClass);
316
+ _a.FormioClass.license = true;
317
+ _a._formioReady(_a.FormioClass);
318
318
  return wrapper;
319
319
  });
320
320
  }
@@ -325,48 +325,49 @@ class Formio {
325
325
  if (loader) {
326
326
  wrapper.removeChild(loader);
327
327
  }
328
- Formio.FormioClass.events.emit(readyEvent, instance);
329
- if (Formio.config.after) {
330
- Formio.debug('Calling ready callback');
331
- Formio.config.after(instance, Formio.config);
328
+ _a.FormioClass.events.emit(readyEvent, instance);
329
+ if (_a.config.after) {
330
+ _a.debug('Calling ready callback');
331
+ _a.config.after(instance, _a.config);
332
332
  }
333
333
  return instance;
334
334
  });
335
335
  }
336
336
  // Create a new form.
337
- static createForm(element, form, options = {}) {
338
- return __awaiter(this, void 0, void 0, function* () {
339
- if (Formio.FormioClass) {
340
- return Formio.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));
337
+ static createForm(element_1, form_1) {
338
+ return __awaiter(this, arguments, void 0, function* (element, form, options = {}) {
339
+ if (_a.FormioClass) {
340
+ return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));
341
341
  }
342
- const wrapper = yield Formio.init(element, options);
343
- return Formio.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {
342
+ const wrapper = yield _a.init(element, options);
343
+ return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {
344
344
  // Set the default submission data.
345
- if (Formio.config.submission) {
346
- Formio.debug('Setting submission', Formio.config.submission);
347
- instance.submission = Formio.config.submission;
345
+ if (_a.config.submission) {
346
+ _a.debug('Setting submission', _a.config.submission);
347
+ instance.submission = _a.config.submission;
348
348
  }
349
349
  // Call the after create method.
350
- Formio.afterCreate(instance, wrapper, 'formEmbedded');
350
+ _a.afterCreate(instance, wrapper, 'formEmbedded');
351
351
  return instance;
352
352
  });
353
353
  });
354
354
  }
355
355
  // Create a form builder.
356
- static builder(element, form, options = {}) {
357
- var _b;
358
- return __awaiter(this, void 0, void 0, function* () {
359
- if ((_b = Formio.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {
360
- return Formio.FormioClass.builder(element, form, options);
356
+ static builder(element_1, form_1) {
357
+ return __awaiter(this, arguments, void 0, function* (element, form, options = {}) {
358
+ var _a;
359
+ if ((_a = _a.FormioClass) === null || _a === void 0 ? void 0 : _a.builder) {
360
+ return _a.FormioClass.builder(element, form, options);
361
361
  }
362
- const wrapper = yield Formio.init(element, options, true);
363
- return Formio.FormioClass.builder(element, form, options).then((instance) => {
364
- Formio.afterCreate(instance, wrapper, 'builderEmbedded');
362
+ const wrapper = yield _a.init(element, options, true);
363
+ return _a.FormioClass.builder(element, form, options).then((instance) => {
364
+ _a.afterCreate(instance, wrapper, 'builderEmbedded');
365
365
  return instance;
366
366
  });
367
367
  });
368
368
  }
369
369
  }
370
+ exports.Formio = Formio;
370
371
  _a = Formio;
371
372
  Formio.FormioClass = null;
372
373
  Formio.config = {};
@@ -374,25 +375,24 @@ Formio.modules = [];
374
375
  Formio.icons = '';
375
376
  Formio.license = '';
376
377
  Formio.formioReady = new Promise((ready, reject) => {
377
- Formio._formioReady = ready;
378
- Formio._formioReadyReject = reject;
378
+ _a._formioReady = ready;
379
+ _a._formioReadyReject = reject;
379
380
  });
380
381
  Formio.version = 'FORMIO_VERSION';
381
382
  // Create a report.
382
383
  Formio.Report = {
383
- create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
384
+ create: (element_1, submission_1, ...args_1) => __awaiter(void 0, [element_1, submission_1, ...args_1], void 0, function* (element, submission, options = {}) {
384
385
  var _b;
385
- if ((_b = Formio.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {
386
- return Formio.FormioClass.Report.create(element, submission, options);
386
+ if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {
387
+ return _a.FormioClass.Report.create(element, submission, options);
387
388
  }
388
- const wrapper = yield Formio.init(element, options, true);
389
- return Formio.FormioClass.Report.create(element, submission, options).then((instance) => {
390
- Formio.afterCreate(instance, wrapper, 'reportEmbedded');
389
+ const wrapper = yield _a.init(element, options, true);
390
+ return _a.FormioClass.Report.create(element, submission, options).then((instance) => {
391
+ _a.afterCreate(instance, wrapper, 'reportEmbedded');
391
392
  return instance;
392
393
  });
393
394
  })
394
395
  };
395
- exports.Formio = Formio;
396
396
  CDN_js_1.default.defaultCDN = Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
397
397
  class Form {
398
398
  constructor(element, form, options) {
@@ -214,11 +214,13 @@ class Webform extends NestedDataComponent_1.default {
214
214
  this.language = this.i18next.language;
215
215
  // See if we need to restore the draft from a user.
216
216
  if (this.options.saveDraft && !this.options.skipDraftRestore) {
217
- const user = Formio_1.Formio.getUser();
218
- // Only restore a draft if the submission isn't explicitly set.
219
- if (user && !this.submissionSet) {
220
- this.restoreDraft(user._id);
221
- }
217
+ this.formReady.then(() => {
218
+ const user = Formio_1.Formio.getUser();
219
+ // Only restore a draft if the submission isn't explicitly set.
220
+ if (user && !this.submissionSet) {
221
+ this.restoreDraft(user._id);
222
+ }
223
+ });
222
224
  }
223
225
  this.component.clearOnHide = false;
224
226
  // Ensure the root is set to this component.
@@ -537,6 +539,10 @@ class Webform extends NestedDataComponent_1.default {
537
539
  if (form && form.properties) {
538
540
  this.options.properties = form.properties;
539
541
  }
542
+ // Use the sanitize config from the form settings or the global sanitize config if it is not provided in the options
543
+ if (!this.options.sanitizeConfig && !this.builderMode) {
544
+ this.options.sanitizeConfig = lodash_1.default.get(form, 'settings.sanitizeConfig') || lodash_1.default.get(form, 'globalSettings.sanitizeConfig');
545
+ }
540
546
  if ('schema' in form && (0, compare_versions_1.compareVersions)(form.schema, '1.x') > 0) {
541
547
  this.ready.then(() => {
542
548
  this.setAlert('alert alert-danger', 'Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.');
@@ -644,6 +650,11 @@ class Webform extends NestedDataComponent_1.default {
644
650
  return this.submissionReadyResolve(submission);
645
651
  }, (err) => this.submissionReadyReject(err)).catch((err) => this.submissionReadyReject(err));
646
652
  }
653
+ handleDraftError(errName, errDetails, restoreDraft) {
654
+ const errorMessage = lodash_1.default.trim(`${this.t(errName)} ${errDetails || ''}`);
655
+ console.warn(errorMessage);
656
+ this.emit(restoreDraft ? 'restoreDraftError' : 'saveDraftError', errDetails || errorMessage);
657
+ }
647
658
  /**
648
659
  * Saves a submission draft.
649
660
  */
@@ -652,11 +663,11 @@ class Webform extends NestedDataComponent_1.default {
652
663
  return;
653
664
  }
654
665
  if (!this.formio) {
655
- console.warn(this.t('saveDraftInstanceError'));
666
+ this.handleDraftError('saveDraftInstanceError');
656
667
  return;
657
668
  }
658
669
  if (!Formio_1.Formio.getUser()) {
659
- console.warn(this.t('saveDraftAuthError'));
670
+ this.handleDraftError('saveDraftAuthError');
660
671
  return;
661
672
  }
662
673
  const draft = (0, utils_1.fastCloneDeep)(this.submission);
@@ -669,6 +680,10 @@ class Webform extends NestedDataComponent_1.default {
669
680
  this.submission._id = sub._id;
670
681
  this.savingDraft = false;
671
682
  this.emit('saveDraft', sub);
683
+ })
684
+ .catch(err => {
685
+ this.savingDraft = false;
686
+ this.handleDraftError('saveDraftError', err);
672
687
  });
673
688
  }
674
689
  }
@@ -679,7 +694,7 @@ class Webform extends NestedDataComponent_1.default {
679
694
  */
680
695
  restoreDraft(userId) {
681
696
  if (!this.formio) {
682
- console.warn(this.t('restoreDraftInstanceError'));
697
+ this.handleDraftError('restoreDraftInstanceError', null, true);
683
698
  return;
684
699
  }
685
700
  this.savingDraft = true;
@@ -701,6 +716,11 @@ class Webform extends NestedDataComponent_1.default {
701
716
  this.draftEnabled = true;
702
717
  this.savingDraft = false;
703
718
  this.emit('restoreDraft', null);
719
+ })
720
+ .catch(err => {
721
+ this.draftEnabled = true;
722
+ this.savingDraft = false;
723
+ this.handleDraftError('restoreDraftError', err, true);
704
724
  });
705
725
  }
706
726
  get schema() {
@@ -879,7 +899,7 @@ class Webform extends NestedDataComponent_1.default {
879
899
  resetValue() {
880
900
  lodash_1.default.each(this.getComponents(), (comp) => (comp.resetValue()));
881
901
  this.setPristine(true);
882
- this.onChange();
902
+ this.onChange({ resetValue: true });
883
903
  }
884
904
  /**
885
905
  * Sets a new alert to display in the error dialog of the form.
@@ -985,7 +1005,7 @@ class Webform extends NestedDataComponent_1.default {
985
1005
  if (!Array.isArray(errors)) {
986
1006
  errors = [errors];
987
1007
  }
988
- errors = errors.concat(this.serverErrors || []);
1008
+ errors = errors.concat(this.customErrors);
989
1009
  if (!errors.length) {
990
1010
  this.setAlert(false);
991
1011
  return;
@@ -1097,16 +1117,17 @@ class Webform extends NestedDataComponent_1.default {
1097
1117
  error = this.normalizeError(error);
1098
1118
  this.submitting = false;
1099
1119
  this.setPristine(false);
1100
- this.emit('submitError', error);
1120
+ this.emit('submitError', error || this.errors);
1101
1121
  // Allow for silent cancellations (no error message, no submit button error state)
1102
1122
  if (error && error.silent) {
1103
1123
  this.emit('change', { isValid: true }, { silent: true });
1104
1124
  return false;
1105
1125
  }
1106
- this.showErrors(error, true);
1126
+ const errors = this.showErrors(error, true);
1107
1127
  if (this.root && this.root.alert) {
1108
1128
  this.scrollIntoView(this.root.alert);
1109
1129
  }
1130
+ return errors;
1110
1131
  }
1111
1132
  /**
1112
1133
  * Trigger the change event for this form.
@@ -1130,7 +1151,9 @@ class Webform extends NestedDataComponent_1.default {
1130
1151
  value.isValid = errors.length === 0;
1131
1152
  this.loading = false;
1132
1153
  if (this.submitted) {
1133
- this.showErrors(errors);
1154
+ // show server errors while they are not cleaned/fixed
1155
+ const nonComponentServerErrors = lodash_1.default.filter(this.serverErrors || [], err => !err.component && !err.path);
1156
+ this.showErrors(nonComponentServerErrors.length ? nonComponentServerErrors : null);
1134
1157
  }
1135
1158
  // See if we need to save the draft of the form.
1136
1159
  if (modified && this.options.saveDraft) {