@formio/js 5.1.0-dev.6113.1a173e6 → 5.1.0-dev.6114.02b6d9c
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 +5 -5
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +5 -5
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/Wizard.d.ts +1 -2
- package/lib/cjs/Wizard.js +17 -23
- package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/cjs/components/_classes/component/Component.js +4 -2
- package/lib/cjs/components/_classes/input/Input.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -1
- package/lib/cjs/components/textfield/TextField.js +1 -6
- package/lib/mjs/Wizard.d.ts +1 -2
- package/lib/mjs/Wizard.js +16 -22
- package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/mjs/components/_classes/component/Component.js +4 -2
- package/lib/mjs/components/_classes/input/Input.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -1
- package/lib/mjs/components/textfield/TextField.js +1 -6
- package/package.json +1 -1
package/lib/cjs/Wizard.d.ts
CHANGED
@@ -6,7 +6,6 @@ declare class Wizard extends Webform {
|
|
6
6
|
originalComponents: any[];
|
7
7
|
page: number;
|
8
8
|
currentPanel: any;
|
9
|
-
currentPanels: any[] | null;
|
10
9
|
currentNextPage: number;
|
11
10
|
_seenPages: number[];
|
12
11
|
subWizards: any[];
|
@@ -17,7 +16,7 @@ declare class Wizard extends Webform {
|
|
17
16
|
originalOptions: any;
|
18
17
|
isLastPage(): any;
|
19
18
|
getPages(args?: {}): any[];
|
20
|
-
get
|
19
|
+
get hasSubWizards(): boolean;
|
21
20
|
get localData(): any;
|
22
21
|
get wizardKey(): string;
|
23
22
|
set wizard(form: object);
|
package/lib/cjs/Wizard.js
CHANGED
@@ -34,7 +34,6 @@ class Wizard extends Webform_1.default {
|
|
34
34
|
this.originalComponents = [];
|
35
35
|
this.page = 0;
|
36
36
|
this.currentPanel = null;
|
37
|
-
this.currentPanels = null;
|
38
37
|
this.currentNextPage = 0;
|
39
38
|
this._seenPages = [0];
|
40
39
|
this.subWizards = [];
|
@@ -53,12 +52,12 @@ class Wizard extends Webform_1.default {
|
|
53
52
|
}
|
54
53
|
getPages(args = {}) {
|
55
54
|
const { all = false } = args;
|
56
|
-
const pages = this.
|
55
|
+
const pages = this.hasSubWizards ? this.components : this.pages;
|
57
56
|
const filteredPages = pages
|
58
57
|
.filter(all ? lodash_1.default.identity : (p, index) => this._seenPages.includes(index));
|
59
58
|
return filteredPages;
|
60
59
|
}
|
61
|
-
get
|
60
|
+
get hasSubWizards() {
|
62
61
|
return !lodash_1.default.isEmpty(this.subWizards);
|
63
62
|
}
|
64
63
|
get data() {
|
@@ -187,9 +186,9 @@ class Wizard extends Webform_1.default {
|
|
187
186
|
}
|
188
187
|
render() {
|
189
188
|
const ctx = this.renderContext;
|
190
|
-
if (this.component.
|
191
|
-
ctx.panels.
|
192
|
-
if (panel.
|
189
|
+
if (this.component.id) {
|
190
|
+
ctx.panels.forEach(panel => {
|
191
|
+
if (panel.id === this.component.id) {
|
193
192
|
this.currentPanel = panel;
|
194
193
|
ctx.wizardPageTooltip = this.getFormattedTooltip(panel.tooltip);
|
195
194
|
}
|
@@ -587,7 +586,7 @@ class Wizard extends Webform_1.default {
|
|
587
586
|
this.pageFieldLogic(num);
|
588
587
|
this.getNextPage();
|
589
588
|
let parentNum = num;
|
590
|
-
if (this.
|
589
|
+
if (this.hasSubWizards) {
|
591
590
|
const pageFromPages = this.pages[num];
|
592
591
|
const pageFromComponents = this.components[num];
|
593
592
|
if (!pageFromComponents || (pageFromPages === null || pageFromPages === void 0 ? void 0 : pageFromPages.id) !== pageFromComponents.id) {
|
@@ -873,7 +872,7 @@ class Wizard extends Webform_1.default {
|
|
873
872
|
}
|
874
873
|
}
|
875
874
|
onChange(flags, changed, modified, changes) {
|
876
|
-
var _a
|
875
|
+
var _a;
|
877
876
|
super.onChange(flags, changed, modified, changes);
|
878
877
|
// The onChange loop doesn't need all components for wizards
|
879
878
|
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
@@ -881,23 +880,18 @@ class Wizard extends Webform_1.default {
|
|
881
880
|
this.showErrors(errors, true, true);
|
882
881
|
}
|
883
882
|
// If the pages change, need to redraw the header.
|
884
|
-
|
885
|
-
|
883
|
+
const currentPanels = this.pages;
|
884
|
+
// calling this.establishPages() updates/mutates this.pages to be the current pages
|
885
|
+
this.establishPages();
|
886
|
+
const newPanels = this.pages;
|
886
887
|
const currentNextPage = this.currentNextPage;
|
887
|
-
|
888
|
-
|
889
|
-
this.
|
890
|
-
|
891
|
-
|
892
|
-
else {
|
893
|
-
currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
|
894
|
-
panels = this.establishPages().map(panel => panel.key);
|
895
|
-
this.currentPanels = panels;
|
896
|
-
if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.key) && ((_b = this.currentPanels) === null || _b === void 0 ? void 0 : _b.length)) {
|
897
|
-
this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
|
898
|
-
}
|
888
|
+
const panelsUpdated = !lodash_1.default.isEqual(newPanels, currentPanels);
|
889
|
+
if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.id) && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
|
890
|
+
const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
|
891
|
+
if (newIndex !== -1)
|
892
|
+
this.setPage(newIndex);
|
899
893
|
}
|
900
|
-
if (
|
894
|
+
if (panelsUpdated || (flags && flags.fromSubmission)) {
|
901
895
|
this.redrawHeader();
|
902
896
|
}
|
903
897
|
// If the next page changes, then make sure to redraw navigation.
|
@@ -165,7 +165,6 @@ declare class Component extends Element {
|
|
165
165
|
get componentsMap(): object;
|
166
166
|
/**
|
167
167
|
* Returns if the parent should conditionally clear.
|
168
|
-
*
|
169
168
|
* @returns {boolean} - If the parent should conditionally clear.
|
170
169
|
*/
|
171
170
|
parentShouldConditionallyClear(): boolean;
|
@@ -460,7 +460,6 @@ class Component extends Element_1.default {
|
|
460
460
|
}
|
461
461
|
/**
|
462
462
|
* Returns if the parent should conditionally clear.
|
463
|
-
*
|
464
463
|
* @returns {boolean} - If the parent should conditionally clear.
|
465
464
|
*/
|
466
465
|
parentShouldConditionallyClear() {
|
@@ -2714,13 +2713,16 @@ class Component extends Element_1.default {
|
|
2714
2713
|
}
|
2715
2714
|
const isArray = Array.isArray(value);
|
2716
2715
|
const valueInput = this.refs.fileLink || this.refs.input;
|
2716
|
+
const isFilelink = !!this.refs.fileLink;
|
2717
2717
|
if (isArray &&
|
2718
2718
|
Array.isArray(this.defaultValue) &&
|
2719
2719
|
this.refs.hasOwnProperty('input') &&
|
2720
2720
|
valueInput &&
|
2721
2721
|
(valueInput.length !== value.length) &&
|
2722
2722
|
this.visible) {
|
2723
|
-
|
2723
|
+
if (isFilelink || valueInput.length) {
|
2724
|
+
this.redraw();
|
2725
|
+
}
|
2724
2726
|
}
|
2725
2727
|
if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
|
2726
2728
|
this.redraw();
|
@@ -118,7 +118,7 @@ class Input extends Multivalue_1.default {
|
|
118
118
|
}
|
119
119
|
const info = this.inputInfo;
|
120
120
|
info.attr = info.attr || {};
|
121
|
-
info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(
|
121
|
+
info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(value)))
|
122
122
|
.replace(/"/g, '"');
|
123
123
|
const valueMask = this.component.inputMask;
|
124
124
|
const displayMask = this.component.displayMask;
|
@@ -664,7 +664,7 @@ class NestedComponent extends Field_1.default {
|
|
664
664
|
validationProcessor({ scope, data, row, instance, paths }, flags) {
|
665
665
|
var _a;
|
666
666
|
const { dirty } = flags;
|
667
|
-
if (this.root.
|
667
|
+
if (this.root.hasSubWizards && this.page !== this.root.page) {
|
668
668
|
instance = ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(paths.dataPath))
|
669
669
|
? this.componentsMap[paths.dataPath]
|
670
670
|
: this.getComponent(paths.dataPath);
|
@@ -130,12 +130,7 @@ class TextFieldComponent extends Input_1.default {
|
|
130
130
|
// If no value is provided, then set the defaultValue.
|
131
131
|
if (!value.value) {
|
132
132
|
const defaultValue = flags.noDefault ? this.emptyValue : this.defaultValue;
|
133
|
-
|
134
|
-
value.value = lodash_1.default.isObject(defaultValue[0]) ? defaultValue[0].value : defaultValue;
|
135
|
-
}
|
136
|
-
else {
|
137
|
-
value.value = lodash_1.default.isObject(defaultValue) ? defaultValue.value : defaultValue;
|
138
|
-
}
|
133
|
+
value.value = Array.isArray(defaultValue) ? defaultValue[0] : defaultValue;
|
139
134
|
}
|
140
135
|
return value;
|
141
136
|
}
|
package/lib/mjs/Wizard.d.ts
CHANGED
@@ -6,7 +6,6 @@ declare class Wizard extends Webform {
|
|
6
6
|
originalComponents: any[];
|
7
7
|
page: number;
|
8
8
|
currentPanel: any;
|
9
|
-
currentPanels: any[] | null;
|
10
9
|
currentNextPage: number;
|
11
10
|
_seenPages: number[];
|
12
11
|
subWizards: any[];
|
@@ -17,7 +16,7 @@ declare class Wizard extends Webform {
|
|
17
16
|
originalOptions: any;
|
18
17
|
isLastPage(): any;
|
19
18
|
getPages(args?: {}): any[];
|
20
|
-
get
|
19
|
+
get hasSubWizards(): boolean;
|
21
20
|
get localData(): any;
|
22
21
|
get wizardKey(): string;
|
23
22
|
set wizard(form: object);
|
package/lib/mjs/Wizard.js
CHANGED
@@ -29,7 +29,6 @@ export default class Wizard extends Webform {
|
|
29
29
|
this.originalComponents = [];
|
30
30
|
this.page = 0;
|
31
31
|
this.currentPanel = null;
|
32
|
-
this.currentPanels = null;
|
33
32
|
this.currentNextPage = 0;
|
34
33
|
this._seenPages = [0];
|
35
34
|
this.subWizards = [];
|
@@ -48,12 +47,12 @@ export default class Wizard extends Webform {
|
|
48
47
|
}
|
49
48
|
getPages(args = {}) {
|
50
49
|
const { all = false } = args;
|
51
|
-
const pages = this.
|
50
|
+
const pages = this.hasSubWizards ? this.components : this.pages;
|
52
51
|
const filteredPages = pages
|
53
52
|
.filter(all ? _.identity : (p, index) => this._seenPages.includes(index));
|
54
53
|
return filteredPages;
|
55
54
|
}
|
56
|
-
get
|
55
|
+
get hasSubWizards() {
|
57
56
|
return !_.isEmpty(this.subWizards);
|
58
57
|
}
|
59
58
|
get data() {
|
@@ -177,9 +176,9 @@ export default class Wizard extends Webform {
|
|
177
176
|
}
|
178
177
|
render() {
|
179
178
|
const ctx = this.renderContext;
|
180
|
-
if (this.component.
|
181
|
-
ctx.panels.
|
182
|
-
if (panel.
|
179
|
+
if (this.component.id) {
|
180
|
+
ctx.panels.forEach(panel => {
|
181
|
+
if (panel.id === this.component.id) {
|
183
182
|
this.currentPanel = panel;
|
184
183
|
ctx.wizardPageTooltip = this.getFormattedTooltip(panel.tooltip);
|
185
184
|
}
|
@@ -580,7 +579,7 @@ export default class Wizard extends Webform {
|
|
580
579
|
this.pageFieldLogic(num);
|
581
580
|
this.getNextPage();
|
582
581
|
let parentNum = num;
|
583
|
-
if (this.
|
582
|
+
if (this.hasSubWizards) {
|
584
583
|
const pageFromPages = this.pages[num];
|
585
584
|
const pageFromComponents = this.components[num];
|
586
585
|
if (!pageFromComponents || pageFromPages?.id !== pageFromComponents.id) {
|
@@ -869,23 +868,18 @@ export default class Wizard extends Webform {
|
|
869
868
|
this.showErrors(errors, true, true);
|
870
869
|
}
|
871
870
|
// If the pages change, need to redraw the header.
|
872
|
-
|
873
|
-
|
871
|
+
const currentPanels = this.pages;
|
872
|
+
// calling this.establishPages() updates/mutates this.pages to be the current pages
|
873
|
+
this.establishPages();
|
874
|
+
const newPanels = this.pages;
|
874
875
|
const currentNextPage = this.currentNextPage;
|
875
|
-
|
876
|
-
|
877
|
-
this.
|
878
|
-
|
879
|
-
|
880
|
-
else {
|
881
|
-
currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
|
882
|
-
panels = this.establishPages().map(panel => panel.key);
|
883
|
-
this.currentPanels = panels;
|
884
|
-
if (this.currentPanel?.key && this.currentPanels?.length) {
|
885
|
-
this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
|
886
|
-
}
|
876
|
+
const panelsUpdated = !_.isEqual(newPanels, currentPanels);
|
877
|
+
if (this.currentPanel?.id && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
|
878
|
+
const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
|
879
|
+
if (newIndex !== -1)
|
880
|
+
this.setPage(newIndex);
|
887
881
|
}
|
888
|
-
if (
|
882
|
+
if (panelsUpdated || (flags && flags.fromSubmission)) {
|
889
883
|
this.redrawHeader();
|
890
884
|
}
|
891
885
|
// If the next page changes, then make sure to redraw navigation.
|
@@ -165,7 +165,6 @@ declare class Component extends Element {
|
|
165
165
|
get componentsMap(): object;
|
166
166
|
/**
|
167
167
|
* Returns if the parent should conditionally clear.
|
168
|
-
*
|
169
168
|
* @returns {boolean} - If the parent should conditionally clear.
|
170
169
|
*/
|
171
170
|
parentShouldConditionallyClear(): boolean;
|
@@ -424,7 +424,6 @@ export default class Component extends Element {
|
|
424
424
|
}
|
425
425
|
/**
|
426
426
|
* Returns if the parent should conditionally clear.
|
427
|
-
*
|
428
427
|
* @returns {boolean} - If the parent should conditionally clear.
|
429
428
|
*/
|
430
429
|
parentShouldConditionallyClear() {
|
@@ -2683,13 +2682,16 @@ export default class Component extends Element {
|
|
2683
2682
|
}
|
2684
2683
|
const isArray = Array.isArray(value);
|
2685
2684
|
const valueInput = this.refs.fileLink || this.refs.input;
|
2685
|
+
const isFilelink = !!this.refs.fileLink;
|
2686
2686
|
if (isArray &&
|
2687
2687
|
Array.isArray(this.defaultValue) &&
|
2688
2688
|
this.refs.hasOwnProperty('input') &&
|
2689
2689
|
valueInput &&
|
2690
2690
|
(valueInput.length !== value.length) &&
|
2691
2691
|
this.visible) {
|
2692
|
-
|
2692
|
+
if (isFilelink || valueInput.length) {
|
2693
|
+
this.redraw();
|
2694
|
+
}
|
2693
2695
|
}
|
2694
2696
|
if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
|
2695
2697
|
this.redraw();
|
@@ -113,7 +113,7 @@ export default class Input extends Multivalue {
|
|
113
113
|
}
|
114
114
|
const info = this.inputInfo;
|
115
115
|
info.attr = info.attr || {};
|
116
|
-
info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(
|
116
|
+
info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(value)))
|
117
117
|
.replace(/"/g, '"');
|
118
118
|
const valueMask = this.component.inputMask;
|
119
119
|
const displayMask = this.component.displayMask;
|
@@ -659,7 +659,7 @@ export default class NestedComponent extends Field {
|
|
659
659
|
}
|
660
660
|
validationProcessor({ scope, data, row, instance, paths }, flags) {
|
661
661
|
const { dirty } = flags;
|
662
|
-
if (this.root.
|
662
|
+
if (this.root.hasSubWizards && this.page !== this.root.page) {
|
663
663
|
instance = this.componentsMap?.hasOwnProperty(paths.dataPath)
|
664
664
|
? this.componentsMap[paths.dataPath]
|
665
665
|
: this.getComponent(paths.dataPath);
|
@@ -114,12 +114,7 @@ export default class TextFieldComponent extends Input {
|
|
114
114
|
// If no value is provided, then set the defaultValue.
|
115
115
|
if (!value.value) {
|
116
116
|
const defaultValue = flags.noDefault ? this.emptyValue : this.defaultValue;
|
117
|
-
|
118
|
-
value.value = _.isObject(defaultValue[0]) ? defaultValue[0].value : defaultValue;
|
119
|
-
}
|
120
|
-
else {
|
121
|
-
value.value = _.isObject(defaultValue) ? defaultValue.value : defaultValue;
|
122
|
-
}
|
117
|
+
value.value = Array.isArray(defaultValue) ? defaultValue[0] : defaultValue;
|
123
118
|
}
|
124
119
|
return value;
|
125
120
|
}
|