@salla.sa/twilight-components 1.0.26 → 1.0.28

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 (47) hide show
  1. package/dist/cjs/index.cjs.js +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-button_5.cjs.entry.js +15 -5
  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/salla-product-availability.cjs.entry.js +11 -11
  7. package/dist/cjs/{salla-search-eb0112c0.js → salla-search-7d0fe40b.js} +1 -0
  8. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  9. package/dist/cjs/twilight-components.cjs.js +1 -1
  10. package/dist/collection/collection-manifest.json +1 -0
  11. package/dist/collection/components/salla-button/salla-button.js +26 -0
  12. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +149 -0
  13. package/dist/collection/components/salla-login/salla-login.js +78 -22
  14. package/dist/collection/components/salla-modal/salla-modal.js +20 -1
  15. package/dist/collection/components/salla-product-availability/salla-product-availability.js +13 -16
  16. package/dist/collection/components/salla-search/salla-search.js +1 -0
  17. package/dist/collection/components/salla-tel-input/salla-tel-input.js +13 -8
  18. package/dist/esm/index.js +2 -2
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/salla-button_5.entry.js +15 -5
  21. package/dist/esm/salla-infinite-scroll.entry.js +70 -0
  22. package/dist/esm/{salla-login-fcb7ad15.js → salla-login-e6e86a3d.js} +39 -16
  23. package/dist/esm/salla-product-availability.entry.js +11 -11
  24. package/dist/esm/{salla-search-57bd45eb.js → salla-search-66aae389.js} +1 -0
  25. package/dist/esm/salla-search.entry.js +1 -1
  26. package/dist/esm/twilight-components.js +1 -1
  27. package/dist/twilight-components/index.esm.js +1 -1
  28. package/dist/twilight-components/p-079df88b.js +1 -0
  29. package/dist/twilight-components/p-54f90d2b.entry.js +1 -0
  30. package/dist/twilight-components/p-562fd1e3.entry.js +1 -0
  31. package/dist/twilight-components/p-8305cef7.entry.js +1 -0
  32. package/dist/twilight-components/p-c479a524.entry.js +1 -0
  33. package/dist/twilight-components/p-f97ea1f7.js +1 -0
  34. package/dist/twilight-components/twilight-components.esm.js +1 -1
  35. package/dist/types/components/salla-button/salla-button.d.ts +1 -0
  36. package/dist/types/components/salla-infinite-scroll/salla-infinite-scroll.d.ts +27 -0
  37. package/dist/types/components/salla-login/salla-login.d.ts +2 -0
  38. package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
  39. package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +2 -3
  40. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +6 -6
  41. package/dist/types/components.d.ts +46 -0
  42. package/package.json +1 -1
  43. package/dist/twilight-components/p-13855688.js +0 -1
  44. package/dist/twilight-components/p-47f3d098.entry.js +0 -1
  45. package/dist/twilight-components/p-6d5f0951.entry.js +0 -1
  46. package/dist/twilight-components/p-8cce4c31.entry.js +0 -1
  47. package/dist/twilight-components/p-e7edc889.js +0 -1
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaLogin = require('./salla-login-bf0972bf.js');
6
- const sallaSearch = require('./salla-search-eb0112c0.js');
5
+ const sallaLogin = require('./salla-login-15aff630.js');
6
+ const sallaSearch = require('./salla-search-7d0fe40b.js');
7
7
  require('./index-714023c8.js');
8
8
  require('./Helper-fcea994c.js');
9
9
 
@@ -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],"setText":[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"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[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
 
@@ -39,6 +39,10 @@ const SallaButton = class {
39
39
  this.host.setAttribute('loading', '');
40
40
  return this.host;
41
41
  }
42
+ async setText(html) {
43
+ this.text.innerHTML = html;
44
+ return this.host;
45
+ }
42
46
  async stop() {
43
47
  this.host.removeAttribute('loading');
44
48
  if (this.loaderPosition == 'center')
@@ -97,6 +101,7 @@ const SallaModal = class {
97
101
  this.visible = false;
98
102
  this.isLoading = false;
99
103
  this.subTitleFirst = false;
104
+ this.noPadding = false;
100
105
  this.subTitle = '';
101
106
  this.icon = '';
102
107
  this.imageIcon = '';
@@ -159,7 +164,7 @@ const SallaModal = class {
159
164
  this.host.id = this.host.id || 'salla-modal';
160
165
  return (
161
166
  //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
167
+ 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
168
  ? index.h("div", { class: "s-modal-loader-wrap" }, index.h("span", { class: "s-modal-loader" }))
164
169
  :
165
170
  [index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
@@ -1571,6 +1576,13 @@ const SallaTelInput = class {
1571
1576
  this.enterClicked = index.createEvent(this, "enterClicked", 7);
1572
1577
  this.countryCode = "SA";
1573
1578
  this.countryKey = "+966";
1579
+ this.countryCodeLabel = salla.lang.get('common.country_code');
1580
+ this.mobileLabel = salla.lang.get('common.elements.mobile');
1581
+ this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
1582
+ this.tooLong = salla.lang.get('common.errors.too_long', { attribute: this.mobileLabel });
1583
+ this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.countryCodeLabel });
1584
+ this.invalidNumber = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
1585
+ this.errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
1574
1586
  Helper.Helper.setHost(this.host);
1575
1587
  salla.event.on('languages::translations.loaded', () => {
1576
1588
  this.mobileLabel = salla.lang.get('common.elements.mobile');
@@ -1625,9 +1637,7 @@ const SallaTelInput = class {
1625
1637
  this.isValid();
1626
1638
  });
1627
1639
  // on keyup / change flag: reset
1628
- this.phoneInput.addEventListener('keyup', e => {
1629
- if (e.key == 'Enter')
1630
- return;
1640
+ this.phoneInput.addEventListener('input', e => {
1631
1641
  salla.helpers.digitsOnly(e.target);
1632
1642
  this.reset();
1633
1643
  });
@@ -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
  };
@@ -9,7 +9,7 @@ const SallaProductAvailability = class {
9
9
  constructor(hostRef) {
10
10
  index.registerInstance(this, hostRef);
11
11
  this.isUser = Helper.Helper.isUser();
12
- this.productId = salla.get('page.id');
12
+ this.productId = salla.config.get('page.id');
13
13
  this.isSubscribed = false;
14
14
  // @Method()
15
15
  this.submit = async () => {
@@ -20,7 +20,7 @@ const SallaProductAvailability = class {
20
20
  let { mobile, countryCode } = await this.mobileInput.getValues(), data = { id: this.productId, country_code: countryCode };
21
21
  mobile !== '' && (data['mobile'] = mobile);
22
22
  this.email.value !== '' && (data['email'] = this.email.value);
23
- await this.validateform({ mobile: mobile, email: this.email.value });
23
+ await this.validateform();
24
24
  return this.btn.load()
25
25
  .then(() => this.btn.disable())
26
26
  .then(() => salla.api.product.availabilitySubscribe(data))
@@ -43,31 +43,31 @@ const SallaProductAvailability = class {
43
43
  this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
44
44
  this.host.removeAttribute('title');
45
45
  salla.event.on('languages::translations.loaded', () => {
46
- var _a;
46
+ var _a, _b, _c, _d;
47
47
  this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
48
- this.subscribeText = salla.lang.get('common.elements.submit');
49
- this.cancelText = salla.lang.get('common.elements.cancel');
50
48
  this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
51
49
  this.mobileLabel = salla.lang.get('common.elements.mobile');
52
50
  this.emailLabel = salla.lang.get('common.elements.email');
53
51
  this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
54
52
  this.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
55
- this.buttonText = salla.lang.get('pages.products.notify_availability');
56
53
  this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
57
54
  (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title_);
55
+ (_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('common.elements.submit'));
56
+ (_c = this.cancelBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('common.elements.cancel'));
57
+ (_d = this.inlineBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('pages.products.notify_availability'));
58
58
  });
59
59
  }
60
60
  channelsWatcher(newValue) {
61
61
  this.channels_ = newValue.split(',');
62
62
  }
63
- async validateform(data) {
64
- if (this.channels_.includes('email') && !data.mobile) {
63
+ async validateform() {
64
+ if (this.channels_.includes('email')) {
65
65
  const isEmailValid = Helper.Helper.isValidEmail(this.email.value);
66
66
  if (isEmailValid)
67
67
  return;
68
68
  !isEmailValid && this.validateField(this.email, this.emailErrorMsg);
69
69
  }
70
- if (this.channels_.includes('sms') && !data.email) {
70
+ if (this.channels_.includes('sms')) {
71
71
  const isPhoneValid = await this.mobileInput.isValid();
72
72
  if (isPhoneValid)
73
73
  return;
@@ -81,7 +81,7 @@ const SallaProductAvailability = class {
81
81
  render() {
82
82
  return (index.h(index.Host, null, this.isSubscribed
83
83
  ? index.h("div", { class: "s-product-availability-subscribed" }, index.h("i", { class: "sicon-bell-ring s-product-availability-subs-icon" }), " ", this.subscribedMessage)
84
- : index.h("slot", null, index.h("salla-button", { wide: true, onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser || this.isSubscribed ? '' : this.renderModal()));
84
+ : index.h("slot", null, index.h("salla-button", { onClick: () => this.isUser ? this.submit() : this.modal.show(), wide: true, ref: btn => this.inlineBtn = btn }, salla.lang.get('pages.products.notify_availability'))), this.isUser || this.isSubscribed ? '' : this.renderModal()));
85
85
  }
86
86
  renderModal() {
87
87
  return (index.h("salla-modal", { ref: modal => this.modal = modal, title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", width: "sm" }, index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
@@ -91,7 +91,7 @@ const SallaProductAvailability = class {
91
91
  ] : '', this.channels_.includes('sms') ? [
92
92
  index.h("label", { class: "s-product-availability-label" }, this.mobileLabel),
93
93
  index.h("salla-tel-input", { ref: el => this.mobileInput = el, onKeyDown: e => this.typing(e, this.submit) })
94
- ] : ''), index.h("div", { slot: "footer", class: "s-product-availability-footer" }, index.h("salla-button", { wide: true, "btn-style": "outline", onClick: () => this.modal.hide() }, this.cancelText), index.h("salla-button", { "loader-position": 'center', wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.subscribeText))));
94
+ ] : ''), index.h("div", { slot: "footer", class: "s-product-availability-footer" }, index.h("salla-button", { wide: true, "btn-style": "outline", onClick: () => this.modal.hide(), ref: btn => this.cancelBtn = btn }, salla.lang.get('common.elements.cancel')), index.h("salla-button", { "loader-position": 'center', wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.submit')))));
95
95
  }
96
96
  get host() { return index.getElement(this); }
97
97
  static get watchers() { return {
@@ -11,6 +11,7 @@ const SallaSearch = class {
11
11
  var _a;
12
12
  Helper.Helper.setHost(this.host);
13
13
  this.productSlot = ((_a = Helper.Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
14
+ salla.event.on('search::show', () => this.modal.show());
14
15
  salla.event.on('languages::translations.loaded', () => {
15
16
  this.placeholder = salla.lang.get('blocks.header.search_placeholder');
16
17
  this.noResultsText = salla.lang.get('common.elements.no_options');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaSearch = require('./salla-search-eb0112c0.js');
5
+ const sallaSearch = require('./salla-search-7d0fe40b.js');
6
6
  require('./index-714023c8.js');
7
7
  require('./Helper-fcea994c.js');
8
8
 
@@ -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],"setText":[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"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[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",
@@ -30,6 +30,10 @@ export class SallaButton {
30
30
  this.host.setAttribute('loading', '');
31
31
  return this.host;
32
32
  }
33
+ async setText(html) {
34
+ this.text.innerHTML = html;
35
+ return this.host;
36
+ }
33
37
  async stop() {
34
38
  this.host.removeAttribute('loading');
35
39
  if (this.loaderPosition == 'center')
@@ -185,6 +189,28 @@ export class SallaButton {
185
189
  "tags": []
186
190
  }
187
191
  },
192
+ "setText": {
193
+ "complexType": {
194
+ "signature": "(html: string) => Promise<HTMLElement>",
195
+ "parameters": [{
196
+ "tags": [],
197
+ "text": ""
198
+ }],
199
+ "references": {
200
+ "Promise": {
201
+ "location": "global"
202
+ },
203
+ "HTMLElement": {
204
+ "location": "global"
205
+ }
206
+ },
207
+ "return": "Promise<HTMLElement>"
208
+ },
209
+ "docs": {
210
+ "text": "",
211
+ "tags": []
212
+ }
213
+ },
188
214
  "stop": {
189
215
  "complexType": {
190
216
  "signature": "() => Promise<HTMLElement>",
@@ -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
+ }