@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.
@@ -10,7 +10,7 @@
10
10
  * MIT licensed
11
11
  */
12
12
 
13
- /*! formiojs v5.0.0-rc.55 | https://unpkg.com/formiojs@5.0.0-rc.55/LICENSE.txt */
13
+ /*! formiojs v5.0.0-rc.57 | https://unpkg.com/formiojs@5.0.0-rc.57/LICENSE.txt */
14
14
 
15
15
  /**
16
16
  * @license
@@ -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.55 | https://unpkg.com/formiojs@5.0.0-rc.55/LICENSE.txt */
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
- // Add the premium modules.
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.modules.premium = _a.config.premium;
308
+ _a.config.libraries.premium = _a.config.premium;
303
309
  }
304
310
  // Allow adding dynamic modules.
305
- if (_a.config.modules) {
306
- for (const name in _a.config.modules) {
307
- const lib = _a.config.modules[name];
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
  }
@@ -27,16 +27,20 @@ function embed(config = {}) {
27
27
  });
28
28
  let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
29
29
  scriptSrc.pop();
30
- if (config.formioPath) {
31
- config.formioPath(scriptSrc);
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 || (`${config.updatePath ? config.updatePath() : scriptSrc}/${renderer}.js`),
38
- style: query.styles || (`${config.updatePath ? config.updatePath() : scriptSrc}/${renderer}.css`),
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: (`${config.updatePath ? config.updatePath() : scriptSrc}/formio.embed.css`),
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 => Embed_1.Formio.submitDone(instance, submission));
96
- }
97
- else {
98
- Embed_1.Formio.submitDone(instance, submission);
101
+ .then((submission) => {
102
+ Embed_1.Formio.submitDone(instance, submission);
103
+ });
99
104
  }
100
105
  });
101
106
  });
@@ -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: any): Promise<any>;
301
+ setForm(form: object, flags?: any): Promise<any>;
302
302
  initialized: boolean | undefined;
303
303
  /**
304
304
  * Sets the form value.
@@ -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 {
@@ -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: any): Promise<any> | undefined;
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
@@ -794,7 +794,7 @@ class Wizard extends Webform_1.default {
794
794
  this.originalComponents.push(lodash_1.default.clone(newPage));
795
795
  }
796
796
  }
797
- setForm(form, flags) {
797
+ setForm(form, flags = {}) {
798
798
  if (!form) {
799
799
  return;
800
800
  }
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
- // Add the premium modules.
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.modules.premium = Formio.config.premium;
296
+ Formio.config.libraries.premium = Formio.config.premium;
291
297
  }
292
298
  // Allow adding dynamic modules.
293
- if (Formio.config.modules) {
294
- for (const name in Formio.config.modules) {
295
- const lib = Formio.config.modules[name];
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
  }
@@ -23,16 +23,20 @@ export function embed(config = {}) {
23
23
  });
24
24
  let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
25
25
  scriptSrc.pop();
26
- if (config.formioPath) {
27
- config.formioPath(scriptSrc);
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 || (`${config.updatePath ? config.updatePath() : scriptSrc}/${renderer}.js`),
34
- style: query.styles || (`${config.updatePath ? config.updatePath() : scriptSrc}/${renderer}.css`),
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: (`${config.updatePath ? config.updatePath() : scriptSrc}/formio.embed.css`),
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 => Formio.submitDone(instance, submission));
92
- }
93
- else {
94
- Formio.submitDone(instance, submission);
97
+ .then((submission) => {
98
+ Formio.submitDone(instance, submission);
99
+ });
95
100
  }
96
101
  });
97
102
  });
@@ -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: any): Promise<any>;
301
+ setForm(form: object, flags?: any): Promise<any>;
302
302
  initialized: boolean | undefined;
303
303
  /**
304
304
  * Sets the form value.
@@ -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
@@ -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: any): Promise<any> | undefined;
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
@@ -783,7 +783,7 @@ export default class Wizard extends Webform {
783
783
  this.originalComponents.push(_.clone(newPage));
784
784
  }
785
785
  }
786
- setForm(form, flags) {
786
+ setForm(form, flags = {}) {
787
787
  if (!form) {
788
788
  return;
789
789
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.55",
3
+ "version": "5.0.0-rc.57",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {