@formio/js 5.1.0-dev.6024.3b197fc → 5.1.0-dev.6025.8026a2f

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.
@@ -455,7 +455,7 @@ declare class Webform extends NestedDataComponent {
455
455
  */
456
456
  submit(before?: boolean, options?: any): Promise<any>;
457
457
  submitUrl(URL: any, headers: any): void;
458
- triggerCaptcha(): void;
458
+ triggerCaptcha(components?: null): void;
459
459
  _nosubmit: any;
460
460
  get conditions(): any;
461
461
  get variables(): any;
@@ -1534,17 +1534,20 @@ class Webform extends NestedDataComponent_1.default {
1534
1534
  return console.warn(message);
1535
1535
  }
1536
1536
  }
1537
- triggerCaptcha() {
1537
+ triggerCaptcha(components = null) {
1538
1538
  if (!this || !this.components || this.options.preview) {
1539
1539
  return;
1540
1540
  }
1541
1541
  const captchaComponent = [];
1542
- (0, formUtils_1.eachComponent)(this.components, (component) => {
1542
+ (0, formUtils_1.eachComponent)(components || this.components, (component) => {
1543
1543
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1544
1544
  captchaComponent.push(component);
1545
1545
  }
1546
1546
  }, true);
1547
1547
  if (captchaComponent.length > 0) {
1548
+ if (captchaComponent[0].component.provider === 'google' && components) {
1549
+ return;
1550
+ }
1548
1551
  if (this.parent) {
1549
1552
  this.parent.subFormReady.then(() => {
1550
1553
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
@@ -1553,7 +1556,6 @@ class Webform extends NestedDataComponent_1.default {
1553
1556
  else {
1554
1557
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1555
1558
  }
1556
- ;
1557
1559
  }
1558
1560
  }
1559
1561
  set nosubmit(value) {
package/lib/cjs/Wizard.js CHANGED
@@ -602,6 +602,7 @@ class Wizard extends Webform_1.default {
602
602
  }
603
603
  this.redraw().then(() => {
604
604
  this.checkData(this.submission.data);
605
+ this.triggerCaptcha(this.currentPanel.componets);
605
606
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
606
607
  if (this.alert) {
607
608
  this.showErrors(errors, true, true);
@@ -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;
@@ -455,7 +455,7 @@ declare class Webform extends NestedDataComponent {
455
455
  */
456
456
  submit(before?: boolean, options?: any): Promise<any>;
457
457
  submitUrl(URL: any, headers: any): void;
458
- triggerCaptcha(): void;
458
+ triggerCaptcha(components?: null): void;
459
459
  _nosubmit: any;
460
460
  get conditions(): any;
461
461
  get variables(): any;
@@ -1534,17 +1534,20 @@ export default class Webform extends NestedDataComponent {
1534
1534
  return console.warn(message);
1535
1535
  }
1536
1536
  }
1537
- triggerCaptcha() {
1537
+ triggerCaptcha(components = null) {
1538
1538
  if (!this || !this.components || this.options.preview) {
1539
1539
  return;
1540
1540
  }
1541
1541
  const captchaComponent = [];
1542
- eachComponent(this.components, (component) => {
1542
+ eachComponent(components || this.components, (component) => {
1543
1543
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1544
1544
  captchaComponent.push(component);
1545
1545
  }
1546
1546
  }, true);
1547
1547
  if (captchaComponent.length > 0) {
1548
+ if (captchaComponent[0].component.provider === 'google' && components) {
1549
+ return;
1550
+ }
1548
1551
  if (this.parent) {
1549
1552
  this.parent.subFormReady.then(() => {
1550
1553
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
@@ -1553,7 +1556,6 @@ export default class Webform extends NestedDataComponent {
1553
1556
  else {
1554
1557
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1555
1558
  }
1556
- ;
1557
1559
  }
1558
1560
  }
1559
1561
  set nosubmit(value) {
package/lib/mjs/Wizard.js CHANGED
@@ -594,6 +594,7 @@ export default class Wizard extends Webform {
594
594
  }
595
595
  this.redraw().then(() => {
596
596
  this.checkData(this.submission.data);
597
+ this.triggerCaptcha(this.currentPanel.componets);
597
598
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
598
599
  if (this.alert) {
599
600
  this.showErrors(errors, true, true);
@@ -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.6024.3b197fc",
3
+ "version": "5.1.0-dev.6025.8026a2f",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {