@formio/js 5.1.0-dev.6035.9508dc1 → 5.1.0-dev.6036.0df1d6a

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.
@@ -119,13 +119,6 @@ declare class Component extends Element {
119
119
  */
120
120
  paths: import('@formio/core').ComponentPaths;
121
121
  _path: string;
122
- /**
123
- * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
124
- * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
125
- * conditionallyHidden separately from "regular" visibility.
126
- */
127
- _parentConditionallyHidden: any;
128
- _conditionallyHidden: any;
129
122
  /**
130
123
  * Determines if this component is visible, or not.
131
124
  */
@@ -170,6 +163,7 @@ declare class Component extends Element {
170
163
  */
171
164
  info: any;
172
165
  get componentsMap(): object;
166
+ get parentConditionallyHidden(): any;
173
167
  set data(value: any);
174
168
  get data(): any;
175
169
  mergeSchema(component?: {}): any;
@@ -239,6 +233,7 @@ declare class Component extends Element {
239
233
  * @returns {boolean} - Whether the component is conditionally hidden.
240
234
  */
241
235
  checkConditionallyHidden(data?: object, row?: object): boolean;
236
+ _conditionallyHidden: any;
242
237
  set currentForm(instance: any);
243
238
  get currentForm(): any;
244
239
  _currentForm: any;
@@ -356,8 +356,7 @@ class Component extends Element_1.default {
356
356
  * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
357
357
  * conditionallyHidden separately from "regular" visibility.
358
358
  */
359
- this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
360
- this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
359
+ this.checkConditionallyHidden(null, data);
361
360
  /**
362
361
  * Determines if this component is visible, or not.
363
362
  */
@@ -465,6 +464,18 @@ class Component extends Element_1.default {
465
464
  var _a;
466
465
  return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
467
466
  }
467
+ get parentConditionallyHidden() {
468
+ let parentHidden = false;
469
+ let currentParent = this.parent;
470
+ while (currentParent) {
471
+ parentHidden = parentHidden || currentParent._conditionallyHidden;
472
+ if (parentHidden) {
473
+ break;
474
+ }
475
+ currentParent = currentParent.parent;
476
+ }
477
+ return parentHidden;
478
+ }
468
479
  get data() {
469
480
  return this._data;
470
481
  }
@@ -505,7 +516,7 @@ class Component extends Element_1.default {
505
516
  init() {
506
517
  var _a;
507
518
  this.disabled = this.shouldDisabled;
508
- this._conditionallyHidden = this.checkConditionallyHidden();
519
+ this.checkConditionallyHidden();
509
520
  this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
510
521
  if ((_a = this.component.addons) === null || _a === void 0 ? void 0 : _a.length) {
511
522
  this.component.addons.forEach((addon) => this.createAddon(addon));
@@ -672,7 +683,7 @@ class Component extends Element_1.default {
672
683
  return this._visible && this._parentVisible;
673
684
  }
674
685
  get conditionallyHidden() {
675
- return this._conditionallyHidden || this._parentConditionallyHidden;
686
+ return this._conditionallyHidden || this.parentConditionallyHidden;
676
687
  }
677
688
  /**
678
689
  * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
@@ -681,10 +692,13 @@ class Component extends Element_1.default {
681
692
  * @returns {boolean} - Whether the component is conditionally hidden.
682
693
  */
683
694
  checkConditionallyHidden(data = null, row = null) {
695
+ this._conditionallyHidden = false;
684
696
  if (!this.hasCondition()) {
685
- return false;
697
+ this._conditionallyHidden = this.parentConditionallyHidden;
698
+ return this._conditionallyHidden;
686
699
  }
687
- return !this.conditionallyVisible(data, row);
700
+ this._conditionallyHidden = !this.conditionallyVisible(data, row) || this.parentConditionallyHidden;
701
+ return this._conditionallyHidden;
688
702
  }
689
703
  get currentForm() {
690
704
  return this._currentForm;
@@ -1951,12 +1965,7 @@ class Component extends Element_1.default {
1951
1965
  this.redraw();
1952
1966
  }
1953
1967
  // Check advanced conditions (and cache the result)
1954
- const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1955
- let shouldClear = false;
1956
- if (isConditionallyHidden !== this._conditionallyHidden) {
1957
- this._conditionallyHidden = isConditionallyHidden;
1958
- shouldClear = true;
1959
- }
1968
+ const shouldClear = this.checkConditionallyHidden(data, row);
1960
1969
  // Check visibility
1961
1970
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1962
1971
  if (this.visible !== visible) {
@@ -2494,8 +2503,7 @@ class Component extends Element_1.default {
2494
2503
  * @returns {*} - The value for this component.
2495
2504
  */
2496
2505
  get dataValue() {
2497
- if (!this.key ||
2498
- (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2506
+ if (!this.key) {
2499
2507
  return this.emptyValue;
2500
2508
  }
2501
2509
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2512,9 +2520,7 @@ class Component extends Element_1.default {
2512
2520
  * @param {*} value - The value to set for this component.
2513
2521
  */
2514
2522
  set dataValue(value) {
2515
- if (!this.allowData ||
2516
- !this.key ||
2517
- (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2523
+ if (!this.allowData || !this.key) {
2518
2524
  return;
2519
2525
  }
2520
2526
  if ((value !== null) && (value !== undefined)) {
@@ -85,18 +85,16 @@ class NestedComponent extends Field_1.default {
85
85
  const visibilityChanged = this._visible !== value;
86
86
  this._visible = value;
87
87
  const isVisible = this.visible;
88
- const isConditionallyHidden = this.checkConditionallyHidden();
88
+ this.checkConditionallyHidden();
89
89
  const forceShow = this.shouldForceShow();
90
90
  const forceHide = this.shouldForceHide();
91
91
  this.components.forEach((component) => {
92
92
  // Set the parent visibility first since we may have nested components within nested components
93
93
  // and they need to be able to determine their visibility based on the parent visibility.
94
94
  component.parentVisible = isVisible;
95
- component._parentConditionallyHidden = isConditionallyHidden;
96
95
  let visible;
97
96
  if (component.hasCondition()) {
98
- component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
99
- visible = !component.conditionallyHidden;
97
+ visible = !component.checkConditionallyHidden();
100
98
  }
101
99
  else {
102
100
  visible = !component.component.hidden;
@@ -377,7 +375,6 @@ class NestedComponent extends Field_1.default {
377
375
  data = data || this.data;
378
376
  options.parent = this;
379
377
  options.parentVisible = this.visible;
380
- options.parentConditionallyHidden = this.conditionallyHidden;
381
378
  options.root = (options === null || options === void 0 ? void 0 : options.root) || this.root || this;
382
379
  options.localRoot = this.localRoot;
383
380
  options.skipInit = true;
@@ -1159,9 +1159,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1159
1159
  }
1160
1160
  }
1161
1161
  const changed = this.hasChanged(value, this.dataValue);
1162
- if (this.parent) {
1163
- this.parent.checkComponentConditions();
1164
- }
1165
1162
  this.dataValue = value;
1166
1163
  // Refresh editRow data when data changes.
1167
1164
  this.dataValue.forEach((row, rowIndex) => {
@@ -1192,7 +1189,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1192
1189
  this.editRows = this.editRows.slice(0, dataLength);
1193
1190
  this.openWhenEmpty();
1194
1191
  this.updateOnChange(flags, changed);
1195
- this.checkData();
1196
1192
  this.changeState(changed, flags);
1197
1193
  return changed;
1198
1194
  }
@@ -58,8 +58,7 @@ class HTMLComponent extends Component_1.default {
58
58
  super.checkRefreshOn(changed);
59
59
  let visible;
60
60
  if (this.hasCondition()) {
61
- this._conditionallyHidden = this.checkConditionallyHidden();
62
- visible = !this.conditionallyHidden;
61
+ visible = !this.checkConditionallyHidden();
63
62
  }
64
63
  else {
65
64
  visible = !this.component.hidden;
@@ -143,6 +143,7 @@ class TabsComponent extends NestedComponent_1.default {
143
143
  this.addClass(this.refs[this.tabLinkKey][index], 'active');
144
144
  this.addClass(this.refs[this.tabLinkKey][index], 'formio-tab-link-active');
145
145
  }
146
+ this.setValue(this.data);
146
147
  this.triggerChange();
147
148
  }
148
149
  beforeFocus(component) {
@@ -119,13 +119,6 @@ declare class Component extends Element {
119
119
  */
120
120
  paths: import('@formio/core').ComponentPaths;
121
121
  _path: string;
122
- /**
123
- * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
124
- * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
125
- * conditionallyHidden separately from "regular" visibility.
126
- */
127
- _parentConditionallyHidden: any;
128
- _conditionallyHidden: any;
129
122
  /**
130
123
  * Determines if this component is visible, or not.
131
124
  */
@@ -170,6 +163,7 @@ declare class Component extends Element {
170
163
  */
171
164
  info: any;
172
165
  get componentsMap(): object;
166
+ get parentConditionallyHidden(): any;
173
167
  set data(value: any);
174
168
  get data(): any;
175
169
  mergeSchema(component?: {}): any;
@@ -239,6 +233,7 @@ declare class Component extends Element {
239
233
  * @returns {boolean} - Whether the component is conditionally hidden.
240
234
  */
241
235
  checkConditionallyHidden(data?: object, row?: object): boolean;
236
+ _conditionallyHidden: any;
242
237
  set currentForm(instance: any);
243
238
  get currentForm(): any;
244
239
  _currentForm: any;
@@ -321,8 +321,7 @@ export default class Component extends Element {
321
321
  * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
322
322
  * conditionallyHidden separately from "regular" visibility.
323
323
  */
324
- this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
325
- this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
324
+ this.checkConditionallyHidden(null, data);
326
325
  /**
327
326
  * Determines if this component is visible, or not.
328
327
  */
@@ -429,6 +428,18 @@ export default class Component extends Element {
429
428
  get componentsMap() {
430
429
  return this.root?.childComponentsMap || {};
431
430
  }
431
+ get parentConditionallyHidden() {
432
+ let parentHidden = false;
433
+ let currentParent = this.parent;
434
+ while (currentParent) {
435
+ parentHidden = parentHidden || currentParent._conditionallyHidden;
436
+ if (parentHidden) {
437
+ break;
438
+ }
439
+ currentParent = currentParent.parent;
440
+ }
441
+ return parentHidden;
442
+ }
432
443
  get data() {
433
444
  return this._data;
434
445
  }
@@ -468,7 +479,7 @@ export default class Component extends Element {
468
479
  }
469
480
  init() {
470
481
  this.disabled = this.shouldDisabled;
471
- this._conditionallyHidden = this.checkConditionallyHidden();
482
+ this.checkConditionallyHidden();
472
483
  this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
473
484
  if (this.component.addons?.length) {
474
485
  this.component.addons.forEach((addon) => this.createAddon(addon));
@@ -636,7 +647,7 @@ export default class Component extends Element {
636
647
  return this._visible && this._parentVisible;
637
648
  }
638
649
  get conditionallyHidden() {
639
- return this._conditionallyHidden || this._parentConditionallyHidden;
650
+ return this._conditionallyHidden || this.parentConditionallyHidden;
640
651
  }
641
652
  /**
642
653
  * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
@@ -645,10 +656,13 @@ export default class Component extends Element {
645
656
  * @returns {boolean} - Whether the component is conditionally hidden.
646
657
  */
647
658
  checkConditionallyHidden(data = null, row = null) {
659
+ this._conditionallyHidden = false;
648
660
  if (!this.hasCondition()) {
649
- return false;
661
+ this._conditionallyHidden = this.parentConditionallyHidden;
662
+ return this._conditionallyHidden;
650
663
  }
651
- return !this.conditionallyVisible(data, row);
664
+ this._conditionallyHidden = !this.conditionallyVisible(data, row) || this.parentConditionallyHidden;
665
+ return this._conditionallyHidden;
652
666
  }
653
667
  get currentForm() {
654
668
  return this._currentForm;
@@ -1917,12 +1931,7 @@ export default class Component extends Element {
1917
1931
  this.redraw();
1918
1932
  }
1919
1933
  // Check advanced conditions (and cache the result)
1920
- const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1921
- let shouldClear = false;
1922
- if (isConditionallyHidden !== this._conditionallyHidden) {
1923
- this._conditionallyHidden = isConditionallyHidden;
1924
- shouldClear = true;
1925
- }
1934
+ const shouldClear = this.checkConditionallyHidden(data, row);
1926
1935
  // Check visibility
1927
1936
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1928
1937
  if (this.visible !== visible) {
@@ -2463,8 +2472,7 @@ export default class Component extends Element {
2463
2472
  * @returns {*} - The value for this component.
2464
2473
  */
2465
2474
  get dataValue() {
2466
- if (!this.key ||
2467
- (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2475
+ if (!this.key) {
2468
2476
  return this.emptyValue;
2469
2477
  }
2470
2478
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2481,9 +2489,7 @@ export default class Component extends Element {
2481
2489
  * @param {*} value - The value to set for this component.
2482
2490
  */
2483
2491
  set dataValue(value) {
2484
- if (!this.allowData ||
2485
- !this.key ||
2486
- (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2492
+ if (!this.allowData || !this.key) {
2487
2493
  return;
2488
2494
  }
2489
2495
  if ((value !== null) && (value !== undefined)) {
@@ -81,18 +81,16 @@ export default class NestedComponent extends Field {
81
81
  const visibilityChanged = this._visible !== value;
82
82
  this._visible = value;
83
83
  const isVisible = this.visible;
84
- const isConditionallyHidden = this.checkConditionallyHidden();
84
+ this.checkConditionallyHidden();
85
85
  const forceShow = this.shouldForceShow();
86
86
  const forceHide = this.shouldForceHide();
87
87
  this.components.forEach((component) => {
88
88
  // Set the parent visibility first since we may have nested components within nested components
89
89
  // and they need to be able to determine their visibility based on the parent visibility.
90
90
  component.parentVisible = isVisible;
91
- component._parentConditionallyHidden = isConditionallyHidden;
92
91
  let visible;
93
92
  if (component.hasCondition()) {
94
- component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
95
- visible = !component.conditionallyHidden;
93
+ visible = !component.checkConditionallyHidden();
96
94
  }
97
95
  else {
98
96
  visible = !component.component.hidden;
@@ -373,7 +371,6 @@ export default class NestedComponent extends Field {
373
371
  data = data || this.data;
374
372
  options.parent = this;
375
373
  options.parentVisible = this.visible;
376
- options.parentConditionallyHidden = this.conditionallyHidden;
377
374
  options.root = options?.root || this.root || this;
378
375
  options.localRoot = this.localRoot;
379
376
  options.skipInit = true;
@@ -1150,9 +1150,6 @@ export default class EditGridComponent extends NestedArrayComponent {
1150
1150
  }
1151
1151
  }
1152
1152
  const changed = this.hasChanged(value, this.dataValue);
1153
- if (this.parent) {
1154
- this.parent.checkComponentConditions();
1155
- }
1156
1153
  this.dataValue = value;
1157
1154
  // Refresh editRow data when data changes.
1158
1155
  this.dataValue.forEach((row, rowIndex) => {
@@ -1183,7 +1180,6 @@ export default class EditGridComponent extends NestedArrayComponent {
1183
1180
  this.editRows = this.editRows.slice(0, dataLength);
1184
1181
  this.openWhenEmpty();
1185
1182
  this.updateOnChange(flags, changed);
1186
- this.checkData();
1187
1183
  this.changeState(changed, flags);
1188
1184
  return changed;
1189
1185
  }
@@ -53,8 +53,7 @@ export default class HTMLComponent extends Component {
53
53
  super.checkRefreshOn(changed);
54
54
  let visible;
55
55
  if (this.hasCondition()) {
56
- this._conditionallyHidden = this.checkConditionallyHidden();
57
- visible = !this.conditionallyHidden;
56
+ visible = !this.checkConditionallyHidden();
58
57
  }
59
58
  else {
60
59
  visible = !this.component.hidden;
@@ -138,6 +138,7 @@ export default class TabsComponent extends NestedComponent {
138
138
  this.addClass(this.refs[this.tabLinkKey][index], 'active');
139
139
  this.addClass(this.refs[this.tabLinkKey][index], 'formio-tab-link-active');
140
140
  }
141
+ this.setValue(this.data);
141
142
  this.triggerChange();
142
143
  }
143
144
  beforeFocus(component) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6035.9508dc1",
3
+ "version": "5.1.0-dev.6036.0df1d6a",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {