@formio/js 5.2.1-rc.8 → 5.2.1

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.
Files changed (56) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +13 -13
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.full.js +15 -15
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  10. package/dist/formio.js +3 -3
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +2 -2
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  16. package/lib/cjs/Element.js +2 -2
  17. package/lib/cjs/Embed.js +1 -1
  18. package/lib/cjs/Formio.js +1 -1
  19. package/lib/cjs/WebformBuilder.d.ts +1 -0
  20. package/lib/cjs/WebformBuilder.js +15 -0
  21. package/lib/cjs/Wizard.js +2 -6
  22. package/lib/cjs/WizardBuilder.js +4 -0
  23. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  24. package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -2
  25. package/lib/cjs/components/datagrid/DataGrid.js +8 -1
  26. package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
  27. package/lib/cjs/components/form/Form.d.ts +2 -1
  28. package/lib/cjs/components/form/Form.js +32 -20
  29. package/lib/cjs/components/radio/Radio.js +1 -1
  30. package/lib/cjs/components/select/Select.js +1 -1
  31. package/lib/cjs/components/tags/Tags.js +7 -0
  32. package/lib/cjs/formio.form.d.ts +2 -1
  33. package/lib/cjs/formio.form.js +2 -1
  34. package/lib/cjs/utils/index.d.ts +3 -2
  35. package/lib/cjs/utils/index.js +2 -1
  36. package/lib/mjs/Element.js +2 -2
  37. package/lib/mjs/Embed.js +1 -1
  38. package/lib/mjs/Formio.js +1 -1
  39. package/lib/mjs/WebformBuilder.d.ts +1 -0
  40. package/lib/mjs/WebformBuilder.js +14 -0
  41. package/lib/mjs/Wizard.js +2 -6
  42. package/lib/mjs/WizardBuilder.js +4 -0
  43. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  44. package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -2
  45. package/lib/mjs/components/datagrid/DataGrid.js +7 -1
  46. package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
  47. package/lib/mjs/components/form/Form.d.ts +2 -1
  48. package/lib/mjs/components/form/Form.js +32 -20
  49. package/lib/mjs/components/radio/Radio.js +1 -1
  50. package/lib/mjs/components/select/Select.js +1 -1
  51. package/lib/mjs/components/tags/Tags.js +7 -0
  52. package/lib/mjs/formio.form.d.ts +2 -1
  53. package/lib/mjs/formio.form.js +2 -2
  54. package/lib/mjs/utils/index.d.ts +3 -2
  55. package/lib/mjs/utils/index.js +2 -2
  56. package/package.json +3 -3
@@ -20,7 +20,7 @@
20
20
 
21
21
  /*! @license DOMPurify 3.2.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.2.4/LICENSE */
22
22
 
23
- /*! formiojs v5.2.1-rc.8 | https://unpkg.com/formiojs@5.2.1-rc.8/LICENSE.txt */
23
+ /*! formiojs v5.2.1 | https://unpkg.com/formiojs@5.2.1/LICENSE.txt */
24
24
 
25
25
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
26
26
 
@@ -531,9 +531,9 @@ class Element {
531
531
  if (this.component.filter === string && !this.options.building) {
532
532
  const evalContext = this.evalContext(data);
533
533
  evalContext.data = lodash_1.default.mapValues(evalContext.data, (val) => lodash_1.default.isString(val) ? encodeURIComponent(val) : val);
534
- return utils_1.default.Evaluator.interpolate(string, evalContext, options);
534
+ return utils_1.default.interpolate(string, evalContext, options);
535
535
  }
536
- return utils_1.default.Evaluator.interpolate(string, this.evalContext(data), options);
536
+ return utils_1.default.interpolate(string, this.evalContext(data), options);
537
537
  }
538
538
  /**
539
539
  * Performs an evaluation using the evaluation context of this component.
package/lib/cjs/Embed.js CHANGED
@@ -418,7 +418,7 @@ Formio.formioReady = new Promise((ready, reject) => {
418
418
  _a._formioReady = ready;
419
419
  _a._formioReadyReject = reject;
420
420
  });
421
- Formio.version = '5.2.1-rc.8';
421
+ Formio.version = '5.2.1';
422
422
  // Create a report.
423
423
  Formio.Report = {
424
424
  create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
package/lib/cjs/Formio.js CHANGED
@@ -11,7 +11,7 @@ const CDN_1 = __importDefault(require("./CDN"));
11
11
  const providers_1 = __importDefault(require("./providers"));
12
12
  sdk_1.Formio.cdn = new CDN_1.default();
13
13
  sdk_1.Formio.Providers = providers_1.default;
14
- sdk_1.Formio.version = '5.2.1-rc.8';
14
+ sdk_1.Formio.version = '5.2.1';
15
15
  CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
16
16
  const isNil = (val) => val === null || val === undefined;
17
17
  sdk_1.Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
@@ -77,6 +77,7 @@ export default class WebformBuilder extends Component {
77
77
  removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
78
78
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
79
79
  updateComponent(component: any, changed: any): void;
80
+ originalDefaultValue: any;
80
81
  findComponentsWithRepeatablePaths(): any[];
81
82
  highlightInvalidComponents(): void;
82
83
  /**
@@ -1089,6 +1089,17 @@ class WebformBuilder extends Component_1.default {
1089
1089
  'fields.month.required',
1090
1090
  'fields.year.required',
1091
1091
  ]));
1092
+ if (defaultValueComponent.component.components) {
1093
+ if (!this.originalDefaultValue) {
1094
+ this.originalDefaultValue = (0, utils_1.fastCloneDeep)(defaultValueComponent.component);
1095
+ }
1096
+ (0, utils_1.eachComponent)(defaultValueComponent.component.components, (comp => {
1097
+ var _a;
1098
+ if ((_a = comp.validate) === null || _a === void 0 ? void 0 : _a.required) {
1099
+ comp.validate.required = false;
1100
+ }
1101
+ }));
1102
+ }
1092
1103
  const parentComponent = defaultValueComponent.parent;
1093
1104
  let tabIndex = -1;
1094
1105
  let index = -1;
@@ -1198,6 +1209,10 @@ class WebformBuilder extends Component_1.default {
1198
1209
  if (index !== -1) {
1199
1210
  let submissionData = this.editForm.submission.data;
1200
1211
  submissionData = submissionData.componentJson || submissionData;
1212
+ if (submissionData.components && this.originalDefaultValue) {
1213
+ submissionData.components = this.originalDefaultValue.components;
1214
+ this.originalDefaultValue = null;
1215
+ }
1201
1216
  const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
1202
1217
  this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
1203
1218
  this.hook('beforeSaveComponentSettings', submissionData);
package/lib/cjs/Wizard.js CHANGED
@@ -599,7 +599,7 @@ class Wizard extends Webform_1.default {
599
599
  if (!this._seenPages.includes(parentNum)) {
600
600
  this._seenPages = this._seenPages.concat(parentNum);
601
601
  }
602
- this.redraw().then(() => {
602
+ return this.redraw().then(() => {
603
603
  this.checkData(this.submission.data);
604
604
  this.triggerCaptcha(this.currentPage.components);
605
605
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
@@ -607,7 +607,6 @@ class Wizard extends Webform_1.default {
607
607
  this.showErrors(errors, true, true);
608
608
  }
609
609
  });
610
- return Promise.resolve();
611
610
  }
612
611
  else if (!this.pages.length) {
613
612
  this.redraw();
@@ -936,10 +935,7 @@ class Wizard extends Webform_1.default {
936
935
  if (pageIndex >= 0) {
937
936
  const page = this.pages[pageIndex];
938
937
  if (page && page !== this.currentPage) {
939
- return this.setPage(pageIndex).then(() => {
940
- this.showErrors(this.validate(this.localData, { dirty: true }));
941
- super.focusOnComponent(key);
942
- });
938
+ return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
943
939
  }
944
940
  }
945
941
  }
@@ -183,6 +183,10 @@ class WizardBuilder extends WebformBuilder_1.default {
183
183
  this.navigationDragula = null;
184
184
  super.detach();
185
185
  }
186
+ destroy(all = false) {
187
+ this.off('saveComponent');
188
+ super.destroy(all);
189
+ }
186
190
  rebuild() {
187
191
  var _a;
188
192
  const page = this.currentPage;
@@ -155,7 +155,7 @@ export default class NestedComponent extends Field {
155
155
  * @param {import('@formio/core').Component[]} components - The components to attach logic to.
156
156
  */
157
157
  attachComponentsLogic(components: import('@formio/core').Component[]): void;
158
- attachComponents(element: any, components: any, container: any): Promise<any>;
158
+ attachComponents(element: any, components: any, container: any): Promise<void> | Promise<any[]>;
159
159
  /**
160
160
  * Remove a component from the components array and from the children object
161
161
  * @param {import('@formio/core').Component} component - The component to remove from the components.
@@ -538,8 +538,7 @@ class NestedComponent extends Field_1.default {
538
538
  container = container || this.component.components;
539
539
  element = this.hook('attachComponents', element, components, container, this);
540
540
  if (!element) {
541
- // Return a non-resolving promise.
542
- return (new Promise(() => { }));
541
+ return Promise.resolve();
543
542
  }
544
543
  let index = 0;
545
544
  const promises = [];
@@ -477,11 +477,18 @@ class DataGridComponent extends NestedArrayComponent_1.default {
477
477
  options.row = `${rowIndex}-${colIndex}`;
478
478
  options.rowIndex = rowIndex;
479
479
  options.onChange = (flags, changed, modified) => {
480
+ var _a, _b;
480
481
  if (changed.component.type === 'form') {
481
482
  const formComp = (0, utils_1.getComponent)(this.component.components, changed.component.key);
482
483
  lodash_1.default.set(formComp, 'components', changed.component.components);
483
484
  }
484
- this.triggerChange({ modified });
485
+ // If we're in a nested form we need to ensure our changes are triggered upstream
486
+ if (((_a = changed.instance.root) === null || _a === void 0 ? void 0 : _a.id) && (((_b = this.root) === null || _b === void 0 ? void 0 : _b.id) !== changed.instance.root.id)) {
487
+ changed.instance.root.triggerChange(flags, changed, modified);
488
+ }
489
+ else {
490
+ this.triggerChange({ modified });
491
+ }
485
492
  };
486
493
  let columnComponent;
487
494
  if (this.builderMode) {
@@ -73,10 +73,10 @@ export default class EditGridComponent extends NestedArrayComponent {
73
73
  rowIndex: any;
74
74
  } | undefined;
75
75
  emptyRow: any;
76
- addRowModal(rowIndex: any): Promise<any>;
76
+ addRowModal(rowIndex: any): Promise<void> | Promise<any[]>;
77
77
  alert: Alert | null | undefined;
78
78
  showDialog(rowIndex: any): Promise<any>;
79
- editRow(rowIndex: any): Promise<any>;
79
+ editRow(rowIndex: any): Promise<void> | Promise<any[]>;
80
80
  clearErrors(rowIndex: any): void;
81
81
  cancelRow(rowIndex: any): void;
82
82
  saveRow(rowIndex: any, modified: any): boolean | undefined;
@@ -29,7 +29,7 @@ export default class FormComponent extends Component {
29
29
  * Prints out the value of form components as a datagrid value.
30
30
  */
31
31
  getValueAsString(value: any, options: any): any;
32
- attach(element: any): Promise<void>;
32
+ attach(element: any): Promise<any>;
33
33
  get hasLoadedForm(): any;
34
34
  get isRevisionChanged(): any;
35
35
  get subFormData(): any;
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
42
42
  everyComponent(...args: any[]): any;
43
43
  setSubFormDisabled(subForm: any): void;
44
44
  updateSubWizards(subForm: any): void;
45
+ setComponentsMap(): void;
45
46
  /**
46
47
  * Create a subform instance.
47
48
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
@@ -289,29 +289,35 @@ class FormComponent extends Component_1.default {
289
289
  return;
290
290
  }
291
291
  this.setContent(element, this.render());
292
+ const postAttach = () => {
293
+ if (!this.builderMode && this.component.modalEdit) {
294
+ const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
295
+ const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
296
+ this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
297
+ this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
298
+ this.setOpenModalElement();
299
+ }
300
+ this.calculateValue();
301
+ };
292
302
  if (this.subForm) {
293
303
  if (this.isNestedWizard) {
294
304
  element = this.root.element;
295
305
  }
296
- this.subForm.attach(element);
297
- this.valueChanged = this.hasSetValue;
298
- if (!this.shouldConditionallyClear()) {
299
- if (!this.valueChanged && this.dataValue.state !== 'submitted') {
300
- this.setDefaultValue();
301
- }
302
- else {
303
- this.restoreValue();
306
+ return this.subForm.attach(element).then(() => {
307
+ this.valueChanged = this.hasSetValue;
308
+ if (!this.shouldConditionallyClear()) {
309
+ if (!this.valueChanged && this.dataValue.state !== 'submitted') {
310
+ this.setDefaultValue();
311
+ }
312
+ else {
313
+ this.restoreValue();
314
+ }
304
315
  }
305
- }
306
- }
307
- if (!this.builderMode && this.component.modalEdit) {
308
- const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
309
- const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
310
- this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
311
- this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
312
- this.setOpenModalElement();
316
+ postAttach();
317
+ this.setComponentsMap();
318
+ });
313
319
  }
314
- this.calculateValue();
320
+ postAttach();
315
321
  });
316
322
  });
317
323
  }
@@ -389,6 +395,14 @@ class FormComponent extends Component_1.default {
389
395
  this.emit('subWizardsUpdated', subForm);
390
396
  }
391
397
  }
398
+ setComponentsMap() {
399
+ if (!this.subForm) {
400
+ return;
401
+ }
402
+ const componentsMap = this.componentsMap;
403
+ const formComponentsMap = this.subForm.componentsMap;
404
+ lodash_1.default.assign(componentsMap, formComponentsMap);
405
+ }
392
406
  /**
393
407
  * Create a subform instance.
394
408
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
@@ -414,9 +428,7 @@ class FormComponent extends Component_1.default {
414
428
  this.subForm = instance;
415
429
  this.subForm.currentForm = this;
416
430
  this.subForm.parentVisible = this.visible;
417
- const componentsMap = this.componentsMap;
418
- const formComponentsMap = this.subForm.componentsMap;
419
- lodash_1.default.assign(componentsMap, formComponentsMap);
431
+ this.setComponentsMap();
420
432
  this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
421
433
  this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
422
434
  this.subForm.on('change', () => {
@@ -142,7 +142,7 @@ class RadioComponent extends ListComponent_1.default {
142
142
  });
143
143
  this.optionsLoaded = !this.component.dataSrc || this.component.dataSrc === 'values';
144
144
  this.loadedOptions = [];
145
- if (!this.visible) {
145
+ if (!this.visible || this.optionsLoaded) {
146
146
  this.itemsLoadedResolve();
147
147
  }
148
148
  // Get the template keys for this radio component.
@@ -1123,7 +1123,7 @@ class SelectComponent extends ListComponent_1.default {
1123
1123
  }
1124
1124
  // Choices will return undefined if nothing is selected. We really want '' to be empty.
1125
1125
  if (value === undefined || value === null) {
1126
- value = '';
1126
+ value = this.emptyValue;
1127
1127
  }
1128
1128
  return value;
1129
1129
  }
@@ -160,6 +160,13 @@ class TagsComponent extends Input_1.default {
160
160
  this.refs.input[0].parentNode.lastChild.focus();
161
161
  }
162
162
  }
163
+ getValue() {
164
+ if (this.choices) {
165
+ const value = this.choices.getValue(true);
166
+ return value.join(`${this.delimiter}`);
167
+ }
168
+ return super.getValue();
169
+ }
163
170
  getValueAsString(value) {
164
171
  if (!value) {
165
172
  return '';
@@ -23,4 +23,5 @@ import { Formio } from './Formio';
23
23
  import Licenses from './licenses';
24
24
  import EventEmitter from './EventEmitter';
25
25
  import Webform from './Webform';
26
- export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform };
26
+ import { DefaultEvaluator } from './utils';
27
+ export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
6
+ exports.DefaultEvaluator = exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const Formio_1 = require("./Formio");
9
9
  Object.defineProperty(exports, "Formio", { enumerable: true, get: function () { return Formio_1.Formio; } });
@@ -29,6 +29,7 @@ exports.EventEmitter = EventEmitter_1.default;
29
29
  const Webform_1 = __importDefault(require("./Webform"));
30
30
  exports.Webform = Webform_1.default;
31
31
  const utils_2 = require("./utils");
32
+ Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return utils_2.DefaultEvaluator; } });
32
33
  Formio_1.Formio.loadModules = (path = `${Formio_1.Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
33
34
  Formio_1.Formio.requireLibrary(name, name, path, true)
34
35
  .then((modules) => {
@@ -2,7 +2,7 @@ export * from "./utils";
2
2
  export * from "./formUtils";
3
3
  export default FormioUtils;
4
4
  declare const FormioUtils: {
5
- Evaluator: import("./Evaluator").DefaultEvaluator;
5
+ Evaluator: DefaultEvaluator;
6
6
  interpolate: typeof interpolate;
7
7
  ConditionOperators: {
8
8
  [x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
@@ -163,6 +163,7 @@ declare const FormioUtils: {
163
163
  };
164
164
  import { Evaluator } from './Evaluator';
165
165
  import { registerEvaluator } from './Evaluator';
166
+ import { DefaultEvaluator } from './Evaluator';
166
167
  import { interpolate } from './Evaluator';
167
168
  import moment from 'moment';
168
- export { FormioUtils as Utils, Evaluator, registerEvaluator };
169
+ export { FormioUtils as Utils, Evaluator, registerEvaluator, DefaultEvaluator };
@@ -29,12 +29,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
32
+ exports.DefaultEvaluator = exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
33
33
  const utils = __importStar(require("./utils"));
34
34
  const formUtils = __importStar(require("./formUtils"));
35
35
  const Evaluator_1 = require("./Evaluator");
36
36
  Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
37
37
  Object.defineProperty(exports, "registerEvaluator", { enumerable: true, get: function () { return Evaluator_1.registerEvaluator; } });
38
+ Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return Evaluator_1.DefaultEvaluator; } });
38
39
  const conditionOperators_1 = __importDefault(require("./conditionOperators"));
39
40
  const lodash_1 = __importDefault(require("lodash"));
40
41
  const moment_1 = __importDefault(require("moment"));
@@ -523,9 +523,9 @@ export default class Element {
523
523
  if (this.component.filter === string && !this.options.building) {
524
524
  const evalContext = this.evalContext(data);
525
525
  evalContext.data = _.mapValues(evalContext.data, (val) => _.isString(val) ? encodeURIComponent(val) : val);
526
- return FormioUtils.Evaluator.interpolate(string, evalContext, options);
526
+ return FormioUtils.interpolate(string, evalContext, options);
527
527
  }
528
- return FormioUtils.Evaluator.interpolate(string, this.evalContext(data), options);
528
+ return FormioUtils.interpolate(string, this.evalContext(data), options);
529
529
  }
530
530
  /**
531
531
  * Performs an evaluation using the evaluation context of this component.
package/lib/mjs/Embed.js CHANGED
@@ -14,7 +14,7 @@ export class Formio {
14
14
  Formio._formioReady = ready;
15
15
  Formio._formioReadyReject = reject;
16
16
  });
17
- static version = '5.2.1-rc.8';
17
+ static version = '5.2.1';
18
18
  static setLicense(license, norecurse = false) {
19
19
  Formio.license = license;
20
20
  if (!norecurse && Formio.FormioClass) {
package/lib/mjs/Formio.js CHANGED
@@ -4,7 +4,7 @@ import CDN from './CDN';
4
4
  import Providers from './providers';
5
5
  FormioCore.cdn = new CDN();
6
6
  FormioCore.Providers = Providers;
7
- FormioCore.version = '5.2.1-rc.8';
7
+ FormioCore.version = '5.2.1';
8
8
  CDN.defaultCDN = FormioCore.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
9
9
  const isNil = (val) => val === null || val === undefined;
10
10
  FormioCore.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
@@ -77,6 +77,7 @@ export default class WebformBuilder extends Component {
77
77
  removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
78
78
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
79
79
  updateComponent(component: any, changed: any): void;
80
+ originalDefaultValue: any;
80
81
  findComponentsWithRepeatablePaths(): any[];
81
82
  highlightInvalidComponents(): void;
82
83
  /**
@@ -1073,6 +1073,16 @@ export default class WebformBuilder extends Component {
1073
1073
  'fields.month.required',
1074
1074
  'fields.year.required',
1075
1075
  ]));
1076
+ if (defaultValueComponent.component.components) {
1077
+ if (!this.originalDefaultValue) {
1078
+ this.originalDefaultValue = fastCloneDeep(defaultValueComponent.component);
1079
+ }
1080
+ eachComponent(defaultValueComponent.component.components, (comp => {
1081
+ if (comp.validate?.required) {
1082
+ comp.validate.required = false;
1083
+ }
1084
+ }));
1085
+ }
1076
1086
  const parentComponent = defaultValueComponent.parent;
1077
1087
  let tabIndex = -1;
1078
1088
  let index = -1;
@@ -1181,6 +1191,10 @@ export default class WebformBuilder extends Component {
1181
1191
  if (index !== -1) {
1182
1192
  let submissionData = this.editForm.submission.data;
1183
1193
  submissionData = submissionData.componentJson || submissionData;
1194
+ if (submissionData.components && this.originalDefaultValue) {
1195
+ submissionData.components = this.originalDefaultValue.components;
1196
+ this.originalDefaultValue = null;
1197
+ }
1184
1198
  const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
1185
1199
  this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
1186
1200
  this.hook('beforeSaveComponentSettings', submissionData);
package/lib/mjs/Wizard.js CHANGED
@@ -591,7 +591,7 @@ export default class Wizard extends Webform {
591
591
  if (!this._seenPages.includes(parentNum)) {
592
592
  this._seenPages = this._seenPages.concat(parentNum);
593
593
  }
594
- this.redraw().then(() => {
594
+ return this.redraw().then(() => {
595
595
  this.checkData(this.submission.data);
596
596
  this.triggerCaptcha(this.currentPage.components);
597
597
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
@@ -599,7 +599,6 @@ export default class Wizard extends Webform {
599
599
  this.showErrors(errors, true, true);
600
600
  }
601
601
  });
602
- return Promise.resolve();
603
602
  }
604
603
  else if (!this.pages.length) {
605
604
  this.redraw();
@@ -924,10 +923,7 @@ export default class Wizard extends Webform {
924
923
  if (pageIndex >= 0) {
925
924
  const page = this.pages[pageIndex];
926
925
  if (page && page !== this.currentPage) {
927
- return this.setPage(pageIndex).then(() => {
928
- this.showErrors(this.validate(this.localData, { dirty: true }));
929
- super.focusOnComponent(key);
930
- });
926
+ return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
931
927
  }
932
928
  }
933
929
  }
@@ -178,6 +178,10 @@ export default class WizardBuilder extends WebformBuilder {
178
178
  this.navigationDragula = null;
179
179
  super.detach();
180
180
  }
181
+ destroy(all = false) {
182
+ this.off('saveComponent');
183
+ super.destroy(all);
184
+ }
181
185
  rebuild() {
182
186
  const page = this.currentPage;
183
187
  this.webform.setForm({
@@ -155,7 +155,7 @@ export default class NestedComponent extends Field {
155
155
  * @param {import('@formio/core').Component[]} components - The components to attach logic to.
156
156
  */
