@salla.sa/twilight-components 1.6.2 → 1.6.3

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 (67) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-button_24.cjs.entry.js +10087 -0
  3. package/dist/cjs/twilight-components.cjs.js +1 -1
  4. package/dist/collection/components/salla-login-modal/salla-login-modal.js +3 -4
  5. package/dist/collection/components/salla-verify/salla-verify.js +1 -1
  6. package/dist/components/salla-login-modal.js +3 -4
  7. package/dist/components/salla-verify2.js +1 -1
  8. package/dist/esm/loader.js +1 -1
  9. package/dist/esm/salla-button_24.entry.js +10060 -0
  10. package/dist/esm/twilight-components.js +1 -1
  11. package/dist/twilight-components/p-30b2c5b0.entry.js +4 -0
  12. package/dist/twilight-components/twilight-components.esm.js +1 -1
  13. package/package.json +9 -3
  14. package/dist/cjs/Helper-8ae6a805.js +0 -28
  15. package/dist/cjs/arrow-right-3d137e4c.js +0 -13
  16. package/dist/cjs/cancel-ae668d91.js +0 -13
  17. package/dist/cjs/check-circle2-1aac98d1.js +0 -13
  18. package/dist/cjs/mail-2db058ee.js +0 -13
  19. package/dist/cjs/salla-button_10.cjs.entry.js +0 -2584
  20. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +0 -93
  21. package/dist/cjs/salla-list-tile_2.cjs.entry.js +0 -80
  22. package/dist/cjs/salla-loyalty.cjs.entry.js +0 -229
  23. package/dist/cjs/salla-product-availability.cjs.entry.js +0 -128
  24. package/dist/cjs/salla-product-size-guide.cjs.entry.js +0 -52
  25. package/dist/cjs/salla-quantity-input.cjs.entry.js +0 -101
  26. package/dist/cjs/salla-rating-modal.cjs.entry.js +0 -169
  27. package/dist/cjs/salla-rating-stars.cjs.entry.js +0 -83
  28. package/dist/cjs/salla-social-share.cjs.entry.js +0 -1447
  29. package/dist/cjs/salla-swiper.cjs.entry.js +0 -5023
  30. package/dist/cjs/salla-tab-content_3.cjs.entry.js +0 -159
  31. package/dist/cjs/star2-8288e6e1.js +0 -13
  32. package/dist/esm/Helper-e1d414a5.js +0 -26
  33. package/dist/esm/arrow-right-1c3e04f2.js +0 -11
  34. package/dist/esm/cancel-41a92070.js +0 -11
  35. package/dist/esm/check-circle2-f6e5f685.js +0 -11
  36. package/dist/esm/mail-9d5204c6.js +0 -11
  37. package/dist/esm/salla-button_10.entry.js +0 -2571
  38. package/dist/esm/salla-infinite-scroll.entry.js +0 -89
  39. package/dist/esm/salla-list-tile_2.entry.js +0 -75
  40. package/dist/esm/salla-loyalty.entry.js +0 -225
  41. package/dist/esm/salla-product-availability.entry.js +0 -124
  42. package/dist/esm/salla-product-size-guide.entry.js +0 -48
  43. package/dist/esm/salla-quantity-input.entry.js +0 -97
  44. package/dist/esm/salla-rating-modal.entry.js +0 -165
  45. package/dist/esm/salla-rating-stars.entry.js +0 -79
  46. package/dist/esm/salla-social-share.entry.js +0 -1443
  47. package/dist/esm/salla-swiper.entry.js +0 -5019
  48. package/dist/esm/salla-tab-content_3.entry.js +0 -153
  49. package/dist/esm/star2-b134fc74.js +0 -11
  50. package/dist/twilight-components/p-0d498694.entry.js +0 -4
  51. package/dist/twilight-components/p-14f0ff17.entry.js +0 -4
  52. package/dist/twilight-components/p-335abbbb.entry.js +0 -4
  53. package/dist/twilight-components/p-4cafb11b.entry.js +0 -4
  54. package/dist/twilight-components/p-5e63e308.entry.js +0 -4
  55. package/dist/twilight-components/p-648e74e5.entry.js +0 -4
  56. package/dist/twilight-components/p-6a3adf55.entry.js +0 -4
  57. package/dist/twilight-components/p-6da4bb74.entry.js +0 -4
  58. package/dist/twilight-components/p-897b2018.js +0 -4
  59. package/dist/twilight-components/p-93708e1e.js +0 -4
  60. package/dist/twilight-components/p-9d236cf4.entry.js +0 -4
  61. package/dist/twilight-components/p-9d2ca9c8.js +0 -4
  62. package/dist/twilight-components/p-af7d5660.js +0 -4
  63. package/dist/twilight-components/p-bdbd2386.entry.js +0 -4
  64. package/dist/twilight-components/p-cac3db69.entry.js +0 -4
  65. package/dist/twilight-components/p-d914a212.js +0 -4
  66. package/dist/twilight-components/p-dace8e6d.js +0 -4
  67. package/dist/twilight-components/p-f9253fda.entry.js +0 -4
@@ -1,101 +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-0d0167d5.js');
9
- const Helper = require('./Helper-8ae6a805.js');
10
-
11
- const Add = `<!-- Generated by IcoMoon.io -->
12
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
13
- <title>add</title>
14
- <path d="M26.667 14.667h-9.333v-9.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v9.333h-9.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h9.333v9.333c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-9.333h9.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333z"></path>
15
- </svg>
16
- `;
17
-
18
- const Minus = `<!-- Generated by IcoMoon.io -->
19
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
20
- <title>minus</title>
21
- <path d="M26.667 14.667h-21.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h21.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333z"></path>
22
- </svg>
23
- `;
24
-
25
- const sallaQuantityInputCss = "";
26
-
27
- const SallaQuantityInput = class {
28
- constructor(hostRef) {
29
- index.registerInstance(this, hostRef);
30
- this.hostAttributes = {};
31
- this.hasIncrementSlot = false;
32
- this.hasDecrementSlot = false;
33
- this.didLoaded = false;
34
- this.quantity = 1;
35
- }
36
- /**
37
- * Workaround to fire change event for the input.
38
- */
39
- watchPropHandler() {
40
- if (!this.didLoaded) {
41
- return;
42
- }
43
- Helper.Helper.debounce(() => salla.document.event.fireEvent(this.textInput, 'change', { 'bubbles': true }));
44
- }
45
- componentWillLoad() {
46
- this.quantity = parseInt(this.host.getAttribute('value')) || 1;
47
- this.hasIncrementSlot = !!this.host.querySelector('[slot="increment-button"]');
48
- this.hasDecrementSlot = !!this.host.querySelector('[slot="decrement-button"]');
49
- }
50
- componentDidLoad() {
51
- this.didLoaded = true;
52
- this.textInput.addEventListener('input', (event) => salla.helpers.inputDigitsOnly(event.target));
53
- }
54
- getInputAttributes() {
55
- for (let i = 0; i < this.host.attributes.length; i++) {
56
- if (!['id', 'value', 'min', 'class'].includes(this.host.attributes[i].name)) {
57
- this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
58
- }
59
- }
60
- return this.hostAttributes;
61
- }
62
- /**
63
- * decrease quantity by one.
64
- * @return HTMLSallaQuantityInputElement
65
- */
66
- async decrease() {
67
- return this.setValue(this.quantity - 1);
68
- }
69
- /**
70
- * increase quantity by one.
71
- * @return HTMLSallaQuantityInputElement
72
- */
73
- async increase() {
74
- return this.setValue(Number(this.quantity) + 1);
75
- }
76
- /**
77
- * set quantity by one.
78
- * @return HTMLSallaQuantityInputElement
79
- */
80
- async setValue(value) {
81
- let maxQuantity = parseInt(this.host.getAttribute('max'));
82
- if (maxQuantity && value > maxQuantity) {
83
- value = maxQuantity;
84
- }
85
- if (value <= 1) {
86
- value = 1;
87
- }
88
- this.quantity = value;
89
- return this.host;
90
- }
91
- render() {
92
- return (index.h(index.Host, { class: "s-quantity-input" }, index.h("div", { class: "s-quantity-input-container" }, index.h("button", { onClick: () => this.increase(), class: "s-quantity-input-increase-button s-quantity-input-button", type: "button" }, !this.hasIncrementSlot ? index.h("span", { innerHTML: Add }) : '', index.h("slot", { name: "increment-button" })), index.h("input", Object.assign({ class: "s-quantity-input-input" }, this.getInputAttributes(), { ref: (el) => this.textInput = el, onInput: (event) => this.setValue(event.target.value), min: "1", value: this.quantity })), index.h("button", { class: "s-quantity-input-decrease-button s-quantity-input-button", onClick: () => this.decrease(), type: "button" }, !this.hasDecrementSlot ? index.h("span", { innerHTML: Minus }) : '', index.h("slot", { name: "decrement-button" })))));
93
- }
94
- get host() { return index.getElement(this); }
95
- static get watchers() { return {
96
- "quantity": ["watchPropHandler"]
97
- }; }
98
- };
99
- SallaQuantityInput.style = sallaQuantityInputCss;
100
-
101
- exports.salla_quantity_input = SallaQuantityInput;
@@ -1,169 +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-0d0167d5.js');
9
- const Helper = require('./Helper-8ae6a805.js');
10
- const checkCircle2 = require('./check-circle2-1aac98d1.js');
11
-
12
- const ShippingFast = `<!-- Generated by IcoMoon.io -->
13
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
14
- <title>shipping-fast</title>
15
- <path d="M10.667 14.667c0-0.737-0.597-1.333-1.333-1.333h-8c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h8c0.736 0 1.333-0.596 1.333-1.333zM9.333 18.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM9.333 26.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667zM1.333 10.667h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333zM31.123 13.103l-3.147-3.935c-1.273-1.589-3.171-2.501-5.205-2.501h-1.437c0-2.205-1.795-4-4-4h-13.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h13.333c0.735 0 1.333 0.597 1.333 1.333v1.333c0 0.248 0.087 0.468 0.204 0.667-0.117 0.199-0.204 0.419-0.204 0.667v5.333c0 0.737 0.597 1.333 1.333 1.333h9.333v6.667h-1.333c-0.063 0-0.117 0.028-0.179 0.036-0.583-2.313-2.664-4.036-5.155-4.036-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333c2.491 0 4.572-1.723 5.155-4.036 0.061 0.008 0.116 0.036 0.179 0.036h2.667c0.736 0 1.333-0.596 1.333-1.333v-8.399c0-0.905-0.311-1.792-0.877-2.499zM21.333 13.333v-4h1.437c1.221 0 2.36 0.547 3.124 1.501l1.997 2.499zM22.667 26.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>
16
- </svg>
17
- `;
18
-
19
- const sallaRatingModalCss = "";
20
-
21
- const SallaRatingModal = class {
22
- constructor(hostRef) {
23
- index.registerInstance(this, hostRef);
24
- this.stepsCount = 0;
25
- this.currentIndex = 0;
26
- this.submitted = [];
27
- /**
28
- * The order id, to rate on its products & shipping
29
- */
30
- this.orderId = salla.config.get('page.id');
31
- this.translationLoaded = false;
32
- Helper.Helper.setHost(document);
33
- salla.event.on('rating::open', () => this.open());
34
- salla.lang.onLoaded(() => {
35
- this.translationLoaded = true;
36
- });
37
- }
38
- /**
39
- * Show the rating modal
40
- */
41
- async open() {
42
- return this.modal.open()
43
- .then(() => this.order || salla.rating.api.order(this.orderId).then(res => this.order = res.data))
44
- .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
45
- .then(() => this.modal.stopLoading())
46
- .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
47
- .then(() => setTimeout(() => this.handleWizard(), 100));
48
- }
49
- /**
50
- * Show the rating modal
51
- */
52
- async close() {
53
- return this.modal.close();
54
- }
55
- // handle wizard
56
- handleWizard() {
57
- this.steps = this.modal.querySelectorAll(".s-rating-modal-step");
58
- this.dots = this.modal.querySelectorAll(".s-rating-modal-step-dot");
59
- this.showActiveStep();
60
- }
61
- showActiveStep(current = null) {
62
- var _a;
63
- this.currentTab = current || this.steps[this.currentIndex];
64
- Helper.Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
65
- .toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
66
- if (this.currentIndex != 0) {
67
- // the animation
68
- Helper.Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
69
- setTimeout(() => Helper.Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
70
- }
71
- // Btn text
72
- let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
73
- this.nextBtn.setText(nextType ? salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.' + nextType)
74
- : salla.lang.get('pages.rating.send_ratings'));
75
- setTimeout(() => { var _a; return this.body.setAttribute('style', 'height:' + ((_a = this.currentTab) === null || _a === void 0 ? void 0 : _a.scrollHeight) + 'px'); });
76
- }
77
- previousTab() {
78
- this.currentIndex > 0 && this.currentIndex--;
79
- Helper.Helper.toggleElementClassIf(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
80
- this.showActiveStep();
81
- }
82
- submit() {
83
- this.submittedBefore() || this.validate();
84
- salla.config.canLeave = false;
85
- this.nextBtn.load()
86
- .then(() => this.submittedBefore() || this.sendFeedback())
87
- .then(() => this.currentTab.querySelectorAll('[name],.s-rating-modal-btn-star').forEach(el => el.setAttribute('disabled', '')))
88
- .then(() => this.currentIndex < this.stepsCount && this.currentIndex++)
89
- .then(() => this.showActiveStep())
90
- .then(() => Helper.Helper.toggleClassIf('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
91
- .finally(() => {
92
- this.nextBtn.stop();
93
- salla.config.canLeave = true;
94
- this.currentIndex == this.stepsCount && this.showThankYou();
95
- this.modal.isClosable = false;
96
- });
97
- }
98
- submittedBefore() {
99
- return this.submitted.includes(this.currentIndex);
100
- }
101
- validate(rating = null, type = null) {
102
- if (!rating && this.currentTab.dataset.type == 'products') {
103
- return this.currentTab.querySelectorAll('.rating-outer-form').forEach(rating => this.validate(rating, 'product'));
104
- }
105
- rating = rating || this.currentTab;
106
- let stars = rating.querySelector('.rating_hidden_input').value;
107
- let comment = rating.querySelector('.s-rating-modal-comment');
108
- let validationMessage = rating.querySelector('.s-rating-modal-validation-msg');
109
- if (stars && comment.value && comment.value.length > 3) {
110
- comment.classList.remove('s-has-error');
111
- validationMessage.innerHTML = '';
112
- return;
113
- }
114
- type = type || rating['dataset'].type;
115
- Helper.Helper.toggleElementClassIf(comment, 'save', 's-has-error', el => el.value.length > 3);
116
- throw validationMessage.innerHTML = stars
117
- ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
118
- : salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
119
- }
120
- sendFeedback() {
121
- let data = {};
122
- this.currentTab.querySelectorAll('[name]').forEach((input) => {
123
- //decode names like `<input name="jamal[inner]" value="hi">` to be {name:jamal, value: {inner:"hi"}}
124
- let inputData = salla.helpers.inputData(input.name, input.value, data);
125
- data[inputData.name] = inputData.value;
126
- });
127
- if (Object.keys(data).length == 0) {
128
- return;
129
- }
130
- data['order_id'] = this.orderId;
131
- data['type'] = this.currentTab.dataset.type;
132
- this.submitted.push(this.currentIndex);
133
- return salla.rating.api[this.currentTab.dataset.type](data);
134
- }
135
- showThankYou() {
136
- let seconds = 10;
137
- let timeToClose = setInterval(() => {
138
- this.thanksTime.innerHTML = '00:0' + (seconds--);
139
- if (seconds > 0) {
140
- return;
141
- }
142
- clearInterval(timeToClose);
143
- this.thanksTime.remove();
144
- this.close().then(() => window.location.reload());
145
- }, 1000);
146
- this.modal.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
147
- this.showActiveStep(this.thanksTab);
148
- }
149
- render() {
150
- return (index.h(index.Host, { class: "s-rating" }, index.h("salla-modal", { isLoading: true, width: "md", ref: modal => this.modal = modal }, this.order
151
- ? [index.h("div", { class: "s-rating-modal-wrapper", ref: el => this.body = el }, this.order.testimonials_enabled ?
152
- 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" }, salla.lang.get('pages.rating.rate_the_store')), 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: salla.lang.get('pages.rating.write_store_rate') }), index.h("small", { class: "s-rating-modal-validation-msg" }))
153
- : '', this.order.products_enabled
154
- ? 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": salla.lang.get('pages.rating.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: salla.lang.get('pages.rating.write_product_rate'), name: `products[${index$1}][comment]`, class: "s-rating-modal-comment" }), index.h("small", { class: "s-rating-modal-validation-msg" })))))
155
- : '', this.order.shipping_enabled
156
- ? 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
157
- ? 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 }))
158
- : index.h("span", { class: "s-rating-modal-icon", innerHTML: ShippingFast }), index.h("div", { class: "s-rating-modal-title" }, " ", salla.lang.get('pages.rating.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: salla.lang.get('pages.rating.write_shipping_rate') }), index.h("small", { class: "s-rating-modal-validation-msg" }))
159
- : '', 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", innerHTML: checkCircle2.CheckCircle2 }), index.h("h3", { class: "s-rating-modal-thanks-title" }, salla.lang.get('pages.rating.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" }, salla.lang.get('common.elements.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() }, salla.lang.get('common.elements.next'))),]
160
- : '')));
161
- }
162
- componentDidLoad() {
163
- salla.event.dispatch('rating::ready', this);
164
- }
165
- get host() { return index.getElement(this); }
166
- };
167
- SallaRatingModal.style = sallaRatingModalCss;
168
-
169
- exports.salla_rating_modal = SallaRatingModal;
@@ -1,83 +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-0d0167d5.js');
9
- const Helper = require('./Helper-8ae6a805.js');
10
- const star2 = require('./star2-8288e6e1.js');
11
-
12
- const sallaRatingStarsCss = "";
13
-
14
- const SallaRatingStars = class {
15
- constructor(hostRef) {
16
- index.registerInstance(this, hostRef);
17
- /**
18
- * Sets input name.
19
- */
20
- this.name = 'rating';
21
- /**
22
- * Sets the height and width of the component. Defaults to medium.
23
- */
24
- this.size = 'medium';
25
- }
26
- initiateRating() {
27
- this.host.addEventListener('click', () => {
28
- if (!this.startsElem)
29
- return;
30
- // Get the selected star - activeElement is not supported in safari
31
- let activeStars = this.startsElem.querySelectorAll('.s-rating-stars-hovered');
32
- let selected = activeStars[activeStars.length - 1];
33
- if (!selected)
34
- return;
35
- let selectedIndex = selected.getAttribute('data-star');
36
- this.startsElem.querySelector('.rating_hidden_input').value = selectedIndex;
37
- // Loop through each star, and add or remove the `.selected` class to toggle highlighting
38
- this.startsElem.querySelectorAll('.s-rating-stars-btn-star')
39
- .forEach((star, index) => Helper.Helper.toggleElementClassIf(star, 's-rating-stars-selected', 's-rating-stars-unselected', () => index < parseInt(selectedIndex)));
40
- // update aria-pressed attr status
41
- this.startsElem.querySelectorAll('[aria-pressed]').forEach(star => star.removeAttribute('aria-pressed'));
42
- selected.setAttribute('aria-pressed', 'true');
43
- });
44
- }
45
- highlightSelectedStars() {
46
- var _a, _b;
47
- let hoveredClass = 's-rating-stars-hovered', stars = (_a = this.startsElem) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.s-rating-stars-btn-star');
48
- stars === null || stars === void 0 ? void 0 : stars.forEach((star, index) => {
49
- star.addEventListener('mouseover', () => {
50
- for (let i = 0; i <= index; i++) {
51
- stars[i].classList.add(hoveredClass);
52
- }
53
- });
54
- star.addEventListener('mouseout', () => star.classList.remove(hoveredClass));
55
- });
56
- (_b = this.startsElem) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseout', () => stars.forEach(star => star.classList.remove(hoveredClass)));
57
- }
58
- createStars(n) {
59
- let stars = [];
60
- for (let i = 0; i < 5; i++) {
61
- stars.push(index.h("span", { class: {
62
- 's-rating-stars-btn-star': true,
63
- ['s-rating-stars-' + this.size]: true,
64
- 's-rating-stars-selected': i < n
65
- }, innerHTML: star2.Star2 }));
66
- }
67
- return stars;
68
- }
69
- render() {
70
- return (index.h(index.Host, null, this.value ?
71
- index.h("div", { class: "s-rating-stars-wrapper" }, " ", this.createStars(this.value), " ")
72
- :
73
- 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("span", { innerHTML: star2.Star2 }))))));
74
- }
75
- componentDidLoad() {
76
- this.initiateRating();
77
- this.highlightSelectedStars();
78
- }
79
- get host() { return index.getElement(this); }
80
- };
81
- SallaRatingStars.style = sallaRatingStarsCss;
82
-
83
- exports.salla_rating_stars = SallaRatingStars;