@salla.sa/twilight-components 1.0.25 → 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.
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-button_5.cjs.entry.js +76 -62
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +74 -0
- package/dist/cjs/{salla-login-784855c5.js → salla-login-15aff630.js} +56 -29
- package/dist/cjs/salla-product-availability.cjs.entry.js +61 -34
- package/dist/cjs/salla-rating.cjs.entry.js +3 -3
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +149 -0
- package/dist/collection/components/salla-login/salla-login.js +101 -41
- package/dist/collection/components/salla-modal/salla-modal.js +20 -1
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +78 -234
- package/dist/collection/components/salla-rating/salla-rating.js +3 -3
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +49 -42
- package/dist/collection/components/salla-verify/salla-verify.js +38 -27
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-button_5.entry.js +76 -62
- package/dist/esm/salla-infinite-scroll.entry.js +70 -0
- package/dist/esm/{salla-login-cd1ce308.js → salla-login-e6e86a3d.js} +56 -29
- package/dist/esm/salla-product-availability.entry.js +61 -34
- package/dist/esm/salla-rating.entry.js +3 -3
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-8cce4c31.entry.js +1 -0
- package/dist/twilight-components/p-932906dc.entry.js +1 -0
- package/dist/twilight-components/p-b4e1d032.entry.js +1 -0
- package/dist/twilight-components/p-c479a524.entry.js +1 -0
- package/dist/twilight-components/p-f97ea1f7.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-infinite-scroll/salla-infinite-scroll.d.ts +27 -0
- package/dist/types/components/salla-login/salla-login.d.ts +5 -3
- package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +10 -8
- package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +8 -6
- package/dist/types/components/salla-verify/salla-verify.d.ts +2 -1
- package/dist/types/components.d.ts +48 -24
- package/package.json +1 -1
- package/dist/twilight-components/p-0dbace0e.entry.js +0 -1
- package/dist/twilight-components/p-22f06d26.entry.js +0 -1
- package/dist/twilight-components/p-7fe5d346.entry.js +0 -1
- package/dist/twilight-components/p-d3dc2ffe.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const sallaLogin = require('./salla-login-
|
|
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');
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -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],"
|
|
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-
|
|
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,24 +1572,32 @@ 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');
|
|
1585
|
+
this.countryCodeLabel = salla.lang.get('common.country_code');
|
|
1577
1586
|
this.invalidNumber = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
|
|
1578
|
-
this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.
|
|
1587
|
+
this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.countryCodeLabel });
|
|
1579
1588
|
this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
|
|
1580
1589
|
this.tooLong = salla.lang.get('common.errors.too_long', { attribute: this.mobileLabel });
|
|
1581
1590
|
this.mobileRequired = salla.lang.get('common.errors.field_required', { attribute: this.mobileLabel });
|
|
1591
|
+
this.errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
|
|
1582
1592
|
});
|
|
1583
1593
|
}
|
|
1584
1594
|
async getValues() {
|
|
1585
|
-
this.
|
|
1595
|
+
this.mobile = this.phoneInput.value;
|
|
1586
1596
|
this.countryCode = this.countryCodeInput.value;
|
|
1587
1597
|
this.countryKey = this.countryKeyInput.value;
|
|
1588
|
-
return {
|
|
1598
|
+
return { mobile: this.phoneInput.value, countryCode: this.countryCodeInput.value, countryKey: this.countryKeyInput.value };
|
|
1589
1599
|
}
|
|
1590
1600
|
async isValid() {
|
|
1591
|
-
const errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
|
|
1592
1601
|
this.reset();
|
|
1593
1602
|
if (this.iti.isValidNumber())
|
|
1594
1603
|
return true;
|
|
@@ -1599,40 +1608,37 @@ const SallaTelInput = class {
|
|
|
1599
1608
|
}
|
|
1600
1609
|
this.phoneInput.classList.add("s-has-error");
|
|
1601
1610
|
let errorCode = this.iti.getValidationError();
|
|
1602
|
-
this.errorMsg.innerText = errorMap[errorCode] || '';
|
|
1611
|
+
this.errorMsg.innerText = this.errorMap[errorCode] || '';
|
|
1603
1612
|
return false;
|
|
1604
1613
|
}
|
|
1605
1614
|
initTelInput() {
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
this.
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
input.value = ('+' + data.dialCode).replace('++', '+');
|
|
1621
|
-
});
|
|
1622
|
-
});
|
|
1623
|
-
// on blur: validate
|
|
1624
|
-
intlInput.addEventListener('blur', () => {
|
|
1625
|
-
this.isValid();
|
|
1626
|
-
});
|
|
1627
|
-
// on keyup / change flag: reset
|
|
1628
|
-
// this.phoneInput.addEventListener('change', () => this.reset());
|
|
1629
|
-
salla.document.event.onKeyup('.tel-input', e => {
|
|
1630
|
-
if (e.key == 'Enter')
|
|
1631
|
-
return;
|
|
1632
|
-
salla.helpers.digitsOnly(e.target);
|
|
1633
|
-
this.reset();
|
|
1615
|
+
salla.helpers.digitsOnly(this.phoneInput);
|
|
1616
|
+
this.iti = intlTelInput(this.phoneInput, {
|
|
1617
|
+
initialCountry: this.countryCode || 'sa',
|
|
1618
|
+
preferredCountries: ['sa', 'ae', 'kw', 'bh', 'qa', 'iq', 'om', 'ye', 'eg', 'jo', 'sy', 'ps', 'sd', 'lb', 'dz', 'tn', 'ma', 'ly'],
|
|
1619
|
+
formatOnDisplay: false,
|
|
1620
|
+
separateDialCode: true,
|
|
1621
|
+
autoPlaceholder: 'aggressive',
|
|
1622
|
+
utilsScript: 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.min.js',
|
|
1623
|
+
});
|
|
1624
|
+
this.phoneInput.addEventListener("countrychange", () => {
|
|
1625
|
+
let data = this.iti.getSelectedCountryData();
|
|
1626
|
+
this.host.querySelectorAll('.country_code').forEach((input) => input.value = data.iso2.toUpperCase());
|
|
1627
|
+
this.host.querySelectorAll('.country_key').forEach((input) => {
|
|
1628
|
+
input.value = ('+' + data.dialCode).replace('++', '+');
|
|
1634
1629
|
});
|
|
1635
1630
|
});
|
|
1631
|
+
// on blur: validate
|
|
1632
|
+
this.phoneInput.addEventListener('blur', () => {
|
|
1633
|
+
this.isValid();
|
|
1634
|
+
});
|
|
1635
|
+
// on keyup / change flag: reset
|
|
1636
|
+
this.phoneInput.addEventListener('keyup', e => {
|
|
1637
|
+
if (e.key == 'Enter')
|
|
1638
|
+
return;
|
|
1639
|
+
salla.helpers.digitsOnly(e.target);
|
|
1640
|
+
this.reset();
|
|
1641
|
+
});
|
|
1636
1642
|
}
|
|
1637
1643
|
reset() {
|
|
1638
1644
|
this.phoneInput.classList.remove("s-has-error");
|
|
@@ -1640,7 +1646,7 @@ const SallaTelInput = class {
|
|
|
1640
1646
|
}
|
|
1641
1647
|
;
|
|
1642
1648
|
render() {
|
|
1643
|
-
return (index.h(index.Host, null, index.h("input", { type: "tel", name: "mobile",
|
|
1649
|
+
return (index.h(index.Host, null, index.h("input", { type: "tel", name: "mobile", value: this.mobile, ref: el => this.phoneInput = el, class: "s-tel-input-control tel-input s-ltr" }), index.h("span", { class: "s-tel-input-error-msg", ref: el => this.errorMsg = el }), index.h("input", { type: "hidden", name: "country_code", value: this.countryCode, ref: el => this.countryCodeInput = el, class: "country_code" }), index.h("input", { type: "hidden", name: "country_key", value: this.countryKey, ref: el => this.countryKeyInput = el, class: "country_key" })));
|
|
1644
1650
|
}
|
|
1645
1651
|
componentDidLoad() {
|
|
1646
1652
|
this.initTelInput();
|
|
@@ -1655,6 +1661,7 @@ const SallaVerify = class {
|
|
|
1655
1661
|
this.backClicked = index.createEvent(this, "backClicked", 7);
|
|
1656
1662
|
this.by = 'sms';
|
|
1657
1663
|
this.autoReload = true;
|
|
1664
|
+
this.initiated = false;
|
|
1658
1665
|
Helper.Helper.setHost(this.host);
|
|
1659
1666
|
if (this.withoutModal) {
|
|
1660
1667
|
this.modal = { show: () => '', hide: () => '' };
|
|
@@ -1665,38 +1672,45 @@ const SallaVerify = class {
|
|
|
1665
1672
|
this.show(data);
|
|
1666
1673
|
});
|
|
1667
1674
|
}
|
|
1675
|
+
salla.event.on('languages::translations.loaded', () => {
|
|
1676
|
+
this.title = salla.lang.get('pages.profile.verify_title');
|
|
1677
|
+
});
|
|
1668
1678
|
}
|
|
1669
1679
|
async getCode() {
|
|
1670
1680
|
return this.code.value;
|
|
1671
1681
|
}
|
|
1672
|
-
componentDidLoad() {
|
|
1673
|
-
Helper.Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
|
|
1674
|
-
Helper.Helper.onKeyUp('.s-verify-input', event => {
|
|
1675
|
-
var _a, _b, _c, _d;
|
|
1676
|
-
let key = event.keyCode || event.charCode;
|
|
1677
|
-
if (event.target.value) {
|
|
1678
|
-
(_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1679
|
-
(_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
|
|
1680
|
-
}
|
|
1681
|
-
else if ([8, 46].includes(key)) {
|
|
1682
|
-
(_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
|
|
1683
|
-
(_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
|
|
1684
|
-
}
|
|
1685
|
-
this.toggleOTPSubmit();
|
|
1686
|
-
});
|
|
1687
|
-
Helper.Helper.on('paste', '.s-verify-input', event => {
|
|
1688
|
-
let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
|
|
1689
|
-
this.otpInputs.forEach((input, i) => input.value = text[i] || '');
|
|
1690
|
-
this.toggleOTPSubmit();
|
|
1691
|
-
setTimeout(() => this.otpInputs[3].focus(), 100);
|
|
1692
|
-
});
|
|
1693
|
-
return this.modal.show();
|
|
1694
|
-
}
|
|
1695
1682
|
async show(data) {
|
|
1683
|
+
var _a;
|
|
1696
1684
|
this.data = data;
|
|
1697
1685
|
this.resendTimer();
|
|
1698
|
-
this.otpInputs =
|
|
1686
|
+
this.otpInputs = this.host.querySelectorAll('.s-verify-input');
|
|
1687
|
+
if (!this.initiated) {
|
|
1688
|
+
Helper.Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
|
|
1689
|
+
Helper.Helper.onKeyUp('.s-verify-input', event => {
|
|
1690
|
+
var _a, _b, _c, _d;
|
|
1691
|
+
let key = event.keyCode || event.charCode;
|
|
1692
|
+
if (event.target.value) {
|
|
1693
|
+
(_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1694
|
+
(_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
|
|
1695
|
+
}
|
|
1696
|
+
else if ([8, 46].includes(key)) {
|
|
1697
|
+
(_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
|
|
1698
|
+
(_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
|
|
1699
|
+
}
|
|
1700
|
+
this.toggleOTPSubmit();
|
|
1701
|
+
});
|
|
1702
|
+
Helper.Helper.on('paste', '.s-verify-input', event => {
|
|
1703
|
+
let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
|
|
1704
|
+
this.otpInputs.forEach((input, i) => input.value = text[i] || '');
|
|
1705
|
+
this.toggleOTPSubmit();
|
|
1706
|
+
setTimeout(() => this.otpInputs[3].focus(), 100);
|
|
1707
|
+
});
|
|
1708
|
+
// return this.modal.show();
|
|
1709
|
+
this.initiated = true;
|
|
1710
|
+
}
|
|
1699
1711
|
this.reset();
|
|
1712
|
+
!this.withoutModal && ((_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title));
|
|
1713
|
+
this.modal.show();
|
|
1700
1714
|
}
|
|
1701
1715
|
toggleOTPSubmit() {
|
|
1702
1716
|
let otp = [];
|
|
@@ -1754,7 +1768,7 @@ const SallaVerify = class {
|
|
|
1754
1768
|
}
|
|
1755
1769
|
render() {
|
|
1756
1770
|
return this.withoutModal ? this.myBody() :
|
|
1757
|
-
index.h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title:
|
|
1771
|
+
index.h("salla-modal", { icon: "sicon-android-phone", width: "xs", id: "s-verify", ref: modal => this.modal = modal, title: this.title }, this.myBody());
|
|
1758
1772
|
}
|
|
1759
1773
|
myBody() {
|
|
1760
1774
|
return [
|
|
@@ -1762,7 +1776,7 @@ const SallaVerify = class {
|
|
|
1762
1776
|
// <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
|
|
1763
1777
|
index.h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
1764
1778
|
index.h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => index.h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))),
|
|
1765
|
-
index.h("div", { slot: "footer", class: "s-verify-footer" }, index.h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')), this.isShowBack ?
|
|
1779
|
+
index.h("div", { slot: "footer", class: "s-verify-footer" }, index.h("salla-button", { class: "s-verify-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')), this.isShowBack ?
|
|
1766
1780
|
index.h("a", { href: "#", class: "s-verify-back", onClick: () => this.backClicked.emit() }, index.h("i", { class: "sicon-arrow-right" }))
|
|
1767
1781
|
: '')
|
|
1768
1782
|
];
|
|
@@ -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');
|
|
@@ -17,21 +30,21 @@ const SallaLogin = class {
|
|
|
17
30
|
e.key == 'Enter' && submitMethod();
|
|
18
31
|
};
|
|
19
32
|
this.loginBySMS = async () => {
|
|
20
|
-
const {
|
|
33
|
+
const { mobile, countryCode } = await this.loginTelInput.getValues();
|
|
21
34
|
const isPhoneValid = await this.loginTelInput.isValid();
|
|
22
35
|
if (!isPhoneValid)
|
|
23
36
|
return;
|
|
24
37
|
this.smsBtn.load()
|
|
25
38
|
.then(() => this.smsBtn.disable())
|
|
26
|
-
.then(() => salla.auth.api.login({ type: 'mobile', phone:
|
|
39
|
+
.then(() => salla.auth.api.login({ type: 'mobile', phone: mobile, country_code: countryCode }))
|
|
27
40
|
.then(() => this.smsBtn.stop() && this.smsBtn.enable())
|
|
28
41
|
.then(() => this.showTab(this.verifyTab))
|
|
29
|
-
.then(() => this.verifyTab.by = 'sms')
|
|
30
|
-
.then(() => this.verifyTab.show({ phone:
|
|
42
|
+
.then(() => (this.verifyTab.by = 'sms') && (this.verifyTab.url = 'auth/mobile/verify'))
|
|
43
|
+
.then(() => this.verifyTab.show({ phone: mobile, country_code: countryCode }));
|
|
31
44
|
};
|
|
32
45
|
this.loginByEmail = () => {
|
|
33
46
|
if (!Helper.Helper.isValidEmail(this.loginEmail.value)) {
|
|
34
|
-
this.validateField(this.loginEmail, this.
|
|
47
|
+
this.validateField(this.loginEmail, this.emailErrorMsg);
|
|
35
48
|
return;
|
|
36
49
|
}
|
|
37
50
|
this.emailBtn.load()
|
|
@@ -43,27 +56,30 @@ const SallaLogin = class {
|
|
|
43
56
|
.then(() => this.verifyTab.show({ email: this.loginEmail.value }));
|
|
44
57
|
};
|
|
45
58
|
this.newUser = async () => {
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
phone: regPhone || this.loginTelInput.
|
|
55
|
-
email: this.regEmail.value || this.loginEmail.value,
|
|
67
|
+
phone: regPhone || this.loginTelInput.mobile,
|
|
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
|
};
|
|
64
78
|
this.title = this.host.title || salla.lang.get('blocks.header.login');
|
|
65
79
|
this.host.removeAttribute('title');
|
|
66
80
|
salla.event.on('languages::translations.loaded', () => {
|
|
81
|
+
var _a;
|
|
82
|
+
this.title = salla.lang.get('blocks.header.login');
|
|
67
83
|
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
68
84
|
this.loginText = salla.lang.get('blocks.header.login');
|
|
69
85
|
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
@@ -72,12 +88,12 @@ const SallaLogin = class {
|
|
|
72
88
|
this.enterText = salla.lang.get('blocks.header.enter');
|
|
73
89
|
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
74
90
|
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
75
|
-
this.
|
|
76
|
-
this.isEmailValid = salla.lang.get('common.elements.email_is_valid');
|
|
91
|
+
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
77
92
|
this.firstNameLabel = salla.lang.get('blocks.header.your_name');
|
|
78
93
|
this.lastNameLabel = salla.lang.get('pages.profile.last_name');
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
94
|
+
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
95
|
+
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
96
|
+
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
|
|
81
97
|
});
|
|
82
98
|
salla.auth.event.onVerificationFailed(() => {
|
|
83
99
|
//
|
|
@@ -109,10 +125,19 @@ const SallaLogin = class {
|
|
|
109
125
|
this.regType == 'phone' ? this.showTab(this.mobileTab) : this.showTab(this.emailTab);
|
|
110
126
|
}
|
|
111
127
|
async show() {
|
|
112
|
-
|
|
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
|
+
}
|
|
113
137
|
return this.modal.show();
|
|
114
138
|
}
|
|
115
139
|
showTab(tab, evt) {
|
|
140
|
+
var _a, _b;
|
|
116
141
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
117
142
|
[this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab].map(el => Helper.Helper.toggleElement(el, 'visible', 'hidden', () => el == tab));
|
|
118
143
|
setTimeout(() => {
|
|
@@ -125,8 +150,8 @@ const SallaLogin = class {
|
|
|
125
150
|
this.regType = tab === this.mobileTab ? 'phone' : 'email';
|
|
126
151
|
}
|
|
127
152
|
let isRegistrationTab = tab == this.registrationTab;
|
|
128
|
-
isRegistrationTab && this.firstName.focus();
|
|
129
|
-
this.modal.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
|
|
153
|
+
isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
|
|
154
|
+
(_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
|
|
130
155
|
if (!isRegistrationTab) {
|
|
131
156
|
Helper.Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
|
|
132
157
|
.toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
|
|
@@ -134,12 +159,12 @@ const SallaLogin = class {
|
|
|
134
159
|
return this;
|
|
135
160
|
}
|
|
136
161
|
async newUserValidation() {
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
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)
|
|
139
164
|
return;
|
|
140
|
-
!isEmailValid && this.validateField(this.regEmail, this.
|
|
141
|
-
!isFirstNameValid && this.validateField(this.firstName, this.
|
|
142
|
-
!isLastNameValid && this.validateField(this.lastName, this.
|
|
165
|
+
!isEmailValid && this.validateField(this.regEmail, this.emailErrorMsg);
|
|
166
|
+
!isFirstNameValid && this.validateField(this.firstName, this.firstNameErrorMsg);
|
|
167
|
+
!isLastNameValid && this.validateField(this.lastName, this.lastNameErrorMsg);
|
|
143
168
|
throw ('Please insert required fields');
|
|
144
169
|
}
|
|
145
170
|
validateField(field, errorMsg) {
|
|
@@ -147,11 +172,13 @@ const SallaLogin = class {
|
|
|
147
172
|
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
148
173
|
}
|
|
149
174
|
render() {
|
|
150
|
-
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 ?
|
|
151
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" })))
|
|
152
|
-
: '',
|
|
153
|
-
index.h("
|
|
154
|
-
|
|
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'))))));
|
|
155
182
|
}
|
|
156
183
|
get host() { return index.getElement(this); }
|
|
157
184
|
};
|