@formio/js 5.2.1-dev.6186.ffe4f6c → 5.2.1-dev.6228.7172789

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 (57) hide show
  1. package/Changelog.md +49 -0
  2. package/dist/formio.embed.js +1 -1
  3. package/dist/formio.embed.min.js +1 -1
  4. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  5. package/dist/formio.form.js +17 -17
  6. package/dist/formio.form.min.js +1 -1
  7. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  8. package/dist/formio.full.js +18 -18
  9. package/dist/formio.full.min.js +1 -1
  10. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  11. package/dist/formio.js +3 -3
  12. package/dist/formio.min.js +1 -1
  13. package/dist/formio.min.js.LICENSE.txt +1 -1
  14. package/dist/formio.utils.js +2 -2
  15. package/dist/formio.utils.min.js +1 -1
  16. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  17. package/lib/cjs/Element.js +2 -2
  18. package/lib/cjs/Embed.js +1 -1
  19. package/lib/cjs/Formio.js +1 -1
  20. package/lib/cjs/Webform.js +8 -0
  21. package/lib/cjs/WebformBuilder.d.ts +1 -0
  22. package/lib/cjs/WebformBuilder.js +26 -3
  23. package/lib/cjs/Wizard.js +7 -6
  24. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  25. package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -2
  26. package/lib/cjs/components/datagrid/DataGrid.js +8 -1
  27. package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
  28. package/lib/cjs/components/form/Form.d.ts +2 -1
  29. package/lib/cjs/components/form/Form.js +32 -20
  30. package/lib/cjs/components/radio/Radio.js +1 -1
  31. package/lib/cjs/components/select/Select.js +1 -1
  32. package/lib/cjs/components/tags/Tags.js +7 -0
  33. package/lib/cjs/formio.form.d.ts +2 -1
  34. package/lib/cjs/formio.form.js +2 -1
  35. package/lib/cjs/utils/index.d.ts +3 -2
  36. package/lib/cjs/utils/index.js +2 -1
  37. package/lib/mjs/Element.js +2 -2
  38. package/lib/mjs/Embed.js +1 -1
  39. package/lib/mjs/Formio.js +1 -1
  40. package/lib/mjs/Webform.js +8 -0
  41. package/lib/mjs/WebformBuilder.d.ts +1 -0
  42. package/lib/mjs/WebformBuilder.js +25 -3
  43. package/lib/mjs/Wizard.js +7 -6
  44. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  45. package/lib/mjs/components/_classes/nested/NestedComponent.js +4 -2
  46. package/lib/mjs/components/datagrid/DataGrid.js +7 -1
  47. package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
  48. package/lib/mjs/components/form/Form.d.ts +2 -1
  49. package/lib/mjs/components/form/Form.js +32 -20
  50. package/lib/mjs/components/radio/Radio.js +1 -1
  51. package/lib/mjs/components/select/Select.js +1 -1
  52. package/lib/mjs/components/tags/Tags.js +7 -0
  53. package/lib/mjs/formio.form.d.ts +2 -1
  54. package/lib/mjs/formio.form.js +2 -2
  55. package/lib/mjs/utils/index.d.ts +3 -2
  56. package/lib/mjs/utils/index.js +2 -2
  57. 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.5 | https://unpkg.com/formiojs@5.2.1-rc.5/LICENSE.txt */
23
+ /*! formiojs v5.2.1-rc.14 | https://unpkg.com/formiojs@5.2.1-rc.14/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.5';
421
+ Formio.version = '5.2.1-rc.14';
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.5';
14
+ sdk_1.Formio.version = '5.2.1-rc.14';
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) {
@@ -351,6 +351,14 @@ class Webform extends NestedDataComponent_1.default {
351
351
  get shadowRoot() {
352
352
  return this.options.shadowRoot;
353
353
  }
354
+ // Webforms have no default value setting, so this should be always false
355
+ // I does not affect setting default value to nested forms
356
+ get shouldAddDefaultValue() {
357
+ return false;
358
+ }
359
+ get componentsMap() {
360
+ return this.childComponentsMap || {};
361
+ }
354
362
  /**
355
363
  * Add a language for translations
356
364
  * @param {string} code - The language code for the language being added.
@@ -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
  /**
@@ -83,8 +83,16 @@ class WebformBuilder extends Component_1.default {
83
83
  }
84
84
  this.groupOrder = this.groupOrder
85
85
  .filter(group => group && !group.ignore)
86
- .sort((a, b) => a.weight - b.weight)
87
- .map(group => group.key);
86
+ .sort((a, b) => a.weight - b.weight);
87
+ const defaultOpenedGroup = this.groupOrder.find(x => x.key !== 'basic' && x.default);
88
+ if (defaultOpenedGroup) {
89
+ this.groupOrder.forEach(x => {
90
+ if ('default' in x && x.key !== defaultOpenedGroup.key) {
91
+ x.default = false;
92
+ }
93
+ });
94
+ }
95
+ this.groupOrder = this.groupOrder.map(group => group.key);
88
96
  for (const type in Components_1.default.components) {
89
97
  const component = Components_1.default.components[type];
90
98
  if (component.builderInfo && component.builderInfo.schema) {
@@ -1081,6 +1089,17 @@ class WebformBuilder extends Component_1.default {
1081
1089
  'fields.month.required',
1082
1090
  'fields.year.required',
1083
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
+ }
1084
1103
  const parentComponent = defaultValueComponent.parent;
1085
1104
  let tabIndex = -1;
1086
1105
  let index = -1;
@@ -1100,7 +1119,7 @@ class WebformBuilder extends Component_1.default {
1100
1119
  const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
1101
1120
  lodash_1.default.pull(newComp.validators, 'required');
1102
1121
  parentComponent.tabs[tabIndex].splice(index, 1, newComp);
1103
- newComp.checkValidity = () => true;
1122
+ newComp.processOwnValidation = true;
1104
1123
  newComp.build(defaultValueComponent.element);
1105
1124
  if (this.preview && !this.preview.defaultChanged) {
1106
1125
  const defaultValue = lodash_1.default.get(this.preview._data, this.editForm._data.key);
@@ -1190,6 +1209,10 @@ class WebformBuilder extends Component_1.default {
1190
1209
  if (index !== -1) {
1191
1210
  let submissionData = this.editForm.submission.data;
1192
1211
  submissionData = submissionData.componentJson || submissionData;
1212
+ if (submissionData.components && this.originalDefaultValue) {
1213
+ submissionData.components = this.originalDefaultValue.components;
1214
+ this.originalDefaultValue = null;
1215
+ }
1193
1216
  const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
1194
1217
  this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
1195
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();
@@ -821,6 +820,11 @@ class Wizard extends Webform_1.default {
821
820
  }
822
821
  }
823
822
  setValue(submission, flags = {}, ignoreEstablishment) {
823
+ if (!submission || !submission.data) {
824
+ submission = {
825
+ data: {},
826
+ };
827
+ }
824
828
  const changed = this.getPages({ all: true }).reduce((changed, page) => {
825
829
  return this.setNestedValue(page, submission.data, flags, changed) || changed;
826
830
  }, false);
@@ -931,10 +935,7 @@ class Wizard extends Webform_1.default {
931
935
  if (pageIndex >= 0) {
932
936
  const page = this.pages[pageIndex];
933
937
  if (page && page !== this.currentPage) {
934
- return this.setPage(pageIndex).then(() => {
935
- this.showErrors(this.validate(this.localData, { dirty: true }));
936
- super.focusOnComponent(key);
937
- });
938
+ return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
938
939
  }
939
940
  }
940
941
  }
@@ -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 = [];
@@ -558,12 +557,16 @@ class NestedComponent extends Field_1.default {
558
557
  * @param {boolean} [all] - If set to TRUE will cascade remove all components.
559
558
  */
560
559
  removeComponent(component, components, all = false) {
560
+ var _a, _b;
561
561
  components = components || this.components;
562
562
  component.destroy(all);
563
563
  lodash_1.default.remove(components, { id: component.id });
564
564
  if (this.componentsMap[component.path]) {
565
565
  delete this.componentsMap[component.path];
566
566
  }
567
+ if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.componentsMap[component.path]) {
568
+ (_b = this.root) === null || _b === void 0 ? true : delete _b.componentsMap[component.path];
569
+ }
567
570
  }
568
571
  /**
569
572
  * Removes a component provided the API key of that component.
@@ -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.5';
17
+ static version = '5.2.1-rc.14';
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.5';
7
+ FormioCore.version = '5.2.1-rc.14';
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) {
@@ -323,6 +323,14 @@ export default class Webform extends NestedDataComponent {
323
323
  get shadowRoot() {
324
324
  return this.options.shadowRoot;
325
325
  }
326
+ // Webforms have no default value setting, so this should be always false
327
+ // I does not affect setting default value to nested forms
328
+ get shouldAddDefaultValue() {
329
+ return false;
330
+ }
331
+ get componentsMap() {
332
+ return this.childComponentsMap || {};
333
+ }
326
334
  /**
327
335
  * Add a language for translations
328
336
  * @param {string} code - The language code for the language being added.
@@ -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
  /**
@@ -63,8 +63,16 @@ export default class WebformBuilder extends Component {
63
63
  }
64
64
  this.groupOrder = this.groupOrder
65
65
  .filter(group => group && !group.ignore)
66
- .sort((a, b) => a.weight - b.weight)
67
- .map(group => group.key);
66
+ .sort((a, b) => a.weight - b.weight);
67
+ const defaultOpenedGroup = this.groupOrder.find(x => x.key !== 'basic' && x.default);
68
+ if (defaultOpenedGroup) {
69
+ this.groupOrder.forEach(x => {
70
+ if ('default' in x && x.key !== defaultOpenedGroup.key) {
71
+ x.default = false;
72
+ }
73
+ });
74
+ }
75
+ this.groupOrder = this.groupOrder.map(group => group.key);
68
76
  for (const type in Components.components) {
69
77
  const component = Components.components[type];
70
78
  if (component.builderInfo && component.builderInfo.schema) {
@@ -1065,6 +1073,16 @@ export default class WebformBuilder extends Component {
1065
1073
  'fields.month.required',
1066
1074
  'fields.year.required',
1067
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
+ }
1068
1086
  const parentComponent = defaultValueComponent.parent;
1069
1087
  let tabIndex = -1;
1070
1088
  let index = -1;
@@ -1084,7 +1102,7 @@ export default class WebformBuilder extends Component {
1084
1102
  const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
1085
1103
  _.pull(newComp.validators, 'required');
1086
1104
  parentComponent.tabs[tabIndex].splice(index, 1, newComp);
1087
- newComp.checkValidity = () => true;
1105
+ newComp.processOwnValidation = true;
1088
1106
  newComp.build(defaultValueComponent.element);
1089
1107
  if (this.preview && !this.preview.defaultChanged) {
1090
1108
  const defaultValue = _.get(this.preview._data, this.editForm._data.key);
@@ -1173,6 +1191,10 @@ export default class WebformBuilder extends Component {
1173
1191
  if (index !== -1) {
1174
1192
  let submissionData = this.editForm.submission.data;
1175
1193
  submissionData = submissionData.componentJson || submissionData;
1194
+ if (submissionData.components && this.originalDefaultValue) {
1195
+ submissionData.components = this.originalDefaultValue.components;
1196
+ this.originalDefaultValue = null;
1197
+ }
1176
1198
  const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
1177
1199
  this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
1178
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();
@@ -810,6 +809,11 @@ export default class Wizard extends Webform {
810
809
  }
811
810
  }
812
811
  setValue(submission, flags = {}, ignoreEstablishment) {
812
+ if (!submission || !submission.data) {
813
+ submission = {
814
+ data: {},
815
+ };
816
+ }
813
817
  const changed = this.getPages({ all: true }).reduce((changed, page) => {
814
818
  return this.setNestedValue(page, submission.data, flags, changed) || changed;
815
819
  }, false);
@@ -919,10 +923,7 @@ export default class Wizard extends Webform {
919
923
  if (pageIndex >= 0) {
920
924
  const page = this.pages[pageIndex];
921
925
  if (page && page !== this.currentPage) {
922
- return this.setPage(pageIndex).then(() => {
923
- this.showErrors(this.validate(this.localData, { dirty: true }));
924
- super.focusOnComponent(key);
925
- });
926
+ return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
926
927
  }
927
928
  }
928
929
  }
@@ -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 = [];
@@ -560,6 +559,9 @@ export default class NestedComponent extends Field {
560
559
  if (this.componentsMap[component.path]) {
561
560
  delete this.componentsMap[component.path];
562
561
  }
562
+ if (this.root?.componentsMap[component.path]) {
563
+ delete this.root?.componentsMap[component.path];
564
+ }
563
565
  }
564
566
  /**
565
567
  * Removes a component provided the API key of that component.
@@ -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) {