@formio/js 5.0.0-dev.5826.02fa4d9 → 5.0.0-dev.5829.56191dc

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.
@@ -105,6 +105,7 @@ declare class Wizard extends Webform {
105
105
  pageId(page: any): any;
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
+ showErrors(errors: any, triggerEvent: any): void | any[];
108
109
  focusOnComponent(key: any): void | Promise<void>;
109
110
  }
110
111
  declare namespace Wizard {
package/lib/cjs/Wizard.js CHANGED
@@ -924,6 +924,17 @@ class Wizard extends Webform_1.default {
924
924
  }
925
925
  return super.errors;
926
926
  }
927
+ showErrors(errors, triggerEvent) {
928
+ if (this.hasExtraPages) {
929
+ this.subWizards.forEach((subWizard) => {
930
+ if (Array.isArray(subWizard.errors)) {
931
+ errors = [...errors, ...subWizard.errors];
932
+ }
933
+ });
934
+ }
935
+ ;
936
+ return super.showErrors(errors, triggerEvent);
937
+ }
927
938
  focusOnComponent(key) {
928
939
  const component = this.getComponent(key);
929
940
  if (component) {
@@ -931,7 +942,7 @@ class Wizard extends Webform_1.default {
931
942
  while (!(topPanel.parent instanceof Wizard)) {
932
943
  topPanel = topPanel.parent;
933
944
  }
934
- const pageIndex = this.pages.findIndex(page => page === topPanel);
945
+ const pageIndex = this.pages.findIndex(page => page.id === topPanel.id);
935
946
  if (pageIndex >= 0) {
936
947
  const page = this.pages[pageIndex];
937
948
  if (page && page !== this.currentPage) {
@@ -881,6 +881,11 @@ declare class Component extends Element {
881
881
  * @returns {boolean} - If the value changed.
882
882
  */
883
883
  setValue(value: any, flags?: any): boolean;
884
+ /**
885
+ * Returns if the value (e.g. array) should be divided between several inputs
886
+ * @returns {boolean}
887
+ */
888
+ isSingleInputValue(): boolean;
884
889
  /**
885
890
  * Set the value at a specific index.
886
891
  * @param {number} index - The index to set the value at.
@@ -2586,11 +2586,18 @@ class Component extends Element_1.default {
2586
2586
  }
2587
2587
  for (const i in this.refs.input) {
2588
2588
  if (this.refs.input.hasOwnProperty(i)) {
2589
- this.setValueAt(i, isArray ? value[i] : value, flags);
2589
+ this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
2590
2590
  }
2591
2591
  }
2592
2592
  return changed;
2593
2593
  }
2594
+ /**
2595
+ * Returns if the value (e.g. array) should be divided between several inputs
2596
+ * @returns {boolean}
2597
+ */
2598
+ isSingleInputValue() {
2599
+ return false;
2600
+ }
2594
2601
  /**
2595
2602
  * Set the value at a specific index.
2596
2603
  * @param {number} index - The index to set the value at.
@@ -19,6 +19,13 @@ export default class TextAreaComponent extends TextFieldComponent {
19
19
  setContent(element: any, content: any, forceSanitize: any): void;
20
20
  setReadOnlyValue(value: any, index: any): void;
21
21
  get isJsonValue(): any;
22
+ /**
23
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
24
+ * @param {*} value - The value to normalize
25
+ * @returns {*} - Returns the normalized value
26
+ */
27
+ normalizeValue(value: any): any;
28
+ normalizeSingleValue(value: any): any;
22
29
  setConvertedValue(value: any, index: any): any;
23
30
  setAsyncConvertedValue(value: any): Promise<any>;
24
31
  setImagesUrl(images: any): Promise<any>;
@@ -309,6 +309,26 @@ class TextAreaComponent extends TextField_1.default {
309
309
  get isJsonValue() {
310
310
  return this.component.as && this.component.as === 'json';
311
311
  }
312
+ /**
313
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
314
+ * @param {*} value - The value to normalize
315
+ * @returns {*} - Returns the normalized value
316
+ */
317
+ normalizeValue(value) {
318
+ if (this.component.multiple && Array.isArray(value)) {
319
+ return value.map((singleValue) => this.normalizeSingleValue(singleValue));
320
+ }
321
+ return super.normalizeValue(this.normalizeSingleValue(value));
322
+ }
323
+ normalizeSingleValue(value) {
324
+ if (lodash_1.default.isNil(value)) {
325
+ return;
326
+ }
327
+ return this.isJsonValue ? value : String(value);
328
+ }
329
+ isSingleInputValue() {
330
+ return !this.component.multiple;
331
+ }
312
332
  setConvertedValue(value, index) {
313
333
  if (this.isJsonValue && !lodash_1.default.isNil(value)) {
314
334
  try {
@@ -105,6 +105,7 @@ declare class Wizard extends Webform {
105
105
  pageId(page: any): any;
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
+ showErrors(errors: any, triggerEvent: any): void | any[];
108
109
  focusOnComponent(key: any): void | Promise<void>;
109
110
  }
110
111
  declare namespace Wizard {
package/lib/mjs/Wizard.js CHANGED
@@ -911,6 +911,17 @@ export default class Wizard extends Webform {
911
911
  }
912
912
  return super.errors;
913
913
  }
914
+ showErrors(errors, triggerEvent) {
915
+ if (this.hasExtraPages) {
916
+ this.subWizards.forEach((subWizard) => {
917
+ if (Array.isArray(subWizard.errors)) {
918
+ errors = [...errors, ...subWizard.errors];
919
+ }
920
+ });
921
+ }
922
+ ;
923
+ return super.showErrors(errors, triggerEvent);
924
+ }
914
925
  focusOnComponent(key) {
915
926
  const component = this.getComponent(key);
916
927
  if (component) {
@@ -918,7 +929,7 @@ export default class Wizard extends Webform {
918
929
  while (!(topPanel.parent instanceof Wizard)) {
919
930
  topPanel = topPanel.parent;
920
931
  }
921
- const pageIndex = this.pages.findIndex(page => page === topPanel);
932
+ const pageIndex = this.pages.findIndex(page => page.id === topPanel.id);
922
933
  if (pageIndex >= 0) {
923
934
  const page = this.pages[pageIndex];
924
935
  if (page && page !== this.currentPage) {
@@ -881,6 +881,11 @@ declare class Component extends Element {
881
881
  * @returns {boolean} - If the value changed.
882
882
  */
883
883
  setValue(value: any, flags?: any): boolean;
884
+ /**
885
+ * Returns if the value (e.g. array) should be divided between several inputs
886
+ * @returns {boolean}
887
+ */
888
+ isSingleInputValue(): boolean;
884
889
  /**
885
890
  * Set the value at a specific index.
886
891
  * @param {number} index - The index to set the value at.
@@ -2552,11 +2552,18 @@ export default class Component extends Element {
2552
2552
  }
2553
2553
  for (const i in this.refs.input) {
2554
2554
  if (this.refs.input.hasOwnProperty(i)) {
2555
- this.setValueAt(i, isArray ? value[i] : value, flags);
2555
+ this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
2556
2556
  }
2557
2557
  }
2558
2558
  return changed;
2559
2559
  }
2560
+ /**
2561
+ * Returns if the value (e.g. array) should be divided between several inputs
2562
+ * @returns {boolean}
2563
+ */
2564
+ isSingleInputValue() {
2565
+ return false;
2566
+ }
2560
2567
  /**
2561
2568
  * Set the value at a specific index.
2562
2569
  * @param {number} index - The index to set the value at.
@@ -19,6 +19,13 @@ export default class TextAreaComponent extends TextFieldComponent {
19
19
  setContent(element: any, content: any, forceSanitize: any): void;
20
20
  setReadOnlyValue(value: any, index: any): void;
21
21
  get isJsonValue(): any;
22
+ /**
23
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
24
+ * @param {*} value - The value to normalize
25
+ * @returns {*} - Returns the normalized value
26
+ */
27
+ normalizeValue(value: any): any;
28
+ normalizeSingleValue(value: any): any;
22
29
  setConvertedValue(value: any, index: any): any;
23
30
  setAsyncConvertedValue(value: any): Promise<any>;
24
31
  setImagesUrl(images: any): Promise<any>;
@@ -304,6 +304,26 @@ export default class TextAreaComponent extends TextFieldComponent {
304
304
  get isJsonValue() {
305
305
  return this.component.as && this.component.as === 'json';
306
306
  }
307
+ /**
308
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
309
+ * @param {*} value - The value to normalize
310
+ * @returns {*} - Returns the normalized value
311
+ */
312
+ normalizeValue(value) {
313
+ if (this.component.multiple && Array.isArray(value)) {
314
+ return value.map((singleValue) => this.normalizeSingleValue(singleValue));
315
+ }
316
+ return super.normalizeValue(this.normalizeSingleValue(value));
317
+ }
318
+ normalizeSingleValue(value) {
319
+ if (_.isNil(value)) {
320
+ return;
321
+ }
322
+ return this.isJsonValue ? value : String(value);
323
+ }
324
+ isSingleInputValue() {
325
+ return !this.component.multiple;
326
+ }
307
327
  setConvertedValue(value, index) {
308
328
  if (this.isJsonValue && !_.isNil(value)) {
309
329
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5826.02fa4d9",
3
+ "version": "5.0.0-dev.5829.56191dc",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -82,7 +82,7 @@
82
82
  "dependencies": {
83
83
  "@formio/bootstrap": "3.0.0-dev.98.17ba6ea",
84
84
  "@formio/choices.js": "^10.2.1",
85
- "@formio/core": "2.1.0-dev.146.e57530c",
85
+ "@formio/core": "v2.1.0-dev.156.78a83fd",
86
86
  "@formio/text-mask-addons": "^3.8.0-formio.2",
87
87
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
88
88
  "abortcontroller-polyfill": "^1.7.5",