@salla.sa/twilight-components 1.0.17 → 1.0.18

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 (89) hide show
  1. package/dist/{esm/Helper-81ac9a8c.js → twilight-components/Helper-d07ebbc7.js} +1 -1
  2. package/dist/twilight-components/app-globals-0f993ce5.js +3 -0
  3. package/dist/twilight-components/css-shim-a64b8820.js +4 -0
  4. package/dist/twilight-components/dom-d08ba8aa.js +73 -0
  5. package/dist/twilight-components/index-8966d27f.js +3010 -0
  6. package/dist/twilight-components/index.esm.js +4 -1
  7. package/dist/{esm → twilight-components}/salla-branches.entry.js +1 -1
  8. package/dist/twilight-components/salla-button.entry.js +75 -0
  9. package/dist/{esm → twilight-components}/salla-localization.entry.js +18 -16
  10. package/dist/{esm/salla-login-32d25ffa.js → twilight-components/salla-login-7c25f64b.js} +2 -2
  11. package/dist/twilight-components/salla-login-b92c73dc.js +127 -0
  12. package/dist/twilight-components/salla-login.entry.js +3 -0
  13. package/dist/twilight-components/salla-modal.entry.js +113 -0
  14. package/dist/twilight-components/salla-offer.entry.js +46 -0
  15. package/dist/{esm → twilight-components}/salla-product-availability.entry.js +2 -2
  16. package/dist/{esm → twilight-components}/salla-rating.entry.js +2 -2
  17. package/dist/{esm/salla-search-f552c487.js → twilight-components/salla-search-69f2d9c1.js} +2 -2
  18. package/dist/twilight-components/salla-search.entry.js +3 -0
  19. package/dist/{collection/components/salla-verify/salla-verify.js → twilight-components/salla-verify.entry.js} +16 -140
  20. package/dist/twilight-components/shadow-css-bc14d9fd.js +389 -0
  21. package/dist/twilight-components/twilight-components.css +3 -1
  22. package/dist/twilight-components/twilight-components.esm.js +125 -1
  23. package/dist/types/components/salla-localization/salla-localization.d.ts +2 -0
  24. package/dist/types/components/salla-login/salla-login.d.ts +3 -2
  25. package/dist/types/components/salla-offer/salla-offer.d.ts +50 -2
  26. package/dist/types/components/salla-verify/salla-verify.d.ts +2 -0
  27. package/dist/types/components.d.ts +6 -1
  28. package/package.json +1 -1
  29. package/dist/cjs/Helper-8852feaa.js +0 -23
  30. package/dist/cjs/index-0b5b5867.js +0 -1656
  31. package/dist/cjs/index.cjs.js +0 -13
  32. package/dist/cjs/loader.cjs.js +0 -21
  33. package/dist/cjs/salla-branches.cjs.entry.js +0 -92
  34. package/dist/cjs/salla-button_4.cjs.entry.js +0 -299
  35. package/dist/cjs/salla-localization.cjs.entry.js +0 -80
  36. package/dist/cjs/salla-login-342876b9.js +0 -118
  37. package/dist/cjs/salla-offer.cjs.entry.js +0 -25
  38. package/dist/cjs/salla-product-availability.cjs.entry.js +0 -75
  39. package/dist/cjs/salla-rating.cjs.entry.js +0 -300
  40. package/dist/cjs/salla-search-28da4616.js +0 -81
  41. package/dist/cjs/salla-search.cjs.entry.js +0 -11
  42. package/dist/cjs/twilight-components.cjs.js +0 -19
  43. package/dist/collection/Helpers/Helper.js +0 -19
  44. package/dist/collection/collection-manifest.json +0 -21
  45. package/dist/collection/components/generate-summary.js +0 -35
  46. package/dist/collection/components/salla-branches/salla-branches.css +0 -12
  47. package/dist/collection/components/salla-branches/salla-branches.js +0 -233
  48. package/dist/collection/components/salla-button/salla-button.css +0 -3
  49. package/dist/collection/components/salla-button/salla-button.js +0 -246
  50. package/dist/collection/components/salla-localization/salla-localization.js +0 -206
  51. package/dist/collection/components/salla-login/salla-login.js +0 -348
  52. package/dist/collection/components/salla-modal/salla-modal.js +0 -459
  53. package/dist/collection/components/salla-offer/salla-offer.js +0 -40
  54. package/dist/collection/components/salla-product-availability/salla-product-availability.js +0 -331
  55. package/dist/collection/components/salla-rating/salla-rating.css +0 -7
  56. package/dist/collection/components/salla-rating/salla-rating.js +0 -483
  57. package/dist/collection/components/salla-search/salla-search.js +0 -132
  58. package/dist/collection/index.js +0 -2
  59. package/dist/collection/interfaces/colors.js +0 -1
  60. package/dist/collection/interfaces/index.js +0 -2
  61. package/dist/collection/interfaces/ratio.js +0 -1
  62. package/dist/collection/plugins/tailwind-theme/generator.js +0 -62
  63. package/dist/collection/plugins/tailwind-theme/index.js +0 -26
  64. package/dist/esm/index-8b97d225.js +0 -1628
  65. package/dist/esm/index.js +0 -4
  66. package/dist/esm/loader.js +0 -17
  67. package/dist/esm/polyfills/core-js.js +0 -11
  68. package/dist/esm/polyfills/css-shim.js +0 -1
  69. package/dist/esm/polyfills/dom.js +0 -79
  70. package/dist/esm/polyfills/es5-html-element.js +0 -1
  71. package/dist/esm/polyfills/index.js +0 -34
  72. package/dist/esm/polyfills/system.js +0 -6
  73. package/dist/esm/salla-button_4.entry.js +0 -292
  74. package/dist/esm/salla-offer.entry.js +0 -21
  75. package/dist/esm/salla-search.entry.js +0 -3
  76. package/dist/esm/twilight-components.js +0 -17
  77. package/dist/index.cjs.js +0 -1
  78. package/dist/index.js +0 -1
  79. package/dist/twilight-components/p-33990e49.entry.js +0 -1
  80. package/dist/twilight-components/p-36683152.js +0 -1
  81. package/dist/twilight-components/p-3cfede65.entry.js +0 -1
  82. package/dist/twilight-components/p-648661c8.entry.js +0 -1
  83. package/dist/twilight-components/p-93c3ac79.js +0 -1
  84. package/dist/twilight-components/p-9bc28e0c.js +0 -1
  85. package/dist/twilight-components/p-a923a51e.entry.js +0 -1
  86. package/dist/twilight-components/p-bc278b0e.entry.js +0 -1
  87. package/dist/twilight-components/p-cb1c59a2.js +0 -1
  88. package/dist/twilight-components/p-fa04c4b6.entry.js +0 -1
  89. package/dist/twilight-components/p-fa2f0e64.entry.js +0 -1
