@formio/js 5.0.0-dev.5947.acce78f → 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.
- package/dist/formio.form.js +9 -9
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +9 -9
- 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.d.ts +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +9 -7
- package/lib/cjs/components/form/Form.js +5 -4
- package/lib/cjs/components/html/HTML.js +15 -3
- package/lib/cjs/formio.form.js +1 -0
- 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.d.ts +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +9 -7
- package/lib/mjs/components/form/Form.js +5 -4
- package/lib/mjs/components/html/HTML.js +15 -3
- package/lib/mjs/formio.form.js +1 -0
- package/package.json +2 -2
@@ -81,17 +81,26 @@ 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
85
|
const forceShow = this.shouldForceShow();
|
85
86
|
const forceHide = this.shouldForceHide();
|
86
|
-
this.components.forEach(component => {
|
87
|
+
this.components.forEach((component) => {
|
87
88
|
// Set the parent visibility first since we may have nested components within nested components
|
88
89
|
// and they need to be able to determine their visibility based on the parent visibility.
|
89
90
|
component.parentVisible = isVisible;
|
90
|
-
|
91
|
-
|
91
|
+
component._parentConditionallyHidden = isConditionallyHidden;
|
92
|
+
let visible;
|
93
|
+
if (component.hasCondition()) {
|
94
|
+
component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
|
95
|
+
visible = !component.conditionallyHidden;
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
visible = !component.component.hidden;
|
99
|
+
}
|
100
|
+
if (forceShow || visible) {
|
92
101
|
component.visible = true;
|
93
102
|
}
|
94
|
-
else if (forceHide || !isVisible || !
|
103
|
+
else if (forceHide || !isVisible || !visible) {
|
95
104
|
component.visible = false;
|
96
105
|
}
|
97
106
|
// If hiding a nested component, clear all errors below.
|
@@ -100,7 +109,6 @@ export default class NestedComponent extends Field {
|
|
100
109
|
}
|
101
110
|
});
|
102
111
|
if (visibilityChanged) {
|
103
|
-
this.clearOnHide();
|
104
112
|
this.redraw();
|
105
113
|
}
|
106
114
|
}
|
@@ -365,6 +373,7 @@ export default class NestedComponent extends Field {
|
|
365
373
|
data = data || this.data;
|
366
374
|
options.parent = this;
|
367
375
|
options.parentVisible = this.visible;
|
376
|
+
options.parentConditionallyHidden = this.conditionallyHidden;
|
368
377
|
options.root = options?.root || this.root || this;
|
369
378
|
options.localRoot = this.localRoot;
|
370
379
|
options.skipInit = true;
|
@@ -623,7 +632,7 @@ export default class NestedComponent extends Field {
|
|
623
632
|
clearOnHide(show) {
|
624
633
|
super.clearOnHide(show);
|
625
634
|
if (this.component.clearOnHide) {
|
626
|
-
if (this.allowData && !this.hasValue() && !
|
635
|
+
if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
|
627
636
|
this.dataValue = this.defaultValue;
|
628
637
|
}
|
629
638
|
if (this.hasValue()) {
|
@@ -652,7 +661,7 @@ export default class NestedComponent extends Field {
|
|
652
661
|
}
|
653
662
|
calculateValue(data, flags, row) {
|
654
663
|
// Do not iterate into children and calculateValues if this nested component is conditionally hidden.
|
655
|
-
if (
|
664
|
+
if (this.conditionallyHidden) {
|
656
665
|
return false;
|
657
666
|
}
|
658
667
|
return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
|
@@ -69,7 +69,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
69
69
|
}
|
70
70
|
get dataValue() {
|
71
71
|
if (!this.key ||
|
72
|
-
(
|
72
|
+
(this.conditionallyHidden && this.component.clearOnHide)) {
|
73
73
|
return this.emptyValue;
|
74
74
|
}
|
75
75
|
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -43,7 +43,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
43
43
|
get defaultValue(): any[];
|
44
44
|
hasRemoveButtons(): boolean;
|
45
45
|
editRows: any;
|
46
|
-
checkRowVariableTypeComponents(editRow: any, rowIndex: any):
|
46
|
+
checkRowVariableTypeComponents(editRow: any, rowIndex: any): boolean;
|
47
47
|
setVariableTypeComponents(): void;
|
48
48
|
variableTypeComponentsIndexes: any[] | undefined;
|
49
49
|
isOpen(editRow: any): boolean;
|
@@ -289,12 +289,15 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
289
289
|
}
|
290
290
|
checkRowVariableTypeComponents(editRow, rowIndex) {
|
291
291
|
const rowComponents = editRow.components;
|
292
|
+
let typeChanged = false;
|
292
293
|
if (_.some(this.variableTypeComponentsIndexes, (compIndex) => {
|
293
294
|
const variableTypeComp = rowComponents[compIndex];
|
294
295
|
return variableTypeComp.type !== variableTypeComp.component.type;
|
295
296
|
})) {
|
296
297
|
editRow.components = this.createRowComponents(editRow.data, rowIndex, true);
|
298
|
+
typeChanged = true;
|
297
299
|
}
|
300
|
+
return typeChanged;
|
298
301
|
}
|
299
302
|
setVariableTypeComponents() {
|
300
303
|
//set components which type is changing within a row (e.g.,by mergeComponentSchema action)
|
@@ -943,8 +946,10 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
943
946
|
this.validateRow(editRow, false, false);
|
944
947
|
}
|
945
948
|
if (this.variableTypeComponentsIndexes.length) {
|
946
|
-
this.checkRowVariableTypeComponents(editRow, rowIndex);
|
947
|
-
|
949
|
+
const typeChanged = this.checkRowVariableTypeComponents(editRow, rowIndex);
|
950
|
+
if (typeChanged) {
|
951
|
+
this.redraw();
|
952
|
+
}
|
948
953
|
}
|
949
954
|
};
|
950
955
|
const comp = this.createComponent(_.assign({}, column, { row: options.row }), options, row, null, recreatePartially && currentRowComponents ? currentRowComponents[colIndex] : null);
|
@@ -1145,7 +1150,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
1145
1150
|
}
|
1146
1151
|
}
|
1147
1152
|
const changed = this.hasChanged(value, this.dataValue);
|
1148
|
-
if (this.parent
|
1153
|
+
if (this.parent) {
|
1149
1154
|
this.parent.checkComponentConditions();
|
1150
1155
|
}
|
1151
1156
|
this.dataValue = value;
|
@@ -1178,10 +1183,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
1178
1183
|
this.editRows = this.editRows.slice(0, dataLength);
|
1179
1184
|
this.openWhenEmpty();
|
1180
1185
|
this.updateOnChange(flags, changed);
|
1181
|
-
|
1182
|
-
if (!this.options.server) {
|
1183
|
-
this.checkData();
|
1184
|
-
}
|
1186
|
+
this.checkData();
|
1185
1187
|
this.changeState(changed, flags);
|
1186
1188
|
return changed;
|
1187
1189
|
}
|
@@ -421,10 +421,11 @@ export default class FormComponent extends Component {
|
|
421
421
|
return this.subFormReady;
|
422
422
|
}
|
423
423
|
hideSubmitButton(component) {
|
424
|
-
const isSubmitButton =
|
425
|
-
((component.action === 'submit') || !component.action);
|
424
|
+
const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
|
426
425
|
if (isSubmitButton) {
|
427
426
|
component.hidden = true;
|
427
|
+
// clearOnHide no longer clears from the JSON `hidden` flag, so we make the button conditionally hidden to clear its data
|
428
|
+
component.customConditional = 'show = false';
|
428
429
|
}
|
429
430
|
}
|
430
431
|
/**
|
@@ -433,7 +434,7 @@ export default class FormComponent extends Component {
|
|
433
434
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
434
435
|
*/
|
435
436
|
loadSubForm(fromAttach) {
|
436
|
-
if (this.builderMode || this.
|
437
|
+
if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
|
437
438
|
return Promise.resolve();
|
438
439
|
}
|
439
440
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -505,7 +506,7 @@ export default class FormComponent extends Component {
|
|
505
506
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
506
507
|
*/
|
507
508
|
get shouldSubmit() {
|
508
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.
|
509
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
509
510
|
}
|
510
511
|
/**
|
511
512
|
* 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
|
}
|
package/lib/mjs/formio.form.js
CHANGED
@@ -56,6 +56,7 @@ export function registerModule(mod, defaultFn = null, options = {}) {
|
|
56
56
|
case 'templates':
|
57
57
|
for (const framework of Object.keys(mod.templates)) {
|
58
58
|
Formio.Templates.extendTemplate(framework, mod.templates[framework]);
|
59
|
+
Formio.Templates.defaultTemplates = _.defaults(mod.templates[framework], Formio.Templates.defaultTemplates);
|
59
60
|
}
|
60
61
|
if (mod.templates[current]) {
|
61
62
|
Formio.Templates.current = mod.templates[current];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.0.0-dev.
|
3
|
+
"version": "5.0.0-dev.5948.072adfa",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -80,7 +80,7 @@
|
|
80
80
|
},
|
81
81
|
"homepage": "https://github.com/formio/formio.js#readme",
|
82
82
|
"dependencies": {
|
83
|
-
"@formio/bootstrap": "3.0.0-dev.
|
83
|
+
"@formio/bootstrap": "3.0.0-dev.118.f146cb4",
|
84
84
|
"@formio/choices.js": "^10.2.1",
|
85
85
|
"@formio/core": "2.1.0-dev.193.68cf8c3",
|
86
86
|
"@formio/text-mask-addons": "3.8.0-formio.4",
|