@formio/js 5.0.0-rc.56 → 5.0.0-rc.57

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@
10
10
  * MIT licensed
11
11
  */
12
12
 
13
- /*! formiojs v5.0.0-rc.56 | https://unpkg.com/formiojs@5.0.0-rc.56/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.56 | https://unpkg.com/formiojs@5.0.0-rc.56/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>`;
@@ -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
  });
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>`;
@@ -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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.56",
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": {