@salla.sa/twilight-components 1.0.15 → 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 (75) 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-branches.cjs.entry.js +5 -5
  4. package/dist/cjs/salla-button_4.cjs.entry.js +299 -0
  5. package/dist/cjs/salla-localization.cjs.entry.js +27 -24
  6. package/dist/cjs/salla-login-342876b9.js +118 -0
  7. package/dist/cjs/salla-offer.cjs.entry.js +25 -0
  8. package/dist/cjs/salla-product-availability.cjs.entry.js +1 -1
  9. package/dist/cjs/salla-rating.cjs.entry.js +155 -158
  10. package/dist/cjs/{salla-search-311c7053.js → salla-search-28da4616.js} +2 -2
  11. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  12. package/dist/cjs/twilight-components.cjs.js +1 -1
  13. package/dist/collection/collection-manifest.json +1 -0
  14. package/dist/collection/components/salla-branches/salla-branches.js +26 -28
  15. package/dist/collection/components/salla-button/salla-button.js +26 -23
  16. package/dist/collection/components/salla-localization/salla-localization.js +35 -29
  17. package/dist/collection/components/salla-login/salla-login.js +343 -26
  18. package/dist/collection/components/salla-modal/salla-modal.js +144 -45
  19. package/dist/collection/components/salla-offer/salla-offer.js +40 -0
  20. package/dist/collection/components/salla-product-availability/salla-product-availability.js +1 -1
  21. package/dist/collection/components/salla-rating/salla-rating.css +4 -0
  22. package/dist/collection/components/salla-rating/salla-rating.js +206 -211
  23. package/dist/collection/components/salla-search/salla-search.js +3 -3
  24. package/dist/collection/components/salla-verify/salla-verify.js +160 -21
  25. package/dist/collection/plugins/tailwind-theme/generator.js +21 -12
  26. package/dist/collection/plugins/tailwind-theme/index.js +9 -9
  27. package/dist/esm/index.js +2 -2
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/esm/salla-branches.entry.js +5 -5
  30. package/dist/esm/salla-button_4.entry.js +292 -0
  31. package/dist/esm/salla-localization.entry.js +27 -24
  32. package/dist/esm/salla-login-32d25ffa.js +116 -0
  33. package/dist/esm/salla-offer.entry.js +21 -0
  34. package/dist/esm/salla-product-availability.entry.js +1 -1
  35. package/dist/esm/salla-rating.entry.js +155 -158
  36. package/dist/esm/{salla-search-add7bdb6.js → salla-search-f552c487.js} +2 -2
  37. package/dist/esm/salla-search.entry.js +1 -1
  38. package/dist/esm/twilight-components.js +1 -1
  39. package/dist/twilight-components/index.esm.js +1 -1
  40. package/dist/twilight-components/{p-d584d0c7.entry.js → p-33990e49.entry.js} +1 -1
  41. package/dist/twilight-components/p-36683152.js +1 -0
  42. package/dist/twilight-components/p-3cfede65.entry.js +1 -0
  43. package/dist/twilight-components/p-648661c8.entry.js +1 -0
  44. package/dist/twilight-components/p-93c3ac79.js +1 -0
  45. package/dist/twilight-components/p-a923a51e.entry.js +1 -0
  46. package/dist/twilight-components/p-bc278b0e.entry.js +1 -0
  47. package/dist/twilight-components/p-fa04c4b6.entry.js +1 -0
  48. package/dist/twilight-components/p-fa2f0e64.entry.js +1 -0
  49. package/dist/twilight-components/twilight-components.esm.js +1 -1
  50. package/dist/types/components/salla-button/salla-button.d.ts +3 -2
  51. package/dist/types/components/salla-localization/salla-localization.d.ts +8 -0
  52. package/dist/types/components/salla-login/salla-login.d.ts +39 -0
  53. package/dist/types/components/salla-modal/salla-modal.d.ts +12 -4
  54. package/dist/types/components/salla-offer/salla-offer.d.ts +8 -0
  55. package/dist/types/components/salla-rating/salla-rating.d.ts +23 -9
  56. package/dist/types/components/salla-verify/salla-verify.d.ts +16 -6
  57. package/dist/types/components.d.ts +94 -8
  58. package/package.json +2 -1
  59. package/dist/cjs/salla-button.cjs.entry.js +0 -77
  60. package/dist/cjs/salla-login-6a54572d.js +0 -14
  61. package/dist/cjs/salla-login_2.cjs.entry.js +0 -97
  62. package/dist/cjs/salla-verify.cjs.entry.js +0 -96
  63. package/dist/esm/salla-button.entry.js +0 -73
  64. package/dist/esm/salla-login-c9c9fa57.js +0 -12
  65. package/dist/esm/salla-login_2.entry.js +0 -92
  66. package/dist/esm/salla-verify.entry.js +0 -92
  67. package/dist/twilight-components/p-010b8dfd.entry.js +0 -1
  68. package/dist/twilight-components/p-0ceecf63.js +0 -1
  69. package/dist/twilight-components/p-32d29245.entry.js +0 -1
  70. package/dist/twilight-components/p-50e70ad4.entry.js +0 -1
  71. package/dist/twilight-components/p-68c9f122.entry.js +0 -1
  72. package/dist/twilight-components/p-8126278e.entry.js +0 -1
  73. package/dist/twilight-components/p-9d327a79.entry.js +0 -1
  74. package/dist/twilight-components/p-b05450bc.entry.js +0 -1
  75. package/dist/twilight-components/p-bd5da080.js +0 -1
