@formio/js 5.3.2 → 5.3.4

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 (54) 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 +922 -922
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +2 -2
  7. package/dist/formio.full.js +1201 -1201
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +2 -2
  10. package/dist/formio.js +841 -841
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +2 -2
  13. package/dist/formio.utils.js +786 -786
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +2 -2
  16. package/lib/cjs/Element.d.ts +11 -0
  17. package/lib/cjs/Element.js +24 -0
  18. package/lib/cjs/Embed.js +1 -1
  19. package/lib/cjs/Formio.js +1 -1
  20. package/lib/cjs/Webform.js +7 -4
  21. package/lib/cjs/Wizard.js +15 -11
  22. package/lib/cjs/components/Components.js +9 -1
  23. package/lib/cjs/components/_classes/component/Component.js +13 -18
  24. package/lib/cjs/components/_classes/nested/NestedComponent.js +9 -6
  25. package/lib/cjs/components/datagrid/DataGrid.js +3 -2
  26. package/lib/cjs/components/editgrid/EditGrid.js +2 -2
  27. package/lib/cjs/components/file/File.js +6 -5
  28. package/lib/cjs/components/form/Form.d.ts +1 -0
  29. package/lib/cjs/components/form/Form.js +18 -7
  30. package/lib/cjs/components/textfield/editForm/TextField.edit.display.d.ts +0 -10
  31. package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +9 -23
  32. package/lib/cjs/package.json +1 -1
  33. package/lib/cjs/utils/formUtils.d.ts +2 -2
  34. package/lib/cjs/utils/index.d.ts +2 -2
  35. package/lib/mjs/Element.d.ts +11 -0
  36. package/lib/mjs/Element.js +23 -0
  37. package/lib/mjs/Embed.js +1 -1
  38. package/lib/mjs/Formio.js +1 -1
  39. package/lib/mjs/Webform.js +5 -1
  40. package/lib/mjs/Wizard.js +9 -10
  41. package/lib/mjs/components/Components.js +9 -1
  42. package/lib/mjs/components/_classes/component/Component.js +12 -18
  43. package/lib/mjs/components/_classes/nested/NestedComponent.js +8 -5
  44. package/lib/mjs/components/datagrid/DataGrid.js +3 -2
  45. package/lib/mjs/components/editgrid/EditGrid.js +1 -1
  46. package/lib/mjs/components/file/File.js +6 -5
  47. package/lib/mjs/components/form/Form.d.ts +1 -0
  48. package/lib/mjs/components/form/Form.js +16 -5
  49. package/lib/mjs/components/textfield/editForm/TextField.edit.display.d.ts +0 -10
  50. package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +9 -23
  51. package/lib/mjs/package.json +1 -1
  52. package/lib/mjs/utils/formUtils.d.ts +2 -2
  53. package/lib/mjs/utils/index.d.ts +2 -2
  54. package/package.json +2 -2
@@ -18,9 +18,9 @@
18
18
  * MIT licensed
19
19
  */
20
20
 
21
- /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */
21
+ /*! @license DOMPurify 3.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.0/LICENSE */
22
22
 
23
- /*! formiojs v5.3.2 | https://unpkg.com/formiojs@5.3.2/LICENSE.txt */
23
+ /*! formiojs v5.3.4 | https://unpkg.com/formiojs@5.3.4/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
 
@@ -210,6 +210,17 @@ export default class Element {
210
210
  * @returns {this} - The instance of the element.
211
211
  */
212
212
  removeClass(element: HTMLElement, className: string): this;
213
+ /**
214
+ * Idempotently add or remove a class on a DOM element based on a boolean.
215
+ * Skips the mutation when the element is already in the desired state, so
216
+ * callers can safely invoke it on every change without triggering redundant
217
+ * CSS transitions or attribute writes.
218
+ * @param {HTMLElement} element - The DOM element to toggle the class on.
219
+ * @param {string} className - The class name to add or remove.
220
+ * @param {boolean} want - TRUE to ensure the class is present, FALSE to ensure it is absent.
221
+ * @returns {this} - The instance of the element.
222
+ */
223
+ toggleClass(element: HTMLElement, className: string, want: boolean): this;
213
224
  /**
214
225
  * Empty's an HTML DOM element.
215
226
  * @param {HTMLElement} element - The element you wish to empty.
@@ -487,6 +487,30 @@ class Element {
487
487
  }
488
488
  return this;
489
489
  }
490
+ /**
491
+ * Idempotently add or remove a class on a DOM element based on a boolean.
492
+ * Skips the mutation when the element is already in the desired state, so
493
+ * callers can safely invoke it on every change without triggering redundant
494
+ * CSS transitions or attribute writes.
495
+ * @param {HTMLElement} element - The DOM element to toggle the class on.
496
+ * @param {string} className - The class name to add or remove.
497
+ * @param {boolean} want - TRUE to ensure the class is present, FALSE to ensure it is absent.
498
+ * @returns {this} - The instance of the element.
499
+ */
500
+ toggleClass(element, className, want) {
501
+ var _a;
502
+ if (!element || !className || !(element instanceof HTMLElement)) {
503
+ return this;
504
+ }
505
+ const has = !!((_a = element.classList) === null || _a === void 0 ? void 0 : _a.contains(className));
506
+ if (want && !has) {
507
+ this.addClass(element, className);
508
+ }
509
+ else if (!want && has) {
510
+ this.removeClass(element, className);
511
+ }
512
+ return this;
513
+ }
490
514
  /**
491
515
  * Empty's an HTML DOM element.
492
516
  * @param {HTMLElement} element - The element you wish to empty.
package/lib/cjs/Embed.js CHANGED
@@ -481,7 +481,7 @@ Formio.formioReady = new Promise((ready, reject) => {
481
481
  _a._formioReady = ready;
482
482
  _a._formioReadyReject = reject;
483
483
  });
484
- Formio.version = '5.3.2';
484
+ Formio.version = '5.3.4';
485
485
  // Create a report.
486
486
  Formio.Report = {
487
487
  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.3.2';
14
+ sdk_1.Formio.version = '5.3.4';
15
15
  CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc')
16
16
  ? 'https://cdn.test-form.io'
17
17
  : 'https://cdn.form.io';
@@ -1030,7 +1030,7 @@ class Webform extends NestedDataComponent_1.default {
1030
1030
  * @returns {void|Array} - The errors that were set.
1031
1031
  */
