@formio/js 5.1.0-dev.6112.86987a5 → 5.1.0-dev.6112.b627acb

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 (83) hide show
  1. package/dist/formio.builder.css +6 -0
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.css +1 -1
  4. package/dist/formio.embed.min.css +1 -1
  5. package/dist/formio.form.css +6 -0
  6. package/dist/formio.form.js +43 -65
  7. package/dist/formio.form.min.css +1 -1
  8. package/dist/formio.form.min.js +1 -1
  9. package/dist/formio.full.css +6 -0
  10. package/dist/formio.full.js +47 -69
  11. package/dist/formio.full.min.css +1 -1
  12. package/dist/formio.full.min.js +1 -1
  13. package/dist/formio.js +21 -43
  14. package/dist/formio.min.js +1 -1
  15. package/dist/formio.utils.js +22 -44
  16. package/dist/formio.utils.min.js +1 -1
  17. package/lib/cjs/Element.js +2 -2
  18. package/lib/cjs/PDFBuilder.js +8 -6
  19. package/lib/cjs/Webform.js +9 -1
  20. package/lib/cjs/WebformBuilder.js +17 -6
  21. package/lib/cjs/Wizard.js +7 -6
  22. package/lib/cjs/WizardBuilder.js +4 -0
  23. package/lib/cjs/components/Components.js +7 -1
  24. package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
  25. package/lib/cjs/components/_classes/component/Component.js +30 -17
  26. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
  27. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
  28. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +2 -1
  29. package/lib/cjs/components/_classes/nested/NestedComponent.js +18 -5
  30. package/lib/cjs/components/address/Address.js +4 -4
  31. package/lib/cjs/components/address/editForm/Address.edit.provider.js +1 -1
  32. package/lib/cjs/components/datagrid/DataGrid.js +12 -1
  33. package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -3
  34. package/lib/cjs/components/editgrid/EditGrid.js +0 -8
  35. package/lib/cjs/components/form/Form.d.ts +2 -1
  36. package/lib/cjs/components/form/Form.js +32 -20
  37. package/lib/cjs/components/number/Number.js +4 -1
  38. package/lib/cjs/components/radio/Radio.d.ts +1 -0
  39. package/lib/cjs/components/radio/Radio.js +5 -5
  40. package/lib/cjs/components/select/Select.js +1 -1
  41. package/lib/cjs/components/tags/Tags.js +7 -0
  42. package/lib/cjs/formio.form.d.ts +2 -1
  43. package/lib/cjs/formio.form.js +2 -1
  44. package/lib/cjs/providers/storage/url.js +7 -3
  45. package/lib/cjs/utils/formUtils.d.ts +3 -3
  46. package/lib/cjs/utils/index.d.ts +6 -5
  47. package/lib/cjs/utils/index.js +2 -1
  48. package/lib/cjs/utils/utils.js +0 -4
  49. package/lib/cjs/widgets/CalendarWidget.js +8 -1
  50. package/lib/mjs/Element.js +2 -2
  51. package/lib/mjs/PDFBuilder.js +8 -6
  52. package/lib/mjs/Webform.js +9 -1
  53. package/lib/mjs/WebformBuilder.js +17 -6
  54. package/lib/mjs/Wizard.js +7 -6
  55. package/lib/mjs/WizardBuilder.js +4 -0
  56. package/lib/mjs/components/Components.js +7 -1
  57. package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
  58. package/lib/mjs/components/_classes/component/Component.js +29 -16
  59. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
  60. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
  61. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +2 -1
  62. package/lib/mjs/components/_classes/nested/NestedComponent.js +17 -5
  63. package/lib/mjs/components/address/Address.js +4 -4
  64. package/lib/mjs/components/address/editForm/Address.edit.provider.js +1 -1
  65. package/lib/mjs/components/datagrid/DataGrid.js +11 -1
  66. package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -3
  67. package/lib/mjs/components/editgrid/EditGrid.js +0 -8
  68. package/lib/mjs/components/form/Form.d.ts +2 -1
  69. package/lib/mjs/components/form/Form.js +32 -20
  70. package/lib/mjs/components/number/Number.js +4 -1
  71. package/lib/mjs/components/radio/Radio.d.ts +1 -0
  72. package/lib/mjs/components/radio/Radio.js +5 -5
  73. package/lib/mjs/components/select/Select.js +1 -1
  74. package/lib/mjs/components/tags/Tags.js +7 -0
  75. package/lib/mjs/formio.form.d.ts +2 -1
  76. package/lib/mjs/formio.form.js +2 -2
  77. package/lib/mjs/providers/storage/url.js +7 -3
  78. package/lib/mjs/utils/formUtils.d.ts +3 -3
  79. package/lib/mjs/utils/index.d.ts +6 -5
  80. package/lib/mjs/utils/index.js +2 -2
  81. package/lib/mjs/utils/utils.js +0 -4
  82. package/lib/mjs/widgets/CalendarWidget.js +8 -1
  83. package/package.json +2 -2
@@ -533,9 +533,9 @@ class Element {
533
533
  if (this.component.filter === string && !this.options.building) {
534
534
  const evalContext = this.evalContext(data);
535
535
  evalContext.data = lodash_1.default.mapValues(evalContext.data, (val) => lodash_1.default.isString(val) ? encodeURIComponent(val) : val);
536
- return utils_1.default.Evaluator.interpolate(string, evalContext, options);
536
+ return utils_1.default.interpolate(string, evalContext, options);
537
537
  }
538
- return utils_1.default.Evaluator.interpolate(string, this.evalContext(data), options);
538
+ return utils_1.default.interpolate(string, this.evalContext(data), options);
539
539
  }
540
540
  /**
541
541
  * Performs an evaluation using the evaluation context of this component.
@@ -454,18 +454,20 @@ class PDFBuilder extends WebformBuilder_1.default {
454
454
  const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
455
455
  // update elements which path was duplicated if any pathes have been changed
456
456
  if (!lodash_1.default.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
457
- (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
458
- if (this.repeatablePathsComps.includes(comp.component)) {
459
- this.webform.postMessage({ name: 'updateElement', data: comp.component });
460
- }
461
- });
457
+ if (!lodash_1.default.isEmpty(this.repeatablePathsComps)) {
458
+ (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
459
+ if (this.repeatablePathsComps.includes(comp.component)) {
460
+ this.webform.postMessage({ name: 'updateElement', data: comp.component });
461
+ }
462
+ });
463
+ }
462
464
  this.repeatablePathsComps = repeatablePathsComps;
463
465
  }
464
466
  if (!repeatablePathsComps.length) {
465
467
  return;
466
468
  }
467
469
  (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
468
- if (this.repeatablePathsComps.includes(comp)) {
470
+ if (this.repeatablePathsComps.includes(comp.component)) {
469
471
  this.webform.postMessage({
470
472
  name: 'showBuilderErrors',
471
473
  data: {
@@ -361,6 +361,14 @@ class Webform extends NestedDataComponent_1.default {
361
361
  get shadowRoot() {
362
362
  return this.options.shadowRoot;
363
363
  }
364
+ // Webforms have no default value setting, so this should be always false
365
+ // I does not affect setting default value to nested forms
366
+ get shouldAddDefaultValue() {
367
+ return false;
368
+ }
369
+ get componentsMap() {
370
+ return this.childComponentsMap || {};
371
+ }
364
372
  /**
365
373
  * Add a language for translations
366
374
  * @param {string} code - The language code for the language being added.
@@ -1119,7 +1127,7 @@ class Webform extends NestedDataComponent_1.default {
1119
1127
  const componentErrors = {};
1120
1128
  errors.forEach((err) => {
1121
1129
  var _a, _b;
1122
- const path = err.path || ((_a = err.context) === null || _a === void 0 ? void 0 : _a.path) || ((_b = err.component) === null || _b === void 0 ? void 0 : _b.key);
1130
+ const path = (0, utils_1.getStringFromComponentPath)(err.path) || ((_a = err.context) === null || _a === void 0 ? void 0 : _a.path) || ((_b = err.component) === null || _b === void 0 ? void 0 : _b.key);
1123
1131
  if (!componentErrors[path]) {
1124
1132
  componentErrors[path] = [];
1125
1133
  }
@@ -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) {
@@ -521,8 +529,8 @@ class WebformBuilder extends Component_1.default {
521
529
  }
522
530
  return elem;
523
531
  };
524
- const hideShow = (group, show) => {
525
- if (show) {
532
+ const hideShow = (group, forceShow, toggle = false) => {
533
+ if (forceShow || (toggle && !Array.from(group.classList).includes('show'))) {
526
534
  group.classList.add(['show']);
527
535
  group.style.display = 'inherit';
528
536
  }
@@ -544,7 +552,9 @@ class WebformBuilder extends Component_1.default {
544
552
  const openByDefault = getAttribute(group, 'default') === 'true';
545
553
  const groupId = group.getAttribute('id').slice('group-'.length);
546
554
  const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
547
- hideShow(group, ((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index));
555
+ if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
556
+ hideShow(group, false, true);
557
+ }
548
558
  });
549
559
  }, true);
550
560
  });
@@ -1099,7 +1109,7 @@ class WebformBuilder extends Component_1.default {
1099
1109
  const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
1100
1110
  lodash_1.default.pull(newComp.validators, 'required');
1101
1111
  parentComponent.tabs[tabIndex].splice(index, 1, newComp);
1102
- newComp.checkValidity = () => true;
1112
+ newComp.processOwnValidation = true;
1103
1113
  newComp.build(defaultValueComponent.element);
1104
1114
  if (this.preview && !this.preview.defaultChanged) {
1105
1115
  const defaultValue = lodash_1.default.get(this.preview._data, this.editForm._data.key);
@@ -1198,6 +1208,7 @@ class WebformBuilder extends Component_1.default {
1198
1208
  submissionData = submissionData.componentJson || submissionData;
1199
1209
  if (submissionData.components && this.originalDefaultValue) {
1200
1210
  submissionData.components = this.originalDefaultValue.components;
1211
+ this.originalDefaultValue = null;
1201
1212
  }
1202
1213
  const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
1203
1214
  this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
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
  }
@@ -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;
@@ -57,7 +57,7 @@ class Components {
57
57
  // eslint-disable-next-line new-cap
58
58
  comp = new Components.components['datagrid'](component, options, data);
59
59
  }
60
- else if (component.tree) {
60
+ else if (component.tree || (component.input && Array.isArray(component.components))) {
61
61
  // eslint-disable-next-line new-cap
62
62
  comp = new Components.components['nesteddata'](component, options, data);
63
63
  }
@@ -75,6 +75,12 @@ class Components {
75
75
  if (comp.path) {
76
76
  comp.componentsMap[comp.path] = comp;
77
77
  }
78
+ // Reset the componentMatches on the root element if any new component is created.
79
+ let parent = comp.parent;
80
+ while (parent) {
81
+ parent.componentMatches = {};
82
+ parent = parent.parent;
83
+ }
78
84
  return comp;
79
85
  }
80
86
  }
@@ -168,6 +168,7 @@ declare class Component extends Element {
168
168
  * @returns {boolean} - If the parent should conditionally clear.
169
169
  */
