@formio/js 5.0.0-dev.5913.cb0bb4a → 5.0.0-dev.5913.cf6760f

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.
@@ -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 hasExtraPages(): boolean;
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.hasExtraPages ? this.components : this.pages;
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 hasExtraPages() {
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.key) {
189
+ if (this.component.id) {
191
190
  ctx.panels.map(panel => {
192
- if (panel.key === this.component.key && panel.title === this.component.title) {
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.hasExtraPages) {
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) {
@@ -862,33 +861,25 @@ class Wizard extends Webform_1.default {
862
861
  }
863
862
  }
864
863
  onChange(flags, changed, modified, changes) {
865
- var _a, _b;
864
+ var _a;
866
865
  super.onChange(flags, changed, modified, changes);
867
866
  const errors = this.validate(this.localData, { dirty: false });
868
867
  if (this.alert) {
869
868
  this.showErrors(errors, true, true);
870
869
  }
871
870
  // If the pages change, need to redraw the header.
872
- let currentPanels;
873
- let panels;
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
- if (this.hasExtraPages) {
876
- currentPanels = this.pages.map(page => page.component.key);
877
- this.establishPages();
878
- panels = this.pages.map(page => page.component.key);
879
- if (panels.length !== currentPanels.length) {
880
- this.setPage(this.pages.findIndex(page => page.component.title === this.currentPanel.components[0].label));
881
- }
882
- }
883
- else {
884
- currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
885
- panels = this.establishPages().map(panel => panel.key);
886
- this.currentPanels = panels;
887
- if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.key) && ((_b = this.currentPanels) === null || _b === void 0 ? void 0 : _b.length)) {
888
- this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
889
- }
876
+ const panelsUpdated = !lodash_1.default.isEqual(newPanels, currentPanels);
877
+ if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.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);
890
881
  }
891
- if (!lodash_1.default.isEqual(panels, currentPanels) || (flags && flags.fromSubmission)) {
882
+ if (panelsUpdated || (flags && flags.fromSubmission)) {
892
883
  this.redrawHeader();
893
884
  }
894
885
  // If the next page changes, then make sure to redraw navigation.
@@ -928,7 +919,7 @@ class Wizard extends Webform_1.default {
928
919
  return super.errors;
929
920
  }
930
921
  showErrors(errors, triggerEvent) {
931
- if (this.hasExtraPages) {
922
+ if (this.hasSubWizards) {
932
923
  this.subWizards.forEach((subWizard) => {
933
924
  if (Array.isArray(subWizard.errors)) {
934
925
  errors = [...errors, ...subWizard.errors];
@@ -2516,7 +2516,7 @@ class Component extends Element_1.default {
2516
2516
  }
2517
2517
  return value;
2518
2518
  };
2519
- if (this.defaultMask) {
2519
+ if (Array.isArray(this.defaultMask) ? this.defaultMask.length > 0 : this.defaultMask) {
2520
2520
  if (Array.isArray(defaultValue)) {
2521
2521
  defaultValue = defaultValue.map(checkMask);
2522
2522
  }
@@ -27,7 +27,7 @@ exports.default = [
27
27
  weight: 100,
28
28
  type: 'checkbox',
29
29
  label: 'Validate When Hidden',
30
- tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission.',
30
+ tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission. Use caution when enabling this setting, as it can cause a hidden component to be invalid with no way for the form user to correct it.',
31
31
  key: 'validateWhenHidden',
32
32
  input: true
33
33
  },
@@ -685,7 +685,7 @@ class NestedComponent extends Field_1.default {
685
685
  validationProcessor({ scope, data, row, instance, component }, flags) {
686
686
  var _a;
687
687
  const { dirty } = flags;
688
- if (this.root.hasExtraPages && this.page !== this.root.page) {
688
+ if (this.root.hasSubWizards && this.page !== this.root.page) {
689
689
  instance = ((_a = this.childComponentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(component.path))
690
690
  ? this.childComponentsMap[component.path]
691
691
  : this.getComponent(component.path);
@@ -267,6 +267,7 @@ class SelectBoxesComponent extends Radio_1.default {
267
267
  else {
268
268
  return super.setCustomValidity(messages, dirty, external);
269
269
  }
270
+ ;
270
271
  }
271
272
  validateValueAvailability(setting, value) {
272
273
  if (!(0, utils_1.boolValue)(setting) || !value) {
@@ -159,7 +159,9 @@ class SignatureComponent extends Input_1.default {
159
159
  if (this.dataValue) {
160
160
  this.setDataToSigaturePad();
161
161
  }
162
- this.showCanvas(true);
162
+ if (!this.disabled) {
163
+ this.showCanvas(true);
164
+ }
163
165
  }
164
166
  }
165
167
  renderElement(value, index) {
@@ -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 hasExtraPages(): boolean;
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.hasExtraPages ? this.components : this.pages;
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 hasExtraPages() {
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.key) {
179
+ if (this.component.id) {
181
180
  ctx.panels.map(panel => {
182
- if (panel.key === this.component.key && panel.title === this.component.title) {
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.hasExtraPages) {
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) {
@@ -857,26 +856,18 @@ export default class Wizard extends Webform {
857
856
  this.showErrors(errors, true, true);
858
857
  }
859
858
  // If the pages change, need to redraw the header.
860
- let currentPanels;
861
- let panels;
859
+ const currentPanels = this.pages;
860
+ // calling this.establishPages() updates/mutates this.pages to be the current pages
861
+ this.establishPages();
862
+ const newPanels = this.pages;
862
863
  const currentNextPage = this.currentNextPage;
863
- if (this.hasExtraPages) {
864
- currentPanels = this.pages.map(page => page.component.key);
865
- this.establishPages();
866
- panels = this.pages.map(page => page.component.key);
867
- if (panels.length !== currentPanels.length) {
868
- this.setPage(this.pages.findIndex(page => page.component.title === this.currentPanel.components[0].label));
869
- }
870
- }
871
- else {
872
- currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
873
- panels = this.establishPages().map(panel => panel.key);
874
- this.currentPanels = panels;
875
- if (this.currentPanel?.key && this.currentPanels?.length) {
876
- this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
877
- }
864
+ const panelsUpdated = !_.isEqual(newPanels, currentPanels);
865
+ if (this.currentPanel?.id && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
866
+ const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
867
+ if (newIndex !== -1)
868
+ this.setPage(newIndex);
878
869
  }
879
- if (!_.isEqual(panels, currentPanels) || (flags && flags.fromSubmission)) {
870
+ if (panelsUpdated || (flags && flags.fromSubmission)) {
880
871
  this.redrawHeader();
881
872
  }
882
873
  // If the next page changes, then make sure to redraw navigation.
@@ -915,7 +906,7 @@ export default class Wizard extends Webform {
915
906
  return super.errors;
916
907
  }
917
908
  showErrors(errors, triggerEvent) {
918
- if (this.hasExtraPages) {
909
+ if (this.hasSubWizards) {
919
910
  this.subWizards.forEach((subWizard) => {
920
911
  if (Array.isArray(subWizard.errors)) {
921
912
  errors = [...errors, ...subWizard.errors];
@@ -2482,7 +2482,7 @@ export default class Component extends Element {
2482
2482
  }
2483
2483
  return value;
2484
2484
  };
2485
- if (this.defaultMask) {
2485
+ if (Array.isArray(this.defaultMask) ? this.defaultMask.length > 0 : this.defaultMask) {
2486
2486
  if (Array.isArray(defaultValue)) {
2487
2487
  defaultValue = defaultValue.map(checkMask);
2488
2488
  }
@@ -22,7 +22,7 @@ export default [
22
22
  weight: 100,
23
23
  type: 'checkbox',
24
24
  label: 'Validate When Hidden',
25
- tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission.',
25
+ tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission. Use caution when enabling this setting, as it can cause a hidden component to be invalid with no way for the form user to correct it.',
26
26
  key: 'validateWhenHidden',
27
27
  input: true
28
28
  },
@@ -680,7 +680,7 @@ export default class NestedComponent extends Field {
680
680
  }
681
681
  validationProcessor({ scope, data, row, instance, component }, flags) {
682
682
  const { dirty } = flags;
683
- if (this.root.hasExtraPages && this.page !== this.root.page) {
683
+ if (this.root.hasSubWizards && this.page !== this.root.page) {
684
684
  instance = this.childComponentsMap?.hasOwnProperty(component.path)
685
685
  ? this.childComponentsMap[component.path]
686
686
  : this.getComponent(component.path);
@@ -268,6 +268,7 @@ export default class SelectBoxesComponent extends RadioComponent {
268
268
  else {
269
269
  return super.setCustomValidity(messages, dirty, external);
270
270
  }
271
+ ;
271
272
  }
272
273
  validateValueAvailability(setting, value) {
273
274
  if (!boolValue(setting) || !value) {
@@ -156,7 +156,9 @@ export default class SignatureComponent extends Input {
156
156
  if (this.dataValue) {
157
157
  this.setDataToSigaturePad();
158
158
  }
159
- this.showCanvas(true);
159
+ if (!this.disabled) {
160
+ this.showCanvas(true);
161
+ }
160
162
  }
161
163
  }
162
164
  renderElement(value, index) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5913.cb0bb4a",
3
+ "version": "5.0.0-dev.5913.cf6760f",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {