@formio/js 5.0.0-bb.dev.3 → 5.0.0-bb.dev.6

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 (54) 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 +12 -12
  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 +12 -12
  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 +1 -1
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  14. package/lib/cjs/Form.js +0 -15
  15. package/lib/cjs/components/_classes/component/Component.js +10 -4
  16. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +8 -0
  17. package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -2
  18. package/lib/cjs/components/datagrid/DataGrid.js +2 -1
  19. package/lib/cjs/components/datagrid/fixtures/comp-with-allow-calculate-override.js +1 -1
  20. package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
  21. package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
  22. package/lib/cjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.d.ts +53 -0
  23. package/lib/cjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.js +104 -0
  24. package/lib/cjs/components/editgrid/EditGrid.js +7 -4
  25. package/lib/cjs/components/editgrid/fixtures/formsWithEditGridAndConditions.d.ts +910 -0
  26. package/lib/cjs/components/editgrid/fixtures/formsWithEditGridAndConditions.js +923 -0
  27. package/lib/cjs/components/html/HTML.d.ts +1 -0
  28. package/lib/cjs/components/html/HTML.js +9 -0
  29. package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -3
  30. package/lib/cjs/formio.form.js +14 -0
  31. package/lib/cjs/translations/en.d.ts +2 -0
  32. package/lib/cjs/translations/en.js +2 -0
  33. package/lib/cjs/validator/Validator.js +1 -1
  34. package/lib/mjs/Form.js +0 -15
  35. package/lib/mjs/components/_classes/component/Component.js +10 -4
  36. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +8 -0
  37. package/lib/mjs/components/_classes/nested/NestedComponent.js +2 -2
  38. package/lib/mjs/components/datagrid/DataGrid.js +2 -1
  39. package/lib/mjs/components/datagrid/fixtures/comp-with-allow-calculate-override.js +1 -1
  40. package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
  41. package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
  42. package/lib/mjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.d.ts +53 -0
  43. package/lib/mjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.js +102 -0
  44. package/lib/mjs/components/editgrid/EditGrid.js +7 -4
  45. package/lib/mjs/components/editgrid/fixtures/formsWithEditGridAndConditions.d.ts +910 -0
  46. package/lib/mjs/components/editgrid/fixtures/formsWithEditGridAndConditions.js +921 -0
  47. package/lib/mjs/components/html/HTML.d.ts +1 -0
  48. package/lib/mjs/components/html/HTML.js +8 -0
  49. package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -3
  50. package/lib/mjs/formio.form.js +14 -0
  51. package/lib/mjs/translations/en.d.ts +2 -0
  52. package/lib/mjs/translations/en.js +2 -0
  53. package/lib/mjs/validator/Validator.js +1 -1
  54. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  /*! @license DOMPurify 3.0.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.5/LICENSE */
2
2
 
3
- /*! formiojs v5.0.0-bb.dev.2 | https://unpkg.com/formiojs@5.0.0-bb.dev.2/LICENSE.txt */
3
+ /*! formiojs v5.0.0-bb.dev.5 | https://unpkg.com/formiojs@5.0.0-bb.dev.5/LICENSE.txt */
4
4
 
5
5
  /**
6
6
  * @license
@@ -12,7 +12,7 @@
12
12
 
13
13
  /*! @license DOMPurify 3.0.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.5/LICENSE */
14
14
 
15
- /*! formiojs v5.0.0-bb.dev.2 | https://unpkg.com/formiojs@5.0.0-bb.dev.2/LICENSE.txt */
15
+ /*! formiojs v5.0.0-bb.dev.5 | https://unpkg.com/formiojs@5.0.0-bb.dev.5/LICENSE.txt */
16
16
 
17
17
  /**
18
18
  * @license
package/lib/cjs/Form.js CHANGED
@@ -364,18 +364,3 @@ class Form extends Element_1.default {
364
364
  }
365
365
  }
366
366
  exports.default = Form;
367
- // Allow simple embedding.
368
- Formio_1.Formio.embedForm = (embed) => Form.embed(embed);
369
- /**
370
- * Factory that creates a new form based on the form parameters.
371
- *
372
- * @param element {HMTLElement} - The HTML Element to add this form to.
373
- * @param form {string|Object} - The src of the form, or a form object.
374
- * @param options {Object} - The options to create this form.
375
- *
376
- * @return {Promise} - When the form is instance is ready.
377
- */
378
- Formio_1.Formio.createForm = (...args) => {
379
- return (new Form(...args)).ready;
380
- };
381
- Formio_1.Formio.Form = Form;
@@ -1846,6 +1846,10 @@ class Component extends Element_1.default {
1846
1846
  this.setElementInvalid(this.performInputMapping(element), false);
1847
1847
  });
1848
1848
  this.setInputWidgetErrorClasses(elements, hasErrors);
1849
+ // do not set error classes for hidden components
1850
+ if (!this.visible) {
1851
+ return;
1852
+ }
1849
1853
  if (hasErrors) {
1850
1854
  // Add error classes
1851
1855
  elements.forEach((input) => {
@@ -2459,8 +2463,8 @@ class Component extends Element_1.default {
2459
2463
  }
2460
2464
  /* eslint-disable max-statements */
2461
2465
  calculateComponentValue(data, flags, row) {
2462
- // Skip value calculation for the component if we don't have entire form data set
2463
- if (lodash_1.default.isUndefined(lodash_1.default.get(this, 'root.data'))) {
2466
+ // Skip value calculation for the component if we don't have entire form data set or in builder mode
2467
+ if (this.builderMode || lodash_1.default.isUndefined(lodash_1.default.get(this, 'root.data'))) {
2464
2468
  return false;
2465
2469
  }
2466
2470
  // If no calculated value or
@@ -2518,6 +2522,7 @@ class Component extends Element_1.default {
2518
2522
  }
2519
2523
  // Check to ensure that the calculated value is different than the previously calculated value.
2520
2524
  if (previousCalculatedValue && previousChanged && !calculationChanged) {
2525
+ this.calculatedValue = null;
2521
2526
  return false;
2522
2527
  }
2523
2528
  if (flags.isReordered || !calculationChanged) {
@@ -2876,6 +2881,7 @@ class Component extends Element_1.default {
2876
2881
  return (this.component.protected || !this.component.persistent || (this.component.persistent === 'client-only'));
2877
2882
  }
2878
2883
  shouldSkipValidation(data, dirty, row) {
2884
+ const { validateWhenHidden = false } = this.component || {};
2879
2885
  const rules = [
2880
2886
  // Force valid if component is read-only
2881
2887
  () => this.options.readOnly,
@@ -2884,9 +2890,9 @@ class Component extends Element_1.default {
2884
2890
  // Check to see if we are editing and if so, check component persistence.
2885
2891
  () => this.isValueHidden(),
2886
2892
  // Force valid if component is hidden.
2887
- () => !this.visible,
2893
+ () => !this.visible && !validateWhenHidden,
2888
2894
  // Force valid if component is conditionally hidden.
2889
- () => !this.checkCondition(row, data)
2895
+ () => !this.checkCondition(row, data) && !validateWhenHidden
2890
2896
  ];
2891
2897
  return rules.some(pred => pred());
2892
2898
  }
@@ -23,6 +23,14 @@ exports.default = [
23
23
  key: 'unique',
24
24
  input: true
25
25
  },
26
+ {
27
+ weight: 100,
28
+ type: 'checkbox',
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.',
31
+ key: 'validateWhenHidden',
32
+ input: true
33
+ },
26
34
  {
27
35
  weight: 0,
28
36
  type: 'select',
@@ -530,8 +530,8 @@ class NestedComponent extends Field_1.default {
530
530
  row = row || this.data;
531
531
  components = components && lodash_1.default.isArray(components) ? components : this.getComponents();
532
532
  const isValid = components.reduce((valid, comp) => {
533
- return comp.checkData(data, flags, row) && valid;
534
- }, super.checkData(data, flags, row));
533
+ return comp.checkData(data, Object.assign({}, flags), row) && valid;
534
+ }, super.checkData(data, Object.assign({}, flags), row));
535
535
  this.checkModal(isValid, this.isDirty);
536
536
  return isValid;
537
537
  }
@@ -587,7 +587,8 @@ class DataGridComponent extends NestedArrayComponent_1.default {
587
587
  const isSettingSubmission = flags.fromSubmission && !lodash_1.default.isEqual(value, this.emptyValue);
588
588
  const changed = this.hasChanged(value, this.dataValue);
589
589
  this.dataValue = value;
590
- if (this.initRows || isSettingSubmission) {
590
+ if (this.initRows || isSettingSubmission ||
591
+ (Array.isArray(this.dataValue) && this.dataValue.length !== this.rows.length)) {
591
592
  if (!this.createRows() && changed) {
592
593
  this.redraw();
593
594
  }
@@ -42,7 +42,7 @@ exports.default = {
42
42
  lastName: ''
43
43
  }
44
44
  ],
45
- calculateValue: "var temp = [\n {'firstName': 'initial 1','lastName': 'initial 2'},\n {'firstName': 'initial 1b','lastName': 'initial 2b'},\n ];\n if(data.select === 'a')\n {\n temp = [{'firstName': 'A f 1','lastName': 'A l 1'}];\n } else if(data.select === 'b') { \n temp = [{'firstName': 'B f 1','lastName': 'B l 1'} \n ,{'firstName': 'B f 2','lastName': 'B l 2'}];\n } else if(data.select === 'c') { \n temp = [{'firstName': 'C f 1','lastName': 'C l 1'}];\n }\n value = temp;",
45
+ calculateValue: "var temp = instance.defaultValue;\n if(data.select === 'a')\n {\n temp = [{'firstName': 'A f 1','lastName': 'A l 1'}];\n } else if(data.select === 'b') { \n temp = [{'firstName': 'B f 1','lastName': 'B l 1'} \n ,{'firstName': 'B f 2','lastName': 'B l 2'}];\n } else if(data.select === 'c') { \n temp = [{'firstName': 'C f 1','lastName': 'C l 1'}];\n }\n value = temp;",
46
46
  allowCalculateOverride: true,
47
47
  key: 'dataGrid',
48
48
  type: 'datagrid',
@@ -13,4 +13,5 @@ import withLogic from './comp-with-logic';
13
13
  import withRowGroupsAndDefValue from './comp-row-groups-with-def-value';
14
14
  import modalWithRequiredFields from './comp-modal-with-required-fields';
15
15
  import withAllowCalculateOverride from './comp-with-allow-calculate-override';
16
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride };
16
+ import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
17
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.twoWithAllowCalculatedOverride = exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const comp2_1 = __importDefault(require("./comp2"));
@@ -34,3 +34,5 @@ const comp_with_collapsible_groups_1 = __importDefault(require("./comp-with-coll
34
34
  exports.withCollapsibleRowGroups = comp_with_collapsible_groups_1.default;
35
35
  const comp_with_allow_calculate_override_1 = __importDefault(require("./comp-with-allow-calculate-override"));
36
36
  exports.withAllowCalculateOverride = comp_with_allow_calculate_override_1.default;
37
+ const two_comp_with_allow_calculate_override_1 = __importDefault(require("./two-comp-with-allow-calculate-override"));
38
+ exports.twoWithAllowCalculatedOverride = two_comp_with_allow_calculate_override_1.default;
@@ -0,0 +1,53 @@
1
+ declare namespace _default {
2
+ const type: string;
3
+ const display: string;
4
+ const components: ({
5
+ label: string;
6
+ widget: string;
7
+ tableView: boolean;
8
+ data: {
9
+ values: {
10
+ label: string;
11
+ value: string;
12
+ }[];
13
+ };
14
+ key: string;
15
+ type: string;
16
+ input: boolean;
17
+ reorder?: undefined;
18
+ addAnotherPosition?: undefined;
19
+ layoutFixed?: undefined;
20
+ enableRowGroups?: undefined;
21
+ initEmpty?: undefined;
22
+ defaultValue?: undefined;
23
+ allowCalculateOverride?: undefined;
24
+ components?: undefined;
25
+ } | {
26
+ label: string;
27
+ reorder: boolean;
28
+ addAnotherPosition: string;
29
+ layoutFixed: boolean;
30
+ enableRowGroups: boolean;
31
+ initEmpty: boolean;
32
+ tableView: boolean;
33
+ defaultValue: {
34
+ firstName: string;
35
+ lastName: string;
36
+ }[];
37
+ calculateValue: string;
38
+ allowCalculateOverride: boolean;
39
+ key: string;
40
+ type: string;
41
+ input: boolean;
42
+ components: {
43
+ label: string;
44
+ tableView: boolean;
45
+ key: string;
46
+ type: string;
47
+ input: boolean;
48
+ }[];
49
+ widget?: undefined;
50
+ data?: undefined;
51
+ })[];
52
+ }
53
+ export default _default;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ type: 'form',
5
+ display: 'form',
6
+ components: [
7
+ {
8
+ label: 'Select',
9
+ widget: 'choicesjs',
10
+ tableView: true,
11
+ data: {
12
+ values: [
13
+ {
14
+ label: 'a',
15
+ value: 'a'
16
+ },
17
+ {
18
+ label: 'b',
19
+ value: 'b'
20
+ },
21
+ {
22
+ label: 'c',
23
+ value: 'c'
24
+ }
25
+ ]
26
+ },
27
+ key: 'select',
28
+ type: 'select',
29
+ input: true
30
+ },
31
+ {
32
+ label: 'Data Grid',
33
+ reorder: false,
34
+ addAnotherPosition: 'bottom',
35
+ layoutFixed: false,
36
+ enableRowGroups: false,
37
+ initEmpty: false,
38
+ tableView: false,
39
+ defaultValue: [
40
+ {
41
+ firstName: '',
42
+ lastName: ''
43
+ }
44
+ ],
45
+ calculateValue: "var temp = instance.defaultValue;\n if(data.select === 'a')\n {\n temp = [{'firstName': 'A f 1','lastName': 'A l 1'}];\n } else if(data.select === 'b') { \n temp = [{'firstName': 'B f 1','lastName': 'B l 1'} \n ,{'firstName': 'B f 2','lastName': 'B l 2'}];\n } else if(data.select === 'c') { \n temp = [{'firstName': 'C f 1','lastName': 'C l 1'}];\n }\n value = temp;",
46
+ allowCalculateOverride: true,
47
+ key: 'dataGrid',
48
+ type: 'datagrid',
49
+ input: true,
50
+ components: [
51
+ {
52
+ label: 'First Name',
53
+ tableView: true,
54
+ key: 'firstName',
55
+ type: 'textfield',
56
+ input: true
57
+ },
58
+ {
59
+ label: 'Last Name',
60
+ tableView: true,
61
+ key: 'lastName',
62
+ type: 'textfield',
63
+ input: true
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ label: 'Data Grid 2',
69
+ reorder: false,
70
+ addAnotherPosition: 'bottom',
71
+ layoutFixed: false,
72
+ enableRowGroups: false,
73
+ initEmpty: false,
74
+ tableView: false,
75
+ defaultValue: [
76
+ {
77
+ firstName: '',
78
+ lastName: ''
79
+ }
80
+ ],
81
+ calculateValue: "var temp = instance.defaultValue;\n if(data.select === 'a')\n {\n temp = [{'firstName': 'A f 1','lastName': 'A l 1'}];\n } else if(data.select === 'b') { \n temp = [{'firstName': 'B f 1','lastName': 'B l 1'} \n ,{'firstName': 'B f 2','lastName': 'B l 2'}];\n } else if(data.select === 'c') { \n temp = [{'firstName': 'C f 1','lastName': 'C l 1'}];\n }\n value = temp;",
82
+ allowCalculateOverride: true,
83
+ key: 'dataGrid2',
84
+ type: 'datagrid',
85
+ input: true,
86
+ components: [
87
+ {
88
+ label: 'First Name',
89
+ tableView: true,
90
+ key: 'firstName',
91
+ type: 'textfield',
92
+ input: true
93
+ },
94
+ {
95
+ label: 'Last Name',
96
+ tableView: true,
97
+ key: 'lastName',
98
+ type: 'textfield',
99
+ input: true
100
+ }
101
+ ]
102
+ }
103
+ ]
104
+ };
@@ -1074,7 +1074,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1074
1074
  }
1075
1075
  return false;
1076
1076
  }
1077
- else if (rowsEditing && this.saveEditMode) {
1077
+ else if (rowsEditing && this.saveEditMode && !this.component.openWhenEmpty) {
1078
1078
  this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);
1079
1079
  return false;
1080
1080
  }
@@ -1089,7 +1089,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1089
1089
  return superValid;
1090
1090
  }
1091
1091
  changeState(changed, flags) {
1092
- if (changed || (flags.resetValue && this.component.modalEdit)) {
1092
+ if (this.visible && (changed || (flags.resetValue && this.component.modalEdit))) {
1093
1093
  this.rebuild();
1094
1094
  }
1095
1095
  else {
@@ -1110,7 +1110,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1110
1110
  }
1111
1111
  const changed = this.hasChanged(value, this.dataValue);
1112
1112
  flags.noValidate = !changed;
1113
- if (this.parent && !(this.options.server && !this.parent.parentVisible)) {
1113
+ if (this.parent && !this.options.server) {
1114
1114
  this.parent.checkComponentConditions();
1115
1115
  }
1116
1116
  this.dataValue = value;
@@ -1143,7 +1143,10 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1143
1143
  this.editRows = this.editRows.slice(0, dataLength);
1144
1144
  this.openWhenEmpty();
1145
1145
  this.updateOnChange(flags, changed);
1146
- this.checkData();
1146
+ // do not call checkData with server option, it is called when change is triggered in updateOnChange
1147
+ if (!this.options.server) {
1148
+ this.checkData();
1149
+ }
1147
1150
  this.changeState(changed, flags);
1148
1151
  return changed;
1149
1152
  }