@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.
- package/README.md +11 -5
- package/dist/formio.builder.css +12 -5
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +12 -5
- package/dist/formio.form.js +2883 -2867
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -2
- package/dist/formio.full.css +12 -5
- package/dist/formio.full.js +3507 -3491
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -2
- package/dist/formio.js +1139 -1145
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +2 -2
- package/dist/formio.utils.js +1066 -1072
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -2
- package/lib/cjs/Embed.js +8 -16
- package/lib/cjs/Form.js +4 -4
- package/lib/cjs/Formio.js +2 -9
- package/lib/cjs/InlineEmbed.js +1 -4
- package/lib/cjs/PDF.js +28 -8
- package/lib/cjs/PDFBuilder.js +6 -10
- package/lib/cjs/Webform.d.ts +1 -0
- package/lib/cjs/Webform.js +19 -34
- package/lib/cjs/WebformBuilder.js +27 -68
- package/lib/cjs/Wizard.d.ts +1 -0
- package/lib/cjs/Wizard.js +44 -31
- package/lib/cjs/WizardBuilder.js +5 -15
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
- package/lib/cjs/addons/index.js +1 -3
- package/lib/cjs/components/_classes/component/Component.d.ts +10 -5
- package/lib/cjs/components/_classes/component/Component.js +76 -134
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
- package/lib/cjs/components/_classes/field/Field.js +1 -4
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/cjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +8 -26
- package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -4
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
- package/lib/cjs/components/address/Address.js +10 -30
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -32
- package/lib/cjs/components/alert/Alert.js +3 -6
- package/lib/cjs/components/button/Button.d.ts +1 -0
- package/lib/cjs/components/button/Button.js +31 -17
- package/lib/cjs/components/button/editForm/Button.edit.display.js +8 -32
- package/lib/cjs/components/checkbox/Checkbox.js +4 -10
- package/lib/cjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
- package/lib/cjs/components/columns/Columns.js +5 -17
- package/lib/cjs/components/container/Container.js +1 -3
- package/lib/cjs/components/currency/Currency.js +2 -7
- package/lib/cjs/components/datagrid/DataGrid.js +27 -68
- package/lib/cjs/components/datamap/DataMap.js +4 -16
- package/lib/cjs/components/datetime/DateTime.js +2 -6
- package/lib/cjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
- package/lib/cjs/components/day/Day.js +12 -70
- package/lib/cjs/components/day/editForm/Day.edit.day.js +1 -3
- package/lib/cjs/components/day/editForm/Day.edit.month.js +1 -3
- package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -0
- package/lib/cjs/components/editgrid/EditGrid.js +18 -44
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
- package/lib/cjs/components/file/File.js +40 -70
- package/lib/cjs/components/file/editForm/File.edit.display.js +1 -5
- package/lib/cjs/components/file/editForm/File.edit.file.js +8 -30
- package/lib/cjs/components/form/Form.js +5 -7
- package/lib/cjs/components/html/HTML.js +1 -5
- package/lib/cjs/components/number/Number.js +2 -4
- package/lib/cjs/components/panel/editForm/Panel.edit.display.js +3 -12
- package/lib/cjs/components/password/Password.js +1 -4
- package/lib/cjs/components/radio/Radio.js +7 -17
- package/lib/cjs/components/radio/editForm/Radio.edit.data.js +4 -14
- package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -6
- package/lib/cjs/components/select/Select.js +49 -94
- package/lib/cjs/components/select/editForm/Select.edit.data.js +37 -182
- package/lib/cjs/components/select/editForm/Select.edit.validation.js +1 -9
- package/lib/cjs/components/selectboxes/SelectBoxes.js +3 -6
- package/lib/cjs/components/signature/Signature.d.ts +1 -1
- package/lib/cjs/components/signature/Signature.js +5 -10
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +2 -6
- package/lib/cjs/components/survey/Survey.js +6 -17
- package/lib/cjs/components/survey/editForm/Survey.edit.data.js +4 -12
- package/lib/cjs/components/table/editForm/Table.edit.display.js +3 -3
- package/lib/cjs/components/tabs/Tabs.js +4 -19
- package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
- package/lib/cjs/components/tags/Tags.js +4 -14
- package/lib/cjs/components/textarea/TextArea.js +8 -15
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
- package/lib/cjs/components/textfield/TextField.js +4 -4
- package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +2 -8
- package/lib/cjs/components/time/Time.js +1 -4
- package/lib/cjs/components/time/editForm/Time.edit.display.js +1 -4
- package/lib/cjs/formio.form.js +5 -5
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/providers/address/AddressProvider.js +1 -1
- package/lib/cjs/providers/address/GoogleAddressProvider.js +2 -4
- package/lib/cjs/providers/processor/fileProcessor.js +1 -3
- package/lib/cjs/providers/storage/azure.js +5 -6
- package/lib/cjs/providers/storage/indexeddb.js +5 -15
- package/lib/cjs/providers/storage/s3.js +3 -14
- package/lib/cjs/providers/storage/xhr.js +19 -28
- package/lib/cjs/templates/Templates.js +1 -0
- package/lib/cjs/translations/en.d.ts +237 -81
- package/lib/cjs/translations/en.js +10 -81
- package/lib/cjs/utils/ChoicesWrapper.js +1 -1
- package/lib/cjs/utils/builder.js +5 -26
- package/lib/cjs/utils/i18n.d.ts +5 -2
- package/lib/cjs/utils/i18n.js +33 -12
- package/lib/cjs/utils/utils.js +42 -52
- package/lib/cjs/widgets/CalendarWidget.js +2 -6
- package/lib/mjs/Embed.js +8 -16
- package/lib/mjs/Form.js +4 -4
- package/lib/mjs/Formio.js +2 -9
- package/lib/mjs/InlineEmbed.js +1 -4
- package/lib/mjs/PDF.js +27 -8
- package/lib/mjs/PDFBuilder.js +6 -10
- package/lib/mjs/Webform.d.ts +1 -0
- package/lib/mjs/Webform.js +19 -31
- package/lib/mjs/WebformBuilder.js +27 -68
- package/lib/mjs/Wizard.d.ts +1 -0
- package/lib/mjs/Wizard.js +39 -27
- package/lib/mjs/WizardBuilder.js +5 -15
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
- package/lib/mjs/addons/index.js +1 -3
- package/lib/mjs/components/_classes/component/Component.d.ts +10 -5
- package/lib/mjs/components/_classes/component/Component.js +75 -134
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
- package/lib/mjs/components/_classes/field/Field.js +1 -4
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/mjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +8 -26
- package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -4
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
- package/lib/mjs/components/address/Address.js +10 -30
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -32
- package/lib/mjs/components/alert/Alert.js +3 -6
- package/lib/mjs/components/button/Button.d.ts +1 -0
- package/lib/mjs/components/button/Button.js +29 -16
- package/lib/mjs/components/button/editForm/Button.edit.display.js +8 -32
- package/lib/mjs/components/checkbox/Checkbox.js +4 -10
- package/lib/mjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
- package/lib/mjs/components/columns/Columns.js +5 -17
- package/lib/mjs/components/container/Container.js +1 -3
- package/lib/mjs/components/currency/Currency.js +2 -7
- package/lib/mjs/components/datagrid/DataGrid.js +28 -69
- package/lib/mjs/components/datamap/DataMap.js +12 -18
- package/lib/mjs/components/datetime/DateTime.js +2 -6
- package/lib/mjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
- package/lib/mjs/components/day/Day.js +12 -70
- package/lib/mjs/components/day/editForm/Day.edit.day.js +1 -3
- package/lib/mjs/components/day/editForm/Day.edit.month.js +1 -3
- package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -0
- package/lib/mjs/components/editgrid/EditGrid.js +18 -44
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
- package/lib/mjs/components/file/File.js +40 -70
- package/lib/mjs/components/file/editForm/File.edit.display.js +1 -5
- package/lib/mjs/components/file/editForm/File.edit.file.js +8 -30
- package/lib/mjs/components/form/Form.js +5 -7
- package/lib/mjs/components/html/HTML.js +1 -5
- package/lib/mjs/components/number/Number.js +2 -4
- package/lib/mjs/components/panel/editForm/Panel.edit.display.js +3 -12
- package/lib/mjs/components/password/Password.js +1 -4
- package/lib/mjs/components/radio/Radio.js +7 -17
- package/lib/mjs/components/radio/editForm/Radio.edit.data.js +4 -14
- package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -6
- package/lib/mjs/components/select/Select.js +52 -97
- package/lib/mjs/components/select/editForm/Select.edit.data.js +37 -182
- package/lib/mjs/components/select/editForm/Select.edit.validation.js +1 -9
- package/lib/mjs/components/selectboxes/SelectBoxes.js +3 -6
- package/lib/mjs/components/signature/Signature.d.ts +1 -1
- package/lib/mjs/components/signature/Signature.js +5 -10
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +2 -6
- package/lib/mjs/components/survey/Survey.js +6 -17
- package/lib/mjs/components/survey/editForm/Survey.edit.data.js +4 -12
- package/lib/mjs/components/table/editForm/Table.edit.display.js +3 -3
- package/lib/mjs/components/tabs/Tabs.js +4 -19
- package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
- package/lib/mjs/components/tags/Tags.js +4 -14
- package/lib/mjs/components/textarea/TextArea.js +8 -15
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
- package/lib/mjs/components/textfield/TextField.js +4 -4
- package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +2 -8
- package/lib/mjs/components/time/Time.js +1 -4
- package/lib/mjs/components/time/editForm/Time.edit.display.js +1 -4
- package/lib/mjs/formio.form.js +6 -6
- package/lib/mjs/package.json +1 -1
- package/lib/mjs/providers/address/AddressProvider.js +1 -1
- package/lib/mjs/providers/address/GoogleAddressProvider.js +2 -4
- package/lib/mjs/providers/processor/fileProcessor.js +1 -3
- package/lib/mjs/providers/storage/azure.js +5 -6
- package/lib/mjs/providers/storage/indexeddb.js +5 -15
- package/lib/mjs/providers/storage/s3.js +3 -14
- package/lib/mjs/providers/storage/xhr.js +19 -32
- package/lib/mjs/templates/Templates.js +1 -0
- package/lib/mjs/translations/en.d.ts +237 -81
- package/lib/mjs/translations/en.js +91 -1
- package/lib/mjs/utils/ChoicesWrapper.js +1 -1
- package/lib/mjs/utils/builder.js +5 -26
- package/lib/mjs/utils/i18n.d.ts +5 -2
- package/lib/mjs/utils/i18n.js +33 -12
- package/lib/mjs/utils/utils.js +42 -52
- package/lib/mjs/widgets/CalendarWidget.js +2 -6
- package/package.json +8 -6
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* MIT licensed
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
/*! @license DOMPurify 3.4.
|
|
21
|
+
/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */
|
|
22
22
|
|
|
23
|
-
/*! formiojs v5.4.
|
|
23
|
+
/*! formiojs v5.4.2 | https://unpkg.com/formiojs@5.4.2/LICENSE.txt */
|
|
24
24
|
|
|
25
25
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
26
26
|
|
package/lib/cjs/Embed.js
CHANGED
|
@@ -161,10 +161,10 @@ class Formio {
|
|
|
161
161
|
if (!liveRegion) {
|
|
162
162
|
liveRegion = _a.createElement('div', {
|
|
163
163
|
id: 'formio-announcements',
|
|
164
|
-
|
|
164
|
+
role: 'status',
|
|
165
165
|
'aria-live': 'polite',
|
|
166
166
|
'aria-atomic': 'true',
|
|
167
|
-
style: 'position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);'
|
|
167
|
+
style: 'position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);',
|
|
168
168
|
});
|
|
169
169
|
document.body.appendChild(liveRegion);
|
|
170
170
|
}
|
|
@@ -278,9 +278,7 @@ class Formio {
|
|
|
278
278
|
_a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});
|
|
279
279
|
_a.config.libs = _a.config.libs || {
|
|
280
280
|
uswds: {
|
|
281
|
-
dependencies: [
|
|
282
|
-
'fontawesome',
|
|
283
|
-
],
|
|
281
|
+
dependencies: ['fontawesome'],
|
|
284
282
|
js: `${_a.cdn.uswds}/uswds.min.js`,
|
|
285
283
|
css: `${_a.cdn.uswds}/uswds.min.css`,
|
|
286
284
|
use: true,
|
|
@@ -298,15 +296,11 @@ class Formio {
|
|
|
298
296
|
}`,
|
|
299
297
|
},
|
|
300
298
|
bootstrap4: {
|
|
301
|
-
dependencies: [
|
|
302
|
-
'fontawesome',
|
|
303
|
-
],
|
|
299
|
+
dependencies: ['fontawesome'],
|
|
304
300
|
css: `${_a.cdn.bootstrap4}/css/bootstrap.min.css`,
|
|
305
301
|
},
|
|
306
302
|
bootstrap: {
|
|
307
|
-
dependencies: [
|
|
308
|
-
'bootstrap-icons',
|
|
309
|
-
],
|
|
303
|
+
dependencies: ['bootstrap-icons'],
|
|
310
304
|
css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`,
|
|
311
305
|
},
|
|
312
306
|
'bootstrap-icons': {
|
|
@@ -346,9 +340,7 @@ class Formio {
|
|
|
346
340
|
'yeti',
|
|
347
341
|
].forEach((template) => {
|
|
348
342
|
_a.config.libs[template] = {
|
|
349
|
-
dependencies: [
|
|
350
|
-
'bootstrap-icons',
|
|
351
|
-
],
|
|
343
|
+
dependencies: ['bootstrap-icons'],
|
|
352
344
|
css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.css`,
|
|
353
345
|
};
|
|
354
346
|
});
|
|
@@ -390,7 +382,7 @@ class Formio {
|
|
|
390
382
|
// Due to an issue with quill not loading styles in the shadowdom, we need to add quill styles and js to the shadowdom
|
|
391
383
|
const quill = {
|
|
392
384
|
js: `${_a.cdn.quill}/quill.js`,
|
|
393
|
-
css: `${_a.cdn.quill}/quill.snow.css
|
|
385
|
+
css: `${_a.cdn.quill}/quill.snow.css`,
|
|
394
386
|
};
|
|
395
387
|
yield _a.addLibrary(wrapper, quill, 'quill');
|
|
396
388
|
}
|
|
@@ -508,7 +500,7 @@ Formio.formioReady = new Promise((ready, reject) => {
|
|
|
508
500
|
_a._formioReady = ready;
|
|
509
501
|
_a._formioReadyReject = reject;
|
|
510
502
|
});
|
|
511
|
-
Formio.version = '5.4.
|
|
503
|
+
Formio.version = '5.4.2';
|
|
512
504
|
// Create a report.
|
|
513
505
|
Formio.Report = {
|
|
514
506
|
create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
package/lib/cjs/Form.js
CHANGED
|
@@ -420,10 +420,10 @@ class Form extends Element_1.default {
|
|
|
420
420
|
*/
|
|
421
421
|
build() {
|
|
422
422
|
if (!this.instance) {
|
|
423
|
-
return Promise.reject(
|
|
423
|
+
return Promise.reject(this.t('formNotReady'));
|
|
424
424
|
}
|
|
425
425
|
if (!this.element) {
|
|
426
|
-
return Promise.reject(
|
|
426
|
+
return Promise.reject(this.t('noFormElement'));
|
|
427
427
|
}
|
|
428
428
|
// Add temporary loader.
|
|
429
429
|
const template = this.options && this.options.template ? this.options.template : 'bootstrap';
|
|
@@ -441,7 +441,7 @@ class Form extends Element_1.default {
|
|
|
441
441
|
}
|
|
442
442
|
render() {
|
|
443
443
|
if (!this.instance) {
|
|
444
|
-
return Promise.reject(
|
|
444
|
+
return Promise.reject(this.t('formNotReady'));
|
|
445
445
|
}
|
|
446
446
|
return Promise.resolve(this.instance.render()).then((param) => {
|
|
447
447
|
this.emit('render', param);
|
|
@@ -450,7 +450,7 @@ class Form extends Element_1.default {
|
|
|
450
450
|
}
|
|
451
451
|
attach(element) {
|
|
452
452
|
if (!this.instance) {
|
|
453
|
-
return Promise.reject(
|
|
453
|
+
return Promise.reject(this.t('formNotReady'));
|
|
454
454
|
}
|
|
455
455
|
if (this.element) {
|
|
456
456
|
delete this.element.component;
|
package/lib/cjs/Formio.js
CHANGED
|
@@ -11,7 +11,7 @@ const CDN_1 = __importDefault(require("./CDN"));
|
|
|
11
11
|
const providers_1 = __importDefault(require("./providers"));
|
|
12
12
|
sdk_1.Formio.cdn = new CDN_1.default();
|
|
13
13
|
sdk_1.Formio.Providers = providers_1.default;
|
|
14
|
-
sdk_1.Formio.version = '5.4.
|
|
14
|
+
sdk_1.Formio.version = '5.4.2';
|
|
15
15
|
CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc')
|
|
16
16
|
? 'https://cdn.test-form.io'
|
|
17
17
|
: 'https://cdn.form.io';
|
|
@@ -90,14 +90,7 @@ sdk_1.Formio.prototype.deleteFile = function (file, options) {
|
|
|
90
90
|
return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);
|
|
91
91
|
};
|
|
92
92
|
// Esnure we proxy the following methods to the FormioEmbed class.
|
|
93
|
-
[
|
|
94
|
-
'setBaseUrl',
|
|
95
|
-
'setApiUrl',
|
|
96
|
-
'setAppUrl',
|
|
97
|
-
'setProjectUrl',
|
|
98
|
-
'setPathType',
|
|
99
|
-
'setLicense',
|
|
100
|
-
].forEach((fn) => {
|
|
93
|
+
['setBaseUrl', 'setApiUrl', 'setAppUrl', 'setProjectUrl', 'setPathType', 'setLicense'].forEach((fn) => {
|
|
101
94
|
const baseFn = sdk_1.Formio[fn];
|
|
102
95
|
sdk_1.Formio[fn] = function (arg) {
|
|
103
96
|
const retVal = Embed_1.Formio[fn](arg, true);
|
package/lib/cjs/InlineEmbed.js
CHANGED
|
@@ -31,10 +31,7 @@ function embed(config = {}) {
|
|
|
31
31
|
let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
|
|
32
32
|
scriptSrc.pop();
|
|
33
33
|
let cdnSrc = '';
|
|
34
|
-
if ([
|
|
35
|
-
'js',
|
|
36
|
-
'offline',
|
|
37
|
-
].includes(scriptSrc[scriptSrc.length - 1])) {
|
|
34
|
+
if (['js', 'offline'].includes(scriptSrc[scriptSrc.length - 1])) {
|
|
38
35
|
scriptSrc.pop();
|
|
39
36
|
scriptSrc = cdnSrc = scriptSrc.join('/');
|
|
40
37
|
scriptSrc += '/js';
|
package/lib/cjs/PDF.js
CHANGED
|
@@ -6,6 +6,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const Formio_1 = require("./Formio");
|
|
7
7
|
const Webform_1 = __importDefault(require("./Webform"));
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
|
+
const getIframeOrigin = (iframeElement) => {
|
|
10
|
+
try {
|
|
11
|
+
const origin = new URL(iframeElement.src, window.location.href).origin;
|
|
12
|
+
return origin === 'null' ? null : origin;
|
|
13
|
+
}
|
|
14
|
+
catch (ignoreErr) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const isTrustedIframeMessage = (event, form) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const iframeWindow = (_a = form === null || form === void 0 ? void 0 : form.iframeElement) === null || _a === void 0 ? void 0 : _a.contentWindow;
|
|
21
|
+
const iframeOrigin = (form === null || form === void 0 ? void 0 : form.iframeElement) && getIframeOrigin(form.iframeElement);
|
|
22
|
+
return Boolean(iframeWindow &&
|
|
23
|
+
iframeOrigin &&
|
|
24
|
+
event.source === iframeWindow &&
|
|
25
|
+
event.origin === iframeOrigin);
|
|
26
|
+
};
|
|
9
27
|
class PDF extends Webform_1.default {
|
|
10
28
|
constructor(element, options) {
|
|
11
29
|
options.display = 'pdf';
|
|
@@ -17,11 +35,11 @@ class PDF extends Webform_1.default {
|
|
|
17
35
|
// Handle an iframe submission.
|
|
18
36
|
this.on('iframe-submission', (submission) => this.setValue(submission, {
|
|
19
37
|
fromIframe: true,
|
|
20
|
-
noDefault: true
|
|
38
|
+
noDefault: true,
|
|
21
39
|
}), true);
|
|
22
40
|
this.on('iframe-change', (submission) => this.setValue(submission, {
|
|
23
41
|
fromIframe: true,
|
|
24
|
-
noDefault: true
|
|
42
|
+
noDefault: true,
|
|
25
43
|
}), true);
|
|
26
44
|
this.on('iframe-getIframePositions', (query) => {
|
|
27
45
|
const iframe = document.getElementById(`iframe-${query.formId}`);
|
|
@@ -167,9 +185,7 @@ class PDF extends Webform_1.default {
|
|
|
167
185
|
return '';
|
|
168
186
|
}
|
|
169
187
|
let iframeSrc = `${this._form.settings.pdf.src}.html`;
|
|
170
|
-
const params = [
|
|
171
|
-
`id=${this.id}`,
|
|
172
|
-
];
|
|
188
|
+
const params = [`id=${this.id}`];
|
|
173
189
|
if (this.options.showCheckboxBackground || this._form.settings.showCheckboxBackground) {
|
|
174
190
|
params.push('checkboxbackground=1');
|
|
175
191
|
}
|
|
@@ -283,19 +299,23 @@ if (typeof window !== 'undefined') {
|
|
|
283
299
|
catch (ignoreErr) {
|
|
284
300
|
eventData = null;
|
|
285
301
|
}
|
|
286
|
-
// If this form exists,
|
|
302
|
+
// If this form exists and the message came from its PDF iframe, emit the event within this form.
|
|
287
303
|
if (eventData &&
|
|
288
304
|
eventData.name &&
|
|
289
305
|
eventData.formId &&
|
|
290
306
|
Formio_1.Formio.forms.hasOwnProperty(eventData.formId)) {
|
|
307
|
+
const form = Formio_1.Formio.forms[eventData.formId];
|
|
308
|
+
if (!isTrustedIframeMessage(event, form)) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
291
311
|
if (eventData.compPath) {
|
|
292
|
-
const comp =
|
|
312
|
+
const comp = form.getComponent(eventData.compPath);
|
|
293
313
|
if (comp) {
|
|
294
314
|
comp.emit(eventData.name, eventData.data);
|
|
295
315
|
}
|
|
296
316
|
}
|
|
297
317
|
else {
|
|
298
|
-
|
|
318
|
+
form.emit(`iframe-${eventData.name}`, eventData.data);
|
|
299
319
|
}
|
|
300
320
|
}
|
|
301
321
|
});
|
package/lib/cjs/PDFBuilder.js
CHANGED
|
@@ -199,10 +199,10 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
|
199
199
|
const progress = Math.floor((event.loaded / event.total) * 100);
|
|
200
200
|
this.refs.uploadProgress.style.width = `${progress}%`;
|
|
201
201
|
if (progress > 98) {
|
|
202
|
-
this.refs.uploadProgress.innerHTML = this.t('
|
|
202
|
+
this.refs.uploadProgress.innerHTML = this.t('waitPdfConverting');
|
|
203
203
|
}
|
|
204
204
|
else {
|
|
205
|
-
this.refs.uploadProgress.innerHTML = `${this.t('
|
|
205
|
+
this.refs.uploadProgress.innerHTML = `${this.t('uploading')} ${progress}%`;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
}, `${this.projectUrl}/upload`, {}, 'file')
|
|
@@ -247,7 +247,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
249
|
this.refs.uploadError.style.display = message ? '' : 'none';
|
|
250
|
-
this.refs.uploadError.innerHTML = message;
|
|
250
|
+
this.refs.uploadError.innerHTML = this.t(`${message}`);
|
|
251
251
|
}
|
|
252
252
|
createForm(options) {
|
|
253
253
|
// Instantiate the webform from the PDF class instead of Webform
|
|
@@ -257,9 +257,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
|
257
257
|
this.webform.on('attach', () => {
|
|
258
258
|
// If the dropzone exists but has been removed in a PDF rebuild, reinstate it
|
|
259
259
|
if (this.refs.iframeDropzone &&
|
|
260
|
-
![
|
|
261
|
-
...this.refs.form.children,
|
|
262
|
-
].includes(this.refs.iframeDropzone)) {
|
|
260
|
+
![...this.refs.form.children].includes(this.refs.iframeDropzone)) {
|
|
263
261
|
this.prependTo(this.refs.iframeDropzone, this.refs.form);
|
|
264
262
|
}
|
|
265
263
|
});
|
|
@@ -375,9 +373,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
|
375
373
|
return;
|
|
376
374
|
}
|
|
377
375
|
this.refs['sidebar-container'].forEach((container) => {
|
|
378
|
-
[
|
|
379
|
-
...container.children,
|
|
380
|
-
].forEach((el) => {
|
|
376
|
+
[...container.children].forEach((el) => {
|
|
381
377
|
el.draggable = true;
|
|
382
378
|
el.setAttribute('draggable', true);
|
|
383
379
|
this.removeEventListener(el, 'dragstart');
|
|
@@ -492,7 +488,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
|
492
488
|
name: 'showBuilderErrors',
|
|
493
489
|
data: {
|
|
494
490
|
compId: comp.component.id,
|
|
495
|
-
errorMessage:
|
|
491
|
+
errorMessage: `${this.t('notUniqueKey')}: ${comp.key}`,
|
|
496
492
|
},
|
|
497
493
|
});
|
|
498
494
|
}
|
package/lib/cjs/Webform.d.ts
CHANGED
package/lib/cjs/Webform.js
CHANGED
|
@@ -297,11 +297,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
297
297
|
return false;
|
|
298
298
|
}
|
|
299
299
|
if (element.nodeName === 'INPUT') {
|
|
300
|
-
return (
|
|
301
|
-
'text',
|
|
302
|
-
'email',
|
|
303
|
-
'password',
|
|
304
|
-
].indexOf(element.type) === -1);
|
|
300
|
+
return ['text', 'email', 'password'].indexOf(element.type) === -1;
|
|
305
301
|
}
|
|
306
302
|
return true;
|
|
307
303
|
}
|
|
@@ -548,7 +544,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
548
544
|
}
|
|
549
545
|
if ('schema' in form && (0, compare_versions_1.compareVersions)(form.schema, '1.x') > 0) {
|
|
550
546
|
this.ready.then(() => {
|
|
551
|
-
this.setAlert('alert alert-danger',
|
|
547
|
+
this.setAlert('alert alert-danger', this.t('newFormSchema'));
|
|
552
548
|
});
|
|
553
549
|
}
|
|
554
550
|
// See if they pass a module, and evaluate it if so.
|
|
@@ -741,9 +737,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
741
737
|
});
|
|
742
738
|
}
|
|
743
739
|
get schema() {
|
|
744
|
-
const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, [
|
|
745
|
-
'components',
|
|
746
|
-
]));
|
|
740
|
+
const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, ['components']));
|
|
747
741
|
schema.components = [];
|
|
748
742
|
this.eachComponent((component) => schema.components.push(component.schema));
|
|
749
743
|
return schema;
|
|
@@ -770,10 +764,12 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
770
764
|
if (!this.options.submissionTimezone && submission.metadata && submission.metadata.timezone) {
|
|
771
765
|
this.options.submissionTimezone = submission.metadata.timezone;
|
|
772
766
|
}
|
|
767
|
+
this.subFromServer = lodash_1.default.cloneDeep(submission.data);
|
|
773
768
|
const changed = super.setValue(submission.data, flags);
|
|
774
769
|
if (!flags.sanitize) {
|
|
775
770
|
this.mergeData(this.data, submission.data);
|
|
776
771
|
}
|
|
772
|
+
// GOTCHA(G-FJS01)
|
|
777
773
|
submission.data = this.data;
|
|
778
774
|
this._submission = submission;
|
|
779
775
|
return changed;
|
|
@@ -1010,6 +1006,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1010
1006
|
const component = this.getComponent(key);
|
|
1011
1007
|
if (component) {
|
|
1012
1008
|
component.focus();
|
|
1009
|
+
component.scrollIntoView();
|
|
1013
1010
|
}
|
|
1014
1011
|
}
|
|
1015
1012
|
}
|
|
@@ -1035,9 +1032,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1035
1032
|
var _a, _b;
|
|
1036
1033
|
this.loading = false;
|
|
1037
1034
|
if (!Array.isArray(errors)) {
|
|
1038
|
-
errors = [
|
|
1039
|
-
errors,
|
|
1040
|
-
];
|
|
1035
|
+
errors = [errors];
|
|
1041
1036
|
}
|
|
1042
1037
|
if (Array.isArray(this.errors) &&
|
|
1043
1038
|
// do not show components validation errors in alert for draft submission
|
|
@@ -1070,14 +1065,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1070
1065
|
}
|
|
1071
1066
|
const displayedErrors = [];
|
|
1072
1067
|
if (errors.length) {
|
|
1073
|
-
errors = lodash_1.default.uniqBy(errors, (error) => {
|
|
1074
|
-
var _a, _b;
|
|
1075
|
-
return [
|
|
1076
|
-
error.message,
|
|
1077
|
-
(_a = error.component) === null || _a === void 0 ? void 0 : _a.id,
|
|
1078
|
-
(_b = error.context) === null || _b === void 0 ? void 0 : _b.path,
|
|
1079
|
-
].join();
|
|
1080
|
-
});
|
|
1068
|
+
errors = lodash_1.default.uniqBy(errors, (error) => { var _a, _b; return [error.message, (_a = error.component) === null || _a === void 0 ? void 0 : _a.id, (_b = error.context) === null || _b === void 0 ? void 0 : _b.path].join(); });
|
|
1081
1069
|
const createListItem = (message, index) => {
|
|
1082
1070
|
var _a, _b, _c;
|
|
1083
1071
|
const err = errors[index];
|
|
@@ -1105,6 +1093,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1105
1093
|
});
|
|
1106
1094
|
}
|
|
1107
1095
|
const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
|
|
1096
|
+
// GOTCHA(G-FJS02)
|
|
1108
1097
|
// Only paint the alert from a subform when the root won't double paint it to avoid a painful flicker
|
|
1109
1098
|
if (this === this.root || !((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted)) {
|
|
1110
1099
|
(_b = this.root) === null || _b === void 0 ? void 0 : _b.setAlert('danger', errorsList);
|
|
@@ -1146,7 +1135,8 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1146
1135
|
liveRegion.setAttribute('role', 'status');
|
|
1147
1136
|
liveRegion.setAttribute('aria-live', 'polite');
|
|
1148
1137
|
liveRegion.setAttribute('aria-atomic', 'true');
|
|
1149
|
-
liveRegion.style.cssText =
|
|
1138
|
+
liveRegion.style.cssText =
|
|
1139
|
+
'position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);';
|
|
1150
1140
|
document.body.appendChild(liveRegion);
|
|
1151
1141
|
}
|
|
1152
1142
|
// Announce the submission completion using VPAT clear-and-reset technique
|
|
@@ -1361,11 +1351,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1361
1351
|
};
|
|
1362
1352
|
}
|
|
1363
1353
|
// Ensure err is an array.
|
|
1364
|
-
err = Array.isArray(err)
|
|
1365
|
-
? err
|
|
1366
|
-
: [
|
|
1367
|
-
err,
|
|
1368
|
-
];
|
|
1354
|
+
err = Array.isArray(err) ? err : [err];
|
|
1369
1355
|
return reject(err);
|
|
1370
1356
|
}
|
|
1371
1357
|
this.loading = true;
|
|
@@ -1416,9 +1402,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1416
1402
|
});
|
|
1417
1403
|
}
|
|
1418
1404
|
else if (typeof error === 'string') {
|
|
1419
|
-
this.serverErrors = [
|
|
1420
|
-
{ fromServer: true, level: 'error', message: error },
|
|
1421
|
-
];
|
|
1405
|
+
this.serverErrors = [{ fromServer: true, level: 'error', message: error }];
|
|
1422
1406
|
}
|
|
1423
1407
|
}
|
|
1424
1408
|
executeSubmit(options) {
|
|
@@ -1477,7 +1461,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1477
1461
|
}
|
|
1478
1462
|
submitUrl(URL, headers) {
|
|
1479
1463
|
if (!URL) {
|
|
1480
|
-
return console.warn('
|
|
1464
|
+
return console.warn(this.t('missingUrl'));
|
|
1481
1465
|
}
|
|
1482
1466
|
const submission = this.submission || {};
|
|
1483
1467
|
const API_URL = URL;
|
|
@@ -1498,7 +1482,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1498
1482
|
})
|
|
1499
1483
|
.then(() => {
|
|
1500
1484
|
this.emit('requestDone');
|
|
1501
|
-
this.setAlert('success',
|
|
1485
|
+
this.setAlert('success', `<p> ${this.t('success')} </p>`);
|
|
1502
1486
|
})
|
|
1503
1487
|
.catch((e) => {
|
|
1504
1488
|
const message = `${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`;
|
|
@@ -1509,9 +1493,10 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1509
1493
|
});
|
|
1510
1494
|
}
|
|
1511
1495
|
else {
|
|
1512
|
-
|
|
1513
|
-
this.
|
|
1514
|
-
|
|
1496
|
+
const message = this.t('urlNotAttachedToBtn');
|
|
1497
|
+
this.emit('error', message);
|
|
1498
|
+
this.setAlert('warning', message);
|
|
1499
|
+
return console.warn(message);
|
|
1515
1500
|
}
|
|
1516
1501
|
}
|
|
1517
1502
|
triggerCaptcha(components = null) {
|