@formio/js 5.1.0-dev.6017.d6efba0 → 5.1.0-dev.6021.879d00c

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.
@@ -106,7 +106,6 @@ declare class Wizard extends Webform {
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
108
  focusOnComponent(key: any): void | Promise<void>;
109
- triggerButtonCaptcha(page: any): void;
110
109
  }
111
110
  declare namespace Wizard {
112
111
  let setBaseUrl: any;
package/lib/cjs/Wizard.js CHANGED
@@ -669,7 +669,6 @@ class Wizard extends Webform_1.default {
669
669
  beforeSubmit() {
670
670
  const pages = this.getPages({ all: true });
671
671
  return Promise.all(pages.map((page) => {
672
- this.triggerButtonCaptcha(page);
673
672
  page.options.beforeSubmit = true;
674
673
  return page.beforeSubmit();
675
674
  }));
@@ -942,22 +941,6 @@ class Wizard extends Webform_1.default {
942
941
  }
943
942
  return super.focusOnComponent(key);
944
943
  }
945
- triggerButtonCaptcha(page) {
946
- if (!page.components) {
947
- return;
948
- }
949
- let captchaComponent;
950
- page.eachComponent((component) => {
951
- if (/^(re)?captcha$/.test(component.component.type) &&
952
- component.component.eventType === 'buttonClick' &&
953
- component.component.buttonKey === 'submit') {
954
- captchaComponent = component;
955
- }
956
- });
957
- if (captchaComponent) {
958
- captchaComponent.verify(`submitClick`);
959
- }
960
- }
961
944
  }
962
945
  exports.default = Wizard;
963
946
  Wizard.setBaseUrl = Formio_1.Formio.setBaseUrl;
@@ -198,6 +198,7 @@ class Component extends Element_1.default {
198
198
  properties: {},
199
199
  allowMultipleMasks: false,
200
200
  addons: [],
201
+ serverOverride: {},
201
202
  }, ...sources);
202
203
  }
203
204
  /**
@@ -87,6 +87,9 @@ declare const _default: ({
87
87
  valueProperty?: undefined;
88
88
  data?: undefined;
89
89
  conditional?: undefined;
90
+ as?: undefined;
91
+ editor?: undefined;
92
+ description?: undefined;
90
93
  } | {
91
94
  type: string;
92
95
  label: string;
@@ -103,6 +106,9 @@ declare const _default: ({
103
106
  valueProperty?: undefined;
104
107
  data?: undefined;
105
108
  conditional?: undefined;
109
+ as?: undefined;
110
+ editor?: undefined;
111
+ description?: undefined;
106
112
  } | {
107
113
  weight: number;
108
114
  type: string;
@@ -125,6 +131,9 @@ declare const _default: ({
125
131
  valueProperty?: undefined;
126
132
  data?: undefined;
127
133
  conditional?: undefined;
134
+ as?: undefined;
135
+ editor?: undefined;
136
+ description?: undefined;
128
137
  } | {
129
138
  weight: number;
130
139
  type: string;
@@ -173,6 +182,9 @@ declare const _default: ({
173
182
  valueProperty?: undefined;
174
183
  data?: undefined;
175
184
  conditional?: undefined;
185
+ as?: undefined;
186
+ editor?: undefined;
187
+ description?: undefined;
176
188
  } | {
177
189
  type: string;
178
190
  input: boolean;
@@ -200,6 +212,9 @@ declare const _default: ({
200
212
  defaultValue?: undefined;
201
213
  values?: undefined;
202
214
  logic?: undefined;
215
+ as?: undefined;
216
+ editor?: undefined;
217
+ description?: undefined;
203
218
  } | {
204
219
  weight: number;
205
220
  type: string;
@@ -216,5 +231,27 @@ declare const _default: ({
216
231
  valueProperty?: undefined;
217
232
  data?: undefined;
218
233
  conditional?: undefined;
234
+ as?: undefined;
235
+ editor?: undefined;
236
+ description?: undefined;
237
+ } | {
238
+ type: string;
239
+ as: string;
240
+ editor: string;
241
+ weight: number;
242
+ input: boolean;
243
+ key: string;
244
+ label: string;
245
+ tooltip: string;
246
+ defaultValue: {};
247
+ description: string;
248
+ placeholder?: undefined;
249
+ inline?: undefined;
250
+ values?: undefined;
251
+ logic?: undefined;
252
+ dataSrc?: undefined;
253
+ valueProperty?: undefined;
254
+ data?: undefined;
255
+ conditional?: undefined;
219
256
  })[];
220
257
  export default _default;
@@ -157,5 +157,16 @@ exports.default = [
157
157
  label: 'Allow Manual Override of Calculated Value',
158
158
  tooltip: 'When checked, this will allow the user to manually override the calculated value.'
159
159
  },
160
+ {
161
+ type: 'textarea',
162
+ as: 'json',
163
+ editor: 'ace',
164
+ weight: 1400,
165
+ input: true,
166
+ key: 'serverOverride',
167
+ label: 'Server Override',
168
+ tooltip: 'A JSON object containing the component settings that should be overriden when the form submission is processed on the server side.',
169
+ defaultValue: {},
170
+ description: '<b>Example</b>: { "clearOnHide": true }',
171
+ }
160
172
  ];
161
- /* eslint-enable max-len */
@@ -45,16 +45,18 @@ export default class FormComponent extends Component {
45
45
  /**
46
46
  * Create a subform instance.
47
47
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
48
+ * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
48
49
  * @returns {*} - The subform instance.
49
50
  */
50
- createSubForm(fromAttach?: boolean | undefined): any;
51
+ createSubForm(fromAttach?: boolean | undefined, beforeSubmit?: boolean | undefined): any;
51
52
  hideSubmitButton(component: any): void;
52
53
  /**
53
54
  * Load the subform.
54
55
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
56
+ * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
55
57
  * @returns {Promise} - The promise that resolves when the subform is loaded.
56
58
  */
57
- loadSubForm(fromAttach: boolean): Promise<any>;
59
+ loadSubForm(fromAttach: boolean, beforeSubmit: boolean): Promise<any>;
58
60
  subFormLoading: boolean | undefined;
59
61
  checkComponentConditions(data: any, flags: any, row: any): any;
60
62
  calculateValue(data: any, flags: any, row: any): any;
@@ -380,10 +380,11 @@ class FormComponent extends Component_1.default {
380
380
  /**
381
381
  * Create a subform instance.
382
382
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
383
+ * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
383
384
  * @returns {*} - The subform instance.
384
385
  */
385
- createSubForm(fromAttach) {
386
- this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
386
+ createSubForm(fromAttach, beforeSubmit) {
387
+ this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
387
388
  if (!form) {
388
389
  return;
389
390
  }
@@ -440,11 +441,13 @@ class FormComponent extends Component_1.default {
440
441
  /**
441
442
  * Load the subform.
442
443
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
444
+ * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
443
445
  * @returns {Promise} - The promise that resolves when the subform is loaded.
444
446
  */
445
- loadSubForm(fromAttach) {
447
+ loadSubForm(fromAttach, beforeSubmit) {
446
448
  var _a, _b, _c, _d, _e;
447
- if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
449
+ const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
450
+ if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
448
451
  return Promise.resolve();
449
452
  }
450
453
  if (this.hasLoadedForm && !this.isRevisionChanged &&
@@ -516,7 +519,7 @@ class FormComponent extends Component_1.default {
516
519
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
517
520
  */
518
521
  get shouldSubmit() {
519
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
522
+ return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
520
523
  }
521
524
  /**
522
525
  * Returns the data for the subform.
@@ -587,8 +590,10 @@ class FormComponent extends Component_1.default {
587
590
  this.dataValue = submission;
588
591
  return Promise.resolve(this.dataValue);
589
592
  }
590
- if (this.isSubFormLazyLoad() && !this.subFormLoading) {
591
- return this.createSubForm(true)
593
+ // we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
594
+ const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
595
+ if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
596
+ return this.createSubForm(true, true)
592
597
  .then(this.submitSubForm(false))
593
598
  .then(() => {
594
599
  return this.dataValue;
@@ -106,7 +106,6 @@ declare class Wizard extends Webform {
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
108
  focusOnComponent(key: any): void | Promise<void>;
109
- triggerButtonCaptcha(page: any): void;
110
109
  }
111
110
  declare namespace Wizard {
112
111
  let setBaseUrl: any;
package/lib/mjs/Wizard.js CHANGED
@@ -659,7 +659,6 @@ export default class Wizard extends Webform {
659
659
  beforeSubmit() {
660
660
  const pages = this.getPages({ all: true });
661
661
  return Promise.all(pages.map((page) => {
662
- this.triggerButtonCaptcha(page);
663
662
  page.options.beforeSubmit = true;
664
663
  return page.beforeSubmit();
665
664
  }));
@@ -930,22 +929,6 @@ export default class Wizard extends Webform {
930
929
  }
931
930
  return super.focusOnComponent(key);
932
931
  }
933
- triggerButtonCaptcha(page) {
934
- if (!page.components) {
935
- return;
936
- }
937
- let captchaComponent;
938
- page.eachComponent((component) => {
939
- if (/^(re)?captcha$/.test(component.component.type) &&
940
- component.component.eventType === 'buttonClick' &&
941
- component.component.buttonKey === 'submit') {
942
- captchaComponent = component;
943
- }
944
- });
945
- if (captchaComponent) {
946
- captchaComponent.verify(`submitClick`);
947
- }
948
- }
949
932
  }
950
933
  Wizard.setBaseUrl = Formio.setBaseUrl;
951
934
  Wizard.setApiUrl = Formio.setApiUrl;
@@ -161,6 +161,7 @@ export default class Component extends Element {
161
161
  properties: {},
162
162
  allowMultipleMasks: false,
163
163
  addons: [],
164
+ serverOverride: {},
164
165
  }, ...sources);
165
166
  }
166
167
  /**
@@ -87,6 +87,9 @@ declare const _default: ({
87
87
  valueProperty?: undefined;
88
88
  data?: undefined;
89
89
  conditional?: undefined;
90
+ as?: undefined;
91
+ editor?: undefined;
92
+ description?: undefined;
90
93
  } | {
91
94
  type: string;
92
95
  label: string;
@@ -103,6 +106,9 @@ declare const _default: ({
103
106
  valueProperty?: undefined;
104
107
  data?: undefined;
105
108
  conditional?: undefined;
109
+ as?: undefined;
110
+ editor?: undefined;
111
+ description?: undefined;
106
112
  } | {
107
113
  weight: number;
108
114
  type: string;
@@ -125,6 +131,9 @@ declare const _default: ({
125
131
  valueProperty?: undefined;
126
132
  data?: undefined;
127
133
  conditional?: undefined;
134
+ as?: undefined;
135
+ editor?: undefined;
136
+ description?: undefined;
128
137
  } | {
129
138
  weight: number;
130
139
  type: string;
@@ -173,6 +182,9 @@ declare const _default: ({
173
182
  valueProperty?: undefined;
174
183
  data?: undefined;
175
184
  conditional?: undefined;
185
+ as?: undefined;
186
+ editor?: undefined;
187
+ description?: undefined;
176
188
  } | {
177
189
  type: string;
178
190
  input: boolean;
@@ -200,6 +212,9 @@ declare const _default: ({
200
212
  defaultValue?: undefined;
201
213
  values?: undefined;
202
214
  logic?: undefined;
215
+ as?: undefined;
216
+ editor?: undefined;
217
+ description?: undefined;
203
218
  } | {
204
219
  weight: number;
205
220
  type: string;
@@ -216,5 +231,27 @@ declare const _default: ({
216
231
  valueProperty?: undefined;
217
232
  data?: undefined;
218
233
  conditional?: undefined;
234
+ as?: undefined;
235
+ editor?: undefined;
236
+ description?: undefined;
237
+ } | {
238
+ type: string;
239
+ as: string;
240
+ editor: string;
241
+ weight: number;
242
+ input: boolean;
243
+ key: string;
244
+ label: string;
245
+ tooltip: string;
246
+ defaultValue: {};
247
+ description: string;
248
+ placeholder?: undefined;
249
+ inline?: undefined;
250
+ values?: undefined;
251
+ logic?: undefined;
252
+ dataSrc?: undefined;
253
+ valueProperty?: undefined;
254
+ data?: undefined;
255
+ conditional?: undefined;
219
256
  })[];
220
257
  export default _default;
@@ -152,5 +152,16 @@ export default [
152
152
  label: 'Allow Manual Override of Calculated Value',
153
153
  tooltip: 'When checked, this will allow the user to manually override the calculated value.'
154
154
  },
155
+ {
156
+ type: 'textarea',
157
+ as: 'json',
158
+ editor: 'ace',
159
+ weight: 1400,
160
+ input: true,
161
+ key: 'serverOverride',
162
+ label: 'Server Override',
163
+ tooltip: 'A JSON object containing the component settings that should be overriden when the form submission is processed on the server side.',
164
+ defaultValue: {},
165
+ description: '<b>Example</b>: { "clearOnHide": true }',
166
+ }
155
167
  ];
156
- /* eslint-enable max-len */
@@ -45,16 +45,18 @@ export default class FormComponent extends Component {
45
45
  /**
46
46
  * Create a subform instance.
47
47
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
48
+ * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
48
49
  * @returns {*} - The subform instance.
49
50
  */
50
- createSubForm(fromAttach?: boolean | undefined): any;
51
+ createSubForm(fromAttach?: boolean | undefined, beforeSubmit?: boolean | undefined): any;
51
52
  hideSubmitButton(component: any): void;
52
53
  /**
53
54
  * Load the subform.
54
55
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
56
+ * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
55
57
  * @returns {Promise} - The promise that resolves when the subform is loaded.
56
58
  */
57
- loadSubForm(fromAttach: boolean): Promise<any>;
59
+ loadSubForm(fromAttach: boolean, beforeSubmit: boolean): Promise<any>;
58
60
  subFormLoading: boolean | undefined;
59
61
  checkComponentConditions(data: any, flags: any, row: any): any;
60
62
  calculateValue(data: any, flags: any, row: any): any;
@@ -375,10 +375,11 @@ export default class FormComponent extends Component {
375
375
  /**
376
376
  * Create a subform instance.
377
377
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
378
+ * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
378
379
  * @returns {*} - The subform instance.
379
380
  */
380
- createSubForm(fromAttach) {
381
- this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
381
+ createSubForm(fromAttach, beforeSubmit) {
382
+ this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
382
383
  if (!form) {
383
384
  return;
384
385
  }
@@ -435,10 +436,12 @@ export default class FormComponent extends Component {
435
436
  /**
436
437
  * Load the subform.
437
438
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
439
+ * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
438
440
  * @returns {Promise} - The promise that resolves when the subform is loaded.
439
441
  */
440
- loadSubForm(fromAttach) {
441
- if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
442
+ loadSubForm(fromAttach, beforeSubmit) {
443
+ const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
444
+ if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
442
445
  return Promise.resolve();
443
446
  }
444
447
  if (this.hasLoadedForm && !this.isRevisionChanged &&
@@ -510,7 +513,7 @@ export default class FormComponent extends Component {
510
513
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
511
514
  */
512
515
  get shouldSubmit() {
513
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
516
+ return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
514
517
  }
515
518
  /**
516
519
  * Returns the data for the subform.
@@ -580,8 +583,10 @@ export default class FormComponent extends Component {
580
583
  this.dataValue = submission;
581
584
  return Promise.resolve(this.dataValue);
582
585
  }
583
- if (this.isSubFormLazyLoad() && !this.subFormLoading) {
584
- return this.createSubForm(true)
586
+ // we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
587
+ const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
588
+ if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
589
+ return this.createSubForm(true, true)
585
590
  .then(this.submitSubForm(false))
586
591
  .then(() => {
587
592
  return this.dataValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6017.d6efba0",
3
+ "version": "5.1.0-dev.6021.879d00c",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {