@salla.sa/twilight-components 1.0.100 → 1.0.107

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