@formio/js 5.0.0-rc.55 → 5.0.0-rc.57
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/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.js +4 -4
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +4 -4
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Embed.js +11 -5
- package/lib/cjs/InlineEmbed.js +20 -15
- package/lib/cjs/Webform.d.ts +1 -1
- package/lib/cjs/Webform.js +1 -1
- package/lib/cjs/Wizard.d.ts +1 -1
- package/lib/cjs/Wizard.js +1 -1
- package/lib/mjs/Embed.js +11 -5
- package/lib/mjs/InlineEmbed.js +20 -15
- package/lib/mjs/Webform.d.ts +1 -1
- package/lib/mjs/Webform.js +1 -1
- package/lib/mjs/Wizard.d.ts +1 -1
- package/lib/mjs/Wizard.js +1 -1
- package/package.json +1 -1
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
/*! @license DOMPurify 3.1.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.4/LICENSE */
|
24
24
|
|
25
|
-
/*! formiojs v5.0.0-rc.
|
25
|
+
/*! formiojs v5.0.0-rc.57 | https://unpkg.com/formiojs@5.0.0-rc.57/LICENSE.txt */
|
26
26
|
|
27
27
|
/**
|
28
28
|
* @license
|
package/lib/cjs/Embed.js
CHANGED
@@ -144,6 +144,9 @@ class Formio {
|
|
144
144
|
static submitDone(instance, submission) {
|
145
145
|
return __awaiter(this, void 0, void 0, function* () {
|
146
146
|
_a.debug('Submision Complete', submission);
|
147
|
+
if (_a.config.submitDone) {
|
148
|
+
_a.config.submitDone(submission, instance);
|
149
|
+
}
|
147
150
|
const successMessage = (_a.config.success || '').toString();
|
148
151
|
if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {
|
149
152
|
instance.element.innerHTML = `<div class="alert-success" role="alert">${successMessage}</div>`;
|
@@ -297,14 +300,17 @@ class Formio {
|
|
297
300
|
if (_a.config.template && _a.config.includeLibs) {
|
298
301
|
yield _a.addLibrary(libWrapper, _a.config.libs[_a.config.template], _a.config.template);
|
299
302
|
}
|
300
|
-
|
303
|
+
if (!_a.config.libraries) {
|
304
|
+
_a.config.libraries = _a.config.modules || {};
|
305
|
+
}
|
306
|
+
// Adding premium if it is provided via the config.
|
301
307
|
if (_a.config.premium) {
|
302
|
-
_a.config.
|
308
|
+
_a.config.libraries.premium = _a.config.premium;
|
303
309
|
}
|
304
310
|
// Allow adding dynamic modules.
|
305
|
-
if (_a.config.
|
306
|
-
for (const name in _a.config.
|
307
|
-
const lib = _a.config.
|
311
|
+
if (_a.config.libraries) {
|
312
|
+
for (const name in _a.config.libraries) {
|
313
|
+
const lib = _a.config.libraries[name];
|
308
314
|
lib.use = lib.use || true;
|
309
315
|
yield _a.addLibrary(libWrapper, lib, name);
|
310
316
|
}
|
package/lib/cjs/InlineEmbed.js
CHANGED
@@ -27,16 +27,20 @@ function embed(config = {}) {
|
|
27
27
|
});
|
28
28
|
let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
|
29
29
|
scriptSrc.pop();
|
30
|
-
|
31
|
-
|
30
|
+
let cdnSrc = '';
|
31
|
+
if (scriptSrc[scriptSrc.length - 1] === 'js') {
|
32
|
+
scriptSrc.pop();
|
33
|
+
scriptSrc = cdnSrc = scriptSrc.join('/');
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
scriptSrc = scriptSrc.join('/');
|
32
37
|
}
|
33
|
-
scriptSrc = scriptSrc.join('/');
|
34
38
|
const debug = (query.debug === 'true' || query.debug === '1');
|
35
39
|
const renderer = debug ? 'formio.form' : 'formio.form.min';
|
36
40
|
Embed_1.Formio.config = Object.assign({
|
37
|
-
script: query.script || (`${
|
38
|
-
style: query.styles || (`${
|
39
|
-
cdn: query.cdn,
|
41
|
+
script: query.script || (`${scriptSrc}/${renderer}.js`),
|
42
|
+
style: query.styles || (`${scriptSrc}/${renderer}.css`),
|
43
|
+
cdn: query.cdn || cdnSrc,
|
40
44
|
class: (query.class || 'formio-form-wrapper'),
|
41
45
|
src: query.src,
|
42
46
|
form: null,
|
@@ -45,21 +49,21 @@ function embed(config = {}) {
|
|
45
49
|
base: query.base || 'https://api.form.io',
|
46
50
|
submit: query.submit,
|
47
51
|
includeLibs: (query.libs === 'true' || query.libs === '1'),
|
48
|
-
template: query.template,
|
52
|
+
template: query.template || 'bootstrap',
|
49
53
|
debug: debug,
|
50
54
|
config: {},
|
51
55
|
redirect: (query.return || query.redirect),
|
52
|
-
embedCSS: (`${
|
56
|
+
embedCSS: (`${scriptSrc}/formio.embed.css`),
|
53
57
|
success: query.success || 'Thank you for your submission!',
|
54
58
|
before: null,
|
55
59
|
after: null
|
56
60
|
}, config);
|
61
|
+
if (Embed_1.Formio.config.alter) {
|
62
|
+
Embed_1.Formio.config.alter(Embed_1.Formio.config);
|
63
|
+
}
|
57
64
|
const form = (Embed_1.Formio.config.form || Embed_1.Formio.config.src);
|
58
65
|
if (form) {
|
59
66
|
Embed_1.Formio.debug('Embedding Configuration', config);
|
60
|
-
if (Embed_1.Formio.config.addPremiumLib) {
|
61
|
-
Embed_1.Formio.config.addPremiumLib(Embed_1.Formio.config, scriptSrc);
|
62
|
-
}
|
63
67
|
// The id for this embedded form.
|
64
68
|
Embed_1.Formio.config.id = `formio-${Math.random().toString(36).substring(7)}`;
|
65
69
|
Embed_1.Formio.debug('Creating form element');
|
@@ -73,6 +77,8 @@ function embed(config = {}) {
|
|
73
77
|
if (Embed_1.Formio.config.submit) {
|
74
78
|
instance.nosubmit = true;
|
75
79
|
}
|
80
|
+
// Trigger the submit done event.
|
81
|
+
instance.on('submitDone', (submission) => Embed_1.Formio.submitDone(instance, submission));
|
76
82
|
// Configure a redirect.
|
77
83
|
instance.on('submit', (submission) => {
|
78
84
|
Embed_1.Formio.debug("on('submit')", submission);
|
@@ -92,10 +98,9 @@ function embed(config = {}) {
|
|
92
98
|
mode: 'cors',
|
93
99
|
})
|
94
100
|
.then(resp => resp.json())
|
95
|
-
.then(submission =>
|
96
|
-
|
97
|
-
|
98
|
-
Embed_1.Formio.submitDone(instance, submission);
|
101
|
+
.then((submission) => {
|
102
|
+
Embed_1.Formio.submitDone(instance, submission);
|
103
|
+
});
|
99
104
|
}
|
100
105
|
});
|
101
106
|
});
|
package/lib/cjs/Webform.d.ts
CHANGED
@@ -298,7 +298,7 @@ declare class Webform extends NestedDataComponent {
|
|
298
298
|
* @param {any} flags - Any flags to apply when setting the form.
|
299
299
|
* @returns {Promise} - The promise that is triggered when the form is set.
|
300
300
|
*/
|
301
|
-
setForm(form: object, flags
|
301
|
+
setForm(form: object, flags?: any): Promise<any>;
|
302
302
|
initialized: boolean | undefined;
|
303
303
|
/**
|
304
304
|
* Sets the form value.
|
package/lib/cjs/Webform.js
CHANGED
@@ -580,7 +580,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
580
580
|
* @param {any} flags - Any flags to apply when setting the form.
|
581
581
|
* @returns {Promise} - The promise that is triggered when the form is set.
|
582
582
|
*/
|
583
|
-
setForm(form, flags) {
|
583
|
+
setForm(form, flags = {}) {
|
584
584
|
var _a, _b, _c;
|
585
585
|
const isFormAlreadySet = this._form && ((_a = this._form.components) === null || _a === void 0 ? void 0 : _a.length);
|
586
586
|
try {
|
package/lib/cjs/Wizard.d.ts
CHANGED
@@ -96,7 +96,7 @@ declare class Wizard extends Webform {
|
|
96
96
|
getPageIndexByKey(key: any): number;
|
97
97
|
get schema(): object;
|
98
98
|
setComponentSchema(): void;
|
99
|
-
setForm(form: any, flags
|
99
|
+
setForm(form: any, flags?: {}): Promise<any> | undefined;
|
100
100
|
onSetForm(clonedForm: any, initialForm: any): void;
|
101
101
|
setEditMode(submission: any): void;
|
102
102
|
setValue(submission: any, flags: {} | undefined, ignoreEstablishment: any): any;
|
package/lib/cjs/Wizard.js
CHANGED
package/lib/mjs/Embed.js
CHANGED
@@ -138,6 +138,9 @@ export class Formio {
|
|
138
138
|
}
|
139
139
|
static async submitDone(instance, submission) {
|
140
140
|
Formio.debug('Submision Complete', submission);
|
141
|
+
if (Formio.config.submitDone) {
|
142
|
+
Formio.config.submitDone(submission, instance);
|
143
|
+
}
|
141
144
|
const successMessage = (Formio.config.success || '').toString();
|
142
145
|
if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {
|
143
146
|
instance.element.innerHTML = `<div class="alert-success" role="alert">${successMessage}</div>`;
|
@@ -285,14 +288,17 @@ export class Formio {
|
|
285
288
|
if (Formio.config.template && Formio.config.includeLibs) {
|
286
289
|
await Formio.addLibrary(libWrapper, Formio.config.libs[Formio.config.template], Formio.config.template);
|
287
290
|
}
|
288
|
-
|
291
|
+
if (!Formio.config.libraries) {
|
292
|
+
Formio.config.libraries = Formio.config.modules || {};
|
293
|
+
}
|
294
|
+
// Adding premium if it is provided via the config.
|
289
295
|
if (Formio.config.premium) {
|
290
|
-
Formio.config.
|
296
|
+
Formio.config.libraries.premium = Formio.config.premium;
|
291
297
|
}
|
292
298
|
// Allow adding dynamic modules.
|
293
|
-
if (Formio.config.
|
294
|
-
for (const name in Formio.config.
|
295
|
-
const lib = Formio.config.
|
299
|
+
if (Formio.config.libraries) {
|
300
|
+
for (const name in Formio.config.libraries) {
|
301
|
+
const lib = Formio.config.libraries[name];
|
296
302
|
lib.use = lib.use || true;
|
297
303
|
await Formio.addLibrary(libWrapper, lib, name);
|
298
304
|
}
|
package/lib/mjs/InlineEmbed.js
CHANGED
@@ -23,16 +23,20 @@ export function embed(config = {}) {
|
|
23
23
|
});
|
24
24
|
let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
|
25
25
|
scriptSrc.pop();
|
26
|
-
|
27
|
-
|
26
|
+
let cdnSrc = '';
|
27
|
+
if (scriptSrc[scriptSrc.length - 1] === 'js') {
|
28
|
+
scriptSrc.pop();
|
29
|
+
scriptSrc = cdnSrc = scriptSrc.join('/');
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
scriptSrc = scriptSrc.join('/');
|
28
33
|
}
|
29
|
-
scriptSrc = scriptSrc.join('/');
|
30
34
|
const debug = (query.debug === 'true' || query.debug === '1');
|
31
35
|
const renderer = debug ? 'formio.form' : 'formio.form.min';
|
32
36
|
Formio.config = Object.assign({
|
33
|
-
script: query.script || (`${
|
34
|
-
style: query.styles || (`${
|
35
|
-
cdn: query.cdn,
|
37
|
+
script: query.script || (`${scriptSrc}/${renderer}.js`),
|
38
|
+
style: query.styles || (`${scriptSrc}/${renderer}.css`),
|
39
|
+
cdn: query.cdn || cdnSrc,
|
36
40
|
class: (query.class || 'formio-form-wrapper'),
|
37
41
|
src: query.src,
|
38
42
|
form: null,
|
@@ -41,21 +45,21 @@ export function embed(config = {}) {
|
|
41
45
|
base: query.base || 'https://api.form.io',
|
42
46
|
submit: query.submit,
|
43
47
|
includeLibs: (query.libs === 'true' || query.libs === '1'),
|
44
|
-
template: query.template,
|
48
|
+
template: query.template || 'bootstrap',
|
45
49
|
debug: debug,
|
46
50
|
config: {},
|
47
51
|
redirect: (query.return || query.redirect),
|
48
|
-
embedCSS: (`${
|
52
|
+
embedCSS: (`${scriptSrc}/formio.embed.css`),
|
49
53
|
success: query.success || 'Thank you for your submission!',
|
50
54
|
before: null,
|
51
55
|
after: null
|
52
56
|
}, config);
|
57
|
+
if (Formio.config.alter) {
|
58
|
+
Formio.config.alter(Formio.config);
|
59
|
+
}
|
53
60
|
const form = (Formio.config.form || Formio.config.src);
|
54
61
|
if (form) {
|
55
62
|
Formio.debug('Embedding Configuration', config);
|
56
|
-
if (Formio.config.addPremiumLib) {
|
57
|
-
Formio.config.addPremiumLib(Formio.config, scriptSrc);
|
58
|
-
}
|
59
63
|
// The id for this embedded form.
|
60
64
|
Formio.config.id = `formio-${Math.random().toString(36).substring(7)}`;
|
61
65
|
Formio.debug('Creating form element');
|
@@ -69,6 +73,8 @@ export function embed(config = {}) {
|
|
69
73
|
if (Formio.config.submit) {
|
70
74
|
instance.nosubmit = true;
|
71
75
|
}
|
76
|
+
// Trigger the submit done event.
|
77
|
+
instance.on('submitDone', (submission) => Formio.submitDone(instance, submission));
|
72
78
|
// Configure a redirect.
|
73
79
|
instance.on('submit', (submission) => {
|
74
80
|
Formio.debug("on('submit')", submission);
|
@@ -88,10 +94,9 @@ export function embed(config = {}) {
|
|
88
94
|
mode: 'cors',
|
89
95
|
})
|
90
96
|
.then(resp => resp.json())
|
91
|
-
.then(submission =>
|
92
|
-
|
93
|
-
|
94
|
-
Formio.submitDone(instance, submission);
|
97
|
+
.then((submission) => {
|
98
|
+
Formio.submitDone(instance, submission);
|
99
|
+
});
|
95
100
|
}
|
96
101
|
});
|
97
102
|
});
|
package/lib/mjs/Webform.d.ts
CHANGED
@@ -298,7 +298,7 @@ declare class Webform extends NestedDataComponent {
|
|
298
298
|
* @param {any} flags - Any flags to apply when setting the form.
|
299
299
|
* @returns {Promise} - The promise that is triggered when the form is set.
|
300
300
|
*/
|
301
|
-
setForm(form: object, flags
|
301
|
+
setForm(form: object, flags?: any): Promise<any>;
|
302
302
|
initialized: boolean | undefined;
|
303
303
|
/**
|
304
304
|
* Sets the form value.
|
package/lib/mjs/Webform.js
CHANGED
@@ -579,7 +579,7 @@ export default class Webform extends NestedDataComponent {
|
|
579
579
|
* @param {any} flags - Any flags to apply when setting the form.
|
580
580
|
* @returns {Promise} - The promise that is triggered when the form is set.
|
581
581
|
*/
|
582
|
-
setForm(form, flags) {
|
582
|
+
setForm(form, flags = {}) {
|
583
583
|
const isFormAlreadySet = this._form && this._form.components?.length;
|
584
584
|
try {
|
585
585
|
// Do not set the form again if it has been already set
|
package/lib/mjs/Wizard.d.ts
CHANGED
@@ -96,7 +96,7 @@ declare class Wizard extends Webform {
|
|
96
96
|
getPageIndexByKey(key: any): number;
|
97
97
|
get schema(): object;
|
98
98
|
setComponentSchema(): void;
|
99
|
-
setForm(form: any, flags
|
99
|
+
setForm(form: any, flags?: {}): Promise<any> | undefined;
|
100
100
|
onSetForm(clonedForm: any, initialForm: any): void;
|
101
101
|
setEditMode(submission: any): void;
|
102
102
|
setValue(submission: any, flags: {} | undefined, ignoreEstablishment: any): any;
|
package/lib/mjs/Wizard.js
CHANGED