@salla.sa/twilight-components 1.6.15-alpha.20 → 1.6.15-alpha.3

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.
Files changed (125) hide show
  1. package/dist/cjs/{index-ccab76e9.js → index-98e1eea0.js} +2 -2
  2. package/dist/cjs/{index-2d91726c.js → index-cac2fd59.js} +10 -89
  3. package/dist/cjs/loader.cjs.js +3 -3
  4. package/dist/cjs/salla-add-product-button.cjs.entry.js +1 -1
  5. package/dist/cjs/{salla-button_29.cjs.entry.js → salla-button_27.cjs.entry.js} +107 -231
  6. package/dist/cjs/salla-conditional-fields.cjs.entry.js +1 -1
  7. package/dist/cjs/salla-installment.cjs.entry.js +9 -4
  8. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  9. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  10. package/dist/cjs/salla-select.cjs.entry.js +1 -1
  11. package/dist/cjs/twilight.cjs.js +3 -3
  12. package/dist/collection/Helpers/Helper.js +15 -22
  13. package/dist/collection/collection-manifest.json +0 -2
  14. package/dist/collection/components/salla-gifting/salla-gifting.js +3 -9
  15. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +2 -1
  16. package/dist/collection/components/salla-installment/salla-installment.css +0 -3
  17. package/dist/collection/components/salla-installment/salla-installment.js +7 -2
  18. package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +4 -2
  19. package/dist/collection/components/salla-login-modal/salla-login-modal.js +1 -1
  20. package/dist/collection/components/salla-modal/salla-modal.js +9 -18
  21. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +28 -61
  22. package/dist/collection/components/salla-placeholder/salla-placeholder.js +6 -6
  23. package/dist/collection/components/salla-product-availability/salla-product-availability.js +2 -2
  24. package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +32 -32
  25. package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +1 -1
  26. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +18 -15
  27. package/dist/collection/components/salla-rating-stars/salla-rating-stars.js +1 -1
  28. package/dist/collection/components/salla-search/salla-search.js +4 -3
  29. package/dist/collection/components/salla-swiper/salla-swiper.js +0 -1
  30. package/dist/collection/components/salla-tel-input/salla-tel-input.js +4 -2
  31. package/dist/collection/components/salla-verify/salla-verify.js +33 -38
  32. package/dist/components/Helper.js +15 -22
  33. package/dist/components/index.d.ts +0 -2
  34. package/dist/components/index.js +2 -4
  35. package/dist/components/salla-gifting.js +3 -7
  36. package/dist/components/salla-infinite-scroll.js +1 -0
  37. package/dist/components/salla-installment.js +8 -3
  38. package/dist/components/salla-localization-modal.js +4 -2
  39. package/dist/components/salla-login-modal.js +1 -1
  40. package/dist/components/salla-modal2.js +8 -10
  41. package/dist/components/salla-offer-modal.js +19 -41
  42. package/dist/components/salla-placeholder2.js +2 -2
  43. package/dist/components/salla-product-availability2.js +1 -1
  44. package/dist/components/salla-product-size-guide.js +6 -13
  45. package/dist/components/salla-rating-modal.js +21 -21
  46. package/dist/components/salla-rating-stars2.js +1 -1
  47. package/dist/components/salla-search.js +4 -3
  48. package/dist/components/salla-swiper2.js +0 -1
  49. package/dist/components/salla-tel-input2.js +3 -1
  50. package/dist/components/salla-verify2.js +31 -37
  51. package/dist/esm/{index-03197930.js → index-0ce70ad2.js} +10 -89
  52. package/dist/esm/{index-1cc8829f.js → index-294a3ac7.js} +2 -2
  53. package/dist/esm/loader.js +3 -3
  54. package/dist/esm/salla-add-product-button.entry.js +1 -1
  55. package/dist/esm/{salla-button_29.entry.js → salla-button_27.entry.js} +108 -230
  56. package/dist/esm/salla-conditional-fields.entry.js +1 -1
  57. package/dist/esm/salla-installment.entry.js +9 -4
  58. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  59. package/dist/esm/salla-scopes.entry.js +1 -1
  60. package/dist/esm/salla-select.entry.js +1 -1
  61. package/dist/esm/twilight.js +3 -3
  62. package/dist/esm-es5/index-0ce70ad2.js +4 -0
  63. package/dist/esm-es5/index-294a3ac7.js +24 -0
  64. package/dist/esm-es5/loader.js +1 -1
  65. package/dist/esm-es5/salla-add-product-button.entry.js +1 -1
  66. package/dist/esm-es5/salla-button_27.entry.js +34 -0
  67. package/dist/esm-es5/salla-conditional-fields.entry.js +1 -1
  68. package/dist/esm-es5/salla-installment.entry.js +1 -1
  69. package/dist/esm-es5/salla-loyalty-prize-item.entry.js +1 -1
  70. package/dist/esm-es5/salla-scopes.entry.js +1 -1
  71. package/dist/esm-es5/salla-select.entry.js +1 -1
  72. package/dist/esm-es5/twilight.js +1 -1
  73. package/dist/twilight/p-05eb9983.system.js +24 -0
  74. package/dist/twilight/p-0db2b810.entry.js +4 -0
  75. package/dist/twilight/{p-2b8f1167.entry.js → p-10ac9c79.entry.js} +1 -1
  76. package/dist/twilight/{p-06ecc027.entry.js → p-13129ac9.entry.js} +1 -1
  77. package/dist/twilight/{p-f0415183.system.entry.js → p-1914490f.system.entry.js} +1 -1
  78. package/dist/twilight/p-24e726cc.system.entry.js +34 -0
  79. package/dist/twilight/{p-3feb37f5.system.entry.js → p-26a23097.system.entry.js} +1 -1
  80. package/dist/twilight/p-44829812.system.js +4 -0
  81. package/dist/twilight/{p-092ad6d4.entry.js → p-521b6fde.entry.js} +1 -1
  82. package/dist/twilight/p-5b6fe797.js +24 -0
  83. package/dist/twilight/{p-bac267ae.entry.js → p-97daba27.entry.js} +1 -1
  84. package/dist/twilight/{p-a1cd00a6.system.entry.js → p-a7caaba3.system.entry.js} +1 -1
  85. package/dist/twilight/{p-20584294.entry.js → p-bbc94b9b.entry.js} +1 -1
  86. package/dist/twilight/p-ca68752d.js +5 -0
  87. package/dist/twilight/p-ce3e3fa2.system.entry.js +4 -0
  88. package/dist/twilight/p-d64f3123.entry.js +22 -0
  89. package/dist/twilight/p-db0ba553.system.js +5 -0
  90. package/dist/twilight/{p-f7bb47ef.system.entry.js → p-dd9b3c90.system.entry.js} +1 -1
  91. package/dist/twilight/{p-a82f8d33.system.entry.js → p-f610b6bf.system.entry.js} +1 -1
  92. package/dist/twilight/twilight.esm.js +1 -1
  93. package/dist/twilight/twilight.js +1 -1
  94. package/dist/types/Helpers/Helper.d.ts +6 -6
  95. package/dist/types/components/salla-installment/salla-installment.d.ts +2 -1
  96. package/dist/types/components/salla-modal/salla-modal.d.ts +0 -1
  97. package/dist/types/components/salla-offer-modal/offer-schema.d.ts +0 -1
  98. package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +0 -4
  99. package/dist/types/components/salla-placeholder/salla-placeholder.d.ts +3 -3
  100. package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +1 -2
  101. package/dist/types/components/salla-verify/salla-verify.d.ts +1 -2
  102. package/dist/types/components.d.ts +7 -35
  103. package/package.json +4 -4
  104. package/dist/collection/components/salla-cart-summary/salla-cart-summary.css +0 -3
  105. package/dist/collection/components/salla-cart-summary/salla-cart-summary.js +0 -35
  106. package/dist/collection/components/salla-user-settings/salla-user-settings.css +0 -0
  107. package/dist/collection/components/salla-user-settings/salla-user-settings.js +0 -107
  108. package/dist/components/salla-cart-summary.d.ts +0 -11
  109. package/dist/components/salla-cart-summary.js +0 -53
  110. package/dist/components/salla-user-settings.d.ts +0 -11
  111. package/dist/components/salla-user-settings.js +0 -116
  112. package/dist/esm-es5/index-03197930.js +0 -4
  113. package/dist/esm-es5/index-1cc8829f.js +0 -24
  114. package/dist/esm-es5/salla-button_29.entry.js +0 -34
  115. package/dist/twilight/p-2bdd14ea.entry.js +0 -22
  116. package/dist/twilight/p-a058465b.system.js +0 -24
  117. package/dist/twilight/p-a2cc9062.entry.js +0 -4
  118. package/dist/twilight/p-b95c5d8c.system.entry.js +0 -34
  119. package/dist/twilight/p-c571b40b.js +0 -5
  120. package/dist/twilight/p-ca961962.system.js +0 -5
  121. package/dist/twilight/p-ee91a41b.system.js +0 -4
  122. package/dist/twilight/p-f59fe82e.js +0 -24
  123. package/dist/twilight/p-f99821d3.system.entry.js +0 -4
  124. package/dist/types/components/salla-cart-summary/salla-cart-summary.d.ts +0 -6
  125. package/dist/types/components/salla-user-settings/salla-user-settings.d.ts +0 -18
