@salla.sa/twilight-components 1.0.16 → 1.0.17

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 (93) hide show
  1. package/dist/cjs/Helper-8852feaa.js +23 -0
  2. package/dist/cjs/index-0b5b5867.js +1656 -0
  3. package/dist/cjs/index.cjs.js +13 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/salla-branches.cjs.entry.js +92 -0
  6. package/dist/cjs/salla-button_4.cjs.entry.js +299 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +80 -0
  8. package/dist/cjs/salla-login-342876b9.js +118 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +25 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +300 -0
  12. package/dist/cjs/salla-search-28da4616.js +81 -0
  13. package/dist/cjs/salla-search.cjs.entry.js +11 -0
  14. package/dist/cjs/twilight-components.cjs.js +19 -0
  15. package/dist/collection/Helpers/Helper.js +19 -0
  16. package/dist/collection/collection-manifest.json +21 -0
  17. package/dist/collection/components/generate-summary.js +35 -0
  18. package/dist/collection/components/salla-branches/salla-branches.css +12 -0
  19. package/dist/collection/components/salla-branches/salla-branches.js +233 -0
  20. package/dist/collection/components/salla-button/salla-button.css +3 -0
  21. package/dist/collection/components/salla-button/salla-button.js +246 -0
  22. package/dist/collection/components/salla-localization/salla-localization.js +206 -0
  23. package/dist/collection/components/salla-login/salla-login.js +348 -0
  24. package/dist/collection/components/salla-modal/salla-modal.js +459 -0
  25. package/dist/collection/components/salla-offer/salla-offer.js +40 -0
  26. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  27. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  28. package/dist/collection/components/salla-rating/salla-rating.js +483 -0
  29. package/dist/collection/components/salla-search/salla-search.js +132 -0
  30. package/dist/collection/components/salla-verify/salla-verify.js +238 -0
  31. package/dist/collection/index.js +2 -0
  32. package/dist/collection/interfaces/colors.js +1 -0
  33. package/dist/collection/interfaces/index.js +2 -0
  34. package/dist/collection/interfaces/ratio.js +1 -0
  35. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  36. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  37. package/dist/{twilight-components → esm}/Helper-81ac9a8c.js +0 -0
  38. package/dist/esm/index-8b97d225.js +1628 -0
  39. package/dist/esm/index.js +4 -0
  40. package/dist/esm/loader.js +17 -0
  41. package/dist/esm/polyfills/core-js.js +11 -0
  42. package/dist/esm/polyfills/css-shim.js +1 -0
  43. package/dist/esm/polyfills/dom.js +79 -0
  44. package/dist/esm/polyfills/es5-html-element.js +1 -0
  45. package/dist/esm/polyfills/index.js +34 -0
  46. package/dist/esm/polyfills/system.js +6 -0
  47. package/dist/{twilight-components → esm}/salla-branches.entry.js +6 -6
  48. package/dist/esm/salla-button_4.entry.js +292 -0
  49. package/dist/esm/salla-localization.entry.js +76 -0
  50. package/dist/esm/salla-login-32d25ffa.js +116 -0
  51. package/dist/esm/salla-offer.entry.js +21 -0
  52. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +2 -2
  53. package/dist/{twilight-components → esm}/salla-rating.entry.js +73 -70
  54. package/dist/{twilight-components/salla-search-5338c0a1.js → esm/salla-search-f552c487.js} +1 -1
  55. package/dist/esm/salla-search.entry.js +3 -0
  56. package/dist/esm/twilight-components.js +17 -0
  57. package/dist/index.cjs.js +1 -0
  58. package/dist/index.js +1 -0
  59. package/dist/twilight-components/index.esm.js +1 -4
  60. package/dist/twilight-components/p-33990e49.entry.js +1 -0
  61. package/dist/twilight-components/p-36683152.js +1 -0
  62. package/dist/twilight-components/p-3cfede65.entry.js +1 -0
  63. package/dist/twilight-components/p-648661c8.entry.js +1 -0
  64. package/dist/twilight-components/p-93c3ac79.js +1 -0
  65. package/dist/twilight-components/p-9bc28e0c.js +1 -0
  66. package/dist/twilight-components/p-a923a51e.entry.js +1 -0
  67. package/dist/twilight-components/p-bc278b0e.entry.js +1 -0
  68. package/dist/twilight-components/p-cb1c59a2.js +1 -0
  69. package/dist/twilight-components/p-fa04c4b6.entry.js +1 -0
  70. package/dist/twilight-components/p-fa2f0e64.entry.js +1 -0
  71. package/dist/twilight-components/twilight-components.css +1 -3
  72. package/dist/twilight-components/twilight-components.esm.js +1 -125
  73. package/dist/types/components/salla-button/salla-button.d.ts +3 -2
  74. package/dist/types/components/salla-localization/salla-localization.d.ts +8 -0
  75. package/dist/types/components/salla-login/salla-login.d.ts +39 -0
  76. package/dist/types/components/salla-modal/salla-modal.d.ts +12 -4
  77. package/dist/types/components/salla-offer/salla-offer.d.ts +8 -0
  78. package/dist/types/components/salla-rating/salla-rating.d.ts +17 -2
  79. package/dist/types/components/salla-verify/salla-verify.d.ts +16 -6
  80. package/dist/types/components.d.ts +94 -8
  81. package/package.json +2 -1
  82. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  83. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  84. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  85. package/dist/twilight-components/index-8966d27f.js +0 -3010
  86. package/dist/twilight-components/salla-button.entry.js +0 -73
  87. package/dist/twilight-components/salla-localization.entry.js +0 -73
  88. package/dist/twilight-components/salla-login-4d620368.js +0 -12
  89. package/dist/twilight-components/salla-login.entry.js +0 -2
  90. package/dist/twilight-components/salla-modal.entry.js +0 -91
  91. package/dist/twilight-components/salla-search.entry.js +0 -3
  92. package/dist/twilight-components/salla-verify.entry.js +0 -92
  93. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -1,73 +0,0 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
3
-
4
- const sallaButtonCss = ":host{display:block}";
5
-
6
- const SallaButton = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.btnStyle = 'primary'; // outline, outline-primary ,danger
10
- this.loading = false;
11
- this.disabled = false;
12
- this.loaderPosition = 'before';
13
- this.wide = false;
14
- this.hostAttributes = {};
15
- //============= Initiate Button Attributes =============//
16
- for (let i = 0; i < this.host.attributes.length; i++) {
17
- this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
18
- }
19
- this.hostAttributes.type = this.hostAttributes.type || 'button';
20
- this.hostAttributes.class += ' s-button-btn btn--has-loading '
21
- + 'btn-' + this.btnStyle
22
- + (this.wide ? ' s-button-wide ' : '')
23
- + 'loader-' + this.loaderPosition
24
- + (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
25
- // if(this.hostAttributes.onclick){
26
- // this.hostAttributes.onclick=eval(this.hostAttributes.onclick);
27
- // }
28
- delete this.hostAttributes['btn-style'];
29
- delete this.hostAttributes['id'];
30
- if (this.wide) {
31
- this.host.classList.add('s-button-wide');
32
- }
33
- }
34
- async load() {
35
- if (this.loaderPosition == 'center')
36
- this.host.querySelector('.s-button-text').classList.add('s-button-hide');
37
- this.host.setAttribute('loading', '');
38
- return this.host;
39
- }
40
- async stop() {
41
- this.host.removeAttribute('loading');
42
- return this.host;
43
- }
44
- async disable() {
45
- this.host.setAttribute('disabled', '');
46
- }
47
- async enable() {
48
- this.host.removeAttribute('disabled');
49
- }
50
- handleVisible(newKind, oldKind) {
51
- this.btn.classList.remove('btn-' + oldKind);
52
- this.btn.classList.add('btn-' + newKind);
53
- }
54
- handleLoading(newVal) {
55
- Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
56
- }
57
- render() {
58
- return (h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: "s-button-text" }, h("slot", null)), this.loading ? h("span", { class: {
59
- 'loader loader--small s-button-loader': true,
60
- 's-button-loader-start': this.loaderPosition === 'start',
61
- 's-button-loader-end': this.loaderPosition === 'end',
62
- 's-buton-loader-center': this.loaderPosition === 'center',
63
- } }) : ''));
64
- }
65
- get host() { return getElement(this); }
66
- static get watchers() { return {
67
- "btnStyle": ["handleVisible"],
68
- "loading": ["handleLoading"]
69
- }; }
70
- };
71
- SallaButton.style = sallaButtonCss;
72
-
73
- export { SallaButton as salla_button };
@@ -1,73 +0,0 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
3
-
4
- const SallaLocalization = class {
5
- constructor(hostRef) {
6
- registerInstance(this, hostRef);
7
- var _a, _b;
8
- this.language = salla.config.language;
9
- this.currency = salla.config.currency;
10
- //todo::
11
- this.languagesTitle = salla.lang.get('common.titles.language');
12
- this.currenciesTitle = salla.lang.get('common.titles.currency');
13
- this.ok = salla.lang.get('common.elements.ok');
14
- Helper.setHost(this.host);
15
- salla.event.on('localization::show', () => this.show());
16
- /**
17
- * letting developer to insert his own slot like:
18
- * <salla-localization>
19
- * <div slot="language">...{name}....</div>
20
- * <div slot="currency">...{name}....</div>
21
- * </salla-localization>
22
- * Because scoped templates not supported in stencil );
23
- * we made a workaround to pass language & currency attributes, then replace names in rendering
24
- */
25
- this.languageSlot = ((_a = Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-label" for="lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>';
26
- this.currencySlot = ((_b = Helper.getElement('[slot="currency"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>';
27
- }
28
- async show() {
29
- return this.modal.show();
30
- }
31
- async hide() {
32
- return this.modal.hide();
33
- }
34
- async submit() {
35
- let url;
36
- this.btn.load()
37
- .then(() => {
38
- if (this.currency && this.currency.code !== salla.config.currency.code) {
39
- url = window.location.href;
40
- return salla.currency.api.change(this.currency.code);
41
- }
42
- }).then(() => {
43
- if (this.language && this.language.code !== salla.config.language.code) {
44
- url = this.language.url;
45
- }
46
- }).then(() => this.btn.stop())
47
- .then(() => this.hide())
48
- .then(() => url && (window.location.href = url));
49
- }
50
- render() {
51
- return (h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal }, h("slot", { name: "header" }, h("div", { slot: "header" })), h("div", { class: "s-localization-inner" }, salla.config.languages
52
- ? h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.languagesTitle), h("fieldset", { class: "s-localization-fieldset" }, h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", checked: this.language.code == lang.code, onChange: () => this.language = lang, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }), h("div", { id: "language-slot", innerHTML: this.languageSlot
53
- .replace(/\{name\}/g, lang.name)
54
- .replace(/\{code\}/g, lang.code)
55
- .replace(/\{country_code\}/g, lang.country_code) }))))))
56
- : '', salla.config.currencies
57
- ? h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.currenciesTitle), h("fieldset", { class: "s-localization-fieldset" }, h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency.code == currency.code, onChange: () => this.currency = currency, id: 'currency-' + currency.code, value: currency.code }), h("div", { id: "currency-slot", innerHTML: this.currencySlot
58
- .replace(/\{name\}/g, currency.name)
59
- .replace(/\{code\}/g, currency.code)
60
- .replace(/\{country_code\}/g, currency.country_code) }))))))
61
- : ''), h("p", { slot: "footer" }, h("slot", { name: "footer" }, h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.ok)))));
62
- }
63
- /**
64
- * to reduce dom levels we will move slot data into the parent dom
65
- */
66
- componentDidRender() {
67
- this.host.querySelectorAll('#currency-slot').forEach(el => el.replaceWith(el.firstChild));
68
- this.host.querySelectorAll('#language-slot').forEach(el => el.replaceWith(el.firstChild));
69
- }
70
- get host() { return getElement(this); }
71
- };
72
-
73
- export { SallaLocalization as salla_localization };
@@ -1,12 +0,0 @@
1
- import { r as registerInstance, h } from './index-8966d27f.js';
2
-
3
- const SallaLogin = class {
4
- constructor(hostRef) {
5
- registerInstance(this, hostRef);
6
- }
7
- render() {
8
- return (h("salla-modal", { id: "salla-login", title: "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644 \u0625\u0644\u0649 \u0627\u0644\u0645\u0648\u0642\u0639" }, h("div", { id: "showLoginMethods" }, h("p", { class: "text-sm text-gray-text mb-5" }, "\u0627\u062E\u062A\u0631 \u0627\u0644\u0648\u0633\u064A\u0644\u0629 \u0627\u0644\u0645\u0646\u0627\u0633\u0628\u0629"), h("div", { id: "openEmailLogin", class: "mb-2.5 box-content relative rounded-md border border-border-color bg-white py-5 pe-4 ps-5 flex items-center space-s-3 hover:border-gray-200" }, h("div", { class: "flex-shrink-0" }, h("div", { class: "bg-primary w-12 h-12 text-lg text-white rounded-icon" }, h("i", { class: "sicon-mail" }))), h("div", { class: "flex-1 min-w-0" }, h("a", { href: "#", class: "focus:outline-none flex justify-between items-center" }, h("div", { class: "flex-1" }, h("span", { class: "absolute inset-0", "aria-hidden": "true" }), h("p", { class: "text-sm text-gray-text" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644"), h("h6", { class: "font-boldf" }, "\u0627\u0644\u0628\u0631\u064A\u062F \u0627\u0644\u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A")), h("i", { class: "sicon-keyboard_arrow_left text-primary text-xl" })))), h("div", { class: "box-content relative rounded-md border border-border-color bg-white py-5 pe-4 ps-5 flex items-center space-s-3 hover:border-gray-200" }, h("div", { class: "flex-shrink-0" }, h("div", { class: "bg-primary w-12 h-12 text-lg text-white rounded-icon" }, h("i", { class: "sicon-phone" }))), h("div", { class: "flex-1 min-w-0" }, h("a", { href: "#", class: "focus:outline-none flex justify-between items-center" }, h("div", { class: "flex-1" }, h("span", { class: "absolute inset-0", "aria-hidden": "true" }), h("p", { class: "text-sm text-gray-text" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644"), h("h6", { class: "font-boldf" }, "\u0627\u0644\u0647\u0627\u062A\u0641")), h("i", { class: "sicon-keyboard_arrow_left text-primary text-xl" })))))));
9
- }
10
- };
11
-
12
- export { SallaLogin as S };
@@ -1,2 +0,0 @@
1
- export { S as salla_login } from './salla-login-4d620368.js';
2
- import './index-8966d27f.js';
@@ -1,91 +0,0 @@
1
- import { r as registerInstance, f as createEvent, h, e as Host, g as getElement } from './index-8966d27f.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
3
-
4
- const SallaModal = class {
5
- constructor(hostRef) {
6
- registerInstance(this, hostRef);
7
- this.ready = createEvent(this, "ready", 7);
8
- this.close = createEvent(this, "close", 7);
9
- var _a;
10
- this.error = false;
11
- this.success = false;
12
- this.isClosable = true;
13
- this.modalWidth = 'w-96'; //todo use friendly names
14
- this.visible = false;
15
- this.subTitleFirst = false;
16
- this.subTitle = '';
17
- this.icon = '';
18
- this.imageIcon = '';
19
- Helper.setHost(this.host);
20
- salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
21
- salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
22
- this.title = this.host.title;
23
- this.host.removeAttribute('title');
24
- (_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body');
25
- }
26
- handleVisible(newValue) {
27
- if (!newValue) {
28
- this.toggleModal(false);
29
- this.close.emit();
30
- return;
31
- }
32
- this.host.classList.remove('hidden');
33
- setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
34
- this.ready.emit();
35
- }
36
- async show() {
37
- this.host.setAttribute('visible', '');
38
- return this.host;
39
- }
40
- async hide() {
41
- this.host.removeAttribute('visible');
42
- return this.host;
43
- }
44
- async setTitle(title) {
45
- this.title = title;
46
- return this.host;
47
- }
48
- toggleModal(isOpen) {
49
- Helper.toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
50
- .toggleElement(this.host.querySelector('[slot=body]'), 's-modal-entering', 's-modal-leaving', () => isOpen)
51
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
52
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
53
- if (!isOpen) {
54
- setTimeout(() => this.host.classList.add('hidden'), 350);
55
- }
56
- }
57
- closeModal() {
58
- if (!this.isClosable) {
59
- return;
60
- }
61
- this.host.removeAttribute('visible');
62
- }
63
- //todo:: pref for each modal
64
- render() {
65
- this.host.id = this.host.id || 'salla-modal';
66
- return (h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), h("span", { class: "s-modal-spacer" }, "\u200B"), h("slot", { name: "body" }, h("div", { class: 's-modal-body ' + this.modalWidth }, h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
67
- h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
68
- : '', this.error || this.success || this.icon
69
- ? h("div", { class: {
70
- 's-modal-icon': true,
71
- 's-modal-bg-error': this.error,
72
- 's-modal-bg-success': this.success,
73
- 's-modal-bg-normal': !this.error && !this.success
74
- } }, h("i", { class: {
75
- [this.icon]: true,
76
- 's-modal-text-error': this.error,
77
- 's-modal-text-success': this.success,
78
- } }))
79
- : this.imageIcon ?
80
- h("img", { class: "s-modal-header-img", src: this.imageIcon })
81
- : '', this.title || this.subTitle ?
82
- h("div", { class: "s-modal-header-content" }, h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
83
- : ''), h("slot", null), h("slot", { name: "footer" }))))));
84
- }
85
- get host() { return getElement(this); }
86
- static get watchers() { return {
87
- "visible": ["handleVisible"]
88
- }; }
89
- };
90
-
91
- export { SallaModal as salla_modal };
@@ -1,3 +0,0 @@
1
- export { S as salla_search } from './salla-search-5338c0a1.js';
2
- import './index-8966d27f.js';
3
- import './Helper-81ac9a8c.js';
@@ -1,92 +0,0 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
2
- import { H as Helper } from './Helper-81ac9a8c.js';
3
-
4
- const SallaVerify = class {
5
- constructor(hostRef) {
6
- registerInstance(this, hostRef);
7
- Helper.setHost(this.host);
8
- salla.event.on('profile::verify.mobile', data => this.show(data));
9
- }
10
- show({ international_mobile: mobile, _country_iso2: country_code }) {
11
- this.mobile = mobile;
12
- this.country_code = country_code;
13
- this.resendTimer();
14
- this.otpInputs = document.querySelectorAll('.s-verify-input');
15
- this.otpInputs[0].focus();
16
- Helper.onKeyUp('.s-verify-input', event => {
17
- var _a, _b, _c, _d;
18
- let key = event.keyCode || event.charCode;
19
- salla.helpers.digitsOnly(event.target);
20
- if (event.target.value) {
21
- (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
22
- (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
23
- }
24
- else if ([8, 46].includes(key)) {
25
- (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
26
- (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
27
- }
28
- this.toggleOTPSubmit();
29
- });
30
- Helper.on('paste', '.s-verify-input', event => {
31
- let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
32
- this.otpInputs.forEach((input, i) => input.value = text[i] || '');
33
- this.toggleOTPSubmit();
34
- setTimeout(() => this.otpInputs[3].focus(), 100);
35
- });
36
- return this.modal.show();
37
- }
38
- toggleOTPSubmit() {
39
- let otp = [];
40
- this.otpInputs.forEach(input => input.value && otp.push(input.value));
41
- this.code.value = otp.join('');
42
- if (otp.length === 4) {
43
- this.btn.removeAttribute('disabled');
44
- this.btn.click();
45
- return;
46
- }
47
- this.btn.setAttribute('disabled', '');
48
- }
49
- resendTimer() {
50
- Helper.showElement(this.resendMessage).hideElement(this.resend);
51
- let resendAfter = 30;
52
- let timerId = setInterval(() => {
53
- if (resendAfter === -1) {
54
- clearTimeout(timerId);
55
- Helper.hideElement(this.resendMessage).showElement(this.resend);
56
- }
57
- else {
58
- this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
59
- resendAfter--;
60
- }
61
- }, 1000);
62
- }
63
- submit() {
64
- return this.btn.load()
65
- .then(() => this.btn.disable())
66
- .then(() => salla.document.api.request('profile/verify-mobile', {
67
- mobile: this.mobile,
68
- country_code: this.country_code,
69
- code: this.code.value
70
- })).then(() => this.btn.stop() && this.btn.disable())
71
- .then(() => this.modal.hide())
72
- .then(() => window.location.reload())
73
- .catch(() => this.btn.stop() && this.btn.enable());
74
- }
75
- resendCode() {
76
- return this.btn.stop()
77
- .then(() => this.btn.disable())
78
- .then(() => {
79
- this.otpInputs.forEach(input => input.value = '');
80
- this.otpInputs[0].focus();
81
- })
82
- .then(() => salla.api.auth.resend({ phone: this.mobile, country_code: this.country_code }))
83
- .then(() => this.resendTimer())
84
- .catch(() => this.resendTimer());
85
- }
86
- render() {
87
- return (h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')), h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))), h("div", { slot: "footer", class: "s-verify-footer" }, h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), h("b", { class: "s-verify-timer", ref: el => this.timer = el })), h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))));
88
- }
89
- get host() { return getElement(this); }
90
- };
91
-
92
- export { SallaVerify as salla_verify };