@@ -1,97 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const sallaLogin = require('./salla-login-6a54572d.js');
6
- const index = require('./index-0b5b5867.js');
7
- const Helper = require('./Helper-8852feaa.js');
8
-
9
- const SallaModal = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.ready = index.createEvent(this, "ready", 7);
13
- this.close = index.createEvent(this, "close", 7);
14
- var _a;
15
- this.error = false;
16
- this.success = false;
17
- this.isClosable = true;
18
- this.modalWidth = 'w-96'; //todo use friendly names
19
- this.visible = false;
20
- this.subTitleFirst = false;
21
- this.subTitle = '';
22
- this.icon = '';
23
- this.imageIcon = '';
24
- Helper.Helper.setHost(this.host);
25
- salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
26
- salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
27
- this.title = this.host.title;
28
- this.host.removeAttribute('title');
29
- (_a = Helper.Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body');
30
- }
31
- handleVisible(newValue) {
32
- if (!newValue) {
33
- this.toggleModal(false);
34
- this.close.emit();
35
- return;
36
- }
37
- this.host.classList.remove('hidden');
38
- setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
39
- this.ready.emit();
40
- }
41
- async show() {
42
- this.host.setAttribute('visible', '');
43
- return this.host;
44
- }
45
- async hide() {
46
- this.host.removeAttribute('visible');
47
- return this.host;
48
- }
49
- async setTitle(title) {
50
- this.title = title;
51
- return this.host;
52
- }
53
- toggleModal(isOpen) {
54
- Helper.Helper.toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
55
- .toggleElement(this.host.querySelector('[slot=body]'), 's-modal-entering', 's-modal-leaving', () => isOpen)
56
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
57
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
58
- if (!isOpen) {
59
- setTimeout(() => this.host.classList.add('hidden'), 350);
60
- }
61
- }
62
- closeModal() {
63
- if (!this.isClosable) {
64
- return;
65
- }
66
- this.host.removeAttribute('visible');
67
- }
68
- //todo:: pref for each modal
69
- render() {
70
- this.host.id = this.host.id || 'salla-modal';
71
- return (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" }, "\u200B"), index.h("slot", { name: "body" }, index.h("div", { class: 's-modal-body ' + this.modalWidth }, index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
72
- index.h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
73
- : '', this.error || this.success || this.icon
74
- ? index.h("div", { class: {
75
- 's-modal-icon': true,
76
- 's-modal-bg-error': this.error,
77
- 's-modal-bg-success': this.success,
78
- 's-modal-bg-normal': !this.error && !this.success
79
- } }, index.h("i", { class: {
80
- [this.icon]: true,
81
- 's-modal-text-error': this.error,
82
- 's-modal-text-success': this.success,
83
- } }))
84
- : this.imageIcon ?
85
- index.h("img", { class: "s-modal-header-img", src: this.imageIcon })
86
- : '', this.title || this.subTitle ?
87
- index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
88
- : ''), index.h("slot", null), index.h("slot", { name: "footer" }))))));
89
- }
90
- get host() { return index.getElement(this); }
91
- static get watchers() { return {
92
- "visible": ["handleVisible"]
93
- }; }
94
- };
95
-
96
- exports.salla_login = sallaLogin.SallaLogin;
97
- exports.salla_modal = SallaModal;
@@ -1,96 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-0b5b5867.js');
6
- const Helper = require('./Helper-8852feaa.js');
7
-
8
- const SallaVerify = class {
9
- constructor(hostRef) {
10
- index.registerInstance(this, hostRef);
11
- Helper.Helper.setHost(this.host);
12
- salla.event.on('profile::verify.mobile', data => this.show(data));
13
- }
14
- show({ international_mobile: mobile, _country_iso2: country_code }) {
15
- this.mobile = mobile;
16
- this.country_code = country_code;
17
- this.resendTimer();
18
- this.otpInputs = document.querySelectorAll('.s-verify-input');
19
- this.otpInputs[0].focus();
20
- Helper.Helper.onKeyUp('.s-verify-input', event => {
21
- var _a, _b, _c, _d;
22
- let key = event.keyCode || event.charCode;
23
- salla.helpers.digitsOnly(event.target);
24
- if (event.target.value) {
25
- (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
26
- (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
27
- }
28
- else if ([8, 46].includes(key)) {
29
- (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
30
- (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
31
- }
32
- this.toggleOTPSubmit();
33
- });
34
- Helper.Helper.on('paste', '.s-verify-input', event => {
35
- let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
36
- this.otpInputs.forEach((input, i) => input.value = text[i] || '');
37
- this.toggleOTPSubmit();
38
- setTimeout(() => this.otpInputs[3].focus(), 100);
39
- });
40
- return this.modal.show();
41
- }
42
- toggleOTPSubmit() {
43
- let otp = [];
44
- this.otpInputs.forEach(input => input.value && otp.push(input.value));
45
- this.code.value = otp.join('');
46
- if (otp.length === 4) {
47
- this.btn.removeAttribute('disabled');
48
- this.btn.click();
49
- return;
50
- }
51
- this.btn.setAttribute('disabled', '');
52
- }
53
- resendTimer() {
54
- Helper.Helper.showElement(this.resendMessage).hideElement(this.resend);
55
- let resendAfter = 30;
56
- let timerId = setInterval(() => {
57
- if (resendAfter === -1) {
58
- clearTimeout(timerId);
59
- Helper.Helper.hideElement(this.resendMessage).showElement(this.resend);
60
- }
61
- else {
62
- this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
63
- resendAfter--;
64
- }
65
- }, 1000);
66
- }
67
- submit() {
68
- return this.btn.load()
69
- .then(() => this.btn.disable())
70
- .then(() => salla.document.api.request('profile/verify-mobile', {
71
- mobile: this.mobile,
72
- country_code: this.country_code,
73
- code: this.code.value
74
- })).then(() => this.btn.stop() && this.btn.disable())
75
- .then(() => this.modal.hide())
76
- .then(() => window.location.reload())
77
- .catch(() => this.btn.stop() && this.btn.enable());
78
- }
79
- resendCode() {
80
- return this.btn.stop()
81
- .then(() => this.btn.disable())
82
- .then(() => {
83
- this.otpInputs.forEach(input => input.value = '');
84
- this.otpInputs[0].focus();
85
- })
86
- .then(() => salla.api.auth.resend({ phone: this.mobile, country_code: this.country_code }))
87
- .then(() => this.resendTimer())
88
- .catch(() => this.resendTimer());
89
- }
90
- render() {
91
- return (index.h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, index.h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), index.h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')), index.h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), 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 }))), 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')))));
92
- }
93
- get host() { return index.getElement(this); }
94
- };
95
-
96
- exports.salla_verify = SallaVerify;
@@ -1,73 +0,0 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8b97d225.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' ? ' flex-row-reverse' : '');
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('.btn-text').classList.add('opacity-0');
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: "btn-text transition-opacity duration-300" }, h("slot", null)), this.loading ? h("span", { class: {
59
- 'loader loader--small s-button-loader': true,
60
- 'absolute right-2': this.loaderPosition === 'start',
61
- 'absolute left-2': this.loaderPosition === 'end',
62
- 'absolute top-1/2 left-1/2 !-translate-x-1/2 !-translate-y-1/2 !m-0': 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,12 +0,0 @@
1
- import { r as registerInstance, h } from './index-8b97d225.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,92 +0,0 @@
1
- export { S as salla_login } from './salla-login-c9c9fa57.js';
2
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-8b97d225.js';
3
- import { H as Helper } from './Helper-81ac9a8c.js';
4
-
5
- const SallaModal = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- this.ready = createEvent(this, "ready", 7);
9
- this.close = createEvent(this, "close", 7);
10
- var _a;
11
- this.error = false;
12
- this.success = false;
13
- this.isClosable = true;
14
- this.modalWidth = 'w-96'; //todo use friendly names
15
- this.visible = false;
16
- this.subTitleFirst = false;
17
- this.subTitle = '';
18
- this.icon = '';
19
- this.imageIcon = '';
20
- Helper.setHost(this.host);
21
- salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
22
- salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
23
- this.title = this.host.title;
24
- this.host.removeAttribute('title');
25
- (_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body');
26
- }
27
- handleVisible(newValue) {
28
- if (!newValue) {
29
- this.toggleModal(false);
30
- this.close.emit();
31
- return;
32
- }
33
- this.host.classList.remove('hidden');
34
- setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
35
- this.ready.emit();
36
- }
37
- async show() {
38
- this.host.setAttribute('visible', '');
39
- return this.host;
40
- }
41
- async hide() {
42
- this.host.removeAttribute('visible');
43
- return this.host;
44
- }
45
- async setTitle(title) {
46
- this.title = title;
47
- return this.host;
48
- }
49
- toggleModal(isOpen) {
50
- Helper.toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
51
- .toggleElement(this.host.querySelector('[slot=body]'), 's-modal-entering', 's-modal-leaving', () => isOpen)
52
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
53
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
54
- if (!isOpen) {
55
- setTimeout(() => this.host.classList.add('hidden'), 350);
56
- }
57
- }
58
- closeModal() {
59
- if (!this.isClosable) {
60
- return;
61
- }
62
- this.host.removeAttribute('visible');
63
- }
64
- //todo:: pref for each modal
65
- render() {
66
- this.host.id = this.host.id || 'salla-modal';
67
- 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 ?
68
- h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
69
- : '', this.error || this.success || this.icon
70
- ? h("div", { class: {
71
- 's-modal-icon': true,
72
- 's-modal-bg-error': this.error,
73
- 's-modal-bg-success': this.success,
74
- 's-modal-bg-normal': !this.error && !this.success
75
- } }, h("i", { class: {
76
- [this.icon]: true,
77
- 's-modal-text-error': this.error,
78
- 's-modal-text-success': this.success,
79
- } }))
80
- : this.imageIcon ?
81
- h("img", { class: "s-modal-header-img", src: this.imageIcon })
82
- : '', this.title || this.subTitle ?
83
- 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 }))
84
- : ''), h("slot", null), h("slot", { name: "footer" }))))));
85
- }
86
- get host() { return getElement(this); }
87
- static get watchers() { return {
88
- "visible": ["handleVisible"]
89
- }; }
90
- };
91
-
92
- export { SallaModal as salla_modal };
@@ -1,92 +0,0 @@
1
- import { r as registerInstance, h, g as getElement } from './index-8b97d225.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 };
@@ -1 +0,0 @@
1
- export{S as salla_login}from"./p-bd5da080.js";import{r as s,c as t,h as i,H as l,g as a}from"./p-cb1c59a2.js";import{H as o}from"./p-9bc28e0c.js";const e=class{constructor(i){var l;s(this,i),this.ready=t(this,"ready",7),this.close=t(this,"close",7),this.error=!1,this.success=!1,this.isClosable=!0,this.modalWidth="w-96",this.visible=!1,this.subTitleFirst=!1,this.subTitle="",this.icon="",this.imageIcon="",o.setHost(this.host),salla.event.on("modal::open",(s=>s.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(s=>s.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title"),null===(l=o.getElement("[slot=body]"))||void 0===l||l.classList.add("s-modal-body")}handleVisible(s){if(!s)return this.toggleModal(!1),void this.close.emit();this.host.classList.remove("hidden"),setTimeout((()=>this.toggleModal(!0))),this.ready.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.title=s,this.host}toggleModal(s){o.toggleElement(this.host.querySelector(".s-modal-body"),"s-modal-entering","s-modal-leaving",(()=>s)).toggleElement(this.host.querySelector("[slot=body]"),"s-modal-entering","s-modal-leaving",(()=>s)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}render(){return this.host.id=this.host.id||"salla-modal",i(l,{class:"s-modal-container hidden","aria-modal":"true",role:"dialog"},i("div",{class:"s-modal-wrapper"},i("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal()}),i("span",{class:"s-modal-spacer"},"​"),i("slot",{name:"body"},i("div",{class:"s-modal-body "+this.modalWidth},i("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?i("button",{class:"s-modal-close cursor-pointer",onClick:()=>this.closeModal(),type:"button"},i("span",{class:"sicon-cancel"})):"",this.error||this.success||this.icon?i("div",{class:{"s-modal-icon":!0,"s-modal-bg-error":this.error,"s-modal-bg-success":this.success,"s-modal-bg-normal":!this.error&&!this.success}},i("i",{class:{[this.icon]:!0,"s-modal-text-error":this.error,"s-modal-text-success":this.success}})):this.imageIcon?i("img",{class:"s-modal-header-img",src:this.imageIcon}):"",this.title||this.subTitle?i("div",{class:"s-modal-header-content"},i("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),i("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle})):""),i("slot",null),i("slot",{name:"footer"})))))}get host(){return a(this)}static get watchers(){return{visible:["handleVisible"]}}};export{e as salla_modal}
@@ -1 +0,0 @@
1
- import{r as s,h as t,H as i,g as a}from"./p-cb1c59a2.js";import{H as e}from"./p-9bc28e0c.js";const r=class{constructor(t){var i,a;s(this,t),this.results=[],this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options"),e.setHost(this.host),this.buttonSlot=(null===(i=e.getElement('[slot="button"]'))||void 0===i?void 0:i.innerHTML)||'<i class="sicon-search font-bold"></i>',this.productSlot=(null===(a=e.getElement('[slot="product"]'))||void 0===a?void 0:a.innerHTML)||this.getDefaultProductSlot()}onModalClose(){e.getElement(".s-search-input").value="",this.results=[],this.afterSearching()}getDefaultProductSlot(){return'<a target="_blank" href={url} class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></a><div class="s-search-product-details"> <div class="s-search-product-name">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(e.hideElement(this.noResults),0===s.target.value.length)return this.results=[],void this.afterSearching();s.target.value.length<=2||(e.toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s.results)).catch((s=>"Query Same As Previous!"!==s?this.results=[]:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){this.noResults.style.display=s||this.results.length>0?"none":"block",e.toggleElement(this.container,"s-search-container-open","no-results",(()=>this.results.length)).toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery=""}render(){var s;return t(i,{class:"s-search"},t("button",{onClick:()=>this.modal.show(),class:"s-search-button-icon",innerHTML:this.buttonSlot}),t("salla-modal",{ref:s=>this.modal=s},t("div",{class:"s-search-container",slot:"body",ref:s=>this.container=s},t("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s)}),t("span",{class:"s-search-icon"},t("i",{class:"sicon-search",ref:s=>this.searchIcon=s})),t("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.map((s=>{var i;return t("div",{class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.title).replace(/\{price\}/g,null===(i=s.price)||void 0===i?void 0:i.after).replace(/\{url\}/g,s.url).replace(/\{image\}/g,s.thumb)})})),t("p",{ref:s=>this.noResults=s,class:"s-search-no-results"},this.noResultsText)))))}componentDidLoad(){this.afterSearching()}get host(){return a(this)}};export{r as S}
@@ -1 +0,0 @@
1
- export{S as salla_search}from"./p-0ceecf63.js";import"./p-cb1c59a2.js";import"./p-9bc28e0c.js";
@@ -1 +0,0 @@
1
- import{r as l,h as s,g as a}from"./p-cb1c59a2.js";import{H as i}from"./p-9bc28e0c.js";const t=class{constructor(s){var a,t;l(this,s),this.language=salla.config.language,this.currency=salla.config.currency,this.languagesTitle=salla.lang.get("common.titles.language"),this.currenciesTitle=salla.lang.get("common.titles.currency"),this.ok=salla.lang.get("common.elements.ok"),i.setHost(this.host),salla.event.on("localization::show",(()=>this.show())),this.languageSlot=(null===(a=i.getElement('[slot="language"]'))||void 0===a?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>',this.currencySlot=(null===(t=i.getElement('[slot="currency"]'))||void 0===t?void 0:t.innerHTML)||'<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>'}async show(){return this.modal.show()}async hide(){return this.modal.hide()}async submit(){let l;this.btn.load().then((()=>{if(this.currency&&this.currency.code!==salla.config.currency.code)return l=window.location.href,salla.currency.api.change(this.currency.code)})).then((()=>{this.language&&this.language.code!==salla.config.language.code&&(l=this.language.url)})).then((()=>this.btn.stop())).then((()=>this.hide())).then((()=>l&&(window.location.href=l)))}render(){return s("salla-modal",{id:"salla-localization",class:"hidden",ref:l=>this.modal=l},s("slot",{name:"header"},s("div",{slot:"header"})),s("div",{class:"s-localization-inner"},salla.config.languages?s("div",{class:"s-localization-section"},s("label",{class:"s-localization-title"},this.languagesTitle),s("fieldset",{class:"s-localization-fieldset"},s("div",{class:"s-localization-section-inner"},salla.config.languages.map((l=>s("div",{class:"s-localization-item"},s("input",{class:"s-localization-input",type:"radio",checked:this.language.code==l.code,onChange:()=>this.language=l,name:"language",id:"lang-"+l.code.toLowerCase(),value:l.code}),s("div",{id:"language-slot",innerHTML:this.languageSlot.replace(/\{name\}/g,l.name).replace(/\{code\}/g,l.code).replace(/\{country_code\}/g,l.country_code)}))))))):"",salla.config.currencies?s("div",{class:"s-localization-section"},s("label",{class:"s-localization-title"},this.currenciesTitle),s("fieldset",{class:"s-localization-fieldset"},s("div",{class:"s-localization-section-inner"},salla.config.currencies.map((l=>s("div",{class:"s-localization-item"},s("input",{class:"s-localization-input",type:"radio",name:"currency",checked:this.currency.code==l.code,onChange:()=>this.currency=l,id:"currency-"+l.code,value:l.code}),s("div",{id:"currency-slot",innerHTML:this.currencySlot.replace(/\{name\}/g,l.name).replace(/\{code\}/g,l.code).replace(/\{country_code\}/g,l.country_code)}))))))):""),s("p",{slot:"footer"},s("slot",{name:"footer"},s("salla-button",{wide:!0,ref:l=>this.btn=l,onClick:()=>this.submit()},this.ok))))}componentDidRender(){this.host.querySelectorAll("#currency-slot").forEach((l=>l.replaceWith(l.firstChild))),this.host.querySelectorAll("#language-slot").forEach((l=>l.replaceWith(l.firstChild)))}get host(){return a(this)}};export{t as salla_localization}
@@ -1 +0,0 @@
1
- import{r as t,h as s,g as i}from"./p-cb1c59a2.js";import{H as e}from"./p-9bc28e0c.js";const a=class{constructor(s){t(this,s),this.btnStyle="primary",this.loading=!1,this.disabled=!1,this.loaderPosition="before",this.wide=!1,this.hostAttributes={};for(let t=0;t<this.host.attributes.length;t++)this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value;this.hostAttributes.type=this.hostAttributes.type||"button",this.hostAttributes.class+=" s-button-btn btn--has-loading btn-"+this.btnStyle+(this.wide?" s-button-wide ":"")+"loader-"+this.loaderPosition+("before"==this.loaderPosition?" flex-row-reverse":""),delete this.hostAttributes["btn-style"],delete this.hostAttributes.id,this.wide&&this.host.classList.add("s-button-wide")}async load(){return"center"==this.loaderPosition&&this.host.querySelector(".btn-text").classList.add("opacity-0"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),this.host}async disable(){this.host.setAttribute("disabled","")}async enable(){this.host.removeAttribute("disabled")}handleVisible(t,s){this.btn.classList.remove("btn-"+s),this.btn.classList.add("btn-"+t)}handleLoading(t){e.toggleElement(this.btn,"btn--is-loading","btn--no-loading",(()=>t))}render(){return s("button",Object.assign({ref:t=>this.btn=t,disabled:this.disabled},this.hostAttributes),s("span",{class:"btn-text transition-opacity duration-300"},s("slot",null)),this.loading?s("span",{class:{"loader loader--small s-button-loader":!0,"absolute right-2":"start"===this.loaderPosition,"absolute left-2":"end"===this.loaderPosition,"absolute top-1/2 left-1/2 !-translate-x-1/2 !-translate-y-1/2 !m-0":"center"===this.loaderPosition}}):"")}get host(){return i(this)}static get watchers(){return{btnStyle:["handleVisible"],loading:["handleLoading"]}}};a.style=":host{display:block}";export{a as salla_button}
@@ -1 +0,0 @@
1
- import{r as s,h as e,g as t}from"./p-cb1c59a2.js";let i=require("store/src/store-engine"),a=require("store/storages/sessionStorage"),l=i.createStore(a);const h=class{constructor(e){s(this,e),this.open=!1,this.isOpenedBefore=l.get("branch-choosed-before"),this.displayAs="default",this.browseProductsFrom="all",this.branches=[{id:1,name:"فرع الرياض",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:2,name:"فرع جدة",open:!1,available:!1,limited:!1,tag:"غير متوفر"},{id:3,name:"فرع مكة",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:4,name:"فرع المدينة",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:5,name:"فرع جازان",open:!0,available:!0,limited:!0,tag:"الكمية محدودة"}],this.current=1,this.currentBranch=s=>this.branches.filter((s=>s.id==this.current))[0][s],this.statusColor=(s=null)=>s?s.limited?"text-red-400":s.available?"text-green-500":"text-gray-400":this.currentBranch("limited")?"text-red-400":this.currentBranch("available")?"text-green-500":"text-gray-400",this.isChoiceable=()=>"all"!==this.browseProductsFrom&&"single"==this.position||"header"==this.position,this.formTitle=()=>this.isChoiceable()?"توفر المنتج في الفروع الآخرى":"التسوق من فرع آخر",salla.event.on("branches::show",(()=>this.show()))}async show(){return this.modal.show()}async hide(){return this.modal.hide()}handelChange(s){this.selected=s.target.value}handleSubmit(){this.btn.load().then((()=>{setTimeout((()=>location.reload()),2e3)})),l.set("branch-choosed-before",!0),this.show(),setTimeout((()=>{this.current=this.selected}),300)}render(){return e("salla-modal",{icon:"sicon-store-alt",title:"فرع الرياض","sub-title":"أنت الآن تتصفح المتجر من","sub-title-first":!0,"is-closable":this.isOpenedBefore||"popup"!=this.displayAs?"true":"false",ref:s=>this.modal=s,"modal-width":"w-116",id:"s-branches-modal",class:"hidden"},e("fieldset",null,e("h4",{class:"s-branches-title"},this.formTitle()),e("legend",{class:"s-branches-sr-only"},this.formTitle()),this.branches.length<=5?e("div",{class:"s-branches-space-v"},this.branches.map((s=>e("div",{class:"s-branches-input-wrap"},e("input",{id:this.position+"_branch_"+s.id,disabled:!s.open&&this.isChoiceable(),name:"lang",type:"radio",value:s.id,onChange:s=>this.handelChange(s),class:{"s-branches-input":!0,"opacity-50":!s.open,hidden:!this.isChoiceable()},checked:this.current==s.id}),e("label",{htmlFor:this.position+"_branch_"+s.id,class:{"s-branches-label":!0,"s-branches-clickable":this.isChoiceable()}},e("span",{class:{"s-branches-is-closed":!s.open}},s.name),this.isChoiceable()?e("small",{class:"s-branches-closed-badge"},s.open?"":"مُغلق"):e("span",{class:this.statusColor(s)},s.tag)))))):e("select",{class:"s-branches-select",onInput:s=>this.handelChange(s)},this.branches.map((s=>e("option",{value:s.id,disabled:!s.open,selected:this.selected==s.id},s.name," ",s.open?"":"- مُغلق"))))),this.isChoiceable()?e("slot",{name:"footer"},e("salla-button",{"loader-position":"before",ref:s=>this.btn=s,onClick:()=>this.handleSubmit(),class:"s-branches-submit"},salla.lang.get("common.elements.ok"))):"")}componentDidRender(){this.isOpenedBefore||"popup"!=this.displayAs||this.show()}get host(){return t(this)}};h.style=":host{display:block}";export{h as salla_branches}
@@ -1 +0,0 @@
1
- import{r as s,h as i,g as e}from"./p-cb1c59a2.js";import{H as t}from"./p-9bc28e0c.js";const l=class{constructor(i){s(this,i),t.setHost(this.host),salla.event.on("profile::verify.mobile",(s=>this.show(s)))}show({international_mobile:s,_country_iso2:i}){return this.mobile=s,this.country_code=i,this.resendTimer(),this.otpInputs=document.querySelectorAll(".s-verify-input"),this.otpInputs[0].focus(),t.onKeyUp(".s-verify-input",(s=>{var i,e,t,l;let r=s.keyCode||s.charCode;salla.helpers.digitsOnly(s.target),s.target.value?(null===(i=s.target.nextElementSibling)||void 0===i||i.focus(),null===(e=s.target.nextElementSibling)||void 0===e||e.select()):[8,46].includes(r)&&(null===(t=s.target.previousElementSibling)||void 0===t||t.focus(),null===(l=s.target.previousElementSibling)||void 0===l||l.select()),this.toggleOTPSubmit()})),t.on("paste",".s-verify-input",(s=>{let i=s.clipboardData.getData("text").toArabicDigits().replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((s,e)=>s.value=i[e]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.modal.show()}toggleOTPSubmit(){let s=[];if(this.otpInputs.forEach((i=>i.value&&s.push(i.value))),this.code.value=s.join(""),4===s.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}resendTimer(){t.showElement(this.resendMessage).hideElement(this.resend);let s=30,i=setInterval((()=>{-1===s?(clearTimeout(i),t.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${s>=10?s:"0"+s} : 00`,s--)}),1e3)}submit(){return this.btn.load().then((()=>this.btn.disable())).then((()=>salla.document.api.request("profile/verify-mobile",{mobile:this.mobile,country_code:this.country_code,code:this.code.value}))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()))}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((s=>s.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend({phone:this.mobile,country_code:this.country_code}))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}render(){return i("salla-modal",{id:"s-verify",ref:s=>this.modal=s,title:salla.lang.get("pages.profile.verify_title")},i("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),i("label",{class:"s-verify-label"},salla.lang.get("pages.profile.verify_placeholder")),i("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:s=>this.code=s}),i("div",{class:"s-verify-codes",dir:"ltr"},[1,2,3,4].map((()=>i("input",{type:"text",maxlength:"1",class:"s-verify-input",required:!0})))),i("div",{slot:"footer",class:"s-verify-footer"},i("salla-button",{class:"s-verify-submit",disabled:!0,onClick:()=>this.submit(),ref:s=>this.btn=s},salla.lang.get("pages.profile.verify")),i("p",{class:"s-verify-resend-message",ref:s=>this.resendMessage=s},salla.lang.get("blocks.header.resend_after"),i("b",{class:"s-verify-timer",ref:s=>this.timer=s})),i("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:s=>this.resend=s},salla.lang.get("blocks.comments.submit"))))}get host(){return e(this)}};export{l as salla_verify}
@@ -1 +0,0 @@
1
- import{r as t,h as e,H as a,g as s}from"./p-cb1c59a2.js";import{H as i}from"./p-9bc28e0c.js";const r=class{constructor(e){t(this,e),this.stars=[1,2,3,4,5],this.order={shipping:{id:5622},products:[{title:"ميكروفون عالى الجودة",image:"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",price:"‏10,978.00 ر.س",qty:"‏2",totalBefore:"‏1120 ر.س",discount:"-5%",total:"‏1064 ر.س",id:"2314513454",getOptimusRouteKey:"7351233357"},{title:"ساعة ذكية بنظام اندرويد",image:"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",price:"‏10,978.00 ر.س",qty:"‏2",totalBefore:"‏1120 ر.س",discount:"-5%",total:"‏1064 ر.س",id:"679822376",getOptimusRouteKey:"73233357"}]},this.isProductsRating=!1,this.ratingChain=Promise.resolve(),this.stepsCount=0,i.setHost(this.host)}async show(){return this.modal.show()}async hide(){return this.modal.hide()}componentWillLoad(){this.stepsCount=[this.isStoreRating,this.isProductsRating,this.isShippingRating].filter((t=>t)).length,this.getData()}componentDidRender(){this.show(),this.initiateRating()}initiateRating(){this.highlightSelectedStars(),this.starsRating(),this.handleWizard();const t=this.host.querySelector(".step:first-child");this.setModalHeight(t),salla.event.on("submit::order-rating",(()=>this.sendRating().then((()=>{let t=10,e=setInterval((()=>{t--,this.host.querySelector(".close-time").innerHTML=`00:0${t}`,0==t&&(this.hide(),clearInterval(e))}),1e3);this.host.querySelector(".wizard-footer").classList.add("opacity-0","pointer-events-0"),i.toggle(".step","hidden","block",(()=>!0)),i.toggle(".thankyou-view","is-opened","hidden",(()=>!0));const a=this.host.querySelector(".thankyou-view");this.setModalHeight(a),setTimeout((()=>{i.toggleElement(a,["opacity-1","translate-x-0"],["opacity-0","translate-x-3"],(()=>!0))}),200)}))))}handleWizard(){var t;let e=0,a=this.host.querySelectorAll(".step"),s=this.host.querySelectorAll(".step-dot"),r=this.host.querySelector("#next-btn .btn-text");this.showActiveStep(a,s,e),r.innerHTML=(null===(t=a[e+1])||void 0===t?void 0:t.dataset.stepName)||"إرسال التقييم",i.onClick("#prev-btn",(()=>{var t;e>0&&e--,this.showActiveStep(a,s,e),r.innerHTML=(null===(t=a[e+1])||void 0===t?void 0:t.dataset.stepName)||"إرسال التقييم",0==e&&i.toggle("#prev-btn",["pointer-events-none","opacity-0"],"block",(()=>!0))})),i.onClick("#next-btn",(()=>{var t;this.ratingValidation(),e==this.stepsCount-1?salla.event.dispatch("submit::order-rating"):(e<this.stepsCount-1&&e++,this.showActiveStep(a,s,e),r.innerHTML=(null===(t=a[e+1])||void 0===t?void 0:t.dataset.stepName)||"إرسال التقييم",i.toggle("#prev-btn","block",["pointer-events-none","opacity-0"],(()=>!0)))}))}showActiveStep(t,e,a){i.toggle(".step-dot","bg-gray-200","bg-primay",(()=>!0)),this.stepsCount>1&&i.toggleElement(e[a],"bg-primary","bg-gray-200",(()=>!0)),i.toggle(".step",["hidden","opacity-0","translate-x-3"],["active","opacity-1","translate-x-0"],(()=>!0)),i.toggleElement(t[a],"active","hidden",(()=>!0)),this.setModalHeight(t[a]),setTimeout((()=>{i.toggleElement(t[a],["opacity-1","translate-x-0"],["opacity-0","translate-x-3"],(()=>!0))}),200)}setModalHeight(t){const e=this.host.querySelector(".s-order-rating-steps-wrapper");setTimeout((()=>{null==e||e.setAttribute("style","height:"+(null==t?void 0:t.scrollHeight)+"px")}))}sendRating(){return i.all(".rating-section",(t=>{let e=t.dataset.type,a=[];t.querySelectorAll(".rating-outer-form").forEach((t=>{let s={};t.querySelectorAll("[name]").forEach((function(t){let e=salla.helpers.inputData(t.name,t.value,s);s[e.name]=e.value})),a=[],a.push(s),this.sendFeedback(e,a)}))})),this.ratingChain}sendFeedback(t,e){e&&0!=e.length&&(this.nextBtn.load(),salla.config.canLeave=!1,this.ratingChain=salla.feedback.api[t](e[0]).then((function(){salla.config.canLeave=!0})).catch((()=>salla.config.canLeave=!0)))}ratingValidation(){let t="";if(document.querySelectorAll(".rating-section.active").forEach((e=>{e.querySelectorAll(".rating-outer-form").forEach((e=>{let a=e.querySelector(".rating_hidden_input"),s=e.querySelector(".comment"),i=e.querySelector(".validation-message");if(a.value&&s.value&&s.value.length>3)return s.classList.remove("has-error"),void(i.innerHTML="");s.value&&s.value.length>3?s.classList.remove("has-error"):s.classList.add("has-error"),t=a.value?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+s.getAttribute("placeholder"):e.dataset.starsError||salla.lang.get("pages.rating.rate_store_stars"),i.innerHTML=t}))})),t){let e=document.querySelectorAll(".has-error");throw e.length&&window.scrollTo({top:e[0].offsetTop-80}),new Error(t)}}getData(){salla.api.order.endpointsMethods.details="get",salla.order.api.details(salla.config.page.id).then((t=>console.log(t)))}starsRating(){let t=["selected","text-theme-yellow"];salla.document.event.onSubmit(".rate-element",(function(e){e.preventDefault();var a=e.target.querySelectorAll(".btn--star.hovered"),s=a[a.length-1];if(s){var i=parseInt(s.dataset.star,10);e.target.querySelector(".rating_hidden_input").value=i,e.target.querySelectorAll(".btn--star").forEach((function(e,a){a<i?e.classList.add(...t):e.classList.remove(...t)}));var r=e.target.querySelector('.star[aria-pressed="true"]');r&&r.removeAttribute("aria-pressed"),s.setAttribute("aria-pressed",!0)}}))}highlightSelectedStars(){let t=["hovered","text-theme-yellow"];i.all(".rate-element",(e=>{let a=e.querySelectorAll(".btn--star");e.addEventListener("mouseout",(()=>e.querySelectorAll(".btn--star").forEach((e=>e.classList.remove(...t))))),a.forEach(((e,s)=>{e.addEventListener("mouseover",(()=>{if(e.classList.add(...t),s<=1)"BUTTON"===e.previousElementSibling.tagName&&e.previousElementSibling.classList.add(...t);else for(let e=0;e<s;e++)a[e].classList.add(...t)})),e.addEventListener("mouseout",(()=>{e.classList.contains(...t)&&e.classList.remove(...t)}))}))}))}render(){return e(a,null,e("salla-modal",{class:"hidden","modal-width":"w-[800px]",ref:t=>this.modal=t,title:salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.orderId+")</span>"},e("div",{class:"s-order-rating-steps-wrapper mt-12 mb-10 transition-all duration-300 ease-elastic"},this.isStoreRating&&this.renderStoreRating(),this.isProductsRating&&this.renderProductsRating(),this.isShippingRating&&this.renderShippingRating(),this.renderThanksView()),e("div",{class:"wizard-footer relative flex justify-between items-center"},e("button",{id:"prev-btn",class:"font-bold text-sm w-28 h-10 px-4 text-primary hover:text-primary-d opacity-0 pointer-events-none duration-300 transition-all"},"السابق"),this.stepsCount>1?e("ul",{class:"flex justify-center text-center space-s-1.5 flex-1"},[0,1,2].slice(0,this.stepsCount).map((t=>e("li",{class:(0==t?"bg-primary":"bg-gray-200")+" step-dot w-2.5 h-2.5 rounded-full transition-colors duration-300"})))):"",e("salla-button",{id:"next-btn",class:"w-28",ref:t=>this.nextBtn=t},"التالي"))))}renderStoreRating(){return e("section",{class:"step rating-section active transition-all duration-500 opacity-0 translate-x-3 hidden","data-type":"store","data-step-name":"تقييم المتجر"},e("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_store_stars")},e("input",{type:"hidden",name:"order_id",value:this.orderId}),e("input",{type:"hidden",name:"type",value:"store"}),e("div",{class:"flex flex-col items-center "},e("div",{class:"w-28 h-28 border border-gray-200 rounded-full flex items-center justify-center mb-4"},e("img",{src:"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png",alt:"store name",class:"w-12 object-contain"})),e("h2",{class:"section-title text-lg font-bold mb-4"},salla.lang.get("pages.rating.rate_the_store"))),e("div",{class:"rating-wrap flex items-center flex justify-center mb-4"},e("form",{class:"rate-element rate-element--has-label"},this.getStarsRating())),e("textarea",{id:"storeReview",name:"comment",class:"form-input comment h-20",placeholder:salla.lang.get("pages.rating.write_store_rate")}),e("small",{class:"text-red-400 validation-message"})))}renderProductsRating(){return e("section",{class:"step rating-section products-section transition-all duration-500 opacity-0 translate-x-3 hidden","data-type":"product","data-step-name":"تقييم المنتجات"},e("div",{class:"overflow-hidden"},this.order.products.map(((t,a)=>e("div",{class:"rating-outer-form mb-8 last:mb-0","data-stars-error":salla.lang.get("pages.rating.rate_product_stars",{item:t.title})},e("div",{class:"product-item"},e("div",{class:"flex space-s-5"},e("img",{src:t.image,alt:t.title,class:"w-18 h-14 object-cover rounded-md"}),e("div",{class:"flex-1"},e("h3",{class:"section-title leading-5 mb-1.5 font-bold md:text-sm"}," ",t.title),e("div",{class:"rw-product-entry__rate"},e("div",{class:"rating-wrap flex items-center space-s-4"},e("form",{class:"rate-element rate-element--has-label"},this.getStarsRating())),e("input",{type:"hidden",name:"order_id",value:this.orderId}),e("input",{type:"hidden",name:`products[${a}][product_id]`,value:t.getOptimusRouteKey}),e("input",{type:"hidden",name:"type",value:"products"}),e("textarea",{"data-product-id":t.id,name:`products[${a}][comment]`,id:`productReview_${t.id}`,class:"comment form-input h-20 product-review",placeholder:salla.lang.get("pages.rating.write_product_rate")}),e("small",{class:"text-red-400 validation-message"}))))))))))}renderShippingRating(){return e("section",{class:"step rating-section py-5 rounded-md transition-all duration-500 opacity-0 translate-x-3 hidden","data-type":"shipping","data-step-name":"تقييم شركة الشحن"},e("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_shipping_stars")},e("input",{type:"hidden",name:"order_id",value:this.orderId}),e("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.id}),e("input",{type:"hidden",name:"type",value:"shipping"}),e("div",{class:"flex flex-col items-center "},e("div",{class:"w-28 h-28 overflow-hidden border border-gray-200 rounded-full flex items-center justify-center mb-4"},e("img",{src:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU",alt:"company name",class:"w-full h-full object-contain"})),e("h2",{class:"section-title text-lg font-bold mb-4"}," ",salla.lang.get("pages.rating.rate_shipping")," ارامكس")),e("div",{class:"rating-wrap flex flex justify-center mb-4"},e("form",{class:"rate-element ratFeedbackPresentere-element--has-label"},this.getStarsRating())),e("textarea",{id:"shippingReview",name:"comment",class:"form-input comment h-20 mb-2",placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),e("small",{class:"text-red-400 validation-message"})))}renderThanksView(){return e("div",{class:"thankyou-view px-8 text-center transition-all duration-500 opacity-0 translate-x-3 hidden"},e("span",{class:"w-20 h-20 text-4xl inline-flex justify-center items-center bg-gray-50 rounded-full text-primary sicon-check-circle2"}),e("div",{class:"mt-4 mb-6"},e("h3",{class:"font-bold"},salla.lang.get("pages.rating.thanks")),e("div",{class:"text-gray-400 text-sm",innerHTML:this.thanksMsg})),e("a",{href:"#!",onClick:()=>this.hide(),class:"btn btn-primary h-10 flex-none px-8"},"عودة إلي تفاصيل الطلب"),e("time",{class:"close-time text-gray-400 block h-6 mt-3 text-sm"}))}getStarsRating(){return e("div",{class:"mb-1"},e("input",{type:"hidden",class:"rating_hidden_input",name:"rating",value:""}),this.stars.map((t=>e("button",{type:"submit",class:"btn btn--transparent px-1 text-2xl text-gray-400 btn--star","data-star":t},e("i",{class:"sicon-star2"})))))}get host(){return s(this)}};r.style=":host{display:block}";export{r as salla_rating}
@@ -1 +0,0 @@
1
- import{r as e,h as s}from"./p-cb1c59a2.js";const t=class{constructor(s){e(this,s)}render(){return s("salla-modal",{id:"salla-login",title:"سجل دخول إلى الموقع"},s("div",{id:"showLoginMethods"},s("p",{class:"text-sm text-gray-text mb-5"},"اختر الوسيلة المناسبة"),s("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"},s("div",{class:"flex-shrink-0"},s("div",{class:"bg-primary w-12 h-12 text-lg text-white rounded-icon"},s("i",{class:"sicon-mail"}))),s("div",{class:"flex-1 min-w-0"},s("a",{href:"#",class:"focus:outline-none flex justify-between items-center"},s("div",{class:"flex-1"},s("span",{class:"absolute inset-0","aria-hidden":"true"}),s("p",{class:"text-sm text-gray-text"},"سجل دخول"),s("h6",{class:"font-boldf"},"البريد الإلكتروني")),s("i",{class:"sicon-keyboard_arrow_left text-primary text-xl"})))),s("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"},s("div",{class:"flex-shrink-0"},s("div",{class:"bg-primary w-12 h-12 text-lg text-white rounded-icon"},s("i",{class:"sicon-phone"}))),s("div",{class:"flex-1 min-w-0"},s("a",{href:"#",class:"focus:outline-none flex justify-between items-center"},s("div",{class:"flex-1"},s("span",{class:"absolute inset-0","aria-hidden":"true"}),s("p",{class:"text-sm text-gray-text"},"سجل دخول"),s("h6",{class:"font-boldf"},"الهاتف")),s("i",{class:"sicon-keyboard_arrow_left text-primary text-xl"}))))))}};export{t as S}