@formio/js 5.1.0-dev.6036.0df1d6a → 5.1.0-dev.6039.a838d78

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.
@@ -1623,7 +1623,7 @@ class WebformBuilder extends Component_1.default {
1623
1623
  info.type);
1624
1624
  }
1625
1625
  hasEditTabs(type) {
1626
- const editTabs = (0, formUtils_1.getComponent)(Components_1.default.components[type].editForm().components, 'tabs', true).components;
1626
+ const editTabs = (0, formUtils_1.getComponent)(Components_1.default.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
1627
1627
  const hiddenEditTabs = lodash_1.default.filter(lodash_1.default.get(this.options, `editForm.${type}`, []), 'ignore');
1628
1628
  return lodash_1.default.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
1629
1629
  }
@@ -119,6 +119,13 @@ 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;
122
129
  /**
123
130
  * Determines if this component is visible, or not.
124
131
  */
@@ -163,7 +170,6 @@ declare class Component extends Element {
163
170
  */
164
171
  info: any;
165
172
  get componentsMap(): object;
166
- get parentConditionallyHidden(): any;
167
173
  set data(value: any);
168
174
  get data(): any;
169
175
  mergeSchema(component?: {}): any;
@@ -233,7 +239,6 @@ declare class Component extends Element {
233
239
  * @returns {boolean} - Whether the component is conditionally hidden.
234
240
  */
235
241
  checkConditionallyHidden(data?: object, row?: object): boolean;
236
- _conditionallyHidden: any;
237
242
  set currentForm(instance: any);
238
243
  get currentForm(): any;
239
244
  _currentForm: any;
@@ -356,7 +356,8 @@ 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.checkConditionallyHidden(null, data);
359
+ this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
360
+ this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
360
361
  /**
361
362
  * Determines if this component is visible, or not.
362
363
  */
@@ -464,18 +465,6 @@ class Component extends Element_1.default {
464
465
  var _a;
465
466
  return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
466
467
  }
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
- }
479
468
  get data() {
480
469
  return this._data;
481
470
  }
@@ -516,7 +505,7 @@ class Component extends Element_1.default {
516
505
  init() {
517
506
  var _a;
518
507
  this.disabled = this.shouldDisabled;
519
- this.checkConditionallyHidden();
508
+ this._conditionallyHidden = this.checkConditionallyHidden();
520
509
  this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
521
510
  if ((_a = this.component.addons) === null || _a === void 0 ? void 0 : _a.length) {
522
511
  this.component.addons.forEach((addon) => this.createAddon(addon));
@@ -683,7 +672,7 @@ class Component extends Element_1.default {
683
672
  return this._visible && this._parentVisible;
684
673
  }
685
674
  get conditionallyHidden() {
686
- return this._conditionallyHidden || this.parentConditionallyHidden;
675
+ return this._conditionallyHidden || this._parentConditionallyHidden;
687
676
  }
688
677
  /**
689
678
  * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
@@ -692,13 +681,10 @@ class Component extends Element_1.default {
692
681
  * @returns {boolean} - Whether the component is conditionally hidden.
693
682
  */
694
683
  checkConditionallyHidden(data = null, row = null) {
695
- this._conditionallyHidden = false;
696
684
  if (!this.hasCondition()) {
697
- this._conditionallyHidden = this.parentConditionallyHidden;
698
- return this._conditionallyHidden;
685
+ return false;
699
686
  }
700
- this._conditionallyHidden = !this.conditionallyVisible(data, row) || this.parentConditionallyHidden;
701
- return this._conditionallyHidden;
687
+ return !this.conditionallyVisible(data, row);
702
688
  }
703
689
  get currentForm() {
704
690
  return this._currentForm;
@@ -1965,7 +1951,12 @@ class Component extends Element_1.default {
1965
1951
  this.redraw();
1966
1952
  }
1967
1953
  // Check advanced conditions (and cache the result)
1968
- const shouldClear = this.checkConditionallyHidden(data, row);
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
+ }
1969
1960
  // Check visibility
1970
1961
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1971
1962
  if (this.visible !== visible) {
@@ -2503,7 +2494,8 @@ class Component extends Element_1.default {
2503
2494
  * @returns {*} - The value for this component.
2504
2495
  */
2505
2496
  get dataValue() {
2506
- if (!this.key) {
2497
+ if (!this.key ||
2498
+ (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2507
2499
  return this.emptyValue;
2508
2500
  }
2509
2501
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2520,7 +2512,9 @@ class Component extends Element_1.default {
2520
2512
  * @param {*} value - The value to set for this component.
2521
2513
  */
2522
2514
  set dataValue(value) {
2523
- if (!this.allowData || !this.key) {
2515
+ if (!this.allowData ||
2516
+ !this.key ||
2517
+ (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2524
2518
  return;
2525
2519
  }
2526
2520
  if ((value !== null) && (value !== undefined)) {
@@ -85,16 +85,18 @@ 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
- this.checkConditionallyHidden();
88
+ const isConditionallyHidden = 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;
95
96
  let visible;
96
97
  if (component.hasCondition()) {
97
- visible = !component.checkConditionallyHidden();
98
+ component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
99
+ visible = !component.conditionallyHidden;
98
100
  }
99
101
  else {
100
102
  visible = !component.component.hidden;
@@ -375,6 +377,7 @@ class NestedComponent extends Field_1.default {
375
377
  data = data || this.data;
376
378
  options.parent = this;
377
379
  options.parentVisible = this.visible;
380
+ options.parentConditionallyHidden = this.conditionallyHidden;
378
381
  options.root = (options === null || options === void 0 ? void 0 : options.root) || this.root || this;
379
382
  options.localRoot = this.localRoot;
380
383
  options.skipInit = true;
@@ -1159,6 +1159,9 @@ 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
+ }
1162
1165
  this.dataValue = value;
1163
1166
  // Refresh editRow data when data changes.
1164
1167
  this.dataValue.forEach((row, rowIndex) => {
@@ -1189,6 +1192,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1189
1192
  this.editRows = this.editRows.slice(0, dataLength);
1190
1193
  this.openWhenEmpty();
1191
1194
  this.updateOnChange(flags, changed);
1195
+ this.checkData();
1192
1196
  this.changeState(changed, flags);
1193
1197
  return changed;
1194
1198
  }
@@ -58,7 +58,8 @@ class HTMLComponent extends Component_1.default {
58
58
  super.checkRefreshOn(changed);
59
59
  let visible;
60
60
  if (this.hasCondition()) {
61
- visible = !this.checkConditionallyHidden();
61
+ this._conditionallyHidden = this.checkConditionallyHidden();
62
+ visible = !this.conditionallyHidden;
62
63
  }
63
64
  else {
64
65
  visible = !this.component.hidden;
@@ -143,7 +143,6 @@ 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);
147
146
  this.triggerChange();
148
147
  }
149
148
  beforeFocus(component) {
@@ -1626,7 +1626,7 @@ export default class WebformBuilder extends Component {
1626
1626
  info.type);
1627
1627
  }
1628
1628
  hasEditTabs(type) {
1629
- const editTabs = getComponent(Components.components[type].editForm().components, 'tabs', true).components;
1629
+ const editTabs = getComponent(Components.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
1630
1630
  const hiddenEditTabs = _.filter(_.get(this.options, `editForm.${type}`, []), 'ignore');
1631
1631
  return _.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
1632
1632
  }
@@ -119,6 +119,13 @@ 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;
122
129
  /**
123
130
  * Determines if this component is visible, or not.
124
131
  */
@@ -163,7 +170,6 @@ declare class Component extends Element {
163
170
  */
164
171
  info: any;
165
172
  get componentsMap(): object;
166
- get parentConditionallyHidden(): any;
167
173
  set data(value: any);
168
174
  get data(): any;
169
175
  mergeSchema(component?: {}): any;
@@ -233,7 +239,6 @@ declare class Component extends Element {
233
239
  * @returns {boolean} - Whether the component is conditionally hidden.
234
240
  */
235
241
  checkConditionallyHidden(data?: object, row?: object): boolean;
236
- _conditionallyHidden: any;
237
242
  set currentForm(instance: any);
238
243
  get currentForm(): any;
239
244
  _currentForm: any;
@@ -321,7 +321,8 @@ 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.checkConditionallyHidden(null, data);
324
+ this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
325
+ this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
325
326
  /**
326
327
  * Determines if this component is visible, or not.
327
328
  */
@@ -428,18 +429,6 @@ export default class Component extends Element {
428
429
  get componentsMap() {
429
430
  return this.root?.childComponentsMap || {};
430
431
  }
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
- }
443
432
  get data() {
444
433
  return this._data;
445
434
  }
@@ -479,7 +468,7 @@ export default class Component extends Element {
479
468
  }
480
469
  init() {
481
470
  this.disabled = this.shouldDisabled;
482
- this.checkConditionallyHidden();
471
+ this._conditionallyHidden = this.checkConditionallyHidden();
483
472
  this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
484
473
  if (this.component.addons?.length) {
485
474
  this.component.addons.forEach((addon) => this.createAddon(addon));
@@ -647,7 +636,7 @@ export default class Component extends Element {
647
636
  return this._visible && this._parentVisible;
648
637
  }
649
638
  get conditionallyHidden() {
650
- return this._conditionallyHidden || this.parentConditionallyHidden;
639
+ return this._conditionallyHidden || this._parentConditionallyHidden;
651
640
  }
652
641
  /**
653
642
  * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
@@ -656,13 +645,10 @@ export default class Component extends Element {
656
645
  * @returns {boolean} - Whether the component is conditionally hidden.
657
646
  */
658
647
  checkConditionallyHidden(data = null, row = null) {
659
- this._conditionallyHidden = false;
660
648
  if (!this.hasCondition()) {
661
- this._conditionallyHidden = this.parentConditionallyHidden;
662
- return this._conditionallyHidden;
649
+ return false;
663
650
  }
664
- this._conditionallyHidden = !this.conditionallyVisible(data, row) || this.parentConditionallyHidden;
665
- return this._conditionallyHidden;
651
+ return !this.conditionallyVisible(data, row);
666
652
  }
667
653
  get currentForm() {
668
654
  return this._currentForm;
@@ -1931,7 +1917,12 @@ export default class Component extends Element {
1931
1917
  this.redraw();
1932
1918
  }
1933
1919
  // Check advanced conditions (and cache the result)
1934
- const shouldClear = this.checkConditionallyHidden(data, row);
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
+ }
1935
1926
  // Check visibility
1936
1927
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1937
1928
  if (this.visible !== visible) {
@@ -2472,7 +2463,8 @@ export default class Component extends Element {
2472
2463
  * @returns {*} - The value for this component.
2473
2464
  */
2474
2465
  get dataValue() {
2475
- if (!this.key) {
2466
+ if (!this.key ||
2467
+ (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2476
2468
  return this.emptyValue;
2477
2469
  }
2478
2470
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2489,7 +2481,9 @@ export default class Component extends Element {
2489
2481
  * @param {*} value - The value to set for this component.
2490
2482
  */
2491
2483
  set dataValue(value) {
2492
- if (!this.allowData || !this.key) {
2484
+ if (!this.allowData ||
2485
+ !this.key ||
2486
+ (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2493
2487
  return;
2494
2488
  }
2495
2489
  if ((value !== null) && (value !== undefined)) {
@@ -81,16 +81,18 @@ 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
- this.checkConditionallyHidden();
84
+ const isConditionallyHidden = 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;
91
92
  let visible;
92
93
  if (component.hasCondition()) {
93
- visible = !component.checkConditionallyHidden();
94
+ component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
95
+ visible = !component.conditionallyHidden;
94
96
  }
95
97
  else {
96
98
  visible = !component.component.hidden;
@@ -371,6 +373,7 @@ export default class NestedComponent extends Field {
371
373
  data = data || this.data;
372
374
  options.parent = this;
373
375
  options.parentVisible = this.visible;
376
+ options.parentConditionallyHidden = this.conditionallyHidden;
374
377
  options.root = options?.root || this.root || this;
375
378
  options.localRoot = this.localRoot;
376
379
  options.skipInit = true;
@@ -1150,6 +1150,9 @@ 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
+ }
1153
1156
  this.dataValue = value;
1154
1157
  // Refresh editRow data when data changes.
1155
1158
  this.dataValue.forEach((row, rowIndex) => {
@@ -1180,6 +1183,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1180
1183
  this.editRows = this.editRows.slice(0, dataLength);
1181
1184
  this.openWhenEmpty();
1182
1185
  this.updateOnChange(flags, changed);
1186
+ this.checkData();
1183
1187
  this.changeState(changed, flags);
1184
1188
  return changed;
1185
1189
  }
@@ -53,7 +53,8 @@ export default class HTMLComponent extends Component {
53
53
  super.checkRefreshOn(changed);
54
54
  let visible;
55
55
  if (this.hasCondition()) {
56
- visible = !this.checkConditionallyHidden();
56
+ this._conditionallyHidden = this.checkConditionallyHidden();
57
+ visible = !this.conditionallyHidden;
57
58
  }
58
59
  else {
59
60
  visible = !this.component.hidden;
@@ -138,7 +138,6 @@ 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);
142
141
  this.triggerChange();
143
142
  }
144
143
  beforeFocus(component) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6036.0df1d6a",
3
+ "version": "5.1.0-dev.6039.a838d78",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {