@salla.sa/twilight-components 2.14.339 → 2.14.340

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.
@@ -10330,6 +10330,8 @@ const sallaQuickBuyCss = ".s-quick-buy-button .s-button-text{display:flex}apple-
10330
10330
  const SallaQuickBuy = class {
10331
10331
  constructor(hostRef) {
10332
10332
  index.registerInstance(this, hostRef);
10333
+ this.validationFailed = index.createEvent(this, "validationFailed");
10334
+ this.requireLogin = index.createEvent(this, "requireLogin");
10333
10335
  /**
10334
10336
  * Button type.
10335
10337
  *
@@ -10351,6 +10353,7 @@ const SallaQuickBuy = class {
10351
10353
  }
10352
10354
  async quickBuyHandler() {
10353
10355
  if (salla.config.isGuest()) {
10356
+ this.requireLogin.emit({ productId: this.productId });
10354
10357
  // todo (low) :: find a way to re-fire the method after success
10355
10358
  let afterLoginEvent = "salla-quick-buy::user.logged-in";
10356
10359
  salla.event.on(afterLoginEvent, () => this.settlePayment());
@@ -10363,6 +10366,7 @@ const SallaQuickBuy = class {
10363
10366
  let optionsElement = document.querySelector(`salla-product-options[product-id="${this.productId}"]`);
10364
10367
  //make sure all the required options are selected
10365
10368
  if (optionsElement && !await optionsElement.reportValidity()) {
10369
+ this.validationFailed.emit({ productId: this.productId });
10366
10370
  return salla.error(salla.lang.get('common.messages.required_fields'));
10367
10371
  }
10368
10372
  //use this way to get quantity too
@@ -10509,7 +10513,7 @@ const SallaQuickBuy = class {
10509
10513
  });
10510
10514
  }
10511
10515
  render() {
10512
- return index.h(index.Host, { key: 'a6093f9df07d58cc290a3376c44847c8b4c345ce' }, this.quickBuyButton());
10516
+ return index.h(index.Host, { key: '326f9d1a5336de18e77a71cef8d4e0118acb8055' }, this.quickBuyButton());
10513
10517
  }
10514
10518
  quickBuyButton() {
10515
10519
  return index.h("apple-pay-button", { locale: salla.config.get('user.language_code'), onClick: () => this.quickBuyHandler(), "data-quick-purchase": "applepay", class: "s-quick-buy-apple-pay", "data-is-applepay": "1", buttonstyle: "black", type: this.type });
@@ -26,6 +26,7 @@ export class SallaQuickBuy {
26
26
  }
27
27
  async quickBuyHandler() {
28
28
  if (salla.config.isGuest()) {
29
+ this.requireLogin.emit({ productId: this.productId });
29
30
  // todo (low) :: find a way to re-fire the method after success
30
31
  let afterLoginEvent = "salla-quick-buy::user.logged-in";
31
32
  salla.event.on(afterLoginEvent, () => this.settlePayment());
@@ -38,6 +39,7 @@ export class SallaQuickBuy {
38
39
  let optionsElement = document.querySelector(`salla-product-options[product-id="${this.productId}"]`);
39
40
  //make sure all the required options are selected
40
41
  if (optionsElement && !await optionsElement.reportValidity()) {
42
+ this.validationFailed.emit({ productId: this.productId });
41
43
  return salla.error(salla.lang.get('common.messages.required_fields'));
42
44
  }
43
45
  //use this way to get quantity too
@@ -184,7 +186,7 @@ export class SallaQuickBuy {
184
186
  });
185
187
  }
186
188
  render() {
187
- return h(Host, { key: 'a6093f9df07d58cc290a3376c44847c8b4c345ce' }, this.quickBuyButton());
189
+ return h(Host, { key: '326f9d1a5336de18e77a71cef8d4e0118acb8055' }, this.quickBuyButton());
188
190
  }
189
191
  quickBuyButton() {
190
192
  return h("apple-pay-button", { locale: salla.config.get('user.language_code'), onClick: () => this.quickBuyHandler(), "data-quick-purchase": "applepay", class: "s-quick-buy-apple-pay", "data-is-applepay": "1", buttonstyle: "black", type: this.type });
@@ -399,5 +401,38 @@ export class SallaQuickBuy {
399
401
  "quickBuy": {}
400
402
  };
401
403
  }
404
+ static get events() {
405
+ return [{
406
+ "method": "validationFailed",
407
+ "name": "validationFailed",
408
+ "bubbles": true,
409
+ "cancelable": true,
410
+ "composed": true,
411
+ "docs": {
412
+ "tags": [],
413
+ "text": "Emitted when Apple Pay button is clicked but form validation fails."
414
+ },
415
+ "complexType": {
416
+ "original": "{ productId: string }",
417
+ "resolved": "{ productId: string; }",
418
+ "references": {}
419
+ }
420
+ }, {
421
+ "method": "requireLogin",
422
+ "name": "requireLogin",
423
+ "bubbles": true,
424
+ "cancelable": true,
425
+ "composed": true,
426
+ "docs": {
427
+ "tags": [],
428
+ "text": "Emitted when Apple Pay button is clicked but user is not logged in."
429
+ },
430
+ "complexType": {
431
+ "original": "{ productId: string }",
432
+ "resolved": "{ productId: string; }",
433
+ "references": {}
434
+ }
435
+ }];
436
+ }
402
437
  static get elementRef() { return "host"; }
403
438
  }
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
4
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
5
5
  import { a as axios } from './axios.js';
6
6
 
7
7
  var Http = {
@@ -724,6 +724,8 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class SallaQuickBuy exten
724
724
  constructor() {
725
725
  super();
726
726
  this.__registerHost();
727
+ this.validationFailed = createEvent(this, "validationFailed", 7);
728
+ this.requireLogin = createEvent(this, "requireLogin", 7);
727
729
  /**
728
730
  * Button type.
729
731
  *
@@ -745,6 +747,7 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class SallaQuickBuy exten
745
747
  }
746
748
  async quickBuyHandler() {
747
749
  if (salla.config.isGuest()) {
750
+ this.requireLogin.emit({ productId: this.productId });
748
751
  // todo (low) :: find a way to re-fire the method after success
749
752
  let afterLoginEvent = "salla-quick-buy::user.logged-in";
750
753
  salla.event.on(afterLoginEvent, () => this.settlePayment());
@@ -757,6 +760,7 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class SallaQuickBuy exten
757
760
  let optionsElement = document.querySelector(`salla-product-options[product-id="${this.productId}"]`);
758
761
  //make sure all the required options are selected
759
762
  if (optionsElement && !await optionsElement.reportValidity()) {
763
+ this.validationFailed.emit({ productId: this.productId });
760
764
  return salla.error(salla.lang.get('common.messages.required_fields'));
761
765
  }
762
766
  //use this way to get quantity too
@@ -903,7 +907,7 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class SallaQuickBuy exten
903
907
  });
904
908
  }
905
909
  render() {
906
- return h(Host, { key: 'a6093f9df07d58cc290a3376c44847c8b4c345ce' }, this.quickBuyButton());
910
+ return h(Host, { key: '326f9d1a5336de18e77a71cef8d4e0118acb8055' }, this.quickBuyButton());
907
911
  }
908
912
  quickBuyButton() {
909
913
  return h("apple-pay-button", { locale: salla.config.get('user.language_code'), onClick: () => this.quickBuyHandler(), "data-quick-purchase": "applepay", class: "s-quick-buy-apple-pay", "data-is-applepay": "1", buttonstyle: "black", type: this.type });
@@ -10310,6 +10310,8 @@ const sallaQuickBuyCss = ".s-quick-buy-button .s-button-text{display:flex}apple-
10310
10310
  const SallaQuickBuy = class {
10311
10311
  constructor(hostRef) {
10312
10312
  registerInstance(this, hostRef);
10313
+ this.validationFailed = createEvent(this, "validationFailed");
10314
+ this.requireLogin = createEvent(this, "requireLogin");
10313
10315
  /**
10314
10316
  * Button type.
10315
10317
  *
@@ -10331,6 +10333,7 @@ const SallaQuickBuy = class {
10331
10333
  }
10332
10334
  async quickBuyHandler() {
10333
10335
  if (salla.config.isGuest()) {
10336
+ this.requireLogin.emit({ productId: this.productId });
10334
10337
  // todo (low) :: find a way to re-fire the method after success
10335
10338
  let afterLoginEvent = "salla-quick-buy::user.logged-in";
10336
10339
  salla.event.on(afterLoginEvent, () => this.settlePayment());
@@ -10343,6 +10346,7 @@ const SallaQuickBuy = class {
10343
10346
  let optionsElement = document.querySelector(`salla-product-options[product-id="${this.productId}"]`);
10344
10347
  //make sure all the required options are selected
10345
10348
  if (optionsElement && !await optionsElement.reportValidity()) {
10349
+ this.validationFailed.emit({ productId: this.productId });
10346
10350
  return salla.error(salla.lang.get('common.messages.required_fields'));
10347
10351
  }
10348
10352
  //use this way to get quantity too
@@ -10489,7 +10493,7 @@ const SallaQuickBuy = class {
10489
10493
  });
10490
10494
  }
10491
10495
  render() {
10492
- return h(Host, { key: 'a6093f9df07d58cc290a3376c44847c8b4c345ce' }, this.quickBuyButton());
10496
+ return h(Host, { key: '326f9d1a5336de18e77a71cef8d4e0118acb8055' }, this.quickBuyButton());
10493
10497
  }
10494
10498
  quickBuyButton() {
10495
10499
  return h("apple-pay-button", { locale: salla.config.get('user.language_code'), onClick: () => this.quickBuyHandler(), "data-quick-purchase": "applepay", class: "s-quick-buy-apple-pay", "data-is-applepay": "1", buttonstyle: "black", type: this.type });