@formio/js 5.0.0-rc.32 → 5.0.0-rc.33

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@
12
12
 
13
13
  /*! @license DOMPurify 3.0.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.6/LICENSE */
14
14
 
15
- /*! formiojs v5.0.0-rc.32 | https://unpkg.com/formiojs@5.0.0-rc.32/LICENSE.txt */
15
+ /*! formiojs v5.0.0-rc.33 | https://unpkg.com/formiojs@5.0.0-rc.33/LICENSE.txt */
16
16
 
17
17
  /**
18
18
  * @license
package/lib/cjs/Embed.js CHANGED
@@ -268,7 +268,8 @@ class Formio {
268
268
  }
269
269
  }]
270
270
  }]));
271
- const renderer = Formio.config.debug ? 'formio.form' : 'formio.form.min';
271
+ const formioSrc = Formio.config.full ? 'formio.full' : 'formio.form';
272
+ const renderer = Formio.config.debug ? formioSrc : `${formioSrc}.min`;
272
273
  Formio.FormioClass = yield Formio.addScript(wrapper, Formio.formioScript(Formio.config.script || `${Formio.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');
273
274
  Formio.FormioClass.cdn = Formio.cdn;
274
275
  Formio.FormioClass.setBaseUrl(options.baseUrl || Formio.baseUrl || Formio.config.base);
@@ -312,7 +313,10 @@ class Formio {
312
313
  // Called after an instance has been created.
313
314
  static afterCreate(instance, wrapper, readyEvent) {
314
315
  return __awaiter(this, void 0, void 0, function* () {
315
- wrapper.removeChild(wrapper.querySelector('.formio-loader'));
316
+ const loader = wrapper.querySelector('.formio-loader');
317
+ if (loader) {
318
+ wrapper.removeChild(loader);
319
+ }
316
320
  Formio.FormioClass.events.emit(readyEvent, instance);
317
321
  if (Formio.config.after) {
318
322
  Formio.debug('Calling ready callback');
@@ -324,6 +328,9 @@ class Formio {
324
328
  // Create a new form.
325
329
  static createForm(element, form, options = {}) {
326
330
  return __awaiter(this, void 0, void 0, function* () {
331
+ if (Formio.FormioClass) {
332
+ return Formio.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));
333
+ }
327
334
  const wrapper = yield Formio.init(element, options);
328
335
  return Formio.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {
329
336
  // Set the default submission data.
@@ -339,7 +346,11 @@ class Formio {
339
346
  }
340
347
  // Create a form builder.
341
348
  static builder(element, form, options = {}) {
349
+ var _b;
342
350
  return __awaiter(this, void 0, void 0, function* () {
351
+ if ((_b = Formio.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {
352
+ return Formio.FormioClass.builder(element, form, options);
353
+ }
343
354
  const wrapper = yield Formio.init(element, options, true);
344
355
  return Formio.FormioClass.builder(element, form, options).then((instance) => {
345
356
  Formio.afterCreate(instance, wrapper, 'builderEmbedded');
@@ -362,6 +373,10 @@ Formio.version = 'FORMIO_VERSION';
362
373
  // Create a report.
363
374
  Formio.Report = {
364
375
  create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
376
+ var _b;
377
+ if ((_b = Formio.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {
378
+ return Formio.FormioClass.Report.create(element, submission, options);
379
+ }
365
380
  const wrapper = yield Formio.init(element, options, true);
366
381
  return Formio.FormioClass.Report.create(element, submission, options).then((instance) => {
367
382
  Formio.afterCreate(instance, wrapper, 'reportEmbedded');
@@ -384,6 +399,9 @@ class Form {
384
399
  };
385
400
  }
386
401
  init() {
402
+ if (this.instance && !this.instance.proxy) {
403
+ this.instance.destroy();
404
+ }
387
405
  this.element.innerHTML = '';
388
406
  this.ready = this.create().then((instance) => {
389
407
  this.instance = instance;
@@ -394,12 +412,22 @@ class Form {
394
412
  create() {
395
413
  return Formio.createForm(this.element, this.form, this.options);
396
414
  }
415
+ setForm(form) {
416
+ this.form = form;
417
+ if (this.instance) {
418
+ this.instance.setForm(form);
419
+ }
420
+ }
397
421
  setDisplay(display) {
398
422
  if (this.instance.proxy) {
399
423
  return this.ready;
400
424
  }
401
425
  this.form.display = display;
402
- this.init();
426
+ this.instance.destroy();
427
+ this.ready = this.create().then((instance) => {
428
+ this.instance = instance;
429
+ this.setForm(this.form);
430
+ });
403
431
  return this.ready;
404
432
  }
405
433
  }
@@ -97,7 +97,7 @@ class WizardBuilder extends WebformBuilder_1.default {
97
97
  const pages = this.pages;
98
98
  return (pages && (pages.length >= this.page)) ? pages[this.page] : null;
99
99
  }
100
- set form(value) {
100
+ setForm(value) {
101
101
  this._form = value;
102
102
  if (!this._form.components || !Array.isArray(this._form.components)) {
103
103
  this._form.components = [];
@@ -113,6 +113,9 @@ class WizardBuilder extends WebformBuilder_1.default {
113
113
  }
114
114
  this.rebuild();
115
115
  }
116
+ set form(value) {
117
+ this.setForm(value);
118
+ }
116
119
  get form() {
117
120
  return this._form;
118
121
  }
@@ -1891,7 +1891,7 @@ class Component extends Element_1.default {
1891
1891
  if (this.options.onChange) {
1892
1892
  this.options.onChange(...args);
1893
1893
  }
1894
- else if (this.root) {
1894
+ else if (this.root && this.root.triggerChange) {
1895
1895
  this.root.triggerChange(...args);
1896
1896
  }
1897
1897
  }
@@ -60,6 +60,10 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
60
60
  data = data || this.data;
61
61
  return this.validateComponents([this.component], data, flags);
62
62
  }
63
+ checkRow(...args) {
64
+ console.log('Deprecation Warning: checkRow method has been replaced with processRow');
65
+ return this.processRow.call(this, ...args);
66
+ }
63
67
  processRow(method, data, opts, row, components, silentCheck) {
64
68
  if (opts === null || opts === void 0 ? void 0 : opts.isolateRow) {
65
69
  silentCheck = true;
package/lib/mjs/Embed.js CHANGED
@@ -258,7 +258,8 @@ class Formio {
258
258
  }
259
259
  }]
260
260
  }]));
261
- const renderer = Formio.config.debug ? 'formio.form' : 'formio.form.min';
261
+ const formioSrc = Formio.config.full ? 'formio.full' : 'formio.form';
262
+ const renderer = Formio.config.debug ? formioSrc : `${formioSrc}.min`;
262
263
  Formio.FormioClass = await Formio.addScript(wrapper, Formio.formioScript(Formio.config.script || `${Formio.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');
263
264
  Formio.FormioClass.cdn = Formio.cdn;
264
265
  Formio.FormioClass.setBaseUrl(options.baseUrl || Formio.baseUrl || Formio.config.base);
@@ -300,7 +301,10 @@ class Formio {
300
301
  }
301
302
  // Called after an instance has been created.
302
303
  static async afterCreate(instance, wrapper, readyEvent) {
303
- wrapper.removeChild(wrapper.querySelector('.formio-loader'));
304
+ const loader = wrapper.querySelector('.formio-loader');
305
+ if (loader) {
306
+ wrapper.removeChild(loader);
307
+ }
304
308
  Formio.FormioClass.events.emit(readyEvent, instance);
305
309
  if (Formio.config.after) {
306
310
  Formio.debug('Calling ready callback');
@@ -310,6 +314,12 @@ class Formio {
310
314
  }
311
315
  // Create a new form.
312
316
  static async createForm(element, form, options = {}) {
317
+ if (Formio.FormioClass) {
318
+ return Formio.FormioClass.createForm(element, form, {
319
+ ...options,
320
+ ...{ noLoader: true }
321
+ });
322
+ }
313
323
  const wrapper = await Formio.init(element, options);
314
324
  return Formio.FormioClass.createForm(element, form, {
315
325
  ...options,
@@ -327,6 +337,9 @@ class Formio {
327
337
  }
328
338
  // Create a form builder.
329
339
  static async builder(element, form, options = {}) {
340
+ if (Formio.FormioClass?.builder) {
341
+ return Formio.FormioClass.builder(element, form, options);
342
+ }
330
343
  const wrapper = await Formio.init(element, options, true);
331
344
  return Formio.FormioClass.builder(element, form, options).then((instance) => {
332
345
  Formio.afterCreate(instance, wrapper, 'builderEmbedded');
@@ -336,6 +349,9 @@ class Formio {
336
349
  // Create a report.
337
350
  static Report = {
338
351
  create: async (element, submission, options = {}) => {
352
+ if (Formio.FormioClass?.Report) {
353
+ return Formio.FormioClass.Report.create(element, submission, options);
354
+ }
339
355
  const wrapper = await Formio.init(element, options, true);
340
356
  return Formio.FormioClass.Report.create(element, submission, options).then((instance) => {
341
357
  Formio.afterCreate(instance, wrapper, 'reportEmbedded');
@@ -359,6 +375,9 @@ export class Form {
359
375
  };
360
376
  }
361
377
  init() {
378
+ if (this.instance && !this.instance.proxy) {
379
+ this.instance.destroy();
380
+ }
362
381
  this.element.innerHTML = '';
363
382
  this.ready = this.create().then((instance) => {
364
383
  this.instance = instance;
@@ -369,12 +388,22 @@ export class Form {
369
388
  create() {
370
389
  return Formio.createForm(this.element, this.form, this.options);
371
390
  }
391
+ setForm(form) {
392
+ this.form = form;
393
+ if (this.instance) {
394
+ this.instance.setForm(form);
395
+ }
396
+ }
372
397
  setDisplay(display) {
373
398
  if (this.instance.proxy) {
374
399
  return this.ready;
375
400
  }
376
401
  this.form.display = display;
377
- this.init();
402
+ this.instance.destroy();
403
+ this.ready = this.create().then((instance) => {
404
+ this.instance = instance;
405
+ this.setForm(this.form);
406
+ });
378
407
  return this.ready;
379
408
  }
380
409
  }
@@ -92,7 +92,7 @@ export default class WizardBuilder extends WebformBuilder {
92
92
  const pages = this.pages;
93
93
  return (pages && (pages.length >= this.page)) ? pages[this.page] : null;
94
94
  }
95
- set form(value) {
95
+ setForm(value) {
96
96
  this._form = value;
97
97
  if (!this._form.components || !Array.isArray(this._form.components)) {
98
98
  this._form.components = [];
@@ -108,6 +108,9 @@ export default class WizardBuilder extends WebformBuilder {
108
108
  }
109
109
  this.rebuild();
110
110
  }
111
+ set form(value) {
112
+ this.setForm(value);
113
+ }
111
114
  get form() {
112
115
  return this._form;
113
116
  }
@@ -1855,7 +1855,7 @@ export default class Component extends Element {
1855
1855
  if (this.options.onChange) {
1856
1856
  this.options.onChange(...args);
1857
1857
  }
1858
- else if (this.root) {
1858
+ else if (this.root && this.root.triggerChange) {
1859
1859
  this.root.triggerChange(...args);
1860
1860
  }
1861
1861
  }
@@ -56,6 +56,10 @@ export default class NestedArrayComponent extends NestedDataComponent {
56
56
  data = data || this.data;
57
57
  return this.validateComponents([this.component], data, flags);
58
58
  }
59
+ checkRow(...args) {
60
+ console.log('Deprecation Warning: checkRow method has been replaced with processRow');
61
+ return this.processRow.call(this, ...args);
62
+ }
59
63
  processRow(method, data, opts, row, components, silentCheck) {
60
64
  if (opts?.isolateRow) {
61
65
  silentCheck = true;
@@ -4,7 +4,7 @@ import { editgrid as templates } from '@formio/bootstrap/components';
4
4
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
5
5
  import Component from '../_classes/component/Component';
6
6
  import Alert from '../alert/Alert';
7
- import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent, getComponentsSchema } from '../../utils/utils';
7
+ import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } from '../../utils/utils';
8
8
  const EditRowState = {
9
9
  New: 'new',
10
10
  Editing: 'editing',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.32",
3
+ "version": "5.0.0-rc.33",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {