@formio/js 5.1.0-dev.6113.1a173e6 → 5.1.0-dev.6115.a496b38
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/input/Input.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -1
- package/lib/cjs/components/form/Form.js +13 -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/input/Input.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -1
- package/lib/mjs/components/form/Form.js +12 -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.
|
@@ -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);
|
@@ -278,6 +278,9 @@ class FormComponent extends Component_1.default {
|
|
278
278
|
if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
|
279
279
|
this.createSubForm(true);
|
280
280
|
}
|
281
|
+
if (!this.subFormReady) {
|
282
|
+
return Promise.resolve();
|
283
|
+
}
|
281
284
|
return this.subFormReady.then(() => {
|
282
285
|
this.empty(element);
|
283
286
|
if (this.options.builder) {
|
@@ -408,13 +411,15 @@ class FormComponent extends Component_1.default {
|
|
408
411
|
}
|
409
412
|
// Render the form.
|
410
413
|
return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
|
414
|
+
var _a, _b;
|
411
415
|
this.subForm = instance;
|
412
416
|
this.subForm.currentForm = this;
|
413
417
|
this.subForm.parentVisible = this.visible;
|
414
418
|
const componentsMap = this.componentsMap;
|
415
419
|
const formComponentsMap = this.subForm.componentsMap;
|
416
420
|
lodash_1.default.assign(componentsMap, formComponentsMap);
|
417
|
-
this.component.components = this.subForm.
|
421
|
+
this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
|
422
|
+
this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
|
418
423
|
this.subForm.on('change', () => {
|
419
424
|
if (this.subForm && !this.shouldConditionallyClear()) {
|
420
425
|
this.dataValue = this.subForm.getValue();
|
@@ -699,6 +704,13 @@ class FormComponent extends Component_1.default {
|
|
699
704
|
}
|
700
705
|
return errors;
|
701
706
|
}
|
707
|
+
conditionallyHidden() {
|
708
|
+
const conditionallyHidden = super.conditionallyHidden();
|
709
|
+
if (this.subForm) {
|
710
|
+
this.subForm._conditionallyHidden = conditionallyHidden;
|
711
|
+
}
|
712
|
+
return conditionallyHidden;
|
713
|
+
}
|
702
714
|
updateSubFormVisibility() {
|
703
715
|
if (this.subForm) {
|
704
716
|
this.subForm.parentVisible = this.visible;
|
@@ -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.
|
@@ -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);
|
@@ -274,6 +274,9 @@ export default class FormComponent extends Component {
|
|
274
274
|
if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
|
275
275
|
this.createSubForm(true);
|
276
276
|
}
|
277
|
+
if (!this.subFormReady) {
|
278
|
+
return Promise.resolve();
|
279
|
+
}
|
277
280
|
return this.subFormReady.then(() => {
|
278
281
|
this.empty(element);
|
279
282
|
if (this.options.builder) {
|
@@ -408,7 +411,8 @@ export default class FormComponent extends Component {
|
|
408
411
|
const componentsMap = this.componentsMap;
|
409
412
|
const formComponentsMap = this.subForm.componentsMap;
|
410
413
|
_.assign(componentsMap, formComponentsMap);
|
411
|
-
this.component.components = this.subForm.components
|
414
|
+
this.component.components = this.subForm._form?.components;
|
415
|
+
this.component.display = this.subForm._form?.display;
|
412
416
|
this.subForm.on('change', () => {
|
413
417
|
if (this.subForm && !this.shouldConditionallyClear()) {
|
414
418
|
this.dataValue = this.subForm.getValue();
|
@@ -688,6 +692,13 @@ export default class FormComponent extends Component {
|
|
688
692
|
}
|
689
693
|
return errors;
|
690
694
|
}
|
695
|
+
conditionallyHidden() {
|
696
|
+
const conditionallyHidden = super.conditionallyHidden();
|
697
|
+
if (this.subForm) {
|
698
|
+
this.subForm._conditionallyHidden = conditionallyHidden;
|
699
|
+
}
|
700
|
+
return conditionallyHidden;
|
701
|
+
}
|
691
702
|
updateSubFormVisibility() {
|
692
703
|
if (this.subForm) {
|
693
704
|
this.subForm.parentVisible = this.visible;
|
@@ -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
|
}
|