@websy/websy-designs 1.10.5 → 1.10.7

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.
@@ -12,6 +12,11 @@ module.exports = {
12
12
  const rect = el.getBoundingClientRect()
13
13
  const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft
14
14
  const scrollTop = window.pageYOffset || document.documentElement.scrollTop
15
- return { top: rect.top + scrollTop, left: rect.left + scrollLeft, width: rect.width, height: rect.height }
15
+ return {
16
+ top: rect.top + scrollTop,
17
+ left: rect.left + scrollLeft,
18
+ width: rect.width,
19
+ height: rect.height
20
+ }
16
21
  }
17
22
  }
@@ -2137,6 +2137,7 @@ class WebsyForm {
2137
2137
  const defaults = {
2138
2138
  submit: { text: 'Save', classes: [] },
2139
2139
  useRecaptcha: false,
2140
+ recaptchaAction: 'submit',
2140
2141
  clearAfterSave: false,
2141
2142
  fields: [],
2142
2143
  mode: 'add',
@@ -2199,6 +2200,23 @@ class WebsyForm {
2199
2200
  resolve(false)
2200
2201
  }
2201
2202
  }
2203
+ else if (this.options.useRecaptchaV3 === true) {
2204
+ grecaptcha.ready(() => {
2205
+ grecaptcha.execute(ENVIRONMENT.RECAPTCHA_KEY, { action: this.options.recaptchaAction }).then(token => {
2206
+ this.apiService.add('google/checkrecaptcha', {grecaptcharesponse: token}).then(response => {
2207
+ if (response.success && response.success === true) {
2208
+ resolve(true)
2209
+ grecaptcha.reset(`${this.elementId}_recaptcha`, {sitekey: ENVIRONMENT.RECAPTCHA_KEY})
2210
+ }
2211
+ else {
2212
+ resolve(false)
2213
+ }
2214
+ })
2215
+ }, err => {
2216
+ console.log(err)
2217
+ })
2218
+ })
2219
+ }
2202
2220
  else {
2203
2221
  resolve(true)
2204
2222
  }
@@ -2536,7 +2554,7 @@ class WebsyForm {
2536
2554
  `
2537
2555
  el.innerHTML = html
2538
2556
  this.processComponents(componentsToProcess, () => {
2539
- if (this.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
2557
+ if ((this.options.useRecaptcha === true || this.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
2540
2558
  this.recaptchaReady()
2541
2559
  }
2542
2560
  })
@@ -2626,6 +2644,9 @@ class WebsyForm {
2626
2644
  if (recaptchErrEl) {
2627
2645
  recaptchErrEl.classList.remove('websy-hidden')
2628
2646
  }
2647
+ if (this.options.submitErr) {
2648
+ this.options.submitErr()
2649
+ }
2629
2650
  }
2630
2651
  })
2631
2652
  }
@@ -2128,6 +2128,7 @@ var WebsyForm = /*#__PURE__*/function () {
2128
2128
  classes: []
2129
2129
  },
2130
2130
  useRecaptcha: false,
2131
+ recaptchaAction: 'submit',
2131
2132
  clearAfterSave: false,
2132
2133
  fields: [],
2133
2134
  mode: 'add',
@@ -2198,6 +2199,27 @@ var WebsyForm = /*#__PURE__*/function () {
2198
2199
  } else {
2199
2200
  resolve(false);
2200
2201
  }
2202
+ } else if (_this13.options.useRecaptchaV3 === true) {
2203
+ grecaptcha.ready(function () {
2204
+ grecaptcha.execute(ENVIRONMENT.RECAPTCHA_KEY, {
2205
+ action: _this13.options.recaptchaAction
2206
+ }).then(function (token) {
2207
+ _this13.apiService.add('google/checkrecaptcha', {
2208
+ grecaptcharesponse: token
2209
+ }).then(function (response) {
2210
+ if (response.success && response.success === true) {
2211
+ resolve(true);
2212
+ grecaptcha.reset("".concat(_this13.elementId, "_recaptcha"), {
2213
+ sitekey: ENVIRONMENT.RECAPTCHA_KEY
2214
+ });
2215
+ } else {
2216
+ resolve(false);
2217
+ }
2218
+ });
2219
+ }, function (err) {
2220
+ console.log(err);
2221
+ });
2222
+ });
2201
2223
  } else {
2202
2224
  resolve(true);
2203
2225
  }
@@ -2511,7 +2533,7 @@ var WebsyForm = /*#__PURE__*/function () {
2511
2533
  html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
2512
2534
  el.innerHTML = html;
2513
2535
  this.processComponents(componentsToProcess, function () {
2514
- if (_this18.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
2536
+ if ((_this18.options.useRecaptcha === true || _this18.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
2515
2537
  _this18.recaptchaReady();
2516
2538
  }
2517
2539
  });
@@ -2600,6 +2622,9 @@ var WebsyForm = /*#__PURE__*/function () {
2600
2622
  if (recaptchErrEl) {
2601
2623
  recaptchErrEl.classList.remove('websy-hidden');
2602
2624
  }
2625
+ if (_this19.options.submitErr) {
2626
+ _this19.options.submitErr();
2627
+ }
2603
2628
  }
2604
2629
  });
2605
2630
  }