1032
1032
  showErrors(errors, triggerEvent) {
1033
- var _a;
1033
+ var _a, _b;
1034
1034
  this.loading = false;
1035
1035
  if (!Array.isArray(errors)) {
1036
1036
  errors = [
@@ -1103,7 +1103,10 @@ class Webform extends NestedDataComponent_1.default {
1103
1103
  });
1104
1104
  }
1105
1105
  const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
1106
- (_a = this.root) === null || _a === void 0 ? void 0 : _a.setAlert('danger', errorsList);
1106
+ // Only paint the alert from a subform when the root won't double paint it to avoid a painful flicker
1107
+ if (this === this.root || !((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted)) {
1108
+ (_b = this.root) === null || _b === void 0 ? void 0 : _b.setAlert('danger', errorsList);
1109
+ }
1107
1110
  if (triggerEvent) {
1108
1111
  this.emit('error', errors);
1109
1112
  }
@@ -1202,7 +1205,7 @@ class Webform extends NestedDataComponent_1.default {
1202
1205
  * @param {any} changes - The changes that have occured in the form.
1203
1206
  */
1204
1207
  onChange(flags, changed, modified, changes) {
1205
- var _a;
1208
+ var _a, _b;
1206
1209
  flags = flags || {};
1207
1210
  let isChangeEventEmitted = false;
1208
1211
  if (((_a = this.parent) === null || _a === void 0 ? void 0 : _a.subForm) === this) {
@@ -1222,7 +1225,7 @@ class Webform extends NestedDataComponent_1.default {
1222
1225
  flags.fromIframe ||
1223
1226
  (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1224
1227
  const errors = shouldValidate
1225
- ? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: false, process: 'change' }))
1228
+ ? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: false, process: 'change', dirty: (_b = flags.dirty) !== null && _b !== void 0 ? _b : this.submitted }))
1226
1229
  : [];
1227
1230
  value.isValid = (errors || []).filter((err) => !err.fromServer).length === 0;
1228
1231
  this.loading = false;
package/lib/cjs/Wizard.js CHANGED
@@ -188,6 +188,7 @@ class Wizard extends Webform_1.default {
188
188
  return this.renderTemplate(headerType, ctx);
189
189
  }
190
190
  render() {
191
+ var _a;
191
192
  const ctx = this.renderContext;
192
193
  if (this.component.id) {
193
194
  ctx.panels.forEach((panel) => {
@@ -206,7 +207,7 @@ class Wizard extends Webform_1.default {
206
207
  wizardHeaderLocation,
207
208
  wizardNav, components: this.renderComponents([
208
209
  ...this.prefixComps,
209
- ...this.currentPage.components,
210
+ ...((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components) || [],
210
211
  ...this.suffixComps,
211
212
  ]) }), this.builderMode ? 'builder' : 'form');
212
213
  }
@@ -250,7 +251,7 @@ class Wizard extends Webform_1.default {
250
251
  * @returns {Promise} A promise that resolves when all components have been successfully attached.
251
252
  */
252
253
  attach(element) {
253
- var _a;
254
+ var _a, _b;
254
255
  this.setElement(element);
255
256
  this.loadRefs(element, {
256
257
  [this.wizardKey]: 'single',
@@ -268,7 +269,7 @@ class Wizard extends Webform_1.default {
268
269
  this.hook('attachWebform', element, this);
269
270
  const promises = this.attachComponents(this.refs[this.wizardKey], [
270
271
  ...this.prefixComps,
271
- ...this.currentPage.components,
272
+ ...((_b = this.currentPage) === null || _b === void 0 ? void 0 : _b.components) || [],
272
273
  ...this.suffixComps,
273
274
  ]);
274
275
  this.attachNav();
@@ -296,7 +297,8 @@ class Wizard extends Webform_1.default {
296
297
  isBreadcrumbClickable() {
297
298
  let currentPage = null;
298
299
  this.pages.map((page) => {
299
- if (lodash_1.default.isEqual(this.currentPage.component, page.component)) {
300
+ var _a;
301
+ if (lodash_1.default.isEqual((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.component, page.component)) {
300
302
  currentPage = page;
301
303
  }
302
304
  });
@@ -311,11 +313,12 @@ class Wizard extends Webform_1.default {
311
313
  isAllowPrevious() {
312
314
  let currentPage = null;
313
315
  this.pages.map((page) => {
314
- if (lodash_1.default.isEqual(this.currentPage.component, page.component)) {
316
+ var _a;
317
+ if (lodash_1.default.isEqual((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.component, page.component)) {
315
318
  currentPage = page;
316
319
  }
317
320
  });
318
- return lodash_1.default.get(currentPage.component, 'allowPrevious', this.options.allowPrevious);
321
+ return lodash_1.default.get(currentPage === null || currentPage === void 0 ? void 0 : currentPage.component, 'allowPrevious', this.options.allowPrevious);
319
322
  }
320
323
  /**
321
324
  * Handles navigate on 'Enter' key event in a wizard form.
@@ -544,7 +547,7 @@ class Wizard extends Webform_1.default {
544
547
  const forceShow = this.shouldForceShow(item);
545
548
  const forceHide = this.shouldForceHide(item);
546
549
  let isVisible = !page
547
- ? (0, utils_1.checkCondition)(item, data, data, this.component, this) && !item.hidden
550
+ ? ((0, utils_1.checkCondition)(item, data, data, this.component, this) && !item.hidden)
548
551
  : page.visible;
549
552
  if (forceShow) {
550
553
  isVisible = true;
@@ -615,8 +618,9 @@ class Wizard extends Webform_1.default {
615
618
  this._seenPages = this._seenPages.concat(parentNum);
616
619
  }
617
620
  return this.redraw().then(() => {
621
+ var _a;
618
622
  this.checkData(this.submission.data);
619
- this.triggerCaptcha(this.currentPage.components);
623
+ this.triggerCaptcha((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components);
620
624
  const errors = this.submitted
621
625
  ? this.validate(this.localData, { dirty: true })
622
626
  : this.validateCurrentPage();
@@ -833,8 +837,7 @@ class Wizard extends Webform_1.default {
833
837
  return super.setForm(form, flags);
834
838
  }
835
839
  onSetForm(clonedForm, initialForm) {
836
- this.component.components =
837
- (this.parent ? initialForm.components : clonedForm.components) || [];
840
+ this.component.components = (this.parent ? initialForm.components : clonedForm.components) || [];
838
841
  this.setComponentSchema();
839
842
  }
840
843
  setEditMode(submission) {
@@ -944,11 +947,12 @@ class Wizard extends Webform_1.default {
944
947
  return super.rebuild().then(setCurrentPage);
945
948
  }
946
949
  checkValidity(data, dirty, row, currentPageOnly, childErrors = []) {
950
+ var _a;
947
951
  if (!this.checkCondition(row, data)) {
948
952
  this.setCustomValidity('');
949
953
  return true;
950
954
  }
951
- const components = !currentPageOnly || this.isLastPage() ? this.getComponents() : this.currentPage.components;
955
+ const components = !currentPageOnly || this.isLastPage() ? this.getComponents() : (_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components;
952
956
  return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
953
957
  }
954
958
  get errors() {
@@ -69,7 +69,15 @@ class Components {
69
69
  comp = new Component_1.default(component, options, data);
70
70
  }
71
71
  if (comp.path) {
72
- comp.componentsMap[comp.path] = comp;
72
+ let currentRoot = comp.root;
73
+ let prevRootId = null;
74
+ while (currentRoot && currentRoot.id !== prevRootId) {
75
+ if (currentRoot.childComponentsMap) {
76
+ currentRoot.childComponentsMap[comp.path] = comp;
77
+ }
78
+ prevRootId = currentRoot.id;
79
+ currentRoot = currentRoot.root;
80
+ }
73
81
  }
74
82
  // Reset the componentMatches on the root element if any new component is created.
75
83
  let parent = comp.parent;
@@ -2272,29 +2272,24 @@ class Component extends Element_1.default {
2272
2272
  * @returns {void}
2273
2273
  */
2274
2274
  setErrorClasses(elements, dirty, hasErrors, hasMessages, element = this.element) {
2275
- this.clearErrorClasses();
2276
- elements.forEach((element) => {
2277
- this.setElementInvalid(this.performInputMapping(element), hasErrors);
2275
+ var _a;
2276
+ elements.forEach((el) => {
2277
+ this.setElementInvalid(this.performInputMapping(el), hasErrors);
2278
2278
  });
2279
2279
  this.setInputWidgetErrorClasses(elements, hasErrors);
2280
2280
  // do not set error classes for hidden components
2281
2281
  if (!this.visible) {
2282
+ this.clearErrorClasses(element);
2282
2283
  return;
2283
2284
  }
2284
- if (hasErrors) {
2285
- // Add error classes
2286
- elements.forEach((input) => {
2287
- this.setElementInvalid(this.performInputMapping(input), true);
2288
- });
2289
- if (dirty && this.options.highlightErrors) {
2290
- this.addClass(element, this.options.componentErrorClass);
2291
- }
2292
- else {
2293
- this.addClass(element, 'has-error');
2294
- }
2295
- }
2296
- if (hasMessages) {
2297
- this.addClass(element, 'has-message');
2285
+ const wantHighlight = hasErrors && !!dirty && !!this.options.highlightErrors;
2286
+ const wantHasError = hasErrors && !wantHighlight;
2287
+ this.toggleClass(element, this.options.componentErrorClass, wantHighlight);
2288
+ this.toggleClass(element, 'has-error', wantHasError);
2289
+ this.toggleClass(element, 'has-message', hasMessages);
2290
+ // Preserve previous clearErrorClasses() behavior: drop the 'alert alert-danger' pair if left over.
2291
+ if ((_a = element === null || element === void 0 ? void 0 : element.classList) === null || _a === void 0 ? void 0 : _a.contains('alert-danger')) {
2292
+ this.removeClass(element, 'alert alert-danger');
2298
2293
  }
2299
2294
  }
2300
2295
  /**
@@ -3189,7 +3184,7 @@ class Component extends Element_1.default {
3189
3184
  if (flags.silentCheck) {
3190
3185
  return [];
3191
3186
  }
3192
- let isDirty = flags.dirty === false ? false : this.dirty || flags.dirty;
3187
+ let isDirty = flags.dirty || this.dirty;
3193
3188
  if (this.options.alwaysDirty) {
3194
3189
  isDirty = true;
3195
3190
  }
@@ -557,15 +557,18 @@ class NestedComponent extends Field_1.default {
557
557
  * @param {boolean} [all] - If set to TRUE will cascade remove all components.
558
558
  */
559
559
  removeComponent(component, components, all = false) {
560
- var _a, _b;
560
+ var _a;
561
561
  components = components || this.components;
562
562
  component.destroy(all);
563
563
  lodash_1.default.remove(components, { id: component.id });
564
- if (this.componentsMap[component.path]) {
565
- delete this.componentsMap[component.path];
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];
564
+ let currentRoot = component.root;
565
+ let prevRootId = null;
566
+ while (currentRoot && currentRoot.id !== prevRootId) {
567
+ if ((_a = currentRoot.childComponentsMap) === null || _a === void 0 ? void 0 : _a[component.path]) {
568
+ delete currentRoot.childComponentsMap[component.path];
569
+ }
570
+ prevRootId = currentRoot.id;
571
+ currentRoot = currentRoot.root;
569
572
  }
570
573
  }
571
574
  /**
@@ -537,8 +537,9 @@ class DataGridComponent extends NestedArrayComponent_1.default {
537
537
  options.rowIndex = rowIndex;
538
538
  options.onChange = (flags, changed, modified) => {
539
539
  var _a, _b, _c, _d, _e;
540
- if (changed.component.type === 'form') {
541
- const formComp = (0, utils_1.getComponent)(this.component.components, changed.component.key);
540
+ const changedComponent = changed.component;
541
+ if ((changedComponent === null || changedComponent === void 0 ? void 0 : changedComponent.type) === 'form' && (changedComponent === null || changedComponent === void 0 ? void 0 : changedComponent.key)) {
542
+ const formComp = (0, utils_1.getComponent)(this.component.components, changedComponent.key);
542
543
  lodash_1.default.set(formComp, 'components', changed.component.components);
543
544
  }
544
545
  // If we're in a nested form we need to ensure our changes are triggered upstream
@@ -814,7 +814,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
814
814
  }
815
815
  }
816
816
  saveRow(rowIndex, modified) {
817
- var _a, _b, _c;
817
+ var _a, _b, _c, _d;
818
818
  const editRow = this.editRows[rowIndex];
819
819
  if (this.options.readOnly) {
820
820
  return;
@@ -869,7 +869,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
869
869
  if (this.component.rowDrafts) {
870
870
  editRow.components.forEach((comp) => comp.setPristine(this.pristine));
871
871
  }
872
- this.checkValidity(null, true);
872
+ this.checkValidity(null, !this.component.rowDrafts || ((_d = this.root) === null || _d === void 0 ? void 0 : _d.submitted));
873
873
  this.redraw();
874
874
  if (editRow.alerts) {
875
875
  editRow.alerts = false;
@@ -946,16 +946,17 @@ class FileComponent extends Field_1.default {
946
946
  }
947
947
  uploadFile(fileToSync) {
948
948
  return __awaiter(this, void 0, void 0, function* () {
949
- return yield this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
949
+ const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
950
950
  // Progress callback
951
951
  this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
952
- this.emit('fileUploadingStart');
952
+ this.emit('fileUploadingStart', filePromise);
953
953
  },
954
954
  // Abort upload callback
955
955
  (abort) => this.abortUploads.push({
956
956
  id: fileToSync.id,
957
957
  abort,
958
958
  }), this.getMultipartOptions(fileToSync));
959
+ return yield filePromise;
959
960
  });
960
961
  }
961
962
  upload() {
@@ -977,7 +978,7 @@ class FileComponent extends Field_1.default {
977
978
  fileToSync.message = this.t('Succefully uploaded');
978
979
  fileInfo.originalName = fileToSync.originalName;
979
980
  fileInfo.hash = fileToSync.hash;
980
- this.emit('fileUploadingEnd');
981
+ this.emit('fileUploadingEnd', Promise.resolve(fileInfo));
981
982
  }
982
983
  catch (response) {
983
984
  fileToSync.status = 'error';
@@ -988,8 +989,8 @@ class FileComponent extends Field_1.default {
988
989
  : response.type === 'abort'
989
990
  ? this.t('Request was aborted')
990
991
  : response.toString();
991
- this.emit('fileUploadingEnd');
992
- this.emit('fileUploadError', {
992
+ this.emit('fileUploadingEnd', Promise.reject(response));
993
+ this.emit(lodash_1.default.get(response, 'type') === 'abort' ? 'fileUploadCanceled' : 'fileUploadError', {
993
994
  fileToSync,
994
995
  response,
995
996
  });
@@ -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
+ updateTopLevelComponentsMap(): void;
45
46
  setComponentsMap(): void;
46
47
  /**
47
48
  * Create a subform instance.
@@ -400,13 +400,22 @@ class FormComponent extends Component_1.default {
400
400
  this.emit('subWizardsUpdated', subForm);
401
401
  }
402
402
  }
403
+ updateTopLevelComponentsMap() {
404
+ let prevRootId = null;
405
+ let currentRoot = this.root;
406
+ const subFormComponentMap = this.subForm.componentsMap;
407
+ // update components map for all top forms
408
+ while (currentRoot && prevRootId !== currentRoot.id) {
409
+ lodash_1.default.assign(currentRoot.componentsMap, subFormComponentMap);
410
+ prevRootId = currentRoot.id;
411
+ currentRoot = currentRoot.root;
412
+ }
413
+ }
403
414
  setComponentsMap() {
404
415
  if (!this.subForm) {
405
416
  return;
406
417
  }
407
- const componentsMap = this.componentsMap;
408
- const formComponentsMap = this.subForm.componentsMap;
409
- lodash_1.default.assign(componentsMap, formComponentsMap);
418
+ this.updateTopLevelComponentsMap();
410
419
  }
411
420
  /**
412
421
  * Create a subform instance.
@@ -431,13 +440,13 @@ class FormComponent extends Component_1.default {
431
440
  // Render the form.
432
441
  return new Form_1.default(form, this.getSubOptions()).ready
433
442
  .then((instance) => {
434
- var _a, _b;
443
+ var _a;
435
444
  this.subForm = instance;
436
445
  this.subForm.currentForm = this;
437
446
  this.subForm.parentVisible = this.visible;
438
447
  this.setComponentsMap();
439
- this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
440
- this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
448
+ this.component.components = this.subForm.components.map((comp) => comp.component);
449
+ this.component.display = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.display;
441
450
  this.subForm.on('change', () => {
442
451
  var _a;
443
452
  if (this.subForm && !this.shouldConditionallyClear()) {
@@ -775,7 +784,9 @@ class FormComponent extends Component_1.default {
775
784
  }
776
785
  this.updateSubFormVisibility();
777
786
  this.clearOnHide();
778
- isNestedWizard ? this.rebuild() : this.redraw();
787
+ if (!isNestedWizard) {
788
+ this.redraw();
789
+ }
779
790
  }
780
791
  if (!value && isNestedWizard) {
781
792
  (_a = this.root) === null || _a === void 0 ? void 0 : _a.redraw();
@@ -25,7 +25,6 @@ declare const _default: ({
25
25
  };
26
26
  };
27
27
  clearOnHide?: undefined;
28
- customDefaultValue?: undefined;
29
28
  rows?: undefined;
30
29
  editor?: undefined;
31
30
  as?: undefined;
@@ -40,7 +39,6 @@ declare const _default: ({
40
39
  label: string;
41
40
  clearOnHide: boolean;
42
41
  onChange: (context: any) => void;
43
- customDefaultValue: (value: any, component: any, row: any, data: any, instance: any) => any;
44
42
  input: boolean;
45
43
  rows: number;
46
44
  editor: string;
@@ -79,7 +77,6 @@ declare const _default: ({
79
77
  data?: undefined;
80
78
  conditional?: undefined;
81
79
  clearOnHide?: undefined;
82
- customDefaultValue?: undefined;
83
80
  rows?: undefined;
84
81
  editor?: undefined;
85
82
  as?: undefined;
@@ -107,7 +104,6 @@ declare const _default: ({
107
104
  onChange?: undefined;
108
105
  conditional?: undefined;
109
106
  clearOnHide?: undefined;
110
- customDefaultValue?: undefined;
111
107
  rows?: undefined;
112
108
  editor?: undefined;
113
109
  as?: undefined;
@@ -133,7 +129,6 @@ declare const _default: ({
133
129
  data?: undefined;
134
130
  conditional?: undefined;
135
131
  clearOnHide?: undefined;
136
- customDefaultValue?: undefined;
137
132
  rows?: undefined;
138
133
  editor?: undefined;
139
134
  as?: undefined;
@@ -154,7 +149,6 @@ declare const _default: ({
154
149
  data?: undefined;
155
150
  conditional?: undefined;
156
151
  clearOnHide?: undefined;
157
- customDefaultValue?: undefined;
158
152
  rows?: undefined;
159
153
  editor?: undefined;
160
154
  as?: undefined;
@@ -177,7 +171,6 @@ declare const _default: ({
177
171
  data?: undefined;
178
172
  conditional?: undefined;
179
173
  clearOnHide?: undefined;
180
- customDefaultValue?: undefined;
181
174
  rows?: undefined;
182
175
  editor?: undefined;
183
176
  as?: undefined;
@@ -208,7 +201,6 @@ declare const _default: ({
208
201
  data?: undefined;
209
202
  conditional?: undefined;
210
203
  clearOnHide?: undefined;
211
- customDefaultValue?: undefined;
212
204
  rows?: undefined;
213
205
  editor?: undefined;
214
206
  as?: undefined;
@@ -228,7 +220,6 @@ declare const _default: ({
228
220
  data?: undefined;
229
221
  conditional?: undefined;
230
222
  clearOnHide?: undefined;
231
- customDefaultValue?: undefined;
232
223
  rows?: undefined;
233
224
  editor?: undefined;
234
225
  as?: undefined;
@@ -251,7 +242,6 @@ declare const _default: ({
251
242
  data?: undefined;
252
243
  conditional?: undefined;
253
244
  clearOnHide?: undefined;
254
- customDefaultValue?: undefined;
255
245
  rows?: undefined;
256
246
  editor?: undefined;
257
247
  as?: undefined;
@@ -20,19 +20,19 @@ exports.default = [
20
20
  defaultValue: 'input',
21
21
  calculateValue: (context) => {
22
22
  var _a;
23
- let currentType = context.data['widget.type'];
23
+ let currentType = context.instance._widgetType;
24
24
  if (currentType) {
25
25
  return currentType;
26
26
  }
27
27
  const widget = context.data.widget;
28
28
  if (isObject(widget) && widget.type) {
29
- context.data['widget.type'] = widget.type;
29
+ context.instance._widgetType = widget.type;
30
30
  return widget.type;
31
31
  }
32
32
  if (typeof widget === 'string') {
33
33
  const originalType = (_a = getOriginalWidget(context.instance)) === null || _a === void 0 ? void 0 : _a.type;
34
34
  if (originalType) {
35
- context.data['widget.type'] = originalType;
35
+ context.instance._widgetType = originalType;
36
36
  return originalType;
37
37
  }
38
38
  }
@@ -40,11 +40,11 @@ exports.default = [
40
40
  },
41
41
  onChange: (context) => {
42
42
  var _a;
43
- const newType = context.data['widget.type'];
43
+ const newType = context.instance.dataValue;
44
44
  const currentWidget = context.data.widget;
45
45
  let oldType;
46
46
  if (isObject(currentWidget)) {
47
- oldType = currentWidget.type;
47
+ oldType = context.instance._widgetType;
48
48
  }
49
49
  else if (typeof currentWidget === 'string') {
50
50
  oldType = (_a = getOriginalWidget(context.instance)) === null || _a === void 0 ? void 0 : _a.type;
@@ -55,10 +55,12 @@ exports.default = [
55
55
  if (newType !== oldType) {
56
56
  if (newType === 'input') {
57
57
  context.data.widget = { type: 'input' };
58
+ context.instance._widgetType = newType;
58
59
  }
59
- else {
60
+ else if (newType) {
60
61
  const defaultSettings = getDefaultWidgetSettings(newType);
61
62
  context.data.widget = defaultSettings || { type: newType };
63
+ context.instance._widgetType = newType;
62
64
  }
63
65
  }
64
66
  else if (!currentWidget) {
@@ -94,28 +96,12 @@ exports.default = [
94
96
  return;
95
97
  }
96
98
  if (isObject(currentWidget)) {
97
- const currentType = context.data['widget.type'];
99
+ const currentType = context.instance.root.getComponent('widget.type')._widgetType || currentWidget.type;
98
100
  if (currentType && currentWidget.type !== currentType) {
99
101
  context.data.widget = Object.assign(Object.assign({}, currentWidget), { type: currentType });
100
102
  }
101
103
  }
102
104
  },
103
- customDefaultValue: (value, component, row, data, instance) => {
104
- if (!data.widget) {
105
- const originalWidget = getOriginalWidget(instance);
106
- const widgetType = data['widget.type'] || (originalWidget === null || originalWidget === void 0 ? void 0 : originalWidget.type);
107
- if (widgetType && widgetType !== 'input') {
108
- if ((originalWidget === null || originalWidget === void 0 ? void 0 : originalWidget.type) === widgetType && !lodash_1.default.isEmpty(lodash_1.default.omit(originalWidget, 'type'))) {
109
- return lodash_1.default.omit(originalWidget, 'language');
110
- }
111
- const defaultSettings = getDefaultWidgetSettings(widgetType);
112
- if (defaultSettings) {
113
- return defaultSettings;
114
- }
115
- }
116
- }
117
- return value;
118
- },
119
105
  input: true,
120
106
  rows: 5,
121
107
  editor: 'ace',
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "type": "commonjs",
3
- "version": "5.3.2"
3
+ "version": "5.3.4"
4
4
  }
@@ -26,8 +26,8 @@ export const getBestMatch: typeof Utils.getBestMatch;
26
26
  export const getComponentFromPath: typeof Utils.getComponentFromPath;
27
27
  export const getComponentValue: typeof Utils.getComponentValue;
28
28
  export const findComponents: typeof Utils.findComponents;
29
- export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
30
- export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
29
+ export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined, localRoot?: import("@formio/core").LocalRoot | undefined) => Promise<void>;
30
+ export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined, localRoot?: import("@formio/core").LocalRoot | undefined) => void;
31
31
  export const getComponentKey: typeof Utils.getComponentKey;
32
32
  export const getContextualRowPath: any;
33
33
  export const getContextualRowData: typeof Utils.getContextualRowData;