@salla.sa/twilight-components 1.0.56 → 1.0.58

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/index.cjs.js +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-button.cjs.entry.js +7 -7
  4. package/dist/cjs/salla-conditional-fields.cjs.entry.js +76 -0
  5. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  6. package/dist/cjs/{salla-login-modal-d0fb6180.js → salla-login-modal-02e4e65e.js} +5 -5
  7. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  8. package/dist/cjs/salla-modal_2.cjs.entry.js +5 -5
  9. package/dist/cjs/salla-offer-modal.cjs.entry.js +8 -3
  10. package/dist/cjs/salla-quantity-input.cjs.entry.js +64 -0
  11. package/dist/cjs/salla-rating-modal.cjs.entry.js +8 -8
  12. package/dist/cjs/{salla-search-f76c6d61.js → salla-search-9d17eb96.js} +3 -3
  13. package/dist/cjs/twilight-components.cjs.js +1 -1
  14. package/dist/collection/collection-manifest.json +2 -0
  15. package/dist/collection/components/salla-button/salla-button.js +10 -10
  16. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.css +3 -0
  17. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +82 -0
  18. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +1 -1
  19. package/dist/collection/components/salla-login-modal/salla-login-modal.js +5 -5
  20. package/dist/collection/components/salla-modal/salla-modal.css +1 -4
  21. package/dist/collection/components/salla-modal/salla-modal.js +3 -3
  22. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +11 -4
  23. package/dist/collection/components/salla-quantity-input/salla-quantity-input.css +3 -0
  24. package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +71 -0
  25. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +8 -8
  26. package/dist/collection/components/salla-search/salla-search.js +3 -3
  27. package/dist/esm/index.js +2 -2
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/esm/salla-button.entry.js +7 -7
  30. package/dist/esm/salla-conditional-fields.entry.js +72 -0
  31. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  32. package/dist/esm/{salla-login-modal-63f03766.js → salla-login-modal-7ad386c8.js} +5 -5
  33. package/dist/esm/salla-login-modal.entry.js +1 -1
  34. package/dist/esm/salla-modal_2.entry.js +5 -5
  35. package/dist/esm/salla-offer-modal.entry.js +8 -3
  36. package/dist/esm/salla-quantity-input.entry.js +60 -0
  37. package/dist/esm/salla-rating-modal.entry.js +8 -8
  38. package/dist/esm/{salla-search-7521be0c.js → salla-search-ce45eb5b.js} +3 -3
  39. package/dist/esm/twilight-components.js +1 -1
  40. package/dist/twilight-components/index.esm.js +1 -1
  41. package/dist/twilight-components/p-1514ed09.js +1 -0
  42. package/dist/twilight-components/p-40693cd3.entry.js +1 -0
  43. package/dist/twilight-components/p-5d5b04ec.entry.js +1 -0
  44. package/dist/twilight-components/p-64977eab.entry.js +1 -0
  45. package/dist/twilight-components/p-6c928c14.entry.js +1 -0
  46. package/dist/twilight-components/p-7c4ba872.entry.js +1 -0
  47. package/dist/twilight-components/p-84936d9d.entry.js +1 -0
  48. package/dist/twilight-components/{p-e306c6bb.entry.js → p-884a80ca.entry.js} +1 -1
  49. package/dist/twilight-components/p-ebd63ad4.js +1 -0
  50. package/dist/twilight-components/p-ee9d8563.entry.js +1 -0
  51. package/dist/twilight-components/twilight-components.esm.js +1 -1
  52. package/dist/types/components/salla-button/salla-button.d.ts +2 -2
  53. package/dist/types/components/salla-conditional-fields/salla-conditional-fields.d.ts +9 -0
  54. package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +2 -0
  55. package/dist/types/components/salla-quantity-input/salla-quantity-input.d.ts +18 -0
  56. package/dist/types/components.d.ts +34 -8
  57. package/example/dist/tailwind.css +944 -326
  58. package/example/dist/twilight.js +1 -1
  59. package/example/index.html +523 -123
  60. package/package.json +1 -1
  61. package/dist/twilight-components/p-05574321.entry.js +0 -1
  62. package/dist/twilight-components/p-134fa158.entry.js +0 -1
  63. package/dist/twilight-components/p-646fbb7f.entry.js +0 -1
  64. package/dist/twilight-components/p-85427280.entry.js +0 -1
  65. package/dist/twilight-components/p-88dce1e4.js +0 -1
  66. package/dist/twilight-components/p-a26e2e12.entry.js +0 -1
  67. package/dist/twilight-components/p-e4f716b0.js +0 -1
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaLoginModal = require('./salla-login-modal-d0fb6180.js');
6
- const sallaSearch = require('./salla-search-f76c6d61.js');
5
+ const sallaLoginModal = require('./salla-login-modal-02e4e65e.js');
6
+ const sallaSearch = require('./salla-search-9d17eb96.js');
7
7
  require('./index-0b5b5867.js');
8
8
  require('./Helper-98cc9f18.js');
9
9
 
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"buttonType":[513,"button-type"],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
17
+ return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[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"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -11,9 +11,9 @@ const SallaButton = class {
11
11
  index.registerInstance(this, hostRef);
12
12
  this.hostAttributes = {};
13
13
  /**
14
- * Button Type
14
+ * Button Type todo :: find better name,
15
15
  */
16
- this.buttonType = 'btn';
16
+ this.shape = 'btn';
17
17
  /**
18
18
  * Button Color
19
19
  */
@@ -92,21 +92,21 @@ const SallaButton = class {
92
92
  }
93
93
  getBtnAttributes() {
94
94
  for (let i = 0; i < this.host.attributes.length; i++) {
95
- if (!['type', 'color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
95
+ if (!['color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
96
96
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
97
97
  }
98
98
  }
99
99
  this.hostAttributes.type = this.hostAttributes.type || 'button';
100
100
  this.hostAttributes.class +=
101
- ' s-button-element s-button-' + this.buttonType
101
+ ' s-button-element s-button-' + this.shape
102
102
  + ' s-button-' + (this.fill == "none" ? 'fill-none' : this.fill)
103
103
  + (this.size != "medium" ? ' s-button-' + this.size : '')
104
104
  + (this.width != "normal" ? ' s-button-' + this.width : '')
105
- + (this.buttonType == "link" ? ' s-button-' + this.color + '-link' : '')
106
- + (this.buttonType != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
105
+ + (this.shape == "link" ? ' s-button-' + this.color + '-link' : '')
106
+ + (this.shape != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
107
107
  + (this.fill == 'outline' ? ' s-button-' + this.color + '-outline' : '')
108
108
  + (this.disabled ? ' s-button-disabled ' : '')
109
- + (this.buttonType == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
109
+ + (this.shape == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
110
110
  return this.hostAttributes;
111
111
  }
112
112
  render() {
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-0b5b5867.js');
6
+
7
+ const sallaConditionalFieldsCss = ":host{display:block}";
8
+
9
+ const SallaConditionalFields = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ }
13
+ changeHandler(event) {
14
+ salla.log('Received the change event: ', event);
15
+ if (!['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
16
+ // todo :: support debug
17
+ salla.log('Ignore the change because is not support input: ' + event.target.tagName);
18
+ return;
19
+ }
20
+ // to extract the option id from the input name, the supported names are name[*] and name[*][]
21
+ let optionId = event.target.name.replace('[]', '');
22
+ let isMultiple = event.target.getAttribute('type') === 'checkbox';
23
+ salla.log('Trying to find all the element with condation:', `[data-show-when^="${optionId}"]`);
24
+ this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
25
+ .forEach((field) => {
26
+ // @ts-ignore
27
+ let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
28
+ // @ts-ignore
29
+ let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
30
+ // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
31
+ let isSelected = false;
32
+ if (isMultiple) {
33
+ // @ts-ignore
34
+ let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
35
+ isSelected = selectedValues.includes(value.toString());
36
+ }
37
+ else {
38
+ isSelected = value === event.target.value;
39
+ }
40
+ salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
41
+ let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
42
+ if (showTheInput) {
43
+ field.classList.remove('hidden');
44
+ field.querySelectorAll('[name]').forEach((input) => {
45
+ input.removeAttribute('disabled');
46
+ //To handle focus on hidden input error
47
+ if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
48
+ input.setAttribute('required', '');
49
+ }
50
+ });
51
+ }
52
+ else {
53
+ field.classList.add('hidden');
54
+ field.querySelectorAll('[name]').forEach((input) => {
55
+ input.setAttribute('disabled', '');
56
+ input.removeAttribute('required');
57
+ if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
58
+ // @ts-ignore
59
+ input.checked = false;
60
+ }
61
+ //firing this event will show errors, so don't run it when pageLoading.
62
+ // if (this.optionsAlreadyInitiated) {
63
+ // salla.document.event.fireEvent(input, 'change', {'bubbles': true});
64
+ // }
65
+ });
66
+ }
67
+ });
68
+ }
69
+ render() {
70
+ return (index.h(index.Host, null, index.h("slot", null)));
71
+ }
72
+ get host() { return index.getElement(this); }
73
+ };
74
+ SallaConditionalFields.style = sallaConditionalFieldsCss;
75
+
76
+ exports.salla_conditional_fields = SallaConditionalFields;
@@ -46,7 +46,7 @@ const SallaInfiniteScroll = class {
46
46
  }
47
47
  loading(isLoading = true) {
48
48
  let btnText = this.status.querySelector('.s-button-text');
49
- Helper.Helper.toggleElement(btnText, 's-button-hide', 's-button-show', () => isLoading);
49
+ Helper.Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);
50
50
  this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
51
51
  }
52
52
  componentWillLoad() {
@@ -65,7 +65,7 @@ const SallaLoginModal = class {
65
65
  .then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
66
66
  .then(() => this.emailBtn.stop() && this.emailBtn.enable())
67
67
  .then(() => this.showTab(this.verifyTab))
68
- .then(() => this.verifyTab.by = 'email')
68
+ .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
69
69
  .then(() => this.verifyTab.show({ email: this.loginEmail.value }));
70
70
  };
71
71
  this.newUser = async () => {
@@ -159,8 +159,8 @@ const SallaLoginModal = class {
159
159
  var _a, _b;
160
160
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
161
161
  let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
162
- tabs.map(el => Helper.Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
163
- setTimeout(() => tabs.map(el => Helper.Helper.toggleElement(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
162
+ tabs.map(el => Helper.Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
163
+ setTimeout(() => tabs.map(el => Helper.Helper.toggleElementClassIf(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
164
164
  setTimeout(() => this.host.querySelector('.s-login-modal-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
165
165
  if ([this.mobileTab, this.emailTab].includes(tab)) {
166
166
  this.regType = tab === this.mobileTab ? 'phone' : 'email';
@@ -169,8 +169,8 @@ const SallaLoginModal = class {
169
169
  isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
170
170
  (_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
171
171
  if (!isRegistrationTab) {
172
- Helper.Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
173
- .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
172
+ Helper.Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
173
+ .toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
174
174
  }
175
175
  return this;
176
176
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaLoginModal = require('./salla-login-modal-d0fb6180.js');
5
+ const sallaLoginModal = require('./salla-login-modal-02e4e65e.js');
6
6
  require('./index-0b5b5867.js');
7
7
  require('./Helper-98cc9f18.js');
8
8
 
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0b5b5867.js');
6
6
  const Helper = require('./Helper-98cc9f18.js');
7
- const sallaSearch = require('./salla-search-f76c6d61.js');
7
+ const sallaSearch = require('./salla-search-9d17eb96.js');
8
8
 
9
- const sallaModalCss = ".salla-modal .s-modal-wrapper{height:calc(var(--vh, 1vh) * 100)}";
9
+ const sallaModalCss = "";
10
10
 
11
11
  const SallaModal = class {
12
12
  constructor(hostRef) {
@@ -96,10 +96,10 @@ const SallaModal = class {
96
96
  }
97
97
  toggleModal(isOpen) {
98
98
  const body = this.host.querySelector('.s-modal-body');
99
- Helper.Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
100
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
99
+ Helper.Helper.toggleElementClassIf(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
100
+ .toggleElementClassIf(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
101
101
  //todo:: use united class names
102
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
102
+ .toggleElementClassIf(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
103
103
  if (!isOpen) {
104
104
  setTimeout(() => this.host.classList.add('s-hidden'), 350);
105
105
  }
@@ -14,10 +14,14 @@ const SallaOfferModal = class {
14
14
  this.offer = null;
15
15
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
16
16
  this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
17
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
18
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
17
19
  Helper.Helper.setHost(this.host);
18
20
  salla.event.on('languages::translations.loaded', () => {
19
21
  this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
20
22
  this.remember_my_choice = salla.lang.get('common.remember_my_choice');
23
+ this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
24
+ this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
21
25
  });
22
26
  this.categorySlot = ((_a = Helper.Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>';
23
27
  this.productSlot = ((_b = Helper.Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
@@ -46,6 +50,7 @@ const SallaOfferModal = class {
46
50
  this.offer = offer;
47
51
  this.offer_name = offer.name;
48
52
  this.offer_message = offer.message;
53
+ this.modal.setTitle(this.offer_name);
49
54
  return this.modal.show();
50
55
  }
51
56
  rememberMe(event) {
@@ -67,18 +72,18 @@ const SallaOfferModal = class {
67
72
  }
68
73
  render() {
69
74
  var _a, _b;
70
- return index.h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", title: "\u0639\u0631\u0648\u0636 \u0631\u0627\u0626\u0639\u0629 \u0641\u064A \u0627\u0646\u062A\u0638\u0627\u0631\u0643\u060C \u0645\u0627\u0630\u0627 \u0646\u062A\u0646\u0638\u0631!", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
75
+ return index.h("salla-modal", { id: "salla-offer-modal", "sub-title-first": true, icon: "sicon-special-discount", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
71
76
  ? [index.h("div", { class: "s-offer-modal-scrolled-slider-wrap" }, index.h("div", { class: "s-offer-modal-body s-offer-modal-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
72
77
  ? this.offer.get.categories.map(category => index.h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item", innerHTML: this.categorySlot
73
78
  .replace(/\{name\}/g, category.name)
74
79
  .replace(/\{url\}/g, category.urls.customer) }))
75
- : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => index.h("div", { class: "s-offer-modal-product s-offer-modal-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
80
+ : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => index.h("div", { class: { "s-offer-modal-product": true, "s-offer-modal-slider-item": true, "s-offer-modal-not-available": !product.is_available }, id: 'product_' + product.id, innerHTML: this.productSlot
76
81
  .replace(/\{name\}/g, product.name)
77
82
  .replace(/\{url\}/g, product.url)
78
83
  .replace(/\{image\}/g, product.thumbnail)
79
84
  .replace(/\{price\}/g, product.has_special_price
80
85
  ? salla.money(product.price) + '<span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
81
- : salla.money(product.price)) }, index.h("div", { class: "s-offer-modal-btn-wrap" }, index.h("salla-button", { wide: true, "btn-style": 'outline-primary', "data-id": product.id, "loader-position": "center", onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart')))))), index.h("div", { class: "s-offer-modal-slider-nav" }, index.h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, index.h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })), index.h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, index.h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })))),
86
+ : salla.money(product.price)) }, index.h("div", { class: "s-offer-modal-btn-wrap" }, index.h("salla-button", { width: "wide", fill: 'outline', "data-id": product.id, disabled: !product.is_available, "loader-position": "center", onClick: this.addItem }, product.is_available ? this.add_to_cart : this.out_of_stock))))), index.h("div", { class: "s-offer-modal-slider-nav" }, index.h("button", { class: "s-offer-modal-nav-btn s-offer-modal-prev-btn" }, index.h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right" })), index.h("button", { class: "s-offer-modal-nav-btn s-offer-modal-next-btn" }, index.h("span", { class: "s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left" })))),
82
87
  index.h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.expiry_date ?
83
88
  index.h("p", { class: "s-offer-modal-expiry" }, this.offer_expires_in, " ", this.offer.expiry_date)
84
89
  : '', index.h("label", { class: "s-offer-modal-remember-label" }, index.h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-modal-remember-input" }), "\u00A0 ", this.remember_my_choice)),
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-0b5b5867.js');
6
+
7
+ const sallaQuantityInputCss = ":host{display:block}";
8
+
9
+ const SallaQuantityInput = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.hostAttributes = {};
13
+ this.hasIncrementSlot = false;
14
+ this.hasDecrementSlot = false;
15
+ this.quantity = 1;
16
+ }
17
+ /**
18
+ * Workaround to fire change event for the input.
19
+ */
20
+ watchPropHandler() {
21
+ salla.helpers.debounce(() => salla.document.event.fireEvent(this.textInput, 'change', { 'bubbles': true }))();
22
+ }
23
+ componentWillLoad() {
24
+ this.hasIncrementSlot = !!this.host.querySelector('[slot="increment-button"]');
25
+ this.hasDecrementSlot = !!this.host.querySelector('[slot="decrement-button"]');
26
+ }
27
+ // border-border-color
28
+ // transtion transition-color duration-300
29
+ componentdidLoad() {
30
+ this.quantity = parseInt(this.host.getAttribute('value')) || 1;
31
+ //app.on('input', '[name="quantity"]', event => salla.helpers.inputDigitsOnly(event.target));
32
+ }
33
+ getInputAttributes() {
34
+ for (let i = 0; i < this.host.attributes.length; i++) {
35
+ if (!['id', 'value', 'min', 'class'].includes(this.host.attributes[i].name)) {
36
+ this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
37
+ }
38
+ }
39
+ return this.hostAttributes;
40
+ }
41
+ decrement() {
42
+ if (this.quantity <= 1) {
43
+ return;
44
+ }
45
+ this.quantity--;
46
+ }
47
+ increment() {
48
+ let maxQuantity = parseInt(this.host.getAttribute('max'));
49
+ if (maxQuantity && this.quantity >= maxQuantity) {
50
+ return;
51
+ }
52
+ this.quantity++;
53
+ }
54
+ render() {
55
+ return (index.h(index.Host, { class: "s-quantity-input s-quantity-input-container" }, index.h("button", { onClick: () => this.increment(), class: "s-quantity-input-button", type: "button" }, !this.hasIncrementSlot ? index.h("i", { class: "sicon-add" }) : '', index.h("slot", { name: "increment-button" })), index.h("input", Object.assign({ class: "s-quantity-input-input" }, this.getInputAttributes(), { min: "1", value: this.quantity, ref: (el) => this.textInput = el })), index.h("button", { class: "s-quantity-input-button", onClick: () => this.decrement(), type: "button" }, !this.hasDecrementSlot ? index.h("i", { class: "sicon-minus" }) : '', index.h("slot", { name: "decrement-button" }))));
56
+ }
57
+ get host() { return index.getElement(this); }
58
+ static get watchers() { return {
59
+ "quantity": ["watchPropHandler"]
60
+ }; }
61
+ };
62
+ SallaQuantityInput.style = sallaQuantityInputCss;
63
+
64
+ exports.salla_quantity_input = SallaQuantityInput;
@@ -74,7 +74,7 @@ const SallaRatingModal = class {
74
74
  // Loop through each star, and add or remove the `.selected` class to toggle highlighting
75
75
  event.target
76
76
  .querySelectorAll('.s-rating-modal-btn-star')
77
- .forEach((star, index) => Helper.Helper.toggleElement(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
77
+ .forEach((star, index) => Helper.Helper.toggleElementClassIf(star, 's-rating-modal-selected', 's-rating-modal-un-selected', () => index < selectedIndex));
78
78
  // Remove aria-pressed from any previously selected star
79
79
  event.target.querySelectorAll('.s-rating-modal-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
80
80
  // Add aria-pressed role to the selected button
@@ -90,12 +90,12 @@ const SallaRatingModal = class {
90
90
  showActiveStep(current = null) {
91
91
  var _a;
92
92
  this.currentTab = current || this.steps[this.currentIndex];
93
- Helper.Helper.toggle('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
94
- .toggle('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
93
+ Helper.Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex])
94
+ .toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
95
95
  if (this.currentIndex != 0) {
96
96
  // the animation
97
- Helper.Helper.toggleElement(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
98
- setTimeout(() => Helper.Helper.toggleElement(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
97
+ Helper.Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
98
+ setTimeout(() => Helper.Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
99
99
  }
100
100
  // Btn text
101
101
  let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
@@ -127,7 +127,7 @@ const SallaRatingModal = class {
127
127
  }
128
128
  previousTab() {
129
129
  this.currentIndex > 0 && this.currentIndex--;
130
- Helper.Helper.toggleElement(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
130
+ Helper.Helper.toggleElementClassIf(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
131
131
  this.showActiveStep();
132
132
  }
133
133
  submit() {
@@ -138,7 +138,7 @@ const SallaRatingModal = class {
138
138
  .then(() => this.currentTab.querySelectorAll('[name],.s-rating-modal-btn-star').forEach(el => el.setAttribute('disabled', '')))
139
139
  .then(() => this.currentIndex < this.stepsCount && this.currentIndex++)
140
140
  .then(() => this.showActiveStep())
141
- .then(() => Helper.Helper.toggle('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
141
+ .then(() => Helper.Helper.toggleClassIf('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true))
142
142
  .finally(() => {
143
143
  this.nextBtn.stop();
144
144
  salla.config.canLeave = true;
@@ -163,7 +163,7 @@ const SallaRatingModal = class {
163
163
  return;
164
164
  }
165
165
  type = type || rating['dataset'].type;
166
- Helper.Helper.toggleElement(comment, 'save', 's-has-error', el => el.value.length > 3);
166
+ Helper.Helper.toggleElementClassIf(comment, 'save', 's-has-error', el => el.value.length > 3);
167
167
  throw validationMessage.innerHTML = stars
168
168
  ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
169
169
  : salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
@@ -51,7 +51,7 @@ const SallaSearch = class {
51
51
  return;
52
52
  }
53
53
  //run loading spinner or stop it
54
- Helper.Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
54
+ Helper.Helper.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
55
55
  salla.search.api.search(e.target.value)
56
56
  .then(response => this.results = response)
57
57
  .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
@@ -60,8 +60,8 @@ const SallaSearch = class {
60
60
  afterSearching(isEmpty = true) {
61
61
  var _a;
62
62
  this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
63
- Helper.Helper.toggleElement(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
64
- .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
63
+ Helper.Helper.toggleElementClassIf(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
64
+ .toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
65
65
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
66
66
  this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
67
67
  }
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"buttonType":[513,"button-type"],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
18
+ return index.bootstrapLazy([["salla-button.cjs",[[4,"salla-button",{"shape":[513],"color":[513],"fill":[513],"size":[513],"width":[513],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"href":[1],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"add_to_cart":[32],"out_of_stock":[32],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[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"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-quantity-input.cjs",[[4,"salla-quantity-input",{"quantity":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}]]]], options);
19
19
  });
@@ -4,11 +4,13 @@
4
4
  "./components/salla-search/salla-search.js",
5
5
  "./components/salla-branches/salla-branches.js",
6
6
  "./components/salla-button/salla-button.js",
7
+ "./components/salla-conditional-fields/salla-conditional-fields.js",
7
8
  "./components/salla-infinite-scroll/salla-infinite-scroll.js",
8
9
  "./components/salla-localization-modal/salla-localization-modal.js",
9
10
  "./components/salla-modal/salla-modal.js",
10
11
  "./components/salla-offer-modal/salla-offer-modal.js",
11
12
  "./components/salla-product-availability/salla-product-availability.js",
13
+ "./components/salla-quantity-input/salla-quantity-input.js",
12
14
  "./components/salla-rating-modal/salla-rating-modal.js",
13
15
  "./components/salla-tel-input/salla-tel-input.js",
14
16
  "./components/salla-verify-modal/salla-verify-modal.js"
@@ -3,9 +3,9 @@ export class SallaButton {
3
3
  constructor() {
4
4
  this.hostAttributes = {};
5
5
  /**
6
- * Button Type
6
+ * Button Type todo :: find better name,
7
7
  */
8
- this.buttonType = 'btn';
8
+ this.shape = 'btn';
9
9
  /**
10
10
  * Button Color
11
11
  */
@@ -84,21 +84,21 @@ export class SallaButton {
84
84
  }
85
85
  getBtnAttributes() {
86
86
  for (let i = 0; i < this.host.attributes.length; i++) {
87
- if (!['type', 'color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
87
+ if (!['color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
88
88
  this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
89
89
  }
90
90
  }
91
91
  this.hostAttributes.type = this.hostAttributes.type || 'button';
92
92
  this.hostAttributes.class +=
93
- ' s-button-element s-button-' + this.buttonType
93
+ ' s-button-element s-button-' + this.shape
94
94
  + ' s-button-' + (this.fill == "none" ? 'fill-none' : this.fill)
95
95
  + (this.size != "medium" ? ' s-button-' + this.size : '')
96
96
  + (this.width != "normal" ? ' s-button-' + this.width : '')
97
- + (this.buttonType == "link" ? ' s-button-' + this.color + '-link' : '')
98
- + (this.buttonType != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
97
+ + (this.shape == "link" ? ' s-button-' + this.color + '-link' : '')
98
+ + (this.shape != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
99
99
  + (this.fill == 'outline' ? ' s-button-' + this.color + '-outline' : '')
100
100
  + (this.disabled ? ' s-button-disabled ' : '')
101
- + (this.buttonType == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
101
+ + (this.shape == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
102
102
  return this.hostAttributes;
103
103
  }
104
104
  render() {
@@ -116,7 +116,7 @@ export class SallaButton {
116
116
  "$": ["salla-button.css"]
117
117
  }; }
118
118
  static get properties() { return {
119
- "buttonType": {
119
+ "shape": {
120
120
  "type": "string",
121
121
  "mutable": false,
122
122
  "complexType": {
@@ -128,9 +128,9 @@ export class SallaButton {
128
128
  "optional": false,
129
129
  "docs": {
130
130
  "tags": [],
131
- "text": "Button Type"
131
+ "text": "Button Type todo :: find better name,"
132
132
  },
133
- "attribute": "button-type",
133
+ "attribute": "shape",
134
134
  "reflect": true,
135
135
  "defaultValue": "'btn'"
136
136
  },
@@ -0,0 +1,82 @@
1
+ import { Component, Element, Host, Listen, h } from '@stencil/core';
2
+ /**
3
+ * its to easy to use, currenlty its support select & checkbox input as trigger for show/hide the dom
4
+ * the dom you can put it like this data-show-when="{name of the field} {= or !=} {value of the field}"
5
+ */
6
+ export class SallaConditionalFields {
7
+ changeHandler(event) {
8
+ salla.log('Received the change event: ', event);
9
+ if (!['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {
10
+ // todo :: support debug
11
+ salla.log('Ignore the change because is not support input: ' + event.target.tagName);
12
+ return;
13
+ }
14
+ // to extract the option id from the input name, the supported names are name[*] and name[*][]
15
+ let optionId = event.target.name.replace('[]', '');
16
+ let isMultiple = event.target.getAttribute('type') === 'checkbox';
17
+ salla.log('Trying to find all the element with condation:', `[data-show-when^="${optionId}"]`);
18
+ this.host.querySelectorAll(`[data-show-when^="${optionId}"]`)
19
+ .forEach((field) => {
20
+ // @ts-ignore
21
+ let isEqual = !(field === null || field === void 0 ? void 0 : field.dataset.showWhen.includes('!='));
22
+ // @ts-ignore
23
+ let value = field === null || field === void 0 ? void 0 : field.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();
24
+ // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;
25
+ let isSelected = false;
26
+ if (isMultiple) {
27
+ // @ts-ignore
28
+ let selectedValues = Array.from(this.host.querySelectorAll(`input[name="${event.target.name}"]:checked`), e => e === null || e === void 0 ? void 0 : e.value);
29
+ isSelected = selectedValues.includes(value.toString());
30
+ }
31
+ else {
32
+ isSelected = value === event.target.value;
33
+ }
34
+ salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);
35
+ let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);
36
+ if (showTheInput) {
37
+ field.classList.remove('hidden');
38
+ field.querySelectorAll('[name]').forEach((input) => {
39
+ input.removeAttribute('disabled');
40
+ //To handle focus on hidden input error
41
+ if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {
42
+ input.setAttribute('required', '');
43
+ }
44
+ });
45
+ }
46
+ else {
47
+ field.classList.add('hidden');
48
+ field.querySelectorAll('[name]').forEach((input) => {
49
+ input.setAttribute('disabled', '');
50
+ input.removeAttribute('required');
51
+ if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {
52
+ // @ts-ignore
53
+ input.checked = false;
54
+ }
55
+ //firing this event will show errors, so don't run it when pageLoading.
56
+ // if (this.optionsAlreadyInitiated) {
57
+ // salla.document.event.fireEvent(input, 'change', {'bubbles': true});
58
+ // }
59
+ });
60
+ }
61
+ });
62
+ }
63
+ render() {
64
+ return (h(Host, null,
65
+ h("slot", null)));
66
+ }
67
+ static get is() { return "salla-conditional-fields"; }
68
+ static get originalStyleUrls() { return {
69
+ "$": ["salla-conditional-fields.css"]
70
+ }; }
71
+ static get styleUrls() { return {
72
+ "$": ["salla-conditional-fields.css"]
73
+ }; }
74
+ static get elementRef() { return "host"; }
75
+ static get listeners() { return [{
76
+ "name": "change",
77
+ "method": "changeHandler",
78
+ "target": undefined,
79
+ "capture": false,
80
+ "passive": false
81
+ }]; }
82
+ }