@salla.sa/twilight-components 1.0.52 → 1.0.54

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-branches.cjs.entry.js +2 -2
  4. package/dist/cjs/salla-button.cjs.entry.js +47 -36
  5. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  6. package/dist/cjs/{salla-login-modal-a2c7fa5d.js → salla-login-modal-d0fb6180.js} +6 -6
  7. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  8. package/dist/cjs/salla-modal_2.cjs.entry.js +2 -2
  9. package/dist/cjs/salla-offer-modal.cjs.entry.js +4 -5
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +2 -2
  11. package/dist/cjs/{salla-search-99d08b1f.js → salla-search-f76c6d61.js} +15 -4
  12. package/dist/cjs/salla-tel-input.cjs.entry.js +4 -6
  13. package/dist/cjs/salla-verify-modal.cjs.entry.js +6 -6
  14. package/dist/cjs/twilight-components.cjs.js +1 -1
  15. package/dist/collection/components/salla-branches/salla-branches.js +2 -2
  16. package/dist/collection/components/salla-button/salla-button.css +83 -1
  17. package/dist/collection/components/salla-button/salla-button.js +153 -50
  18. package/dist/collection/components/salla-localization-modal/salla-localization-modal.css +5 -1
  19. package/dist/collection/components/salla-login-modal/salla-login-modal.css +5 -1
  20. package/dist/collection/components/salla-login-modal/salla-login-modal.js +6 -6
  21. package/dist/collection/components/salla-modal/salla-modal.css +4 -1
  22. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +4 -5
  23. package/dist/collection/components/salla-product-availability/salla-product-availability.js +2 -2
  24. package/dist/collection/components/salla-search/salla-search.css +11 -0
  25. package/dist/collection/components/salla-search/salla-search.js +79 -13
  26. package/dist/collection/components/salla-tel-input/salla-tel-input.js +4 -6
  27. package/dist/collection/components/salla-verify-modal/salla-verify-modal.css +4 -0
  28. package/dist/collection/components/salla-verify-modal/salla-verify-modal.js +5 -5
  29. package/dist/esm/index.js +2 -2
  30. package/dist/esm/loader.js +1 -1
  31. package/dist/esm/salla-branches.entry.js +2 -2
  32. package/dist/esm/salla-button.entry.js +47 -36
  33. package/dist/esm/salla-localization-modal.entry.js +1 -1
  34. package/dist/esm/{salla-login-modal-187c1f98.js → salla-login-modal-63f03766.js} +6 -6
  35. package/dist/esm/salla-login-modal.entry.js +1 -1
  36. package/dist/esm/salla-modal_2.entry.js +2 -2
  37. package/dist/esm/salla-offer-modal.entry.js +4 -5
  38. package/dist/esm/salla-product-availability.entry.js +2 -2
  39. package/dist/esm/{salla-search-2e3e60cb.js → salla-search-7521be0c.js} +15 -4
  40. package/dist/esm/salla-tel-input.entry.js +4 -6
  41. package/dist/esm/salla-verify-modal.entry.js +6 -6
  42. package/dist/esm/twilight-components.js +1 -1
  43. package/dist/twilight-components/index.esm.js +1 -1
  44. package/dist/twilight-components/p-05574321.entry.js +1 -0
  45. package/dist/twilight-components/{p-ea455ae9.entry.js → p-134fa158.entry.js} +1 -1
  46. package/dist/twilight-components/p-2a032b88.entry.js +1 -0
  47. package/dist/twilight-components/p-2f3f4cce.entry.js +1 -0
  48. package/dist/twilight-components/p-4da2c2c8.entry.js +1 -0
  49. package/dist/twilight-components/p-635c08a7.entry.js +1 -0
  50. package/dist/twilight-components/{p-05dff05e.entry.js → p-79ab1ed9.entry.js} +1 -1
  51. package/dist/twilight-components/p-88dce1e4.js +1 -0
  52. package/dist/twilight-components/p-a26e2e12.entry.js +1 -0
  53. package/dist/twilight-components/{p-1f873057.entry.js → p-c51984d6.entry.js} +1 -1
  54. package/dist/twilight-components/p-e4f716b0.js +1 -0
  55. package/dist/twilight-components/twilight-components.esm.js +1 -1
  56. package/dist/types/components/salla-button/salla-button.d.ts +26 -8
  57. package/dist/types/components/salla-search/salla-search.d.ts +4 -0
  58. package/dist/types/components.d.ts +52 -6
  59. package/package.json +1 -1
  60. package/dist/twilight-components/p-0b599094.js +0 -1
  61. package/dist/twilight-components/p-2e03db57.entry.js +0 -1
  62. package/dist/twilight-components/p-5ffd56fb.js +0 -1
  63. package/dist/twilight-components/p-88d1bb89.entry.js +0 -1
  64. package/dist/twilight-components/p-8bfa19fb.entry.js +0 -1
  65. package/dist/twilight-components/p-c0a7b5a2.entry.js +0 -1
  66. package/dist/twilight-components/p-e6c67b55.entry.js +0 -1
  67. package/dist/twilight-components/p-f0f51a3c.entry.js +0 -1
@@ -6,6 +6,7 @@ import Helper from "../../Helpers/Helper";
6
6
  */