157
157
  attachComponentsLogic(components: import('@formio/core').Component[]): void;
158
- attachComponents(element: any, components: any, container: any): Promise<any>;
158
+ attachComponents(element: any, components: any, container: any): Promise<void> | Promise<any[]>;
159
159
  /**
160
160
  * Remove a component from the components array and from the children object
161
161
  * @param {import('@formio/core').Component} component - The component to remove from the components.
@@ -534,8 +534,7 @@ export default class NestedComponent extends Field {
534
534
  container = container || this.component.components;
535
535
  element = this.hook('attachComponents', element, components, container, this);
536
536
  if (!element) {
537
- // Return a non-resolving promise.
538
- return (new Promise(() => { }));
537
+ return Promise.resolve();
539
538
  }
540
539
  let index = 0;
541
540
  const promises = [];
@@ -477,7 +477,13 @@ export default class DataGridComponent extends NestedArrayComponent {
477
477
  const formComp = getComponent(this.component.components, changed.component.key);
478
478
  _.set(formComp, 'components', changed.component.components);
479
479
  }
480
- this.triggerChange({ modified });
480
+ // If we're in a nested form we need to ensure our changes are triggered upstream
481
+ if (changed.instance.root?.id && (this.root?.id !== changed.instance.root.id)) {
482
+ changed.instance.root.triggerChange(flags, changed, modified);
483
+ }
484
+ else {
485
+ this.triggerChange({ modified });
486
+ }
481
487
  };
482
488
  let columnComponent;
483
489
  if (this.builderMode) {
@@ -73,10 +73,10 @@ export default class EditGridComponent extends NestedArrayComponent {
73
73
  rowIndex: any;
74
74
  } | undefined;
75
75
  emptyRow: any;
76
- addRowModal(rowIndex: any): Promise<any>;
76
+ addRowModal(rowIndex: any): Promise<void> | Promise<any[]>;
77
77
  alert: Alert | null | undefined;
78
78
  showDialog(rowIndex: any): Promise<any>;
79
- editRow(rowIndex: any): Promise<any>;
79
+ editRow(rowIndex: any): Promise<void> | Promise<any[]>;
80
80
  clearErrors(rowIndex: any): void;
81
81
  cancelRow(rowIndex: any): void;
82
82
  saveRow(rowIndex: any, modified: any): boolean | undefined;
@@ -29,7 +29,7 @@ export default class FormComponent extends Component {
29
29
  * Prints out the value of form components as a datagrid value.
30
30
  */
31
31
  getValueAsString(value: any, options: any): any;
32
- attach(element: any): Promise<void>;
32
+ attach(element: any): Promise<any>;
33
33
  get hasLoadedForm(): any;
34
34
  get isRevisionChanged(): any;
35
35
  get subFormData(): any;
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
42
42
  everyComponent(...args: any[]): any;
43
43
  setSubFormDisabled(subForm: any): void;
44
44
  updateSubWizards(subForm: any): void;
45
+ setComponentsMap(): void;
45
46
  /**
46
47
  * Create a subform instance.
47
48
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.