170
170
  parentShouldConditionallyClear(): boolean;
171
+ hasCondionallyHiddenLayoutParent(): boolean;
171
172
  parentConditionallyHidden(): boolean;
172
173
  /**
173
174
  * Returns true if any of the parents default their component "hidden" property to true.
@@ -450,6 +450,16 @@ class Component extends Element_1.default {
450
450
  }
451
451
  return false;
452
452
  }
453
+ hasCondionallyHiddenLayoutParent() {
454
+ let currentParent = this.parent;
455
+ while (currentParent) {
456
+ if (currentParent._conditionallyHidden && utils_1.default.isLayoutComponent(currentParent) && currentParent.component.clearOnHide === true) {
457
+ return true;
458
+ }
459
+ currentParent = currentParent.parent;
460
+ }
461
+ return false;
462
+ }
453
463
  parentConditionallyHidden() {
454
464
  let currentParent = this.parent;
455
465
  while (currentParent) {
@@ -633,10 +643,13 @@ class Component extends Element_1.default {
633
643
  if (!component) {
634
644
  component = this.component;
635
645
  }
646
+ if (!this.path) {
647
+ return false;
648
+ }
636
649
  if (lodash_1.default.isArray(this.options[visibility])) {
637
- return this.options[visibility].includes(component.key);
650
+ return this.options[visibility].includes(this.path);
638
651
  }
639
- return this.options[visibility][component.key];
652
+ return this.options[visibility][this.path];
640
653
  }
641
654
  shouldForceHide(component) {
642
655
  return this.shouldForceVisibility(component, 'hide');
@@ -716,7 +729,7 @@ class Component extends Element_1.default {
716
729
  this._conditionallyClear = true;
717
730
  return this._conditionallyClear;
718
731
  }
719
- this._conditionallyClear = this.hasSetValue ? false : this.parentShouldConditionallyClear();
732
+ this._conditionallyClear = this.hasSetValue ? this.hasCondionallyHiddenLayoutParent() : this.parentShouldConditionallyClear();
720
733
  return this._conditionallyClear;
721
734
  }
722
735
  /**
@@ -1170,15 +1183,21 @@ class Component extends Element_1.default {
1170
1183
  * @returns {string} - The modal preview template.
1171
1184
  */
1172
1185
  getModalPreviewTemplate() {
1173
- var _a;
1186
+ var _a, _b;
1174
1187
  const dataValue = this.component.type === 'password' ? this.dataValue.replace(/./g, '•') : this.dataValue;
1175
1188
  let modalLabel;
1176
1189
  if (this.hasInput && ((_a = this.component.validate) === null || _a === void 0 ? void 0 : _a.required) && !this.isPDFReadOnlyMode) {
1177
1190
  modalLabel = { className: 'field-required' };
1178
1191
  }
1192
+ let messages = '';
1193
+ if ((_b = this.errors) === null || _b === void 0 ? void 0 : _b.length) {
1194
+ messages = this.errors.map((err) => {
1195
+ return err.level === 'error' ? this.renderTemplate('message', Object.assign({}, err)) : '';
1196
+ }).join('');
1197
+ }
1179
1198
  return this.renderModalPreview({
1180
1199
  previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('clickToSetValue'),
1181
- messages: '',
1200
+ messages,
1182
1201
  labelInfo: modalLabel,
1183
1202
  });
1184
1203
  }
@@ -2557,7 +2576,7 @@ class Component extends Element_1.default {
2557
2576
  if ((value !== null) && (value !== undefined)) {
2558
2577
  value = this.hook('setDataValue', value, this.key, this._data);
2559
2578
  }
2560
- if ((value === null) || (value === undefined)) {
2579
+ if ((value === null) || (value === undefined) || lodash_1.default.isNaN(value)) {
2561
2580
  this.unset();
2562
2581
  return;
2563
2582
  }
@@ -2590,17 +2609,6 @@ class Component extends Element_1.default {
2590
2609
  noUpdateEvent: true,
2591
2610
  noDefault: true
2592
2611
  });
2593
- if (utils_1.default.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
2594
- utils_1.default.eachComponent(this.components, (component) => {
2595
- if (component.component.clearOnHide !== false) {
2596
- component.setValue(null, {
2597
- noUpdateEvent: true,
2598
- noDefault: true
2599
- });
2600
- component.unset();
2601
- }
2602
- });
2603
- }
2604
2612
  this.unset();
2605
2613
  }