@@ -1 +1,4 @@
1
- export{S as SallaLogin}from"./p-93c3ac79.js";export{S as SallaSearch}from"./p-36683152.js";import"./p-cb1c59a2.js";import"./p-9bc28e0c.js";
1
+ export { S as SallaLogin } from './salla-login-b92c73dc.js';
2
+ export { S as SallaSearch } from './salla-search-69f2d9c1.js';
3
+ import './index-8966d27f.js';
4
+ import './Helper-d07ebbc7.js';
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
2
 
3
3
  const sallaBranchesCss = ":host{display:block}";
4
4
 
@@ -0,0 +1,75 @@
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-d07ebbc7.js';
3
+
4
+ const sallaButtonCss = ":host{display:block}";
5
+
6
+ const SallaButton = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.btnStyle = 'primary';
10
+ this.loading = false;
11
+ this.disabled = false;
12
+ this.loaderPosition = 'before';
13
+ this.wide = false;
14
+ this.hostAttributes = {};
15
+ //============= Initiate Button Attributes =============//
16
+ for (let i = 0; i < this.host.attributes.length; i++) {
17
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
18
+ }
19
+ this.hostAttributes.type = this.hostAttributes.type || 'button';
20
+ this.hostAttributes.class += ' s-button-btn btn--has-loading'
21
+ + ' s-button-' + this.btnStyle
22
+ + (this.wide ? ' s-button-wide ' : '')
23
+ + ' loader-' + this.loaderPosition
24
+ + (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
25
+ delete this.hostAttributes['btn-style'];
26
+ delete this.hostAttributes['id'];
27
+ if (this.wide) {
28
+ this.host.classList.add('s-button-wide');
29
+ }
30
+ }
31
+ async load() {
32
+ if (this.loaderPosition == 'center')
33
+ this.text.classList.add('s-button-hide');
34
+ this.host.setAttribute('loading', '');
35
+ return this.host;
36
+ }
37
+ async stop() {
38
+ this.host.removeAttribute('loading');
39
+ return this.host;
40
+ }
41
+ async disable() {
42
+ this.host.setAttribute('disabled', '');
43
+ }
44
+ async enable() {
45
+ this.host.removeAttribute('disabled');
46
+ }
47
+ handleVisible(newKind, oldKind) {
48
+ //todo::use united styles
49
+ this.btn.classList.remove('btn-' + oldKind);
50
+ this.btn.classList.add('btn-' + newKind);
51
+ }
52
+ handleLoading(newVal) {
53
+ //todo::use united styles
54
+ Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
55
+ }
56
+ render() {
57
+ return (
58
+ //TODO:: use HOST then fake button behaviours
59
+ h(Host, { class: "s-button-host-tag" }, h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: "s-button-text", ref: el => this.text = el }, h("slot", null)), this.loading ? h("span", { class: {
60
+ //todo::use united styles
61
+ 's-button-loader': true,
62
+ 's-button-loader-start': this.loaderPosition === 'start',
63
+ 's-button-loader-end': this.loaderPosition === 'end',
64
+ 's-button-loader-center': this.loaderPosition === 'center',
65
+ } }) : '')));
66
+ }
67
+ get host() { return getElement(this); }
68
+ static get watchers() { return {
69
+ "btnStyle": ["handleVisible"],
70
+ "loading": ["handleLoading"]
71
+ }; }
72
+ };
73
+ SallaButton.style = sallaButtonCss;
74
+
75
+ export { SallaButton as salla_button };
@@ -1,12 +1,12 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-d07ebbc7.js';
3
3
 
4
4
  const SallaLocalization = class {
5
5
  constructor(hostRef) {
6
6
  registerInstance(this, hostRef);
7
7
  var _a, _b;
8
- this.language = salla.config.language || {};
9
- this.currency = salla.config.currency || {};
8
+ this.language = salla.config.get('language', {});
9
+ this.currency = salla.config.get('currency', {});
10
10
  this.languagesTitle = salla.lang.get('common.titles.language');
11
11
  this.currenciesTitle = salla.lang.get('common.titles.currency');
12
12
  this.ok = salla.lang.get('common.elements.ok');
@@ -23,6 +23,8 @@ const SallaLocalization = class {
23
23
  */
24
24
  this.languageSlot = ((_a = Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-label" for="lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>';
25
25
  this.currencySlot = ((_b = Helper.getElement('[slot="currency"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>';
26
+ this.languages = Object.values(salla.config.get('languages', {}));
27
+ this.currencies = Object.values(salla.config.get('currencies', {}));
26
28
  }
27
29
  async show() {
28
30
  return this.modal.show();
@@ -31,36 +33,36 @@ const SallaLocalization = class {
31
33
  return this.modal.hide();
32
34
  }
33
35
  onChangeCurrency(event) {
34
- this.currency = salla.config.currencies.filter(currency => currency.code == event.target.value)[0];
36
+ this.currency = salla.config.get('currencies.' + event.target.value);
35
37
  }
36
38
  onChangeLanguage(event) {
37
- this.language = salla.config.languages.filter(lang => lang.code == event.target.value)[0];
39
+ this.language = salla.config.get('languages.' + event.target.value);
38
40
  }
39
41
  async submit() {
40
42
  let url;
41
43
  console.log('this.currency.code::::', this.currency, this.currency.code);
42
44
  this.btn.load()
43
- .then(() => (this.currency.code === salla.config.currency.code) || ((url = window.location.href) && salla.currency.api.change(this.currency.code)))
44
- .then(() => (this.language.code === salla.config.language.code) || (url = this.language.url))
45
+ .then(() => this.currency.code === salla.config.get('user.currency') || ((url = window.location.href) && salla.currency.api.change(this.currency.code)))
46
+ .then(() => this.language.code === salla.config.get('user.language') || (url = this.language.url))
45
47
  .then(() => this.btn.stop())
46
48
  .then(() => this.hide())
47
49
  .then(() => url && (window.location.href = url));
48
50
  }
49
51
  render() {
50
- return (h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal, "modal-width": "xs" }, h("div", { slot: "header" }, h("slot", { name: "header" })), h("div", { class: "s-localization-inner" }, salla.config.languages ?
51
- h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.languagesTitle), h("div", { class: "s-localization-section-inner" }, salla.config.languages.length < 6 ?
52
- salla.config.languages.map(lang => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", checked: this.language.code == lang.code, onChange: () => this.language = lang, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }), h("div", { id: "language-slot", innerHTML: this.languageSlot
52
+ return (h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal, "modal-width": "xs" }, h("div", { slot: "header" }, h("slot", { name: "header" })), h("div", { class: "s-localization-inner" }, this.languages.length > 1 ?
53
+ h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.languagesTitle), h("div", { class: "s-localization-section-inner" }, this.languages.length < 6 ?
54
+ this.languages.map(lang => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", checked: this.language.code == lang.code, onChange: () => this.language = lang, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }), h("div", { id: "language-slot", innerHTML: this.languageSlot
53
55
  .replace(/\{name\}/g, lang.name)
54
56
  .replace(/\{code\}/g, lang.code)
55
57
  .replace(/\{country_code\}/g, lang.country_code) }))) :
56
- h("select", { class: "s-branches-select", name: "currency", onChange: e => this.onChangeLanguage(e) }, salla.config.languages.map(lang => h("option", { value: lang.code, selected: this.language.code == lang.code }, lang.name)))))
57
- : '', salla.config.currencies ?
58
- h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.currenciesTitle), h("div", { class: "s-localization-section-inner" }, salla.config.currencies.length < 6 ?
59
- salla.config.currencies.map(currency => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency.code == currency.code, onChange: () => this.currency = currency, id: 'currency-' + currency.code, value: currency.code }), h("div", { id: "currency-slot", innerHTML: this.currencySlot
58
+ h("select", { class: "s-branches-select", name: "currency", onChange: e => this.onChangeLanguage(e) }, this.languages.map(lang => h("option", { value: lang.code, selected: this.language.code == lang.code }, lang.name)))))
59
+ : '', this.currencies.length > 1 ?
60
+ h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.currenciesTitle), h("div", { class: "s-localization-section-inner" }, this.currencies.length < 6 ?
61
+ this.currencies.map(currency => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency.code == currency.code, onChange: () => this.currency = currency, id: 'currency-' + currency.code, value: currency.code }), h("div", { id: "currency-slot", innerHTML: this.currencySlot
60
62
  .replace(/\{name\}/g, currency.name)
61
63
  .replace(/\{code\}/g, currency.code)
62
64
  .replace(/\{country_code\}/g, currency.country_code) }))) :
63
- h("select", { class: "s-branches-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, salla.config.currencies.map(currency => h("option", { value: currency.code, selected: this.currency.code == currency.code }, currency.name)))))
65
+ h("select", { class: "s-branches-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, this.currencies.map(currency => h("option", { value: currency.code, selected: this.currency.code == currency.code }, currency.name)))))
64
66
  : ''), h("slot", { name: "footer" }, h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.ok))));
65
67
  }
66
68
  /**
@@ -1,5 +1,5 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-d07ebbc7.js';
3
3
 
4
4
  const SallaLogin = class {
5
5
  constructor(hostRef) {
@@ -0,0 +1,127 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-d07ebbc7.js';
3
+
4
+ const sallaLoginCss = "salla-verify{display:block}";
5
+
6
+ const SallaLogin = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.inputChanged = (event) => {
10
+ console.log('input changed: ', event.target.value);
11
+ };
12
+ this.regType = 'sms';
13
+ this.isLoginByMail = true;
14
+ this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
15
+ this.loginText = salla.lang.get('blocks.header.login');
16
+ this.smsLabel = salla.lang.get('blocks.header.sms');
17
+ this.mobileLabel = salla.lang.get('common.elements.mobile');
18
+ this.emailLabel = salla.lang.get('common.elements.email');
19
+ this.enterText = salla.lang.get('blocks.header.enter');
20
+ this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
21
+ this.byEmailText = salla.lang.get('blocks.header.login_by_email');
22
+ this.backText = salla.lang.get('common.elements.back');
23
+ this.title = this.host.title || salla.lang.get('blocks.header.login');
24
+ this.host.removeAttribute('title');
25
+ salla.auth.event.onVerificationFailed(() => {
26
+ //
27
+ });
28
+ }
29
+ /**
30
+ * @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
31
+ */
32
+ onVerified(event) {
33
+ if (!event.detail.case) {
34
+ console.log('verified but without case!');
35
+ return;
36
+ }
37
+ if (event.detail.case === "new_customer") {
38
+ return this.showTab(this.tab5);
39
+ }
40
+ //TODO::It looks that is this workaround🤔
41
+ if (salla.auth.event.getTypeActionOnVerified() !== 'redirect') {
42
+ return;
43
+ }
44
+ if (event.redirect_url) {
45
+ return window.location.href = event.redirect_url;
46
+ }
47
+ window.location.reload();
48
+ }
49
+ onbackClicked() {
50
+ this.regType == 'sms' ? this.showTab(this.tab2) : this.showTab(this.tab3);
51
+ }
52
+ async show() {
53
+ this.showTab(this.isLoginByMail ? this.tab1 : this.tab2);
54
+ return this.modal.show();
55
+ }
56
+ showTab(tab) {
57
+ [this.tab1, this.tab2, this.tab3, this.tab4, this.tab5].map(el => Helper.toggleElement(el, 'visible', 'hidden', () => el == tab));
58
+ setTimeout(() => { [this.tab1, this.tab2, this.tab3, this.tab4, this.tab5].map(el => Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab)); }, 200);
59
+ setTimeout(() => { this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'); });
60
+ if ([this.tab2, this.tab3].includes(tab)) {
61
+ this.regType = tab === this.tab2 ? 'sms' : 'email';
62
+ this.backText = this.regType == 'sms' ? 'تغيير رقم الهاتف' : 'تغيير البريد';
63
+ }
64
+ let isRegistrationTab = tab == this.tab5;
65
+ this.modal.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
66
+ if (!isRegistrationTab) {
67
+ Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'sms')
68
+ .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
69
+ }
70
+ return this;
71
+ }
72
+ loginByEmail() {
73
+ if (!Helper.isValidEmail(this.email.value)) {
74
+ this.email.classList.add('s-has-error');
75
+ this.email.nextElementSibling['innerText'] = '* ' + salla.lang.get('common.elements.email_is_valid');
76
+ return;
77
+ }
78
+ this.email.nextElementSibling['innerText'] = '';
79
+ this.email.classList.remove('s-has-error');
80
+ salla.auth.api.login({ type: 'email', email: this.email.value })
81
+ .then(() => this.showTab(this.tab4))
82
+ .then(() => (this.tab4.by = 'email') && (this.tab4.url = 'auth/email/verify'))
83
+ .then(() => this.tab4.show({ email: this.email.value }));
84
+ }
85
+ loginBySMS() {
86
+ if (this.mobile.value.length < 6) {
87
+ this.mobile.classList.add('s-has-error');
88
+ this.mobile.nextElementSibling['innerText'] = '* ' + salla.lang.get('mobile_app.strings.incorrect_mobile');
89
+ return;
90
+ }
91
+ this.mobile.nextElementSibling['innerText'] = '';
92
+ this.mobile.classList.remove('s-has-error');
93
+ salla.auth.api.login({ type: 'sms', mobile: this.mobile.value })
94
+ .then(() => this.showTab(this.tab4))
95
+ .then(() => (this.tab4.by = 'sms') && (this.tab4.url = 'auth/mobile/verify'))
96
+ .then(() => this.tab4.show({ mobile: this.mobile.value, country_code: 'SA' }));
97
+ }
98
+ //TODO:: if it's enter, go submit
99
+ typing({ target }) {
100
+ target.type === 'tel' && salla.helpers.digitsOnly(target);
101
+ target.classList.remove('s-has-error');
102
+ target.nextElementSibling.innerText = '';
103
+ }
104
+ newUser() {
105
+ this.tab4.getCode()
106
+ .then(code => salla.auth.api.register({
107
+ first_name: this.firstName.value,
108
+ last_name: this.lastName.value,
109
+ phone: this.regMobile.value || this.mobile.value,
110
+ email: this.regEmail.value || this.email.value,
111
+ country_code: '',
112
+ country_key: '',
113
+ code: code,
114
+ verified_by: this.regType,
115
+ }));
116
+ }
117
+ render() {
118
+ return (h("salla-modal", { id: "salla-login", title: this.title, ref: modal => this.modal = modal, width: "xs" }, h("div", { class: "s-login-wrapper" }, this.isLoginByMail ?
119
+ h("div", { class: "s-login-tab", ref: tab => this.tab1 = tab }, h("p", { class: "s-login-sub-title" }, this.loginTypeTitle), h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab2) }, h("i", { class: "s-login-main-btn-icon sicon-phone" }), h("span", { class: "s-login-main-btn-text" }, this.smsLabel), h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab3) }, h("i", { class: "s-login-main-btn-icon sicon-mail" }), h("span", { class: "s-login-main-btn-text" }, this.emailLabel), h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })))
120
+ : '', h("div", { class: "s-login-tab", ref: tab => this.tab2 = tab }, h("label", { class: "s-login-label" }, this.mobileLabel), h("input", { onChange: () => this.loginBySMS(), type: "tel", ref: el => this.mobile = el, onInput: this.typing, placeholder: "5xx xxx xxx", class: "s-login-input tel-input s-ltr" }), h("span", { class: "s-login-error-message" }), h("salla-button", { wide: true, onClick: () => this.loginBySMS() }, this.enterText), this.isLoginByMail ? h("a", { href: "#", onClick: () => this.showTab(this.tab3), class: "s-login-link" }, this.byEmailText) : ''), this.isLoginByMail ?
121
+ h("div", { class: "s-login-tab", ref: tab => this.tab3 = tab }, h("label", { class: "s-login-label" }, this.emailLabel), h("input", { onChange: () => this.loginByEmail(), type: "email", ref: el => this.email = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" }), h("salla-button", { wide: true, onClick: () => this.loginByEmail() }, this.enterText), h("a", { href: "#", onClick: () => this.showTab(this.tab2), class: "s-login-link" }, this.bySMSText)) : '', h("salla-verify", { "without-modal": true, ref: tab => this.tab4 = tab, autoReload: false, "back-text": this.backText }), h("div", { ref: tab => this.tab5 = tab }, h("label", { class: "s-login-label" }, salla.lang.get('blocks.header.your_name')), h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, placeholder: salla.lang.get('pages.profile.first_name') }), h("label", { class: "s-login-label" }, salla.lang.get('pages.profile.last_name')), h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, placeholder: salla.lang.get('pages.profile.last_name') }), h("div", { ref: el => this.regMobileBlock = el }, h("label", { class: "s-login-label" }, this.mobileLabel), h("input", { type: "tel", ref: el => this.regMobile = el, onInput: this.typing, placeholder: "5xx xxx xxx", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" })), h("div", { ref: el => this.regEmailBlock = el }, h("label", { class: "s-login-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.regEmail = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" })), h("salla-button", { wide: true, onClick: () => this.newUser() }, salla.lang.get('blocks.header.register'))))));
122
+ }
123
+ get host() { return getElement(this); }
124
+ };
125
+ SallaLogin.style = sallaLoginCss;
126
+
127
+ export { SallaLogin as S };
@@ -0,0 +1,3 @@
1
+ export { S as salla_login } from './salla-login-b92c73dc.js';
2
+ import './index-8966d27f.js';
3
+ import './Helper-d07ebbc7.js';
@@ -0,0 +1,113 @@
1
+ import { r as registerInstance, f as createEvent, h, e as Host, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-d07ebbc7.js';
3
+
4
+ const SallaModal = class {
5
+ constructor(hostRef) {
6
+ registerInstance(this, hostRef);
7
+ this.modalOpened = createEvent(this, "modalOpened", 7);
8
+ this.modalClosed = createEvent(this, "modalClosed", 7);
9
+ var _a;
10
+ //todo:: unite three colors (error, success, primary) in one prop
11
+ this.error = false;
12
+ this.success = false;
13
+ this.primary = false;
14
+ this.isClosable = true;
15
+ this.width = 'md';
16
+ this.visible = false;
17
+ this.isLoading = false;
18
+ this.subTitleFirst = false;
19
+ this.subTitle = '';
20
+ this.icon = '';
21
+ this.imageIcon = '';
22
+ Helper.setHost(this.host);
23
+ salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
24
+ salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
25
+ this.title = this.host.title;
26
+ this.host.removeAttribute('title');
27
+ (_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
28
+ }
29
+ handleVisible(newValue) {
30
+ if (!newValue) {
31
+ this.toggleModal(false);
32
+ this.modalClosed.emit();
33
+ return;
34
+ }
35
+ this.host.classList.remove('hidden');
36
+ setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
37
+ this.modalOpened.emit();
38
+ }
39
+ async show() {
40
+ this.host.setAttribute('visible', '');
41
+ return this.host;
42
+ }
43
+ async hide() {
44
+ this.host.removeAttribute('visible');
45
+ return this.host;
46
+ }
47
+ async setTitle(title) {
48
+ this.title = title;
49
+ return this.host;
50
+ }
51
+ async loading() {
52
+ this.isLoading = true;
53
+ return this.host;
54
+ }
55
+ async stopLoading() {
56
+ this.isLoading = false;
57
+ return this.host;
58
+ }
59
+ toggleModal(isOpen) {
60
+ Helper
61
+ // .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
62
+ .toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
63
+ .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
64
+ //todo:: use united class names
65
+ .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
66
+ if (!isOpen) {
67
+ setTimeout(() => this.host.classList.add('hidden'), 350);
68
+ }
69
+ }
70
+ closeModal() {
71
+ if (!this.isClosable) {
72
+ return;
73
+ }
74
+ this.host.removeAttribute('visible');
75
+ }
76
+ //todo:: pref for each modal
77
+ render() {
78
+ this.host.id = this.host.id || 'salla-modal';
79
+ return (
80
+ //todo:: use suitable class name instead of hidden
81
+ h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), h("span", { class: "s-modal-spacer" }, "\u200B"), h("slot", { name: "body" }, h("div", { class: 's-modal-body ' + 's-modal-' + this.width, slot: "body" }, this.isLoading
82
+ ? h("span", null, "Loading...")
83
+ : [h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
84
+ //todo:: remove cursor-pointer
85
+ h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
86
+ : '', this.error || this.success || this.icon
87
+ ? h("div", { class: {
88
+ 's-modal-icon': true,
89
+ 's-modal-bg-error': this.error,
90
+ 's-modal-bg-success': this.success,
91
+ 's-modal-bg-normal': !this.error && !this.success,
92
+ 's-modal-bg-primary': this.primary
93
+ } }, h("i", { class: {
94
+ [this.icon]: true,
95
+ 's-modal-text-error': this.error,
96
+ 's-modal-text-success': this.success,
97
+ } }))
98
+ : this.imageIcon ?
99
+ h("img", { class: "s-modal-header-img", src: this.imageIcon })
100
+ : '', this.title || this.subTitle ?
101
+ h("div", { class: "s-modal-header-content" }, h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
102
+ : ''),
103
+ h("slot", null),
104
+ h("slot", { name: "footer" })
105
+ ])))));
106
+ }
107
+ get host() { return getElement(this); }
108
+ static get watchers() { return {
109
+ "visible": ["handleVisible"]
110
+ }; }
111
+ };
112
+
113
+ export { SallaModal as salla_modal };
@@ -0,0 +1,46 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
+
3
+ const SallaOffer = class {
4
+ constructor(hostRef) {
5
+ registerInstance(this, hostRef);
6
+ this.offer = null;
7
+ salla.offer.event.onExisted(data => {
8
+ //TODO:: use the best, should we hide the offer by product Id or Offer id🤔
9
+ if (salla.localStore.get('remember-offer-' + data.offer.offer_id)) {
10
+ salla.log('User selected to don\'t show this offer again.');
11
+ return;
12
+ }
13
+ this.show(data.product_id);
14
+ });
15
+ }
16
+ async show(productId) {
17
+ this.modal.show()
18
+ .then(() => salla.api.offer.details(productId))
19
+ //TODO:: make sure there is only one offer
20
+ .then(response => this.offer = response.data[0])
21
+ .then(() => console.log(this.offer));
22
+ }
23
+ rememberMe(event) {
24
+ salla.localStore.set('remember-offer-' + this.offer.id, event.target.checked);
25
+ }
26
+ render() {
27
+ var _a, _b;
28
+ return h("salla-modal", { ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
29
+ ? [h("div", { class: "s-offer-header" }, h("b", { class: "s-offer-title" }, this.offer.name), h("h3", { class: "s-offer-subtitle" }, this.offer.message)),
30
+ h("div", { class: "s-offer-body" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
31
+ ? this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-badge" }, h("i", { class: "s-offer-badge-icon sicon-tag" }), h("span", { class: "s-offer-badge-text" }, category.name)))
32
+ : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: "s-offer-product" }, "- ", product.name))),
33
+ h("div", { class: "s-offer-footer" }, this.offer.expiry_date ?
34
+ h("p", { class: "s-offer-expiry" }, salla.lang.get('pages.products.offer_expires_in'), " ", this.offer.expiry_date)
35
+ : '', h("label", { class: "s-offer-remember-label" }, h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-remember-input" }), "\u00A0 ", salla.lang.get('common.remember_my_choice'))),
36
+ ] : '');
37
+ }
38
+ componentDidRender() {
39
+ //todo:: now from where there is hidden attributes to the doms🤔
40
+ //todo:: add animation
41
+ this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
42
+ }
43
+ get host() { return getElement(this); }
44
+ };
45
+
46
+ export { SallaOffer as salla_offer };
@@ -1,5 +1,5 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-d07ebbc7.js';
3
3
 
4
4
  const SallaProductAvailability = class {
5
5
  constructor(hostRef) {
@@ -1,5 +1,5 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-d07ebbc7.js';
3
3
 
4
4
  const sallaRatingCss = ":host{display:block}.unicode{unicode-bidi:plaintext}";
5
5
 
@@ -1,5 +1,5 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-8b97d225.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
1
+ import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
2
+ import { H as Helper } from './Helper-d07ebbc7.js';
3
3
 
4
4
  const SallaSearch = class {
5
5
  constructor(hostRef) {
@@ -0,0 +1,3 @@
1
+ export { S as salla_search } from './salla-search-69f2d9c1.js';
2
+ import './index-8966d27f.js';
3
+ import './Helper-d07ebbc7.js';