@salla.sa/twilight-components 1.0.56 → 1.0.58

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 (67) hide show
  1. package/dist/cjs/index.cjs.js +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-button.cjs.entry.js +7 -7
  4. package/dist/cjs/salla-conditional-fields.cjs.entry.js +76 -0
  5. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  6. package/dist/cjs/{salla-login-modal-d0fb6180.js → salla-login-modal-02e4e65e.js} +5 -5
  7. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  8. package/dist/cjs/salla-modal_2.cjs.entry.js +5 -5
  9. package/dist/cjs/salla-offer-modal.cjs.entry.js +8 -3
  10. package/dist/cjs/salla-quantity-input.cjs.entry.js +64 -0
  11. package/dist/cjs/salla-rating-modal.cjs.entry.js +8 -8
  12. package/dist/cjs/{salla-search-f76c6d61.js → salla-search-9d17eb96.js} +3 -3
  13. package/dist/cjs/twilight-components.cjs.js +1 -1
  14. package/dist/collection/collection-manifest.json +2 -0
  15. package/dist/collection/components/salla-button/salla-button.js +10 -10
  16. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.css +3 -0
  17. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +82 -0
  18. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +1 -1
  19. package/dist/collection/components/salla-login-modal/salla-login-modal.js +5 -5
  20. package/dist/collection/components/salla-modal/salla-modal.css +1 -4
  21. package/dist/collection/components/salla-modal/salla-modal.js +3 -3
  22. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +11 -4
  23. package/dist/collection/components/salla-quantity-input/salla-quantity-input.css +3 -0
  24. package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +71 -0
  25. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +8 -8
  26. package/dist/collection/components/salla-search/salla-search.js +3 -3
  27. package/dist/esm/index.js +2 -2
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/esm/salla-button.entry.js +7 -7
  30. package/dist/esm/salla-conditional-fields.entry.js +72 -0
  31. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  32. package/dist/esm/{salla-login-modal-63f03766.js → salla-login-modal-7ad386c8.js} +5 -5
  33. package/dist/esm/salla-login-modal.entry.js +1 -1
  34. package/dist/esm/salla-modal_2.entry.js +5 -5
  35. package/dist/esm/salla-offer-modal.entry.js +8 -3
  36. package/dist/esm/salla-quantity-input.entry.js +60 -0
  37. package/dist/esm/salla-rating-modal.entry.js +8 -8
  38. package/dist/esm/{salla-search-7521be0c.js → salla-search-ce45eb5b.js} +3 -3
  39. package/dist/esm/twilight-components.js +1 -1
  40. package/dist/twilight-components/index.esm.js +1 -1
  41. package/dist/twilight-components/p-1514ed09.js +1 -0
  42. package/dist/twilight-components/p-40693cd3.entry.js +1 -0
  43. package/dist/twilight-components/p-5d5b04ec.entry.js +1 -0
  44. package/dist/twilight-components/p-64977eab.entry.js +1 -0
  45. package/dist/twilight-components/p-6c928c14.entry.js +1 -0
  46. package/dist/twilight-components/p-7c4ba872.entry.js +1 -0
  47. package/dist/twilight-components/p-84936d9d.entry.js +1 -0
  48. package/dist/twilight-components/{p-e306c6bb.entry.js → p-884a80ca.entry.js} +1 -1
  49. package/dist/twilight-components/p-ebd63ad4.js +1 -0
  50. package/dist/twilight-components/p-ee9d8563.entry.js +1 -0
  51. package/dist/twilight-components/twilight-components.esm.js +1 -1
  52. package/dist/types/components/salla-button/salla-button.d.ts +2 -2
  53. package/dist/types/components/salla-conditional-fields/salla-conditional-fields.d.ts +9 -0
  54. package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +2 -0
  55. package/dist/types/components/salla-quantity-input/salla-quantity-input.d.ts +18 -0
  56. package/dist/types/components.d.ts +34 -8
  57. package/example/dist/tailwind.css +944 -326
  58. package/example/dist/twilight.js +1 -1
  59. package/example/index.html +523 -123
  60. package/package.json +1 -1
  61. package/dist/twilight-components/p-05574321.entry.js +0 -1
  62. package/dist/twilight-components/p-134fa158.entry.js +0 -1
  63. package/dist/twilight-components/p-646fbb7f.entry.js +0 -1
  64. package/dist/twilight-components/p-85427280.entry.js +0 -1
  65. package/dist/twilight-components/p-88dce1e4.js +0 -1
  66. package/dist/twilight-components/p-a26e2e12.entry.js +0 -1
  67. package/dist/twilight-components/p-e4f716b0.js +0 -1
@@ -40,7 +40,7 @@ export class SallaInfiniteScroll {
40
40
  }
41
41
  loading(isLoading = true) {
42
42
  let btnText = this.status.querySelector('.s-button-text');
43
- Helper.toggleElement(btnText, 's-button-hide', 's-button-show', () => isLoading);
43
+ Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);
44
44
  this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
45
45
  }
46
46
  componentWillLoad() {
@@ -70,7 +70,7 @@ export class SallaLoginModal {
70
70
  .then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
71
71
  .then(() => this.emailBtn.stop() && this.emailBtn.enable())
72
72
  .then(() => this.showTab(this.verifyTab))
73
- .then(() => this.verifyTab.by = 'email')
73
+ .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
74
74
  .then(() => this.verifyTab.show({ email: this.loginEmail.value }));
75
75
  };
76
76
  this.newUser = async () => {
@@ -164,8 +164,8 @@ export class SallaLoginModal {
164
164
  var _a, _b;
165
165
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
166
166
  let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
167
- tabs.map(el => Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
168
- setTimeout(() => tabs.map(el => Helper.toggleElement(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
167
+ tabs.map(el => Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
168
+ setTimeout(() => tabs.map(el => Helper.toggleElementClassIf(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
169
169
  setTimeout(() => this.host.querySelector('.s-login-modal-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
170
170
  if ([this.mobileTab, this.emailTab].includes(tab)) {
171
171
  this.regType = tab === this.mobileTab ? 'phone' : 'email';
@@ -174,8 +174,8 @@ export class SallaLoginModal {
174
174
  isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
175
175
  (_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
176
176
  if (!isRegistrationTab) {
177
- Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
178
- .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
177
+ Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
178
+ .toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
179
179
  }
180
180
  return this;
181
181
  }
@@ -10,7 +10,4 @@
10
10
  /*
11
11
  * Salla Modal Component: popup modal used in most parts of the theme
12
12
  * You can use these classes to target the elements in the component.
13
- */
14
- .salla-modal .s-modal-wrapper {
15
- height: calc(var(--vh, 1vh) * 100);
16
- }
13
+ */
@@ -88,10 +88,10 @@ export class SallaModal {
88
88
  }
89
89
  toggleModal(isOpen) {
90
90
  const body = this.host.querySelector('.s-modal-body');
91
- Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
92
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
91
+ Helper.toggleElementClassIf(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
92
+ .toggleElementClassIf(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
93
93
  //todo:: use united class names
94
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
94
+ .toggleElementClassIf(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
95
95
  if (!isOpen) {
96
96
  setTimeout(() => this.host.classList.add('s-hidden'), 350);
97
97
  }
@@ -11,10 +11,14 @@ export class SallaOfferModal {
11
11
  this.offer = null;
12
12
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
13
13
  this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
14
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
15
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
14
16
  Helper.setHost(this.host);
15
17
  salla.event.on('languages::translations.loaded', () => {
16
18
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
17
19
  this.remember_my_choice = salla.lang.get('common.remember_my_choice');
20
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
21
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
18
22
  });
19
23
  this.categorySlot = ((_a = Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>';
20
24
  this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
@@ -43,6 +47,7 @@ export class SallaOfferModal {
43
47
  this.offer = offer;
44
48
  this.offer_name = offer.name;
45
49
  this.offer_message = offer.message;
50
+ this.modal.setTitle(this.offer_name);
46
51
  return this.modal.show();
47
52
  }
48
53
  rememberMe(event) {
@@ -64,13 +69,13 @@ export class SallaOfferModal {
64
69
  }
65
70
  render() {
66
71
  var _a, _b;
67
- return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", title: "\u0639\u0631\u0648\u0636 \u0631\u0627\u0626\u0639\u0629 \u0641\u064A \u0627\u0646\u062A\u0638\u0627\u0631\u0643\u060C \u0645\u0627\u0630\u0627 \u0646\u062A\u0646\u0638\u0631!", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
72
+ return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
68
73
  ? [h("div", { class: "s-offer-modal-scrolled-slider-wrap" },
69
74
  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
70
75
  ? 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
71
76
  .replace(/\{name\}/g, category.name)
72
77
  .replace(/\{url\}/g, category.urls.customer) }))
73
- : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: "s-offer-modal-product s-offer-modal-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
78
+ : (_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
74
79
  .replace(/\{name\}/g, product.name)
75
80
  .replace(/\{url\}/g, product.url)
76
81
  .replace(/\{image\}/g, product.thumbnail)
@@ -78,7 +83,7 @@ export class SallaOfferModal {
78
83
  ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
79
84
  : salla.money(product.price)) },
80
85
  h("div", { class: "s-offer-modal-btn-wrap" },
81
- h("salla-button", { wide: true, "btn-style": 'outline-primary', "data-id": product.id, "loader-position": "center", onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart')))))),
86
+ h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? this.add_to_cart : this.out_of_stock))))),
82
87
  h("div", { class: "s-offer-modal-slider-nav" },
83
88
  h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" },
84
89
  h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })),
@@ -155,7 +160,9 @@ export class SallaOfferModal {
155
160
  "offer_name": {},
156
161
  "offer_message": {},
157
162
  "offer_expires_in": {},
158
- "remember_my_choice": {}
163
+ "remember_my_choice": {},
164
+ "add_to_cart": {},
165
+ "out_of_stock": {}
159
166
  }; }
160
167
  static get methods() { return {
161
168
  "show": {
@@ -0,0 +1,3 @@
1
+ :host {
2
+ display: block;
3
+ }
@@ -0,0 +1,71 @@
1
+ import { Component, Element, Host, State, Watch, h } from '@stencil/core';
2
+ export class SallaQuantityInput {
3
+ constructor() {
4
+ this.hostAttributes = {};
5
+ this.hasIncrementSlot = false;
6
+ this.hasDecrementSlot = false;
7
+ this.quantity = 1;
8
+ }
9
+ /**
10
+ * Workaround to fire change event for the input.
11
+ */
12
+ watchPropHandler() {
13
+ salla.helpers.debounce(() => salla.document.event.fireEvent(this.textInput, 'change', { 'bubbles': true }))();
14
+ }
15
+ componentWillLoad() {
16
+ this.hasIncrementSlot = !!this.host.querySelector('[slot="increment-button"]');
17
+ this.hasDecrementSlot = !!this.host.querySelector('[slot="decrement-button"]');
18
+ }
19
+ // border-border-color
20
+ // transtion transition-color duration-300
21
+ componentdidLoad() {
22
+ this.quantity = parseInt(this.host.getAttribute('value')) || 1;
23
+ //app.on('input', '[name="quantity"]', event => salla.helpers.inputDigitsOnly(event.target));
24
+ }
25
+ getInputAttributes() {
26
+ for (let i = 0; i < this.host.attributes.length; i++) {
27
+ if (!['id', 'value', 'min', 'class'].includes(this.host.attributes[i].name)) {
28
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
29
+ }
30
+ }
31
+ return this.hostAttributes;
32
+ }
33
+ decrement() {
34
+ if (this.quantity <= 1) {
35
+ return;
36
+ }
37
+ this.quantity--;
38
+ }
39
+ increment() {
40
+ let maxQuantity = parseInt(this.host.getAttribute('max'));
41
+ if (maxQuantity && this.quantity >= maxQuantity) {
42
+ return;
43
+ }
44
+ this.quantity++;
45
+ }
46
+ render() {
47
+ return (h(Host, { class: "s-quantity-input s-quantity-input-container" },
48
+ h("button", { onClick: () => this.increment(), class: "s-quantity-input-button", type: "button" },
49
+ !this.hasIncrementSlot ? h("i", { class: "sicon-add" }) : '',
50
+ h("slot", { name: "increment-button" })),
51
+ h("input", Object.assign({ class: "s-quantity-input-input" }, this.getInputAttributes(), { min: "1", value: this.quantity, ref: (el) => this.textInput = el })),
52
+ h("button", { class: "s-quantity-input-button", onClick: () => this.decrement(), type: "button" },
53
+ !this.hasDecrementSlot ? h("i", { class: "sicon-minus" }) : '',
54
+ h("slot", { name: "decrement-button" }))));
55
+ }
56
+ static get is() { return "salla-quantity-input"; }
57
+ static get originalStyleUrls() { return {
58
+ "$": ["salla-quantity-input.css"]
59
+ }; }
60
+ static get styleUrls() { return {
61
+ "$": ["salla-quantity-input.css"]
62
+ }; }
63
+ static get states() { return {
64
+ "quantity": {}
65
+ }; }
66
+ static get elementRef() { return "host"; }
67
+ static get watchers() { return [{
68
+ "propName": "quantity",
69
+ "methodName": "watchPropHandler"
70
+ }]; }
71
+ }
@@ -66,7 +66,7 @@ export class SallaRatingModal {
66
66
  // Loop through each star, and add or remove the `.selected` class to toggle highlighting
67
67
  event.target
68
68
  .querySelectorAll('.s-rating-modal-btn-star')
69
- .forEach((star, index) => Helper.toggleElement(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
69
+ .forEach((star, index) => Helper.toggleElementClassIf(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
70
70
  // Remove aria-pressed from any previously selected star
71
71
  event.target.querySelectorAll('.s-rating-modal-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
72
72
  // Add aria-pressed role to the selected button
@@ -82,12 +82,12 @@ export class SallaRatingModal {
82
82
  showActiveStep(current = null) {
83
83
  var _a;
84
84
  this.currentTab = current || this.steps[this.currentIndex];
85
- Helper.toggle('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
86
- .toggle('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
85
+ Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
86
+ .toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
87
87
  if (this.currentIndex != 0) {
88
88
  // the animation
89
- Helper.toggleElement(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
90
- setTimeout(() => Helper.toggleElement(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
89
+ Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
90
+ setTimeout(() => Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
91
91
  }
92
92
  // Btn text
93
93
  let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
@@ -119,7 +119,7 @@ export class SallaRatingModal {
119
119
  }
120
120
  previousTab() {
121
121
  this.currentIndex > 0 && this.currentIndex--;
122
- Helper.toggleElement(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
122
+ Helper.toggleElementClassIf(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
123
123
  this.showActiveStep();
124
124
  }
125
125
  submit() {
@@ -130,7 +130,7 @@ export class SallaRatingModal {
130
130
  .then(() => this.currentTab.querySelectorAll('[name],.s-rating-modal-btn-star').forEach(el => el.setAttribute('disabled', '')))
131
131
  .then(() => this.currentIndex < this.stepsCount && this.currentIndex++)
132
132
  .then(() => this.showActiveStep())
133
- .then(() => Helper.toggle('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
133
+ .then(() => Helper.toggleClassIf('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
134
134
  .finally(() => {
135
135
  this.nextBtn.stop();
136
136
  salla.config.canLeave = true;
@@ -155,7 +155,7 @@ export class SallaRatingModal {
155
155
  return;
156
156
  }
157
157
  type = type || rating['dataset'].type;
158
- Helper.toggleElement(comment, 'save', 's-has-error', el => el.value.length > 3);
158
+ Helper.toggleElementClassIf(comment, 'save', 's-has-error', el => el.value.length > 3);
159
159
  throw validationMessage.innerHTML = stars
160
160
  ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
161
161
  : salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
@@ -48,7 +48,7 @@ export class SallaSearch {
48
48
  return;
49
49
  }
50
50
  //run loading spinner or stop it
51
- Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
51
+ Helper.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
52
52
  salla.search.api.search(e.target.value)
53
53
  .then(response => this.results = response)
54
54
  .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
@@ -57,8 +57,8 @@ export class SallaSearch {
57
57
  afterSearching(isEmpty = true) {
58
58
  var _a;
59
59
  this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
60
- Helper.toggleElement(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
61
- .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
60
+ Helper.toggleElementClassIf(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
61
+ .toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
62
62
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
63
63
  this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
64
64
  }
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { S as SallaLoginModal } from './salla-login-modal-63f03766.js';
2
- export { S as SallaSearch } from './salla-search-7521be0c.js';
1
+ export { S as SallaLoginModal } from './salla-login-modal-7ad386c8.js';
2
+ export { S as SallaSearch } from './salla-search-ce45eb5b.js';
3
3
  import './index-8b97d225.js';
4
4
  import './Helper-7162a06c.js';
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["salla-button",[[4,"salla-button",{"buttonType":[513,"button-type"],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer-modal",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
13
+ return bootstrapLazy([["salla-button",[[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer-modal",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"show":[64],"showOffer":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32]}]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -7,9 +7,9 @@ const SallaButton = class {
7
7
  registerInstance(this, hostRef);
8
8
  this.hostAttributes = {};
9
9
  /**
10
- * Button Type
10
+ * Button Type todo :: find better name,
11
11
  */
12
- this.buttonType = 'btn';
12
+ this.shape = 'btn';
13
13
  /**
14
14
  * Button Color
15
15
  */
@@ -88,21 +88,21 @@ const SallaButton = class {
88
88
  }
89
89
  getBtnAttributes() {
90
90
  for (let i = 0; i < this.host.attributes.length; i++) {
91
- if (!['type', 'color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
91
+ if (!['color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
92
92
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
93
93
  }
94
94
  }
95
95
  this.hostAttributes.type = this.hostAttributes.type || 'button';
96
96
  this.hostAttributes.class +=
97
- ' s-button-element s-button-' + this.buttonType
97
+ ' s-button-element s-button-' + this.shape
98
98
  + ' s-button-' + (this.fill == "none" ? 'fill-none' : this.fill)
99
99
  + (this.size != "medium" ? ' s-button-' + this.size : '')
100
100
  + (this.width != "normal" ? ' s-button-' + this.width : '')
101
- + (this.buttonType == "link" ? ' s-button-' + this.color + '-link' : '')
102
- + (this.buttonType != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
101
+ + (this.shape == "link" ? ' s-button-' + this.color + '-link' : '')
102
+ + (this.shape != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
103
103
  + (this.fill == 'outline' ? ' s-button-' + this.color + '-outline' : '')
104
104
  + (this.disabled ? ' s-button-disabled ' : '')
105
- + (this.buttonType == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
105
+ + (this.shape == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
106
106
  return this.hostAttributes;
107
107
  }
108
108
  render() {
@@ -0,0 +1,72 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
+
3
+ const sallaConditionalFieldsCss = ":host{display:block}";
4
+
5
+ const SallaConditionalFields = class {
6
+ constructor(hostRef) {
7
+ registerInstance(this, hostRef);
8
+ }
9
+ changeHandler(event) {
10
+ salla.log('Received the change event: ', event);
11
+ if (!['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
12
+ // todo :: support debug
13
+ salla.log('Ignore the change because is not support input: ' + event.target.tagName);
14
+ return;
15
+ }
16
+ // to extract the option id from the input name, the supported names are name[*] and name[*][]
17
+ let optionId = event.target.name.replace('[]', '');
18
+ let isMultiple = event.target.getAttribute('type') === 'checkbox';
19
+ salla.log('Trying to find all the element with condation:', `[data-show-when^="${optionId}"]`);
20
+ this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
21
+ .forEach((field) => {
22
+ // @ts-ignore
23
+ let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
24
+ // @ts-ignore
25
+ let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
26
+ // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
27
+ let isSelected = false;
28
+ if (isMultiple) {
29
+ // @ts-ignore
30
+ let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
31
+ isSelected = selectedValues.includes(value.toString());
32
+ }
33
+ else {
34
+ isSelected = value === event.target.value;
35
+ }
36
+ salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
37
+ let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
38
+ if (showTheInput) {
39
+ field.classList.remove('hidden');
40
+ field.querySelectorAll('[name]').forEach((input) => {
41
+ input.removeAttribute('disabled');
42
+ //To handle focus on hidden input error
43
+ if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
44
+ input.setAttribute('required', '');
45
+ }
46
+ });
47
+ }
48
+ else {
49
+ field.classList.add('hidden');
50
+ field.querySelectorAll('[name]').forEach((input) => {
51
+ input.setAttribute('disabled', '');
52
+ input.removeAttribute('required');
53
+ if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
54
+ // @ts-ignore
55
+ input.checked = false;
56
+ }
57
+ //firing this event will show errors, so don't run it when pageLoading.
58
+ // if (this.optionsAlreadyInitiated) {
59
+ // salla.document.event.fireEvent(input, 'change', {'bubbles': true});
60
+ // }
61
+ });
62
+ }
63
+ });
64
+ }
65
+ render() {
66
+ return (h(Host, null, h("slot", null)));
67
+ }
68
+ get host() { return getElement(this); }
69
+ };
70
+ SallaConditionalFields.style = sallaConditionalFieldsCss;
71
+
72
+ export { SallaConditionalFields as salla_conditional_fields };
@@ -42,7 +42,7 @@ const SallaInfiniteScroll = class {
42
42
  }
43
43
  loading(isLoading = true) {
44
44
  let btnText = this.status.querySelector('.s-button-text');
45
- Helper.toggleElement(btnText, 's-button-hide', 's-button-show', () => isLoading);
45
+ Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);
46
46
  this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
47
47
  }
48
48
  componentWillLoad() {
@@ -63,7 +63,7 @@ const SallaLoginModal = class {
63
63
  .then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
64
64
  .then(() => this.emailBtn.stop() && this.emailBtn.enable())
65
65
  .then(() => this.showTab(this.verifyTab))
66
- .then(() => this.verifyTab.by = 'email')
66
+ .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
67
67
  .then(() => this.verifyTab.show({ email: this.loginEmail.value }));
68
68
  };
69
69
  this.newUser = async () => {
@@ -157,8 +157,8 @@ const SallaLoginModal = class {
157
157
  var _a, _b;
158
158
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
159
159
  let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
160
- tabs.map(el => Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
161
- setTimeout(() => tabs.map(el => Helper.toggleElement(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
160
+ tabs.map(el => Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
161
+ setTimeout(() => tabs.map(el => Helper.toggleElementClassIf(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
162
162
  setTimeout(() => this.host.querySelector('.s-login-modal-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
163
163
  if ([this.mobileTab, this.emailTab].includes(tab)) {
164
164
  this.regType = tab === this.mobileTab ? 'phone' : 'email';
@@ -167,8 +167,8 @@ const SallaLoginModal = class {
167
167
  isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
168
168
  (_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
169
169
  if (!isRegistrationTab) {
170
- Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
171
- .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
170
+ Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
171
+ .toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
172
172
  }
173
173
  return this;
174
174
  }
@@ -1,3 +1,3 @@
1
- export { S as salla_login_modal } from './salla-login-modal-63f03766.js';
1
+ export { S as salla_login_modal } from './salla-login-modal-7ad386c8.js';
2
2
  import './index-8b97d225.js';
3
3
  import './Helper-7162a06c.js';
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-8b97d225.js';
2
2
  import { H as Helper } from './Helper-7162a06c.js';
3
- export { S as salla_search } from './salla-search-7521be0c.js';
3
+ export { S as salla_search } from './salla-search-ce45eb5b.js';
4
4
 
5
- const sallaModalCss = ".salla-modal .s-modal-wrapper{height:calc(var(--vh, 1vh) * 100)}";
5
+ const sallaModalCss = "";
6
6
 
7
7
  const SallaModal = class {
8
8
  constructor(hostRef) {
@@ -92,10 +92,10 @@ const SallaModal = class {
92
92
  }
93
93
  toggleModal(isOpen) {
94
94
  const body = this.host.querySelector('.s-modal-body');
95
- Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
96
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
95
+ Helper.toggleElementClassIf(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
96
+ .toggleElementClassIf(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
97
97
  //todo:: use united class names
98
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
98
+ .toggleElementClassIf(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
99
99
  if (!isOpen) {
100
100
  setTimeout(() => this.host.classList.add('s-hidden'), 350);
101
101
  }
@@ -10,10 +10,14 @@ const SallaOfferModal = class {
10
10
  this.offer = null;
11
11
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
12
12
  this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
13
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
14
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
13
15
  Helper.setHost(this.host);
14
16
  salla.event.on('languages::translations.loaded', () => {
15
17
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
16
18
  this.remember_my_choice = salla.lang.get('common.remember_my_choice');
19
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
20
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
17
21
  });
18
22
  this.categorySlot = ((_a = Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>';
19
23
  this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
@@ -42,6 +46,7 @@ const SallaOfferModal = class {
42
46
  this.offer = offer;
43
47
  this.offer_name = offer.name;
44
48
  this.offer_message = offer.message;
49
+ this.modal.setTitle(this.offer_name);
45
50
  return this.modal.show();
46
51
  }
47
52
  rememberMe(event) {
@@ -63,18 +68,18 @@ const SallaOfferModal = class {
63
68
  }
64
69
  render() {
65
70
  var _a, _b;
66
- return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", title: "\u0639\u0631\u0648\u0636 \u0631\u0627\u0626\u0639\u0629 \u0641\u064A \u0627\u0646\u062A\u0638\u0627\u0631\u0643\u060C \u0645\u0627\u0630\u0627 \u0646\u062A\u0646\u0638\u0631!", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
71
+ return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
67
72
  ? [h("div", { class: "s-offer-modal-scrolled-slider-wrap" }, 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
68
73
  ? 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
69
74
  .replace(/\{name\}/g, category.name)
70
75
  .replace(/\{url\}/g, category.urls.customer) }))
71
- : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: "s-offer-modal-product s-offer-modal-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
76
+ : (_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
72
77
  .replace(/\{name\}/g, product.name)
73
78
  .replace(/\{url\}/g, product.url)
74
79
  .replace(/\{image\}/g, product.thumbnail)
75
80
  .replace(/\{price\}/g, product.has_special_price
76
81
  ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
77
- : salla.money(product.price)) }, h("div", { class: "s-offer-modal-btn-wrap" }, h("salla-button", { wide: true, "btn-style": 'outline-primary', "data-id": product.id, "loader-position": "center", onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart')))))), h("div", { class: "s-offer-modal-slider-nav" }, h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })), h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })))),
82
+ : salla.money(product.price)) }, h("div", { class: "s-offer-modal-btn-wrap" }, h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? this.add_to_cart : this.out_of_stock))))), h("div", { class: "s-offer-modal-slider-nav" }, h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })), h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })))),
78
83
  h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.expiry_date ?
79
84
  h("p", { class: "s-offer-modal-expiry" }, this.offer_expires_in, " ", this.offer.expiry_date)
80
85
  : '', h("label", { class: "s-offer-modal-remember-label" }, h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-modal-remember-input" }), "\u00A0 ", this.remember_my_choice)),
@@ -0,0 +1,60 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
+
3
+ const sallaQuantityInputCss = ":host{display:block}";
4
+
5
+ const SallaQuantityInput = class {
6
+ constructor(hostRef) {
7
+ registerInstance(this, hostRef);
8
+ this.hostAttributes = {};
9
+ this.hasIncrementSlot = false;
10
+ this.hasDecrementSlot = false;
11
+ this.quantity = 1;
12
+ }
13
+ /**
14
+ * Workaround to fire change event for the input.
15
+ */
16
+ watchPropHandler() {
17
+ salla.helpers.debounce(() => salla.document.event.fireEvent(this.textInput, 'change', { 'bubbles': true }))();
18
+ }
19
+ componentWillLoad() {
20
+ this.hasIncrementSlot = !!this.host.querySelector('[slot="increment-button"]');
21
+ this.hasDecrementSlot = !!this.host.querySelector('[slot="decrement-button"]');
22
+ }
23
+ // border-border-color
24
+ // transtion transition-color duration-300
25
+ componentdidLoad() {
26
+ this.quantity = parseInt(this.host.getAttribute('value')) || 1;
27
+ //app.on('input', '[name="quantity"]', event => salla.helpers.inputDigitsOnly(event.target));
28
+ }
29
+ getInputAttributes() {
30
+ for (let i = 0; i < this.host.attributes.length; i++) {
31
+ if (!['id', 'value', 'min', 'class'].includes(this.host.attributes[i].name)) {
32
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
33
+ }
34
+ }
35
+ return this.hostAttributes;
36
+ }
37
+ decrement() {
38
+ if (this.quantity <= 1) {
39
+ return;
40
+ }
41
+ this.quantity--;
42
+ }
43
+ increment() {
44
+ let maxQuantity = parseInt(this.host.getAttribute('max'));
45
+ if (maxQuantity && this.quantity >= maxQuantity) {
46
+ return;
47
+ }
48
+ this.quantity++;
49
+ }
50
+ render() {
51
+ return (h(Host, { class: "s-quantity-input s-quantity-input-container" }, h("button", { onClick: () => this.increment(), class: "s-quantity-input-button", type: "button" }, !this.hasIncrementSlot ? h("i", { class: "sicon-add" }) : '', h("slot", { name: "increment-button" })), h("input", Object.assign({ class: "s-quantity-input-input" }, this.getInputAttributes(), { min: "1", value: this.quantity, ref: (el) => this.textInput = el })), h("button", { class: "s-quantity-input-button", onClick: () => this.decrement(), type: "button" }, !this.hasDecrementSlot ? h("i", { class: "sicon-minus" }) : '', h("slot", { name: "decrement-button" }))));
52
+ }
53
+ get host() { return getElement(this); }
54
+ static get watchers() { return {
55
+ "quantity": ["watchPropHandler"]
56
+ }; }
57
+ };
58
+ SallaQuantityInput.style = sallaQuantityInputCss;
59
+
60
+ export { SallaQuantityInput as salla_quantity_input };