2606
2614
  getCustomDefaultValue(defaultValue) {
@@ -2726,6 +2734,11 @@ class Component extends Element_1.default {
2726
2734
  this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
2727
2735
  }
2728
2736
  }
2737
+ // Also reset value of the modal component, otherwise it will keep the old value locally and the preview
2738
+ // element won't refresh
2739
+ if (this.componentModal && flags && flags.resetValue) {
2740
+ this.componentModal.setValue(value);
2741
+ }
2729
2742
  return changed;
2730
2743
  }
2731
2744
  /**
@@ -82,6 +82,7 @@ declare const _default: ({
82
82
  inline?: undefined;
83
83
  defaultValue?: undefined;
84
84
  values?: undefined;
85
+ customConditional?: undefined;
85
86
  logic?: undefined;
86
87
  dataSrc?: undefined;
87
88
  valueProperty?: undefined;
@@ -101,6 +102,7 @@ declare const _default: ({
101
102
  inline?: undefined;
102
103
  defaultValue?: undefined;
103
104
  values?: undefined;
105
+ customConditional?: undefined;
104
106
  logic?: undefined;
105
107
  dataSrc?: undefined;
106
108
  valueProperty?: undefined;
@@ -126,6 +128,7 @@ declare const _default: ({
126
128
  value: string;
127
129
  })[];
128
130
  placeholder?: undefined;
131
+ customConditional?: undefined;
129
132
  logic?: undefined;
130
133
  dataSrc?: undefined;
131
134
  valueProperty?: undefined;
@@ -141,6 +144,7 @@ declare const _default: ({
141
144
  tooltip: string;
142
145
  key: string;
143
146
  input: boolean;
147
+ customConditional: string;
144
148
  logic: ({
145
149
  name: string;
146
150
  trigger: {
@@ -211,6 +215,7 @@ declare const _default: ({
211
215
  inline?: undefined;
212
216
  defaultValue?: undefined;
213
217
  values?: undefined;
218
+ customConditional?: undefined;
214
219
  logic?: undefined;
215
220
  as?: undefined;
216
221
  editor?: undefined;
@@ -226,6 +231,7 @@ declare const _default: ({
226
231
  placeholder?: undefined;
227
232
  inline?: undefined;
228
233
  values?: undefined;
234
+ customConditional?: undefined;
229
235
  logic?: undefined;
230
236
  dataSrc?: undefined;
231
237
  valueProperty?: undefined;
@@ -248,6 +254,7 @@ declare const _default: ({
248
254
  placeholder?: undefined;
249
255
  inline?: undefined;
250
256
  values?: undefined;
257
+ customConditional?: undefined;
251
258
  logic?: undefined;
252
259
  dataSrc?: undefined;
253
260
  valueProperty?: undefined;
@@ -61,6 +61,7 @@ exports.default = [
61
61
  tooltip: 'Encrypt this field on the server. This is two way encryption which is not suitable for passwords.',
62
62
  key: 'encrypted',
63
63
  input: true,
64
+ customConditional: 'show = data.encrypted;',
64
65
  logic: [
65
66
  {
66
67
  name: 'disabled',
@@ -108,6 +108,7 @@ export default class NestedComponent extends Field {
108
108
  * @returns {any} - The component that is located.
109
109
  */
110
110
  getComponent(path: string): any;
111
+ componentMatches: {} | undefined;
111
112
  /**
112
113
  * Return a component provided the Id of the component.
113
114
  * @param {string} id - The Id of the component.
@@ -154,7 +155,7 @@ export default class NestedComponent extends Field {
154
155
  * @param {import('@formio/core').Component[]} components - The components to attach logic to.
155
156
  */
156
157
  attachComponentsLogic(components: import('@formio/core').Component[]): void;
157
- attachComponents(element: any, components: any, container: any): Promise<any>;
158
+ attachComponents(element: any, components: any, container: any): Promise<void> | Promise<any[]>;
158
159
  /**
159
160
  * Remove a component from the components array and from the children object
160
161
  * @param {import('@formio/core').Component} component - The component to remove from the components.
@@ -311,6 +311,13 @@ class NestedComponent extends Field_1.default {
311
311
  */
312
312
  getComponent(path) {
313
313
  var _a;
314
+ // If the component is found
315
+ if (!this.componentMatches) {
316
+ this.componentMatches = {};
317
+ }
318
+ if (this.componentMatches && this.componentMatches[path]) {
319
+ return this.componentMatches[path];
320
+ }
314
321
  path = utils_1.default.getStringFromComponentPath(path);
315
322
  const matches = {
316
323
  path: undefined,
@@ -336,7 +343,8 @@ class NestedComponent extends Field_1.default {
336
343
  return match;
337
344
  });
338
345
  });
339
- return (_a = utils_1.default.getBestMatch(matches)) === null || _a === void 0 ? void 0 : _a.instance;
346
+ this.componentMatches[path] = (_a = utils_1.default.getBestMatch(matches)) === null || _a === void 0 ? void 0 : _a.instance;
347
+ return this.componentMatches[path];
340
348
  }
341
349
  /**
342
350
  * Return a component provided the Id of the component.
@@ -530,8 +538,7 @@ class NestedComponent extends Field_1.default {
530
538
  container = container || this.component.components;
531
539
  element = this.hook('attachComponents', element, components, container, this);
532
540
  if (!element) {
533
- // Return a non-resolving promise.
534
- return (new Promise(() => { }));
541
+ return Promise.resolve();
535
542
  }
536
543
  let index = 0;
537
544
  const promises = [];
@@ -550,12 +557,16 @@ class NestedComponent extends Field_1.default {
550
557
  * @param {boolean} [all] - If set to TRUE will cascade remove all components.
551
558
  */
552
559
  removeComponent(component, components, all = false) {
560
+ var _a, _b;
553
561
  components = components || this.components;
554
562
  component.destroy(all);
555
563
  lodash_1.default.remove(components, { id: component.id });
556
564
  if (this.componentsMap[component.path]) {
557
565
  delete this.componentsMap[component.path];
558
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
+ }
559
570
  }
