@salla.sa/twilight-components 1.0.26 → 1.0.27

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 (30) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-button_5.cjs.entry.js +10 -2
  4. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +74 -0
  5. package/dist/cjs/{salla-login-bf0972bf.js → salla-login-15aff630.js} +39 -16
  6. package/dist/cjs/twilight-components.cjs.js +1 -1
  7. package/dist/collection/collection-manifest.json +1 -0
  8. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +149 -0
  9. package/dist/collection/components/salla-login/salla-login.js +78 -22
  10. package/dist/collection/components/salla-modal/salla-modal.js +20 -1
  11. package/dist/collection/components/salla-tel-input/salla-tel-input.js +12 -5
  12. package/dist/esm/index.js +1 -1
  13. package/dist/esm/loader.js +1 -1
  14. package/dist/esm/salla-button_5.entry.js +10 -2
  15. package/dist/esm/salla-infinite-scroll.entry.js +70 -0
  16. package/dist/esm/{salla-login-fcb7ad15.js → salla-login-e6e86a3d.js} +39 -16
  17. package/dist/esm/twilight-components.js +1 -1
  18. package/dist/twilight-components/index.esm.js +1 -1
  19. package/dist/twilight-components/p-932906dc.entry.js +1 -0
  20. package/dist/twilight-components/p-c479a524.entry.js +1 -0
  21. package/dist/twilight-components/p-f97ea1f7.js +1 -0
  22. package/dist/twilight-components/twilight-components.esm.js +1 -1
  23. package/dist/types/components/salla-infinite-scroll/salla-infinite-scroll.d.ts +27 -0
  24. package/dist/types/components/salla-login/salla-login.d.ts +2 -0
  25. package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
  26. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +5 -5
  27. package/dist/types/components.d.ts +45 -0
  28. package/package.json +1 -1
  29. package/dist/twilight-components/p-13855688.js +0 -1
  30. package/dist/twilight-components/p-6d5f0951.entry.js +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaLogin = require('./salla-login-bf0972bf.js');
5
+ const sallaLogin = require('./salla-login-15aff630.js');
6
6
  const sallaSearch = require('./salla-search-eb0112c0.js');
7
7
  require('./index-714023c8.js');