@@ -2,6 +2,7 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { Component, h, Element, Method, State } from '@stencil/core';
5
+ import Helper from "../../Helpers/Helper";
5
6
  import SpecialDiscountIcon from '../../assets/svg/special-discount.svg';
6
7
  import KeyboardArrowRightIcon from "../../assets/svg/keyboard_arrow_right.svg";
7
8
  import KeyboardArrowLeftIcon from "../../assets/svg/keyboard_arrow_left.svg";
@@ -18,15 +19,13 @@ export class SallaOfferModal {
18
19
  this.offer = null;
19
20
  this.hasError = false;
20
21
  this.translationLoaded = false;
21
- this.addToCartLabel = salla.lang.get("pages.cart.add_to_cart");
22
- salla.event.on('offer-modal::open', product_id => this.open(product_id));
22
+ Helper.setHost(this.host);
23
+ salla.event.on('offer-modal::open', (product_id) => this.open(product_id));
23
24
  salla.lang.onLoaded(() => {
24
- this.addToCartLabel = salla.lang.get("pages.cart.add_to_cart");
25
25
  this.translationLoaded = true;
26
26
  });
27
- this.categorySlot = ((_a = this.host.querySelector('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || `<span class="s-offer-modal-badge-icon">{tagIcon}</span><span class="s-offer-modal-badge-text">{name}</span>`;
28
- this.productSlot = ((_b = this.host.querySelector('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
29
- salla.event.on('offer-modal::open', product_id => this.open(product_id));
27
+ this.categorySlot = ((_a = Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || `<span class="s-offer-modal-badge-icon">{tagIcon}</span><span class="s-offer-modal-badge-text">{name}</span>`;
28
+ this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
30
29
  salla.product.event.onOfferExisted(offer => {
31
30
  if (salla.storage.get('remember-offer-' + offer.id)) {
32
31
  salla.log('User selected to don\'t show this offer again.');
@@ -40,7 +39,6 @@ export class SallaOfferModal {
40
39
  * @param product_id
41
40
  */
42
41
  async open(product_id) {
43
- this.productID = product_id;
44
42
  //TODO:: make sure there is only one offer
45
43
  this.modal.open();
46
44
  return salla.api.withoutNotifier(() => salla.product.offers(product_id))
@@ -65,54 +63,6 @@ export class SallaOfferModal {
65
63
  rememberMe(event) {
66
64
  salla.storage.set('remember-offer-' + this.offer.id, event.target.checked);
67
65
  }
68
- addToCart(qty) {
69
- //todo:: add enhancement, to cover the previous quantity, because if the discount to add two, user already added one before.
70
- salla.api.withoutNotifier(() => salla.cart.quickAdd(this.productID, qty)).then(() => this.modal.close());
71
- }
72
- getOfferContent() {
73
- var _a, _b, _c, _d;
74
- if ((_a = this.offer.get.products) === null || _a === void 0 ? void 0 : _a.length) {
75
- return h("div", { class: "s-offer-modal-scrolled-slider-wrap" },
76
- h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: {
77
- "s-offer-modal-product": true,
78
- "s-offer-modal-slider-item": true,
79
- "s-offer-modal-not-available": !product.is_available
80
- }, id: 'product_' + product.id, innerHTML: this.productSlot
81
- .replace(/\{name\}/g, product.name)
82
- .replace(/\{url\}/g, product.url)
83
- .replace(/\{image\}/g, product.thumbnail)
84
- .replace(/\{price\}/g, product.has_special_price
85
- ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
86
- : salla.money(product.price)) },
87
- h("div", { class: "s-offer-modal-btn-wrap" },
88
- h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? salla.lang.get('pages.cart.add_to_cart') : salla.lang.get('pages.products.out_of_stock')))))),
89
- h("div", { class: "s-offer-modal-slider-nav" },
90
- h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" },
91
- h("span", { class: "s-offer-modal-nav-btn-icon", innerHTML: KeyboardArrowLeftIcon })),
92
- h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" },
93
- h("span", { class: "s-offer-modal-nav-btn-icon", innerHTML: KeyboardArrowRightIcon }))));
94
- }
95
- else if ((_c = this.offer.get.categories) === null || _c === void 0 ? void 0 : _c.length) {
96
- return h("div", { class: "s-offer-modal-scrolled-slider-wrap" },
97
- h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item", innerHTML: this.categorySlot
98
- .replace(/\{tagIcon\}/g, Tag)
99
- .replace(/\{name\}/g, category.name)
100
- .replace(/\{url\}/g, category.urls.customer) }))),
101
- h("div", { class: "s-offer-modal-slider-nav" },
102
- h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" },
103
- h("span", { class: "s-offer-modal-nav-btn-icon", innerHTML: KeyboardArrowLeftIcon })),
104
- h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" },
105
- h("span", { class: "s-offer-modal-nav-btn-icon", innerHTML: KeyboardArrowRightIcon }))));
106
- }
107
- else if (this.offer.get.discounts_table) {
108
- return h("div", { class: "s-offer-modal-discount-table" },
109
- h("table", null,
110
- h("tbody", null, (_d = this.offer.get.discounts_table) === null || _d === void 0 ? void 0 : _d.map(discount => h("tr", null,
111
- h("td", null, discount.text),
112
- h("td", { class: "s-offer-modal-discount-table-cell" },
113
- h("salla-button", { fill: "outline", shape: "btn", color: "primary", size: "medium", width: "normal", onClick: () => this.addToCart(discount.quantity) }, this.addToCartLabel)))))));
114
- }
115
- }
116
66
  //todo:: pass event then use sallaButton from it
117
67
  addItem() {
118
68
  // this here, is sallaButton
@@ -129,6 +79,7 @@ export class SallaOfferModal {
129
79
  '</div>';
130
80
  }
131
81
  render() {
82
+ var _a, _b;
132
83
  return h("salla-modal", { "sub-title-first": true, "has-skeleton": true, "sub-title": this.offer_message, ref: modal => this.modal = modal, isLoading: true },
133
84
  h("div", { slot: 'loading' },
134
85
  h("div", { class: "s-offer-modal-skeleton" },
@@ -147,7 +98,26 @@ export class SallaOfferModal {
147
98
  h("salla-skeleton", { height: '15px', width: '50%' }),
148
99
  h("salla-skeleton", { height: '15px', width: '30%' })))),
149
100
  !this.hasError && this.offer !== null
150
- ? [h("span", { slot: 'icon', class: "s-offer-modal-header-icon", innerHTML: SpecialDiscountIcon }), this.getOfferContent(), h("div", { class: "s-offer-modal-footer", slot: "footer" },
101
+ ? [h("span", { slot: 'icon', class: "s-offer-modal-header-icon", innerHTML: SpecialDiscountIcon }), h("div", { class: "s-offer-modal-scrolled-slider-wrap" },
102
+ h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
103
+ ? this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item", innerHTML: this.categorySlot
104
+ .replace(/\{tagIcon\}/g, Tag)
105
+ .replace(/\{name\}/g, category.name)
106
+ .replace(/\{url\}/g, category.urls.customer) }))
107
+ : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: { "s-offer-modal-product": true, "s-offer-modal-slider-item": true, "s-offer-modal-not-available": !product.is_available }, id: 'product_' + product.id, innerHTML: this.productSlot
108
+ .replace(/\{name\}/g, product.name)
109
+ .replace(/\{url\}/g, product.url)
110
+ .replace(/\{image\}/g, product.thumbnail)
111
+ .replace(/\{price\}/g, product.has_special_price
112
+ ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
113
+ : salla.money(product.price)) },
114
+ h("div", { class: "s-offer-modal-btn-wrap" },
115
+ h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? salla.lang.get('pages.cart.add_to_cart') : salla.lang.get('pages.products.out_of_stock')))))),
116
+ h("div", { class: "s-offer-modal-slider-nav" },
117
+ h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" },
118
+ h("span", { class: "s-offer-modal-nav-btn-icon", innerHTML: KeyboardArrowLeftIcon })),
119
+ h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" },
120
+ h("span", { class: "s-offer-modal-nav-btn-icon", innerHTML: KeyboardArrowRightIcon })))), h("div", { class: "s-offer-modal-footer", slot: "footer" },
151
121
  this.offer.formatted_date ?
152
122
  h("p", { class: "s-offer-modal-expiry" },
153
123
  salla.lang.get('pages.products.offer_expires_in'),
@@ -162,9 +132,8 @@ export class SallaOfferModal {
162
132
  h("salla-placeholder", { class: "s-loyalty-placeholder", alignment: "center" }, !!this.errorMessage ? h("span", { slot: "description" }, this.errorMessage) : ''));
163
133
  }
164
134
  componentDidRender() {
165
- var _a, _b;
166
135
  // Sooo mini Slider
167
- if (this.offer && (((_a = this.offer.get.products) === null || _a === void 0 ? void 0 : _a.length) || ((_b = this.offer.get.categories) === null || _b === void 0 ? void 0 : _b.length)) && window.screen.width > 639) {
136
+ if (this.offer && window.screen.width > 639) {
168
137
  let sliderWrap = this.modal.querySelector('.s-offer-modal-scrolled-slider-wrap'), slider = this.modal.querySelector('.s-offer-modal-scrolled-slider'), navButtons = this.modal.querySelectorAll('.s-offer-modal-nav-btn'), nexBtn = this.modal.querySelector('.s-offer-modal-next-btn'), prevBtn = this.modal.querySelector('.s-offer-modal-prev-btn'), items = this.modal.querySelectorAll('.s-offer-modal-slider-item'), sliderNavMargin = 20, // space before displaying the next/prev btns.
169
138
  current = 0, // current slide
170
139
  slidesToScroll = 3, itemsLength = items.length;
@@ -220,9 +189,7 @@ export class SallaOfferModal {
220
189
  "offer_message": {},
221
190
  "hasError": {},
222
191
  "errorMessage": {},
223
- "productID": {},
224
- "translationLoaded": {},
225
- "addToCartLabel": {}
192
+ "translationLoaded": {}
226
193
  }; }
227
194
  static get methods() { return {
228
195
  "open": {
@@ -7,7 +7,7 @@ export class SallaPlaceholder {
7
7
  constructor() {
8
8
  this.translationLoaded = false;
9
9
  /**
10
- * Custom icon to display, defaults to [`Inbox`], can be any valid svg icon or inline element with font icon
10
+ * Custom icon to display, defaults to [`sicon-inbox`]
11
11
  */
12
12
  this.icon = Inbox;
13
13
  /**
@@ -15,7 +15,7 @@ export class SallaPlaceholder {
15
15
  */
16
16
  this.alignment = 'left';
17
17
  /**
18
- * The size of the icon. Defaults to [`md`] = 45px for font icon & width/height: 3.5rem for svg icon
18
+ * The size of the icon. Defaults to [`md`]
19
19
  */
20
20
  this.iconSize = 'md';
21
21
  salla.lang.onLoaded(() => {
@@ -60,7 +60,7 @@ export class SallaPlaceholder {
60
60
  "optional": false,
61
61
  "docs": {
62
62
  "tags": [],
63
- "text": "Custom icon to display, defaults to [`Inbox`], can be any valid svg icon or inline element with font icon"
63
+ "text": "Custom icon to display, defaults to [`sicon-inbox`]"
64
64
  },
65
65
  "attribute": "icon",
66
66
  "reflect": false,
@@ -88,15 +88,15 @@ export class SallaPlaceholder {
88
88
  "type": "string",
89
89
  "mutable": false,
90
90
  "complexType": {
91
- "original": "'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'xxxl'",
92
- "resolved": "\"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\" | \"xxl\" | \"xxxl\"",
91
+ "original": "'xs' | 'sm' | 'md' | 'lg' | 'xl'",
92
+ "resolved": "\"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\"",
93
93
  "references": {}
94
94
  },
95
95
  "required": false,
96
96
  "optional": false,
97
97
  "docs": {
98
98
  "tags": [],
99
- "text": "The size of the icon. Defaults to [`md`] = 45px for font icon & width/height: 3.5rem for svg icon"
99
+ "text": "The size of the icon. Defaults to [`md`]"
100
100
  },
101
101
  "attribute": "icon-size",
102
102
  "reflect": false,
@@ -2,11 +2,11 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';
5
- import BellRingIcon from '../../assets/svg/bell-ring.svg';
6
5
  import Helper from '../../Helpers/Helper';
6
+ import BellRingIcon from '../../assets/svg/bell-ring.svg';
7
7
  export class SallaProductAvailability {
8
8
  constructor() {
9
- this.isUser = salla.config.isUser();
9
+ this.isUser = Helper.isUser();
10
10
  this.translationLoaded = false;
11
11
  /**
12
12
  * product id that can visitor subscribe to its availability notification
@@ -1,11 +1,12 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { Component, State, Method, Element, h } from '@stencil/core';
5
- import PencilRuler from "../../assets/svg/pencil-ruler.svg";
4
+ import { Component, Host, State, Method, Element, h } from '@stencil/core';
5
+ import Helper from "../../Helpers/Helper";
6
6
  export class SallaProductSizeGuide {
7
7
  constructor() {
8
8
  this.hasError = false;
9
+ Helper.setHost(document);
9
10
  salla.event.on('size-guide::open', (product_id) => this.open(product_id));
10
11
  salla.lang.onLoaded(() => {
11
12
  this.placeholder_title = salla.lang.get('pages.products.size_guide_placeholder');
@@ -45,37 +46,36 @@ export class SallaProductSizeGuide {
45
46
  h("div", { slot: "description" }, this.placeholder_description));
46
47
  }
47
48
  render() {
48
- return (h("salla-modal", { class: "s-product-size-guide-wrapper", id: 'salla-product-size-guide-modal', isLoading: true, "has-skeleton": true, width: "md", ref: modal => this.modal = modal },
49
- h("span", { slot: 'icon', class: "s-product-size-guide-header-icon", innerHTML: PencilRuler }),
50
- h("div", { slot: "loading" },
51
- h("div", { class: "s-product-size-guide-skeleton" },
52
- h("salla-skeleton", { height: '15px', width: '25%' }),
53
- h("div", { class: "s-product-size-guide-skeleton-header" },
54
- h("salla-skeleton", { height: '40px' }),
55
- h("salla-skeleton", { height: '40px' }),
56
- h("salla-skeleton", { height: '40px' }),
57
- h("salla-skeleton", { height: '40px' })),
58
- h("div", { class: "s-product-size-guide-skeleton-content" },
49
+ return (h(Host, { class: "s-product-size-guide-block" },
50
+ h("salla-modal", { id: 'salla-product-size-guide-modal', isLoading: true, "has-skeleton": true, width: "md", ref: modal => this.modal = modal },
51
+ h("div", { slot: "loading" },
52
+ h("div", { class: "s-product-size-guide-skeleton" },
59
53
  h("salla-skeleton", { height: '15px', width: '25%' }),
60
- h("salla-skeleton", { height: '10px', width: '75%' }),
61
- h("salla-skeleton", { height: '10px', width: '50%' }),
62
- h("salla-skeleton", { height: '10px', width: '75%' }),
63
- h("salla-skeleton", { height: '10px', width: '100%' }),
64
- h("salla-skeleton", { height: '10px', width: '25%' }),
65
- h("salla-skeleton", { height: '10px', width: '60%' }),
66
- h("salla-skeleton", { height: '10px', width: '45%' }),
67
- h("salla-skeleton", { height: '10px', width: '30%' })))),
68
- h("slot", { name: "header" }),
69
- !this.hasError && !!this.guides ?
70
- [
71
- h("salla-tabs", null,
72
- this.guides.map((guide) => h("salla-tab-header", { slot: "header", name: guide.name },
73
- h("span", null, guide.name))),
74
- this.guides.map((guide) => h("salla-tab-content", { slot: "content", name: guide.name },
75
- h("div", { innerHTML: guide.description }))))
76
- ]
77
- : this.showPlaceholder(),
78
- h("slot", { name: "footer" })));
54
+ h("div", { class: "s-product-size-guide-skeleton-header" },
55
+ h("salla-skeleton", { height: '40px' }),
56
+ h("salla-skeleton", { height: '40px' }),
57
+ h("salla-skeleton", { height: '40px' }),
58
+ h("salla-skeleton", { height: '40px' })),
59
+ h("div", { class: "s-product-size-guide-skeleton-content" },
60
+ h("salla-skeleton", { height: '15px', width: '25%' }),
61
+ h("salla-skeleton", { height: '10px', width: '75%' }),
62
+ h("salla-skeleton", { height: '10px', width: '50%' }),
63
+ h("salla-skeleton", { height: '10px', width: '75%' }),
64
+ h("salla-skeleton", { height: '10px', width: '100%' }),
65
+ h("salla-skeleton", { height: '10px', width: '25%' }),
66
+ h("salla-skeleton", { height: '10px', width: '60%' }),
67
+ h("salla-skeleton", { height: '10px', width: '45%' }),
68
+ h("salla-skeleton", { height: '10px', width: '30%' })))),
69
+ h("slot", { name: "header" }),
70
+ !this.hasError && !!this.guides ?
71
+ [h("div", { class: "container px-8" },
72
+ h("salla-tabs", null,
73
+ this.guides.map((guide) => h("salla-tab-header", { slot: "header", name: guide.name },
74
+ h("span", null, guide.name))),
75
+ this.guides.map((guide) => h("salla-tab-content", { slot: "content", name: guide.name },
76
+ h("div", { innerHTML: guide.description })))))]
77
+ : this.showPlaceholder(),
78
+ h("slot", { name: "footer" }))));
79
79
  }
80
80
  static get is() { return "salla-product-size-guide"; }
81
81
  static get originalStyleUrls() { return {
@@ -2,9 +2,9 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { Component, Element, Host, State, Watch, h, Method } from '@stencil/core';
5
+ import Helper from "../../Helpers/Helper";
5
6
  import Add from "../../assets/svg/add.svg";
6
7
  import Minus from "../../assets/svg/minus.svg";
7
- import Helper from '../../Helpers/Helper';
8
8
  export class SallaQuantityInput {
9
9
  constructor() {
10
10
  this.hostAttributes = {};
@@ -2,10 +2,10 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { Component, h, Method, Element, Host, State, Prop } from '@stencil/core';
5
+ import Helper from "../../Helpers/Helper";
5
6
  import Star from '../../assets/svg/star.svg';
6
7
  import ShippingFast from "../../assets/svg/shipping-fast.svg";
7
8
  import CheckCircle2 from "../../assets/svg/check-circle2.svg";
8
- import Helper from '../../Helpers/Helper';
9
9
  export class SallaRatingModal {
10
10
  constructor() {
11
11
  this.hasError = false;
@@ -17,6 +17,7 @@ export class SallaRatingModal {
17
17
  */
18
18
  this.orderId = salla.config.get('page.id');
19
19
  this.translationLoaded = false;
20
+ Helper.setHost(document);
20
21
  salla.event.on('rating::open', () => this.open());
21
22
  salla.lang.onLoaded(() => {
22
23
  this.translationLoaded = true;
@@ -26,17 +27,22 @@ export class SallaRatingModal {
26
27
  * Show the rating modal
27
28
  */
28
29
  async open() {
29
- return this.modal.open()
30
- .then(() => this.order || salla.api.withoutNotifier(() => salla.rating.api.order(this.orderId)).then(res => this.order = res.data))
31
- .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
32
- .then(() => this.modal.stopLoading())
33
- .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
34
- .then(() => setTimeout(() => this.handleWizard(), 100))
30
+ this.modal.open();
31
+ return await salla.api.withoutNotifier(() => salla.rating.api.order(this.orderId))
32
+ .then(res => this.order = res.data)
35
33
  .catch(e => {
36
34
  var _a, _b, _c, _d;
37
35
  this.hasError = true;
38
36
  this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
39
- this.modal.stopLoading();
37
+ })
38
+ .finally(() => {
39
+ var _a, _b, _c;
40
+ this.modal.setTitle(`${salla.lang.get('pages.rating.rate_order')} <span class="unicode">${!!this.order ? `(#${this.order.id})` : ''}</span>`);
41
+ this.stepsCount = [(_a = this.order) === null || _a === void 0 ? void 0 : _a.testimonials_enabled, (_b = this.order) === null || _b === void 0 ? void 0 : _b.products_enabled, (_c = this.order) === null || _c === void 0 ? void 0 : _c.shipping_enabled].filter(enabled => enabled).length;
42
+ setTimeout(() => this.handleWizard(), 100);
43
+ setTimeout(() => {
44
+ this.modal.stopLoading();
45
+ }, 1000);
40
46
  });
41
47
  }
42
48
  /**
@@ -65,7 +71,7 @@ export class SallaRatingModal {
65
71
  let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
66
72
  (_b = this.nextBtn) === null || _b === void 0 ? void 0 : _b.setText(nextType ? salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.' + nextType)
67
73
  : salla.lang.get('pages.rating.send_ratings'));
68
- setTimeout(() => { var _a, _b; return (_a = this.body) === null || _a === void 0 ? void 0 : _a.setAttribute('style', 'height:' + ((_b = this.currentTab) === null || _b === void 0 ? void 0 : _b.offsetHeight) + 'px'); });
74
+ setTimeout(() => { var _a, _b; return (_a = this.body) === null || _a === void 0 ? void 0 : _a.setAttribute('style', 'height:' + ((_b = this.currentTab) === null || _b === void 0 ? void 0 : _b.scrollHeight) + 'px'); });
69
75
  }
70
76
  previousTab() {
71
77
  this.currentIndex > 0 && this.currentIndex--;
@@ -201,7 +207,7 @@ export class SallaRatingModal {
201
207
  h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-modal-btn s-rating-modal-unvisiable" }, salla.lang.get('common.elements.back')),
202
208
  this.stepsCount > 1 ? h("ul", { class: "s-rating-modal-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => h("li", { class: 's-rating-modal-bg-gray s-rating-modal-step-dot' }))) : '',
203
209
  h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, salla.lang.get('common.elements.next'))),]
204
- : h("salla-placeholder", { alignment: "center" }))));
210
+ : '')));
205
211
  }
206
212
  componentDidLoad() {
207
213
  salla.event.dispatch('rating::ready', this);
@@ -242,17 +248,14 @@ export class SallaRatingModal {
242
248
  static get methods() { return {
243
249
  "open": {
244
250
  "complexType": {
245
- "signature": "() => Promise<void | NodeJS.Timeout>",
251
+ "signature": "() => Promise<any>",
246
252
  "parameters": [],
247
253
  "references": {
248
254
  "Promise": {
249
255
  "location": "global"
250
- },
251
- "NodeJS": {
252
- "location": "global"
253
256
  }
254
257
  },
255
- "return": "Promise<void | Timeout>"
258
+ "return": "Promise<any>"
256
259
  },
257
260
  "docs": {
258
261
  "text": "Show the rating modal",
@@ -2,8 +2,8 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { Component, Host, h, Prop, Element } from '@stencil/core';
5
+ import Helper from "../../Helpers/Helper";
5
6
  import Star2 from "../../assets/svg/star2.svg";
6
- import Helper from '../../Helpers/Helper';
7
7
  export class SallaRatingStars {
8
8
  constructor() {
9
9
  /**
@@ -2,8 +2,8 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { Component, Prop, h, State, Element, Listen, Watch } from '@stencil/core';
5
+ import Helper from "../../Helpers/Helper";
5
6
  import Search from "../../assets/svg/search.svg";
6
- import Helper from '../../Helpers/Helper';
7
7
  /**
8
8
  * @slot product - Replaces products card in the results, has replaceable props `{name}`, `{price}`, `{regular_price}`, `{image}`.
9
9
  */
@@ -27,7 +27,8 @@ export class SallaSearch {
27
27
  * Sets the height of the input
28
28
  */
29
29
  this.height = 60;
30
- this.productSlot = ((_a = this.host.querySelector('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
30
+ Helper.setHost(this.host);
31
+ this.productSlot = ((_a = Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
31
32
  salla.event.on('search::open', () => this.open());
32
33
  salla.lang.onLoaded(() => {
33
34
  this.translationLoaded = true;
@@ -77,7 +78,7 @@ export class SallaSearch {
77
78
  }
78
79
  }
79
80
  search(val) {
80
- this.noResults.style.display = 'none';
81
+ Helper.hideElement(this.noResults);
81
82
  //run loading spinner or stop it
82
83
  this.loading = true;
83
84
  salla.product.search(val)
@@ -33,7 +33,6 @@ export class SallaSwiper {
33
33
  }
34
34
  initSwiper() {
35
35
  for (const slide of this.swiperWrapper.children) {
36
- //todo:: use `s-swiper-slide`
37
36
  slide.classList.add('swiper-slide');
38
37
  }
39
38
  this.swiper = new Swiper(this.swiperContainer, {
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { Element, Component, Host, h, Prop, Method, Event, State } from '@stencil/core';
5
5
  import TelInput from "intl-tel-input";
6
+ import Helper from "../../Helpers/Helper";
6
7
  export class SallaTelInput {
7
8
  constructor() {
8
9
  /**
@@ -12,7 +13,7 @@ export class SallaTelInput {
12
13
  /**
13
14
  * Current country_code
14
15
  */
15
- this.countryCode = salla.config.get('user.country_code', 'SA') || 'SA';
16
+ this.countryCode = salla.config.get('user.country_code', 'SA');
16
17
  this.countryCodeLabel = salla.lang.get('common.country_code');
17
18
  this.mobileLabel = salla.lang.get('common.elements.mobile');
18
19
  this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
@@ -20,6 +21,7 @@ export class SallaTelInput {
20
21
  this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.countryCodeLabel });
21
22
  this.invalidNumber = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
22
23
  this.errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
24
+ Helper.setHost(this.host);
23
25
  salla.lang.onLoaded(() => {
24
26
  this.mobileLabel = salla.lang.get('common.elements.mobile');
25
27
  this.countryCodeLabel = salla.lang.get('common.elements.country_code');
@@ -164,7 +166,7 @@ export class SallaTelInput {
164
166
  },
165
167
  "attribute": "country-code",
166
168
  "reflect": false,
167
- "defaultValue": "salla.config.get('user.country_code', 'SA') || 'SA'"
169
+ "defaultValue": "salla.config.get('user.country_code', 'SA')"
168
170
  }
169
171
  }; }
170
172
  static get states() { return {
@@ -2,14 +2,15 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { Component, Host, Element, Event, h, Method, Prop, State } from '@stencil/core';
5
+ import Helper from "../../Helpers/Helper";
5
6
  import AndroidPhoneIcon from '../../assets/svg/android-phone.svg';
6
- import MailIcon from '../../assets/svg/mail.svg';
7
7
  /**
8
8
  * @slot footer - Replaces the footer, by default it contains: verify button, resend, and timer
9
9
  * @slot after-footer - placeholder position
10
10
  */
11
11
  export class SallaVerify {
12
12
  constructor() {
13
+ this.initiated = false;
13
14
  this.translationLoaded = false;
14
15
  /**
15
16
  * Should render component without modal
@@ -32,6 +33,7 @@ export class SallaVerify {
32
33
  * to use: `salla.api.auth.verify` or `salla.profile.verify`
33
34
  */
34
35
  this.isProfileVerify = false;
36
+ // Helper.setHost(this.host);
35
37
  salla.lang.onLoaded(() => {
36
38
  var _a;
37
39
  this.translationLoaded = true;
@@ -54,30 +56,6 @@ export class SallaVerify {
54
56
  this.timer.innerHTML = '30 : 00';
55
57
  });
56
58
  }
57
- handleKeyUp(ev) {
58
- var _a, _b, _c, _d;
59
- if (['Alt', 'Shift', 'Control', 'AltGraph', 'Ctrl'].includes(ev.key)) {
60
- return;
61
- }
62
- let key = ev.keyCode || ev.charCode;
63
- if (ev.target.value) {
64
- (_a = ev.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
65
- (_b = ev.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
66
- }
67
- else if ([8, 46].includes(key)) {
68
- (_c = ev.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
69
- (_d = ev.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
70
- }
71
- this.toggleOTPSubmit();
72
- }
73
- handlePaste(ev) {
74
- let text = salla.helpers.number(ev.clipboardData.getData('text'))
75
- .replace(/[^0-9.]/g, '')
76
- .replace('..', '.');
77
- this.otpInputs.forEach((input, i) => input.value = text[i] || '');
78
- this.toggleOTPSubmit();
79
- setTimeout(() => this.otpInputs[3].focus(), 100);
80
- }
81
59
  /**
82
60
  * Get current code
83
61
  * @return {string}
@@ -96,6 +74,30 @@ export class SallaVerify {
96
74
  this.type = this.data.type;
97
75
  this.resendTimer();
98
76
  this.otpInputs = this.body.querySelectorAll('.s-verify-input');
77
+ if (!this.initiated) {
78
+ Helper.on('input', '.s-verify-input', e => salla.helpers.inputDigitsOnly(e.target));
79
+ Helper.onKeyUp('.s-verify-input', event => {
80
+ var _a, _b, _c, _d;
81
+ let key = event.keyCode || event.charCode;
82
+ if (event.target.value) {
83
+ (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
84
+ (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
85
+ }
86
+ else if ([8, 46].includes(key)) {
87
+ (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
88
+ (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
89
+ }
90
+ this.toggleOTPSubmit();
91
+ });
92
+ Helper.on('paste', '.s-verify-input', event => {
93
+ let text = salla.helpers.number(event.clipboardData.getData('text')).replace(/[^0-9.]/g, '').replace('..', '.');
94
+ this.otpInputs.forEach((input, i) => input.value = text[i] || '');
95
+ this.toggleOTPSubmit();
96
+ setTimeout(() => this.otpInputs[3].focus(), 100);
97
+ });
98
+ // return this.modal.open();
99
+ this.initiated = true;
100
+ }
99
101
  this.reset();
100
102
  this.display == 'modal' && ((_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title));
101
103
  this.modal.open();
@@ -119,14 +121,12 @@ export class SallaVerify {
119
121
  this.otpInputs[0].focus();
120
122
  }
121
123
  resendTimer() {
122
- this.resendMessage.style.display = 'block';
123
- this.resend.style.display = 'none';
124
+ Helper.showElement(this.resendMessage).hideElement(this.resend);
124
125
  this.resendAfter = 30;
125
126
  let timerId = setInterval(() => {
126
127
  if (this.resendAfter <= 0) {
127
128
  clearInterval(timerId);
128
- this.resend.style.display = 'block';
129
- this.resendMessage.style.display = 'none';
129
+ Helper.hideElement(this.resendMessage).showElement(this.resend);
130
130
  }
131
131
  else {
132
132
  this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;
@@ -145,12 +145,6 @@ export class SallaVerify {
145
145
  .finally(() => this.resendTimer());
146
146
  }
147
147
  submit() {
148
- //if code not 4 digits, focus on the after filled input,
149
- if (this.code.value.length < 4) {
150
- this.otpInputs[this.code.value.length].focus();
151
- salla.log('Trying to submit without 4 digits!');
152
- return;
153
- }
154
148
  let data = Object.assign({ code: this.code.value }, this.data);
155
149
  return this.btn.load()
156
150
  .then(() => this.btn.disable())
@@ -167,19 +161,20 @@ export class SallaVerify {
167
161
  render() {
168
162
  return this.display == 'inline' ? h(Host, null, this.myBody()) :
169
163
  h("salla-modal", { width: "xs", class: "s-verify", ref: modal => this.modal = modal, "modal-title": this.title },
170
- h("span", { slot: 'icon', innerHTML: this.type == "mobile" ? AndroidPhoneIcon : MailIcon }),
164
+ h("span", { slot: 'icon', innerHTML: AndroidPhoneIcon }),
171
165
  this.myBody());
172
166
  }
173
167
  myBody() {
174
168
  return (h("div", { class: "s-verify-body", ref: body => this.body = body },
175
169
  h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
176
170
  h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
177
- h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "tel", autocomplete: "one-time-code", pattern: "[0-9]*", inputmode: "numeric", maxlength: "1", class: "s-verify-input", onInput: e => salla.helpers.inputDigitsOnly(e.target), onPaste: e => this.handlePaste(e), onKeyUp: e => this.handleKeyUp(e), required: true }))),
171
+ h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "tel", autocomplete: "one-time-code", pattern: "[0-9]*", inputmode: "numeric", maxlength: "1", class: "s-verify-input", required: true }))),
178
172
  h("div", { slot: "footer", class: "s-verify-footer" },
179
173
  h("salla-button", { class: "s-verify-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')),
180
174
  h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el },
181
175
  salla.lang.get('blocks.header.resend_after'),
182
- h("b", { class: "s-verify-timer", ref: el => this.timer = el })),
176
+ h("b", { class: "s-verify-timer", ref: el => this.timer = el }),
177
+ " "),
183
178
  h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))),
184
179
  h("slot", { name: "after-footer" })));
185
180
  }