560
571
  /**
561
572
  * Removes a component provided the API key of that component.
@@ -800,8 +811,10 @@ class NestedComponent extends Field_1.default {
800
811
  return this.data;
801
812
  }
802
813
  resetValue() {
803
- super.resetValue();
814
+ // Reset values of child components first, then reset the parent one, otherwise it will restore the default
815
+ // value of parent component and clear it one by one while resetting child components
804
816
  this.getComponents().forEach((comp) => comp.resetValue());
817
+ super.resetValue();
805
818
  this.setPristine(true);
806
819
  }
807
820
  get dataReady() {
@@ -813,7 +826,7 @@ class NestedComponent extends Field_1.default {
813
826
  return false;
814
827
  }
815
828
  if (component.type === 'components') {
816
- if (component.tree && component.hasValue(value)) {
829
+ if ((component.tree || component.hasInput) && component.hasValue(value)) {
817
830
  return component.setValue(lodash_1.default.get(value, component.key), flags);
818
831
  }
819
832
  return component.setValue(value, flags);
@@ -249,7 +249,7 @@ class AddressComponent extends Container_1.default {
249
249
  if (this.manualMode) {
250
250
  this.restoreComponentsContext();
251
251
  }
252
- if (changed || !lodash_1.default.isEmpty(value) && flags.fromSubmission) {
252
+ if (changed || !lodash_1.default.isEmpty(value) && flags.fromSubmission || flags.resetValue) {
253
253
  this.redraw();
254
254
  }
255
255
  return changed;
@@ -571,11 +571,11 @@ class AddressComponent extends Container_1.default {
571
571
  }
572
572
  if (valueInManualMode) {
573
573
  if (this.component.manualModeViewString) {
574
- return this.interpolate(this.component.manualModeViewString, {
574
+ return this.evaluate(this.component.manualModeViewString, {
575
575
  address,
576
- data: this.data,
576
+ data: value,
577
577
  component: this.component,
578
- });
578
+ }, 'value');
579
579
  }
580
580
  return this.getComponents()
581
581
  .filter((component) => component.hasValue(address))
@@ -147,7 +147,7 @@ exports.default = [
147
147
  key: 'manualModeViewString',
148
148
  label: 'Manual Mode View String',
149
149
  placeholder: 'Enter Manual Mode View String',
150
- description: '"address" variable references component value, "data" - submission data and "component" - address component schema.',
150
+ description: '"data.address" references component value and "component" - address component schema.',
151
151
  weight: 60,
152
152
  rows: 5,
153
153
  editor: 'ace',
@@ -419,12 +419,16 @@ class DataGridComponent extends NestedArrayComponent_1.default {
419
419
  updateComponentsRowIndex(components, rowIndex) {
420
420
  components.forEach((component, colIndex) => {
421
421
  var _a;
422
+ if (this.componentsMap[component.paths.dataPath]) {
423
+ delete this.componentsMap[component.paths.dataPath];
424
+ }
422
425
  if ((_a = component.options) === null || _a === void 0 ? void 0 : _a.name) {
423
426
  const newName = `[${this.key}][${rowIndex}]`;
424
427
  component.options.name = component.options.name.replace(`[${this.key}][${component.rowIndex}]`, newName);
425
428
  }
426
429
  component.rowIndex = rowIndex;
427
430
  component.row = `${rowIndex}-${colIndex}`;
431
+ this.componentsMap[component.paths.dataPath] = component;
428
432
  });
429
433
  }
430
434
  updateRowsComponents(rowIndex) {
@@ -492,11 +496,18 @@ class DataGridComponent extends NestedArrayComponent_1.default {
492
496
  options.row = `${rowIndex}-${colIndex}`;
493
497
  options.rowIndex = rowIndex;
494
498
  options.onChange = (flags, changed, modified) => {
499
+ var _a, _b;
495
500
  if (changed.component.type === 'form') {
496
501
  const formComp = (0, utils_1.getComponent)(this.component.components, changed.component.key);
497
502
  lodash_1.default.set(formComp, 'components', changed.component.components);
498
503
  }
499
- this.triggerChange({ modified });
504
+ // If we're in a nested form we need to ensure our changes are triggered upstream
505
+ 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)) {
506
+ changed.instance.root.triggerChange(flags, changed, modified);
507
+ }
508
+ else {
509
+ this.triggerChange({ modified });
510
+ }
500
511
  };
501
512
  let columnComponent;
502
513
  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;
@@ -101,7 +101,6 @@ export default class EditGridComponent extends NestedArrayComponent {
101
101
  changeState(changed: any, flags: any): void;
102
102
  openWhenEmpty(): void;
103
103
  restoreRowContext(editRow: any, flags?: {}): void;
104
- emptyRows(): void;
105
104
  hasChanged: (newValue: any, oldValue: any) => boolean;
106
105
  }
107
106
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
@@ -1200,14 +1200,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1200
1200
  this.setNestedValue(component, editRow.data, flags);
1201
1201
  });
1202
1202
  }
1203
- emptyRows() {
1204
- this.editRows.forEach((editRow, index) => this.destroyComponents(false, index));
1205
- this.editRows = [];
1206
- }
1207
- resetValue() {
1208
- super.resetValue();
1209
- this.emptyRows();
1210
- }
1211
1203
  }
1212
1204
  exports.default = EditGridComponent;
1213
1205
  EditGridComponent.prototype.hasChanged = Component_1.default.prototype.hasChanged;
@@ -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.