7
7
  export class SallaVerifyModal {
8
8
  constructor() {
9
+ // Helper.setHost(this.host);
9
10
  this.initiated = false;
10
11
  /**
11
12
  * Verifying method
@@ -15,7 +16,6 @@ export class SallaVerifyModal {
15
16
  * should auto reloading the page after success verification
16
17
  */
17
18
  this.autoReload = true;
18
- Helper.setHost(this.host);
19
19
  if (this.withoutModal) {
20
20
  this.modal = { show: () => '', hide: () => '' };
21
21
  }
@@ -48,7 +48,7 @@ export class SallaVerifyModal {
48
48
  this.resendTimer();
49
49
  this.otpInputs = this.host.querySelectorAll('.s-verify-modal-input');
50
50
  if (!this.initiated) {
51
- Helper.on('input', '.s-verify-modal-input', e => salla.helpers.digitsOnly(e.target));
51
+ Helper.on('input', '.s-verify-modal-input', e => salla.helpers.inputDigitsOnly(e.target));
52
52
  Helper.onKeyUp('.s-verify-modal-input', event => {
53
53
  var _a, _b, _c, _d;
54
54
  let key = event.keyCode || event.charCode;
@@ -63,7 +63,7 @@ export class SallaVerifyModal {
63
63
  this.toggleOTPSubmit();
64
64
  });
65
65
  Helper.on('paste', '.s-verify-modal-input', event => {
66
- let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
66
+ let text = salla.helpers.number(event.clipboardData.getData('text')).replace(/[^0-9.]/g, '').replace('..', '.');
67
67
  this.otpInputs.forEach((input, i) => input.value = text[i] || '');
68
68
  this.toggleOTPSubmit();
69
69
  setTimeout(() => this.otpInputs[3].focus(), 100);
@@ -130,11 +130,11 @@ export class SallaVerifyModal {
130
130
  .catch(() => this.btn.stop() && this.btn.enable() && this.reset());
131
131
  }
132
132
  render() {
133
- return this.withoutModal ? this.myBody() :
133
+ return this.withoutModal ? h(Host, null, this.myBody()) :
134
134
  h("salla-modal", { icon: "sicon-android-phone", width: "xs", id: "s-verify-modal", ref: modal => this.modal = modal, title: this.title }, this.myBody());
135
135
  }
136
136
  myBody() {
137
- return (h(Host, { id: "s-verify-modal" },
137
+ return (h("div", { id: "s-verify-modal" },
138
138
  h("div", { class: "s-verify-modal-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
139
139
  h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
140
140
  h("div", { class: "s-verify-modal-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "text", maxlength: "1", class: "s-verify-modal-input", required: true }))),
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { S as SallaLoginModal } from './salla-login-modal-187c1f98.js';
2
- export { S as SallaSearch } from './salla-search-2e3e60cb.js';
1
+ export { S as SallaLoginModal } from './salla-login-modal-63f03766.js';
2
+ export { S as SallaSearch } from './salla-search-7521be0c.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",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2",[[0,"salla-search",{"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",{"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);
14
14
  });
15
15
  };
16
16
 
@@ -6,7 +6,7 @@ const SallaBranches = class {
6
6
  constructor(hostRef) {
7
7
  registerInstance(this, hostRef);
8
8
  this.open = false;
9
- this.isOpenedBefore = salla.localData.get("branch-choosed-before");
9
+ this.isOpenedBefore = salla.storage.get("branch-choosed-before");
10
10
  this.displayAs = 'default'; //todo:: change it to boolean, isPopup default false
11
11
  this.browseProductsFrom = 'all'; //todo:: get better name
12
12
  this.branches = [
@@ -51,7 +51,7 @@ const SallaBranches = class {
51
51
  this.btn.load().then(() => {
52
52
  setTimeout(() => location.reload(), 2000);
53
53
  });
54
- salla.localData.set("branch-choosed-before", true);
54
+ salla.storage.set("branch-choosed-before", true);
55
55
  this.show();
56
56
  setTimeout(() => {
57
57
  this.current = this.selected;
@@ -1,15 +1,31 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
- import { H as Helper } from './Helper-7162a06c.js';
3
2
 
4
- const sallaButtonCss = "";
3
+ const sallaButtonCss = "salla-button{pointer-events:none}salla-button[type=submit]{-webkit-appearance:none}salla-button[width=wide]{width:100%}.s-button-wrap[loading]{pointer-events:none}.s-button-wrap[loading] .s-button-element{pointer-events:none !important}.s-button-wrap[loading] .s-button-loader-center .s-button-text{opacity:0}.s-button-wrap .s-button-element[loading]{pointer-events:none !important}.s-button-wrap .s-button-element:not(:disabled){pointer-events:auto}.s-button-wrap .s-button-solid .s-button-loader:before{border-color:#fff #fff rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.2)}.s-button-wrap .s-button-outline{border:1px solid currentColor}.s-button-wrap .s-button-outline:hover{border-color:transparent}.s-button-wrap .s-button-outline .s-button-loader:before{border-top-color:currentColor;border-left-color:currentColor}.s-button-wrap .s-button-icon.s-button-large{width:56px;height:56px}.s-button-wrap .s-button-icon.s-button-small{width:24px;height:24px}.s-button-wrap .s-button-icon.s-button-small .s-button-loader:before{width:0.85rem;height:0.85rem}.s-button-wrap .s-button-loader-after .s-button-load{flex-direction:row}.s-button-wrap .s-button-loader-start.s-button-element{padding-right:40px}.s-button-wrap .s-button-loader-start .s-button-loader{position:absolute;right:8px}.s-button-wrap .s-button-loader-start .s-button-loader [dir=ltr]{left:8px;right:auto}.s-button-wrap .s-button-loader-end.s-button-element{padding-left:40px}.s-button-wrap .s-button-loader-end .s-button-loader{position:absolute;left:8px}.s-button-wrap .s-button-loader-end .s-button-loader [dir=ltr]{right:8px;left:auto}.s-button-wrap .s-button-loader-center .s-button-loader{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);margin:0 !important}";
5
4
 
6
5
  const SallaButton = class {
7
6
  constructor(hostRef) {
8
7
  registerInstance(this, hostRef);
8
+ this.hostAttributes = {};
9
+ /**
10
+ * Button Type
11
+ */
12
+ this.buttonType = 'btn';
13
+ /**
14
+ * Button Color
15
+ */
16
+ this.color = 'primary';
9
17
  /**
10
- * Button Style
18
+ * Button Fill
11
19
  */
12
- this.btnStyle = 'primary';
20
+ this.fill = 'solid';
21
+ /**
22
+ * Button Size
23
+ */
24
+ this.size = 'medium';
25
+ /**
26
+ * Button Width
27
+ */
28
+ this.width = 'normal';
13
29
  /**
14
30
  * Is the button currently loading
15
31
  */
@@ -26,19 +42,6 @@ const SallaButton = class {
26
42
  * Is the button wide
27
43
  */
28
44
  this.wide = false;
29
- this.hostAttributes = {};
30
- for (let i = 0; i < this.host.attributes.length; i++) {
31
- this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
32
- }
33
- this.hostAttributes.type = this.hostAttributes.type || 'button';
34
- this.hostAttributes.class += ' s-button-btn btn--has-loading'
35
- + ' s-button-' + this.btnStyle
36
- + (this.wide ? ' s-button-wide ' : '')
37
- + ' s-button-btn-loader-' + this.loaderPosition //todo:: it looks there is no need for this class🤔
38
- + (this.loaderPosition == 'after' ? ' s-button-loader-after' : '');
39
- delete this.hostAttributes['btn-style'];
40
- delete this.hostAttributes['id'];
41
- delete this.hostAttributes['data-on-click'];
42
45
  if (this.wide) {
43
46
  this.host.classList.add('s-button-wide');
44
47
  }
@@ -74,38 +77,46 @@ const SallaButton = class {
74
77
  */
75
78
  async disable() {
76
79
  this.host.setAttribute('disabled', '');
80
+ return this.host;
77
81
  }
78
82
  /**
79
83
  * Remove `disabled` attribute
80
84
  */
81
85
  async enable() {
82
86
  this.host.removeAttribute('disabled');
87
+ return this.host;
83
88
  }
84
- handleVisible(newKind, oldKind) {
85
- //todo::use united styles
86
- this.btn.classList.remove('btn-' + oldKind);
87
- this.btn.classList.add('btn-' + newKind);
88
- }
89
- handleLoading(newVal) {
90
- //todo::use united styles
91
- Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
89
+ getBtnAttributes() {
90
+ for (let i = 0; i < this.host.attributes.length; i++) {
91
+ if (!['type', 'color', 'fill', 'size', 'width', 'id',].includes(this.host.attributes[i].name)) {
92
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
93
+ }
94
+ }
95
+ this.hostAttributes.type = this.hostAttributes.type || 'button';
96
+ this.hostAttributes.class +=
97
+ ' s-button-element s-button-' + this.buttonType
98
+ + ' s-button-' + (this.fill == "none" ? 'fill-none' : this.fill)
99
+ + (this.size != "medium" ? ' s-button-' + this.size : '')
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 : '')
103
+ + (this.fill == 'outline' ? ' s-button-' + this.color + '-outline' : '')
104
+ + (this.disabled ? ' s-button-disabled ' : '')
105
+ + (this.buttonType == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
106
+ return this.hostAttributes;
92
107
  }
108
+ // @Watch('btnStyle')
109
+ // handleVisible(newKind: string, oldKind: string) {
110
+ // //todo::use united styles
111
+ // this.btn.classList.remove('btn-' + oldKind);
112
+ // this.btn.classList.add('btn-' + newKind);
113
+ // }
93
114
  render() {
94
115
  return (
95
116
  //TODO:: use HOST then fake button behaviours
96
- h(Host, { class: "s-button-wrap" }, h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: { 's-button-text': true, 's-button-hide': this.loaderPosition == 'center' && this.loading }, ref: el => this.text = el }, h("slot", null)), this.loading ? h("span", { class: {
97
- //todo::use united styles
98
- 's-button-loader': true,
99
- 's-button-loader-start': this.loaderPosition === 'start',
100
- 's-button-loader-end': this.loaderPosition === 'end',
101
- 's-button-loader-center': this.loaderPosition === 'center',
102
- } }) : '')));
117
+ h(Host, { class: "s-button-wrap" }, h("button", Object.assign({}, this.getBtnAttributes(), { disabled: this.disabled }), h("span", { class: "s-button-text", ref: el => this.text = el }, h("slot", null)), this.loading ? h("span", { class: "s-button-loader" }) : '')));
103
118
  }
104
119
  get host() { return getElement(this); }
105
- static get watchers() { return {
106
- "btnStyle": ["handleVisible"],
107
- "loading": ["handleLoading"]
108
- }; }
109
120
  };
110
121
  SallaButton.style = sallaButtonCss;
111
122
 
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
2
  import { H as Helper } from './Helper-7162a06c.js';
3
3
 
4
- const sallaLocalizationModalCss = "";
4
+ const sallaLocalizationModalCss = "#salla-localization .s-localization-modal-select{appearance:none;-webkit-appearance:none}";
5
5
 
6
6
  const SallaLocalizationModal = class {
7
7
  constructor(hostRef) {
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
2
  import { H as Helper } from './Helper-7162a06c.js';
3
3
 
4
- const sallaLoginModalCss = "";
4
+ const sallaLoginModalCss = "[dir=ltr] #salla-login .s-login-modal-main-btn .arrow{display:inline-block;transform:scale(-1)}";
5
5
 
6
6
  const SallaLoginModal = class {
7
7
  constructor(hostRef) {
@@ -68,7 +68,7 @@ const SallaLoginModal = class {
68
68
  };
69
69
  this.newUser = async () => {
70
70
  var _a;
71
- const { mobile: regPhone, countryCode, countryKey } = await this.regTelInput.getValues(), emailValue = this.regEmail.value || ((_a = this.loginEmail) === null || _a === void 0 ? void 0 : _a.value);
71
+ const { mobile: regPhone, countryCode, countryKey } = this.regType == "email" ? await this.regTelInput.getValues() : await this.loginTelInput.getValues(), emailValue = this.regEmail.value || ((_a = this.loginEmail) === null || _a === void 0 ? void 0 : _a.value);
72
72
  await this.newUserValidation();
73
73
  await this.regBtn.load();
74
74
  await this.regBtn.disable();
@@ -188,12 +188,12 @@ const SallaLoginModal = class {
188
188
  }
189
189
  render() {
190
190
  return (h("salla-modal", { id: "salla-login", icon: "sicon-user", title: this.title, ref: modal => this.modal = modal, width: "xs" }, h("div", { class: "s-login-modal-wrapper" }, this.isEmailAllowed && this.isMobileAllowed ?
191
- h("div", { class: "s-login-modal-tab", ref: tab => this.homeTab = tab }, h("p", { class: "s-login-modal-sub-title" }, this.loginTypeTitle), h("slot", { name: "before-login-type" }), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-phone" }), h("span", { class: "s-login-modal-main-btn-text" }, this.smsLabel), h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-mail" }), h("span", { class: "s-login-modal-main-btn-text" }, this.emailLabel), h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), h("slot", { name: "after-login-type" }))
191
+ h("div", { class: "s-login-modal-tab", ref: tab => this.homeTab = tab }, h("p", { class: "s-login-modal-sub-title" }, this.loginTypeTitle), h("slot", { name: "before-login-type" }), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-phone" }), h("span", { class: "s-login-modal-main-btn-text" }, this.smsLabel), h("i", { class: "sicon-keyboard_arrow_left arrow" })), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-mail" }), h("span", { class: "s-login-modal-main-btn-text" }, this.emailLabel), h("i", { class: "sicon-keyboard_arrow_left arrow" })), h("slot", { name: "after-login-type" }))
192
192
  : '', this.isMobileAllowed ?
193
- h("div", { class: "s-login-modal-tab", ref: tab => this.mobileTab = tab }, h("slot", { name: "before-login-mobile" }), h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')), this.isEmailAllowed ?
193
+ h("div", { class: "s-login-modal-tab", ref: tab => this.mobileTab = tab }, h("slot", { name: "before-login-mobile" }), h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')), this.isEmailAllowed ?
194
194
  h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-modal-link" }, this.byEmailText) : '', h("slot", { name: "after-login-mobile" })) : '', this.isEmailAllowed ?
195
- h("div", { class: "s-login-modal-tab", ref: tab => this.emailTab = tab }, h("slot", { name: "before-login-email" }), h("label", { class: "s-login-modal-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), h("span", { class: "s-login-modal-error-message" }), h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')), this.isMobileAllowed ?
196
- h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, this.bySMSText) : '', h("slot", { name: "after-login-email" })) : '', h("salla-verify-modal", { withoutModal: true, ref: tab => this.verifyTab = tab, autoReload: false }, h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-modal-back sicon-arrow-right", slot: "after-footer", href: "#" })), h("div", { ref: tab => this.registrationTab = tab }, h("slot", { name: "before-registration" }), h("label", { class: "s-login-modal-label" }, this.firstNameLabel), h("input", { type: "text", class: "s-login-modal-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), h("span", { class: "s-login-modal-error-message" }), h("label", { class: "s-login-modal-label" }, this.lastNameLabel), h("input", { type: "text", class: "s-login-modal-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), h("span", { class: "s-login-modal-error-message" }), h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), h("span", { class: "s-login-modal-error-message" })), h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), h("slot", { name: "after-registration" })))));
195
+ h("div", { class: "s-login-modal-tab", ref: tab => this.emailTab = tab }, h("slot", { name: "before-login-email" }), h("label", { class: "s-login-modal-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), h("span", { class: "s-login-modal-error-message" }), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')), this.isMobileAllowed ?
196
+ h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, this.bySMSText) : '', h("slot", { name: "after-login-email" })) : '', h("salla-verify-modal", { withoutModal: true, ref: tab => this.verifyTab = tab, autoReload: false }, h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-modal-back sicon-arrow-right", slot: "after-footer", href: "#" })), h("div", { ref: tab => this.registrationTab = tab }, h("slot", { name: "before-registration" }), h("label", { class: "s-login-modal-label" }, this.firstNameLabel), h("input", { type: "text", class: "s-login-modal-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), h("span", { class: "s-login-modal-error-message" }), h("label", { class: "s-login-modal-label" }, this.lastNameLabel), h("input", { type: "text", class: "s-login-modal-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), h("span", { class: "s-login-modal-error-message" }), h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), h("span", { class: "s-login-modal-error-message" })), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), h("slot", { name: "after-registration" })))));
197
197
  }
198
198
  get host() { return getElement(this); }
199
199
  };
@@ -1,3 +1,3 @@
1
- export { S as salla_login_modal } from './salla-login-modal-187c1f98.js';
1
+ export { S as salla_login_modal } from './salla-login-modal-63f03766.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-2e3e60cb.js';
3
+ export { S as salla_search } from './salla-search-7521be0c.js';
4
4
 
5
- const sallaModalCss = "";
5
+ const sallaModalCss = ".salla-modal .s-modal-wrapper{height:calc(var(--vh, 1vh) * 100)}";
6
6
 
7
7
  const SallaModal = class {
8
8
  constructor(hostRef) {
@@ -17,13 +17,12 @@ const SallaOfferModal = class {
17
17
  });
18
18
  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
19
  this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
20
- salla.offer.event.onExisted(data => {
21
- //TODO:: use the best, should we hide the offer by product Id or Offer id🤔
22
- if (salla.localData.get('remember-offer-' + data.offer.offer_id)) {
20
+ salla.offer.event.onExisted(offer => {
21
+ if (salla.storage.get('remember-offer-' + offer.id)) {
23
22
  salla.log('User selected to don\'t show this offer again.');
24
23
  return;
25
24
  }
26
- this.show(data.product_id);
25
+ this.show(offer.product_id);
27
26
  });
28
27
  }
29
28
  /**
@@ -46,7 +45,7 @@ const SallaOfferModal = class {
46
45
  return this.modal.show();
47
46
  }
48
47
  rememberMe(event) {
49
- salla.localData.set('remember-offer-' + this.offer.id, event.target.checked);
48
+ salla.storage.set('remember-offer-' + this.offer.id, event.target.checked);
50
49
  }
51
50
  addItem() {
52
51
  // this here, is sallaButton
@@ -30,7 +30,7 @@ const SallaProductAvailability = class {
30
30
  .then(() => salla.api.product.availabilitySubscribe(data))
31
31
  .then(() => {
32
32
  this.isSubscribed = true;
33
- salla.localData.set(`product-${this.productId}-subscribed`, true);
33
+ salla.storage.set(`product-${this.productId}-subscribed`, true);
34
34
  }) //no need to wait until finishing alert animation
35
35
  .then(() => this.btn.stop())
36
36
  .then(() => this.modal.hide())
@@ -63,7 +63,7 @@ const SallaProductAvailability = class {
63
63
  this.channelsWatcher(this.channels);
64
64
  this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
65
65
  this.host.removeAttribute('title');
66
- this.isVisitorSubscribed = salla.localData.get(`product-${this.productId}-subscribed`);
66
+ this.isVisitorSubscribed = salla.storage.get(`product-${this.productId}-subscribed`);
67
67
  }
68
68
  channelsWatcher(newValue) {
69
69
  this.channels_ = newValue.split(',');
@@ -1,12 +1,16 @@
1
1
  import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
2
  import { H as Helper } from './Helper-7162a06c.js';
3
3
 
4
- const sallaSearchCss = "#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";
4
+ const sallaSearchCss = "#s-search-modal .s-search-inline{border:1px solid #eee}#s-search-modal .s-search-no-results .s-search-input,#s-search-modal .s-search-container-open .s-search-input{border-bottom:1px solid #f4f4f5}#s-search-modal .s-search-product-image[src=null]{opacity:0}#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem;background:transparent;overflow:visible}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";
5
5
 
6
6
  const SallaSearch = class {
7
7
  constructor(hostRef) {
8
8
  registerInstance(this, hostRef);
9
9
  var _a;
10
+ this.inputValue = '';
11
+ this.inline = false;
12
+ this.oval = false;
13
+ this.height = 60;
10
14
  Helper.setHost(this.host);
11
15
  this.productSlot = ((_a = Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
12
16
  salla.event.on('search::show', () => this.modal.show());
@@ -22,6 +26,7 @@ const SallaSearch = class {
22
26
  this.modal.querySelector('.s-search-input').value = '';
23
27
  this.results = undefined;
24
28
  this.afterSearching();
29
+ this.container.classList.remove('s-search-no-results');
25
30
  }
26
31
  getDefaultProductSlot() {
27
32
  return '<div class="s-search-product-image-container">' +
@@ -33,6 +38,7 @@ const SallaSearch = class {
33
38
  }
34
39
  //todo:: reset data when closing
35
40
  search(e) {
41
+ this.inputValue = e.target.value;
36
42
  Helper.hideElement(this.noResults);
37
43
  if (e.target.value.length === 0) {
38
44
  this.results = undefined;
@@ -52,17 +58,22 @@ const SallaSearch = class {
52
58
  afterSearching(isEmpty = true) {
53
59
  var _a;
54
60
  this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
55
- Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
61
+ 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; })
56
62
  .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
57
63
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
64
+ this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
58
65
  }
59
66
  render() {
60
67
  var _a;
61
- return (h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, h("div", { class: "s-search-container", ref: container => this.container = container }, h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }), h("span", { class: "s-search-icon" }, h("i", { class: "sicon-search", ref: el => this.searchIcon = el })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
68
+ const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }), h("span", { class: "s-search-icon-wrap" }, h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
62
69
  _a.data.map(item => h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
63
70
  .replace(/\{name\}/g, item.name)
64
71
  .replace(/\{price\}/g, item.price) //todo:: get discounted price too
65
- .replace(/\{image\}/g, item.image_url) })), h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
72
+ .replace(/\{image\}/g, item.image_url) })), h("p", { ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, this.noResultsText)));
73
+ return (this.inline ?
74
+ h("div", { id: "s-search-modal" }, searchContent)
75
+ :
76
+ h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, searchContent));
66
77
  }
67
78
  /**
68
79
  * Run it one time after load
@@ -1434,7 +1434,7 @@ const SallaTelInput = class {
1434
1434
  return false;
1435
1435
  }
1436
1436
  initTelInput() {
1437
- salla.helpers.digitsOnly(this.phoneInput);
1437
+ salla.helpers.inputDigitsOnly(this.phoneInput);
1438
1438
  this.iti = intlTelInput(this.phoneInput, {
1439
1439
  initialCountry: this.countryCode || 'sa',
1440
1440
  preferredCountries: ['sa', 'ae', 'kw', 'bh', 'qa', 'iq', 'om', 'ye', 'eg', 'jo', 'sy', 'ps', 'sd', 'lb', 'dz', 'tn', 'ma', 'ly'],
@@ -1445,16 +1445,14 @@ const SallaTelInput = class {
1445
1445
  });
1446
1446
  this.phoneInput.addEventListener("countrychange", () => {
1447
1447
  let data = this.iti.getSelectedCountryData();
1448
- this.host.querySelectorAll('.country_code').forEach((input) => input.value = data.iso2.toUpperCase());
1449
- this.host.querySelectorAll('.country_key').forEach((input) => {
1450
- input.value = ('+' + data.dialCode).replace('++', '+');
1451
- });
1448
+ this.countryCodeInput.value = data.iso2.toUpperCase();
1449
+ this.countryKeyInput.value = ('+' + data.dialCode).replace('++', '+');
1452
1450
  });
1453
1451
  // on blur: validate
1454
1452
  this.phoneInput.addEventListener('blur', () => this.isValid());
1455
1453
  // on keyup / change flag: reset
1456
1454
  this.phoneInput.addEventListener('input', e => {
1457
- salla.helpers.digitsOnly(e.target);
1455
+ salla.helpers.inputDigitsOnly(e.target);
1458
1456
  this.reset();
1459
1457
  });
1460
1458
  }
@@ -1,12 +1,13 @@
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
3
 
4
- const sallaVerifyModalCss = "salla-verify-modal{display:block}";
4
+ const sallaVerifyModalCss = "salla-verify-modal{display:block}[dir=ltr] #s-verify-modal .s-verify-modal-back{transform:scale(-1)}";
5
5
 
6
6
  const SallaVerifyModal = class {
7
7
  constructor(hostRef) {
8
8
  registerInstance(this, hostRef);
9
9
  this.verified = createEvent(this, "verified", 7);
10
+ // Helper.setHost(this.host);
10
11
  this.initiated = false;
11
12
  /**
12
13
  * Verifying method
@@ -16,7 +17,6 @@ const SallaVerifyModal = class {
16
17
  * should auto reloading the page after success verification
17
18
  */
18
19
  this.autoReload = true;
19
- Helper.setHost(this.host);
20
20
  if (this.withoutModal) {
21
21
  this.modal = { show: () => '', hide: () => '' };
22
22
  }
@@ -49,7 +49,7 @@ const SallaVerifyModal = class {
49
49
  this.resendTimer();
50
50
  this.otpInputs = this.host.querySelectorAll('.s-verify-modal-input');
51
51
  if (!this.initiated) {
52
- Helper.on('input', '.s-verify-modal-input', e => salla.helpers.digitsOnly(e.target));
52
+ Helper.on('input', '.s-verify-modal-input', e => salla.helpers.inputDigitsOnly(e.target));
53
53
  Helper.onKeyUp('.s-verify-modal-input', event => {
54
54
  var _a, _b, _c, _d;
55
55
  let key = event.keyCode || event.charCode;
@@ -64,7 +64,7 @@ const SallaVerifyModal = class {
64
64
  this.toggleOTPSubmit();
65
65
  });
66
66
  Helper.on('paste', '.s-verify-modal-input', event => {
67
- let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
67
+ let text = salla.helpers.number(event.clipboardData.getData('text')).replace(/[^0-9.]/g, '').replace('..', '.');
68
68
  this.otpInputs.forEach((input, i) => input.value = text[i] || '');
69
69
  this.toggleOTPSubmit();
70
70
  setTimeout(() => this.otpInputs[3].focus(), 100);
@@ -131,11 +131,11 @@ const SallaVerifyModal = class {
131
131
  .catch(() => this.btn.stop() && this.btn.enable() && this.reset());
132
132
  }
133
133
  render() {
134
- return this.withoutModal ? this.myBody() :
134
+ return this.withoutModal ? h(Host, null, this.myBody()) :
135
135
  h("salla-modal", { icon: "sicon-android-phone", width: "xs", id: "s-verify-modal", ref: modal => this.modal = modal, title: this.title }, this.myBody());
136
136
  }
137
137
  myBody() {
138
- return (h(Host, { id: "s-verify-modal" }, h("div", { class: "s-verify-modal-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), h("div", { class: "s-verify-modal-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "text", maxlength: "1", class: "s-verify-modal-input", required: true }))), h("div", { slot: "footer", class: "s-verify-modal-footer" }, h("salla-button", { class: "s-verify-modal-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), h("p", { class: "s-verify-modal-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), h("b", { class: "s-verify-modal-timer", ref: el => this.timer = el })), h("a", { href: "#", class: "s-verify-modal-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))), h("slot", { name: "after-footer" })));
138
+ return (h("div", { id: "s-verify-modal" }, h("div", { class: "s-verify-modal-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), h("div", { class: "s-verify-modal-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "text", maxlength: "1", class: "s-verify-modal-input", required: true }))), h("div", { slot: "footer", class: "s-verify-modal-footer" }, h("salla-button", { class: "s-verify-modal-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), h("p", { class: "s-verify-modal-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), h("b", { class: "s-verify-modal-timer", ref: el => this.timer = el })), h("a", { href: "#", class: "s-verify-modal-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))), h("slot", { name: "after-footer" })));
139
139
  }
140
140
  get host() { return getElement(this); }
141
141
  };
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["salla-button",[[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2",[[0,"salla-search",{"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);
16
+ 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);
17
17
  });
@@ -1 +1 @@
1
- export{S as SallaLoginModal}from"./p-0b599094.js";export{S as SallaSearch}from"./p-5ffd56fb.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
1
+ export{S as SallaLoginModal}from"./p-88dce1e4.js";export{S as SallaSearch}from"./p-e4f716b0.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
@@ -0,0 +1 @@
1
+ export{S as salla_login_modal}from"./p-88dce1e4.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
@@ -1 +1 @@
1
- import{r as s,c as i,h as t,H as a,g as l}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";export{S as salla_search}from"./p-5ffd56fb.js";const o=class{constructor(t){s(this,t),this.modalOpened=i(this,"modalOpened",7),this.modalClosed=i(this,"modalClosed",7),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.icon="",this.iconStyle="",this.imageIcon="",e.setHost(this.host),salla.event.on("modal::open",(s=>s.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(s=>s.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title")}handleVisible(s){if(!s)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.title=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(s){const i=this.host.querySelector(".s-modal-body");e.toggleElement(i,"s-modal-entering","s-modal-leaving",(()=>s)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":"error"!=this.iconStyle&&"success"!=this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}iconClasses(){return{[this.icon]:!0,"sicon-alert-engine":!this.icon&&"error"==this.iconStyle&&!this.imageIcon,"sicon-check-circle2":!this.icon&&"success"==this.iconStyle&&!this.imageIcon}}render(){return this.host.id=this.host.id||"salla-modal",t(a,{class:"salla-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal()}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},"​"),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},this.isLoading?t("div",{class:"s-modal-loader-wrap"},t("span",{class:"s-modal-loader"})):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.title||this.subTitle?t("div",{class:"s-modal-header-inner"},this.iconStyle||this.icon?t("div",{class:this.iconBlockClasses()},t("i",{class:this.iconClasses()})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}))):""),t("slot",null),t("slot",{name:"footer"})])))}get host(){return l(this)}static get watchers(){return{visible:["handleVisible"]}}};o.style="";export{o as salla_modal}
1
+ import{r as s,c as i,h as t,H as a,g as l}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";export{S as salla_search}from"./p-e4f716b0.js";const o=class{constructor(t){s(this,t),this.modalOpened=i(this,"modalOpened",7),this.modalClosed=i(this,"modalClosed",7),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.icon="",this.iconStyle="",this.imageIcon="",e.setHost(this.host),salla.event.on("modal::open",(s=>s.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(s=>s.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title")}handleVisible(s){if(!s)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.title=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(s){const i=this.host.querySelector(".s-modal-body");e.toggleElement(i,"s-modal-entering","s-modal-leaving",(()=>s)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":"error"!=this.iconStyle&&"success"!=this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}iconClasses(){return{[this.icon]:!0,"sicon-alert-engine":!this.icon&&"error"==this.iconStyle&&!this.imageIcon,"sicon-check-circle2":!this.icon&&"success"==this.iconStyle&&!this.imageIcon}}render(){return this.host.id=this.host.id||"salla-modal",t(a,{class:"salla-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal()}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},"​"),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},this.isLoading?t("div",{class:"s-modal-loader-wrap"},t("span",{class:"s-modal-loader"})):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.title||this.subTitle?t("div",{class:"s-modal-header-inner"},this.iconStyle||this.icon?t("div",{class:this.iconBlockClasses()},t("i",{class:this.iconClasses()})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}))):""),t("slot",null),t("slot",{name:"footer"})])))}get host(){return l(this)}static get watchers(){return{visible:["handleVisible"]}}};o.style=".salla-modal .s-modal-wrapper{height:calc(var(--vh, 1vh) * 100)}";export{o as salla_modal}
@@ -0,0 +1 @@
1
+ import{r as s,h as a,g as e}from"./p-cb1c59a2.js";const t=class{constructor(a){s(this,a),this.open=!1,this.isOpenedBefore=salla.storage.get("branch-choosed-before"),this.displayAs="default",this.browseProductsFrom="all",this.branches=[{id:1,name:"فرع الرياض",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:2,name:"فرع جدة",open:!1,available:!1,limited:!1,tag:"غير متوفر"},{id:3,name:"فرع مكة",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:4,name:"فرع المدينة",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:5,name:"فرع جازان",open:!0,available:!0,limited:!0,tag:"الكمية محدودة"}],this.current=1,this.currentBranch=s=>this.branches.filter((s=>s.id==this.current))[0][s],this.statusColor=(s=null)=>s?s.limited?"s-branches-color-red":s.available?"s-branches-color-green":"s-branches-color-gray":this.currentBranch("limited")?"s-branches-color-red":this.currentBranch("available")?"s-branches-color-green":"s-branches-color-gray",this.isChoiceable=()=>"all"!==this.browseProductsFrom&&"single"==this.position||"header"==this.position,this.formTitle=()=>this.isChoiceable()?"توفر المنتج في الفروع الآخرى":"التسوق من فرع آخر",salla.event.on("branches::show",(()=>this.show())),salla.event.on("languages::translations.loaded",(()=>{var s;return null===(s=this.btn)||void 0===s?void 0:s.setText(salla.lang.get("common.elements.ok"))}))}async show(){return this.modal.show()}async hide(){return this.modal.hide()}handelChange(s){this.selected=s.target.value}handleSubmit(){this.btn.load().then((()=>{setTimeout((()=>location.reload()),2e3)})),salla.storage.set("branch-choosed-before",!0),this.show(),setTimeout((()=>{this.current=this.selected}),300)}render(){return a("salla-modal",{icon:"sicon-store-alt",title:"فرع الرياض","sub-title":"أنت الآن تتصفح المتجر من","sub-title-first":!0,"is-closable":this.isOpenedBefore||"popup"!=this.displayAs?"true":"false",ref:s=>this.modal=s,width:"sm",id:"s-branches-modal",class:"s-hidden"},a("h4",{class:"s-branches-title"},this.formTitle()),this.branches.length<=5?a("div",{class:"s-branches-space-v"},this.branches.map((s=>a("div",{class:"s-branches-input-wrap"},a("input",{id:this.position+"_branch_"+s.id,disabled:!s.open&&this.isChoiceable(),name:"lang",type:"radio",value:s.id,onChange:s=>this.handelChange(s),class:{"s-branches-input":!0,"opacity-50":!s.open,"s-hidden":!this.isChoiceable()},checked:this.current==s.id}),a("label",{htmlFor:this.position+"_branch_"+s.id,class:{"s-branches-label":!0,"s-branches-clickable":this.isChoiceable()}},a("span",{class:{"s-branches-is-closed":!s.open}},s.name),this.isChoiceable()?a("small",{class:"s-branches-closed-badge"},s.open?"":"مُغلق"):a("span",{class:this.statusColor(s)},s.tag)))))):a("select",{class:"s-branches-select",onInput:s=>this.handelChange(s)},this.branches.map((s=>a("option",{value:s.id,disabled:!s.open,selected:this.selected==s.id},s.name," ",s.open?"":"- مُغلق")))),this.isChoiceable()?a("slot",{name:"footer"},a("salla-button",{ref:s=>this.btn=s,onClick:()=>this.handleSubmit(),class:"s-branches-submit",wide:!0},salla.lang.get("common.elements.ok"))):"")}componentDidRender(){this.isOpenedBefore||"popup"!=this.displayAs||this.show()}get host(){return e(this)}};t.style="";export{t as salla_branches}
@@ -0,0 +1 @@
1
+ import{r as s,h as i,H as t,g as a}from"./p-cb1c59a2.js";import{H as l}from"./p-ed1c00c5.js";const e=class{constructor(i){s(this,i),this.isUser=l.isUser(),this.productId=salla.config.get("page.id"),this.isSubscribed=!1,this.submit=async()=>{if(this.isUser)return salla.api.product.availabilitySubscribe(this.productId).then((()=>this.isSubscribed=!0));let{mobile:s,countryCode:i}=await this.mobileInput.getValues(),t={id:this.productId,country_code:i};return""!==s&&(t.mobile=s),""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{this.isSubscribed=!0,salla.storage.set(`product-${this.productId}-subscribed`,!0)})).then((()=>this.btn.stop())).then((()=>this.modal.hide())).catch((()=>this.btn.stop()&&this.btn.enable()))},this.typing=(s,i)=>{const t=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==t?void 0:t.classList.contains("s-product-availability-error-msg"))&&(t.innerText=""),"Enter"==s.key&&i()},salla.event.on("languages::translations.loaded",(()=>{var s,i,t,a;this.subscribedMessage=salla.lang.get("pages.products.notify_availability_success"),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.subTitle=salla.lang.get("pages.products.notify_availability_subtitle"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.emailPlaceholder=salla.lang.get("common.elements.email_placeholder"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),null===(s=this.modal)||void 0===s||s.setTitle(this.title_),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("common.elements.submit")),null===(t=this.cancelBtn)||void 0===t||t.setText(salla.lang.get("common.elements.cancel")),null===(a=this.inlineBtn)||void 0===a||a.setText(salla.lang.get("pages.products.notify_availability"))})),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"),this.isVisitorSubscribed=salla.storage.get(`product-${this.productId}-subscribed`))}channelsWatcher(s){this.channels_=s.split(",")}async validateform(){if(this.channels_.includes("email")){const s=l.isValidEmail(this.email.value);if(s)return;!s&&this.validateField(this.email,this.emailErrorMsg)}if(!this.channels_.includes("sms")||!await this.mobileInput.isValid())throw"Please insert required fields"}validateField(s,i){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+i}render(){return i(t,{id:"s-product-availability"},this.isSubscribed||this.isVisitorSubscribed?i("div",{class:"s-product-availability-subscribed"},i("i",{class:"sicon-bell-ring s-product-availability-subs-icon"})," ",this.subscribedMessage):i("slot",null,i("salla-button",{onClick:()=>this.isUser?this.submit():this.modal.show(),wide:!0,ref:s=>this.inlineBtn=s},salla.lang.get("pages.products.notify_availability"))),this.isUser||this.isSubscribed||this.isVisitorSubscribed?"":this.renderModal())}renderModal(){return i("salla-modal",{ref:s=>this.modal=s,title:this.title_,subTitle:this.subTitle,icon:"sicon-bell-ring",width:"sm"},i("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[i("label",{class:"s-product-availability-label"},this.emailLabel),i("input",{class:"s-product-availability-input",onKeyDown:s=>this.typing(s,this.submit),placeholder:this.emailPlaceholder,ref:s=>this.email=s,type:"email"}),i("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")?[i("label",{class:"s-product-availability-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.mobileInput=s,onKeyDown:s=>this.typing(s,this.submit)})]:""),i("div",{slot:"footer",class:"s-product-availability-footer"},i("salla-button",{wide:!0,"btn-style":"outline",onClick:()=>this.modal.hide(),ref:s=>this.cancelBtn=s},salla.lang.get("common.elements.cancel")),i("salla-button",{"loader-position":"center",wide:!0,ref:s=>this.btn=s,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return a(this)}static get watchers(){return{channels:["channelsWatcher"]}}};e.style="";export{e as salla_product_availability}
@@ -0,0 +1 @@
1
+ import{r as t,h as s,H as o,g as n}from"./p-cb1c59a2.js";const e=class{constructor(s){t(this,s),this.hostAttributes={},this.buttonType="btn",this.color="primary",this.fill="solid",this.size="medium",this.width="normal",this.loading=!1,this.disabled=!1,this.loaderPosition="after",this.wide=!1,this.wide&&this.host.classList.add("s-button-wide")}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),"center"==this.loaderPosition&&this.text.classList.remove("s-button-hide"),this.host}async setText(t){return this.text.innerHTML=t,this.host}async disable(){return this.host.setAttribute("disabled",""),this.host}async enable(){return this.host.removeAttribute("disabled"),this.host}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["type","color","fill","size","width","id"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes.type=this.hostAttributes.type||"button",this.hostAttributes.class+=" s-button-element s-button-"+this.buttonType+" s-button-"+("none"==this.fill?"fill-none":this.fill)+("medium"!=this.size?" s-button-"+this.size:"")+("normal"!=this.width?" s-button-"+this.width:"")+("link"==this.buttonType?" s-button-"+this.color+"-link":"")+("link"!=this.buttonType&&"outline"!=this.fill?" s-button-"+this.color:"")+("outline"==this.fill?" s-button-"+this.color+"-outline":"")+(this.disabled?" s-button-disabled ":"")+("icon"==this.buttonType?" s-button-loader-center":" s-button-loader-"+this.loaderPosition),this.hostAttributes}render(){return s(o,{class:"s-button-wrap"},s("button",Object.assign({},this.getBtnAttributes(),{disabled:this.disabled}),s("span",{class:"s-button-text",ref:t=>this.text=t},s("slot",null)),this.loading?s("span",{class:"s-button-loader"}):""))}get host(){return n(this)}};e.style="salla-button{pointer-events:none}salla-button[type=submit]{-webkit-appearance:none}salla-button[width=wide]{width:100%}.s-button-wrap[loading]{pointer-events:none}.s-button-wrap[loading] .s-button-element{pointer-events:none !important}.s-button-wrap[loading] .s-button-loader-center .s-button-text{opacity:0}.s-button-wrap .s-button-element[loading]{pointer-events:none !important}.s-button-wrap .s-button-element:not(:disabled){pointer-events:auto}.s-button-wrap .s-button-solid .s-button-loader:before{border-color:#fff #fff rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.2)}.s-button-wrap .s-button-outline{border:1px solid currentColor}.s-button-wrap .s-button-outline:hover{border-color:transparent}.s-button-wrap .s-button-outline .s-button-loader:before{border-top-color:currentColor;border-left-color:currentColor}.s-button-wrap .s-button-icon.s-button-large{width:56px;height:56px}.s-button-wrap .s-button-icon.s-button-small{width:24px;height:24px}.s-button-wrap .s-button-icon.s-button-small .s-button-loader:before{width:0.85rem;height:0.85rem}.s-button-wrap .s-button-loader-after .s-button-load{flex-direction:row}.s-button-wrap .s-button-loader-start.s-button-element{padding-right:40px}.s-button-wrap .s-button-loader-start .s-button-loader{position:absolute;right:8px}.s-button-wrap .s-button-loader-start .s-button-loader [dir=ltr]{left:8px;right:auto}.s-button-wrap .s-button-loader-end.s-button-element{padding-left:40px}.s-button-wrap .s-button-loader-end .s-button-loader{position:absolute;left:8px}.s-button-wrap .s-button-loader-end .s-button-loader [dir=ltr]{right:8px;left:auto}.s-button-wrap .s-button-loader-center .s-button-loader{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);margin:0 !important}";export{e as salla_button}