@formio/js 5.0.0-dev.5932.9b8cb6d → 5.0.0-dev.5933.3445318

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 (85) hide show
  1. package/Changelog.md +302 -10
  2. package/README.md +28 -1
  3. package/dist/formio.form.js +585 -595
  4. package/dist/formio.form.min.js +1 -1
  5. package/dist/formio.form.min.js.LICENSE.txt +2 -4
  6. package/dist/formio.full.js +586 -596
  7. package/dist/formio.full.min.js +1 -1
  8. package/dist/formio.full.min.js.LICENSE.txt +2 -4
  9. package/dist/formio.js +3006 -287
  10. package/dist/formio.min.js +1 -1
  11. package/dist/formio.min.js.LICENSE.txt +13 -1
  12. package/dist/formio.utils.js +41 -51
  13. package/dist/formio.utils.min.js +1 -1
  14. package/dist/formio.utils.min.js.LICENSE.txt +2 -4
  15. package/lib/cjs/Webform.d.ts +1 -1
  16. package/lib/cjs/Webform.js +27 -28
  17. package/lib/cjs/WebformBuilder.js +6 -13
  18. package/lib/cjs/Wizard.js +15 -20
  19. package/lib/cjs/components/Components.d.ts +0 -7
  20. package/lib/cjs/components/Components.js +1 -33
  21. package/lib/cjs/components/_classes/component/Component.d.ts +39 -7
  22. package/lib/cjs/components/_classes/component/Component.js +97 -29
  23. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
  24. package/lib/cjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  25. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
  26. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  27. package/lib/cjs/components/_classes/nested/NestedComponent.js +54 -60
  28. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  29. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +9 -46
  30. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
  31. package/lib/cjs/components/datagrid/DataGrid.js +5 -46
  32. package/lib/cjs/components/datamap/DataMap.js +2 -3
  33. package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
  34. package/lib/cjs/components/editgrid/EditGrid.js +20 -15
  35. package/lib/cjs/components/form/Form.d.ts +2 -3
  36. package/lib/cjs/components/form/Form.js +26 -28
  37. package/lib/cjs/components/html/HTML.js +15 -3
  38. package/lib/cjs/components/number/Number.js +11 -4
  39. package/lib/cjs/components/selectboxes/SelectBoxes.js +0 -1
  40. package/lib/cjs/formio.form.js +1 -0
  41. package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  42. package/lib/cjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  43. package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  44. package/lib/cjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  45. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
  46. package/lib/cjs/utils/formUtils.d.ts +25 -14
  47. package/lib/cjs/utils/formUtils.js +11 -16
  48. package/lib/cjs/utils/utils.d.ts +1 -2
  49. package/lib/cjs/utils/utils.js +15 -31
  50. package/lib/mjs/Webform.d.ts +1 -1
  51. package/lib/mjs/Webform.js +24 -27
  52. package/lib/mjs/WebformBuilder.js +6 -13
  53. package/lib/mjs/Wizard.js +13 -17
  54. package/lib/mjs/components/Components.d.ts +0 -7
  55. package/lib/mjs/components/Components.js +1 -32
  56. package/lib/mjs/components/_classes/component/Component.d.ts +39 -7
  57. package/lib/mjs/components/_classes/component/Component.js +99 -30
  58. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
  59. package/lib/mjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  60. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
  61. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  62. package/lib/mjs/components/_classes/nested/NestedComponent.js +55 -61
  63. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  64. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +8 -43
  65. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
  66. package/lib/mjs/components/datagrid/DataGrid.js +5 -46
  67. package/lib/mjs/components/datamap/DataMap.js +2 -3
  68. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
  69. package/lib/mjs/components/editgrid/EditGrid.js +22 -14
  70. package/lib/mjs/components/form/Form.d.ts +2 -3
  71. package/lib/mjs/components/form/Form.js +26 -28
  72. package/lib/mjs/components/html/HTML.js +15 -3
  73. package/lib/mjs/components/number/Number.js +11 -4
  74. package/lib/mjs/components/selectboxes/SelectBoxes.js +0 -1
  75. package/lib/mjs/formio.form.js +1 -0
  76. package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  77. package/lib/mjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  78. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  79. package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  80. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
  81. package/lib/mjs/utils/formUtils.d.ts +25 -14
  82. package/lib/mjs/utils/formUtils.js +2 -12
  83. package/lib/mjs/utils/utils.d.ts +1 -2
  84. package/lib/mjs/utils/utils.js +14 -29
  85. package/package.json +4 -4
@@ -4,7 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
- const utils_1 = require("../../../utils/utils");
7
+ const utils_1 = require("@formio/core/utils");
8
+ const { getComponentPaths } = utils_1.Utils;
9
+ const utils_2 = require("../../../utils/utils");
8
10
  const Component_1 = __importDefault(require("../component/Component"));
9
11
  const NestedDataComponent_1 = __importDefault(require("../nesteddata/NestedDataComponent"));
10
12
  class NestedArrayComponent extends NestedDataComponent_1.default {
@@ -14,7 +16,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
14
16
  }, ...extend);
15
17
  }
16
18
  static savedValueTypes() {
17
- return [utils_1.componentValueTypes.array];
19
+ return [utils_2.componentValueTypes.array];
18
20
  }
19
21
  componentContext(component) {
20
22
  return this.iteratableRows[component.rowIndex].data;
@@ -23,9 +25,11 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
23
25
  throw new Error('Getter #iteratableRows() is not implemented');
24
26
  }
25
27
  get rowIndex() {
26
- return super.rowIndex;
28
+ return this._rowIndex;
27
29
  }
28
30
  set rowIndex(value) {
31
+ var _a, _b;
32
+ this.paths = getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths) || {})), { dataIndex: value }));
29
33
  this._rowIndex = value;
30
34
  }
31
35
  init() {
@@ -88,47 +92,6 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
88
92
  value: this.dataValue,
89
93
  }, 'show'));
90
94
  }
91
- getComponent(path, fn, originalPath) {
92
- originalPath = originalPath || (0, utils_1.getStringFromComponentPath)(path);
93
- if (this.componentsMap.hasOwnProperty(originalPath)) {
94
- if (fn) {
95
- return fn(this.componentsMap[originalPath]);
96
- }
97
- else {
98
- return this.componentsMap[originalPath];
99
- }
100
- }
101
- path = Array.isArray(path) ? path : [path];
102
- let key = path.shift();
103
- const remainingPath = path;
104
- let result = [];
105
- let possibleComp = null;
106
- let comp = null;
107
- let rowIndex = null;
108
- if (lodash_1.default.isNumber(key)) {
109
- rowIndex = key;
110
- key = remainingPath.shift();
111
- }
112
- if (!lodash_1.default.isString(key)) {
113
- return result;
114
- }
115
- this.everyComponent((component, components) => {
116
- if (component.component.key === key) {
117
- possibleComp = component;
118
- if (remainingPath.length > 0 && 'getComponent' in component) {
119
- comp = component.getComponent(remainingPath, fn, originalPath);
120
- }
121
- else if (fn) {
122
- fn(component, components);
123
- }
124
- result = rowIndex !== null ? comp : result.concat(comp || possibleComp);
125
- }
126
- }, rowIndex);
127
- if ((!result || result.length === 0) && possibleComp) {
128
- result = rowIndex !== null ? possibleComp : [possibleComp];
129
- }
130
- return result;
131
- }
132
95
  everyComponent(fn, rowIndex, options = {}) {
133
96
  if (lodash_1.default.isObject(rowIndex)) {
134
97
  options = rowIndex;
@@ -163,7 +126,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
163
126
  if (component.isInputComponent) {
164
127
  row += getHeaderCell(component);
165
128
  }
166
- else if ((0, utils_1.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
129
+ else if ((0, utils_2.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
167
130
  component.everyComponent((comp) => {
168
131
  row += getHeaderCell(comp);
169
132
  }, options);
@@ -185,7 +148,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
185
148
  if (component.isInputComponent) {
186
149
  row += getBodyCell(component);
187
150
  }
188
- else if ((0, utils_1.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
151
+ else if ((0, utils_2.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
189
152
  component.everyComponent((comp) => {
190
153
  row += getBodyCell(comp);
191
154
  }, options);
@@ -87,7 +87,6 @@ export default class DataGridComponent extends NestedArrayComponent {
87
87
  show: boolean;
88
88
  };
89
89
  checkComponentConditions(data: any, flags: any, row: any): boolean;
90
- getComponent(path: any, fn: any): any;
91
90
  toggleGroup(element: any, index: any): void;
92
91
  }
93
92
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
8
8
  const utils_1 = require("../../utils/utils");
9
- const Components_1 = __importDefault(require("../Components"));
10
9
  class DataGridComponent extends NestedArrayComponent_1.default {
11
10
  static schema(...extend) {
12
11
  return NestedArrayComponent_1.default.schema({
@@ -412,7 +411,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
412
411
  row
413
412
  });
414
413
  this.checkConditions();
415
- this.triggerChange();
414
+ this.triggerChange({ modified: true });
416
415
  this.redraw().then(() => {
417
416
  this.focusOnNewRowElement(this.rows[index]);
418
417
  });
@@ -426,7 +425,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
426
425
  }
427
426
  component.rowIndex = rowIndex;
428
427
  component.row = `${rowIndex}-${colIndex}`;
429
- component.path = Components_1.default.getComponentPath(component);
430
428
  });
431
429
  }
432
430
  updateRowsComponents(rowIndex) {
@@ -492,6 +490,10 @@ class DataGridComponent extends NestedArrayComponent_1.default {
492
490
  const options = lodash_1.default.clone(this.options);
493
491
  options.name += `[${rowIndex}]`;
494
492
  options.row = `${rowIndex}-${colIndex}`;
493
+ options.rowIndex = rowIndex;
494
+ options.onChange = (flags, changed, modified) => {
495
+ this.triggerChange({ modified });
496
+ };
495
497
  let columnComponent;
496
498
  if (this.builderMode) {
497
499
  col.id = col.id + rowIndex;
@@ -614,49 +616,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
614
616
  restoreComponentsContext() {
615
617
  this.rows.forEach((row, index) => lodash_1.default.forIn(row, (component) => component.data = this.dataValue[index]));
616
618
  }
617
- getComponent(path, fn) {
618
- path = Array.isArray(path) ? path : [path];
619
- const [key, ...remainingPath] = path;
620
- let result = [];
621
- if (lodash_1.default.isNumber(key) && remainingPath.length) {
622
- const compKey = remainingPath.pop();
623
- result = this.rows[key][compKey];
624
- // If the component is inside a Layout Component, try to find it among all the row's components
625
- if (!result) {
626
- Object.entries(this.rows[key]).forEach(([, comp]) => {
627
- if ('getComponent' in comp) {
628
- const possibleResult = comp.getComponent([compKey], fn);
629
- if (possibleResult) {
630
- result = possibleResult;
631
- }
632
- }
633
- });
634
- }
635
- if (result && lodash_1.default.isFunction(fn)) {
636
- fn(result, this.getComponents());
637
- }
638
- if (remainingPath.length && 'getComponent' in result) {
639
- return result.getComponent(remainingPath, fn);
640
- }
641
- return result;
642
- }
643
- if (!lodash_1.default.isString(key)) {
644
- return result;
645
- }
646
- this.everyComponent((component, components) => {
647
- if (component.component.key === key) {
648
- let comp = component;
649
- if (remainingPath.length > 0 && 'getComponent' in component) {
650
- comp = component.getComponent(remainingPath, fn);
651
- }
652
- else if (fn) {
653
- fn(component, components);
654
- }
655
- result = result.concat(comp);
656
- }
657
- });
658
- return result.length > 0 ? result : null;
659
- }
660
619
  toggleGroup(element, index) {
661
620
  element.classList.toggle('collapsed');
662
621
  lodash_1.default.each(this.refs.chunks[index], row => {
@@ -8,7 +8,6 @@ const DataGrid_1 = __importDefault(require("../datagrid/DataGrid"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const eventemitter3_1 = __importDefault(require("eventemitter3"));
10
10
  const utils_1 = require("../../utils/utils");
11
- const Components_1 = __importDefault(require("../Components"));
12
11
  class DataMapComponent extends DataGrid_1.default {
13
12
  static schema(...extend) {
14
13
  return Component_1.default.schema({
@@ -75,7 +74,7 @@ class DataMapComponent extends DataGrid_1.default {
75
74
  }
76
75
  get dataValue() {
77
76
  if (!this.key ||
78
- (!this.visible && this.component.clearOnHide)) {
77
+ (this.conditionallyHidden && this.component.clearOnHide)) {
79
78
  return this.emptyValue;
80
79
  }
81
80
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -232,6 +231,7 @@ class DataMapComponent extends DataGrid_1.default {
232
231
  options.events = new eventemitter3_1.default();
233
232
  options.name += `[${rowIndex}]`;
234
233
  options.row = `${rowIndex}`;
234
+ options.rowIndex = rowIndex;
235
235
  const components = {};
236
236
  components['__key'] = this.createComponent(this.keySchema, options, { __key: this.builderMode ? this.defaultRowKey : key });
237
237
  components['__key'].on('componentChange', (event) => {
@@ -241,7 +241,6 @@ class DataMapComponent extends DataGrid_1.default {
241
241
  delete dataValue[key];
242
242
  const comp = components[this.valueKey];
243
243
  comp.component.key = newKey;
244
- comp.path = Components_1.default.getComponentPath(comp);
245
244
  key = newKey;
246
245
  });
247
246
  const valueComponent = lodash_1.default.clone(this.component.valueComponent);
@@ -43,7 +43,7 @@ export default class EditGridComponent extends NestedArrayComponent {
43
43
  get defaultValue(): any[];
44
44
  hasRemoveButtons(): boolean;
45
45
  editRows: any;
46
- checkRowVariableTypeComponents(editRow: any, rowIndex: any): void;
46
+ checkRowVariableTypeComponents(editRow: any, rowIndex: any): boolean;
47
47
  setVariableTypeComponents(): void;
48
48
  variableTypeComponentsIndexes: any[] | undefined;
49
49
  isOpen(editRow: any): boolean;
@@ -294,12 +294,15 @@ class EditGridComponent extends NestedArrayComponent_1.default {
294
294
  }
295
295
  checkRowVariableTypeComponents(editRow, rowIndex) {
296
296
  const rowComponents = editRow.components;
297
+ let typeChanged = false;
297
298
  if (lodash_1.default.some(this.variableTypeComponentsIndexes, (compIndex) => {
298
299
  const variableTypeComp = rowComponents[compIndex];
299
300
  return variableTypeComp.type !== variableTypeComp.component.type;
300
301
  })) {
301
302
  editRow.components = this.createRowComponents(editRow.data, rowIndex, true);
303
+ typeChanged = true;
302
304
  }
305
+ return typeChanged;
303
306
  }
304
307
  setVariableTypeComponents() {
305
308
  //set components which type is changing within a row (e.g.,by mergeComponentSchema action)
@@ -934,6 +937,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
934
937
  const options = lodash_1.default.clone(this.options);
935
938
  options.name += `[${rowIndex}]`;
936
939
  options.row = `${rowIndex}-${colIndex}`;
940
+ options.rowIndex = rowIndex;
937
941
  options.onChange = (flags = {}, changed, modified) => {
938
942
  var _a, _b;
939
943
  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)) {
@@ -948,11 +952,13 @@ class EditGridComponent extends NestedArrayComponent_1.default {
948
952
  const editRow = this.editRows[rowIndex];
949
953
  if (editRow) {
950
954
  this.processRow('checkData', null, Object.assign(Object.assign({}, flags), { changed }), editRow.data, editRow.components);
951
- this.validateRow(editRow, false);
955
+ this.validateRow(editRow, false, false);
952
956
  }
953
957
  if (this.variableTypeComponentsIndexes.length) {
954
- this.checkRowVariableTypeComponents(editRow, rowIndex);
955
- this.redraw();
958
+ const typeChanged = this.checkRowVariableTypeComponents(editRow, rowIndex);
959
+ if (typeChanged) {
960
+ this.redraw();
961
+ }
956
962
  }
957
963
  };
958
964
  const comp = this.createComponent(lodash_1.default.assign({}, column, { row: options.row }), options, row, null, recreatePartially && currentRowComponents ? currentRowComponents[colIndex] : null);
@@ -987,25 +993,24 @@ class EditGridComponent extends NestedArrayComponent_1.default {
987
993
  dirty;
988
994
  }
989
995
  validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
990
- var _a;
996
+ var _a, _b;
991
997
  editRow.errors = [];
992
998
  if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
993
- const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
999
+ const silentCheck = forceSilentCheck === false ? false : ((this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck);
994
1000
  const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);
995
1001
  const editGridValue = lodash_1.default.get(rootValue, this.path, []);
996
1002
  editGridValue[editRow.rowIndex] = editRow.data;
997
1003
  lodash_1.default.set(rootValue, this.path, editGridValue);
998
1004
  const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
999
1005
  const errors = (0, process_1.processSync)({
1000
- components: (0, utils_1.fastCloneDeep)(this.component.components).map((component) => {
1001
- component.parentPath = `${this.path}[${editRow.rowIndex}]`;
1002
- return component;
1003
- }),
1006
+ components: this.component.components,
1004
1007
  data: rootValue,
1005
1008
  row: editRow.data,
1006
1009
  process: 'validateRow',
1007
1010
  instances: this.componentsMap,
1008
1011
  scope: { errors: [] },
1012
+ parent: this.component,
1013
+ parentPaths: Object.assign(Object.assign({}, this.paths), { dataIndex: editRow.rowIndex }),
1009
1014
  processors: [
1010
1015
  {
1011
1016
  process: validationProcessorProcess,
@@ -1037,9 +1042,12 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1037
1042
  });
1038
1043
  }
1039
1044
  }
1040
- if (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted)) {
1045
+ if (editRow.alerts && (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted))) {
1041
1046
  this.showRowErrorAlerts(editRow, editRow.errors);
1042
1047
  }
1048
+ else if ((_b = editRow.errors) === null || _b === void 0 ? void 0 : _b.length) {
1049
+ this.setCustomValidity(editRow.errors, dirty);
1050
+ }
1043
1051
  return editRow.errors;
1044
1052
  }
1045
1053
  showRowErrorAlerts(editRow, errors) {
@@ -1151,7 +1159,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1151
1159
  }
1152
1160
  }
1153
1161
  const changed = this.hasChanged(value, this.dataValue);
1154
- if (this.parent && !this.options.server) {
1162
+ if (this.parent) {
1155
1163
  this.parent.checkComponentConditions();
1156
1164
  }
1157
1165
  this.dataValue = value;
@@ -1184,10 +1192,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1184
1192
  this.editRows = this.editRows.slice(0, dataLength);
1185
1193
  this.openWhenEmpty();
1186
1194
  this.updateOnChange(flags, changed);
1187
- // do not call checkData with server option, it is called when change is triggered in updateOnChange
1188
- if (!this.options.server) {
1189
- this.checkData();
1190
- }
1195
+ this.checkData();
1191
1196
  this.changeState(changed, flags);
1192
1197
  return changed;
1193
1198
  }
@@ -21,7 +21,7 @@ export default class FormComponent extends Component {
21
21
  get useOriginalRevision(): any;
22
22
  setFormRevision(rev: any): void;
23
23
  subFormRevision: any;
24
- getComponent(path: any, fn: any): any;
24
+ getComponent(path: any): any;
25
25
  getSubOptions(options?: {}): {};
26
26
  render(): string;
27
27
  asString(value: any): any;
@@ -32,6 +32,7 @@ export default class FormComponent extends Component {
32
32
  attach(element: any): Promise<void>;
33
33
  get hasLoadedForm(): any;
34
34
  get isRevisionChanged(): any;
35
+ get subFormData(): any;
35
36
  subFormReady: Promise<any> | null | undefined;
36
37
  /**
37
38
  * Pass everyComponent to subform.
@@ -55,8 +56,6 @@ export default class FormComponent extends Component {
55
56
  */
56
57
  loadSubForm(fromAttach: boolean): Promise<any>;
57
58
  subFormLoading: boolean | undefined;
58
- get subFormData(): any;
59
- checkComponentValidity(data: any, dirty: any, row: any, options: any, errors?: any[]): any;
60
59
  checkComponentConditions(data: any, flags: any, row: any): any;
61
60
  calculateValue(data: any, flags: any, row: any): any;
62
61
  setPristine(pristine: any): void;
@@ -133,21 +133,19 @@ class FormComponent extends Component_1.default {
133
133
  this.subFormRevision = undefined;
134
134
  }
135
135
  }
136
- getComponent(path, fn) {
137
- path = (0, utils_1.getArrayFromComponentPath)(path);
138
- if (path[0] === 'data') {
139
- path.shift();
140
- }
141
- const originalPathStr = `${this.path}.data.${(0, utils_1.getStringFromComponentPath)(path)}`;
142
- if (this.subForm) {
143
- return this.subForm.getComponent(path, fn, originalPathStr);
136
+ getComponent(path) {
137
+ if (!this.subForm) {
138
+ return null;
144
139
  }
140
+ return this.subForm.getComponent(path);
145
141
  }
146
142
  /* eslint-disable max-statements */
147
143
  getSubOptions(options = {}) {
148
144
  options.events = this.createEmitter();
149
145
  // Make sure to not show the submit button in wizards in the nested forms.
150
146
  lodash_1.default.set(options, 'buttonSettings.showSubmit', false);
147
+ // Set the parent option to the subform so those references are stable when the subform is created
148
+ options.parent = this;
151
149
  if (!this.options) {
152
150
  return options;
153
151
  }
@@ -209,6 +207,7 @@ class FormComponent extends Component_1.default {
209
207
  if (this.options.skipDraftRestore) {
210
208
  options.skipDraftRestore = this.options.skipDraftRestore;
211
209
  }
210
+ options.parent = this;
212
211
  return options;
213
212
  }
214
213
  /* eslint-enable max-statements */
@@ -297,6 +296,7 @@ class FormComponent extends Component_1.default {
297
296
  const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
298
297
  const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
299
298
  this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
299
+ this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
300
300
  this.setOpenModalElement();
301
301
  }
302
302
  this.calculateValue();
@@ -332,6 +332,10 @@ class FormComponent extends Component_1.default {
332
332
  && lodash_1.default.isNumber(this.formObj._vid)
333
333
  && this.formObj._vid !== this.subFormRevision;
334
334
  }
335
+ get subFormData() {
336
+ var _a;
337
+ return ((_a = this.dataValue) === null || _a === void 0 ? void 0 : _a.data) || {};
338
+ }
335
339
  destroy(all = false) {
336
340
  if (this.subForm) {
337
341
  this.subForm.destroy(all);
@@ -395,8 +399,11 @@ class FormComponent extends Component_1.default {
395
399
  return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
396
400
  this.subForm = instance;
397
401
  this.subForm.currentForm = this;
398
- this.subForm.parent = this;
399
402
  this.subForm.parentVisible = this.visible;
403
+ const componentsMap = this.componentsMap;
404
+ const formComponentsMap = this.subForm.componentsMap;
405
+ lodash_1.default.assign(componentsMap, formComponentsMap);
406
+ this.component.components = this.subForm.components.map((comp) => comp.component);
400
407
  this.subForm.on('change', () => {
401
408
  if (this.subForm) {
402
409
  this.dataValue = this.subForm.getValue();
@@ -413,6 +420,8 @@ class FormComponent extends Component_1.default {
413
420
  this.valueChanged = this.hasSetValue;
414
421
  this.onChange();
415
422
  return this.subForm;
423
+ }).catch((err) => {
424
+ console.log(err);
416
425
  });
417
426
  }).then((subForm) => {
418
427
  this.updateSubWizards(subForm);
@@ -421,10 +430,11 @@ class FormComponent extends Component_1.default {
421
430
  return this.subFormReady;
422
431
  }
423
432
  hideSubmitButton(component) {
424
- const isSubmitButton = (component.type === 'button') &&
425
- ((component.action === 'submit') || !component.action);
433
+ const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
426
434
  if (isSubmitButton) {
427
435
  component.hidden = true;
436
+ // clearOnHide no longer clears from the JSON `hidden` flag, so we make the button conditionally hidden to clear its data
437
+ component.customConditional = 'show = false';
428
438
  }
429
439
  }
430
440
  /**
@@ -434,7 +444,7 @@ class FormComponent extends Component_1.default {
434
444
  */
435
445
  loadSubForm(fromAttach) {
436
446
  var _a, _b, _c, _d, _e;
437
- if (this.builderMode || this.isHidden() || (this.isSubFormLazyLoad() && !fromAttach)) {
447
+ if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
438
448
  return Promise.resolve();
439
449
  }
440
450
  if (this.hasLoadedForm && !this.isRevisionChanged &&
@@ -469,18 +479,6 @@ class FormComponent extends Component_1.default {
469
479
  }
470
480
  return Promise.resolve();
471
481
  }
472
- get subFormData() {
473
- var _a;
474
- return ((_a = this.dataValue) === null || _a === void 0 ? void 0 : _a.data) || {};
475
- }
476
- checkComponentValidity(data, dirty, row, options, errors = []) {
477
- options = options || {};
478
- const silentCheck = options.silentCheck || false;
479
- if (this.subForm) {
480
- return this.subForm.checkValidity(this.subFormData, dirty, null, silentCheck, errors);
481
- }
482
- return super.checkComponentValidity(data, dirty, row, options, errors);
483
- }
484
482
  checkComponentConditions(data, flags, row) {
485
483
  const visible = super.checkComponentConditions(data, flags, row);
486
484
  // Return if already hidden
@@ -488,14 +486,14 @@ class FormComponent extends Component_1.default {
488
486
  return visible;
489
487
  }
490
488
  if (this.subForm) {
491
- return this.subForm.checkConditions(this.subFormData);
489
+ return this.subForm.checkConditions(this.subFormData, flags);
492
490
  }
493
491
  // There are few cases when subForm is not loaded when a change is triggered,
494
492
  // so we need to perform checkConditions after it is ready, or some conditional fields might be hidden in View mode
495
493
  else if (this.subFormReady) {
496
494
  this.subFormReady.then(() => {
497
495
  if (this.subForm) {
498
- return this.subForm.checkConditions(this.subFormData);
496
+ return this.subForm.checkConditions(this.subFormData, flags);
499
497
  }
500
498
  });
501
499
  }
@@ -518,7 +516,7 @@ class FormComponent extends Component_1.default {
518
516
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
519
517
  */
520
518
  get shouldSubmit() {
521
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.isHidden();
519
+ return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
522
520
  }
523
521
  /**
524
522
  * Returns the data for the subform.
@@ -545,7 +543,7 @@ class FormComponent extends Component_1.default {
545
543
  }
546
544
  this.subForm.nosubmit = false;
547
545
  this.subForm.submitted = true;
548
- return this.subForm.submitForm().then(result => {
546
+ return this.subForm.submitForm({}, true).then(result => {
549
547
  this.subForm.loading = false;
550
548
  this.subForm.showAllErrors = false;
551
549
  this.dataValue = result.submission;
@@ -56,9 +56,21 @@ class HTMLComponent extends Component_1.default {
56
56
  }
57
57
  checkRefreshOn(changed) {
58
58
  super.checkRefreshOn(changed);
59
- if (!this.builderMode && this.component.refreshOnChange && this.element &&
60
- !lodash_1.default.isUndefined(changed) && ((lodash_1.default.isBoolean(changed) && changed) || !lodash_1.default.isEmpty(changed)) &&
61
- this.conditionallyVisible(this.data, this.row)) {
59
+ let visible;
60
+ if (this.hasCondition()) {
61
+ this._conditionallyHidden = this.checkConditionallyHidden();
62
+ visible = !this.conditionallyHidden;
63
+ }
64
+ else {
65
+ visible = !this.component.hidden;
66
+ }
67
+ const shouldSetContent = !this.builderMode
68
+ && this.component.refreshOnChange
69
+ && this.element
70
+ && !lodash_1.default.isUndefined(changed)
71
+ && ((lodash_1.default.isBoolean(changed) && changed) || !lodash_1.default.isEmpty(changed))
72
+ && visible;
73
+ if (shouldSetContent) {
62
74
  this.setContent(this.element, this.renderContent());
63
75
  }
64
76
  }
@@ -170,14 +170,21 @@ class NumberComponent extends Input_1.default {
170
170
  if (typeof input === 'string') {
171
171
  input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
172
172
  }
173
- let value = parseFloat(input);
174
- if (!lodash_1.default.isNaN(value)) {
173
+ let value;
174
+ if (!lodash_1.default.isNaN(input)) {
175
175
  // Format scientific notation
176
- if (/e/i.test(String(value))) {
176
+ if (/[0-9]+[eE]/.test(String(input))) {
177
+ // Convert to exponential notation will depend on the decimal limit set in the component
178
+ // Example: 1.23e-5 will be converted to 1.23e-5 if decimal limit is set to 2
179
+ // Example: 1.23e5 will be converted to 1.23e+5 if decimal limit is set to 2
180
+ // if decimal limit is 3, 1.23e5 will be converted to 1.230e+5
181
+ // if decimal limit is not set, 1.23e5 will be converted to 1.23000000000000000000e+5
182
+ value = parseFloat(input);
177
183
  value = value.toExponential(this.decimalLimit);
178
184
  }
179
185
  else {
180
- value = String(value).replace('.', this.decimalSeparator);
186
+ value = parseFloat(input);
187
+ value = !lodash_1.default.isNaN(value) ? String(value).replace('.', this.decimalSeparator) : null;
181
188
  }
182
189
  }
183
190
  else {
@@ -275,7 +275,6 @@ class SelectBoxesComponent extends Radio_1.default {
275
275
  else {
276
276
  return super.setCustomValidity(messages, dirty, external);
277
277
  }
278
- ;
279
278
  }
280
279
  validateValueAvailability(setting, value) {
281
280
  if (!(0, utils_1.boolValue)(setting) || !value) {
@@ -73,6 +73,7 @@ function registerModule(mod, defaultFn = null, options = {}) {
73
73
  case 'templates':
74
74
  for (const framework of Object.keys(mod.templates)) {
75
75
  Formio_1.Formio.Templates.extendTemplate(framework, mod.templates[framework]);
76
+ Formio_1.Formio.Templates.defaultTemplates = lodash_1.default.defaults(mod.templates[framework], Formio_1.Formio.Templates.defaultTemplates);
76
77
  }
77
78
  if (mod.templates[current]) {
78
79
  Formio_1.Formio.Templates.current = mod.templates[current];
@@ -20,13 +20,13 @@ class DateGeaterThan extends ConditionOperator_1.default {
20
20
  }
21
21
  execute(options, functionName = 'isAfter') {
22
22
  var _a;
23
- const { value, instance, conditionComponentPath } = options;
23
+ const { value, instance, path } = options;
24
24
  if (!value) {
25
25
  return false;
26
26
  }
27
27
  let conditionTriggerComponent = null;
28
28
  if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
29
- conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
29
+ conditionTriggerComponent = instance.root.getComponent(path);
30
30
  }
31
31
  if (conditionTriggerComponent && conditionTriggerComponent.isPartialDay && conditionTriggerComponent.isPartialDay(value)) {
32
32
  return false;
@@ -1,8 +1,8 @@
1
1
  export default class IsEmptyValue extends ConditionOperator {
2
- execute({ value, instance, conditionComponentPath }: {
2
+ execute({ value, instance, path }: {
3
3
  value: any;
4
4
  instance: any;
5
- conditionComponentPath: any;
5
+ path: any;
6
6
  }): any;
7
7
  getResult(options: any): any;
8
8
  }
@@ -15,11 +15,11 @@ class IsEmptyValue extends ConditionOperator_1.default {
15
15
  static get requireValue() {
16
16
  return false;
17
17
  }
18
- execute({ value, instance, conditionComponentPath }) {
18
+ execute({ value, instance, path }) {
19
19
  var _a;
20
20
  const isEmptyValue = lodash_1.default.isEmpty(lodash_1.default.isNumber(value) ? String(value) : value);
21
21
  if ((_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent) {
22
- const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
22
+ const conditionTriggerComponent = instance.root.getComponent(path);
23
23
  return (conditionTriggerComponent === null || conditionTriggerComponent === void 0 ? void 0 : conditionTriggerComponent.isEmpty) ? conditionTriggerComponent.isEmpty() : isEmptyValue;
24
24
  }
25
25
  return isEmptyValue;
@@ -1,9 +1,9 @@
1
1
  export default class IsEqualTo extends ConditionOperator {
2
- execute({ value, comparedValue, instance, conditionComponentPath }: {
2
+ execute({ value, comparedValue, instance, path }: {
3
3
  value: any;
4
4
  comparedValue: any;
5
5
  instance: any;
6
- conditionComponentPath: any;
6
+ path: any;
7
7
  }): any;
8
8
  }
9
9
  import ConditionOperator from './ConditionOperator';