8
8
  require('./Helper-fcea994c.js');
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-button_5.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"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"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"isShowBack":[4,"is-show-back"],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"invalidNumber":[32],"invalidCountryCode":[32],"tooShort":[32],"tooLong":[32],"mobileLabel":[32],"countryCodeLabel":[32],"mobileRequired":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subscribeText":[32],"cancelText":[32],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"buttonText":[32],"emailErrorMsg":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"ok":[32],"show":[64],"hide":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[32],"currenciesTitle":[32],"ok":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
17
+ return index.bootstrapLazy([["salla-button_5.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"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"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"isShowBack":[4,"is-show-back"],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[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]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"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],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subscribeText":[32],"cancelText":[32],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"buttonText":[32],"emailErrorMsg":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"ok":[32],"show":[64],"hide":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[32],"currenciesTitle":[32],"ok":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-714023c8.js');
6
6
  const Helper = require('./Helper-fcea994c.js');
7
- const sallaLogin = require('./salla-login-bf0972bf.js');
7
+ const sallaLogin = require('./salla-login-15aff630.js');
8
8
 
9
9
  const sallaButtonCss = ":host{display:block}";
10
10
 
@@ -97,6 +97,7 @@ const SallaModal = class {
97
97
  this.visible = false;
98
98
  this.isLoading = false;
99
99
  this.subTitleFirst = false;
100
+ this.noPadding = false;
100
101
  this.subTitle = '';
101
102
  this.icon = '';
102
103
  this.imageIcon = '';
@@ -159,7 +160,7 @@ const SallaModal = class {
159
160
  this.host.id = this.host.id || 'salla-modal';
160
161
  return (
161
162
  //todo:: use suitable class name instead of hidden
162
- index.h(index.Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body ' + 's-modal-align-' + this.position + ' s-modal-' + this.width, slot: "body" }, this.isLoading
163
+ index.h(index.Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding'), slot: "body" }, this.isLoading
163
164
  ? index.h("div", { class: "s-modal-loader-wrap" }, index.h("span", { class: "s-modal-loader" }))
164
165
  :
165
166
  [index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
@@ -1571,6 +1572,13 @@ const SallaTelInput = class {
1571
1572
  this.enterClicked = index.createEvent(this, "enterClicked", 7);
1572
1573
  this.countryCode = "SA";
1573
1574
  this.countryKey = "+966";
1575
+ this.countryCodeLabel = salla.lang.get('common.country_code');
1576
+ this.mobileLabel = salla.lang.get('common.elements.mobile');
1577
+ this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
1578
+ this.tooLong = salla.lang.get('common.errors.too_long', { attribute: this.mobileLabel });
1579
+ this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.countryCodeLabel });
1580
+ this.invalidNumber = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
1581
+ this.errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
1574
1582
  Helper.Helper.setHost(this.host);
1575
1583
  salla.event.on('languages::translations.loaded', () => {
1576
1584
  this.mobileLabel = salla.lang.get('common.elements.mobile');
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-714023c8.js');
6
+ const Helper = require('./Helper-fcea994c.js');
7
+
8
+ const SallaInfiniteScroll = class {
9
+ constructor(hostRef) {
10
+ index.registerInstance(this, hostRef);
11
+ /**
12
+ * Next Page element
13
+ */
14
+ this.nextPage = '';
15
+ this.autoload = false;
16
+ /**
17
+ * Class selector to know the container if it's not the host `<salla-infinite-scroll>`
18
+ */
19
+ this.container = '.s-infinite-scroll-container';
20
+ /**
21
+ * Class selector to know list items
22
+ */
23
+ this.item = '.list-block';
24
+ Helper.Helper.setHost(this.host);
25
+ this.status = document.createElement('div');
26
+ this.status.className = 's-infinite-scroll-wrapper';
27
+ this.status.innerHTML = `<div class="s-infinite-scroll-status" style="display:none">
28
+ <p class="s-infinite-scroll-last infinite-scroll-last"></p>
29
+ <p class="s-infinite-scroll-error infinite-scroll-error"></p>
30
+ </div>
31
+ <a href="${this.nextPage}" class="s-button-btn btn--has-loading s-button-primary">
32
+ <span class="s-button-text"></span>
33
+ <span class="s-button-loader s-button-loader-start" style="display: none"></span>
34
+ </a>`;
35
+ this.btnLoader = this.status.querySelector('.s-button-loader');
36
+ salla.event.on('languages::translations.loaded', () => {
37
+ this.status.querySelector('.s-button-text').innerHTML = salla.lang.get('common.elements.load_more');
38
+ this.status.querySelector('.s-infinite-scroll-last').innerHTML = salla.lang.get('common.elements.end_of_content');
39
+ this.status.querySelector('.s-infinite-scroll-error').innerHTML = salla.lang.get('common.elements.failed_to_load_more');
40
+ });
41
+ }
42
+ loading(isLoading = true) {
43
+ this.btnLoader.style.display = isLoading ? 'inline-block' : 'none';
44
+ }
45
+ render() {
46
+ return this.nextPage.length > 1 ?
47
+ index.h(index.Host, { class: "s-infinite-scroll-container" }, index.h("slot", null)) : '';
48
+ }
49
+ componentDidLoad() {
50
+ if (this.nextPage.length === 0) {
51
+ return;
52
+ }
53
+ this.host.insertAdjacentElement('afterend', this.status);
54
+ let that = this;
55
+ salla.infiniteScroll.initiate(this.container, {
56
+ history: this.autoload ? 'push' : false,
57
+ scrollThreshold: this.autoload ? 400 : false,
58
+ nextPage: this.nextPage,
59
+ checkLastPage: 'salla-infinite-scroll[next-page*=":"]',
60
+ status: '.s-infinite-scroll-status',
61
+ button: this.status.querySelector('.s-button-btn'),
62
+ append: this.item,
63
+ path: function () {
64
+ return that.nextPage.replace(/page\=(\d)/g, 'page=' + (this.loadCount + 2));
65
+ },
66
+ })
67
+ .on('request', () => this.loading())
68
+ .on('load', () => this.loading(false))
69
+ .on('error', () => this.loading(false));
70
+ }
71
+ get host() { return index.getElement(this); }
72
+ };
73
+
74
+ exports.salla_infinite_scroll = SallaInfiniteScroll;
@@ -8,8 +8,21 @@ const sallaLoginCss = "salla-verify{display:block}#salla-login .s-modal-body{ove
8
8
  const SallaLogin = class {
9
9
  constructor(hostRef) {
10
10
  index.registerInstance(this, hostRef);
11
- this.isEmailAllowed = true;
12
11
  this.regType = 'phone';
12
+ this.title = salla.lang.get('blocks.header.login');
13
+ this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
14
+ this.loginText = salla.lang.get('blocks.header.login');
15
+ this.smsLabel = salla.lang.get('blocks.header.sms');
16
+ this.mobileLabel = salla.lang.get('common.elements.mobile');
17
+ this.emailLabel = salla.lang.get('common.elements.email');
18
+ this.enterText = salla.lang.get('blocks.header.enter');
19
+ this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
20
+ this.byEmailText = salla.lang.get('blocks.header.login_by_email');
21
+ this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
22
+ this.firstNameLabel = salla.lang.get('blocks.header.your_name');
23
+ this.lastNameLabel = salla.lang.get('pages.profile.last_name');
24
+ this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
25
+ this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
13
26
  this.typing = (e, submitMethod) => {
14
27
  const error = e.target.nextElementSibling;
15
28
  e.target.classList.remove('s-has-error');
@@ -43,21 +56,22 @@ const SallaLogin = class {
43
56
  .then(() => this.verifyTab.show({ email: this.loginEmail.value }));
44
57
  };
45
58
  this.newUser = async () => {
46
- const { mobile: regPhone, countryCode, countryKey } = await this.regTelInput.getValues();
59
+ var _a;
60
+ const { mobile: regPhone, countryCode, countryKey } = await this.regTelInput.getValues(), emailValue = this.regEmail.value || ((_a = this.loginEmail) === null || _a === void 0 ? void 0 : _a.value);
47
61
  await this.newUserValidation();
48
62
  await this.regBtn.load();
49
63
  await this.regBtn.disable();
50
- this.verifyTab.getCode()
51
- .then(code => salla.auth.api.register({
64
+ let data = {
52
65
  first_name: this.firstName.value,
53
66
  last_name: this.lastName.value,
54
67
  phone: regPhone || this.loginTelInput.mobile,
55
- email: this.regEmail.value || this.loginEmail.value,
56
68
  country_code: countryCode,
57
69
  country_key: countryKey,
58
- code: code,
59
70
  verified_by: this.regType,
60
- }))
71
+ };
72
+ emailValue && (data = Object.assign(Object.assign({}, data), { email: emailValue }));
73
+ this.verifyTab.getCode()
74
+ .then(code => salla.auth.api.register(Object.assign(Object.assign({}, data), { code })))
61
75
  .then(() => window.location.reload())
62
76
  .catch(() => this.regBtn.stop() && this.regBtn.enable());
63
77
  };
@@ -65,6 +79,7 @@ const SallaLogin = class {
65
79
  this.host.removeAttribute('title');
66
80
  salla.event.on('languages::translations.loaded', () => {
67
81
  var _a;
82
+ this.title = salla.lang.get('blocks.header.login');
68
83
  this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
69
84
  this.loginText = salla.lang.get('blocks.header.login');
70
85
  this.smsLabel = salla.lang.get('blocks.header.sms');
@@ -73,14 +88,12 @@ const SallaLogin = class {
73
88
  this.enterText = salla.lang.get('blocks.header.enter');
74
89
  this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
75
90
  this.byEmailText = salla.lang.get('blocks.header.login_by_email');
76
- this.title = salla.lang.get('blocks.header.login');
77
91
  this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
78
92
  this.firstNameLabel = salla.lang.get('blocks.header.your_name');
79
93
  this.lastNameLabel = salla.lang.get('pages.profile.last_name');
80
94
  this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
81
95
  this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
82
96
  (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
83
- this.showTab(this.isEmailAllowed ? this.homeTab : this.mobileTab);
84
97
  });
85
98
  salla.auth.event.onVerificationFailed(() => {
86
99
  //
@@ -112,7 +125,15 @@ const SallaLogin = class {
112
125
  this.regType == 'phone' ? this.showTab(this.mobileTab) : this.showTab(this.emailTab);
113
126
  }
114
127
  async show() {
115
- this.showTab(this.isEmailAllowed ? this.homeTab : this.mobileTab);
128
+ if (this.isEmailAllowed && this.isMobileAllowed) {
129
+ this.showTab(this.homeTab);
130
+ }
131
+ else if (this.isEmailAllowed) {
132
+ this.showTab(this.emailTab);
133
+ }
134
+ else if (this.isMobileAllowed) {
135
+ this.showTab(this.mobileTab);
136
+ }
116
137
  return this.modal.show();
117
138
  }
118
139
  showTab(tab, evt) {
@@ -138,8 +159,8 @@ const SallaLogin = class {
138
159
  return this;
139
160
  }
140
161
  async newUserValidation() {
141
- const isPhoneReg = this.regType == "phone", isEmailReg = this.regType == "email", isFirstNameValid = this.firstName.value.length > 0, isLastNameValid = this.lastName.value.length > 0, isEmailValid = Helper.Helper.isValidEmail(this.regEmail.value || isEmailReg && this.loginEmail.value), isPhoneValid = await this.regTelInput.isValid() || isPhoneReg && await this.loginTelInput.isValid();
142
- if (isEmailValid && isPhoneValid && isFirstNameValid && isLastNameValid)
162
+ const isLogByPhone = this.regType == "phone", isLogByEmail = this.regType == "email", emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value), isEmailValid = Helper.Helper.isValidEmail(emailValue), isFirstNameValid = this.firstName.value.length > 0, isLastNameValid = this.lastName.value.length > 0, isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(), emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);
163
+ if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid)
143
164
  return;
144
165
  !isEmailValid && this.validateField(this.regEmail, this.emailErrorMsg);
145
166
  !isFirstNameValid && this.validateField(this.firstName, this.firstNameErrorMsg);
@@ -151,11 +172,13 @@ const SallaLogin = class {
151
172
  field.nextElementSibling['innerText'] = '* ' + errorMsg;
152
173
  }
153
174
  render() {
154
- return (index.h("salla-modal", { id: "salla-login", icon: "sicon-user", title: this.title, ref: modal => this.modal = modal, width: "xs" }, index.h("div", { class: "s-login-wrapper" }, this.isEmailAllowed ?
175
+ return (index.h("salla-modal", { id: "salla-login", icon: "sicon-user", title: this.title, ref: modal => this.modal = modal, width: "xs" }, index.h("div", { class: "s-login-wrapper" }, this.isEmailAllowed && this.isMobileAllowed ?
155
176
  index.h("div", { class: "s-login-tab", ref: tab => this.homeTab = tab }, index.h("p", { class: "s-login-sub-title" }, this.loginTypeTitle), index.h("a", { href: "#", class: "s-login-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, index.h("i", { class: "s-login-main-btn-icon sicon-phone" }), index.h("span", { class: "s-login-main-btn-text" }, this.smsLabel), index.h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), index.h("a", { href: "#", class: "s-login-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, index.h("i", { class: "s-login-main-btn-icon sicon-mail" }), index.h("span", { class: "s-login-main-btn-text" }, this.emailLabel), index.h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })))
156
- : '', index.h("div", { class: "s-login-tab", ref: tab => this.mobileTab = tab }, index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, this.enterText), this.isEmailAllowed ?
157
- index.h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-link" }, this.byEmailText) : ''), this.isEmailAllowed ?
158
- index.h("div", { class: "s-login-tab", ref: tab => this.emailTab = tab }, index.h("label", { class: "s-login-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-input s-ltr" }), index.h("span", { class: "s-login-error-message" }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, this.enterText), index.h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-link" }, this.bySMSText)) : '', index.h("salla-verify", { "without-modal": true, ref: tab => this.verifyTab = tab, autoReload: false, "is-show-back": true }), index.h("div", { ref: tab => this.registrationTab = tab }, index.h("label", { class: "s-login-label" }, this.firstNameLabel), index.h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), index.h("span", { class: "s-login-error-message" }), index.h("label", { class: "s-login-label" }, this.lastNameLabel), index.h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), index.h("span", { class: "s-login-error-message" }), index.h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), index.h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-input s-ltr" }), index.h("span", { class: "s-login-error-message" })), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register'))))));
177
+ : '', this.isMobileAllowed ?
178
+ index.h("div", { class: "s-login-tab", ref: tab => this.mobileTab = tab }, index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, this.enterText), this.isEmailAllowed ?
179
+ index.h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-link" }, this.byEmailText) : '') : '', this.isEmailAllowed ?
180
+ index.h("div", { class: "s-login-tab", ref: tab => this.emailTab = tab }, index.h("label", { class: "s-login-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-input s-ltr" }), index.h("span", { class: "s-login-error-message" }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, this.enterText), this.isMobileAllowed ?
181
+ index.h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-link" }, this.bySMSText) : '') : '', index.h("salla-verify", { "without-modal": true, ref: tab => this.verifyTab = tab, autoReload: false, "is-show-back": true }), index.h("div", { ref: tab => this.registrationTab = tab }, index.h("label", { class: "s-login-label" }, this.firstNameLabel), index.h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), index.h("span", { class: "s-login-error-message" }), index.h("label", { class: "s-login-label" }, this.lastNameLabel), index.h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), index.h("span", { class: "s-login-error-message" }), index.h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), index.h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-input s-ltr" }), index.h("span", { class: "s-login-error-message" })), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register'))))));
159
182
  }
160
183
  get host() { return index.getElement(this); }
161
184
  };
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["salla-button_5.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"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"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"isShowBack":[4,"is-show-back"],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"invalidNumber":[32],"invalidCountryCode":[32],"tooShort":[32],"tooLong":[32],"mobileLabel":[32],"countryCodeLabel":[32],"mobileRequired":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subscribeText":[32],"cancelText":[32],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"buttonText":[32],"emailErrorMsg":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"ok":[32],"show":[64],"hide":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[32],"currenciesTitle":[32],"ok":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
18
+ return index.bootstrapLazy([["salla-button_5.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"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"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"isShowBack":[4,"is-show-back"],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[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]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"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],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subscribeText":[32],"cancelText":[32],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"buttonText":[32],"emailErrorMsg":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"ok":[32],"show":[64],"hide":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[32],"currenciesTitle":[32],"ok":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
19
19
  });
@@ -4,6 +4,7 @@
4
4
  "./components/salla-search/salla-search.js",
5
5
  "./components/salla-branches/salla-branches.js",
6
6
  "./components/salla-button/salla-button.js",
7
+ "./components/salla-infinite-scroll/salla-infinite-scroll.js",
7
8
  "./components/salla-localization/salla-localization.js",
8
9
  "./components/salla-modal/salla-modal.js",
9
10
  "./components/salla-offer/salla-offer.js",
@@ -0,0 +1,149 @@
1
+ import { Component, Element, h, Host, Prop, State } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ /**
4
+ */
5
+ export class SallaInfiniteScroll {
6
+ constructor() {
7
+ /**
8
+ * Next Page element
9
+ */
10
+ this.nextPage = '';
11
+ this.autoload = false;
12
+ /**
13
+ * Class selector to know the container if it's not the host `<salla-infinite-scroll>`
14
+ */
15
+ this.container = '.s-infinite-scroll-container';
16
+ /**
17
+ * Class selector to know list items
18
+ */
19
+ this.item = '.list-block';
20
+ Helper.setHost(this.host);
21
+ this.status = document.createElement('div');
22
+ this.status.className = 's-infinite-scroll-wrapper';
23
+ this.status.innerHTML = `<div class="s-infinite-scroll-status" style="display:none">
24
+ <p class="s-infinite-scroll-last infinite-scroll-last"></p>
25
+ <p class="s-infinite-scroll-error infinite-scroll-error"></p>
26
+ </div>
27
+ <a href="${this.nextPage}" class="s-button-btn btn--has-loading s-button-primary">
28
+ <span class="s-button-text"></span>
29
+ <span class="s-button-loader s-button-loader-start" style="display: none"></span>
30
+ </a>`;
31
+ this.btnLoader = this.status.querySelector('.s-button-loader');
32
+ salla.event.on('languages::translations.loaded', () => {
33
+ this.status.querySelector('.s-button-text').innerHTML = salla.lang.get('common.elements.load_more');
34
+ this.status.querySelector('.s-infinite-scroll-last').innerHTML = salla.lang.get('common.elements.end_of_content');
35
+ this.status.querySelector('.s-infinite-scroll-error').innerHTML = salla.lang.get('common.elements.failed_to_load_more');
36
+ });
37
+ }
38
+ loading(isLoading = true) {
39
+ this.btnLoader.style.display = isLoading ? 'inline-block' : 'none';
40
+ }
41
+ render() {
42
+ return this.nextPage.length > 1 ?
43
+ h(Host, { class: "s-infinite-scroll-container" },
44
+ h("slot", null)) : '';
45
+ }
46
+ componentDidLoad() {
47
+ if (this.nextPage.length === 0) {
48
+ return;
49
+ }
50
+ this.host.insertAdjacentElement('afterend', this.status);
51
+ let that = this;
52
+ salla.infiniteScroll.initiate(this.container, {
53
+ history: this.autoload ? 'push' : false,
54
+ scrollThreshold: this.autoload ? 400 : false,
55
+ nextPage: this.nextPage,
56
+ checkLastPage: 'salla-infinite-scroll[next-page*=":"]',
57
+ status: '.s-infinite-scroll-status',
58
+ button: this.status.querySelector('.s-button-btn'),
59
+ append: this.item,
60
+ path: function () {
61
+ return that.nextPage.replace(/page\=(\d)/g, 'page=' + (this.loadCount + 2));
62
+ },
63
+ })
64
+ .on('request', () => this.loading())
65
+ .on('load', () => this.loading(false))
66
+ .on('error', () => this.loading(false));
67
+ }
68
+ static get is() { return "salla-infinite-scroll"; }
69
+ static get properties() { return {
70
+ "nextPage": {
71
+ "type": "string",
72
+ "mutable": false,
73
+ "complexType": {
74
+ "original": "string",
75
+ "resolved": "string",
76
+ "references": {}
77
+ },
78
+ "required": false,
79
+ "optional": false,
80
+ "docs": {
81
+ "tags": [],
82
+ "text": "Next Page element"
83
+ },
84
+ "attribute": "next-page",
85
+ "reflect": false,
86
+ "defaultValue": "''"
87
+ },
88
+ "autoload": {
89
+ "type": "boolean",
90
+ "mutable": false,
91
+ "complexType": {
92
+ "original": "boolean",
93
+ "resolved": "boolean",
94
+ "references": {}
95
+ },
96
+ "required": false,
97
+ "optional": false,
98
+ "docs": {
99
+ "tags": [],
100
+ "text": ""
101
+ },
102
+ "attribute": "autoload",
103
+ "reflect": false,
104
+ "defaultValue": "false"
105
+ },
106
+ "container": {
107
+ "type": "string",
108
+ "mutable": false,
109
+ "complexType": {
110
+ "original": "string",
111
+ "resolved": "string",
112
+ "references": {}
113
+ },
114
+ "required": false,
115
+ "optional": false,
116
+ "docs": {
117
+ "tags": [],
118
+ "text": "Class selector to know the container if it's not the host `<salla-infinite-scroll>`"
119
+ },
120
+ "attribute": "container",
121
+ "reflect": false,
122
+ "defaultValue": "'.s-infinite-scroll-container'"
123
+ },
124
+ "item": {
125
+ "type": "string",
126
+ "mutable": false,
127
+ "complexType": {
128
+ "original": "string",
129
+ "resolved": "string",
130
+ "references": {}
131
+ },
132
+ "required": false,
133
+ "optional": false,
134
+ "docs": {
135
+ "tags": [],
136
+ "text": "Class selector to know list items"
137
+ },
138
+ "attribute": "item",
139
+ "reflect": false,
140
+ "defaultValue": "'.list-block'"
141
+ }
142
+ }; }
143
+ static get states() { return {
144
+ "loadMore": {},
145
+ "noMore": {},
146
+ "failedToLoad": {}
147
+ }; }
148
+ static get elementRef() { return "host"; }
149
+ }