@salla.sa/twilight-components 1.0.104 → 1.0.108

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 (55) hide show
  1. package/README.md +8 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-add-product-button.cjs.entry.js +85 -0
  4. package/dist/cjs/{salla-add-product-button_6.cjs.entry.js → salla-branches_13.cjs.entry.js} +990 -62
  5. package/dist/cjs/twilight-components.cjs.js +1 -1
  6. package/dist/collection/components/salla-login-modal/salla-login-modal.js +25 -13
  7. package/dist/collection/global/app.js +23 -0
  8. package/dist/collection/plugins/tailwind-theme/index.js +3 -4
  9. package/dist/components/salla-login-modal.js +17 -8
  10. package/dist/esm/loader.js +1 -1
  11. package/dist/esm/salla-add-product-button.entry.js +81 -0
  12. package/dist/esm/{salla-add-product-button_6.entry.js → salla-branches_13.entry.js} +984 -63
  13. package/dist/esm/twilight-components.js +1 -1
  14. package/dist/twilight-components/p-6f4f4260.entry.js +4 -0
  15. package/dist/twilight-components/p-d4539c3e.entry.js +4 -0
  16. package/dist/twilight-components/twilight-components.esm.js +1 -1
  17. package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +1 -1
  18. package/dist/types/components.d.ts +1 -1
  19. package/dist/types/global/app.d.ts +3 -0
  20. package/example/assets/tailwind.css +3938 -3
  21. package/example/assets/translations.js +4981 -0
  22. package/example/index.html +8 -8
  23. package/package.json +13 -6
  24. package/dist/cjs/salla-branches.cjs.entry.js +0 -98
  25. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +0 -93
  26. package/dist/cjs/salla-localization-modal.cjs.entry.js +0 -121
  27. package/dist/cjs/salla-login-modal.cjs.entry.js +0 -196
  28. package/dist/cjs/salla-offer-modal.cjs.entry.js +0 -145
  29. package/dist/cjs/salla-rating-modal.cjs.entry.js +0 -177
  30. package/dist/cjs/salla-rating-stars.cjs.entry.js +0 -76
  31. package/dist/cjs/salla-verify.cjs.entry.js +0 -168
  32. package/dist/esm/salla-branches.entry.js +0 -94
  33. package/dist/esm/salla-infinite-scroll.entry.js +0 -89
  34. package/dist/esm/salla-localization-modal.entry.js +0 -117
  35. package/dist/esm/salla-login-modal.entry.js +0 -192
  36. package/dist/esm/salla-offer-modal.entry.js +0 -141
  37. package/dist/esm/salla-rating-modal.entry.js +0 -173
  38. package/dist/esm/salla-rating-stars.entry.js +0 -72
  39. package/dist/esm/salla-verify.entry.js +0 -164
  40. package/dist/twilight-components/p-30e63760.entry.js +0 -4
  41. package/dist/twilight-components/p-799da239.entry.js +0 -4
  42. package/dist/twilight-components/p-9ff78dd1.entry.js +0 -4
  43. package/dist/twilight-components/p-c1952856.entry.js +0 -4
  44. package/dist/twilight-components/p-cf143464.entry.js +0 -4
  45. package/dist/twilight-components/p-d3778858.entry.js +0 -4
  46. package/dist/twilight-components/p-ebd2e045.entry.js +0 -4
  47. package/dist/twilight-components/p-ec0a2892.entry.js +0 -4
  48. package/dist/twilight-components/p-fab65162.entry.js +0 -4
  49. package/example/dist/demo.js +0 -153
  50. package/example/dist/flags.png +0 -0
  51. package/example/dist/flags@2x.png +0 -0
  52. package/example/dist/intlTelInput.min.css +0 -1
  53. package/example/dist/tailwind.css +0 -3856
  54. package/example/dist/translations.js +0 -1
  55. package/example/dist/twilight.js +0 -437
@@ -1,141 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import { r as registerInstance, h, g as getElement } from './index-20b84fd0.js';
5
- import { H as Helper } from './Helper-e1d414a5.js';
6
-
7
- const sallaOfferModalCss = "";
8
-
9
- const SallaOfferModal = class {
10
- constructor(hostRef) {
11
- registerInstance(this, hostRef);
12
- var _a, _b;
13
- this.offer = null;
14
- this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
15
- this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
16
- this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
17
- this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
18
- Helper.setHost(this.host);
19
- salla.lang.onLoaded(() => {
20
- this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
21
- this.remember_my_choice = salla.lang.get('common.elements.remember_my_choice');
22
- this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
23
- this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
24
- });
25
- this.categorySlot = ((_a = Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>';
26
- this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
27
- salla.product.event.onOfferExisted(offer => {
28
- if (salla.storage.get('remember-offer-' + offer.id)) {
29
- salla.log('User selected to don\'t show this offer again.');
30
- return;
31
- }
32
- this.open(offer.product_id);
33
- });
34
- }
35
- /**
36
- * Show the available offers for the product
37
- * @param product_id
38
- */
39
- async open(product_id) {
40
- //TODO:: make sure there is only one offer
41
- return salla.product.offers(product_id)
42
- .then(response => this.showOffer(response.data[0]));
43
- }
44
- /**
45
- * Show offer details
46
- * @param {Offer} offer
47
- */
48
- async showOffer(offer) {
49
- this.offer = offer;
50
- this.offer_name = offer.name;
51
- this.offer_message = offer.message;
52
- this.modal.setTitle(this.offer_name);
53
- return this.modal.open();
54
- }
55
- rememberMe(event) {
56
- console.log("🚀 ~ file: salla-offer-modal.tsx ~ line 75 ~ SallaOfferModal ~ rememberMe ~ rememberMe", event);
57
- salla.storage.set('remember-offer-' + this.offer.id, event.target.checked);
58
- }
59
- //todo:: pass event then use sallaButton from it
60
- addItem() {
61
- // this here, is sallaButton
62
- this['load']();
63
- return salla.cart.api
64
- .quickAdd(this['dataset'].id)
65
- .finally(() => this['stop']());
66
- }
67
- defaultProductSlot() {
68
- return '<a href={url} class="s-offer-modal-product-image-wrap"><img class="s-offer-modal-product-image" src="{image}" /></a>' +
69
- '<div class="s-offer-modal-product-info">' +
70
- ' <a href={url} class="s-offer-modal-product-name">{name}</a>' +
71
- ' <div class="s-offer-modal-product-price">{price}</div>' +
72
- '</div>';
73
- }
74
- render() {
75
- var _a, _b;
76
- return h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
77
- ? [h("div", { class: "s-offer-modal-scrolled-slider-wrap" }, h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
78
- ? this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item", innerHTML: this.categorySlot
79
- .replace(/\{name\}/g, category.name)
80
- .replace(/\{url\}/g, category.urls.customer) }))
81
- : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: { "s-offer-modal-product": true, "s-offer-modal-slider-item": true, "s-offer-modal-not-available": !product.is_available }, id: 'product_' + product.id, innerHTML: this.productSlot
82
- .replace(/\{name\}/g, product.name)
83
- .replace(/\{url\}/g, product.url)
84
- .replace(/\{image\}/g, product.thumbnail)
85
- .replace(/\{price\}/g, product.has_special_price
86
- ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
87
- : salla.money(product.price)) }, h("div", { class: "s-offer-modal-btn-wrap" }, h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? this.add_to_cart : this.out_of_stock))))), h("div", { class: "s-offer-modal-slider-nav" }, h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })), h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })))), h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.formatted_date ?
88
- h("p", { class: "s-offer-modal-expiry" }, this.offer_expires_in, " ", this.offer.formatted_date)
89
- : '', h("label", { class: "s-offer-modal-remember-label" }, h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-modal-remember-input" }), "\u00A0 ", this.remember_my_choice)),
90
- ] : '');
91
- }
92
- componentDidRender() {
93
- // Sooo mini Slider
94
- if (this.offer && window.screen.width > 639) {
95
- let sliderWrap = this.modal.querySelector('.s-offer-modal-scrolled-slider-wrap'), slider = this.modal.querySelector('.s-offer-modal-scrolled-slider'), navButtons = this.modal.querySelectorAll('.s-offer-modal-nav-btn'), nexBtn = this.modal.querySelector('.s-offer-modal-next-btn'), prevBtn = this.modal.querySelector('.s-offer-modal-prev-btn'), items = this.modal.querySelectorAll('.s-offer-modal-slider-item'), sliderNavMargin = 20, // space before displaying the next/prev btns.
96
- current = 0, // current slide
97
- slidesToScroll = 3, itemsLength = items.length;
98
- console.log('items[0]:', items[0]);
99
- let itemSize = items[0].offsetWidth, sliderSize = itemsLength * itemSize, sliderWrapperSize = sliderWrap.offsetWidth, sliderInvisibleSize = sliderSize - sliderWrapperSize, isRTL = document.body.classList.contains('rtl') ? true : false;
100
- if (sliderInvisibleSize > sliderNavMargin)
101
- nexBtn.classList.add('s-offer-modal-btn-is-active');
102
- window.onresize = function () {
103
- sliderWrapperSize = sliderWrap.offsetWidth;
104
- sliderInvisibleSize = sliderSize - sliderWrapperSize;
105
- };
106
- slider.addEventListener('scroll', function () {
107
- let sliderPosition = Math.abs(slider.scrollLeft);
108
- let sliderEndOffset = sliderInvisibleSize - sliderNavMargin;
109
- // show & hide the navigation btns depending on scroll position
110
- if (sliderPosition <= sliderNavMargin) {
111
- nexBtn.classList.add('s-offer-modal-btn-is-active');
112
- prevBtn.classList.remove('s-offer-modal-btn-is-active');
113
- }
114
- else if (sliderPosition < sliderEndOffset) {
115
- // show both btns in the middle
116
- nexBtn.classList.add('s-offer-modal-btn-is-active');
117
- prevBtn.classList.add('s-offer-modal-btn-is-active');
118
- }
119
- else if (sliderPosition >= sliderEndOffset) {
120
- nexBtn.classList.remove('s-offer-modal-btn-is-active');
121
- prevBtn.classList.add('s-offer-modal-btn-is-active');
122
- }
123
- });
124
- // Navigation
125
- navButtons.forEach(btn => {
126
- btn.addEventListener('click', function () {
127
- btn.classList.contains('s-offer-modal-next-btn') ? current++ : current--;
128
- slider.scrollTo({
129
- top: 0,
130
- left: itemSize * slidesToScroll * current * (isRTL ? -1 : 1),
131
- behavior: 'smooth'
132
- });
133
- });
134
- });
135
- }
136
- }
137
- get host() { return getElement(this); }
138
- };
139
- SallaOfferModal.style = sallaOfferModalCss;
140
-
141
- export { SallaOfferModal as salla_offer_modal };
@@ -1,173 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import { r as registerInstance, h, H as Host, g as getElement } from './index-20b84fd0.js';
5
- import { H as Helper } from './Helper-e1d414a5.js';
6
-
7
- const sallaRatingModalCss = "";
8
-
9
- const SallaRatingModal = class {
10
- constructor(hostRef) {
11
- registerInstance(this, hostRef);
12
- this.stepsCount = 0;
13
- this.currentIndex = 0;
14
- this.submitted = [];
15
- /**
16
- * The order id, to rate on its products & shipping
17
- */
18
- this.orderId = salla.config.get('page.id');
19
- this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
20
- this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
21
- this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
22
- this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
23
- this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
24
- this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
25
- this.thanks = salla.lang.get('pages.rating.thanks');
26
- this.back = salla.lang.get('common.elements.back');
27
- this.next = salla.lang.get('common.elements.next');
28
- Helper.setHost(document);
29
- salla.event.on('rating::open', () => this.open());
30
- salla.lang.onLoaded(() => {
31
- this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
32
- this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
33
- this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
34
- this.write_product_rate = salla.lang.get('pages.rating.write_product_rate');
35
- this.rate_shipping = salla.lang.get('pages.rating.rate_shipping');
36
- this.write_shipping_rate = salla.lang.get('pages.rating.write_shipping_rate');
37
- this.thanks = salla.lang.get('pages.rating.thanks');
38
- this.back = salla.lang.get('common.elements.back');
39
- this.next = salla.lang.get('common.elements.next');
40
- });
41
- }
42
- /**
43
- * Show the rating modal
44
- */
45
- async open() {
46
- return this.modal.open()
47
- .then(() => this.order || salla.rating.api.order(this.orderId).then(res => this.order = res.data))
48
- .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
49
- .then(() => this.modal.stopLoading())
50
- .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
51
- .then(() => setTimeout(() => this.handleWizard(), 100));
52
- }
53
- /**
54
- * Show the rating modal
55
- */
56
- async close() {
57
- return this.modal.close();
58
- }
59
- // handle wizard
60
- handleWizard() {
61
- this.steps = this.modal.querySelectorAll(".s-rating-modal-step");
62
- this.dots = this.modal.querySelectorAll(".s-rating-modal-step-dot");
63
- this.showActiveStep();
64
- }
65
- showActiveStep(current = null) {
66
- var _a;
67
- this.currentTab = current || this.steps[this.currentIndex];
68
- Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
69
- .toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
70
- if (this.currentIndex != 0) {
71
- // the animation
72
- Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
73
- setTimeout(() => Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
74
- }
75
- // Btn text
76
- let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
77
- this.nextBtn.setText(nextType ? salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.' + nextType)
78
- : salla.lang.get('pages.rating.send_ratings'));
79
- setTimeout(() => { var _a; return this.body.setAttribute('style', 'height:' + ((_a = this.currentTab) === null || _a === void 0 ? void 0 : _a.scrollHeight) + 'px'); });
80
- }
81
- previousTab() {
82
- this.currentIndex > 0 && this.currentIndex--;
83
- Helper.toggleElementClassIf(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
84
- this.showActiveStep();
85
- }
86
- submit() {
87
- this.submittedBefore() || this.validate();
88
- salla.config.canLeave = false;
89
- this.nextBtn.load()
90
- .then(() => this.submittedBefore() || this.sendFeedback())
91
- .then(() => this.currentTab.querySelectorAll('[name],.s-rating-modal-btn-star').forEach(el => el.setAttribute('disabled', '')))
92
- .then(() => this.currentIndex < this.stepsCount && this.currentIndex++)
93
- .then(() => this.showActiveStep())
94
- .then(() => Helper.toggleClassIf('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
95
- .finally(() => {
96
- this.nextBtn.stop();
97
- salla.config.canLeave = true;
98
- this.currentIndex == this.stepsCount && this.showThankYou();
99
- this.modal.isClosable = false;
100
- });
101
- }
102
- submittedBefore() {
103
- return this.submitted.includes(this.currentIndex);
104
- }
105
- validate(rating = null, type = null) {
106
- if (!rating && this.currentTab.dataset.type == 'products') {
107
- return this.currentTab.querySelectorAll('.rating-outer-form').forEach(rating => this.validate(rating, 'product'));
108
- }
109
- rating = rating || this.currentTab;
110
- let stars = rating.querySelector('.rating_hidden_input').value;
111
- let comment = rating.querySelector('.s-rating-modal-comment');
112
- let validationMessage = rating.querySelector('.s-rating-modal-validation-msg');
113
- if (stars && comment.value && comment.value.length > 3) {
114
- comment.classList.remove('s-has-error');
115
- validationMessage.innerHTML = '';
116
- return;
117
- }
118
- type = type || rating['dataset'].type;
119
- Helper.toggleElementClassIf(comment, 'save', 's-has-error', el => el.value.length > 3);
120
- throw validationMessage.innerHTML = stars
121
- ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
122
- : salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
123
- }
124
- sendFeedback() {
125
- let data = {};
126
- this.currentTab.querySelectorAll('[name]').forEach((input) => {
127
- //decode names like `<input name="jamal[inner]" value="hi">` to be {name:jamal, value: {inner:"hi"}}
128
- let inputData = salla.helpers.inputData(input.name, input.value, data);
129
- data[inputData.name] = inputData.value;
130
- });
131
- if (Object.keys(data).length == 0) {
132
- return;
133
- }
134
- data['order_id'] = this.orderId;
135
- data['type'] = this.currentTab.dataset.type;
136
- this.submitted.push(this.currentIndex);
137
- return salla.rating.api[this.currentTab.dataset.type](data);
138
- }
139
- showThankYou() {
140
- let seconds = 10;
141
- let timeToClose = setInterval(() => {
142
- this.thanksTime.innerHTML = '00:0' + (seconds--);
143
- if (seconds > 0) {
144
- return;
145
- }
146
- clearInterval(timeToClose);
147
- this.thanksTime.remove();
148
- this.close().then(() => window.location.reload());
149
- }, 1000);
150
- this.modal.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
151
- this.showActiveStep(this.thanksTab);
152
- }
153
- render() {
154
- return (h(Host, { id: "s-rating" }, h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, this.order
155
- ? [h("div", { class: "s-rating-modal-wrapper", ref: el => this.body = el }, this.order.testimonials_enabled ?
156
- h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "store" }, h("div", { class: "s-rating-modal-rounded-icon" }, h("img", { src: salla.config.get('store.logo', 'https://assets.salla.sa/cp/assets/images/logo-new.png'), alt: "store name", class: "s-rating-modal-store-logo" })), h("h2", { class: "s-rating-modal-title" }, this.rate_the_store), h("div", { class: "s-rating-modal-stars-company" }, h("salla-rating-stars", { size: "large" })), h("textarea", { id: "storeReview", name: "comment", class: "s-rating-modal-comment", placeholder: this.write_store_rate }), h("small", { class: "s-rating-modal-validation-msg" }))
157
- : '', this.order.products_enabled
158
- ? h("section", { class: "s-rating-modal-step s-rating-modal-hidden", "data-type": "products" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form s-rating-modal-product", "data-stars-error": this.rate_product_stars }, h("div", { class: "s-rating-modal-product-img-wrap" }, h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-modal-product-img" })), h("div", { class: "s-rating-modal-product-details" }, h("h3", { class: "s-rating-modal-product-title" }, " ", item.product.name), h("div", { class: "s-rating-modal-stars-product" }, h("salla-rating-stars", { size: "small", name: `products[${index}][rating]` })), h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.product.id }), h("textarea", { placeholder: this.write_product_rate, name: `products[${index}][comment]`, class: "s-rating-modal-comment" }), h("small", { class: "s-rating-modal-validation-msg" })))))
159
- : '', this.order.shipping_enabled
160
- ? h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "shipping" }, h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.company.id }), this.order.shipping.company.logo
161
- ? h("div", { class: "s-rating-modal-rounded-icon" }, h("img", { src: this.order.shipping.company.logo, class: "s-rating-modal-shipping-logo", alt: this.order.shipping.company.name }))
162
- : h("span", { class: "s-rating-modal-icon sicon-shipping-fast" }), h("div", { class: "s-rating-modal-title" }, " ", this.rate_shipping + ' ' + this.order.shipping.company.name), h("div", { class: "s-rating-modal-stars-company" }, h("salla-rating-stars", { size: "large" })), h("textarea", { name: "comment", class: "s-rating-modal-comment", placeholder: this.write_shipping_rate }), h("small", { class: "s-rating-modal-validation-msg" }))
163
- : '', h("div", { class: "s-rating-modal-thanks s-rating-modal-hidden", ref: el => this.thanksTab = el }, h("span", { class: "s-rating-modal-icon sicon-check-circle2" }), h("h3", { class: "s-rating-modal-thanks-title" }, this.thanks), h("div", { class: "s-rating-modal-thanks-msg", innerHTML: this.order.thanks_message }), h("time", { class: "s-rating-modal-thanks-time", ref: el => this.thanksTime = el }))), h("div", { class: "s-rating-modal-footer" }, h("button", { ref: el => this.backBtn = el, onClick: () => this.previousTab(), class: "s-rating-modal-btn s-rating-modal-unvisiable" }, this.back), this.stepsCount > 1 ? h("ul", { class: "s-rating-modal-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(() => h("li", { class: 's-rating-modal-bg-gray s-rating-modal-step-dot' }))) : '', h("salla-button", { "loader-position": 'center', ref: el => this.nextBtn = el, onClick: () => this.submit() }, this.next)),]
164
- : '')));
165
- }
166
- componentDidLoad() {
167
- salla.event.dispatch('rating::ready', this);
168
- }
169
- get host() { return getElement(this); }
170
- };
171
- SallaRatingModal.style = sallaRatingModalCss;
172
-
173
- export { SallaRatingModal as salla_rating_modal };
@@ -1,72 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import { r as registerInstance, h, H as Host, g as getElement } from './index-20b84fd0.js';
5
- import { H as Helper } from './Helper-e1d414a5.js';
6
-
7
- const sallaRatingStarsCss = "";
8
-
9
- const SallaRatingStars = class {
10
- constructor(hostRef) {
11
- registerInstance(this, hostRef);
12
- this.name = 'rating';
13
- this.size = 'medium';
14
- }
15
- initiateRating() {
16
- this.host.addEventListener('click', () => {
17
- if (!this.startsElem)
18
- return;
19
- // Get the selected star - activeElement is not supported in safari
20
- let activeStars = this.startsElem.querySelectorAll('.s-rating-stars-hovered');
21
- let selected = activeStars[activeStars.length - 1];
22
- if (!selected)
23
- return;
24
- let selectedIndex = selected.getAttribute('data-star');
25
- this.startsElem.querySelector('.rating_hidden_input').value = selectedIndex;
26
- // Loop through each star, and add or remove the `.selected` class to toggle highlighting
27
- this.startsElem.querySelectorAll('.s-rating-stars-btn-star')
28
- .forEach((star, index) => Helper.toggleElementClassIf(star, 's-rating-stars-selected', 's-rating-stars-unselected', () => index < parseInt(selectedIndex)));
29
- // update aria-pressed attr status
30
- this.startsElem.querySelectorAll('[aria-pressed]').forEach(star => star.removeAttribute('aria-pressed'));
31
- selected.setAttribute('aria-pressed', 'true');
32
- });
33
- }
34
- highlightSelectedStars() {
35
- var _a, _b;
36
- let hoveredClass = 's-rating-stars-hovered', stars = (_a = this.startsElem) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.s-rating-stars-btn-star');
37
- stars === null || stars === void 0 ? void 0 : stars.forEach((star, index) => {
38
- star.addEventListener('mouseover', () => {
39
- for (let i = 0; i <= index; i++) {
40
- stars[i].classList.add(hoveredClass);
41
- }
42
- });
43
- star.addEventListener('mouseout', () => star.classList.remove(hoveredClass));
44
- });
45
- (_b = this.startsElem) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseout', () => stars.forEach(star => star.classList.remove(hoveredClass)));
46
- }
47
- createStars(n) {
48
- let stars = [];
49
- for (let i = 0; i < 5; i++) {
50
- stars.push(h("span", { class: {
51
- 's-rating-stars-btn-star sicon-star2': true,
52
- ['s-rating-stars-' + this.size]: true,
53
- 's-rating-stars-selected': i < n
54
- } }));
55
- }
56
- return stars;
57
- }
58
- render() {
59
- return (h(Host, null, this.value ?
60
- h("div", { class: "s-rating-stars-wrapper" }, " ", this.createStars(this.value), " ")
61
- :
62
- h("div", { class: "s-rating-stars-element", ref: (el) => this.startsElem = el }, h("input", { type: "hidden", class: "rating_hidden_input", name: this.name, value: "" }), [1, 2, 3, 4, 5].map(star => h("button", { class: `s-rating-stars-btn-star s-rating-stars-` + this.size, "data-star": star }, h("i", { class: "sicon-star2" }))))));
63
- }
64
- componentDidLoad() {
65
- this.initiateRating();
66
- this.highlightSelectedStars();
67
- }
68
- get host() { return getElement(this); }
69
- };
70
- SallaRatingStars.style = sallaRatingStarsCss;
71
-
72
- export { SallaRatingStars as salla_rating_stars };
@@ -1,164 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-20b84fd0.js';
5
- import { H as Helper } from './Helper-e1d414a5.js';
6
-
7
- const sallaVerifyCss = "salla-verify{display:block}";
8
-
9
- const SallaVerify = class {
10
- constructor(hostRef) {
11
- registerInstance(this, hostRef);
12
- this.verified = createEvent(this, "verified", 7);
13
- this.initiated = false;
14
- /**
15
- * Should render component without modal
16
- */
17
- this.display = 'modal';
18
- /**
19
- * Verifying method
20
- */
21
- this.type = 'mobile';
22
- /**
23
- * should auto reloading the page after success verification
24
- */
25
- this.autoReload = true;
26
- this.resendAfter = 30;
27
- /**
28
- * to use: `salla.api.auth.verify` or `salla.profile.verify`
29
- */
30
- this.isProfileVerify = false;
31
- // Helper.setHost(this.host);
32
- salla.lang.onLoaded(() => {
33
- var _a, _b;
34
- this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + this.type);
35
- (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
36
- (_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('pages.profile.verify'));
37
- });
38
- if (this.display == 'inline') {
39
- this.modal = { open: () => '', close: () => '', setTitle: () => '' };
40
- return;
41
- }
42
- salla.event.on('profile::verification', data => {
43
- var _a;
44
- this.isProfileVerify = true;
45
- this.open(data);
46
- this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + data.type);
47
- (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
48
- });
49
- salla.event.on('modalClosed', () => {
50
- this.resendAfter = 0;
51
- this.timer.innerHTML = '30 : 00';
52
- });
53
- }
54
- /**
55
- * Get current code
56
- * @return {string}
57
- */
58
- async getCode() {
59
- return this.code.value;
60
- }
61
- /**
62
- * Open verifying modal
63
- * @param data
64
- */
65
- async open(data) {
66
- var _a;
67
- this.data = data;
68
- this.data.type = this.data.type || this.type;
69
- this.type = this.data.type;
70
- this.resendTimer();
71
- this.otpInputs = this.body.querySelectorAll('.s-verify-input');
72
- if (!this.initiated) {
73
- Helper.on('input', '.s-verify-input', e => salla.helpers.inputDigitsOnly(e.target));
74
- Helper.onKeyUp('.s-verify-input', event => {
75
- var _a, _b, _c, _d;
76
- let key = event.keyCode || event.charCode;
77
- if (event.target.value) {
78
- (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
79
- (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
80
- }
81
- else if ([8, 46].includes(key)) {
82
- (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
83
- (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
84
- }
85
- this.toggleOTPSubmit();
86
- });
87
- Helper.on('paste', '.s-verify-input', event => {
88
- let text = salla.helpers.number(event.clipboardData.getData('text')).replace(/[^0-9.]/g, '').replace('..', '.');
89
- this.otpInputs.forEach((input, i) => input.value = text[i] || '');
90
- this.toggleOTPSubmit();
91
- setTimeout(() => this.otpInputs[3].focus(), 100);
92
- });
93
- // return this.modal.open();
94
- this.initiated = true;
95
- }
96
- this.reset();
97
- this.display == 'modal' && ((_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title));
98
- this.modal.open();
99
- // focus the first input after opening the modal
100
- setTimeout(() => this.otpInputs[0].focus(), 100);
101
- }
102
- toggleOTPSubmit() {
103
- let otp = [];
104
- this.otpInputs.forEach(input => input.value && otp.push(input.value));
105
- this.code.value = otp.join('');
106
- if (otp.length === 4) {
107
- this.btn.removeAttribute('disabled');
108
- this.btn.click();
109
- return;
110
- }
111
- this.btn.setAttribute('disabled', '');
112
- }
113
- reset() {
114
- this.otpInputs.forEach((input) => input.value = '');
115
- this.code.value = '';
116
- this.otpInputs[0].focus();
117
- }
118
- resendTimer() {
119
- Helper.showElement(this.resendMessage).hideElement(this.resend);
120
- this.resendAfter = 30;
121
- let timerId = setInterval(() => {
122
- if (this.resendAfter <= 0) {
123
- clearInterval(timerId);
124
- Helper.hideElement(this.resendMessage).showElement(this.resend);
125
- }
126
- else {
127
- this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;
128
- this.resendAfter--;
129
- }
130
- }, 1000);
131
- }
132
- resendCode() {
133
- return this.btn.stop()
134
- .then(() => this.btn.disable())
135
- .then(() => {
136
- this.otpInputs.forEach(input => input.value = '');
137
- this.otpInputs[0].focus();
138
- })
139
- .then(() => salla.api.auth.resend(this.data))
140
- .finally(() => this.resendTimer());
141
- }
142
- submit() {
143
- let data = Object.assign({ code: this.code.value }, this.data);
144
- return this.btn.load()
145
- .then(() => this.btn.disable())
146
- .then(() => this.isProfileVerify ? salla.profile.verify(data) : salla.auth.verify(data, true))
147
- .then(response => this.verified.emit(response))
148
- .then(() => this.btn.stop() && this.btn.disable())
149
- .then(() => this.modal.close())
150
- .then(() => this.autoReload && window.location.reload())
151
- .catch(() => this.btn.stop() && this.btn.enable() && this.reset());
152
- }
153
- render() {
154
- return this.display == 'inline' ? h(Host, null, this.myBody()) :
155
- h("salla-modal", { icon: "sicon-android-phone", width: "xs", class: "s-verify", ref: modal => this.modal = modal, "modal-title": this.title }, this.myBody());
156
- }
157
- myBody() {
158
- return (h("div", { class: "s-verify-body", ref: body => this.body = body }, h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), 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", "loader-position": 'center', 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'))), h("slot", { name: "after-footer" })));
159
- }
160
- get host() { return getElement(this); }
161
- };
162
- SallaVerify.style = sallaVerifyCss;
163
-
164
- export { SallaVerify as salla_verify };
@@ -1,4 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{r as s,h as a,H as t,g as i}from"./p-c2bef5f2.js";import{H as l}from"./p-9d2ca9c8.js";const r=class{constructor(a){s(this,a),this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.orderId=salla.config.get("page.id"),this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next"),l.setHost(document),salla.event.on("rating::open",(()=>this.open())),salla.lang.onLoaded((()=>{this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next")}))}async open(){return this.modal.open().then((()=>this.order||salla.rating.api.order(this.orderId).then((s=>this.order=s.data)))).then((()=>this.modal.setTitle(salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.order.id+")</span>"))).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((s=>s)).length)).then((()=>setTimeout((()=>this.handleWizard()),100)))}async close(){return this.modal.close()}handleWizard(){this.steps=this.modal.querySelectorAll(".s-rating-modal-step"),this.dots=this.modal.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(s=null){var a;this.currentTab=s||this.steps[this.currentIndex],l.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(s=>s!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(s=>s==this.currentTab)),0!=this.currentIndex&&(l.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>l.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));let t=null===(a=this.steps[this.currentIndex+1])||void 0===a?void 0:a.dataset.type;this.nextBtn.setText(t?salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating."+t):salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>{var s;return this.body.setAttribute("style","height:"+(null===(s=this.currentTab)||void 0===s?void 0:s.scrollHeight)+"px")}))}previousTab(){this.currentIndex>0&&this.currentIndex--,l.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((s=>s.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>l.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&this.showThankYou(),this.modal.isClosable=!1}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(s=null,a=null){if(!s&&"products"==this.currentTab.dataset.type)return this.currentTab.querySelectorAll(".rating-outer-form").forEach((s=>this.validate(s,"product")));let t=(s=s||this.currentTab).querySelector(".rating_hidden_input").value,i=s.querySelector(".s-rating-modal-comment"),r=s.querySelector(".s-rating-modal-validation-msg");if(t&&i.value&&i.value.length>3)return i.classList.remove("s-has-error"),void(r.innerHTML="");throw a=a||s.dataset.type,l.toggleElementClassIf(i,"save","s-has-error",(s=>s.value.length>3)),r.innerHTML=t?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+i.getAttribute("placeholder"):salla.lang.get(`pages.rating.rate_${a}_stars`).replace(" (:item)","")}sendFeedback(){let s={};if(this.currentTab.querySelectorAll("[name]").forEach((a=>{let t=salla.helpers.inputData(a.name,a.value,s);s[t.name]=t.value})),0!=Object.keys(s).length)return s.order_id=this.orderId,s.type=this.currentTab.dataset.type,this.submitted.push(this.currentIndex),salla.rating.api[this.currentTab.dataset.type](s)}showThankYou(){let s=10,a=setInterval((()=>{this.thanksTime.innerHTML="00:0"+s--,s>0||(clearInterval(a),this.thanksTime.remove(),this.close().then((()=>window.location.reload())))}),1e3);this.modal.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}render(){return a(t,{id:"s-rating"},a("salla-modal",{isLoading:!0,width:"md",ref:s=>this.modal=s},this.order?[a("div",{class:"s-rating-modal-wrapper",ref:s=>this.body=s},this.order.testimonials_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),a("h2",{class:"s-rating-modal-title"},this.rate_the_store),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{id:"storeReview",name:"comment",class:"s-rating-modal-comment",placeholder:this.write_store_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?a("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((s,t)=>a("div",{class:"rating-outer-form s-rating-modal-product","data-stars-error":this.rate_product_stars},a("div",{class:"s-rating-modal-product-img-wrap"},a("img",{src:s.product.thumbnail,alt:s.product.name,class:"s-rating-modal-product-img"})),a("div",{class:"s-rating-modal-product-details"},a("h3",{class:"s-rating-modal-product-title"}," ",s.product.name),a("div",{class:"s-rating-modal-stars-product"},a("salla-rating-stars",{size:"small",name:`products[${t}][rating]`})),a("input",{type:"hidden",name:`products[${t}][product_id]`,value:s.product.id}),a("textarea",{placeholder:this.write_product_rate,name:`products[${t}][comment]`,class:"s-rating-modal-comment"}),a("small",{class:"s-rating-modal-validation-msg"})))))):"",this.order.shipping_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},a("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):a("span",{class:"s-rating-modal-icon sicon-shipping-fast"}),a("div",{class:"s-rating-modal-title"}," ",this.rate_shipping+" "+this.order.shipping.company.name),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:this.write_shipping_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",a("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:s=>this.thanksTab=s},a("span",{class:"s-rating-modal-icon sicon-check-circle2"}),a("h3",{class:"s-rating-modal-thanks-title"},this.thanks),a("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),a("time",{class:"s-rating-modal-thanks-time",ref:s=>this.thanksTime=s}))),a("div",{class:"s-rating-modal-footer"},a("button",{ref:s=>this.backBtn=s,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},this.back),this.stepsCount>1?a("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((()=>a("li",{class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",a("salla-button",{"loader-position":"center",ref:s=>this.nextBtn=s,onClick:()=>this.submit()},this.next))]:""))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};r.style="";export{r as salla_rating_modal}
@@ -1,4 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{r as s,c as i,h as t,H as e,g as l}from"./p-c2bef5f2.js";import{H as h}from"./p-9d2ca9c8.js";const a=class{constructor(t){s(this,t),this.verified=i(this,"verified",7),this.initiated=!1,this.display="modal",this.type="mobile",this.autoReload=!0,this.resendAfter=30,this.isProfileVerify=!1,salla.lang.onLoaded((()=>{var s,i;this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+this.type),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("pages.profile.verify"))})),"inline"!=this.display?(salla.event.on("profile::verification",(s=>{var i;this.isProfileVerify=!0,this.open(s),this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+s.type),null===(i=this.modal)||void 0===i||i.setTitle(this.title)})),salla.event.on("modalClosed",(()=>{this.resendAfter=0,this.timer.innerHTML="30 : 00"}))):this.modal={open:()=>"",close:()=>"",setTitle:()=>""}}async getCode(){return this.code.value}async open(s){var i;this.data=s,this.data.type=this.data.type||this.type,this.type=this.data.type,this.resendTimer(),this.otpInputs=this.body.querySelectorAll(".s-verify-input"),this.initiated||(h.on("input",".s-verify-input",(s=>salla.helpers.inputDigitsOnly(s.target))),h.onKeyUp(".s-verify-input",(s=>{var i,t,e,l;let h=s.keyCode||s.charCode;s.target.value?(null===(i=s.target.nextElementSibling)||void 0===i||i.focus(),null===(t=s.target.nextElementSibling)||void 0===t||t.select()):[8,46].includes(h)&&(null===(e=s.target.previousElementSibling)||void 0===e||e.focus(),null===(l=s.target.previousElementSibling)||void 0===l||l.select()),this.toggleOTPSubmit()})),h.on("paste",".s-verify-input",(s=>{let i=salla.helpers.number(s.clipboardData.getData("text")).replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((s,t)=>s.value=i[t]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.initiated=!0),this.reset(),"modal"==this.display&&(null===(i=this.modal)||void 0===i||i.setTitle(this.title)),this.modal.open(),setTimeout((()=>this.otpInputs[0].focus()),100)}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","")}reset(){this.otpInputs.forEach((s=>s.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){h.showElement(this.resendMessage).hideElement(this.resend),this.resendAfter=30;let s=setInterval((()=>{this.resendAfter<=0?(clearInterval(s),h.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${this.resendAfter>=10?this.resendAfter:"0"+this.resendAfter} : 00`,this.resendAfter--)}),1e3)}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(this.data))).finally((()=>this.resendTimer()))}submit(){let s=Object.assign({code:this.code.value},this.data);return this.btn.load().then((()=>this.btn.disable())).then((()=>this.isProfileVerify?salla.profile.verify(s):salla.auth.verify(s,!0))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.close())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()&&this.reset()))}render(){return"inline"==this.display?t(e,null,this.myBody()):t("salla-modal",{icon:"sicon-android-phone",width:"xs",class:"s-verify",ref:s=>this.modal=s,"modal-title":this.title},this.myBody())}myBody(){return t("div",{class:"s-verify-body",ref:s=>this.body=s},t("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),t("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:s=>this.code=s}),t("div",{class:"s-verify-codes",dir:"ltr"},[1,2,3,4].map((()=>t("input",{type:"text",maxlength:"1",class:"s-verify-input",required:!0})))),t("div",{slot:"footer",class:"s-verify-footer"},t("salla-button",{class:"s-verify-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:s=>this.btn=s},salla.lang.get("pages.profile.verify")),t("p",{class:"s-verify-resend-message",ref:s=>this.resendMessage=s},salla.lang.get("blocks.header.resend_after"),t("b",{class:"s-verify-timer",ref:s=>this.timer=s})),t("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:s=>this.resend=s},salla.lang.get("blocks.comments.submit"))),t("slot",{name:"after-footer"}))}get host(){return l(this)}};a.style="salla-verify{display:block}";export{a as salla_verify}
@@ -1,4 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{r as s,h as a,g as e}from"./p-c2bef5f2.js";const i=class{constructor(a){s(this,a),this.open=!0,this.isOpenedBefore=salla.storage.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?"s-branches-color-red":s.available?"s-branches-color-green":"s-branches-color-gray":this.currentBranch("limited")?"s-branches-color-red":this.currentBranch("available")?"s-branches-color-green":"s-branches-color-gray",this.isChoiceable=()=>"all"!==this.browseProductsFrom&&"single"==this.position||"header"==this.position,this.formTitle=()=>this.isChoiceable()?"توفر المنتج في الفروع الآخرى":"التسوق من فرع آخر",salla.event.on("branches::show",(s=>s.dataset.target==this.host.id&&this.show())),salla.lang.onLoaded((()=>{var s;return null===(s=this.btn)||void 0===s?void 0:s.setText(salla.lang.get("common.elements.ok"))}))}async show(){var s;return null===(s=this.modal)||void 0===s?void 0:s.open()}async hide(){var s;return null===(s=this.modal)||void 0===s?void 0:s.close()}handelChange(s){this.selected=s.target.value}handleSubmit(){this.btn.load().then((()=>{setTimeout((()=>location.reload()),2e3)})),salla.storage.set("branch-choosed-before",!0),this.show(),setTimeout((()=>{this.current=this.selected}),300)}render(){return a("salla-modal",{icon:"sicon-store-alt","modal-title":"فرع الرياض","sub-title":"أنت الآن تتصفح المتجر من","sub-title-first":!0,ref:s=>this.modal=s,width:"sm",id:"s-branches-modal",class:"s-hidden"},a("h4",{class:"s-branches-title"},this.formTitle()),this.branches.length<=5?a("div",{class:"s-branches-space-v"},this.branches.map((s=>a("div",{class:"s-branches-input-wrap"},a("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,"s-hidden":!this.isChoiceable()},checked:this.current==s.id}),a("label",{htmlFor:this.position+"_branch_"+s.id,class:{"s-branches-label":!0,"s-branches-clickable":this.isChoiceable()}},a("span",{class:{"s-branches-is-closed":!s.open}},s.name),this.isChoiceable()?a("small",{class:"s-branches-closed-badge"},s.open?"":"مُغلق"):a("span",{class:this.statusColor(s)},s.tag)))))):a("select",{class:"s-branches-select",onInput:s=>this.handelChange(s)},this.branches.map((s=>a("option",{value:s.id,disabled:!s.open,selected:this.selected==s.id},s.name," ",s.open?"":"- مُغلق")))),this.isChoiceable()?a("slot",{name:"footer"},a("salla-button",{ref:s=>this.btn=s,onClick:()=>this.handleSubmit(),class:"s-branches-submit",width:"wide"},salla.lang.get("common.elements.ok"))):"")}componentDidRender(){this.isOpenedBefore||"popup"!=this.displayAs||this.show()}get host(){return e(this)}};i.style="";export{i as salla_branches}