@formio/js 5.0.0-rc.86 → 5.0.0-rc.87

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.
Files changed (36) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +43 -13
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.full.js +23 -13
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  10. package/dist/formio.js +3 -3
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +37 -7
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  16. package/lib/cjs/Webform.js +1 -1
  17. package/lib/cjs/Wizard.d.ts +1 -0
  18. package/lib/cjs/Wizard.js +12 -1
  19. package/lib/cjs/components/_classes/component/Component.d.ts +5 -0
  20. package/lib/cjs/components/_classes/component/Component.js +8 -1
  21. package/lib/cjs/components/datagrid/fixtures/comp10.d.ts +81 -0
  22. package/lib/cjs/components/datagrid/fixtures/comp10.js +87 -0
  23. package/lib/cjs/components/datagrid/fixtures/index.d.ts +1 -0
  24. package/lib/cjs/components/textarea/TextArea.d.ts +7 -0
  25. package/lib/cjs/components/textarea/TextArea.js +20 -0
  26. package/lib/mjs/Webform.js +1 -1
  27. package/lib/mjs/Wizard.d.ts +1 -0
  28. package/lib/mjs/Wizard.js +12 -1
  29. package/lib/mjs/components/_classes/component/Component.d.ts +5 -0
  30. package/lib/mjs/components/_classes/component/Component.js +8 -1
  31. package/lib/mjs/components/datagrid/fixtures/comp10.d.ts +81 -0
  32. package/lib/mjs/components/datagrid/fixtures/comp10.js +85 -0
  33. package/lib/mjs/components/datagrid/fixtures/index.d.ts +1 -0
  34. package/lib/mjs/components/textarea/TextArea.d.ts +7 -0
  35. package/lib/mjs/components/textarea/TextArea.js +20 -0
  36. package/package.json +1 -1
@@ -20,7 +20,7 @@
20
20
 
21
21
  /*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
22
22
 
23
- /*! formiojs v5.0.0-rc.85 | https://unpkg.com/formiojs@5.0.0-rc.85/LICENSE.txt */
23
+ /*! formiojs v5.0.0-rc.87 | https://unpkg.com/formiojs@5.0.0-rc.87/LICENSE.txt */
24
24
 
25
25
  /**
26
26
  * @license
@@ -1244,7 +1244,7 @@ class Webform extends NestedDataComponent_1.default {
1244
1244
  const errors = shouldValidate
1245
1245
  ? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: false, process: 'change' }))
1246
1246
  : [];
1247
- value.isValid = errors.length === 0;
1247
+ value.isValid = (errors || []).filter(err => !err.fromServer).length === 0;
1248
1248
  this.loading = false;
1249
1249
  if (this.submitted) {
1250
1250
  // show server errors while they are not cleaned/fixed
@@ -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) {
@@ -867,6 +867,11 @@ declare class Component extends Element {
867
867
  * @returns {boolean} - If the value changed.
868
868
  */
869
869
  setValue(value: any, flags?: any): boolean;
870
+ /**
871
+ * Returns if the value (e.g. array) should be divided between several inputs
872
+ * @returns {boolean}
873
+ */
874
+ isSingleInputValue(): boolean;
870
875
  /**
871
876
  * Set the value at a specific index.
872
877
  * @param {number} index - The index to set the value at.
@@ -2558,11 +2558,18 @@ class Component extends Element_1.default {
2558
2558
  }
2559
2559
  for (const i in this.refs.input) {
2560
2560
  if (this.refs.input.hasOwnProperty(i)) {
2561
- this.setValueAt(i, isArray ? value[i] : value, flags);
2561
+ this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
2562
2562
  }
2563
2563
  }
2564
2564
  return changed;
2565
2565
  }
2566
+ /**
2567
+ * Returns if the value (e.g. array) should be divided between several inputs
2568
+ * @returns {boolean}
2569
+ */
2570
+ isSingleInputValue() {
2571
+ return false;
2572
+ }
2566
2573
  /**
2567
2574
  * Set the value at a specific index.
2568
2575
  * @param {number} index - The index to set the value at.
@@ -0,0 +1,81 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ reorder: boolean;
10
+ addAnotherPosition: string;
11
+ layoutFixed: boolean;
12
+ enableRowGroups: boolean;
13
+ initEmpty: boolean;
14
+ tableView: boolean;
15
+ defaultValue: {}[];
16
+ validate: {
17
+ required: boolean;
18
+ };
19
+ key: string;
20
+ type: string;
21
+ input: boolean;
22
+ components: {
23
+ label: string;
24
+ columns: ({
25
+ components: {
26
+ label: string;
27
+ applyMaskOn: string;
28
+ tableView: boolean;
29
+ key: string;
30
+ type: string;
31
+ input: boolean;
32
+ }[];
33
+ width: number;
34
+ offset: number;
35
+ push: number;
36
+ pull: number;
37
+ size: string;
38
+ currentWidth: number;
39
+ } | {
40
+ components: {
41
+ label: string;
42
+ tableView: boolean;
43
+ key: string;
44
+ type: string;
45
+ input: boolean;
46
+ }[];
47
+ width: number;
48
+ offset: number;
49
+ push: number;
50
+ pull: number;
51
+ size: string;
52
+ currentWidth: number;
53
+ })[];
54
+ key: string;
55
+ type: string;
56
+ input: boolean;
57
+ tableView: boolean;
58
+ }[];
59
+ disableOnInvalid?: undefined;
60
+ } | {
61
+ type: string;
62
+ label: string;
63
+ key: string;
64
+ disableOnInvalid: boolean;
65
+ input: boolean;
66
+ tableView: boolean;
67
+ reorder?: undefined;
68
+ addAnotherPosition?: undefined;
69
+ layoutFixed?: undefined;
70
+ enableRowGroups?: undefined;
71
+ initEmpty?: undefined;
72
+ defaultValue?: undefined;
73
+ validate?: undefined;
74
+ components?: undefined;
75
+ })[];
76
+ let pdfComponents: never[];
77
+ namespace settings {
78
+ let logs: string;
79
+ }
80
+ }
81
+ export default _default;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ title: 'randomName',
5
+ name: 'randomName',
6
+ path: 'randomName',
7
+ type: 'form',
8
+ display: 'form',
9
+ components: [
10
+ {
11
+ label: 'Data Grid',
12
+ reorder: false,
13
+ addAnotherPosition: 'bottom',
14
+ layoutFixed: false,
15
+ enableRowGroups: false,
16
+ initEmpty: false,
17
+ tableView: false,
18
+ defaultValue: [
19
+ {}
20
+ ],
21
+ validate: {
22
+ required: true
23
+ },
24
+ key: 'dataGrid',
25
+ type: 'datagrid',
26
+ input: true,
27
+ components: [
28
+ {
29
+ label: 'Columns',
30
+ columns: [
31
+ {
32
+ components: [
33
+ {
34
+ label: 'Text Field',
35
+ applyMaskOn: 'change',
36
+ tableView: true,
37
+ key: 'textField',
38
+ type: 'textfield',
39
+ input: true
40
+ }
41
+ ],
42
+ width: 6,
43
+ offset: 0,
44
+ push: 0,
45
+ pull: 0,
46
+ size: 'md',
47
+ currentWidth: 6
48
+ },
49
+ {
50
+ components: [
51
+ {
52
+ label: 'Checkbox',
53
+ tableView: false,
54
+ key: 'checkbox',
55
+ type: 'checkbox',
56
+ input: true
57
+ }
58
+ ],
59
+ width: 6,
60
+ offset: 0,
61
+ push: 0,
62
+ pull: 0,
63
+ size: 'md',
64
+ currentWidth: 6
65
+ }
66
+ ],
67
+ key: 'columns',
68
+ type: 'columns',
69
+ input: false,
70
+ tableView: false
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ type: 'button',
76
+ label: 'Submit',
77
+ key: 'submit',
78
+ disableOnInvalid: true,
79
+ input: true,
80
+ tableView: false
81
+ }
82
+ ],
83
+ pdfComponents: [],
84
+ settings: {
85
+ logs: 'true'
86
+ }
87
+ };
@@ -7,6 +7,7 @@ import comp6 from './comp6';
7
7
  import comp7 from './comp7';
8
8
  import comp8 from './comp8';
9
9
  import comp9 from './comp9';
10
+ import comp10 from './comp10';
10
11
  import comp11 from './comp11';
11
12
  import withCollapsibleRowGroups from './comp-with-collapsible-groups';
12
13
  import withConditionalFieldsAndValidations from './comp-with-conditional-components-and-validations';
@@ -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 {
@@ -1250,7 +1250,7 @@ export default class Webform extends NestedDataComponent {
1250
1250
  process: 'change'
1251
1251
  })
1252
1252
  : [];
1253
- value.isValid = errors.length === 0;
1253
+ value.isValid = (errors || []).filter(err => !err.fromServer).length === 0;
1254
1254
  this.loading = false;
1255
1255
  if (this.submitted) {
1256
1256
  // show server errors while they are not cleaned/fixed
@@ -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) {
@@ -867,6 +867,11 @@ declare class Component extends Element {
867
867
  * @returns {boolean} - If the value changed.
868
868
  */
869
869
  setValue(value: any, flags?: any): boolean;
870
+ /**
871
+ * Returns if the value (e.g. array) should be divided between several inputs
872
+ * @returns {boolean}
873
+ */
874
+ isSingleInputValue(): boolean;
870
875
  /**
871
876
  * Set the value at a specific index.
872
877
  * @param {number} index - The index to set the value at.
@@ -2527,11 +2527,18 @@ export default class Component extends Element {
2527
2527
  }
2528
2528
  for (const i in this.refs.input) {
2529
2529
  if (this.refs.input.hasOwnProperty(i)) {
2530
- this.setValueAt(i, isArray ? value[i] : value, flags);
2530
+ this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
2531
2531
  }
2532
2532
  }
2533
2533
  return changed;
2534
2534
  }
2535
+ /**
2536
+ * Returns if the value (e.g. array) should be divided between several inputs
2537
+ * @returns {boolean}
2538
+ */
2539
+ isSingleInputValue() {
2540
+ return false;
2541
+ }
2535
2542
  /**
2536
2543
  * Set the value at a specific index.
2537
2544
  * @param {number} index - The index to set the value at.
@@ -0,0 +1,81 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ reorder: boolean;
10
+ addAnotherPosition: string;
11
+ layoutFixed: boolean;
12
+ enableRowGroups: boolean;
13
+ initEmpty: boolean;
14
+ tableView: boolean;
15
+ defaultValue: {}[];
16
+ validate: {
17
+ required: boolean;
18
+ };
19
+ key: string;
20
+ type: string;
21
+ input: boolean;
22
+ components: {
23
+ label: string;
24
+ columns: ({
25
+ components: {
26
+ label: string;
27
+ applyMaskOn: string;
28
+ tableView: boolean;
29
+ key: string;
30
+ type: string;
31
+ input: boolean;
32
+ }[];
33
+ width: number;
34
+ offset: number;
35
+ push: number;
36
+ pull: number;
37
+ size: string;
38
+ currentWidth: number;
39
+ } | {
40
+ components: {
41
+ label: string;
42
+ tableView: boolean;
43
+ key: string;
44
+ type: string;
45
+ input: boolean;
46
+ }[];
47
+ width: number;
48
+ offset: number;
49
+ push: number;
50
+ pull: number;
51
+ size: string;
52
+ currentWidth: number;
53
+ })[];
54
+ key: string;
55
+ type: string;
56
+ input: boolean;
57
+ tableView: boolean;
58
+ }[];
59
+ disableOnInvalid?: undefined;
60
+ } | {
61
+ type: string;
62
+ label: string;
63
+ key: string;
64
+ disableOnInvalid: boolean;
65
+ input: boolean;
66
+ tableView: boolean;
67
+ reorder?: undefined;
68
+ addAnotherPosition?: undefined;
69
+ layoutFixed?: undefined;
70
+ enableRowGroups?: undefined;
71
+ initEmpty?: undefined;
72
+ defaultValue?: undefined;
73
+ validate?: undefined;
74
+ components?: undefined;
75
+ })[];
76
+ let pdfComponents: never[];
77
+ namespace settings {
78
+ let logs: string;
79
+ }
80
+ }
81
+ export default _default;
@@ -0,0 +1,85 @@
1
+ export default {
2
+ title: 'randomName',
3
+ name: 'randomName',
4
+ path: 'randomName',
5
+ type: 'form',
6
+ display: 'form',
7
+ components: [
8
+ {
9
+ label: 'Data Grid',
10
+ reorder: false,
11
+ addAnotherPosition: 'bottom',
12
+ layoutFixed: false,
13
+ enableRowGroups: false,
14
+ initEmpty: false,
15
+ tableView: false,
16
+ defaultValue: [
17
+ {}
18
+ ],
19
+ validate: {
20
+ required: true
21
+ },
22
+ key: 'dataGrid',
23
+ type: 'datagrid',
24
+ input: true,
25
+ components: [
26
+ {
27
+ label: 'Columns',
28
+ columns: [
29
+ {
30
+ components: [
31
+ {
32
+ label: 'Text Field',
33
+ applyMaskOn: 'change',
34
+ tableView: true,
35
+ key: 'textField',
36
+ type: 'textfield',
37
+ input: true
38
+ }
39
+ ],
40
+ width: 6,
41
+ offset: 0,
42
+ push: 0,
43
+ pull: 0,
44
+ size: 'md',
45
+ currentWidth: 6
46
+ },
47
+ {
48
+ components: [
49
+ {
50
+ label: 'Checkbox',
51
+ tableView: false,
52
+ key: 'checkbox',
53
+ type: 'checkbox',
54
+ input: true
55
+ }
56
+ ],
57
+ width: 6,
58
+ offset: 0,
59
+ push: 0,
60
+ pull: 0,
61
+ size: 'md',
62
+ currentWidth: 6
63
+ }
64
+ ],
65
+ key: 'columns',
66
+ type: 'columns',
67
+ input: false,
68
+ tableView: false
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ type: 'button',
74
+ label: 'Submit',
75
+ key: 'submit',
76
+ disableOnInvalid: true,
77
+ input: true,
78
+ tableView: false
79
+ }
80
+ ],
81
+ pdfComponents: [],
82
+ settings: {
83
+ logs: 'true'
84
+ }
85
+ };
@@ -7,6 +7,7 @@ import comp6 from './comp6';
7
7
  import comp7 from './comp7';
8
8
  import comp8 from './comp8';
9
9
  import comp9 from './comp9';
10
+ import comp10 from './comp10';
10
11
  import comp11 from './comp11';
11
12
  import withCollapsibleRowGroups from './comp-with-collapsible-groups';
12
13
  import withConditionalFieldsAndValidations from './comp-with-conditional-components-and-validations';
@@ -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-rc.86",
3
+ "version": "5.0.0-rc.87",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {