@formio/js 5.0.0-rc.39 → 5.0.0-rc.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. package/dist/formio.builder.css +2 -2
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.js +1 -1
  4. package/dist/formio.embed.min.js +1 -1
  5. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  6. package/dist/formio.form.css +2 -2
  7. package/dist/formio.form.js +5373 -2370
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.form.min.js.LICENSE.txt +25 -7
  11. package/dist/formio.full.css +2 -2
  12. package/dist/formio.full.js +5715 -2704
  13. package/dist/formio.full.min.css +1 -1
  14. package/dist/formio.full.min.js +1 -1
  15. package/dist/formio.full.min.js.LICENSE.txt +25 -7
  16. package/dist/formio.js +143 -61
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +13 -1
  19. package/dist/formio.utils.js +149 -96
  20. package/dist/formio.utils.min.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +4 -4
  22. package/lib/cjs/Element.js +1 -0
  23. package/lib/cjs/Embed.js +121 -121
  24. package/lib/cjs/Webform.js +36 -13
  25. package/lib/cjs/WebformBuilder.js +4 -2
  26. package/lib/cjs/Wizard.js +6 -1
  27. package/lib/cjs/components/_classes/component/Component.js +33 -22
  28. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  29. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +8 -0
  30. package/lib/cjs/components/_classes/component/fixtures/comp5.js +2 -2
  31. package/lib/cjs/components/_classes/multivalue/Multivalue.js +2 -2
  32. package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -2
  33. package/lib/cjs/components/address/fixtures/comp3.js +1 -1
  34. package/lib/cjs/components/builder.js +0 -2
  35. package/lib/cjs/components/button/Button.js +7 -1
  36. package/lib/cjs/components/datagrid/DataGrid.js +16 -3
  37. package/lib/cjs/components/datagrid/fixtures/comp-with-allow-calculate-override.js +68 -0
  38. package/lib/cjs/components/datagrid/fixtures/comp6.js +1 -1
  39. package/lib/cjs/components/datagrid/fixtures/index.js +5 -1
  40. package/lib/cjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.js +104 -0
  41. package/lib/cjs/components/editgrid/EditGrid.js +11 -4
  42. package/lib/cjs/components/editgrid/fixtures/formsWithEditGridAndConditions.js +923 -0
  43. package/lib/cjs/components/file/File.js +2 -2
  44. package/lib/cjs/components/file/editForm/File.edit.file.js +1 -1
  45. package/lib/cjs/components/form/Form.js +1 -1
  46. package/lib/cjs/components/html/HTML.js +11 -2
  47. package/lib/cjs/components/html/fixtures/index.js +1 -3
  48. package/lib/cjs/components/index.js +0 -2
  49. package/lib/cjs/components/recaptcha/ReCaptcha.js +46 -46
  50. package/lib/cjs/components/select/Select.js +3 -1
  51. package/lib/cjs/components/select/fixtures/comp20.js +46 -0
  52. package/lib/cjs/components/select/fixtures/comp21.js +106 -0
  53. package/lib/cjs/components/select/fixtures/index.js +5 -1
  54. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  55. package/lib/cjs/components/textfield/TextField.js +63 -3
  56. package/lib/cjs/providers/storage/s3.js +5 -3
  57. package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
  58. package/lib/cjs/providers/storage/url.js +19 -13
  59. package/lib/cjs/templates/Templates.js +4 -4
  60. package/lib/cjs/translations/en.js +10 -6
  61. package/lib/cjs/utils/Evaluator.js +1 -1
  62. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
  63. package/lib/cjs/utils/formUtils.js +3 -3
  64. package/lib/cjs/utils/utils.js +4 -19
  65. package/lib/cjs/widgets/CalendarWidget.js +1 -1
  66. package/lib/mjs/Element.js +1 -0
  67. package/lib/mjs/Embed.js +1 -2
  68. package/lib/mjs/FormBuilder.js +1 -2
  69. package/lib/mjs/Webform.js +36 -13
  70. package/lib/mjs/WebformBuilder.js +4 -2
  71. package/lib/mjs/Wizard.js +6 -1
  72. package/lib/mjs/builders/Builders.js +1 -2
  73. package/lib/mjs/components/Components.js +1 -2
  74. package/lib/mjs/components/_classes/component/Component.js +33 -24
  75. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  76. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +8 -0
  77. package/lib/mjs/components/_classes/component/fixtures/comp5.js +2 -2
  78. package/lib/mjs/components/_classes/multivalue/Multivalue.js +2 -2
  79. package/lib/mjs/components/_classes/nested/NestedComponent.js +2 -2
  80. package/lib/mjs/components/address/fixtures/comp3.js +1 -1
  81. package/lib/mjs/components/builder.js +0 -2
  82. package/lib/mjs/components/button/Button.js +7 -1
  83. package/lib/mjs/components/datagrid/DataGrid.js +15 -3
  84. package/lib/mjs/components/datagrid/fixtures/comp-with-allow-calculate-override.js +66 -0
  85. package/lib/mjs/components/datagrid/fixtures/comp6.js +1 -1
  86. package/lib/mjs/components/datagrid/fixtures/index.js +3 -1
  87. package/lib/mjs/components/datagrid/fixtures/two-comp-with-allow-calculate-override.js +102 -0
  88. package/lib/mjs/components/editgrid/EditGrid.js +11 -4
  89. package/lib/mjs/components/editgrid/fixtures/formsWithEditGridAndConditions.js +921 -0
  90. package/lib/mjs/components/file/File.js +2 -2
  91. package/lib/mjs/components/file/editForm/File.edit.file.js +1 -1
  92. package/lib/mjs/components/form/Form.js +1 -1
  93. package/lib/mjs/components/html/HTML.js +10 -2
  94. package/lib/mjs/components/html/fixtures/index.js +1 -2
  95. package/lib/mjs/components/index.js +0 -2
  96. package/lib/mjs/components/recaptcha/ReCaptcha.js +32 -43
  97. package/lib/mjs/components/select/Select.js +3 -1
  98. package/lib/mjs/components/select/fixtures/comp20.js +44 -0
  99. package/lib/mjs/components/select/fixtures/comp21.js +104 -0
  100. package/lib/mjs/components/select/fixtures/index.js +3 -1
  101. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  102. package/lib/mjs/components/textfield/TextField.js +62 -3
  103. package/lib/mjs/displays/Displays.js +1 -2
  104. package/lib/mjs/licenses/Licenses.js +1 -2
  105. package/lib/mjs/providers/Providers.js +1 -2
  106. package/lib/mjs/providers/storage/s3.js +5 -3
  107. package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
  108. package/lib/mjs/providers/storage/url.js +19 -13
  109. package/lib/mjs/templates/Templates.js +1 -1
  110. package/lib/mjs/translations/en.js +10 -6
  111. package/lib/mjs/utils/Evaluator.js +1 -1
  112. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
  113. package/lib/mjs/utils/formUtils.js +3 -3
  114. package/lib/mjs/utils/utils.js +2 -16
  115. package/lib/mjs/widgets/CalendarWidget.js +1 -1
  116. package/package.json +23 -22
  117. package/lib/cjs/components/html/fixtures/comp3.js +0 -31
  118. package/lib/cjs/components/resource/Resource.form.js +0 -16
  119. package/lib/cjs/components/resource/Resource.js +0 -39
  120. package/lib/cjs/components/resource/editForm/Resource.edit.display.js +0 -102
  121. package/lib/cjs/components/resource/fixtures/comp1.js +0 -30
  122. package/lib/cjs/components/resource/fixtures/comp2.js +0 -31
  123. package/lib/cjs/components/resource/fixtures/index.js +0 -10
  124. package/lib/mjs/components/html/fixtures/comp3.js +0 -29
  125. package/lib/mjs/components/resource/Resource.form.js +0 -10
  126. package/lib/mjs/components/resource/Resource.js +0 -33
  127. package/lib/mjs/components/resource/editForm/Resource.edit.display.js +0 -100
  128. package/lib/mjs/components/resource/fixtures/comp1.js +0 -28
  129. package/lib/mjs/components/resource/fixtures/comp2.js +0 -29
  130. package/lib/mjs/components/resource/fixtures/index.js +0 -3
@@ -26,7 +26,6 @@ import PasswordForm from './password/Password.form';
26
26
  import PhoneNumberForm from './phonenumber/PhoneNumber.form';
27
27
  import RadioForm from './radio/Radio.form';
28
28
  import ReCaptchaForm from './recaptcha/ReCaptcha.form';
29
- import ResourceForm from './resource/Resource.form';
30
29
  import SelectboxesForm from './selectboxes/SelectBoxes.form';
31
30
  import SelectForm from './select/Select.form';
32
31
  import SignatureForm from './signature/Signature.form';
@@ -67,7 +66,6 @@ Components.password.editForm = PasswordForm;
67
66
  Components.phoneNumber.editForm = PhoneNumberForm;
68
67
  Components.radio.editForm = RadioForm;
69
68
  Components.recaptcha.editForm = ReCaptchaForm;
70
- Components.resource.editForm = ResourceForm;
71
69
  Components.select.editForm = SelectForm;
72
70
  Components.selectboxes.editForm = SelectboxesForm;
73
71
  Components.signature.editForm = SignatureForm;
@@ -358,9 +358,15 @@ export default class ButtonComponent extends Field {
358
358
  response_type: 'code',
359
359
  client_id: settings.clientId,
360
360
  redirect_uri: (settings.redirectURI && this.interpolate(settings.redirectURI)) || window.location.origin || `${window.location.protocol}//${window.location.host}`,
361
- state: settings.state,
362
361
  scope: settings.scope
363
362
  };
363
+ if (settings.state) {
364
+ params.state = settings.state;
365
+ }
366
+ else if (settings.code_challenge) {
367
+ params.code_challenge = settings.code_challenge;
368
+ params.code_challenge_method = 'S256';
369
+ }
364
370
  /*eslint-enable camelcase */
365
371
  // Needs for the correct redirection URI for the OpenID
366
372
  const originalRedirectUri = params.redirect_uri;
@@ -122,6 +122,15 @@ export default class DataGridComponent extends NestedArrayComponent {
122
122
  data: this.dataValue[index],
123
123
  }));
124
124
  }
125
+ isEmpty(value = this.dataValue) {
126
+ const isEmpty = super.isEmpty(value);
127
+ if (this.components?.length) {
128
+ return this.components.reduce((isEmpty, component) => {
129
+ return isEmpty && component.isEmpty();
130
+ }, true);
131
+ }
132
+ return isEmpty;
133
+ }
125
134
  /**
126
135
  * Split rows into chunks.
127
136
  * @param {Number[]} groups - array of numbers where each item is size of group
@@ -400,12 +409,14 @@ export default class DataGridComponent extends NestedArrayComponent {
400
409
  });
401
410
  }
402
411
  removeRow(index) {
403
- this.splice(index, { isReordered: true });
412
+ const makeEmpty = index === 0 && this.rows.length === 1;
413
+ const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
414
+ this.splice(index, flags);
404
415
  this.emit('dataGridDeleteRow', { index });
405
416
  const [row] = this.rows.splice(index, 1);
406
417
  this.removeRowComponents(row);
407
418
  this.updateRowsComponents(index);
408
- this.setValue(this.dataValue, { isReordered: true });
419
+ this.setValue(this.dataValue, flags);
409
420
  this.redraw();
410
421
  }
411
422
  removeRowComponents(row) {
@@ -552,7 +563,8 @@ export default class DataGridComponent extends NestedArrayComponent {
552
563
  const isSettingSubmission = flags.fromSubmission && !_.isEqual(value, this.emptyValue);
553
564
  const changed = this.hasChanged(value, this.dataValue);
554
565
  this.dataValue = value;
555
- if (this.initRows || isSettingSubmission) {
566
+ if (this.initRows || isSettingSubmission ||
567
+ (Array.isArray(this.dataValue) && this.dataValue.length !== this.rows.length)) {
556
568
  if (!this.createRows() && changed) {
557
569
  this.redraw();
558
570
  }
@@ -0,0 +1,66 @@
1
+ export default {
2
+ type: 'form',
3
+ display: 'form',
4
+ components: [
5
+ {
6
+ label: 'Select',
7
+ widget: 'choicesjs',
8
+ tableView: true,
9
+ data: {
10
+ values: [
11
+ {
12
+ label: 'a',
13
+ value: 'a'
14
+ },
15
+ {
16
+ label: 'b',
17
+ value: 'b'
18
+ },
19
+ {
20
+ label: 'c',
21
+ value: 'c'
22
+ }
23
+ ]
24
+ },
25
+ key: 'select',
26
+ type: 'select',
27
+ input: true
28
+ },
29
+ {
30
+ label: 'Data Grid',
31
+ reorder: false,
32
+ addAnotherPosition: 'bottom',
33
+ layoutFixed: false,
34
+ enableRowGroups: false,
35
+ initEmpty: false,
36
+ tableView: false,
37
+ defaultValue: [
38
+ {
39
+ firstName: '',
40
+ lastName: ''
41
+ }
42
+ ],
43
+ 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;",
44
+ allowCalculateOverride: true,
45
+ key: 'dataGrid',
46
+ type: 'datagrid',
47
+ input: true,
48
+ components: [
49
+ {
50
+ label: 'First Name',
51
+ tableView: true,
52
+ key: 'firstName',
53
+ type: 'textfield',
54
+ input: true
55
+ },
56
+ {
57
+ label: 'Last Name',
58
+ tableView: true,
59
+ key: 'lastName',
60
+ type: 'textfield',
61
+ input: true
62
+ }
63
+ ]
64
+ }
65
+ ]
66
+ };
@@ -138,7 +138,7 @@ export default {
138
138
  providerOptions: {
139
139
  params: {
140
140
  autocompleteOptions: {},
141
- key: 'AIzaSyBNL2e4MnmyPj9zN7SVAe428nCSLP1X144',
141
+ key: '',
142
142
  },
143
143
  },
144
144
  input: true,
@@ -12,4 +12,6 @@ import modalWithRequiredFields from './comp-modal-with-required-fields';
12
12
  import withConditionalFieldsAndValidations from './comp-with-conditional-components-and-validations';
13
13
  import withLogic from './comp-with-logic';
14
14
  import withCollapsibleRowGroups from './comp-with-collapsible-groups';
15
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields };
15
+ import withAllowCalculateOverride from './comp-with-allow-calculate-override';
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 };
@@ -0,0 +1,102 @@
1
+ export default {
2
+ type: 'form',
3
+ display: 'form',
4
+ components: [
5
+ {
6
+ label: 'Select',
7
+ widget: 'choicesjs',
8
+ tableView: true,
9
+ data: {
10
+ values: [
11
+ {
12
+ label: 'a',
13
+ value: 'a'
14
+ },
15
+ {
16
+ label: 'b',
17
+ value: 'b'
18
+ },
19
+ {
20
+ label: 'c',
21
+ value: 'c'
22
+ }
23
+ ]
24
+ },
25
+ key: 'select',
26
+ type: 'select',
27
+ input: true
28
+ },
29
+ {
30
+ label: 'Data Grid',
31
+ reorder: false,
32
+ addAnotherPosition: 'bottom',
33
+ layoutFixed: false,
34
+ enableRowGroups: false,
35
+ initEmpty: false,
36
+ tableView: false,
37
+ defaultValue: [
38
+ {
39
+ firstName: '',
40
+ lastName: ''
41
+ }
42
+ ],
43
+ 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;",
44
+ allowCalculateOverride: true,
45
+ key: 'dataGrid',
46
+ type: 'datagrid',
47
+ input: true,
48
+ components: [
49
+ {
50
+ label: 'First Name',
51
+ tableView: true,
52
+ key: 'firstName',
53
+ type: 'textfield',
54
+ input: true
55
+ },
56
+ {
57
+ label: 'Last Name',
58
+ tableView: true,
59
+ key: 'lastName',
60
+ type: 'textfield',
61
+ input: true
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ label: 'Data Grid 2',
67
+ reorder: false,
68
+ addAnotherPosition: 'bottom',
69
+ layoutFixed: false,
70
+ enableRowGroups: false,
71
+ initEmpty: false,
72
+ tableView: false,
73
+ defaultValue: [
74
+ {
75
+ firstName: '',
76
+ lastName: ''
77
+ }
78
+ ],
79
+ 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;",
80
+ allowCalculateOverride: true,
81
+ key: 'dataGrid2',
82
+ type: 'datagrid',
83
+ input: true,
84
+ components: [
85
+ {
86
+ label: 'First Name',
87
+ tableView: true,
88
+ key: 'firstName',
89
+ type: 'textfield',
90
+ input: true
91
+ },
92
+ {
93
+ label: 'Last Name',
94
+ tableView: true,
95
+ key: 'lastName',
96
+ type: 'textfield',
97
+ input: true
98
+ }
99
+ ]
100
+ }
101
+ ]
102
+ };
@@ -570,6 +570,10 @@ export default class EditGridComponent extends NestedArrayComponent {
570
570
  ? (this.editRows[rowIndex]?.components || [])
571
571
  : this.editRows.reduce((result, row) => result.concat(row.components || []), []);
572
572
  }
573
+ destroy(all = false) {
574
+ this.calculatedValue = undefined;
575
+ super.destroy(all);
576
+ }
573
577
  destroyComponents(all = false, rowIndex = 0) {
574
578
  if (this.builderMode) {
575
579
  return super.destroyComponents(all);
@@ -1073,7 +1077,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1073
1077
  }
1074
1078
  return false;
1075
1079
  }
1076
- else if (rowsEditing && this.saveEditMode) {
1080
+ else if (rowsEditing && this.saveEditMode && !this.component.openWhenEmpty) {
1077
1081
  this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);
1078
1082
  return false;
1079
1083
  }
@@ -1101,7 +1105,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1101
1105
  }
1102
1106
  }
1103
1107
  changeState(changed, flags) {
1104
- if (changed || (flags.resetValue && this.component.modalEdit)) {
1108
+ if (this.visible && (changed || (flags.resetValue && this.component.modalEdit))) {
1105
1109
  this.rebuild();
1106
1110
  }
1107
1111
  else {
@@ -1121,7 +1125,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1121
1125
  }
1122
1126
  }
1123
1127
  const changed = this.hasChanged(value, this.dataValue);
1124
- if (this.parent) {
1128
+ if (this.parent && !this.options.server) {
1125
1129
  this.parent.checkComponentConditions();
1126
1130
  }
1127
1131
  this.dataValue = value;
@@ -1154,7 +1158,10 @@ export default class EditGridComponent extends NestedArrayComponent {
1154
1158
  this.editRows = this.editRows.slice(0, dataLength);
1155
1159
  this.openWhenEmpty();
1156
1160
  this.updateOnChange(flags, changed);
1157
- this.checkData();
1161
+ // do not call checkData with server option, it is called when change is triggered in updateOnChange
1162
+ if (!this.options.server) {
1163
+ this.checkData();
1164
+ }
1158
1165
  this.changeState(changed, flags);
1159
1166
  return changed;
1160
1167
  }