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

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.58 | https://unpkg.com/formiojs@5.0.0-rc.58/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.58 | https://unpkg.com/formiojs@5.0.0-rc.58/LICENSE.txt */
26
26
 
27
27
  /**
28
28
  * @license
package/lib/cjs/CDN.d.ts CHANGED
@@ -10,6 +10,7 @@ declare class CDN {
10
10
  bootstrap: string;
11
11
  bootstrap4: string;
12
12
  bootstrap5: string;
13
+ bootswatch: string;
13
14
  'bootstrap-icons': string;
14
15
  ckeditor: string;
15
16
  flatpickr: string;
package/lib/cjs/CDN.js CHANGED
@@ -11,9 +11,10 @@ class CDN {
11
11
  this.libs = {
12
12
  'js': '',
13
13
  'ace': '1.4.12',
14
- 'bootstrap': '5.3.2',
14
+ 'bootstrap': '5.3.3',
15
15
  'bootstrap4': '4.6.2',
16
- 'bootstrap5': '5.3.2',
16
+ 'bootstrap5': '5.3.3',
17
+ 'bootswatch': '5.3.3',
17
18
  'bootstrap-icons': '1.11.1',
18
19
  'ckeditor': '19.0.0',
19
20
  'flatpickr': '4.6.8',
@@ -61,7 +62,9 @@ class CDN {
61
62
  if (lib) {
62
63
  url += `/${lib}`;
63
64
  }
64
- if (version && version !== 'latest') {
65
+ // Only attach the version if this is the hosted cdn.
66
+ if (cdnUrl.includes('form.io') &&
67
+ version && version !== 'latest') {
65
68
  url += `/${version}`;
66
69
  }
67
70
  return url;
@@ -26,7 +26,7 @@ export class Formio {
26
26
  static addStyles(wrapper: any, href: any): Promise<void>;
27
27
  static submitDone(instance: any, submission: any): Promise<void>;
28
28
  static formioScript(script: any, builder: any): any;
29
- static addLibrary(wrapper: any, lib: any, name: any): Promise<void>;
29
+ static addLibrary(libWrapper: any, lib: any, name: any): Promise<void>;
30
30
  static addLoader(wrapper: any): Promise<void>;
31
31
  static init(element: any, options?: {}, builder?: boolean): Promise<any>;
32
32
  static afterCreate(instance: any, wrapper: any, readyEvent: any): Promise<any>;
package/lib/cjs/Embed.js CHANGED
@@ -80,6 +80,9 @@ class Formio {
80
80
  }
81
81
  static createElement(type, attrs, children) {
82
82
  const element = document.createElement(type);
83
+ if (!attrs) {
84
+ return element;
85
+ }
83
86
  Object.keys(attrs).forEach(key => {
84
87
  element.setAttribute(key, attrs[key]);
85
88
  });
@@ -144,6 +147,9 @@ class Formio {
144
147
  static submitDone(instance, submission) {
145
148
  return __awaiter(this, void 0, void 0, function* () {
146
149
  _a.debug('Submision Complete', submission);
150
+ if (_a.config.submitDone) {
151
+ _a.config.submitDone(submission, instance);
152
+ }
147
153
  const successMessage = (_a.config.success || '').toString();
148
154
  if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {
149
155
  instance.element.innerHTML = `<div class="alert-success" role="alert">${successMessage}</div>`;
@@ -184,21 +190,22 @@ class Formio {
184
190
  }
185
191
  return script;
186
192
  }
187
- static addLibrary(wrapper, lib, name) {
193
+ static addLibrary(libWrapper, lib, name) {
188
194
  return __awaiter(this, void 0, void 0, function* () {
189
195
  if (!lib) {
190
196
  return;
191
197
  }
192
198
  if (lib.dependencies) {
193
199
  for (let i = 0; i < lib.dependencies.length; i++) {
194
- yield _a.addLibrary(wrapper, _a.cdn.libs[lib.dependencies[i]]);
200
+ const libName = lib.dependencies[i];
201
+ yield _a.addLibrary(libWrapper, _a.config.libs[libName], libName);
195
202
  }
196
203
  }
197
204
  if (lib.css) {
198
- yield _a.addStyles(wrapper, lib.css);
205
+ yield _a.addStyles((lib.global ? document.body : libWrapper), lib.css);
199
206
  }
200
207
  if (lib.js) {
201
- const module = yield _a.addScript(wrapper, lib.js, lib.use ? name : false);
208
+ const module = yield _a.addScript((lib.global ? document.body : libWrapper), lib.js, lib.use ? name : false);
202
209
  if (lib.use) {
203
210
  _a.debug(`Using ${name}`);
204
211
  const options = lib.options || {};
@@ -208,6 +215,12 @@ class Formio {
208
215
  _a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);
209
216
  }
210
217
  }
218
+ if (lib.globalStyle) {
219
+ const style = _a.createElement('style');
220
+ style.type = 'text/css';
221
+ style.innerHTML = lib.globalStyle;
222
+ document.body.appendChild(style);
223
+ }
211
224
  });
212
225
  }
213
226
  static addLoader(wrapper) {
@@ -240,7 +253,16 @@ class Formio {
240
253
  use: true
241
254
  },
242
255
  fontawesome: {
243
- css: `${_a.cdn['font-awesome']}/css/font-awesome.min.css`
256
+ // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need
257
+ // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.
258
+ css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,
259
+ globalStyle: `@font-face {
260
+ font-family: 'FontAwesome';
261
+ src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');
262
+ src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
263
+ font-weight: normal;
264
+ font-style: normal;
265
+ }`
244
266
  },
245
267
  bootstrap4: {
246
268
  dependencies: ['fontawesome'],
@@ -251,9 +273,24 @@ class Formio {
251
273
  css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`
252
274
  },
253
275
  'bootstrap-icons': {
254
- css: `${_a.cdn['bootstrap-icons']}/css/bootstrap-icons.css`
276
+ // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need
277
+ // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.
278
+ css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',
279
+ globalStyle: `@font-face {
280
+ font-display: block;
281
+ font-family: "bootstrap-icons";
282
+ src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),
283
+ url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");
284
+ }`
255
285
  }
256
286
  };
287
+ // Add all bootswatch templates.
288
+ ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {
289
+ _a.config.libs[template] = {
290
+ dependencies: ['bootstrap-icons'],
291
+ css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.css`
292
+ };
293
+ });
257
294
  const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;
258
295
  // Create a new wrapper and add the element inside of a new wrapper.
259
296
  let wrapper = _a.createElement('div', {
@@ -261,7 +298,7 @@ class Formio {
261
298
  });
262
299
  element.parentNode.insertBefore(wrapper, element);
263
300
  // If we include the libraries, then we will attempt to run this in shadow dom.
264
- const useShadowDom = _a.config.includeLibs && (typeof wrapper.attachShadow === 'function');
301
+ const useShadowDom = _a.config.includeLibs && !_a.config.noshadow && (typeof wrapper.attachShadow === 'function');
265
302
  if (useShadowDom) {
266
303
  wrapper = wrapper.attachShadow({
267
304
  mode: 'open'
@@ -27,16 +27,21 @@ 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 (['js', 'offline'].includes(scriptSrc[scriptSrc.length - 1])) {
32
+ scriptSrc.pop();
33
+ scriptSrc = cdnSrc = scriptSrc.join('/');
34
+ scriptSrc += '/js';
35
+ }
36
+ else {
37
+ scriptSrc = scriptSrc.join('/');
32
38
  }
33
- scriptSrc = scriptSrc.join('/');
34
39
  const debug = (query.debug === 'true' || query.debug === '1');
35
40
  const renderer = debug ? 'formio.form' : 'formio.form.min';
36
41
  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,
42
+ script: query.script || (`${scriptSrc}/${renderer}.js`),
43
+ style: query.styles || (`${scriptSrc}/${renderer}.css`),
44
+ cdn: query.cdn || cdnSrc,
40
45
  class: (query.class || 'formio-form-wrapper'),
41
46
  src: query.src,
42
47
  form: null,
@@ -45,21 +50,22 @@ function embed(config = {}) {
45
50
  base: query.base || 'https://api.form.io',
46
51
  submit: query.submit,
47
52
  includeLibs: (query.libs === 'true' || query.libs === '1'),
48
- template: query.template,
53
+ noshadow: (query.shadow === 'false' || query.shadow === '0'),
54
+ template: query.template || 'bootstrap',
49
55
  debug: debug,
50
56
  config: {},
51
57
  redirect: (query.return || query.redirect),
52
- embedCSS: (`${config.updatePath ? config.updatePath() : scriptSrc}/formio.embed.css`),
58
+ embedCSS: (`${scriptSrc}/formio.embed.css`),
53
59
  success: query.success || 'Thank you for your submission!',
54
60
  before: null,
55
61
  after: null
56
62
  }, config);
63
+ if (Embed_1.Formio.config.alter) {
64
+ Embed_1.Formio.config.alter(Embed_1.Formio.config);
65
+ }
57
66
  const form = (Embed_1.Formio.config.form || Embed_1.Formio.config.src);
58
67
  if (form) {
59
68
  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
69
  // The id for this embedded form.
64
70
  Embed_1.Formio.config.id = `formio-${Math.random().toString(36).substring(7)}`;
65
71
  Embed_1.Formio.debug('Creating form element');
@@ -73,6 +79,8 @@ function embed(config = {}) {
73
79
  if (Embed_1.Formio.config.submit) {
74
80
  instance.nosubmit = true;
75
81
  }
82
+ // Trigger the submit done event.
83
+ instance.on('submitDone', (submission) => Embed_1.Formio.submitDone(instance, submission));
76
84
  // Configure a redirect.
77
85
  instance.on('submit', (submission) => {
78
86
  Embed_1.Formio.debug("on('submit')", submission);
@@ -92,10 +100,9 @@ function embed(config = {}) {
92
100
  mode: 'cors',
93
101
  })
94
102
  .then(resp => resp.json())
95
- .then(submission => Embed_1.Formio.submitDone(instance, submission));
96
- }
97
- else {
98
- Embed_1.Formio.submitDone(instance, submission);
103
+ .then((submission) => {
104
+ Embed_1.Formio.submitDone(instance, submission);
105
+ });
99
106
  }
100
107
  });
101
108
  });
package/lib/mjs/CDN.d.ts CHANGED
@@ -10,6 +10,7 @@ declare class CDN {
10
10
  bootstrap: string;
11
11
  bootstrap4: string;
12
12
  bootstrap5: string;
13
+ bootswatch: string;
13
14
  'bootstrap-icons': string;
14
15
  ckeditor: string;
15
16
  flatpickr: string;
package/lib/mjs/CDN.js CHANGED
@@ -10,9 +10,10 @@ class CDN {
10
10
  this.libs = {
11
11
  'js': '',
12
12
  'ace': '1.4.12',
13
- 'bootstrap': '5.3.2',
13
+ 'bootstrap': '5.3.3',
14
14
  'bootstrap4': '4.6.2',
15
- 'bootstrap5': '5.3.2',
15
+ 'bootstrap5': '5.3.3',
16
+ 'bootswatch': '5.3.3',
16
17
  'bootstrap-icons': '1.11.1',
17
18
  'ckeditor': '19.0.0',
18
19
  'flatpickr': '4.6.8',
@@ -60,7 +61,9 @@ class CDN {
60
61
  if (lib) {
61
62
  url += `/${lib}`;
62
63
  }
63
- if (version && version !== 'latest') {
64
+ // Only attach the version if this is the hosted cdn.
65
+ if (cdnUrl.includes('form.io') &&
66
+ version && version !== 'latest') {
64
67
  url += `/${version}`;
65
68
  }
66
69
  return url;
@@ -26,7 +26,7 @@ export class Formio {
26
26
  static addStyles(wrapper: any, href: any): Promise<void>;
27
27
  static submitDone(instance: any, submission: any): Promise<void>;
28
28
  static formioScript(script: any, builder: any): any;
29
- static addLibrary(wrapper: any, lib: any, name: any): Promise<void>;
29
+ static addLibrary(libWrapper: any, lib: any, name: any): Promise<void>;
30
30
  static addLoader(wrapper: any): Promise<void>;
31
31
  static init(element: any, options?: {}, builder?: boolean): Promise<any>;
32
32
  static afterCreate(instance: any, wrapper: any, readyEvent: any): Promise<any>;
package/lib/mjs/Embed.js CHANGED
@@ -79,6 +79,9 @@ export class Formio {
79
79
  }
80
80
  static createElement(type, attrs, children) {
81
81
  const element = document.createElement(type);
82
+ if (!attrs) {
83
+ return element;
84
+ }
82
85
  Object.keys(attrs).forEach(key => {
83
86
  element.setAttribute(key, attrs[key]);
84
87
  });
@@ -138,6 +141,9 @@ export class Formio {
138
141
  }
139
142
  static async submitDone(instance, submission) {
140
143
  Formio.debug('Submision Complete', submission);
144
+ if (Formio.config.submitDone) {
145
+ Formio.config.submitDone(submission, instance);
146
+ }
141
147
  const successMessage = (Formio.config.success || '').toString();
142
148
  if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {
143
149
  instance.element.innerHTML = `<div class="alert-success" role="alert">${successMessage}</div>`;
@@ -177,20 +183,21 @@ export class Formio {
177
183
  }
178
184
  return script;
179
185
  }
180
- static async addLibrary(wrapper, lib, name) {
186
+ static async addLibrary(libWrapper, lib, name) {
181
187
  if (!lib) {
182
188
  return;
183
189
  }
184
190
  if (lib.dependencies) {
185
191
  for (let i = 0; i < lib.dependencies.length; i++) {
186
- await Formio.addLibrary(wrapper, Formio.cdn.libs[lib.dependencies[i]]);
192
+ const libName = lib.dependencies[i];
193
+ await Formio.addLibrary(libWrapper, Formio.config.libs[libName], libName);
187
194
  }
188
195
  }
189
196
  if (lib.css) {
190
- await Formio.addStyles(wrapper, lib.css);
197
+ await Formio.addStyles((lib.global ? document.body : libWrapper), lib.css);
191
198
  }
192
199
  if (lib.js) {
193
- const module = await Formio.addScript(wrapper, lib.js, lib.use ? name : false);
200
+ const module = await Formio.addScript((lib.global ? document.body : libWrapper), lib.js, lib.use ? name : false);
194
201
  if (lib.use) {
195
202
  Formio.debug(`Using ${name}`);
196
203
  const options = lib.options || {};
@@ -200,6 +207,12 @@ export class Formio {
200
207
  Formio.use((typeof lib.use === 'function' ? lib.use(module) : module), options);
201
208
  }
202
209
  }
210
+ if (lib.globalStyle) {
211
+ const style = Formio.createElement('style');
212
+ style.type = 'text/css';
213
+ style.innerHTML = lib.globalStyle;
214
+ document.body.appendChild(style);
215
+ }
203
216
  }
204
217
  static async addLoader(wrapper) {
205
218
  wrapper.appendChild(Formio.createElement('div', {
@@ -228,7 +241,16 @@ export class Formio {
228
241
  use: true
229
242
  },
230
243
  fontawesome: {
231
- css: `${Formio.cdn['font-awesome']}/css/font-awesome.min.css`
244
+ // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need
245
+ // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.
246
+ css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,
247
+ globalStyle: `@font-face {
248
+ font-family: 'FontAwesome';
249
+ src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');
250
+ src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
251
+ font-weight: normal;
252
+ font-style: normal;
253
+ }`
232
254
  },
233
255
  bootstrap4: {
234
256
  dependencies: ['fontawesome'],
@@ -239,9 +261,24 @@ export class Formio {
239
261
  css: `${Formio.cdn.bootstrap}/css/bootstrap.min.css`
240
262
  },
241
263
  'bootstrap-icons': {
242
- css: `${Formio.cdn['bootstrap-icons']}/css/bootstrap-icons.css`
264
+ // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need
265
+ // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.
266
+ css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',
267
+ globalStyle: `@font-face {
268
+ font-display: block;
269
+ font-family: "bootstrap-icons";
270
+ src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),
271
+ url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");
272
+ }`
243
273
  }
244
274
  };
275
+ // Add all bootswatch templates.
276
+ ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {
277
+ Formio.config.libs[template] = {
278
+ dependencies: ['bootstrap-icons'],
279
+ css: `${Formio.cdn.bootswatch}/dist/${template}/bootstrap.min.css`
280
+ };
281
+ });
245
282
  const id = Formio.config.id || `formio-${Math.random().toString(36).substring(7)}`;
246
283
  // Create a new wrapper and add the element inside of a new wrapper.
247
284
  let wrapper = Formio.createElement('div', {
@@ -249,7 +286,7 @@ export class Formio {
249
286
  });
250
287
  element.parentNode.insertBefore(wrapper, element);
251
288
  // If we include the libraries, then we will attempt to run this in shadow dom.
252
- const useShadowDom = Formio.config.includeLibs && (typeof wrapper.attachShadow === 'function');
289
+ const useShadowDom = Formio.config.includeLibs && !Formio.config.noshadow && (typeof wrapper.attachShadow === 'function');
253
290
  if (useShadowDom) {
254
291
  wrapper = wrapper.attachShadow({
255
292
  mode: 'open'
@@ -23,16 +23,21 @@ 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 (['js', 'offline'].includes(scriptSrc[scriptSrc.length - 1])) {
28
+ scriptSrc.pop();
29
+ scriptSrc = cdnSrc = scriptSrc.join('/');
30
+ scriptSrc += '/js';
31
+ }
32
+ else {
33
+ scriptSrc = scriptSrc.join('/');
28
34
  }
29
- scriptSrc = scriptSrc.join('/');
30
35
  const debug = (query.debug === 'true' || query.debug === '1');
31
36
  const renderer = debug ? 'formio.form' : 'formio.form.min';
32
37
  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,
38
+ script: query.script || (`${scriptSrc}/${renderer}.js`),
39
+ style: query.styles || (`${scriptSrc}/${renderer}.css`),
40
+ cdn: query.cdn || cdnSrc,
36
41
  class: (query.class || 'formio-form-wrapper'),
37
42
  src: query.src,
38
43
  form: null,
@@ -41,21 +46,22 @@ export function embed(config = {}) {
41
46
  base: query.base || 'https://api.form.io',
42
47
  submit: query.submit,
43
48
  includeLibs: (query.libs === 'true' || query.libs === '1'),
44
- template: query.template,
49
+ noshadow: (query.shadow === 'false' || query.shadow === '0'),
50
+ template: query.template || 'bootstrap',
45
51
  debug: debug,
46
52
  config: {},
47
53
  redirect: (query.return || query.redirect),
48
- embedCSS: (`${config.updatePath ? config.updatePath() : scriptSrc}/formio.embed.css`),
54
+ embedCSS: (`${scriptSrc}/formio.embed.css`),
49
55
  success: query.success || 'Thank you for your submission!',
50
56
  before: null,
51
57
  after: null
52
58
  }, config);
59
+ if (Formio.config.alter) {
60
+ Formio.config.alter(Formio.config);
61
+ }
53
62
  const form = (Formio.config.form || Formio.config.src);
54
63
  if (form) {
55
64
  Formio.debug('Embedding Configuration', config);
56
- if (Formio.config.addPremiumLib) {
57
- Formio.config.addPremiumLib(Formio.config, scriptSrc);
58
- }
59
65
  // The id for this embedded form.
60
66
  Formio.config.id = `formio-${Math.random().toString(36).substring(7)}`;
61
67
  Formio.debug('Creating form element');
@@ -69,6 +75,8 @@ export function embed(config = {}) {
69
75
  if (Formio.config.submit) {
70
76
  instance.nosubmit = true;
71
77
  }
78
+ // Trigger the submit done event.
79
+ instance.on('submitDone', (submission) => Formio.submitDone(instance, submission));
72
80
  // Configure a redirect.
73
81
  instance.on('submit', (submission) => {
74
82
  Formio.debug("on('submit')", submission);
@@ -88,10 +96,9 @@ export function embed(config = {}) {
88
96
  mode: 'cors',
89
97
  })
90
98
  .then(resp => resp.json())
91
- .then(submission => Formio.submitDone(instance, submission));
92
- }
93
- else {
94
- Formio.submitDone(instance, submission);
99
+ .then((submission) => {
100
+ Formio.submitDone(instance, submission);
101
+ });
95
102
  }
96
103
  });
97
104
  });
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.58",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {