@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.
@@ -17,7 +17,7 @@ const patchEsm = () => {
17
17
  const defineCustomElements = (win, options) => {
18
18
  if (typeof window === 'undefined') return Promise.resolve();
19
19
  return patchEsm().then(() => {
20
- return index.bootstrapLazy([["salla-loyalty.cjs",[[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.cjs",[[4,"salla-product-size-guide",{"guides":[32],"productId":[32],"open":[64],"close":[64]}]]],["salla-scopes.cjs",[[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.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"translationLoaded":[32],"open":[64],"close":[64]}]]],["salla-social-share.cjs",[[4,"salla-social-share",{"url":[513],"urlName":[513,"url-name"],"platforms":[16],"opened":[32],"allPlatforms":[32],"platformIcons":[32],"open":[64]}]]],["salla-conditional-fields.cjs",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment.cjs",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-tab-content_3.cjs",[[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.cjs",[[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.cjs",[[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.cjs",[[4,"salla-list-tile",{"href":[1],"target":[1]}],[4,"salla-placeholder",{"icon":[1],"alignment":[1],"iconSize":[1,"icon-size"],"translationLoaded":[32]}]]]], options);
20
+ return index.bootstrapLazy([["salla-button_10.cjs",[[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.cjs",[[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.cjs",[[4,"salla-product-size-guide",{"guides":[32],"productId":[32],"open":[64],"close":[64]}]]],["salla-scopes.cjs",[[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.cjs",[[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.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"translationLoaded":[32],"open":[64],"close":[64]}]]],["salla-social-share.cjs",[[4,"salla-social-share",{"url":[513],"urlName":[513,"url-name"],"platforms":[16],"opened":[32],"allPlatforms":[32],"platformIcons":[32],"open":[64]}]]],["salla-conditional-fields.cjs",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment.cjs",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-product-availability.cjs",[[0,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"translationLoaded":[32],"title_":[32],"isVisitorSubscribed":[32]}]]],["salla-swiper.cjs",[[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.cjs",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]],["salla-list-tile_2.cjs",[[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.cjs",[[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);
21
21
  });
22
22
  };
23
23
 
@@ -0,0 +1,104 @@
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
+
10
+ const sallaAddProductButtonCss = ":host{display:block}salla-add-product-button[width=wide]{width:100%}";
11
+
12
+ const SallaAddProductButton = class {
13
+ constructor(hostRef) {
14
+ index.registerInstance(this, hostRef);
15
+ this.success = index.createEvent(this, "success", 7);
16
+ this.failed = index.createEvent(this, "failed", 7);
17
+ this.hostAttributes = {};
18
+ this.hasLabel = false;
19
+ /**
20
+ * Channels.
21
+ */
22
+ this.channels = null;
23
+ /**
24
+ * Product Quantity
25
+ */
26
+ this.quantity = 0;
27
+ /**
28
+ * Donating amount.
29
+ */
30
+ this.donatingAmount = 0;
31
+ /**
32
+ * Product Status.Defaults to `sale`
33
+ */
34
+ this.productStatus = 'sale';
35
+ /**
36
+ * Product type. Defaults to `product`
37
+ */
38
+ this.productType = 'product';
39
+ }
40
+ getLabel() {
41
+ if (this.productStatus === 'sale') {
42
+ return salla.lang.get('pages.cart.add_to_cart');
43
+ }
44
+ if (this.productType !== 'donating') {
45
+ return salla.lang.get('pages.products.out_of_stock');
46
+ }
47
+ // donating
48
+ return salla.lang.get('pages.products.donation_exceed');
49
+ }
50
+ addProductToCart(event) {
51
+ // we want to ignore the click action when the type of button is submit a form
52
+ if (this.hostAttributes['type'] === 'submit') {
53
+ return false;
54
+ }
55
+ event.preventDefault();
56
+ /**
57
+ * by default the quick add is just an alias for add item function
58
+ * but its work only when the id is the only value is passed via the object
59
+ * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action
60
+ */
61
+ const data = Object.entries({
62
+ id: this.productId,
63
+ donating_amount: this.donatingAmount,
64
+ quantity: this.quantity
65
+ }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
66
+ return salla.cart.quickAdd(data)
67
+ .then((response) => {
68
+ return this.success.emit(response);
69
+ })
70
+ .catch((error) => {
71
+ return this.failed.emit(error);
72
+ });
73
+ }
74
+ getBtnAttributes() {
75
+ for (let i = 0; i < this.host.attributes.length; i++) {
76
+ if (!['id', 'class'].includes(this.host.attributes[i].name)) {
77
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
78
+ }
79
+ }
80
+ return this.hostAttributes;
81
+ }
82
+ componentWillLoad() {
83
+ this.hasLabel = !!this.host.innerHTML.replace('<!---->', '').trim();
84
+ }
85
+ render() {
86
+ return (index.h(index.Host, null, this.productStatus === 'out-and-notify' && this.channels ?
87
+ index.h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), index.h("slot", null)) :
88
+ index.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' }), index.h("slot", null))));
89
+ }
90
+ componentDidRender() {
91
+ //if label not passed, get label
92
+ if (this.hasLabel) {
93
+ return;
94
+ }
95
+ this.btn.setText(this.getLabel() || 'اضافة للسلة');
96
+ salla.lang.onLoaded(() => {
97
+ this.btn.setText(this.getLabel() || 'اضافة للسلة');
98
+ });
99
+ }
100
+ get host() { return index.getElement(this); }
101
+ };
102
+ SallaAddProductButton.style = sallaAddProductButtonCss;
103
+
104
+ exports.salla_add_product_button = SallaAddProductButton;
@@ -11,103 +11,8 @@ const mail = require('./mail-2db058ee.js');
11
11
  const arrowRight = require('./arrow-right-3d137e4c.js');
12
12
  const cancel = require('./cancel-ae668d91.js');
13
13
  const checkCircle2 = require('./check-circle2-1aac98d1.js');
14
- const star2 = require('./star2-8288e6e1.js');
15
14
  const search = require('./search-b487cc49.js');
16
15
 
17
- const sallaAddProductButtonCss = ":host{display:block}salla-add-product-button[width=wide]{width:100%}";
18
-
19
- const SallaAddProductButton = class {
20
- constructor(hostRef) {
21
- index.registerInstance(this, hostRef);
22
- this.success = index.createEvent(this, "success", 7);
23
- this.failed = index.createEvent(this, "failed", 7);
24
- this.hostAttributes = {};
25
- this.hasLabel = false;
26
- /**
27
- * Channels.
28
- */
29
- this.channels = null;
30
- /**
31
- * Product Quantity
32
- */
33
- this.quantity = 0;
34
- /**
35
- * Donating amount.
36
- */
37
- this.donatingAmount = 0;
38
- /**
39
- * Product Status.Defaults to `sale`
40
- */
41
- this.productStatus = 'sale';
42
- /**
43
- * Product type. Defaults to `product`
44
- */
45
- this.productType = 'product';
46
- }
47
- getLabel() {
48
- if (this.productStatus === 'sale') {
49
- return salla.lang.get('pages.cart.add_to_cart');
50
- }
51
- if (this.productType !== 'donating') {
52
- return salla.lang.get('pages.products.out_of_stock');
53
- }
54
- // donating
55
- return salla.lang.get('pages.products.donation_exceed');
56
- }
57
- addProductToCart(event) {
58
- // we want to ignore the click action when the type of button is submit a form
59
- if (this.hostAttributes['type'] === 'submit') {
60
- return false;
61
- }
62
- event.preventDefault();
63
- /**
64
- * by default the quick add is just an alias for add item function
65
- * but its work only when the id is the only value is passed via the object
66
- * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action
67
- */
68
- const data = Object.entries({
69
- id: this.productId,
70
- donating_amount: this.donatingAmount,
71
- quantity: this.quantity
72
- }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
73
- return salla.cart.quickAdd(data)
74
- .then((response) => {
75
- return this.success.emit(response);
76
- })
77
- .catch((error) => {
78
- return this.failed.emit(error);
79
- });
80
- }
81
- getBtnAttributes() {
82
- for (let i = 0; i < this.host.attributes.length; i++) {
83
- if (!['id', 'class'].includes(this.host.attributes[i].name)) {
84
- this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
85
- }
86
- }
87
- return this.hostAttributes;
88
- }
89
- componentWillLoad() {
90
- this.hasLabel = !!this.host.innerHTML.replace('<!---->', '').trim();
91
- }
92
- render() {
93
- return (index.h(index.Host, null, this.productStatus === 'out-and-notify' && this.channels ?
94
- index.h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), index.h("slot", null)) :
95
- index.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' }), index.h("slot", null))));
96
- }
97
- componentDidRender() {
98
- //if label not passed, get label
99
- if (this.hasLabel) {
100
- return;
101
- }
102
- this.btn.setText(this.getLabel() || 'اضافة للسلة');
103
- salla.lang.onLoaded(() => {
104
- this.btn.setText(this.getLabel() || 'اضافة للسلة');
105
- });
106
- }
107
- get host() { return index.getElement(this); }
108
- };
109
- SallaAddProductButton.style = sallaAddProductButtonCss;
110
-
111
16
  const sallaButtonCss = "";
112
17
 
113
18
  const SallaButton = class {
@@ -883,194 +788,6 @@ const SallaOfferModal = class {
883
788
  };
884
789
  SallaOfferModal.style = sallaOfferModalCss;
885
790
 
886
- const BellRingIcon = `<!-- Generated by IcoMoon.io -->
887
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
888
- <title>bell-ring</title>
889
- <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>
890
- </svg>
891
- `;
892
-
893
- const sallaProductAvailabilityCss = "";
894
-
895
- const SallaProductAvailability = class {
896
- constructor(hostRef) {
897
- index.registerInstance(this, hostRef);
898
- this.isUser = Helper.Helper.isUser();
899
- this.translationLoaded = false;
900
- /**
901
- * product id that can visitor subscribe to its availability notification
902
- */
903
- this.productId = salla.config.get('page.id');
904
- /**
905
- * is current user already subscribed
906
- */
907
- this.isSubscribed = false;
908
- // @Method()
909
- this.submit = async () => {
910
- if (this.isUser) {
911
- return salla.api.product.availabilitySubscribe(this.productId)
912
- .then(() => this.isSubscribed = true);
913
- }
914
- let data = { id: this.productId };
915
- if (this.channels_.includes('sms')) {
916
- let { phone, countryCode } = await this.mobileInput.getValues();
917
- data['country_code'] = countryCode;
918
- data['phone'] = phone;
919
- }
920
- if (this.channels_.includes('email')) {
921
- this.email.value !== '' && (data['email'] = this.email.value);
922
- }
923
- await this.validateform();
924
- return this.btn.load()
925
- .then(() => this.btn.disable())
926
- .then(() => salla.api.product.availabilitySubscribe(data))
927
- .then(() => {
928
- this.isSubscribed = true;
929
- salla.storage.set(`product-${this.productId}-subscribed`, true);
930
- }) //no need to wait until finishing alert animation
931
- .then(() => this.btn.stop())
932
- .then(() => this.modal.close())
933
- .catch(() => this.btn.stop() && this.btn.enable());
934
- };
935
- // helpers
936
- this.typing = (e, submitMethod) => {
937
- const error = e.target.nextElementSibling;
938
- e.target.classList.remove('s-has-error');
939
- (error === null || error === void 0 ? void 0 : error.classList.contains('s-product-availability-error-msg')) && (error.innerText = '');
940
- e.key == 'Enter' && submitMethod();
941
- };
942
- salla.lang.onLoaded(() => {
943
- var _a;
944
- this.translationLoaded = true;
945
- this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
946
- (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title_);
947
- });
948
- if (this.isUser)
949
- return;
950
- this.channelsWatcher(this.channels);
951
- this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
952
- this.host.removeAttribute('title');
953
- this.isVisitorSubscribed = salla.storage.get(`product-${this.productId}-subscribed`);
954
- }
955
- channelsWatcher(newValue) {
956
- this.channels_ = !!newValue ? newValue.split(',') : [];
957
- }
958
- async validateform() {
959
- try {
960
- if (this.channels_.includes('email')) {
961
- const isEmailValid = Helper.Helper.isValidEmail(this.email.value);
962
- if (isEmailValid)
963
- return;
964
- !isEmailValid && this.validateField(this.email, salla.lang.get('common.elements.email_is_valid'));
965
- }
966
- if (this.channels_.includes('sms')) {
967
- const isPhoneValid = await this.mobileInput.isValid();
968
- if (isPhoneValid)
969
- return;
970
- }
971
- }
972
- catch (error) {
973
- throw ('Please insert required fields');
974
- }
975
- }
976
- validateField(field, errorMsg) {
977
- field.classList.add('s-has-error');
978
- field.nextElementSibling['innerText'] = '* ' + errorMsg;
979
- }
980
- render() {
981
- return (index.h(index.Host, { class: "s-product-availability-wrap" }, this.isSubscribed || this.isVisitorSubscribed
982
- ? index.h("div", { class: "s-product-availability-subscribed" }, index.h("span", { innerHTML: BellRingIcon, class: "s-product-availability-subs-icon" }), " ", salla.lang.get('pages.products.notify_availability_success'))
983
- :
984
- index.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()));
985
- }
986
- renderModal() {
987
- return (index.h("salla-modal", { ref: modal => this.modal = modal, "modal-title": this.title_, subTitle: salla.lang.get('pages.products.notify_availability_subtitle'), width: "sm" }, index.h("span", { slot: 'icon', innerHTML: BellRingIcon }), index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
988
- index.h("label", { class: "s-product-availability-label" }, salla.lang.get('common.elements.email')),
989
- index.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" }),
990
- index.h("span", { class: "s-product-availability-error-msg" })
991
- ] : '', this.channels_.includes('sms') ? [
992
- index.h("label", { class: "s-product-availability-label" }, salla.lang.get('common.elements.mobile')),
993
- index.h("salla-tel-input", { ref: el => this.mobileInput = el, onKeyDown: e => this.typing(e, this.submit) })
994
- ] : ''), index.h("div", { slot: "footer", class: "s-product-availability-footer" }, index.h("salla-button", { class: "modal-cancel-btn", width: "wide", color: "light", fill: "outline", onClick: () => this.modal.close() }, salla.lang.get('common.elements.cancel')), index.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')))));
995
- }
996
- get host() { return index.getElement(this); }
997
- static get watchers() { return {
998
- "channels": ["channelsWatcher"]
999
- }; }
1000
- };
1001
- SallaProductAvailability.style = sallaProductAvailabilityCss;
1002
-
1003
- const sallaRatingStarsCss = "";
1004
-
1005
- const SallaRatingStars = class {
1006
- constructor(hostRef) {
1007
- index.registerInstance(this, hostRef);
1008
- /**
1009
- * Sets input name.
1010
- */
1011
- this.name = 'rating';
1012
- /**
1013
- * Sets the height and width of the component. Defaults to medium.
1014
- */
1015
- this.size = 'medium';
1016
- }
1017
- initiateRating() {
1018
- this.host.addEventListener('click', () => {
1019
- if (!this.startsElem)
1020
- return;
1021
- // Get the selected star - activeElement is not supported in safari
1022
- let activeStars = this.startsElem.querySelectorAll('.s-rating-stars-hovered');
1023
- let selected = activeStars[activeStars.length - 1];
1024
- if (!selected)
1025
- return;
1026
- let selectedIndex = selected.getAttribute('data-star');
1027
- this.startsElem.querySelector('.rating_hidden_input').value = selectedIndex;
1028
- // Loop through each star, and add or remove the `.selected` class to toggle highlighting
1029
- this.startsElem.querySelectorAll('.s-rating-stars-btn-star')
1030
- .forEach((star, index) => Helper.Helper.toggleElementClassIf(star, 's-rating-stars-selected', 's-rating-stars-unselected', () => index < parseInt(selectedIndex)));
1031
- // update aria-pressed attr status
1032
- this.startsElem.querySelectorAll('[aria-pressed]').forEach(star => star.removeAttribute('aria-pressed'));
1033
- selected.setAttribute('aria-pressed', 'true');
1034
- });
1035
- }
1036
- highlightSelectedStars() {
1037
- var _a, _b;
1038
- let hoveredClass = 's-rating-stars-hovered', stars = (_a = this.startsElem) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.s-rating-stars-btn-star');
1039
- stars === null || stars === void 0 ? void 0 : stars.forEach((star, index) => {
1040
- star.addEventListener('mouseover', () => {
1041
- for (let i = 0; i <= index; i++) {
1042
- stars[i].classList.add(hoveredClass);
1043
- }
1044
- });
1045
- star.addEventListener('mouseout', () => star.classList.remove(hoveredClass));
1046
- });
1047
- (_b = this.startsElem) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseout', () => stars.forEach(star => star.classList.remove(hoveredClass)));
1048
- }
1049
- createStars(n) {
1050
- let stars = [];
1051
- for (let i = 0; i < 5; i++) {
1052
- stars.push(index.h("span", { class: {
1053
- 's-rating-stars-btn-star': true,
1054
- ['s-rating-stars-' + this.size]: true,
1055
- 's-rating-stars-selected': i < n
1056
- }, innerHTML: star2.Star2 }));
1057
- }
1058
- return stars;
1059
- }
1060
- render() {
1061
- return (index.h(index.Host, null, this.value ?
1062
- index.h("div", { class: "s-rating-stars-wrapper" }, " ", this.createStars(this.value), " ")
1063
- :
1064
- 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 }))))));
1065
- }
1066
- componentDidLoad() {
1067
- this.initiateRating();
1068
- this.highlightSelectedStars();
1069
- }
1070
- get host() { return index.getElement(this); }
1071
- };
1072
- SallaRatingStars.style = sallaRatingStarsCss;
1073
-
1074
791
  const sallaSearchCss = "";
1075
792
 
1076
793
  const SallaSearch = class {
@@ -2849,21 +2566,18 @@ const SallaVerify = class {
2849
2566
  index.h("salla-modal", { width: "xs", class: "s-verify", ref: modal => this.modal = modal, "modal-title": this.title }, index.h("span", { slot: 'icon', innerHTML: AndroidPhoneIcon }), this.myBody());
2850
2567
  }
2851
2568
  myBody() {
2852
- 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" })));
2569
+ 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: "number", 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" })));
2853
2570
  }
2854
2571
  get host() { return index.getElement(this); }
2855
2572
  };
2856
2573
  SallaVerify.style = sallaVerifyCss;
2857
2574
 
2858
- exports.salla_add_product_button = SallaAddProductButton;
2859
2575
  exports.salla_button = SallaButton;
2860
2576
  exports.salla_loading = SallaLoading;
2861
2577
  exports.salla_localization_modal = SallaLocalizationModal;
2862
2578
  exports.salla_login_modal = SallaLoginModal;
2863
2579
  exports.salla_modal = SallaModal;
2864
2580
  exports.salla_offer_modal = SallaOfferModal;
2865
- exports.salla_product_availability = SallaProductAvailability;
2866
- exports.salla_rating_stars = SallaRatingStars;
2867
2581
  exports.salla_search = SallaSearch;
2868
2582
  exports.salla_skeleton = SallaSkeleton;
2869
2583
  exports.salla_tel_input = SallaTelInput;
@@ -0,0 +1,128 @@
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 BellRingIcon = `<!-- 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>bell-ring</title>
14
+ <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>
15
+ </svg>
16
+ `;
17
+
18
+ const sallaProductAvailabilityCss = "";
19
+
20
+ const SallaProductAvailability = class {
21
+ constructor(hostRef) {
22
+ index.registerInstance(this, hostRef);
23
+ this.isUser = Helper.Helper.isUser();
24
+ this.translationLoaded = false;
25
+ /**
26
+ * product id that can visitor subscribe to its availability notification
27
+ */
28
+ this.productId = salla.config.get('page.id');
29
+ /**
30
+ * is current user already subscribed
31
+ */
32
+ this.isSubscribed = false;
33
+ // @Method()
34
+ this.submit = async () => {
35
+ if (this.isUser) {
36
+ return salla.api.product.availabilitySubscribe(this.productId)
37
+ .then(() => this.isSubscribed = true);
38
+ }
39
+ let data = { id: this.productId };
40
+ if (this.channels_.includes('sms')) {
41
+ let { phone, countryCode } = await this.mobileInput.getValues();
42
+ data['country_code'] = countryCode;
43
+ data['phone'] = phone;
44
+ }
45
+ if (this.channels_.includes('email')) {
46
+ this.email.value !== '' && (data['email'] = this.email.value);
47
+ }
48
+ await this.validateform();
49
+ return this.btn.load()
50
+ .then(() => this.btn.disable())
51
+ .then(() => salla.api.product.availabilitySubscribe(data))
52
+ .then(() => {
53
+ this.isSubscribed = true;
54
+ salla.storage.set(`product-${this.productId}-subscribed`, true);
55
+ }) //no need to wait until finishing alert animation
56
+ .then(() => this.btn.stop())
57
+ .then(() => this.modal.close())
58
+ .catch(() => this.btn.stop() && this.btn.enable());
59
+ };
60
+ // helpers
61
+ this.typing = (e, submitMethod) => {
62
+ const error = e.target.nextElementSibling;
63
+ e.target.classList.remove('s-has-error');
64
+ (error === null || error === void 0 ? void 0 : error.classList.contains('s-product-availability-error-msg')) && (error.innerText = '');
65
+ e.key == 'Enter' && submitMethod();
66
+ };
67
+ salla.lang.onLoaded(() => {
68
+ var _a;
69
+ this.translationLoaded = true;
70
+ this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
71
+ (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title_);
72
+ });
73
+ if (this.isUser)
74
+ return;
75
+ this.channelsWatcher(this.channels);
76
+ this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
77
+ this.host.removeAttribute('title');
78
+ this.isVisitorSubscribed = salla.storage.get(`product-${this.productId}-subscribed`);
79
+ }
80
+ channelsWatcher(newValue) {
81
+ this.channels_ = !!newValue ? newValue.split(',') : [];
82
+ }
83
+ async validateform() {
84
+ try {
85
+ if (this.channels_.includes('email')) {
86
+ const isEmailValid = Helper.Helper.isValidEmail(this.email.value);
87
+ if (isEmailValid)
88
+ return;
89
+ !isEmailValid && this.validateField(this.email, salla.lang.get('common.elements.email_is_valid'));
90
+ }
91
+ if (this.channels_.includes('sms')) {
92
+ const isPhoneValid = await this.mobileInput.isValid();
93
+ if (isPhoneValid)
94
+ return;
95
+ }
96
+ }
97
+ catch (error) {
98
+ throw ('Please insert required fields');
99
+ }
100
+ }
101
+ validateField(field, errorMsg) {
102
+ field.classList.add('s-has-error');
103
+ field.nextElementSibling['innerText'] = '* ' + errorMsg;
104
+ }
105
+ render() {
106
+ return (index.h(index.Host, { class: "s-product-availability-wrap" }, this.isSubscribed || this.isVisitorSubscribed
107
+ ? index.h("div", { class: "s-product-availability-subscribed" }, index.h("span", { innerHTML: BellRingIcon, class: "s-product-availability-subs-icon" }), " ", salla.lang.get('pages.products.notify_availability_success'))
108
+ :
109
+ index.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()));
110
+ }
111
+ renderModal() {
112
+ return (index.h("salla-modal", { ref: modal => this.modal = modal, "modal-title": this.title_, subTitle: salla.lang.get('pages.products.notify_availability_subtitle'), width: "sm" }, index.h("span", { slot: 'icon', innerHTML: BellRingIcon }), index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
113
+ index.h("label", { class: "s-product-availability-label" }, salla.lang.get('common.elements.email')),
114
+ index.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" }),
115
+ index.h("span", { class: "s-product-availability-error-msg" })
116
+ ] : '', this.channels_.includes('sms') ? [
117
+ index.h("label", { class: "s-product-availability-label" }, salla.lang.get('common.elements.mobile')),
118
+ index.h("salla-tel-input", { ref: el => this.mobileInput = el, onKeyDown: e => this.typing(e, this.submit) })
119
+ ] : ''), index.h("div", { slot: "footer", class: "s-product-availability-footer" }, index.h("salla-button", { class: "modal-cancel-btn", width: "wide", color: "light", fill: "outline", onClick: () => this.modal.close() }, salla.lang.get('common.elements.cancel')), index.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')))));
120
+ }
121
+ get host() { return index.getElement(this); }
122
+ static get watchers() { return {
123
+ "channels": ["channelsWatcher"]
124
+ }; }
125
+ };
126
+ SallaProductAvailability.style = sallaProductAvailabilityCss;
127
+
128
+ exports.salla_product_availability = SallaProductAvailability;