@formio/js 5.0.0-dev.5944.74e70b0 → 5.0.0-dev.5948.072adfa

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 (80) hide show
  1. package/Changelog.md +1 -0
  2. package/dist/formio.form.js +583 -593
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.form.min.js.LICENSE.txt +1 -3
  5. package/dist/formio.full.js +584 -594
  6. package/dist/formio.full.min.js +1 -1
  7. package/dist/formio.full.min.js.LICENSE.txt +1 -3
  8. package/dist/formio.js +3006 -287
  9. package/dist/formio.min.js +1 -1
  10. package/dist/formio.min.js.LICENSE.txt +12 -0
  11. package/dist/formio.utils.js +41 -51
  12. package/dist/formio.utils.min.js +1 -1
  13. package/dist/formio.utils.min.js.LICENSE.txt +1 -3
  14. package/lib/cjs/Webform.d.ts +1 -1
  15. package/lib/cjs/Webform.js +27 -28
  16. package/lib/cjs/WebformBuilder.js +6 -13
  17. package/lib/cjs/Wizard.js +4 -11
  18. package/lib/cjs/components/Components.d.ts +0 -7
  19. package/lib/cjs/components/Components.js +1 -33
  20. package/lib/cjs/components/_classes/component/Component.d.ts +39 -7
  21. package/lib/cjs/components/_classes/component/Component.js +97 -29
  22. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
  23. package/lib/cjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  24. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
  25. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  26. package/lib/cjs/components/_classes/nested/NestedComponent.js +54 -60
  27. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  28. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +9 -46
  29. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
  30. package/lib/cjs/components/datagrid/DataGrid.js +1 -45
  31. package/lib/cjs/components/datamap/DataMap.js +2 -3
  32. package/lib/cjs/components/editgrid/EditGrid.js +13 -13
  33. package/lib/cjs/components/form/Form.d.ts +1 -3
  34. package/lib/cjs/components/form/Form.js +21 -28
  35. package/lib/cjs/components/html/HTML.js +15 -3
  36. package/lib/cjs/components/selectboxes/SelectBoxes.js +0 -1
  37. package/lib/cjs/formio.form.js +1 -0
  38. package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  39. package/lib/cjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  40. package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  41. package/lib/cjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  42. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
  43. package/lib/cjs/utils/formUtils.d.ts +25 -14
  44. package/lib/cjs/utils/formUtils.js +11 -16
  45. package/lib/cjs/utils/utils.d.ts +1 -2
  46. package/lib/cjs/utils/utils.js +15 -31
  47. package/lib/mjs/Webform.d.ts +1 -1
  48. package/lib/mjs/Webform.js +24 -27
  49. package/lib/mjs/WebformBuilder.js +6 -13
  50. package/lib/mjs/Wizard.js +2 -8
  51. package/lib/mjs/components/Components.d.ts +0 -7
  52. package/lib/mjs/components/Components.js +1 -32
  53. package/lib/mjs/components/_classes/component/Component.d.ts +39 -7
  54. package/lib/mjs/components/_classes/component/Component.js +99 -30
  55. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
  56. package/lib/mjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
  57. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
  58. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +4 -19
  59. package/lib/mjs/components/_classes/nested/NestedComponent.js +55 -61
  60. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
  61. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +8 -43
  62. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
  63. package/lib/mjs/components/datagrid/DataGrid.js +1 -45
  64. package/lib/mjs/components/datamap/DataMap.js +2 -3
  65. package/lib/mjs/components/editgrid/EditGrid.js +15 -12
  66. package/lib/mjs/components/form/Form.d.ts +1 -3
  67. package/lib/mjs/components/form/Form.js +22 -28
  68. package/lib/mjs/components/html/HTML.js +15 -3
  69. package/lib/mjs/components/selectboxes/SelectBoxes.js +0 -1
  70. package/lib/mjs/formio.form.js +1 -0
  71. package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +2 -2
  72. package/lib/mjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
  73. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
  74. package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
  75. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
  76. package/lib/mjs/utils/formUtils.d.ts +25 -14
  77. package/lib/mjs/utils/formUtils.js +2 -12
  78. package/lib/mjs/utils/utils.d.ts +1 -2
  79. package/lib/mjs/utils/utils.js +14 -29
  80. package/package.json +4 -4
@@ -243,6 +243,7 @@ class Component extends Element_1.default {
243
243
  */
244
244
  /* eslint-disable max-statements */
245
245
  constructor(component, options, data) {
246
+ var _a, _b, _c, _d;
246
247
  super(Object.assign({
247
248
  renderMode: 'form',
248
249
  attachMode: 'full',
@@ -258,6 +259,10 @@ class Component extends Element_1.default {
258
259
  * @private
259
260
  */
260
261
  this._hasCondition = null;
262
+ /**
263
+ * The row index for this component.
264
+ */
265
+ this._rowIndex = undefined;
261
266
  /**
262
267
  * References to dom elements
263
268
  */
@@ -268,11 +273,6 @@ class Component extends Element_1.default {
268
273
  this.options.components[component.type]) {
269
274
  lodash_1.default.merge(component, this.options.components[component.type]);
270
275
  }
271
- /**
272
- * The data path to this specific component instance.
273
- * @type {string}
274
- */
275
- this.path = (component === null || component === void 0 ? void 0 : component.key) || '';
276
276
  /**
277
277
  * An array of all the children components errors.
278
278
  */
@@ -341,15 +341,27 @@ class Component extends Element_1.default {
341
341
  * @type {Component}
342
342
  */
343
343
  this.parent = this.options.parent;
344
+ /**
345
+ * The component paths for this component.
346
+ * @type {import('@formio/core').ComponentPaths} - The component paths.
347
+ */
348
+ this.paths = FormioUtils.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: this.options.rowIndex === undefined ? (_d = (_c = this.parent) === null || _c === void 0 ? void 0 : _c.paths) === null || _d === void 0 ? void 0 : _d.dataIndex : this.options.rowIndex }));
344
349
  this.options.name = this.options.name || 'data';
345
350
  this._path = '';
346
351
  // Needs for Nextgen Rules Engine
347
352
  this.resetCaches();
353
+ /**
354
+ * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
355
+ * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
356
+ * conditionallyHidden separately from "regular" visibility.
357
+ */
358
+ this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
359
+ this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
348
360
  /**
349
361
  * Determines if this component is visible, or not.
350
362
  */
351
363
  this._parentVisible = this.options.hasOwnProperty('parentVisible') ? this.options.parentVisible : true;
352
- this._visible = this._parentVisible && this.conditionallyVisible(null, data);
364
+ this._visible = this._parentVisible && (this.hasCondition() ? !this._conditionallyHidden : !this.component.hidden);
353
365
  this._parentDisabled = false;
354
366
  /**
355
367
  * The reference attribute name for this component
@@ -418,7 +430,7 @@ class Component extends Element_1.default {
418
430
  if (this.allowData && this.key) {
419
431
  this.options.name += `[${this.key}]`;
420
432
  // If component is visible or not set to clear on hide, set the default value.
421
- if (this.visible || !this.component.clearOnHide) {
433
+ if (!(this.conditionallyHidden && this.component.clearOnHide)) {
422
434
  if (!this.hasValue()) {
423
435
  if (this.shouldAddDefaultValue) {
424
436
  this.dataValue = this.defaultValue;
@@ -447,12 +459,7 @@ class Component extends Element_1.default {
447
459
  /* eslint-enable max-statements */
448
460
  get componentsMap() {
449
461
  var _a;
450
- if ((_a = this.localRoot) === null || _a === void 0 ? void 0 : _a.childComponentsMap) {
451
- return this.localRoot.childComponentsMap;
452
- }
453
- const localMap = {};
454
- localMap[this.path] = this;
455
- return localMap;
462
+ return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
456
463
  }
457
464
  get data() {
458
465
  return this._data;
@@ -494,11 +501,29 @@ class Component extends Element_1.default {
494
501
  init() {
495
502
  var _a;
496
503
  this.disabled = this.shouldDisabled;
497
- this._visible = this.conditionallyVisible(null, null);
504
+ this._conditionallyHidden = this.checkConditionallyHidden();
505
+ this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
498
506
  if ((_a = this.component.addons) === null || _a === void 0 ? void 0 : _a.length) {
499
507
  this.component.addons.forEach((addon) => this.createAddon(addon));
500
508
  }
501
509
  }
510
+ /**
511
+ * Get Row Index.
512
+ * @returns {number} - The row index.
513
+ */
514
+ get rowIndex() {
515
+ return this._rowIndex;
516
+ }
517
+ /**
518
+ * Set Row Index to row and update each component.
519
+ * @param {number} value - The row index.
520
+ * @returns {void}
521
+ */
522
+ set rowIndex(value) {
523
+ var _a, _b;
524
+ this.paths = FormioUtils.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 }));
525
+ this._rowIndex = value;
526
+ }
502
527
  afterComponentAssign() {
503
528
  //implement in extended classes
504
529
  }
@@ -568,6 +593,12 @@ class Component extends Element_1.default {
568
593
  get key() {
569
594
  return lodash_1.default.get(this.component, 'key', '');
570
595
  }
596
+ get path() {
597
+ return this.paths.dataPath;
598
+ }
599
+ set path(path) {
600
+ throw new Error('Should not be setting the path of a component.');
601
+ }
571
602
  set parentVisible(value) {
572
603
  this._parentVisible = value;
573
604
  }
@@ -613,7 +644,6 @@ class Component extends Element_1.default {
613
644
  return;
614
645
  }
615
646
  this._visible = value;
616
- this.clearOnHide();
617
647
  this.redraw();
618
648
  }
619
649
  }
@@ -634,6 +664,21 @@ class Component extends Element_1.default {
634
664
  }
635
665
  return this._visible && this._parentVisible;
636
666
  }
667
+ get conditionallyHidden() {
668
+ return this._conditionallyHidden || this._parentConditionallyHidden;
669
+ }
670
+ /**
671
+ * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
672
+ * @param {object} data - The data object to evaluate the condition against.
673
+ * @param {object} row - The row object to evaluate the condition against.
674
+ * @returns {boolean} - Whether the component is conditionally hidden.
675
+ */
676
+ checkConditionallyHidden(data = null, row = null) {
677
+ if (!this.hasCondition()) {
678
+ return false;
679
+ }
680
+ return !this.conditionallyVisible(data, row);
681
+ }
637
682
  get currentForm() {
638
683
  return this._currentForm;
639
684
  }
@@ -1274,6 +1319,7 @@ class Component extends Element_1.default {
1274
1319
  * @returns {void}
1275
1320
  */
1276
1321
  checkRefresh(refreshData, changed, flags) {
1322
+ var _a, _b;
1277
1323
  const changePath = lodash_1.default.get(changed, 'instance.path', false);
1278
1324
  // Don't let components change themselves.
1279
1325
  if (changePath && this.path === changePath) {
@@ -1282,7 +1328,7 @@ class Component extends Element_1.default {
1282
1328
  if (refreshData === 'data') {
1283
1329
  this.refresh(this.data, changed, flags);
1284
1330
  }
1285
- else if ((changePath && (0, utils_1.getComponentPath)(changed.instance) === refreshData) && changed && changed.instance &&
1331
+ else if ((changePath && (((_b = (_a = changed.instance) === null || _a === void 0 ? void 0 : _a.paths) === null || _b === void 0 ? void 0 : _b.localPath) === refreshData)) && changed && changed.instance &&
1286
1332
  // Make sure the changed component is not in a different "context". Solves issues where refreshOn being set
1287
1333
  // in fields inside EditGrids could alter their state from other rows (which is bad).
1288
1334
  this.inContext(changed.instance)) {
@@ -1801,7 +1847,7 @@ class Component extends Element_1.default {
1801
1847
  rebuild() {
1802
1848
  this.destroy();
1803
1849
  this.init();
1804
- this.visible = this.conditionallyVisible(null, null);
1850
+ this.visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
1805
1851
  return this.redraw();
1806
1852
  }
1807
1853
  /**
@@ -1868,8 +1914,8 @@ class Component extends Element_1.default {
1868
1914
  conditionallyVisible(data, row) {
1869
1915
  data = data || this.rootValue;
1870
1916
  row = row || this.data;
1871
- if (this.builderMode || this.previewMode || !this.hasCondition()) {
1872
- return !this.component.hidden;
1917
+ if (this.builderMode || this.previewMode) {
1918
+ return true;
1873
1919
  }
1874
1920
  data = data || (this.root ? this.root.data : {});
1875
1921
  return this.checkCondition(row, data);
@@ -1899,8 +1945,14 @@ class Component extends Element_1.default {
1899
1945
  if (!this.builderMode & !this.previewMode && this.fieldLogic(data, row)) {
1900
1946
  this.redraw();
1901
1947
  }
1902
- // Check advanced conditions
1903
- const visible = this.conditionallyVisible(data, row);
1948
+ // Check advanced conditions (and cache the result)
1949
+ const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1950
+ if (isConditionallyHidden !== this._conditionallyHidden) {
1951
+ this._conditionallyHidden = isConditionallyHidden;
1952
+ this.clearOnHide();
1953
+ }
1954
+ // Check visibility
1955
+ const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1904
1956
  if (this.visible !== visible) {
1905
1957
  this.visible = visible;
1906
1958
  }
@@ -2010,6 +2062,12 @@ class Component extends Element_1.default {
2010
2062
  FormioUtils.setActionProperty(newComponent, action, result, row, data, this);
2011
2063
  const property = action.property.value;
2012
2064
  if (!lodash_1.default.isEqual(lodash_1.default.get(this.component, property), lodash_1.default.get(newComponent, property))) {
2065
+ // Advanced Logic can modify the component's hidden property; because we track conditionally hidden state
2066
+ // separately from the component's hidden property, and technically this Advanced Logic conditionally hides
2067
+ // a component, we need to set _conditionallyHidden to the new value
2068
+ if (property === 'hidden') {
2069
+ this._conditionallyHidden = newComponent.hidden;
2070
+ }
2013
2071
  changed = true;
2014
2072
  }
2015
2073
  break;
@@ -2023,7 +2081,7 @@ class Component extends Element_1.default {
2023
2081
  component: newComponent,
2024
2082
  result,
2025
2083
  });
2026
- if (!lodash_1.default.isEqual(oldValue, newValue) && !(this.component.clearOnHide && !this.visible)) {
2084
+ if (!lodash_1.default.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
2027
2085
  this.setValue(newValue);
2028
2086
  if (this.viewOnly) {
2029
2087
  this.dataValue = newValue;
@@ -2056,7 +2114,7 @@ class Component extends Element_1.default {
2056
2114
  component: newComponent,
2057
2115
  result,
2058
2116
  }, 'value');
2059
- if (!lodash_1.default.isEqual(oldValue, newValue) && !(this.component.clearOnHide && !this.visible)) {
2117
+ if (!lodash_1.default.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
2060
2118
  this.setValue(newValue);
2061
2119
  if (this.viewOnly) {
2062
2120
  this.dataValue = newValue;
@@ -2167,7 +2225,7 @@ class Component extends Element_1.default {
2167
2225
  this.component.clearOnHide !== false &&
2168
2226
  !this.options.readOnly &&
2169
2227
  !this.options.showHiddenFields) {
2170
- if (!this.visible) {
2228
+ if (this.conditionallyHidden) {
2171
2229
  this.deleteValue();
2172
2230
  }
2173
2231
  else if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2426,7 +2484,7 @@ class Component extends Element_1.default {
2426
2484
  */
2427
2485
  get dataValue() {
2428
2486
  if (!this.key ||
2429
- (!this.visible && this.component.clearOnHide && !this.rootPristine)) {
2487
+ (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2430
2488
  return this.emptyValue;
2431
2489
  }
2432
2490
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2445,7 +2503,7 @@ class Component extends Element_1.default {
2445
2503
  set dataValue(value) {
2446
2504
  if (!this.allowData ||
2447
2505
  !this.key ||
2448
- (!this.visible && this.component.clearOnHide && !this.rootPristine)) {
2506
+ (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2449
2507
  return;
2450
2508
  }
2451
2509
  if ((value !== null) && (value !== undefined)) {
@@ -2766,7 +2824,7 @@ class Component extends Element_1.default {
2766
2824
  // If no calculated value or
2767
2825
  // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
2768
2826
  const { clearOnHide } = this.component;
2769
- const shouldBeCleared = !this.visible && clearOnHide;
2827
+ const shouldBeCleared = this.conditionallyHidden && clearOnHide;
2770
2828
  const allowOverride = lodash_1.default.get(this.component, 'allowCalculateOverride', false);
2771
2829
  if (shouldBeCleared) {
2772
2830
  // remove calculated value so that the value is recalculated once component becomes visible
@@ -2892,6 +2950,10 @@ class Component extends Element_1.default {
2892
2950
  * @returns {string} - The message to show when the component is invalid.
2893
2951
  */
2894
2952
  invalidMessage(data, dirty, ignoreCondition, row) {
2953
+ var _a;
2954
+ if (!row) {
2955
+ row = (0, utils_1.getContextualRowData)(this.component, data, this.paths);
2956
+ }
2895
2957
  if (!ignoreCondition && !this.checkCondition(row, data)) {
2896
2958
  return '';
2897
2959
  }
@@ -2909,6 +2971,8 @@ class Component extends Element_1.default {
2909
2971
  data,
2910
2972
  row,
2911
2973
  path: this.path || this.component.key,
2974
+ parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
2975
+ paths: this.paths,
2912
2976
  scope: validationScope,
2913
2977
  instance: this,
2914
2978
  processors: [
@@ -2962,7 +3026,7 @@ class Component extends Element_1.default {
2962
3026
  if (flags.silentCheck) {
2963
3027
  return [];
2964
3028
  }
2965
- let isDirty = this.dirty || flags.dirty;
3029
+ let isDirty = (flags.dirty === false) ? false : (this.dirty || flags.dirty);
2966
3030
  if (this.options.alwaysDirty) {
2967
3031
  isDirty = true;
2968
3032
  }
@@ -2977,6 +3041,7 @@ class Component extends Element_1.default {
2977
3041
  * @returns {Array<any>} - An array of errors if the component is invalid.
2978
3042
  */
2979
3043
  validateComponent(data = null, row = null, flags = {}) {
3044
+ var _a;
2980
3045
  data = data || this.rootValue;
2981
3046
  row = row || this.data;
2982
3047
  const { async = false } = flags;
@@ -2987,7 +3052,10 @@ class Component extends Element_1.default {
2987
3052
  component: this.component,
2988
3053
  data,
2989
3054
  row,
3055
+ local: !!flags.local,
2990
3056
  value: this.validationValue,
3057
+ parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
3058
+ paths: this.paths,
2991
3059
  path: this.path || this.component.key,
2992
3060
  instance: this,
2993
3061
  form: this.root ? this.root._form : {},
@@ -3406,7 +3474,7 @@ class Component extends Element_1.default {
3406
3474
  // If component definition changed, replace it.
3407
3475
  if (!lodash_1.default.isEqual(this.component, newComponent)) {
3408
3476
  this.component = newComponent;
3409
- const visible = this.conditionallyVisible(null, null);
3477
+ const visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
3410
3478
  const disabled = this.shouldDisabled;
3411
3479
  // Change states which won't be recalculated during redrawing
3412
3480
  if (this.visible !== visible) {
@@ -133,10 +133,10 @@ exports.default = [
133
133
  {
134
134
  weight: 700,
135
135
  type: 'checkbox',
136
- label: 'Clear Value When Hidden',
136
+ label: 'Omit Value From Submission Data When Conditionally Hidden',
137
137
  key: 'clearOnHide',
138
138
  defaultValue: true,
139
- tooltip: 'When a field is hidden, clear the value.',
139
+ tooltip: 'When a field is conditionally hidden, omit the value from the submission data.',
140
140
  input: true
141
141
  },
142
142
  utils_1.default.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
@@ -22,6 +22,7 @@ export default class ComponentModal {
22
22
  modalOverlay: string;
23
23
  modalContents: string;
24
24
  modalClose: string;
25
+ componentContent: string;
25
26
  openModalWrapper: string;
26
27
  openModal: string;
27
28
  modalSave: string;
@@ -64,6 +64,7 @@ class ComponentModal {
64
64
  modalOverlay: 'single',
65
65
  modalContents: 'single',
66
66
  modalClose: 'single',
67
+ componentContent: 'single',
67
68
  openModalWrapper: 'single',
68
69
  openModal: 'single',
69
70
  modalSave: 'single',
@@ -56,18 +56,6 @@ export default class NestedComponent extends Field {
56
56
  * @returns {object} - The current form object.
57
57
  */
58
58
  get currentForm(): object;
59
- /**
60
- * Set Row Index to row and update each component.
61
- * @param {number} value - The row index.
62
- * @returns {void}
63
- */
64
- set rowIndex(value: number);
65
- /**
66
- * Get Row Index.
67
- * @returns {number} - The row index.
68
- */
69
- get rowIndex(): number;
70
- _rowIndex: number | undefined;
71
59
  /**
72
60
  * Get Contextual data of the component.
73
61
  * @returns {object} - The contextual data of the component.
@@ -115,14 +103,11 @@ export default class NestedComponent extends Field {
115
103
  */
116
104
  eachComponent(fn: Function): void;
117
105
  /**
118
- * Returns a component provided a key. This performs a deep search within the
119
- * component tree.
106
+ * Returns a component provided a key. This performs a deep search within the component tree.
120
107
  * @param {string} path - The path to the component.
121
- * @param {Function} [fn] - Called with the component once found.
122
- * @param {string} [originalPath] - The original path to the component.
123
108
  * @returns {any} - The component that is located.
124
109
  */
125
- getComponent(path: string, fn?: Function | undefined, originalPath?: string | undefined): any;
110
+ getComponent(path: string): any;
126
111
  /**
127
112
  * Return a component provided the Id of the component.
128
113
  * @param {string} id - The Id of the component.
@@ -211,12 +196,12 @@ export default class NestedComponent extends Field {
211
196
  calculateValue(data: any, flags: any, row: any): any;
212
197
  isLastPage(): boolean;
213
198
  isValid(data: any, dirty: any): any;
214
- validationProcessor({ scope, data, row, instance, component }: {
199
+ validationProcessor({ scope, data, row, instance, paths }: {
215
200
  scope: any;
216
201
  data: any;
217
202
  row: any;
218
203
  instance: any;
219
- component: any;
204
+ paths: any;
220
205
  }, flags: any): void;
221
206
  /**
222
207
  * Perform a validation on all child components of this nested component.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const Field_1 = __importDefault(require("../field/Field"));
8
8
  const Components_1 = __importDefault(require("../../Components"));
9
+ '';
9
10
  const utils_1 = require("../../../utils/utils");
10
11
  const process_1 = require("@formio/core/process");
11
12
  /**
@@ -84,17 +85,26 @@ class NestedComponent extends Field_1.default {
84
85
  const visibilityChanged = this._visible !== value;
85
86
  this._visible = value;
86
87
  const isVisible = this.visible;
88
+ const isConditionallyHidden = this.checkConditionallyHidden();
87
89
  const forceShow = this.shouldForceShow();
88
90
  const forceHide = this.shouldForceHide();
89
- this.components.forEach(component => {
91
+ this.components.forEach((component) => {
90
92
  // Set the parent visibility first since we may have nested components within nested components
91
93
  // and they need to be able to determine their visibility based on the parent visibility.
92
94
  component.parentVisible = isVisible;
93
- const conditionallyVisible = component.conditionallyVisible();
94
- if (forceShow || conditionallyVisible) {
95
+ component._parentConditionallyHidden = isConditionallyHidden;
96
+ let visible;
97
+ if (component.hasCondition()) {
98
+ component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
99
+ visible = !component.conditionallyHidden;
100
+ }
101
+ else {
102
+ visible = !component.component.hidden;
103
+ }
104
+ if (forceShow || visible) {
95
105
  component.visible = true;
96
106
  }
97
- else if (forceHide || !isVisible || !conditionallyVisible) {
107
+ else if (forceHide || !isVisible || !visible) {
98
108
  component.visible = false;
99
109
  }
100
110
  // If hiding a nested component, clear all errors below.
@@ -103,7 +113,6 @@ class NestedComponent extends Field_1.default {
103
113
  }
104
114
  });
105
115
  if (visibilityChanged) {
106
- this.clearOnHide();
107
116
  this.redraw();
108
117
  }
109
118
  }
@@ -201,7 +210,9 @@ class NestedComponent extends Field_1.default {
201
210
  * @returns {void}
202
211
  */
203
212
  set rowIndex(value) {
213
+ var _a, _b;
204
214
  this._rowIndex = value;
215
+ this.paths = (0, utils_1.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 }));
205
216
  this.eachComponent((component) => {
206
217
  component.rowIndex = value;
207
218
  });
@@ -297,56 +308,38 @@ class NestedComponent extends Field_1.default {
297
308
  });
298
309
  }
299
310
  /**
300
- * Returns a component provided a key. This performs a deep search within the
301
- * component tree.
311
+ * Returns a component provided a key. This performs a deep search within the component tree.
302
312
  * @param {string} path - The path to the component.
303
- * @param {Function} [fn] - Called with the component once found.
304
- * @param {string} [originalPath] - The original path to the component.
305
313
  * @returns {any} - The component that is located.
306
314
  */
307
- getComponent(path, fn, originalPath) {
308
- originalPath = originalPath || (0, utils_1.getStringFromComponentPath)(path);
309
- if (this.componentsMap.hasOwnProperty(originalPath)) {
310
- if (fn) {
311
- return fn(this.componentsMap[originalPath]);
312
- }
313
- else {
314
- return this.componentsMap[originalPath];
315
- }
316
- }
317
- path = (0, utils_1.getArrayFromComponentPath)(path);
318
- const pathStr = originalPath;
319
- const newPath = lodash_1.default.clone(path);
320
- let key = newPath.shift();
321
- const remainingPath = newPath;
322
- let comp = null;
323
- let possibleComp = null;
324
- if (lodash_1.default.isNumber(key)) {
325
- key = remainingPath.shift();
326
- }
327
- if (!lodash_1.default.isString(key)) {
328
- return comp;
329
- }
330
- this.everyComponent((component, components) => {
331
- const matchPath = component.hasInput && component.path ? pathStr.includes(component.path) : true;
332
- if (component.component.key === key) {
333
- possibleComp = component;
334
- if (matchPath) {
335
- comp = component;
336
- if (remainingPath.length > 0 && 'getComponent' in component) {
337
- comp = component.getComponent(remainingPath, fn, originalPath);
338
- }
339
- else if (fn) {
340
- fn(component, components);
341
- }
342
- return false;
343
- }
344
- }
315
+ getComponent(path) {
316
+ var _a;
317
+ path = (0, utils_1.getStringFromComponentPath)(path);
318
+ const matches = {
319
+ path: undefined,
320
+ fullPath: undefined,
321
+ localPath: undefined,
322
+ fullLocalPath: undefined,
323
+ dataPath: undefined,
324
+ localDataPath: undefined,
325
+ key: undefined,
326
+ };
327
+ this.everyComponent((component) => {
328
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
329
+ // All searches are relative to this component so replace this path from the child paths.
330
+ (0, utils_1.componentMatches)(component.component, {
331
+ path: (_b = (_a = component.paths) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(new RegExp(`^${(_c = this.paths) === null || _c === void 0 ? void 0 : _c.path}\\.?`), ''),
332
+ fullPath: (_e = (_d = component.paths) === null || _d === void 0 ? void 0 : _d.fullPath) === null || _e === void 0 ? void 0 : _e.replace(new RegExp(`^${(_f = this.paths) === null || _f === void 0 ? void 0 : _f.fullPath}\\.?`), ''),
333
+ localPath: (_h = (_g = component.paths) === null || _g === void 0 ? void 0 : _g.localPath) === null || _h === void 0 ? void 0 : _h.replace(new RegExp(`^${(_j = this.paths) === null || _j === void 0 ? void 0 : _j.localPath}\\.?`), ''),
334
+ fullLocalPath: (_l = (_k = component.paths) === null || _k === void 0 ? void 0 : _k.fullLocalPath) === null || _l === void 0 ? void 0 : _l.replace(new RegExp(`^${(_m = this.paths) === null || _m === void 0 ? void 0 : _m.fullLocalPath}\\.?`), ''),
335
+ dataPath: (_p = (_o = component.paths) === null || _o === void 0 ? void 0 : _o.dataPath) === null || _p === void 0 ? void 0 : _p.replace(new RegExp(`^${(_q = this.paths) === null || _q === void 0 ? void 0 : _q.dataPath}\\.?`), ''),
336
+ localDataPath: (_s = (_r = component.paths) === null || _r === void 0 ? void 0 : _r.localDataPath) === null || _s === void 0 ? void 0 : _s.replace(new RegExp(`^${(_t = this.paths) === null || _t === void 0 ? void 0 : _t.localDataPath}\\.?`), ''),
337
+ }, path, this.rowIndex, matches, (type, match) => {
338
+ match.instance = component;
339
+ return match;
340
+ });
345
341
  });
346
- if (!comp) {
347
- comp = possibleComp;
348
- }
349
- return comp;
342
+ return (_a = (0, utils_1.getBestMatch)(matches)) === null || _a === void 0 ? void 0 : _a.instance;
350
343
  }
351
344
  /**
352
345
  * Return a component provided the Id of the component.
@@ -384,6 +377,7 @@ class NestedComponent extends Field_1.default {
384
377
  data = data || this.data;
385
378
  options.parent = this;
386
379
  options.parentVisible = this.visible;
380
+ options.parentConditionallyHidden = this.conditionallyHidden;
387
381
  options.root = (options === null || options === void 0 ? void 0 : options.root) || this.root || this;
388
382
  options.localRoot = this.localRoot;
389
383
  options.skipInit = true;
@@ -642,7 +636,7 @@ class NestedComponent extends Field_1.default {
642
636
  clearOnHide(show) {
643
637
  super.clearOnHide(show);
644
638
  if (this.component.clearOnHide) {
645
- if (this.allowData && !this.hasValue() && !(this.options.server && !this.visible)) {
639
+ if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
646
640
  this.dataValue = this.defaultValue;
647
641
  }
648
642
  if (this.hasValue()) {
@@ -671,7 +665,7 @@ class NestedComponent extends Field_1.default {
671
665
  }
672
666
  calculateValue(data, flags, row) {
673
667
  // Do not iterate into children and calculateValues if this nested component is conditionally hidden.
674
- if (!this.conditionallyVisible()) {
668
+ if (this.conditionallyHidden) {
675
669
  return false;
676
670
  }
677
671
  return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
@@ -682,20 +676,17 @@ class NestedComponent extends Field_1.default {
682
676
  isValid(data, dirty) {
683
677
  return this.getComponents().reduce((valid, comp) => comp.isValid(data, dirty) && valid, super.isValid(data, dirty));
684
678
  }
685
- validationProcessor({ scope, data, row, instance, component }, flags) {
679
+ validationProcessor({ scope, data, row, instance, paths }, flags) {
686
680
  var _a;
687
681
  const { dirty } = flags;
688
682
  if (this.root.hasExtraPages && this.page !== this.root.page) {
689
- instance = ((_a = this.childComponentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(component.path))
690
- ? this.childComponentsMap[component.path]
691
- : this.getComponent(component.path);
683
+ instance = ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(paths.dataPath))
684
+ ? this.componentsMap[paths.dataPath]
685
+ : this.getComponent(paths.dataPath);
692
686
  }
693
687
  if (!instance) {
694
688
  return;
695
689
  }
696
- if (!instance.component.path) {
697
- instance.component.path = component.path;
698
- }
699
690
  instance.checkComponentValidity(data, dirty, row, flags, scope.errors);
700
691
  if (instance.processOwnValidation) {
701
692
  scope.noRecurse = true;
@@ -727,7 +718,10 @@ class NestedComponent extends Field_1.default {
727
718
  components,
728
719
  instances: this.componentsMap,
729
720
  data: data,
721
+ local: !!flags.local,
730
722
  scope: { errors: [] },
723
+ parent: this.component,
724
+ parentPaths: this.paths,
731
725
  processors: [
732
726
  {
733
727
  process: validationProcessorProcess,
@@ -2,6 +2,8 @@ export default class NestedArrayComponent extends NestedDataComponent {
2
2
  static savedValueTypes(): string[];
3
3
  componentContext(component: any): any;
4
4
  get iteratableRows(): void;
5
+ set rowIndex(value: number | undefined);
6
+ get rowIndex(): number | undefined;
5
7
  prevHasAddButton: any;
6
8
  checkAddButtonChanged(): void;
7
9
  checkData(data: any, flags: any, row: any): any;
@@ -10,7 +12,6 @@ export default class NestedArrayComponent extends NestedDataComponent {
10
12
  checkRow(...args: any[]): any;
11
13
  processRow(method: any, data: any, opts: any, row: any, components: any, silentCheck: any): any;
12
14
  hasAddButton(): any;
13
- getComponent(path: any, fn: any, originalPath: any): any;
14
15
  everyComponent(fn: any, rowIndex: any, options?: {}): void;
15
16
  _getEmailTableHeader(options: any): string;
16
17
  _getEmailTableBody(options: any): string;