@formio/js 5.2.0 → 5.2.1-dev.6202.2449b29

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/Changelog.md +6969 -0
  2. package/dist/formio.builder.css +15 -17
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.js +1 -1
  5. package/dist/formio.embed.min.js +1 -1
  6. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.form.css +15 -17
  8. package/dist/formio.form.js +49 -60
  9. package/dist/formio.form.min.css +1 -1
  10. package/dist/formio.form.min.js +1 -1
  11. package/dist/formio.form.min.js.LICENSE.txt +3 -3
  12. package/dist/formio.full.css +15 -17
  13. package/dist/formio.full.js +51 -62
  14. package/dist/formio.full.min.css +1 -1
  15. package/dist/formio.full.min.js +1 -1
  16. package/dist/formio.full.min.js.LICENSE.txt +3 -3
  17. package/dist/formio.js +20 -31
  18. package/dist/formio.min.js +1 -1
  19. package/dist/formio.min.js.LICENSE.txt +1 -1
  20. package/dist/formio.utils.js +19 -30
  21. package/dist/formio.utils.min.js +1 -1
  22. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  23. package/lib/cjs/Embed.js +1 -1
  24. package/lib/cjs/Formio.js +1 -1
  25. package/lib/cjs/PDFBuilder.js +8 -6
  26. package/lib/cjs/Webform.js +11 -2
  27. package/lib/cjs/WebformBuilder.js +29 -14
  28. package/lib/cjs/Wizard.d.ts +1 -2
  29. package/lib/cjs/Wizard.js +22 -23
  30. package/lib/cjs/components/Components.js +1 -1
  31. package/lib/cjs/components/_classes/component/Component.d.ts +23 -2
  32. package/lib/cjs/components/_classes/component/Component.js +61 -35
  33. package/lib/cjs/components/_classes/nested/NestedComponent.js +6 -5
  34. package/lib/cjs/components/datagrid/DataGrid.js +8 -1
  35. package/lib/cjs/components/file/File.d.ts +1 -1
  36. package/lib/cjs/components/file/File.js +6 -1
  37. package/lib/cjs/components/form/Form.d.ts +0 -2
  38. package/lib/cjs/components/form/Form.js +12 -20
  39. package/lib/cjs/components/radio/Radio.js +1 -1
  40. package/lib/cjs/components/select/Select.d.ts +1 -1
  41. package/lib/cjs/components/select/Select.js +17 -26
  42. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  43. package/lib/cjs/components/tags/Tags.js +2 -2
  44. package/lib/cjs/formio.form.js +1 -0
  45. package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
  46. package/lib/cjs/utils/ChoicesWrapper.js +47 -124
  47. package/lib/cjs/utils/formUtils.d.ts +3 -3
  48. package/lib/cjs/utils/index.d.ts +5 -5
  49. package/lib/cjs/utils/utils.d.ts +4 -4
  50. package/lib/cjs/utils/utils.js +2 -2
  51. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -1
  52. package/lib/cjs/widgets/CalendarWidget.js +1 -1
  53. package/lib/mjs/Embed.js +1 -1
  54. package/lib/mjs/Formio.js +1 -1
  55. package/lib/mjs/PDFBuilder.js +8 -6
  56. package/lib/mjs/Webform.js +10 -2
  57. package/lib/mjs/WebformBuilder.js +30 -15
  58. package/lib/mjs/Wizard.d.ts +1 -2
  59. package/lib/mjs/Wizard.js +21 -22
  60. package/lib/mjs/components/Components.js +1 -1
  61. package/lib/mjs/components/_classes/component/Component.d.ts +23 -2
  62. package/lib/mjs/components/_classes/component/Component.js +61 -35
  63. package/lib/mjs/components/_classes/nested/NestedComponent.js +5 -5
  64. package/lib/mjs/components/datagrid/DataGrid.js +7 -1
  65. package/lib/mjs/components/file/File.d.ts +1 -1
  66. package/lib/mjs/components/file/File.js +6 -1
  67. package/lib/mjs/components/form/Form.d.ts +0 -2
  68. package/lib/mjs/components/form/Form.js +12 -20
  69. package/lib/mjs/components/radio/Radio.js +1 -1
  70. package/lib/mjs/components/select/Select.d.ts +1 -1
  71. package/lib/mjs/components/select/Select.js +17 -25
  72. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  73. package/lib/mjs/components/tags/Tags.js +2 -2
  74. package/lib/mjs/formio.form.js +1 -0
  75. package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
  76. package/lib/mjs/utils/ChoicesWrapper.js +26 -119
  77. package/lib/mjs/utils/formUtils.d.ts +3 -3
  78. package/lib/mjs/utils/index.d.ts +5 -5
  79. package/lib/mjs/utils/utils.d.ts +4 -4
  80. package/lib/mjs/utils/utils.js +2 -2
  81. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -1
  82. package/lib/mjs/widgets/CalendarWidget.js +1 -1
  83. package/package.json +5 -5
@@ -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.0 | https://unpkg.com/formiojs@5.2.0/LICENSE.txt */
23
+ /*! formiojs v5.2.1-rc.9 | https://unpkg.com/formiojs@5.2.1-rc.9/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
 
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.0';
421
+ Formio.version = '5.2.1-rc.9';
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.0';
14
+ sdk_1.Formio.version = '5.2.1-rc.9';
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) {
@@ -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: {
@@ -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.
@@ -740,7 +748,8 @@ class Webform extends NestedDataComponent_1.default {
740
748
  this.emit(restoreDraft ? "restoreDraftError" : "saveDraftError", errDetails || errorMessage);
741
749
  }
742
750
  saveDraft() {
743
- if (!this.draftEnabled) {
751
+ var _a;
752
+ if (!this.draftEnabled || ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.component.reference) === false) {
744
753
  return;
745
754
  }
746
755
  if (!this.formio) {
@@ -1113,7 +1122,7 @@ class Webform extends NestedDataComponent_1.default {
1113
1122
  const componentErrors = {};
1114
1123
  errors.forEach((err) => {
1115
1124
  var _a, _b;
1116
- 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);
1125
+ 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);
1117
1126
  if (!componentErrors[path]) {
1118
1127
  componentErrors[path] = [];
1119
1128
  }
@@ -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) {
@@ -1100,7 +1108,7 @@ class WebformBuilder extends Component_1.default {
1100
1108
  const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
1101
1109
  lodash_1.default.pull(newComp.validators, 'required');
1102
1110
  parentComponent.tabs[tabIndex].splice(index, 1, newComp);
1103
- newComp.checkValidity = () => true;
1111
+ newComp.processOwnValidation = true;
1104
1112
  newComp.build(defaultValueComponent.element);
1105
1113
  if (this.preview && !this.preview.defaultChanged) {
1106
1114
  const defaultValue = lodash_1.default.get(this.preview._data, this.editForm._data.key);
@@ -1132,15 +1140,18 @@ class WebformBuilder extends Component_1.default {
1132
1140
  (0, utils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
1133
1141
  var _a, _b;
1134
1142
  const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
1135
- if (keys.has(paths.dataPath)) {
1136
- const onlyRadioCheckboxes = ((_a = repeatablePaths[paths.dataPath]) === null || _a === void 0 ? void 0 : _a.onlyRadioCheckboxes) === false ? false : isRadioCheckbox;
1137
- repeatablePaths[paths.dataPath] = {
1138
- comps: [...(((_b = repeatablePaths[paths.dataPath]) === null || _b === void 0 ? void 0 : _b.comps) || []), keys.get(paths.dataPath), comp],
1139
- onlyRadioCheckboxes,
1140
- };
1141
- }
1142
- else {
1143
- keys.set(paths.dataPath, comp);
1143
+ const isLayout = (0, utils_1.componentInfo)(comp).layout;
1144
+ if (!isLayout) {
1145
+ if (keys.has(paths.dataPath)) {
1146
+ const onlyRadioCheckboxes = ((_a = repeatablePaths[paths.dataPath]) === null || _a === void 0 ? void 0 : _a.onlyRadioCheckboxes) === false ? false : isRadioCheckbox;
1147
+ repeatablePaths[paths.dataPath] = {
1148
+ comps: [...(((_b = repeatablePaths[paths.dataPath]) === null || _b === void 0 ? void 0 : _b.comps) || []), keys.get(paths.dataPath), comp],
1149
+ onlyRadioCheckboxes,
1150
+ };
1151
+ }
1152
+ else {
1153
+ keys.set(paths.dataPath, comp);
1154
+ }
1144
1155
  }
1145
1156
  }, true);
1146
1157
  const componentsWithRepeatablePaths = [];
@@ -1160,6 +1171,9 @@ class WebformBuilder extends Component_1.default {
1160
1171
  comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1161
1172
  hasInvalidComponents = true;
1162
1173
  }
1174
+ else {
1175
+ comp.setCustomValidity();
1176
+ }
1163
1177
  });
1164
1178
  this.emit('builderFormValidityChange', hasInvalidComponents);
1165
1179
  }
@@ -1279,7 +1293,8 @@ class WebformBuilder extends Component_1.default {
1279
1293
  helplinks: this.helplinks,
1280
1294
  }));
1281
1295
  this.editForm.attach(this.componentEdit.querySelector(`[${this._referenceAttributeName}="editForm"]`));
1282
- this.updateComponent((_a = this.editForm.submission.data) !== null && _a !== void 0 ? _a : component);
1296
+ const editFormData = (_a = this.editForm.submission) === null || _a === void 0 ? void 0 : _a.data;
1297
+ this.updateComponent((editFormData === null || editFormData === void 0 ? void 0 : editFormData.componentJson) || editFormData || component);
1283
1298
  this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
1284
1299
  });
1285
1300
  });
@@ -1646,7 +1661,7 @@ class WebformBuilder extends Component_1.default {
1646
1661
  }
1647
1662
  hasEditTabs(type) {
1648
1663
  // If the component type does not exist then it has no edit tabs
1649
- if (!Components_1.default.components[type]) {
1664
+ if (!Components_1.default.components[type === 'custom' ? 'unknown' : type]) {
1650
1665
  return false;
1651
1666
  }
1652
1667
  const editTabs = (0, utils_1.getComponent)(Components_1.default.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
@@ -6,7 +6,6 @@ declare class Wizard extends Webform {
6
6
  originalComponents: any[];
7
7
  page: number;
8
8
  currentPanel: any;
9
- currentPanels: any[] | null;
10
9
  currentNextPage: number;
11
10
  _seenPages: number[];
12
11
  subWizards: any[];
@@ -17,7 +16,7 @@ declare class Wizard extends Webform {
17
16
  originalOptions: any;
18
17
  isLastPage(): any;
19
18
  getPages(args?: {}): any[];
20
- get hasExtraPages(): boolean;
19
+ get hasSubWizards(): boolean;
21
20
  get localData(): any;
22
21
  get wizardKey(): string;
23
22
  set wizard(form: object);
package/lib/cjs/Wizard.js CHANGED
@@ -34,7 +34,6 @@ class Wizard extends Webform_1.default {
34
34
  this.originalComponents = [];
35
35
  this.page = 0;
36
36
  this.currentPanel = null;
37
- this.currentPanels = null;
38
37
  this.currentNextPage = 0;
39
38
  this._seenPages = [0];
40
39
  this.subWizards = [];
@@ -53,12 +52,12 @@ class Wizard extends Webform_1.default {
53
52
  }
54
53
  getPages(args = {}) {
55
54
  const { all = false } = args;
56
- const pages = this.hasExtraPages ? this.components : this.pages;
55
+ const pages = this.hasSubWizards ? this.components : this.pages;
57
56
  const filteredPages = pages
58
57
  .filter(all ? lodash_1.default.identity : (p, index) => this._seenPages.includes(index));
59
58
  return filteredPages;
60
59
  }
61
- get hasExtraPages() {
60
+ get hasSubWizards() {
62
61
  return !lodash_1.default.isEmpty(this.subWizards);
63
62
  }
64
63
  get data() {
@@ -187,9 +186,9 @@ class Wizard extends Webform_1.default {
187
186
  }
188
187
  render() {
189
188
  const ctx = this.renderContext;
190
- if (this.component.key) {
191
- ctx.panels.map(panel => {
192
- if (panel.key === this.component.key) {
189
+ if (this.component.id) {
190
+ ctx.panels.forEach(panel => {
191
+ if (panel.id === this.component.id) {
193
192
  this.currentPanel = panel;
194
193
  ctx.wizardPageTooltip = this.getFormattedTooltip(panel.tooltip);
195
194
  }
@@ -587,7 +586,7 @@ class Wizard extends Webform_1.default {
587
586
  this.pageFieldLogic(num);
588
587
  this.getNextPage();
589
588
  let parentNum = num;
590
- if (this.hasExtraPages) {
589
+ if (this.hasSubWizards) {
591
590
  const pageFromPages = this.pages[num];
592
591
  const pageFromComponents = this.components[num];
593
592
  if (!pageFromComponents || (pageFromPages === null || pageFromPages === void 0 ? void 0 : pageFromPages.id) !== pageFromComponents.id) {
@@ -822,6 +821,11 @@ class Wizard extends Webform_1.default {
822
821
  }
823
822
  }
824
823
  setValue(submission, flags = {}, ignoreEstablishment) {
824
+ if (!submission || !submission.data) {
825
+ submission = {
826
+ data: {},
827
+ };
828
+ }
825
829
  const changed = this.getPages({ all: true }).reduce((changed, page) => {
826
830
  return this.setNestedValue(page, submission.data, flags, changed) || changed;
827
831
  }, false);
@@ -873,7 +877,7 @@ class Wizard extends Webform_1.default {
873
877
  }
874
878
  }
875
879
  onChange(flags, changed, modified, changes) {
876
- var _a, _b;
880
+ var _a;
877
881
  super.onChange(flags, changed, modified, changes);
878
882
  // The onChange loop doesn't need all components for wizards
879
883
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
@@ -881,23 +885,18 @@ class Wizard extends Webform_1.default {
881
885
  this.showErrors(errors, true, true);
882
886
  }
883
887
  // If the pages change, need to redraw the header.
884
- let currentPanels;
885
- let panels;
888
+ const currentPanels = this.pages;
889
+ // calling this.establishPages() updates/mutates this.pages to be the current pages
890
+ this.establishPages();
891
+ const newPanels = this.pages;
886
892
  const currentNextPage = this.currentNextPage;
887
- if (this.hasExtraPages) {
888
- currentPanels = this.pages.map(page => page.component.key);
889
- this.establishPages();
890
- panels = this.pages.map(page => page.component.key);
891
- }
892
- else {
893
- currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
894
- panels = this.establishPages().map(panel => panel.key);
895
- this.currentPanels = panels;
896
- if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.key) && ((_b = this.currentPanels) === null || _b === void 0 ? void 0 : _b.length)) {
897
- this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
898
- }
893
+ const panelsUpdated = !lodash_1.default.isEqual(newPanels, currentPanels);
894
+ if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.id) && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
895
+ const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
896
+ if (newIndex !== -1)
897
+ this.setPage(newIndex);
899
898
  }
900
- if (!lodash_1.default.isEqual(panels, currentPanels) || (flags && flags.fromSubmission)) {
899
+ if (panelsUpdated || (flags && flags.fromSubmission)) {
901
900
  this.redrawHeader();
902
901
  }
903
902
  // If the next page changes, then make sure to redraw navigation.
@@ -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
  }
@@ -165,10 +165,16 @@ declare class Component extends Element {
165
165
  get componentsMap(): object;
166
166
  /**
167
167
  * Returns if the parent should conditionally clear.
168
+ *
168
169
  * @returns {boolean} - If the parent should conditionally clear.
169
170
  */
170
171
  parentShouldConditionallyClear(): boolean;
171
172
  parentConditionallyHidden(): boolean;
173
+ /**
174
+ * Returns true if any of the parents default their component "hidden" property to true.
175
+ * @returns {boolean} - If any parent defaults the hidden property to true.
176
+ */
177
+ anyParentDefaultsHidden(): boolean;
172
178
  set data(value: any);
173
179
  get data(): any;
174
180
  mergeSchema(component?: {}): any;
@@ -232,8 +238,23 @@ declare class Component extends Element {
232
238
  get visible(): boolean;
233
239
  get logicallyHidden(): any;
234
240
  _logicallyHidden: any;
235
- shouldConditionallyClear(skipParent?: boolean): boolean;
236
- conditionallyHidden(skipParent?: boolean): boolean;
241
+ /**
242
+ * Determines if the component should clear its value when the root form is pristine.
243
+ * @returns {boolean} - If the component should clear its value when the root form is pristine.
244
+ */
245
+ shouldConditionallyClearOnPristine(): boolean;
246
+ /**
247
+ * Returns if the component should clear its value when conditionally hidden.
248
+ * @returns {boolean} - If the component should clear its value when conditionally hidden.
249
+ */
250
+ shouldConditionallyClear(): boolean;
251
+ _conditionallyClear: boolean | undefined;
252
+ /**
253
+ * Returns if the component is conditionally hidden.
254
+ * @returns {boolean} - If the component is conditionally hidden.
255
+ */
256
+ conditionallyHidden(): boolean;
257
+ _conditionallyHidden: boolean | undefined;
237
258
  set currentForm(instance: any);
238
259
  get currentForm(): any;
239
260
  _currentForm: any;
@@ -424,12 +424,14 @@ class Component extends Element_1.default {
424
424
  }
425
425
  /**
426
426
  * Returns if the parent should conditionally clear.
427
+ *
427
428
  * @returns {boolean} - If the parent should conditionally clear.
428
429
  */
429
430
  parentShouldConditionallyClear() {
430
431
  let currentParent = this.parent;
431
432
  while (currentParent) {
432
- if (currentParent.shouldConditionallyClear(true)) {
433
+ if ((currentParent.allowData && currentParent._conditionallyClear) ||
434
+ (!currentParent.allowData && currentParent._conditionallyHidden)) {
433
435
  return true;
434
436
  }
435
437
  currentParent = currentParent.parent;
@@ -439,7 +441,21 @@ class Component extends Element_1.default {
439
441
  parentConditionallyHidden() {
440
442
  let currentParent = this.parent;
441
443
  while (currentParent) {
442
- if (currentParent.conditionallyHidden(true)) {
444
+ if (currentParent._conditionallyHidden) {
445
+ return true;
446
+ }
447
+ currentParent = currentParent.parent;
448
+ }
449
+ return false;
450
+ }
451
+ /**
452
+ * Returns true if any of the parents default their component "hidden" property to true.
453
+ * @returns {boolean} - If any parent defaults the hidden property to true.
454
+ */
455
+ anyParentDefaultsHidden() {
456
+ let currentParent = this.parent;
457
+ while (currentParent) {
458
+ if (currentParent.component.hidden) {
443
459
  return true;
444
460
  }
445
461
  currentParent = currentParent.parent;
@@ -654,48 +670,58 @@ class Component extends Element_1.default {
654
670
  }
655
671
  return this._logicallyHidden;
656
672
  }
657
- shouldConditionallyClear(skipParent = false) {
673
+ /**
674
+ * Determines if the component should clear its value when the root form is pristine.
675
+ * @returns {boolean} - If the component should clear its value when the root form is pristine.
676
+ */
677
+ shouldConditionallyClearOnPristine() {
678
+ // If the form is pristine, we should NOT clear the value of a conditionally hidden child component
679
+ // of a layout component that defaults to hidden using the "hidden" component property.
680
+ return !this.anyParentDefaultsHidden();
681
+ }
682
+ /**
683
+ * Returns if the component should clear its value when conditionally hidden.
684
+ * @returns {boolean} - If the component should clear its value when conditionally hidden.
685
+ */
686
+ shouldConditionallyClear() {
658
687
  // Skip if this component has clearOnHide set to false.
659
688
  if (this.component.clearOnHide === false) {
660
- return false;
689
+ this._conditionallyClear = false;
690
+ return this._conditionallyClear;
661
691
  }
662
692
  // If the component is logically hidden, then it is conditionally hidden and should clear.
663
693
  if (this.logicallyHidden) {
664
- return true;
694
+ this._conditionallyClear = true;
695
+ return this._conditionallyClear;
665
696
  }
666
697
  // If we have a condition and it is not conditionally visible, the it should conditionally clear.
667
- if (this.hasCondition() && !this.conditionallyVisible()) {
668
- return true;
669
- }
670
- if (skipParent) {
671
- // Stop recurrsion for the parent checks.
672
- return false;
673
- }
674
- // If this component has a set value, then it should ONLY clear if a parent is hidden
675
- // and has the clearOnHide set to true.
676
- if (this.hasSetValue) {
677
- return this.parentShouldConditionallyClear();
698
+ if (this.hasCondition() &&
699
+ !this.conditionallyVisible() &&
700
+ (!this.rootPristine || this.shouldConditionallyClearOnPristine())) {
701
+ this._conditionallyClear = true;
702
+ return this._conditionallyClear;
678
703
  }
679
- // Clear the value if the parent is conditionally hidden.
680
- return this.parentConditionallyHidden();
704
+ this._conditionallyClear = this.hasSetValue ? false : this.parentShouldConditionallyClear();
705
+ return this._conditionallyClear;
681
706
  }
682
- conditionallyHidden(skipParent = false) {
707
+ /**
708
+ * Returns if the component is conditionally hidden.
709
+ * @returns {boolean} - If the component is conditionally hidden.
710
+ */
711
+ conditionallyHidden() {
712
+ // If it is logically hidden, then it is conditionally hidden.
683
713
  if (this.logicallyHidden) {
684
- return true;
714
+ this._conditionallyHidden = true;
715
+ return this._conditionallyHidden;
685
716
  }
686
- if (!this.hasCondition() && !skipParent) {
687
- return this.parentConditionallyHidden();
688
- }
689
- // Return if we are not conditionally visible (conditionallyHidden)
690
- if (!this.conditionallyVisible()) {
691
- return true;
692
- }
693
- if (skipParent) {
694
- // Stop recurrsion for the parent checks.
695
- return false;
717
+ // If it has a condition, and is not conditionally visible, then it is conditionally hidden.
718
+ if (this.hasCondition() && !this.conditionallyVisible()) {
719
+ this._conditionallyHidden = true;
720
+ return this._conditionallyHidden;
696
721
  }
697
- // Check the parent.
698
- return this.parentConditionallyHidden();
722
+ // It is conditionally hidden if its parent is conditionally hidden.
723
+ this._conditionallyHidden = this.parentConditionallyHidden();
724
+ return this._conditionallyHidden;
699
725
  }
700
726
  get currentForm() {
701
727
  return this._currentForm;
@@ -3163,6 +3189,9 @@ class Component extends Element_1.default {
3163
3189
  data = data || this.rootValue;
3164
3190
  flags = flags || {};
3165
3191
  row = row || this.data;
3192
+ if (flags.noCheck) {
3193
+ return true;
3194
+ }
3166
3195
  // Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
3167
3196
  // as setValue. Historically, this was bypassed by a series of cached states around the data model
3168
3197
  // which caused its own problems. We need to ensure that premium and custom components do not fall into
@@ -3177,9 +3206,6 @@ class Component extends Element_1.default {
3177
3206
  if (!flags.fromBlur) {
3178
3207
  this.checkRefreshOn(flags.changes, flags);
3179
3208
  }
3180
- if (flags.noCheck) {
3181
- return true;
3182
- }
3183
3209
  this.checkComponentConditions(data, flags, row);
3184
3210
  if (this.id !== flags.triggeredComponentId) {
3185
3211
  this.calculateComponentValue(data, flags, row);
@@ -558,12 +558,16 @@ class NestedComponent extends Field_1.default {
558
558
  * @param {boolean} [all] - If set to TRUE will cascade remove all components.
559
559
  */
560
560
  removeComponent(component, components, all = false) {
561
+ var _a, _b;
561
562
  components = components || this.components;
562
563
  component.destroy(all);
563
564
  lodash_1.default.remove(components, { id: component.id });
564
565
  if (this.componentsMap[component.path]) {
565
566
  delete this.componentsMap[component.path];
566
567
  }
568
+ if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.componentsMap[component.path]) {
569
+ (_b = this.root) === null || _b === void 0 ? true : delete _b.componentsMap[component.path];
570
+ }
567
571
  }
568
572
  /**
569
573
  * Removes a component provided the API key of that component.
@@ -672,7 +676,7 @@ class NestedComponent extends Field_1.default {
672
676
  validationProcessor({ scope, data, row, instance, paths }, flags) {
673
677
  var _a;
674
678
  const { dirty } = flags;
675
- if (this.root.hasExtraPages && this.page !== this.root.page) {
679
+ if (this.root && this.root.hasSubWizards && this.page !== this.root.page) {
676
680
  instance = ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(paths.dataPath))
677
681
  ? this.componentsMap[paths.dataPath]
678
682
  : this.getComponent(paths.dataPath);
@@ -821,7 +825,7 @@ class NestedComponent extends Field_1.default {
821
825
  return false;
822
826
  }
823
827
  if (component.type === 'components') {
824
- if (component.tree && component.hasValue(value)) {
828
+ if ((component.tree || component.hasInput) && component.hasValue(value)) {
825
829
  return component.setValue(lodash_1.default.get(value, component.key), flags);
826
830
  }
827
831
  return component.setValue(value, flags);
@@ -836,9 +840,6 @@ class NestedComponent extends Field_1.default {
836
840
  }
837
841
  }
838
842
  setValue(value, flags = {}) {
839
- if (!value) {
840
- return false;
841
- }
842
843
  // If the value is equal to the empty value, then this means we need to reset the values.
843
844
  if (lodash_1.default.isEqual(value, this.emptyValue)) {
844
845
  // TO-DO: For a future major release, we need to investigate removing the need for the
@@ -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) {
@@ -33,7 +33,7 @@ export default class FileComponent extends Field {
33
33
  get dataReady(): Promise<any>;
34
34
  loadImage(fileInfo: any): any;
35
35
  get emptyValue(): never[];
36
- getValueAsString(value: any): any;
36
+ getValueAsString(value: any, options: any): any;
37
37
  get defaultValue(): any[];
38
38
  get hasTypes(): any;
39
39
  _fileBrowseHidden: any;
@@ -114,7 +114,12 @@ class FileComponent extends Field_1.default {
114
114
  get emptyValue() {
115
115
  return [];
116
116
  }
117
- getValueAsString(value) {
117
+ getValueAsString(value, options) {
118
+ if ((options === null || options === void 0 ? void 0 : options.review) && !this.component.uploadOnly) {
119
+ return lodash_1.default.map(value, (val, index) => {
120
+ return `<a href="${val.url || '#'}" target="_blank" data-path='${this.path}' data-fileindex='${index}'>${val.originalName}</a>`;
121
+ }).join(', ');
122
+ }
118
123
  if (lodash_1.default.isArray(value)) {
119
124
  return lodash_1.default.map(value, 'originalName').join(', ');
120
125
  }
@@ -98,8 +98,6 @@ export default class FormComponent extends Component {
98
98
  * @returns {void}
99
99
  */
100
100
  onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
101
- areAllComponentsEmpty(data: any): boolean;
102
- conditionallyHidden(): boolean;
103
101
  updateSubFormVisibility(): void;
104
102
  /**
105
103
  * Determines if this form is a Nested Wizard