@formio/js 5.1.0-dev.6068.fbce2f7 → 5.1.0-dev.6069.caec01d
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 +540 -529
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +540 -529
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +21 -10
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +22 -11
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +2 -31
- package/lib/cjs/components/_classes/component/Component.js +32 -66
- package/lib/cjs/components/form/Form.d.ts +1 -0
- package/lib/cjs/components/form/Form.js +20 -12
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/utils.js +2 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +2 -31
- package/lib/mjs/components/_classes/component/Component.js +32 -66
- package/lib/mjs/components/form/Form.d.ts +1 -0
- package/lib/mjs/components/form/Form.js +20 -12
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/utils.js +2 -1
- package/package.json +2 -2
@@ -163,22 +163,8 @@ declare class Component extends Element {
|
|
163
163
|
*/
|
164
164
|
info: any;
|
165
165
|
get componentsMap(): object;
|
166
|
-
/**
|
167
|
-
* Returns if the parent should conditionally clear.
|
168
|
-
* This method does not need to walk up the parent tree since the variables
|
169
|
-
* _conditionallyClear and _conditionallyHidden are set on the parent component
|
170
|
-
* before the child component is determined, and the parent component also references
|
171
|
-
* its parent component.
|
172
|
-
*
|
173
|
-
* @returns {boolean} - If the parent should conditionally clear.
|
174
|
-
*/
|
175
166
|
parentShouldConditionallyClear(): boolean;
|
176
167
|
parentConditionallyHidden(): boolean;
|
177
|
-
/**
|
178
|
-
* Returns true if any of the parents default their component "hidden" property to true.
|
179
|
-
* @returns {boolean} - If any parent defaults the hidden property to true.
|
180
|
-
*/
|
181
|
-
anyParentDefaultsHidden(): boolean;
|
182
168
|
set data(value: any);
|
183
169
|
get data(): any;
|
184
170
|
mergeSchema(component?: {}): any;
|
@@ -242,23 +228,8 @@ declare class Component extends Element {
|
|
242
228
|
get visible(): boolean;
|
243
229
|
get logicallyHidden(): any;
|
244
230
|
_logicallyHidden: any;
|
245
|
-
|
246
|
-
|
247
|
-
* @returns {boolean} - If the component should clear its value when the root form is pristine.
|
248
|
-
*/
|
249
|
-
shouldConditionallyClearOnPristine(): boolean;
|
250
|
-
/**
|
251
|
-
* Returns if the component should clear its value when conditionally hidden.
|
252
|
-
* @returns {boolean} - If the component should clear its value when conditionally hidden.
|
253
|
-
*/
|
254
|
-
shouldConditionallyClear(): boolean;
|
255
|
-
_conditionallyClear: boolean | undefined;
|
256
|
-
/**
|
257
|
-
* Returns if the component is conditionally hidden.
|
258
|
-
* @returns {boolean} - If the component is conditionally hidden.
|
259
|
-
*/
|
260
|
-
conditionallyHidden(): boolean;
|
261
|
-
_conditionallyHidden: boolean | undefined;
|
231
|
+
shouldConditionallyClear(skipParent?: boolean): boolean;
|
232
|
+
conditionallyHidden(skipParent?: boolean): boolean;
|
262
233
|
set currentForm(instance: any);
|
263
234
|
get currentForm(): any;
|
264
235
|
_currentForm: any;
|
@@ -458,20 +458,10 @@ class Component extends Element_1.default {
|
|
458
458
|
var _a;
|
459
459
|
return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
|
460
460
|
}
|
461
|
-
/**
|
462
|
-
* Returns if the parent should conditionally clear.
|
463
|
-
* This method does not need to walk up the parent tree since the variables
|
464
|
-
* _conditionallyClear and _conditionallyHidden are set on the parent component
|
465
|
-
* before the child component is determined, and the parent component also references
|
466
|
-
* its parent component.
|
467
|
-
*
|
468
|
-
* @returns {boolean} - If the parent should conditionally clear.
|
469
|
-
*/
|
470
461
|
parentShouldConditionallyClear() {
|
471
462
|
let currentParent = this.parent;
|
472
463
|
while (currentParent) {
|
473
|
-
if (
|
474
|
-
(!currentParent.allowData && currentParent._conditionallyHidden)) {
|
464
|
+
if (currentParent.shouldConditionallyClear(true)) {
|
475
465
|
return true;
|
476
466
|
}
|
477
467
|
currentParent = currentParent.parent;
|
@@ -481,21 +471,7 @@ class Component extends Element_1.default {
|
|
481
471
|
parentConditionallyHidden() {
|
482
472
|
let currentParent = this.parent;
|
483
473
|
while (currentParent) {
|
484
|
-
if (currentParent.
|
485
|
-
return true;
|
486
|
-
}
|
487
|
-
currentParent = currentParent.parent;
|
488
|
-
}
|
489
|
-
return false;
|
490
|
-
}
|
491
|
-
/**
|
492
|
-
* Returns true if any of the parents default their component "hidden" property to true.
|
493
|
-
* @returns {boolean} - If any parent defaults the hidden property to true.
|
494
|
-
*/
|
495
|
-
anyParentDefaultsHidden() {
|
496
|
-
let currentParent = this.parent;
|
497
|
-
while (currentParent) {
|
498
|
-
if (currentParent.component.hidden) {
|
474
|
+
if (currentParent.conditionallyHidden(true)) {
|
499
475
|
return true;
|
500
476
|
}
|
501
477
|
currentParent = currentParent.parent;
|
@@ -713,58 +689,48 @@ class Component extends Element_1.default {
|
|
713
689
|
}
|
714
690
|
return this._logicallyHidden;
|
715
691
|
}
|
716
|
-
|
717
|
-
* Determines if the component should clear its value when the root form is pristine.
|
718
|
-
* @returns {boolean} - If the component should clear its value when the root form is pristine.
|
719
|
-
*/
|
720
|
-
shouldConditionallyClearOnPristine() {
|
721
|
-
// If the form is pristine, we should NOT clear the value of a conditionally hidden child component
|
722
|
-
// of a layout component that defaults to hidden using the "hidden" component property.
|
723
|
-
return !this.anyParentDefaultsHidden();
|
724
|
-
}
|
725
|
-
/**
|
726
|
-
* Returns if the component should clear its value when conditionally hidden.
|
727
|
-
* @returns {boolean} - If the component should clear its value when conditionally hidden.
|
728
|
-
*/
|
729
|
-
shouldConditionallyClear() {
|
692
|
+
shouldConditionallyClear(skipParent = false) {
|
730
693
|
// Skip if this component has clearOnHide set to false.
|
731
694
|
if (this.component.clearOnHide === false) {
|
732
|
-
|
733
|
-
return this._conditionallyClear;
|
695
|
+
return false;
|
734
696
|
}
|
735
697
|
// If the component is logically hidden, then it is conditionally hidden and should clear.
|
736
698
|
if (this.logicallyHidden) {
|
737
|
-
|
738
|
-
return this._conditionallyClear;
|
699
|
+
return true;
|
739
700
|
}
|
740
701
|
// If we have a condition and it is not conditionally visible, the it should conditionally clear.
|
741
|
-
if (this.hasCondition() &&
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
702
|
+
if (this.hasCondition() && !this.conditionallyVisible()) {
|
703
|
+
return true;
|
704
|
+
}
|
705
|
+
if (skipParent) {
|
706
|
+
// Stop recurrsion for the parent checks.
|
707
|
+
return false;
|
708
|
+
}
|
709
|
+
// If this component has a set value, then it should ONLY clear if a parent is hidden
|
710
|
+
// and has the clearOnHide set to true.
|
711
|
+
if (this.hasSetValue) {
|
712
|
+
return this.parentShouldConditionallyClear();
|
746
713
|
}
|
747
|
-
|
748
|
-
return this.
|
714
|
+
// Clear the value if the parent is conditionally hidden.
|
715
|
+
return this.parentConditionallyHidden();
|
749
716
|
}
|
750
|
-
|
751
|
-
* Returns if the component is conditionally hidden.
|
752
|
-
* @returns {boolean} - If the component is conditionally hidden.
|
753
|
-
*/
|
754
|
-
conditionallyHidden() {
|
755
|
-
// If it is logically hidden, then it is conditionally hidden.
|
717
|
+
conditionallyHidden(skipParent = false) {
|
756
718
|
if (this.logicallyHidden) {
|
757
|
-
|
758
|
-
return this._conditionallyHidden;
|
719
|
+
return true;
|
759
720
|
}
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
721
|
+
if (!this.hasCondition() && !skipParent) {
|
722
|
+
return this.parentConditionallyHidden();
|
723
|
+
}
|
724
|
+
// Return if we are not conditionally visible (conditionallyHidden)
|
725
|
+
if (!this.conditionallyVisible()) {
|
726
|
+
return true;
|
727
|
+
}
|
728
|
+
if (skipParent) {
|
729
|
+
// Stop recurrsion for the parent checks.
|
730
|
+
return false;
|
764
731
|
}
|
765
|
-
//
|
766
|
-
|
767
|
-
return this._conditionallyHidden;
|
732
|
+
// Check the parent.
|
733
|
+
return this.parentConditionallyHidden();
|
768
734
|
}
|
769
735
|
get currentForm() {
|
770
736
|
return this._currentForm;
|
@@ -98,6 +98,7 @@ export default class FormComponent extends Component {
|
|
98
98
|
* @returns {void}
|
99
99
|
*/
|
100
100
|
onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
|
101
|
+
areAllComponentsEmpty(data: any): boolean;
|
101
102
|
updateSubFormVisibility(): void;
|
102
103
|
/**
|
103
104
|
* Determines if this form is a Nested Wizard
|
@@ -101,9 +101,6 @@ class FormComponent extends Component_1.default {
|
|
101
101
|
}
|
102
102
|
return this.createSubForm();
|
103
103
|
}
|
104
|
-
shouldConditionallyClearOnPristine() {
|
105
|
-
return !this.hasSetValue && super.shouldConditionallyClearOnPristine();
|
106
|
-
}
|
107
104
|
get dataReady() {
|
108
105
|
var _a;
|
109
106
|
return ((_a = this.subForm) === null || _a === void 0 ? void 0 : _a.dataReady) || this.subFormReady || Promise.resolve();
|
@@ -293,13 +290,11 @@ class FormComponent extends Component_1.default {
|
|
293
290
|
}
|
294
291
|
this.subForm.attach(element);
|
295
292
|
this.valueChanged = this.hasSetValue;
|
296
|
-
if (!this.
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
this.restoreValue();
|
302
|
-
}
|
293
|
+
if (!this.valueChanged && this.dataValue.state !== 'submitted') {
|
294
|
+
this.setDefaultValue();
|
295
|
+
}
|
296
|
+
else {
|
297
|
+
this.restoreValue();
|
303
298
|
}
|
304
299
|
}
|
305
300
|
if (!this.builderMode && this.component.modalEdit) {
|
@@ -416,7 +411,7 @@ class FormComponent extends Component_1.default {
|
|
416
411
|
lodash_1.default.assign(componentsMap, formComponentsMap);
|
417
412
|
this.component.components = this.subForm.components.map((comp) => comp.component);
|
418
413
|
this.subForm.on('change', () => {
|
419
|
-
if (this.subForm
|
414
|
+
if (this.subForm) {
|
420
415
|
this.dataValue = this.subForm.getValue();
|
421
416
|
this.triggerChange({
|
422
417
|
noEmit: true
|
@@ -684,7 +679,20 @@ class FormComponent extends Component_1.default {
|
|
684
679
|
}
|
685
680
|
}
|
686
681
|
isEmpty(value = this.dataValue) {
|
687
|
-
return value === null || lodash_1.default.isEqual(value, this.emptyValue);
|
682
|
+
return value === null || lodash_1.default.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value === null || value === void 0 ? void 0 : value.data) && !(value === null || value === void 0 ? void 0 : value._id));
|
683
|
+
}
|
684
|
+
areAllComponentsEmpty(data) {
|
685
|
+
let res = true;
|
686
|
+
if (this.subForm) {
|
687
|
+
this.subForm.everyComponent((comp) => {
|
688
|
+
const componentValue = lodash_1.default.get(data, comp.key);
|
689
|
+
res &= comp.isEmpty(componentValue);
|
690
|
+
});
|
691
|
+
}
|
692
|
+
else {
|
693
|
+
res = false;
|
694
|
+
}
|
695
|
+
return res;
|
688
696
|
}
|
689
697
|
getValue() {
|
690
698
|
if (this.subForm) {
|
@@ -26,8 +26,8 @@ export const getBestMatch: typeof Utils.getBestMatch;
|
|
26
26
|
export const getComponentFromPath: typeof Utils.getComponentFromPath;
|
27
27
|
export const getComponentValue: typeof Utils.getComponentValue;
|
28
28
|
export const findComponents: typeof Utils.findComponents;
|
29
|
-
export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?:
|
30
|
-
export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?:
|
29
|
+
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
|
30
|
+
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
|
31
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
32
32
|
export const getContextualRowPath: typeof Utils.getContextualRowPath;
|
33
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -34,6 +34,7 @@ const Evaluator_1 = require("./Evaluator");
|
|
34
34
|
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
35
35
|
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
36
36
|
exports.ConditionOperators = conditionOperators_1.default;
|
37
|
+
const core_1 = require("@formio/core");
|
37
38
|
const interpolate = Evaluator_1.Evaluator.interpolate;
|
38
39
|
exports.interpolate = interpolate;
|
39
40
|
__exportStar(require("./formUtils"), exports);
|
@@ -271,7 +272,7 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
271
272
|
default:
|
272
273
|
result = lodash_1.default.every(conditionsResult.flat(), res => !!res);
|
273
274
|
}
|
274
|
-
return show ? result : !result;
|
275
|
+
return (0, core_1.convertShowToBoolean)(show) ? result : !result;
|
275
276
|
}
|
276
277
|
}
|
277
278
|
exports.checkSimpleConditional = checkSimpleConditional;
|
@@ -163,22 +163,8 @@ declare class Component extends Element {
|
|
163
163
|
*/
|
164
164
|
info: any;
|
165
165
|
get componentsMap(): object;
|
166
|
-
/**
|
167
|
-
* Returns if the parent should conditionally clear.
|
168
|
-
* This method does not need to walk up the parent tree since the variables
|
169
|
-
* _conditionallyClear and _conditionallyHidden are set on the parent component
|
170
|
-
* before the child component is determined, and the parent component also references
|
171
|
-
* its parent component.
|
172
|
-
*
|
173
|
-
* @returns {boolean} - If the parent should conditionally clear.
|
174
|
-
*/
|
175
166
|
parentShouldConditionallyClear(): boolean;
|
176
167
|
parentConditionallyHidden(): boolean;
|
177
|
-
/**
|
178
|
-
* Returns true if any of the parents default their component "hidden" property to true.
|
179
|
-
* @returns {boolean} - If any parent defaults the hidden property to true.
|
180
|
-
*/
|
181
|
-
anyParentDefaultsHidden(): boolean;
|
182
168
|
set data(value: any);
|
183
169
|
get data(): any;
|
184
170
|
mergeSchema(component?: {}): any;
|
@@ -242,23 +228,8 @@ declare class Component extends Element {
|
|
242
228
|
get visible(): boolean;
|
243
229
|
get logicallyHidden(): any;
|
244
230
|
_logicallyHidden: any;
|
245
|
-
|
246
|
-
|
247
|
-
* @returns {boolean} - If the component should clear its value when the root form is pristine.
|
248
|
-
*/
|
249
|
-
shouldConditionallyClearOnPristine(): boolean;
|
250
|
-
/**
|
251
|
-
* Returns if the component should clear its value when conditionally hidden.
|
252
|
-
* @returns {boolean} - If the component should clear its value when conditionally hidden.
|
253
|
-
*/
|
254
|
-
shouldConditionallyClear(): boolean;
|
255
|
-
_conditionallyClear: boolean | undefined;
|
256
|
-
/**
|
257
|
-
* Returns if the component is conditionally hidden.
|
258
|
-
* @returns {boolean} - If the component is conditionally hidden.
|
259
|
-
*/
|
260
|
-
conditionallyHidden(): boolean;
|
261
|
-
_conditionallyHidden: boolean | undefined;
|
231
|
+
shouldConditionallyClear(skipParent?: boolean): boolean;
|
232
|
+
conditionallyHidden(skipParent?: boolean): boolean;
|
262
233
|
set currentForm(instance: any);
|
263
234
|
get currentForm(): any;
|
264
235
|
_currentForm: any;
|
@@ -422,20 +422,10 @@ export default class Component extends Element {
|
|
422
422
|
get componentsMap() {
|
423
423
|
return this.root?.childComponentsMap || {};
|
424
424
|
}
|
425
|
-
/**
|
426
|
-
* Returns if the parent should conditionally clear.
|
427
|
-
* This method does not need to walk up the parent tree since the variables
|
428
|
-
* _conditionallyClear and _conditionallyHidden are set on the parent component
|
429
|
-
* before the child component is determined, and the parent component also references
|
430
|
-
* its parent component.
|
431
|
-
*
|
432
|
-
* @returns {boolean} - If the parent should conditionally clear.
|
433
|
-
*/
|
434
425
|
parentShouldConditionallyClear() {
|
435
426
|
let currentParent = this.parent;
|
436
427
|
while (currentParent) {
|
437
|
-
if (
|
438
|
-
(!currentParent.allowData && currentParent._conditionallyHidden)) {
|
428
|
+
if (currentParent.shouldConditionallyClear(true)) {
|
439
429
|
return true;
|
440
430
|
}
|
441
431
|
currentParent = currentParent.parent;
|
@@ -445,21 +435,7 @@ export default class Component extends Element {
|
|
445
435
|
parentConditionallyHidden() {
|
446
436
|
let currentParent = this.parent;
|
447
437
|
while (currentParent) {
|
448
|
-
if (currentParent.
|
449
|
-
return true;
|
450
|
-
}
|
451
|
-
currentParent = currentParent.parent;
|
452
|
-
}
|
453
|
-
return false;
|
454
|
-
}
|
455
|
-
/**
|
456
|
-
* Returns true if any of the parents default their component "hidden" property to true.
|
457
|
-
* @returns {boolean} - If any parent defaults the hidden property to true.
|
458
|
-
*/
|
459
|
-
anyParentDefaultsHidden() {
|
460
|
-
let currentParent = this.parent;
|
461
|
-
while (currentParent) {
|
462
|
-
if (currentParent.component.hidden) {
|
438
|
+
if (currentParent.conditionallyHidden(true)) {
|
463
439
|
return true;
|
464
440
|
}
|
465
441
|
currentParent = currentParent.parent;
|
@@ -677,58 +653,48 @@ export default class Component extends Element {
|
|
677
653
|
}
|
678
654
|
return this._logicallyHidden;
|
679
655
|
}
|
680
|
-
|
681
|
-
* Determines if the component should clear its value when the root form is pristine.
|
682
|
-
* @returns {boolean} - If the component should clear its value when the root form is pristine.
|
683
|
-
*/
|
684
|
-
shouldConditionallyClearOnPristine() {
|
685
|
-
// If the form is pristine, we should NOT clear the value of a conditionally hidden child component
|
686
|
-
// of a layout component that defaults to hidden using the "hidden" component property.
|
687
|
-
return !this.anyParentDefaultsHidden();
|
688
|
-
}
|
689
|
-
/**
|
690
|
-
* Returns if the component should clear its value when conditionally hidden.
|
691
|
-
* @returns {boolean} - If the component should clear its value when conditionally hidden.
|
692
|
-
*/
|
693
|
-
shouldConditionallyClear() {
|
656
|
+
shouldConditionallyClear(skipParent = false) {
|
694
657
|
// Skip if this component has clearOnHide set to false.
|
695
658
|
if (this.component.clearOnHide === false) {
|
696
|
-
|
697
|
-
return this._conditionallyClear;
|
659
|
+
return false;
|
698
660
|
}
|
699
661
|
// If the component is logically hidden, then it is conditionally hidden and should clear.
|
700
662
|
if (this.logicallyHidden) {
|
701
|
-
|
702
|
-
return this._conditionallyClear;
|
663
|
+
return true;
|
703
664
|
}
|
704
665
|
// If we have a condition and it is not conditionally visible, the it should conditionally clear.
|
705
|
-
if (this.hasCondition() &&
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
666
|
+
if (this.hasCondition() && !this.conditionallyVisible()) {
|
667
|
+
return true;
|
668
|
+
}
|
669
|
+
if (skipParent) {
|
670
|
+
// Stop recurrsion for the parent checks.
|
671
|
+
return false;
|
672
|
+
}
|
673
|
+
// If this component has a set value, then it should ONLY clear if a parent is hidden
|
674
|
+
// and has the clearOnHide set to true.
|
675
|
+
if (this.hasSetValue) {
|
676
|
+
return this.parentShouldConditionallyClear();
|
710
677
|
}
|
711
|
-
|
712
|
-
return this.
|
678
|
+
// Clear the value if the parent is conditionally hidden.
|
679
|
+
return this.parentConditionallyHidden();
|
713
680
|
}
|
714
|
-
|
715
|
-
* Returns if the component is conditionally hidden.
|
716
|
-
* @returns {boolean} - If the component is conditionally hidden.
|
717
|
-
*/
|
718
|
-
conditionallyHidden() {
|
719
|
-
// If it is logically hidden, then it is conditionally hidden.
|
681
|
+
conditionallyHidden(skipParent = false) {
|
720
682
|
if (this.logicallyHidden) {
|
721
|
-
|
722
|
-
return this._conditionallyHidden;
|
683
|
+
return true;
|
723
684
|
}
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
685
|
+
if (!this.hasCondition() && !skipParent) {
|
686
|
+
return this.parentConditionallyHidden();
|
687
|
+
}
|
688
|
+
// Return if we are not conditionally visible (conditionallyHidden)
|
689
|
+
if (!this.conditionallyVisible()) {
|
690
|
+
return true;
|
691
|
+
}
|
692
|
+
if (skipParent) {
|
693
|
+
// Stop recurrsion for the parent checks.
|
694
|
+
return false;
|
728
695
|
}
|
729
|
-
//
|
730
|
-
|
731
|
-
return this._conditionallyHidden;
|
696
|
+
// Check the parent.
|
697
|
+
return this.parentConditionallyHidden();
|
732
698
|
}
|
733
699
|
get currentForm() {
|
734
700
|
return this._currentForm;
|
@@ -98,6 +98,7 @@ export default class FormComponent extends Component {
|
|
98
98
|
* @returns {void}
|
99
99
|
*/
|
100
100
|
onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
|
101
|
+
areAllComponentsEmpty(data: any): boolean;
|
101
102
|
updateSubFormVisibility(): void;
|
102
103
|
/**
|
103
104
|
* Determines if this form is a Nested Wizard
|
@@ -96,9 +96,6 @@ export default class FormComponent extends Component {
|
|
96
96
|
}
|
97
97
|
return this.createSubForm();
|
98
98
|
}
|
99
|
-
shouldConditionallyClearOnPristine() {
|
100
|
-
return !this.hasSetValue && super.shouldConditionallyClearOnPristine();
|
101
|
-
}
|
102
99
|
get dataReady() {
|
103
100
|
return this.subForm?.dataReady || this.subFormReady || Promise.resolve();
|
104
101
|
}
|
@@ -289,13 +286,11 @@ export default class FormComponent extends Component {
|
|
289
286
|
}
|
290
287
|
this.subForm.attach(element);
|
291
288
|
this.valueChanged = this.hasSetValue;
|
292
|
-
if (!this.
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
this.restoreValue();
|
298
|
-
}
|
289
|
+
if (!this.valueChanged && this.dataValue.state !== 'submitted') {
|
290
|
+
this.setDefaultValue();
|
291
|
+
}
|
292
|
+
else {
|
293
|
+
this.restoreValue();
|
299
294
|
}
|
300
295
|
}
|
301
296
|
if (!this.builderMode && this.component.modalEdit) {
|
@@ -410,7 +405,7 @@ export default class FormComponent extends Component {
|
|
410
405
|
_.assign(componentsMap, formComponentsMap);
|
411
406
|
this.component.components = this.subForm.components.map((comp) => comp.component);
|
412
407
|
this.subForm.on('change', () => {
|
413
|
-
if (this.subForm
|
408
|
+
if (this.subForm) {
|
414
409
|
this.dataValue = this.subForm.getValue();
|
415
410
|
this.triggerChange({
|
416
411
|
noEmit: true
|
@@ -673,7 +668,20 @@ export default class FormComponent extends Component {
|
|
673
668
|
}
|
674
669
|
}
|
675
670
|
isEmpty(value = this.dataValue) {
|
676
|
-
return value === null || _.isEqual(value, this.emptyValue);
|
671
|
+
return value === null || _.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value?.data) && !value?._id);
|
672
|
+
}
|
673
|
+
areAllComponentsEmpty(data) {
|
674
|
+
let res = true;
|
675
|
+
if (this.subForm) {
|
676
|
+
this.subForm.everyComponent((comp) => {
|
677
|
+
const componentValue = _.get(data, comp.key);
|
678
|
+
res &= comp.isEmpty(componentValue);
|
679
|
+
});
|
680
|
+
}
|
681
|
+
else {
|
682
|
+
res = false;
|
683
|
+
}
|
684
|
+
return res;
|
677
685
|
}
|
678
686
|
getValue() {
|
679
687
|
if (this.subForm) {
|
@@ -26,8 +26,8 @@ export const getBestMatch: typeof Utils.getBestMatch;
|
|
26
26
|
export const getComponentFromPath: typeof Utils.getComponentFromPath;
|
27
27
|
export const getComponentValue: typeof Utils.getComponentValue;
|
28
28
|
export const findComponents: typeof Utils.findComponents;
|
29
|
-
export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?:
|
30
|
-
export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?:
|
29
|
+
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
|
30
|
+
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
|
31
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
32
32
|
export const getContextualRowPath: typeof Utils.getContextualRowPath;
|
33
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -8,6 +8,7 @@ import dompurify from 'dompurify';
|
|
8
8
|
import { getValue } from './formUtils';
|
9
9
|
import { Evaluator } from './Evaluator';
|
10
10
|
import ConditionOperators from './conditionOperators';
|
11
|
+
import { convertShowToBoolean } from '@formio/core';
|
11
12
|
const interpolate = Evaluator.interpolate;
|
12
13
|
export * from './formUtils';
|
13
14
|
// Configure JsonLogic
|
@@ -236,7 +237,7 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
236
237
|
default:
|
237
238
|
result = _.every(conditionsResult.flat(), res => !!res);
|
238
239
|
}
|
239
|
-
return show ? result : !result;
|
240
|
+
return convertShowToBoolean(show) ? result : !result;
|
240
241
|
}
|
241
242
|
}
|
242
243
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.1.0-dev.
|
3
|
+
"version": "5.1.0-dev.6069.caec01d",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -81,7 +81,7 @@
|
|
81
81
|
"homepage": "https://github.com/formio/formio.js#readme",
|
82
82
|
"dependencies": {
|
83
83
|
"@formio/bootstrap": "v3.0.0-dev.121.085d187",
|
84
|
-
"@formio/core": "v2.4.0-dev.
|
84
|
+
"@formio/core": "v2.4.0-dev.232.d91b1e4",
|
85
85
|
"@formio/text-mask-addons": "3.8.0-formio.4",
|
86
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
87
87
|
"abortcontroller-polyfill": "^1.7.5",
|