@formio/js 5.0.0-dev.5898.ffba52a → 5.0.0-dev.5902.bf899bf
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.
- package/dist/formio.form.js +8 -8
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +8 -8
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +15 -0
- package/lib/cjs/components/_classes/component/Component.js +50 -16
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- package/lib/cjs/components/_classes/nested/NestedComponent.js +16 -7
- package/lib/cjs/components/datamap/DataMap.js +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +2 -5
- package/lib/cjs/components/form/Form.js +4 -4
- package/lib/cjs/components/html/HTML.js +15 -3
- package/lib/cjs/components/radio/Radio.js +2 -3
- package/lib/mjs/components/_classes/component/Component.d.ts +15 -0
- package/lib/mjs/components/_classes/component/Component.js +50 -16
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- package/lib/mjs/components/_classes/nested/NestedComponent.js +16 -7
- package/lib/mjs/components/datamap/DataMap.js +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +2 -5
- package/lib/mjs/components/form/Form.js +4 -4
- package/lib/mjs/components/html/HTML.js +15 -3
- package/lib/mjs/components/radio/Radio.js +2 -3
- package/package.json +1 -1
|
@@ -80,17 +80,26 @@ export default class NestedComponent extends Field {
|
|
|
80
80
|
const visibilityChanged = this._visible !== value;
|
|
81
81
|
this._visible = value;
|
|
82
82
|
const isVisible = this.visible;
|
|
83
|
+
const isConditionallyHidden = this.checkConditionallyHidden();
|
|
83
84
|
const forceShow = this.shouldForceShow();
|
|
84
85
|
const forceHide = this.shouldForceHide();
|
|
85
|
-
this.components.forEach(component => {
|
|
86
|
+
this.components.forEach((component) => {
|
|
86
87
|
// Set the parent visibility first since we may have nested components within nested components
|
|
87
88
|
// and they need to be able to determine their visibility based on the parent visibility.
|
|
88
89
|
component.parentVisible = isVisible;
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
component._parentConditionallyHidden = isConditionallyHidden;
|
|
91
|
+
let visible;
|
|
92
|
+
if (component.hasCondition()) {
|
|
93
|
+
component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
|
|
94
|
+
visible = !component.conditionallyHidden;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
visible = !component.component.hidden;
|
|
98
|
+
}
|
|
99
|
+
if (forceShow || visible) {
|
|
91
100
|
component.visible = true;
|
|
92
101
|
}
|
|
93
|
-
else if (forceHide || !isVisible || !
|
|
102
|
+
else if (forceHide || !isVisible || !visible) {
|
|
94
103
|
component.visible = false;
|
|
95
104
|
}
|
|
96
105
|
// If hiding a nested component, clear all errors below.
|
|
@@ -99,7 +108,6 @@ export default class NestedComponent extends Field {
|
|
|
99
108
|
}
|
|
100
109
|
});
|
|
101
110
|
if (visibilityChanged) {
|
|
102
|
-
this.clearOnHide();
|
|
103
111
|
this.redraw();
|
|
104
112
|
}
|
|
105
113
|
}
|
|
@@ -380,6 +388,7 @@ export default class NestedComponent extends Field {
|
|
|
380
388
|
data = data || this.data;
|
|
381
389
|
options.parent = this;
|
|
382
390
|
options.parentVisible = this.visible;
|
|
391
|
+
options.parentConditionallyHidden = this.conditionallyHidden;
|
|
383
392
|
options.root = options?.root || this.root || this;
|
|
384
393
|
options.localRoot = this.localRoot;
|
|
385
394
|
options.skipInit = true;
|
|
@@ -638,7 +647,7 @@ export default class NestedComponent extends Field {
|
|
|
638
647
|
clearOnHide(show) {
|
|
639
648
|
super.clearOnHide(show);
|
|
640
649
|
if (this.component.clearOnHide) {
|
|
641
|
-
if (this.allowData && !this.hasValue() && !
|
|
650
|
+
if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
|
|
642
651
|
this.dataValue = this.defaultValue;
|
|
643
652
|
}
|
|
644
653
|
if (this.hasValue()) {
|
|
@@ -667,7 +676,7 @@ export default class NestedComponent extends Field {
|
|
|
667
676
|
}
|
|
668
677
|
calculateValue(data, flags, row) {
|
|
669
678
|
// Do not iterate into children and calculateValues if this nested component is conditionally hidden.
|
|
670
|
-
if (
|
|
679
|
+
if (this.conditionallyHidden) {
|
|
671
680
|
return false;
|
|
672
681
|
}
|
|
673
682
|
return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
|
|
@@ -70,7 +70,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
70
70
|
}
|
|
71
71
|
get dataValue() {
|
|
72
72
|
if (!this.key ||
|
|
73
|
-
(
|
|
73
|
+
(this.conditionallyHidden && this.component.clearOnHide)) {
|
|
74
74
|
return this.emptyValue;
|
|
75
75
|
}
|
|
76
76
|
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
|
@@ -1139,7 +1139,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
1141
|
const changed = this.hasChanged(value, this.dataValue);
|
|
1142
|
-
if (this.parent
|
|
1142
|
+
if (this.parent) {
|
|
1143
1143
|
this.parent.checkComponentConditions();
|
|
1144
1144
|
}
|
|
1145
1145
|
this.dataValue = value;
|
|
@@ -1172,10 +1172,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
1172
1172
|
this.editRows = this.editRows.slice(0, dataLength);
|
|
1173
1173
|
this.openWhenEmpty();
|
|
1174
1174
|
this.updateOnChange(flags, changed);
|
|
1175
|
-
|
|
1176
|
-
if (!this.options.server) {
|
|
1177
|
-
this.checkData();
|
|
1178
|
-
}
|
|
1175
|
+
this.checkData();
|
|
1179
1176
|
this.changeState(changed, flags);
|
|
1180
1177
|
return changed;
|
|
1181
1178
|
}
|
|
@@ -417,10 +417,10 @@ export default class FormComponent extends Component {
|
|
|
417
417
|
return this.subFormReady;
|
|
418
418
|
}
|
|
419
419
|
hideSubmitButton(component) {
|
|
420
|
-
const isSubmitButton =
|
|
421
|
-
((component.action === 'submit') || !component.action);
|
|
420
|
+
const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
|
|
422
421
|
if (isSubmitButton) {
|
|
423
422
|
component.hidden = true;
|
|
423
|
+
component.customConditional = 'show = false';
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
/**
|
|
@@ -429,7 +429,7 @@ export default class FormComponent extends Component {
|
|
|
429
429
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
|
430
430
|
*/
|
|
431
431
|
loadSubForm(fromAttach) {
|
|
432
|
-
if (this.builderMode || this.
|
|
432
|
+
if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
|
|
433
433
|
return Promise.resolve();
|
|
434
434
|
}
|
|
435
435
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
|
@@ -512,7 +512,7 @@ export default class FormComponent extends Component {
|
|
|
512
512
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
|
513
513
|
*/
|
|
514
514
|
get shouldSubmit() {
|
|
515
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.
|
|
515
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* Returns the data for the subform.
|
|
@@ -51,9 +51,21 @@ export default class HTMLComponent extends Component {
|
|
|
51
51
|
}
|
|
52
52
|
checkRefreshOn(changed) {
|
|
53
53
|
super.checkRefreshOn(changed);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
54
|
+
let visible;
|
|
55
|
+
if (this.hasCondition()) {
|
|
56
|
+
this._conditionallyHidden = this.checkConditionallyHidden();
|
|
57
|
+
visible = !this.conditionallyHidden;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
visible = !this.component.hidden;
|
|
61
|
+
}
|
|
62
|
+
const shouldSetContent = !this.builderMode
|
|
63
|
+
&& this.component.refreshOnChange
|
|
64
|
+
&& this.element
|
|
65
|
+
&& !_.isUndefined(changed)
|
|
66
|
+
&& ((_.isBoolean(changed) && changed) || !_.isEmpty(changed))
|
|
67
|
+
&& visible;
|
|
68
|
+
if (shouldSetContent) {
|
|
57
69
|
this.setContent(this.element, this.renderContent());
|
|
58
70
|
}
|
|
59
71
|
}
|
|
@@ -342,9 +342,8 @@ export default class RadioComponent extends ListComponent {
|
|
|
342
342
|
label: this.component.valueProperty ? this.itemTemplate(item, valueAtProperty) : this.itemTemplate(item, item, i)
|
|
343
343
|
};
|
|
344
344
|
listData.push(this.templateData[this.component.valueProperty ? valueAtProperty : i]);
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
(!this.isRadio && _.isBoolean(valueAtProperty)))) {
|
|
345
|
+
const value = this.loadedOptions[i].value;
|
|
346
|
+
if (!this.isRadio && (_.isObject(value) || _.isBoolean(value) || _.isUndefined(value))) {
|
|
348
347
|
this.loadedOptions[i].invalid = true;
|
|
349
348
|
}
|
|
350
349
|
});
|