@salla.sa/twilight-components 1.6.1 → 1.6.2

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.
@@ -1,109 +1,14 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-4e30ffd0.js';
4
+ import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-4e30ffd0.js';
5
5
  import { H as Helper } from './Helper-e1d414a5.js';
6
6
  import { e as email } from './mail-9d5204c6.js';
7
7
  import { A as ArrowRightIcon } from './arrow-right-1c3e04f2.js';
8
8
  import { C as Cancel } from './cancel-41a92070.js';
9
9
  import { C as CheckCircle2 } from './check-circle2-f6e5f685.js';
10
- import { S as Star2 } from './star2-b134fc74.js';
11
10
  import { S as Search } from './search-19ea3313.js';
12
11
 
13
- const sallaAddProductButtonCss = ":host{display:block}salla-add-product-button[width=wide]{width:100%}";
14
-
15
- const SallaAddProductButton = class {
16
- constructor(hostRef) {
17
- registerInstance(this, hostRef);
18
- this.success = createEvent(this, "success", 7);
19
- this.failed = createEvent(this, "failed", 7);
20
- this.hostAttributes = {};
21
- this.hasLabel = false;
22
- /**
23
- * Channels.
24
- */
25
- this.channels = null;
26
- /**
27
- * Product Quantity
28
- */
29
- this.quantity = 0;
30
- /**
31
- * Donating amount.
32
- */
33
- this.donatingAmount = 0;
34
- /**
35
- * Product Status.Defaults to `sale`
36
- */
37
- this.productStatus = 'sale';
38
- /**
39
- * Product type. Defaults to `product`
40
- */
41
- this.productType = 'product';
42
- }
43
- getLabel() {
44
- if (this.productStatus === 'sale') {
45
- return salla.lang.get('pages.cart.add_to_cart');
46
- }
47
- if (this.productType !== 'donating') {
48
- return salla.lang.get('pages.products.out_of_stock');
49
- }
50
- // donating
51
- return salla.lang.get('pages.products.donation_exceed');
52
- }
53
- addProductToCart(event) {
54
- // we want to ignore the click action when the type of button is submit a form
55
- if (this.hostAttributes['type'] === 'submit') {
56
- return false;
57
- }
58
- event.preventDefault();
59
- /**
60
- * by default the quick add is just an alias for add item function
61
- * but its work only when the id is the only value is passed via the object
62
- * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action
63
- */
64
- const data = Object.entries({
65
- id: this.productId,
66
- donating_amount: this.donatingAmount,
67
- quantity: this.quantity
68
- }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
69
- return salla.cart.quickAdd(data)
70
- .then((response) => {
71
- return this.success.emit(response);
72
- })
73
- .catch((error) => {
74
- return this.failed.emit(error);
75
- });
76
- }
77
- getBtnAttributes() {
78
- for (let i = 0; i < this.host.attributes.length; i++) {
79
- if (!['id', 'class'].includes(this.host.attributes[i].name)) {
80
- this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
81
- }
82
- }
83
- return this.hostAttributes;
84
- }
85
- componentWillLoad() {
86
- this.hasLabel = !!this.host.innerHTML.replace('<!---->', '').trim();
87
- }
88
- render() {
89
- return (h(Host, null, this.productStatus === 'out-and-notify' && this.channels ?
90
- h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), h("slot", null)) :
91
- h("salla-button", Object.assign({ ref: el => this.btn = el, onClick: event => this.addProductToCart(event), type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', color: this.productStatus === 'sale' ? 'primary' : 'light', "loader-position": "center" }, this.getBtnAttributes(), { disabled: this.productStatus !== 'sale' }), h("slot", null))));
92
- }
93
- componentDidRender() {
94
- //if label not passed, get label
95
- if (this.hasLabel) {
96
- return;
97
- }
98
- this.btn.setText(this.getLabel() || 'اضافة للسلة');
99
- salla.lang.onLoaded(() => {
100
- this.btn.setText(this.getLabel() || 'اضافة للسلة');
101
- });
102
- }
103
- get host() { return getElement(this); }
104
- };
105
- SallaAddProductButton.style = sallaAddProductButtonCss;
106
-
107
12
  const sallaButtonCss = "";
108
13
 
109
14
  const SallaButton = class {
@@ -879,194 +784,6 @@ const SallaOfferModal = class {
879
784
  };
880
785
  SallaOfferModal.style = sallaOfferModalCss;
881
786
 
882
- const BellRingIcon = `<!-- Generated by IcoMoon.io -->
883
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
884
- <title>bell-ring</title>
885
- <path d="M2.667 13.333v-4c0-2.592 0.748-5.107 2.161-7.271 0.404-0.616 0.231-1.443-0.387-1.845-0.616-0.401-1.443-0.228-1.845 0.388-1.699 2.599-2.596 5.617-2.596 8.728v4c0 0.736 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333zM25.333 15.647v-6.313c0-5.147-4.188-9.333-9.333-9.333s-9.333 4.187-9.333 9.333v6.312l-5.157 9.027c-0.236 0.413-0.235 0.92 0.004 1.331 0.239 0.412 0.679 0.664 1.153 0.664h8c0 2.941 2.392 5.333 5.333 5.333s5.333-2.392 5.333-5.333h8c0.475 0 0.915-0.252 1.153-0.664 0.239-0.411 0.24-0.917 0.004-1.331zM16 29.333c-1.471 0-2.667-1.196-2.667-2.667h5.333c0 1.472-1.196 2.667-2.667 2.667zM4.965 24l4.193-7.339c0.113-0.2 0.175-0.429 0.175-0.661v-6.667c0-3.676 2.991-6.667 6.667-6.667s6.667 2.991 6.667 6.667v6.667c0 0.232 0.061 0.46 0.176 0.661l4.192 7.339zM29.403 0.603c-0.403-0.616-1.232-0.789-1.845-0.387-0.617 0.403-0.791 1.229-0.387 1.845 1.415 2.165 2.163 4.68 2.163 7.272v4c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-4c0-3.112-0.899-6.132-2.597-8.731z"></path>
886
- </svg>
887
- `;
888
-
889
- const sallaProductAvailabilityCss = "";
890
-
891
- const SallaProductAvailability = class {
892
- constructor(hostRef) {
893
- registerInstance(this, hostRef);
894
- this.isUser = Helper.isUser();
895
- this.translationLoaded = false;
896
- /**
897
- * product id that can visitor subscribe to its availability notification
898
- */
899
- this.productId = salla.config.get('page.id');
900
- /**
901
- * is current user already subscribed
902
- */
903
- this.isSubscribed = false;
904
- // @Method()
905
- this.submit = async () => {
906
- if (this.isUser) {
907
- return salla.api.product.availabilitySubscribe(this.productId)
908
- .then(() => this.isSubscribed = true);
909
- }
910
- let data = { id: this.productId };
911
- if (this.channels_.includes('sms')) {
912
- let { phone, countryCode } = await this.mobileInput.getValues();
913
- data['country_code'] = countryCode;
914
- data['phone'] = phone;
915
- }
916
- if (this.channels_.includes('email')) {
917
- this.email.value !== '' && (data['email'] = this.email.value);
918
- }
919
- await this.validateform();
920
- return this.btn.load()
921
- .then(() => this.btn.disable())
922
- .then(() => salla.api.product.availabilitySubscribe(data))
923
- .then(() => {
924
- this.isSubscribed = true;
925
- salla.storage.set(`product-${this.productId}-subscribed`, true);
926
- }) //no need to wait until finishing alert animation
927
- .then(() => this.btn.stop())
928
- .then(() => this.modal.close())
929
- .catch(() => this.btn.stop() && this.btn.enable());
930
- };
931
- // helpers
932
- this.typing = (e, submitMethod) => {
933
- const error = e.target.nextElementSibling;
934
- e.target.classList.remove('s-has-error');
935
- (error === null || error === void 0 ? void 0 : error.classList.contains('s-product-availability-error-msg')) && (error.innerText = '');
936
- e.key == 'Enter' && submitMethod();
937
- };
938
- salla.lang.onLoaded(() => {
939
- var _a;
940
- this.translationLoaded = true;
941
- this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
942
- (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title_);
943
- });
944
- if (this.isUser)
945
- return;
946
- this.channelsWatcher(this.channels);
947
- this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
948
- this.host.removeAttribute('title');
949
- this.isVisitorSubscribed = salla.storage.get(`product-${this.productId}-subscribed`);
950
- }
951
- channelsWatcher(newValue) {
952
- this.channels_ = !!newValue ? newValue.split(',') : [];
953
- }
954
- async validateform() {
955
- try {
956
- if (this.channels_.includes('email')) {
957
- const isEmailValid = Helper.isValidEmail(this.email.value);
958
- if (isEmailValid)
959
- return;
960
- !isEmailValid && this.validateField(this.email, salla.lang.get('common.elements.email_is_valid'));
961
- }
962
- if (this.channels_.includes('sms')) {
963
- const isPhoneValid = await this.mobileInput.isValid();
964
- if (isPhoneValid)
965
- return;
966
- }
967
- }
968
- catch (error) {
969
- throw ('Please insert required fields');
970
- }
971
- }
972
- validateField(field, errorMsg) {
973
- field.classList.add('s-has-error');
974
- field.nextElementSibling['innerText'] = '* ' + errorMsg;
975
- }
976
- render() {
977
- return (h(Host, { class: "s-product-availability-wrap" }, this.isSubscribed || this.isVisitorSubscribed
978
- ? h("div", { class: "s-product-availability-subscribed" }, h("span", { innerHTML: BellRingIcon, class: "s-product-availability-subs-icon" }), " ", salla.lang.get('pages.products.notify_availability_success'))
979
- :
980
- h("salla-button", { width: "wide", onClick: () => this.isUser ? this.submit() : this.modal.open() }, salla.lang.get('pages.products.notify_availability')), this.isUser || this.isSubscribed || this.isVisitorSubscribed ? '' : this.renderModal()));
981
- }
982
- renderModal() {
983
- return (h("salla-modal", { ref: modal => this.modal = modal, "modal-title": this.title_, subTitle: salla.lang.get('pages.products.notify_availability_subtitle'), width: "sm" }, h("span", { slot: 'icon', innerHTML: BellRingIcon }), h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
984
- h("label", { class: "s-product-availability-label" }, salla.lang.get('common.elements.email')),
985
- h("input", { class: "s-product-availability-input", onKeyDown: e => this.typing(e, this.submit), placeholder: salla.lang.get('common.elements.email_placeholder') || 'your@email.com', ref: el => this.email = el, type: "email" }),
986
- h("span", { class: "s-product-availability-error-msg" })
987
- ] : '', this.channels_.includes('sms') ? [
988
- h("label", { class: "s-product-availability-label" }, salla.lang.get('common.elements.mobile')),
989
- h("salla-tel-input", { ref: el => this.mobileInput = el, onKeyDown: e => this.typing(e, this.submit) })
990
- ] : ''), h("div", { slot: "footer", class: "s-product-availability-footer" }, h("salla-button", { class: "modal-cancel-btn", width: "wide", color: "light", fill: "outline", onClick: () => this.modal.close() }, salla.lang.get('common.elements.cancel')), h("salla-button", { class: "submit-btn", "loader-position": 'center', width: "wide", ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.submit')))));
991
- }
992
- get host() { return getElement(this); }
993
- static get watchers() { return {
994
- "channels": ["channelsWatcher"]
995
- }; }
996
- };
997
- SallaProductAvailability.style = sallaProductAvailabilityCss;
998
-
999
- const sallaRatingStarsCss = "";
1000
-
1001
- const SallaRatingStars = class {
1002
- constructor(hostRef) {
1003
- registerInstance(this, hostRef);
1004
- /**
1005
- * Sets input name.
1006
- */
1007
- this.name = 'rating';
1008
- /**
1009
- * Sets the height and width of the component. Defaults to medium.
1010
- */
1011
- this.size = 'medium';
1012
- }
1013
- initiateRating() {
1014
- this.host.addEventListener('click', () => {
1015
- if (!this.startsElem)
1016
- return;
1017
- // Get the selected star - activeElement is not supported in safari
1018
- let activeStars = this.startsElem.querySelectorAll('.s-rating-stars-hovered');
1019
- let selected = activeStars[activeStars.length - 1];
1020
- if (!selected)
1021
- return;
1022
- let selectedIndex = selected.getAttribute('data-star');
1023
- this.startsElem.querySelector('.rating_hidden_input').value = selectedIndex;
1024
- // Loop through each star, and add or remove the `.selected` class to toggle highlighting
1025
- this.startsElem.querySelectorAll('.s-rating-stars-btn-star')
1026
- .forEach((star, index) => Helper.toggleElementClassIf(star, 's-rating-stars-selected', 's-rating-stars-unselected', () => index < parseInt(selectedIndex)));
1027
- // update aria-pressed attr status
1028
- this.startsElem.querySelectorAll('[aria-pressed]').forEach(star => star.removeAttribute('aria-pressed'));
1029
- selected.setAttribute('aria-pressed', 'true');
1030
- });
1031
- }
1032
- highlightSelectedStars() {
1033
- var _a, _b;
1034
- let hoveredClass = 's-rating-stars-hovered', stars = (_a = this.startsElem) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.s-rating-stars-btn-star');
1035
- stars === null || stars === void 0 ? void 0 : stars.forEach((star, index) => {
1036
- star.addEventListener('mouseover', () => {
1037
- for (let i = 0; i <= index; i++) {
1038
- stars[i].classList.add(hoveredClass);
1039
- }
1040
- });
1041
- star.addEventListener('mouseout', () => star.classList.remove(hoveredClass));
1042
- });
1043
- (_b = this.startsElem) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseout', () => stars.forEach(star => star.classList.remove(hoveredClass)));
1044
- }
1045
- createStars(n) {
1046
- let stars = [];
1047
- for (let i = 0; i < 5; i++) {
1048
- stars.push(h("span", { class: {
1049
- 's-rating-stars-btn-star': true,
1050
- ['s-rating-stars-' + this.size]: true,
1051
- 's-rating-stars-selected': i < n
1052
- }, innerHTML: Star2 }));
1053
- }
1054
- return stars;
1055
- }
1056
- render() {
1057
- return (h(Host, null, this.value ?
1058
- h("div", { class: "s-rating-stars-wrapper" }, " ", this.createStars(this.value), " ")
1059
- :
1060
- 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("span", { innerHTML: Star2 }))))));
1061
- }
1062
- componentDidLoad() {
1063
- this.initiateRating();
1064
- this.highlightSelectedStars();
1065
- }
1066
- get host() { return getElement(this); }
1067
- };
1068
- SallaRatingStars.style = sallaRatingStarsCss;
1069
-
1070
787
  const sallaSearchCss = "";
1071
788
 
1072
789
  const SallaSearch = class {
@@ -2845,10 +2562,10 @@ const SallaVerify = class {
2845
2562
  h("salla-modal", { width: "xs", class: "s-verify", ref: modal => this.modal = modal, "modal-title": this.title }, h("span", { slot: 'icon', innerHTML: AndroidPhoneIcon }), this.myBody());
2846
2563
  }
2847
2564
  myBody() {
2848
- 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" })));
2565
+ 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: "number", 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" })));
2849
2566
  }
2850
2567
  get host() { return getElement(this); }
2851
2568
  };
2852
2569
  SallaVerify.style = sallaVerifyCss;
2853
2570
 
2854
- export { SallaAddProductButton as salla_add_product_button, SallaButton as salla_button, SallaLoading as salla_loading, SallaLocalizationModal as salla_localization_modal, SallaLoginModal as salla_login_modal, SallaModal as salla_modal, SallaOfferModal as salla_offer_modal, SallaProductAvailability as salla_product_availability, SallaRatingStars as salla_rating_stars, SallaSearch as salla_search, SallaSkeleton as salla_skeleton, SallaTelInput as salla_tel_input, SallaVerify as salla_verify };
2571
+ export { SallaButton as salla_button, SallaLoading as salla_loading, SallaLocalizationModal as salla_localization_modal, SallaLoginModal as salla_login_modal, SallaModal as salla_modal, SallaOfferModal as salla_offer_modal, SallaSearch as salla_search, SallaSkeleton as salla_skeleton, SallaTelInput as salla_tel_input, SallaVerify as salla_verify };
@@ -0,0 +1,124 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-4e30ffd0.js';
5
+ import { H as Helper } from './Helper-e1d414a5.js';
6
+
7
+ const BellRingIcon = `<!-- Generated by IcoMoon.io -->
8
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
9
+ <title>bell-ring</title>
10
+ <path d="M2.667 13.333v-4c0-2.592 0.748-5.107 2.161-7.271 0.404-0.616 0.231-1.443-0.387-1.845-0.616-0.401-1.443-0.228-1.845 0.388-1.699 2.599-2.596 5.617-2.596 8.728v4c0 0.736 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333zM25.333 15.647v-6.313c0-5.147-4.188-9.333-9.333-9.333s-9.333 4.187-9.333 9.333v6.312l-5.157 9.027c-0.236 0.413-0.235 0.92 0.004 1.331 0.239 0.412 0.679 0.664 1.153 0.664h8c0 2.941 2.392 5.333 5.333 5.333s5.333-2.392 5.333-5.333h8c0.475 0 0.915-0.252 1.153-0.664 0.239-0.411 0.24-0.917 0.004-1.331zM16 29.333c-1.471 0-2.667-1.196-2.667-2.667h5.333c0 1.472-1.196 2.667-2.667 2.667zM4.965 24l4.193-7.339c0.113-0.2 0.175-0.429 0.175-0.661v-6.667c0-3.676 2.991-6.667 6.667-6.667s6.667 2.991 6.667 6.667v6.667c0 0.232 0.061 0.46 0.176 0.661l4.192 7.339zM29.403 0.603c-0.403-0.616-1.232-0.789-1.845-0.387-0.617 0.403-0.791 1.229-0.387 1.845 1.415 2.165 2.163 4.68 2.163 7.272v4c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-4c0-3.112-0.899-6.132-2.597-8.731z"></path>
11
+ </svg>
12
+ `;
13
+
14
+ const sallaProductAvailabilityCss = "";
15
+
16
+ const SallaProductAvailability = class {
17
+ constructor(hostRef) {
18
+ registerInstance(this, hostRef);
19
+ this.isUser = Helper.isUser();
20
+ this.translationLoaded = false;
21
+ /**
22
+ * product id that can visitor subscribe to its availability notification
23
+ */
24
+ this.productId = salla.config.get('page.id');
25
+ /**
26
+ * is current user already subscribed
27
+ */
28
+ this.isSubscribed = false;
29
+ // @Method()
30
+ this.submit = async () => {
31
+ if (this.isUser) {
32
+ return salla.api.product.availabilitySubscribe(this.productId)
33
+ .then(() => this.isSubscribed = true);
34
+ }
35
+ let data = { id: this.productId };
36
+ if (this.channels_.includes('sms')) {
37
+ let { phone, countryCode } = await this.mobileInput.getValues();
38
+ data['country_code'] = countryCode;
39
+ data['phone'] = phone;
40
+ }
41
+ if (this.channels_.includes('email')) {
42
+ this.email.value !== '' && (data['email'] = this.email.value);
43
+ }
44
+ await this.validateform();
45
+ return this.btn.load()
46
+ .then(() => this.btn.disable())
47
+ .then(() => salla.api.product.availabilitySubscribe(data))
48
+ .then(() => {
49
+ this.isSubscribed = true;
50
+ salla.storage.set(`product-${this.productId}-subscribed`, true);
51
+ }) //no need to wait until finishing alert animation
52
+ .then(() => this.btn.stop())
53
+ .then(() => this.modal.close())
54
+ .catch(() => this.btn.stop() && this.btn.enable());
55
+ };
56
+ // helpers
57
+ this.typing = (e, submitMethod) => {
58
+ const error = e.target.nextElementSibling;
59
+ e.target.classList.remove('s-has-error');
60
+ (error === null || error === void 0 ? void 0 : error.classList.contains('s-product-availability-error-msg')) && (error.innerText = '');
61
+ e.key == 'Enter' && submitMethod();
62
+ };
63
+ salla.lang.onLoaded(() => {
64
+ var _a;
65
+ this.translationLoaded = true;
66
+ this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
67
+ (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title_);
68
+ });
69
+ if (this.isUser)
70
+ return;
71
+ this.channelsWatcher(this.channels);
72
+ this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
73
+ this.host.removeAttribute('title');
74
+ this.isVisitorSubscribed = salla.storage.get(`product-${this.productId}-subscribed`);
75
+ }
76
+ channelsWatcher(newValue) {
77
+ this.channels_ = !!newValue ? newValue.split(',') : [];
78
+ }
79
+ async validateform() {
80
+ try {
81
+ if (this.channels_.includes('email')) {
82
+ const isEmailValid = Helper.isValidEmail(this.email.value);
83
+ if (isEmailValid)
84
+ return;
85
+ !isEmailValid && this.validateField(this.email, salla.lang.get('common.elements.email_is_valid'));
86
+ }
87
+ if (this.channels_.includes('sms')) {
88
+ const isPhoneValid = await this.mobileInput.isValid();
89
+ if (isPhoneValid)
90
+ return;
91
+ }
92
+ }
93
+ catch (error) {
94
+ throw ('Please insert required fields');
95
+ }
96
+ }
97
+ validateField(field, errorMsg) {
98
+ field.classList.add('s-has-error');
99
+ field.nextElementSibling['innerText'] = '* ' + errorMsg;
100
+ }
101
+ render() {
102
+ return (h(Host, { class: "s-product-availability-wrap" }, this.isSubscribed || this.isVisitorSubscribed
103
+ ? h("div", { class: "s-product-availability-subscribed" }, h("span", { innerHTML: BellRingIcon, class: "s-product-availability-subs-icon" }), " ", salla.lang.get('pages.products.notify_availability_success'))
104
+ :
105
+ h("salla-button", { width: "wide", onClick: () => this.isUser ? this.submit() : this.modal.open() }, salla.lang.get('pages.products.notify_availability')), this.isUser || this.isSubscribed || this.isVisitorSubscribed ? '' : this.renderModal()));
106
+ }
107
+ renderModal() {
108
+ return (h("salla-modal", { ref: modal => this.modal = modal, "modal-title": this.title_, subTitle: salla.lang.get('pages.products.notify_availability_subtitle'), width: "sm" }, h("span", { slot: 'icon', innerHTML: BellRingIcon }), h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
109
+ h("label", { class: "s-product-availability-label" }, salla.lang.get('common.elements.email')),
110
+ h("input", { class: "s-product-availability-input", onKeyDown: e => this.typing(e, this.submit), placeholder: salla.lang.get('common.elements.email_placeholder') || 'your@email.com', ref: el => this.email = el, type: "email" }),
111
+ h("span", { class: "s-product-availability-error-msg" })
112
+ ] : '', this.channels_.includes('sms') ? [
113
+ h("label", { class: "s-product-availability-label" }, salla.lang.get('common.elements.mobile')),
114
+ h("salla-tel-input", { ref: el => this.mobileInput = el, onKeyDown: e => this.typing(e, this.submit) })
115
+ ] : ''), h("div", { slot: "footer", class: "s-product-availability-footer" }, h("salla-button", { class: "modal-cancel-btn", width: "wide", color: "light", fill: "outline", onClick: () => this.modal.close() }, salla.lang.get('common.elements.cancel')), h("salla-button", { class: "submit-btn", "loader-position": 'center', width: "wide", ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.submit')))));
116
+ }
117
+ get host() { return getElement(this); }
118
+ static get watchers() { return {
119
+ "channels": ["channelsWatcher"]
120
+ }; }
121
+ };
122
+ SallaProductAvailability.style = sallaProductAvailabilityCss;
123
+
124
+ export { SallaProductAvailability as salla_product_availability };
@@ -0,0 +1,79 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-4e30ffd0.js';
5
+ import { H as Helper } from './Helper-e1d414a5.js';
6
+ import { S as Star2 } from './star2-b134fc74.js';
7
+
8
+ const sallaRatingStarsCss = "";
9
+
10
+ const SallaRatingStars = class {
11
+ constructor(hostRef) {
12
+ registerInstance(this, hostRef);
13
+ /**
14
+ * Sets input name.
15
+ */
16
+ this.name = 'rating';
17
+ /**
18
+ * Sets the height and width of the component. Defaults to medium.
19
+ */
20
+ this.size = 'medium';
21
+ }
22
+ initiateRating() {
23
+ this.host.addEventListener('click', () => {
24
+ if (!this.startsElem)
25
+ return;
26
+ // Get the selected star - activeElement is not supported in safari
27
+ let activeStars = this.startsElem.querySelectorAll('.s-rating-stars-hovered');
28
+ let selected = activeStars[activeStars.length - 1];
29
+ if (!selected)
30
+ return;
31
+ let selectedIndex = selected.getAttribute('data-star');
32
+ this.startsElem.querySelector('.rating_hidden_input').value = selectedIndex;
33
+ // Loop through each star, and add or remove the `.selected` class to toggle highlighting
34
+ this.startsElem.querySelectorAll('.s-rating-stars-btn-star')
35
+ .forEach((star, index) => Helper.toggleElementClassIf(star, 's-rating-stars-selected', 's-rating-stars-unselected', () => index < parseInt(selectedIndex)));
36
+ // update aria-pressed attr status
37
+ this.startsElem.querySelectorAll('[aria-pressed]').forEach(star => star.removeAttribute('aria-pressed'));
38
+ selected.setAttribute('aria-pressed', 'true');
39
+ });
40
+ }
41
+ highlightSelectedStars() {
42
+ var _a, _b;
43
+ let hoveredClass = 's-rating-stars-hovered', stars = (_a = this.startsElem) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.s-rating-stars-btn-star');
44
+ stars === null || stars === void 0 ? void 0 : stars.forEach((star, index) => {
45
+ star.addEventListener('mouseover', () => {
46
+ for (let i = 0; i <= index; i++) {
47
+ stars[i].classList.add(hoveredClass);
48
+ }
49
+ });
50
+ star.addEventListener('mouseout', () => star.classList.remove(hoveredClass));
51
+ });
52
+ (_b = this.startsElem) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseout', () => stars.forEach(star => star.classList.remove(hoveredClass)));
53
+ }
54
+ createStars(n) {
55
+ let stars = [];
56
+ for (let i = 0; i < 5; i++) {
57
+ stars.push(h("span", { class: {
58
+ 's-rating-stars-btn-star': true,
59
+ ['s-rating-stars-' + this.size]: true,
60
+ 's-rating-stars-selected': i < n
61
+ }, innerHTML: Star2 }));
62
+ }
63
+ return stars;
64
+ }
65
+ render() {
66
+ return (h(Host, null, this.value ?
67
+ h("div", { class: "s-rating-stars-wrapper" }, " ", this.createStars(this.value), " ")
68
+ :
69
+ 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("span", { innerHTML: Star2 }))))));
70
+ }
71
+ componentDidLoad() {
72
+ this.initiateRating();
73
+ this.highlightSelectedStars();
74
+ }
75
+ get host() { return getElement(this); }
76
+ };
77
+ SallaRatingStars.style = sallaRatingStarsCss;
78
+
79
+ export { SallaRatingStars as salla_rating_stars };
@@ -16,5 +16,5 @@ const patchBrowser = () => {
16
16
  };
17
17
 
18
18
  patchBrowser().then(options => {
19
- return bootstrapLazy([["salla-loyalty",[[4,"salla-loyalty",{"prizePoints":[8,"prize-points"],"customerPoints":[2,"customer-points"],"prizeTitle":[1,"prize-title"],"allowEmail":[4,"allow-email"],"allowMobile":[4,"allow-mobile"],"requireEmail":[4,"require-email"],"guestMessage":[1,"guest-message"],"loyaltyProgram":[32],"buttonLoading":[32],"selectedItem":[32],"askConfirmation":[32],"is_loggedin":[32],"translationLoaded":[32],"open":[64],"close":[64],"resetExchange":[64],"exchangeLoyaltyPoint":[64]}]]],["salla-product-size-guide",[[4,"salla-product-size-guide",{"guides":[32],"productId":[32],"open":[64],"close":[64]}]]],["salla-scopes",[[4,"salla-scopes",{"selection":[1],"searchDisplayLimit":[2,"search-display-limit"],"translationLoaded":[32],"mode":[32],"current_scope":[32],"scopes":[32],"originalScopesList":[32],"selected_scope":[32],"isOpenedBefore":[32],"close":[64],"open":[64],"handleSubmit":[64]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"translationLoaded":[32],"open":[64],"close":[64]}]]],["salla-social-share",[[4,"salla-social-share",{"url":[513],"urlName":[513,"url-name"],"platforms":[16],"opened":[32],"allPlatforms":[32],"platformIcons":[32],"open":[64]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-tab-content_3",[[4,"salla-tab-content",{"name":[1],"isSelected":[32],"getChild":[64]}],[4,"salla-tab-header",{"name":[1],"activeClass":[1,"active-class"],"height":[8],"centered":[4],"isSelected":[32],"getChild":[64]}],[4,"salla-tabs",{"backgroundColor":[1,"background-color"],"vertical":[4]},[[0,"tabSelected","onSelectedTab"]]]]],["salla-add-product-button_13",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"]}],[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"translationLoaded":[32],"title":[32],"emailErrorMsg":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]],[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"translationLoaded":[32],"languages":[32],"currencies":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}],[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"translationLoaded":[32],"open":[64],"showOffer":[64]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"translationLoaded":[32],"results":[32],"loading":[32],"typing":[32],"debounce":[32],"search_term":[32]},[[0,"keydown","handleKeyDown"]]],[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"translationLoaded":[32],"title_":[32],"isVisitorSubscribed":[32]}],[4,"salla-verify",{"display":[1],"type":[1025],"autoReload":[4,"auto-reload"],"translationLoaded":[32],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}],[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[0,"salla-skeleton",{"type":[1],"width":[1],"height":[1]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"hasSkeleton":[516,"has-skeleton"],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"centered":[4],"iconStyle":[1,"icon-style"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[0,"salla-loading",{"size":[8],"width":[8],"color":[1],"bgColor":[1,"bg-color"]}]]],["salla-swiper",[[4,"salla-swiper",{"loop":[4],"speed":[2],"itemPerView":[8,"item-per-view"],"spaceBetweenItems":[2,"space-between-items"],"currentIndex":[32],"isLastSlideItem":[32],"isFirstSlideItem":[32]}]]],["salla-list-tile_2",[[4,"salla-list-tile",{"href":[1],"target":[1]}],[4,"salla-placeholder",{"icon":[1],"alignment":[1],"iconSize":[1,"icon-size"],"translationLoaded":[32]}]]]], options);
19
+ return bootstrapLazy([["salla-button_10",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"translationLoaded":[32],"title":[32],"emailErrorMsg":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"open":[64]},[[8,"verified","onVerified"]]],[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"translationLoaded":[32],"languages":[32],"currencies":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}],[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"translationLoaded":[32],"open":[64],"showOffer":[64]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"translationLoaded":[32],"results":[32],"loading":[32],"typing":[32],"debounce":[32],"search_term":[32]},[[0,"keydown","handleKeyDown"]]],[4,"salla-verify",{"display":[1],"type":[1025],"autoReload":[4,"auto-reload"],"translationLoaded":[32],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[0,"salla-skeleton",{"type":[1],"width":[1],"height":[1]}],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"hasSkeleton":[516,"has-skeleton"],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"centered":[4],"iconStyle":[1,"icon-style"],"modalTitle":[32],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}],[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[0,"salla-loading",{"size":[8],"width":[8],"color":[1],"bgColor":[1,"bg-color"]}]]],["salla-loyalty",[[4,"salla-loyalty",{"prizePoints":[8,"prize-points"],"customerPoints":[2,"customer-points"],"prizeTitle":[1,"prize-title"],"allowEmail":[4,"allow-email"],"allowMobile":[4,"allow-mobile"],"requireEmail":[4,"require-email"],"guestMessage":[1,"guest-message"],"loyaltyProgram":[32],"buttonLoading":[32],"selectedItem":[32],"askConfirmation":[32],"is_loggedin":[32],"translationLoaded":[32],"open":[64],"close":[64],"resetExchange":[64],"exchangeLoyaltyPoint":[64]}]]],["salla-product-size-guide",[[4,"salla-product-size-guide",{"guides":[32],"productId":[32],"open":[64],"close":[64]}]]],["salla-scopes",[[4,"salla-scopes",{"selection":[1],"searchDisplayLimit":[2,"search-display-limit"],"translationLoaded":[32],"mode":[32],"current_scope":[32],"scopes":[32],"originalScopesList":[32],"selected_scope":[32],"isOpenedBefore":[32],"close":[64],"open":[64],"handleSubmit":[64]}]]],["salla-add-product-button",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"]}]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"translationLoaded":[32],"open":[64],"close":[64]}]]],["salla-social-share",[[4,"salla-social-share",{"url":[513],"urlName":[513,"url-name"],"platforms":[16],"opened":[32],"allPlatforms":[32],"platformIcons":[32],"open":[64]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-product-availability",[[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"translationLoaded":[32],"title_":[32],"isVisitorSubscribed":[32]}]]],["salla-swiper",[[4,"salla-swiper",{"loop":[4],"speed":[2],"itemPerView":[8,"item-per-view"],"spaceBetweenItems":[2,"space-between-items"],"currentIndex":[32],"isLastSlideItem":[32],"isFirstSlideItem":[32]}]]],["salla-rating-stars",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]],["salla-list-tile_2",[[4,"salla-list-tile",{"href":[1],"target":[1]}],[4,"salla-placeholder",{"icon":[1],"alignment":[1],"iconSize":[1,"icon-size"],"translationLoaded":[32]}]]],["salla-tab-content_3",[[4,"salla-tab-content",{"name":[1],"isSelected":[32],"getChild":[64]}],[4,"salla-tab-header",{"name":[1],"activeClass":[1,"active-class"],"height":[8],"centered":[4],"isSelected":[32],"getChild":[64]}],[4,"salla-tabs",{"backgroundColor":[1,"background-color"],"vertical":[4]},[[0,"tabSelected","onSelectedTab"]]]]]], options);
20
20
  });
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as s,h as t,H as i,g as a}from"./p-1503d976.js";import{H as l}from"./p-9d2ca9c8.js";const e='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>bell-ring</title>\n<path d="M2.667 13.333v-4c0-2.592 0.748-5.107 2.161-7.271 0.404-0.616 0.231-1.443-0.387-1.845-0.616-0.401-1.443-0.228-1.845 0.388-1.699 2.599-2.596 5.617-2.596 8.728v4c0 0.736 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333zM25.333 15.647v-6.313c0-5.147-4.188-9.333-9.333-9.333s-9.333 4.187-9.333 9.333v6.312l-5.157 9.027c-0.236 0.413-0.235 0.92 0.004 1.331 0.239 0.412 0.679 0.664 1.153 0.664h8c0 2.941 2.392 5.333 5.333 5.333s5.333-2.392 5.333-5.333h8c0.475 0 0.915-0.252 1.153-0.664 0.239-0.411 0.24-0.917 0.004-1.331zM16 29.333c-1.471 0-2.667-1.196-2.667-2.667h5.333c0 1.472-1.196 2.667-2.667 2.667zM4.965 24l4.193-7.339c0.113-0.2 0.175-0.429 0.175-0.661v-6.667c0-3.676 2.991-6.667 6.667-6.667s6.667 2.991 6.667 6.667v6.667c0 0.232 0.061 0.46 0.176 0.661l4.192 7.339zM29.403 0.603c-0.403-0.616-1.232-0.789-1.845-0.387-0.617 0.403-0.791 1.229-0.387 1.845 1.415 2.165 2.163 4.68 2.163 7.272v4c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-4c0-3.112-0.899-6.132-2.597-8.731z"></path>\n</svg>\n',o=class{constructor(t){s(this,t),this.isUser=l.isUser(),this.translationLoaded=!1,this.productId=salla.config.get("page.id"),this.isSubscribed=!1,this.submit=async()=>{if(this.isUser)return salla.api.product.availabilitySubscribe(this.productId).then((()=>this.isSubscribed=!0));let s={id:this.productId};if(this.channels_.includes("sms")){let{phone:t,countryCode:i}=await this.mobileInput.getValues();s.country_code=i,s.phone=t}return this.channels_.includes("email")&&""!==this.email.value&&(s.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(s))).then((()=>{this.isSubscribed=!0,salla.storage.set(`product-${this.productId}-subscribed`,!0)})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))},this.typing=(s,t)=>{const i=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==i?void 0:i.classList.contains("s-product-availability-error-msg"))&&(i.innerText=""),"Enter"==s.key&&t()},salla.lang.onLoaded((()=>{var s;this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),null===(s=this.modal)||void 0===s||s.setTitle(this.title_)})),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"),this.isVisitorSubscribed=salla.storage.get(`product-${this.productId}-subscribed`))}channelsWatcher(s){this.channels_=s?s.split(","):[]}async validateform(){try{if(this.channels_.includes("email")){const s=l.isValidEmail(this.email.value);if(s)return;!s&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if(this.channels_.includes("sms")&&await this.mobileInput.isValid())return}catch(s){throw"Please insert required fields"}}validateField(s,t){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+t}render(){return t(i,{class:"s-product-availability-wrap"},this.isSubscribed||this.isVisitorSubscribed?t("div",{class:"s-product-availability-subscribed"},t("span",{innerHTML:e,class:"s-product-availability-subs-icon"})," ",salla.lang.get("pages.products.notify_availability_success")):t("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.modal.open()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribed||this.isVisitorSubscribed?"":this.renderModal())}renderModal(){return t("salla-modal",{ref:s=>this.modal=s,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},t("span",{slot:"icon",innerHTML:e}),t("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[t("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),t("input",{class:"s-product-availability-input",onKeyDown:s=>this.typing(s,this.submit),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:s=>this.email=s,type:"email"}),t("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")?[t("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),t("salla-tel-input",{ref:s=>this.mobileInput=s,onKeyDown:s=>this.typing(s,this.submit)})]:""),t("div",{slot:"footer",class:"s-product-availability-footer"},t("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),t("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:s=>this.btn=s,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return a(this)}static get watchers(){return{channels:["channelsWatcher"]}}};o.style="";export{o as salla_product_availability}