@salla.sa/twilight-components 1.0.99 → 1.0.104

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 (129) hide show
  1. package/dist/cjs/{index-fdf99836.js → index-b4140db0.js} +26 -98
  2. package/dist/cjs/loader.cjs.js +3 -3
  3. package/dist/cjs/salla-add-product-button_6.cjs.entry.js +73 -56
  4. package/dist/cjs/salla-branches.cjs.entry.js +10 -6
  5. package/dist/cjs/salla-conditional-fields.cjs.entry.js +4 -5
  6. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  7. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  8. package/dist/cjs/salla-localization-modal.cjs.entry.js +6 -5
  9. package/dist/cjs/salla-login-modal.cjs.entry.js +4 -4
  10. package/dist/cjs/salla-offer-modal.cjs.entry.js +4 -3
  11. package/dist/cjs/salla-quantity-input.cjs.entry.js +3 -3
  12. package/dist/cjs/salla-rating-modal.cjs.entry.js +5 -5
  13. package/dist/cjs/salla-rating-stars.cjs.entry.js +27 -36
  14. package/dist/cjs/{salla-verify-modal.cjs.entry.js → salla-verify.cjs.entry.js} +20 -14
  15. package/dist/cjs/twilight-components.cjs.js +3 -3
  16. package/dist/collection/collection-manifest.json +2 -3
  17. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +13 -28
  18. package/dist/collection/components/salla-branches/salla-branches.css +0 -3
  19. package/dist/collection/components/salla-branches/salla-branches.js +10 -6
  20. package/dist/collection/components/salla-button/salla-button.css +1 -88
  21. package/dist/collection/components/salla-button/salla-button.js +2 -26
  22. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +3 -7
  23. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.css +0 -3
  24. package/dist/collection/components/salla-installment/salla-installment.css +4 -3
  25. package/dist/collection/components/salla-localization-modal/salla-localization-modal.css +2 -16
  26. package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +4 -3
  27. package/dist/collection/components/salla-login-modal/salla-login-modal.css +1 -8
  28. package/dist/collection/components/salla-login-modal/salla-login-modal.js +3 -3
  29. package/dist/collection/components/salla-modal/salla-modal.css +0 -3
  30. package/dist/collection/components/salla-modal/salla-modal.js +13 -12
  31. package/dist/collection/components/salla-offer-modal/salla-offer-modal.css +1 -25
  32. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +2 -1
  33. package/dist/collection/components/salla-product-availability/salla-product-availability.css +0 -3
  34. package/dist/collection/components/salla-product-availability/salla-product-availability.js +18 -13
  35. package/dist/collection/components/salla-quantity-input/salla-quantity-input.css +4 -3
  36. package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +3 -3
  37. package/dist/collection/components/salla-rating-modal/salla-rating-modal.css +1 -20
  38. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +3 -3
  39. package/dist/collection/components/salla-rating-stars/salla-rating-stars.css +3 -5
  40. package/dist/collection/components/salla-rating-stars/salla-rating-stars.js +26 -35
  41. package/dist/collection/components/salla-search/salla-search.css +1 -45
  42. package/dist/collection/components/salla-search/salla-search.js +35 -16
  43. package/dist/collection/components/salla-tel-input/salla-tel-input.css +13 -8
  44. package/dist/collection/components/{salla-verify-modal/salla-verify-modal.css → salla-verify/salla-verify.css} +1 -8
  45. package/dist/collection/components/{salla-verify-modal/salla-verify-modal.js → salla-verify/salla-verify.js} +33 -26
  46. package/dist/collection/plugins/tailwind-theme/generator.js +6 -2
  47. package/dist/collection/plugins/tailwind-theme/index.js +3 -3
  48. package/dist/components/index.d.ts +17 -5
  49. package/dist/components/index.js +17 -0
  50. package/dist/components/salla-add-product-button.js +14 -12
  51. package/dist/components/salla-branches.js +9 -5
  52. package/dist/components/salla-button2.js +3 -10
  53. package/dist/components/salla-conditional-fields.js +3 -4
  54. package/dist/components/salla-localization-modal.js +5 -4
  55. package/dist/components/salla-login-modal.js +6 -6
  56. package/dist/components/salla-modal2.js +7 -7
  57. package/dist/components/salla-offer-modal.js +3 -2
  58. package/dist/components/salla-product-availability2.js +17 -12
  59. package/dist/components/salla-quantity-input.js +2 -2
  60. package/dist/components/salla-rating-modal.js +4 -4
  61. package/dist/components/salla-rating-stars2.js +26 -35
  62. package/dist/components/salla-search.js +33 -15
  63. package/dist/components/salla-tel-input2.js +3 -3
  64. package/dist/components/{salla-sizes-table.d.ts → salla-verify.d.ts} +4 -4
  65. package/dist/components/salla-verify.js +9 -0
  66. package/dist/components/{salla-verify-modal2.js → salla-verify2.js} +24 -18
  67. package/dist/esm/{index-4ffd4317.js → index-20b84fd0.js} +26 -98
  68. package/dist/esm/loader.js +3 -3
  69. package/dist/esm/polyfills/css-shim.js +1 -1
  70. package/dist/esm/salla-add-product-button_6.entry.js +73 -56
  71. package/dist/esm/salla-branches.entry.js +10 -6
  72. package/dist/esm/salla-conditional-fields.entry.js +4 -5
  73. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  74. package/dist/esm/salla-installment.entry.js +1 -1
  75. package/dist/esm/salla-localization-modal.entry.js +6 -5
  76. package/dist/esm/salla-login-modal.entry.js +4 -4
  77. package/dist/esm/salla-offer-modal.entry.js +4 -3
  78. package/dist/esm/salla-quantity-input.entry.js +3 -3
  79. package/dist/esm/salla-rating-modal.entry.js +5 -5
  80. package/dist/esm/salla-rating-stars.entry.js +27 -36
  81. package/dist/esm/{salla-verify-modal.entry.js → salla-verify.entry.js} +20 -14
  82. package/dist/esm/twilight-components.js +3 -3
  83. package/dist/twilight-components/{p-8c69a096.entry.js → p-15fac4f2.entry.js} +1 -1
  84. package/dist/twilight-components/p-27d01075.entry.js +4 -0
  85. package/dist/twilight-components/p-30e63760.entry.js +4 -0
  86. package/dist/twilight-components/{p-edbb12b2.entry.js → p-5ee94c9e.entry.js} +1 -1
  87. package/dist/twilight-components/p-799da239.entry.js +4 -0
  88. package/dist/twilight-components/p-9ff78dd1.entry.js +4 -0
  89. package/dist/twilight-components/p-c1952856.entry.js +4 -0
  90. package/dist/twilight-components/p-c2bef5f2.js +5 -0
  91. package/dist/twilight-components/p-cf143464.entry.js +4 -0
  92. package/dist/twilight-components/p-d3778858.entry.js +4 -0
  93. package/dist/twilight-components/p-ebd2e045.entry.js +4 -0
  94. package/dist/twilight-components/p-ec0a2892.entry.js +4 -0
  95. package/dist/twilight-components/{p-56065da6.entry.js → p-fab65162.entry.js} +1 -1
  96. package/dist/twilight-components/twilight-components.esm.js +1 -1
  97. package/dist/types/components/salla-add-product-button/salla-add-product-button.d.ts +1 -2
  98. package/dist/types/components/salla-button/salla-button.d.ts +0 -5
  99. package/dist/types/components/salla-rating-stars/salla-rating-stars.d.ts +1 -0
  100. package/dist/types/components/salla-search/salla-search.d.ts +6 -1
  101. package/dist/types/components/{salla-verify-modal/salla-verify-modal.d.ts → salla-verify/salla-verify.d.ts} +3 -2
  102. package/dist/types/components.d.ts +33 -50
  103. package/example/dist/translations.js +1 -1
  104. package/example/index.html +184 -162
  105. package/example/tailwind.config.js +4 -7
  106. package/package.json +9 -13
  107. package/dist/cjs/salla-sizes-table.cjs.entry.js +0 -22
  108. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.css +0 -3
  109. package/dist/collection/components/salla-sizes-table/salla-sizes-table.css +0 -6
  110. package/dist/collection/components/salla-sizes-table/salla-sizes-table.js +0 -18
  111. package/dist/components/salla-sizes-table.js +0 -37
  112. package/dist/components/salla-verify-modal.d.ts +0 -11
  113. package/dist/components/salla-verify-modal.js +0 -9
  114. package/dist/esm/salla-sizes-table.entry.js +0 -18
  115. package/dist/twilight-components/p-1d0e664c.js +0 -4
  116. package/dist/twilight-components/p-210f5278.entry.js +0 -4
  117. package/dist/twilight-components/p-2384537d.entry.js +0 -4
  118. package/dist/twilight-components/p-2b1c3490.entry.js +0 -4
  119. package/dist/twilight-components/p-7fae6b84.entry.js +0 -4
  120. package/dist/twilight-components/p-9e05640e.entry.js +0 -4
  121. package/dist/twilight-components/p-af450175.entry.js +0 -4
  122. package/dist/twilight-components/p-d762e16f.entry.js +0 -4
  123. package/dist/twilight-components/p-d77dd260.entry.js +0 -4
  124. package/dist/twilight-components/p-e435a209.entry.js +0 -4
  125. package/dist/twilight-components/p-ecaee6a4.entry.js +0 -4
  126. package/dist/types/components/salla-sizes-table/salla-sizes-table.d.ts +0 -3
  127. package/example/.DS_Store +0 -0
  128. package/example/.gitignore +0 -2
  129. package/example/dist/.DS_Store +0 -0
@@ -9,45 +9,36 @@ export class SallaRatingStars {
9
9
  this.size = 'medium';
10
10
  }
11
11
  initiateRating() {
12
- document.querySelectorAll('.s-rating-stars-element').forEach((elem) => {
13
- elem.addEventListener('submit', function (event) {
14
- event.preventDefault();
15
- // Get the selected star - activeElement is not supported in safari
16
- let activeStars = event.target.querySelectorAll('.s-rating-stars-btn-star.s-rating-stars-hovered');
17
- let selected = activeStars[activeStars.length - 1];
18
- if (!selected)
19
- return;
20
- let selectedIndex = selected.getAttribute('data-star');
21
- event.target.querySelector('.rating_hidden_input').value = selectedIndex;
22
- // Get all stars in this form (only search in the form, not the whole document)
23
- // Loop through each star, and add or remove the `.selected` class to toggle highlighting
24
- event.target
25
- .querySelectorAll('.s-rating-stars-btn-star')
26
- .forEach((star, index) => Helper.toggleElementClassIf(star, 's-rating-stars-selected', 's-rating-stars-unselected', () => index < parseInt(selectedIndex)));
27
- // Remove aria-pressed from any previously selected star
28
- event.target.querySelectorAll('.s-rating-stars-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
29
- // Add aria-pressed role to the selected button
30
- selected.setAttribute('aria-pressed', '');
31
- });
12
+ this.host.addEventListener('click', () => {
13
+ if (!this.startsElem)
14
+ return;
15
+ // Get the selected star - activeElement is not supported in safari
16
+ let activeStars = this.startsElem.querySelectorAll('.s-rating-stars-hovered');
17
+ let selected = activeStars[activeStars.length - 1];
18
+ if (!selected)
19
+ return;
20
+ let selectedIndex = selected.getAttribute('data-star');
21
+ this.startsElem.querySelector('.rating_hidden_input').value = selectedIndex;
22
+ // Loop through each star, and add or remove the `.selected` class to toggle highlighting
23
+ this.startsElem.querySelectorAll('.s-rating-stars-btn-star')
24
+ .forEach((star, index) => Helper.toggleElementClassIf(star, 's-rating-stars-selected', 's-rating-stars-unselected', () => index < parseInt(selectedIndex)));
25
+ // update aria-pressed attr status
26
+ this.startsElem.querySelectorAll('[aria-pressed]').forEach(star => star.removeAttribute('aria-pressed'));
27
+ selected.setAttribute('aria-pressed', 'true');
32
28
  });
33
29
  }
34
30
  highlightSelectedStars() {
35
- let hover = ['s-rating-stars-hovered'], element = this.host.querySelector('.s-rating-stars-element'), starElements = element === null || element === void 0 ? void 0 : element.querySelectorAll('.s-rating-stars-btn-star');
36
- element === null || element === void 0 ? void 0 : element.addEventListener('mouseout', () => starElements.forEach(star => star.classList.remove(...hover)));
37
- starElements === null || starElements === void 0 ? void 0 : starElements.forEach((starElement, index) => {
38
- starElement.addEventListener('mouseover', () => {
39
- starElement.classList.add(...hover);
40
- if (index <= 1) {
41
- starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
42
- }
43
- else {
44
- for (let i = 0; i < index; i++) {
45
- starElements[i].classList.add(...hover);
46
- }
31
+ var _a, _b;
32
+ let hoveredClass = 's-rating-stars-hovered', stars = (_a = this.startsElem) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.s-rating-stars-btn-star');
33
+ stars === null || stars === void 0 ? void 0 : stars.forEach((star, index) => {
34
+ star.addEventListener('mouseover', () => {
35
+ for (let i = 0; i <= index; i++) {
36
+ stars[i].classList.add(hoveredClass);
47
37
  }
48
38
  });
49
- starElement.addEventListener('mouseout', () => starElement.classList.remove(...hover));
39
+ star.addEventListener('mouseout', () => star.classList.remove(hoveredClass));
50
40
  });
41
+ (_b = this.startsElem) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseout', () => stars.forEach(star => star.classList.remove(hoveredClass)));
51
42
  }
52
43
  createStars(n) {
53
44
  let stars = [];
@@ -67,9 +58,9 @@ export class SallaRatingStars {
67
58
  this.createStars(this.value),
68
59
  " ")
69
60
  :
70
- h("form", { class: "s-rating-stars-element" },
61
+ h("div", { class: "s-rating-stars-element", ref: (el) => this.startsElem = el },
71
62
  h("input", { type: "hidden", class: "rating_hidden_input", name: this.name, value: "" }),
72
- [1, 2, 3, 4, 5].map(star => h("button", { type: "submit", class: `s-rating-stars-btn-star s-rating-stars-` + this.size, "data-star": star },
63
+ [1, 2, 3, 4, 5].map(star => h("button", { class: `s-rating-stars-btn-star s-rating-stars-` + this.size, "data-star": star },
73
64
  h("i", { class: "sicon-star2" }))))));
74
65
  }
75
66
  componentDidLoad() {
@@ -1,48 +1,4 @@
1
1
  /*
2
- * Global flags style [imported from Int-tel-input]
3
- */
4
- /*
5
2
  * Salla Search Component: Site search modal.
6
3
  * You can use these classes to target the elements in the component.
7
- */
8
- #s-search-modal .s-search-inline {
9
- border: 1px solid #eee;
10
- }
11
- #s-search-modal .s-search-no-results .s-search-input, #s-search-modal .s-search-container-open .s-search-input {
12
- border-bottom: 1px solid #f4f4f5;
13
- }
14
- #s-search-modal .s-search-product-image {
15
- font-size: 0;
16
- position: relative;
17
- }
18
- #s-search-modal .s-search-product-image:before {
19
- content: "";
20
- position: absolute;
21
- width: 100%;
22
- height: 100%;
23
- left: 0;
24
- top: 0;
25
- background: #eee;
26
- }
27
- /*
28
- * Override general modal style with custom style for search modal
29
- */
30
- #s-search-modal .s-modal-wrapper {
31
- align-items: flex-start;
32
- padding: 0;
33
- }
34
- #s-search-modal .s-modal-spacer {
35
- display: inline;
36
- }
37
- #s-search-modal .s-modal-body {
38
- padding: 0;
39
- max-width: 90%;
40
- margin-top: 3.2rem;
41
- border-radius: 0.5rem;
42
- background: transparent;
43
- overflow: visible;
44
- }
45
- #s-search-modal .s-modal-close {
46
- top: 50%;
47
- transform: translateY(-50%);
48
- }
4
+ */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { Component, Prop, h, State, Element } from '@stencil/core';
4
+ import { Component, Prop, h, State, Element, Watch } from '@stencil/core';
5
5
  import Helper from "../../Helpers/Helper";
6
6
  /**
7
7
  * @slot product - Replaces products card in the results, has replaceable props `{name}`, `{price}`, `{regular_price}`, `{image}`.
@@ -10,6 +10,8 @@ export class SallaSearch {
10
10
  constructor() {
11
11
  var _a;
12
12
  this.inputValue = '';
13
+ this.typing = false;
14
+ this.debounce = setTimeout(() => '', 1000);
13
15
  this.inline = false;
14
16
  this.oval = false;
15
17
  this.height = 60;
@@ -23,6 +25,7 @@ export class SallaSearch {
23
25
  salla.event.on('modalOpened', () => this.onModalOpen());
24
26
  salla.event.on('modalClosed', () => this.onModalClose());
25
27
  }
28
+ ;
26
29
  onModalOpen() {
27
30
  setTimeout(() => this.searchInput.focus(), 300);
28
31
  }
@@ -40,20 +43,29 @@ export class SallaSearch {
40
43
  ' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div>' +
41
44
  '</div>';
42
45
  }
43
- search(e) {
44
- this.inputValue = e.target.value;
45
- Helper.hideElement(this.noResults);
46
- if (e.target.value.length === 0) {
46
+ debounceSearch(event) {
47
+ this.typing = true;
48
+ clearTimeout(this.debounce);
49
+ this.debounce = setTimeout(() => {
50
+ this.typing = false;
51
+ this.search_term = event.target.value;
52
+ }, 500);
53
+ }
54
+ handelSearch(val) {
55
+ this.inputValue = val;
56
+ if (val.length > 2) {
57
+ this.search(val);
58
+ }
59
+ else {
47
60
  this.results = undefined;
48
61
  this.afterSearching();
49
- return;
50
- }
51
- if (e.target.value.length <= 2) {
52
- return;
53
62
  }
63
+ }
64
+ search(val) {
65
+ Helper.hideElement(this.noResults);
54
66
  //run loading spinner or stop it
55
67
  Helper.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
56
- salla.product.search(e.target.value)
68
+ salla.product.search(val)
57
69
  .then(response => this.results = response)
58
70
  .catch(err => err !== 'Query is same as previous one!' ? this.results = undefined : null)
59
71
  .finally(() => this.afterSearching(/*isEmpty*/ false));
@@ -64,12 +76,12 @@ export class SallaSearch {
64
76
  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; })
65
77
  .toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
66
78
  salla.product.api.previousQuery = ''; //avoid having error 'Query is same as previous one!' after reopen modal;
67
- this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
79
+ this.inputValue.length < 3 ? this.container.classList.remove('s-search-no-results') : '';
68
80
  }
69
81
  render() {
70
82
  var _a;
71
- const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} },
72
- h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' }, ref: input => this.searchInput = input }),
83
+ const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container },
84
+ h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.debounceSearch(e), style: { height: this.height + 'px', borderRadius: this.oval ? this.height / 2 + 'px' : '' }, ref: input => this.searchInput = input }),
73
85
  h("span", { class: "s-search-icon-wrap" },
74
86
  h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })),
75
87
  h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
@@ -80,9 +92,9 @@ export class SallaSearch {
80
92
  .replace(/\{image\}/g, item.thumbnail) })),
81
93
  h("p", { ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, this.noResultsText)));
82
94
  return (this.inline ?
83
- h("div", { id: "s-search-modal" }, searchContent)
95
+ h("div", { class: "s-search-modal" }, searchContent)
84
96
  :
85
- h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, searchContent));
97
+ h("salla-modal", { position: "top", class: "s-search-modal", ref: modal => this.modal = modal }, searchContent));
86
98
  }
87
99
  /**
88
100
  * Run it one time after load
@@ -156,7 +168,14 @@ export class SallaSearch {
156
168
  static get states() { return {
157
169
  "results": {},
158
170
  "placeholder": {},
159
- "noResultsText": {}
171
+ "noResultsText": {},
172
+ "typing": {},
173
+ "debounce": {},
174
+ "search_term": {}
160
175
  }; }
161
176
  static get elementRef() { return "host"; }
177
+ static get watchers() { return [{
178
+ "propName": "search_term",
179
+ "methodName": "handelSearch"
180
+ }]; }
162
181
  }
@@ -1,6 +1,9 @@
1
1
  @charset "UTF-8";
2
2
  /*
3
- * Global flags style [imported from Int-tel-input]
3
+ * Salla Tel Input Component: used to get the telephone input, in login and register steps and also in user profile.
4
+ */
5
+ /*
6
+ * native style for tel-input addon
4
7
  */
5
8
  .iti {
6
9
  width: 100%;
@@ -214,12 +217,10 @@
214
217
  line-height: 1.5em;
215
218
  }
216
219
 
217
- /*
218
- * Salla Tel Input Component: used to get the telephone input, in login and register steps and also in user profile.
219
- * You can use these classes to target the elements in the component.
220
- */
221
220
  /*
222
221
  * Global flag style
222
+ * Flags from Int-tel-input
223
+ * Used in tel-input & localiztions components
223
224
  */
224
225
  .iti__flag {
225
226
  width: 20px;
@@ -1283,7 +1284,7 @@
1283
1284
  .iti__flag {
1284
1285
  height: 15px;
1285
1286
  box-shadow: 0px 0px 1px 0px #888;
1286
- background-image: url("https://intl-tel-input.com/node_modules/intl-tel-input/build/img/flags.png");
1287
+ background-image: url("https://cdn.salla.network/images/flags.png");
1287
1288
  background-repeat: no-repeat;
1288
1289
  background-color: #f5f7f9;
1289
1290
  background-position: 20px 0;
@@ -1291,9 +1292,13 @@
1291
1292
 
1292
1293
  @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
1293
1294
  .iti__flag {
1294
- background-image: url("https://intl-tel-input.com/node_modules/intl-tel-input/build/img/flags@2x.png");
1295
+ background-image: url("https://cdn.salla.network/images/flags@2x.png");
1295
1296
  }
1296
1297
  }
1297
1298
  .iti__flag.iti__np {
1298
1299
  background-color: transparent;
1299
- }
1300
+ }
1301
+
1302
+ /*
1303
+ * You can use these classes to target the elements in the component.
1304
+ */
@@ -1,14 +1,7 @@
1
1
  /*
2
- * Global flags style [imported from Int-tel-input]
3
- */
4
- /*
5
2
  * Verify Component: verify step in login and register and displays after the user change it's phone number.
6
3
  * You can use these classes to target the elements in the component.
7
4
  */
8
- salla-verify-modal {
5
+ salla-verify {
9
6
  display: block;
10
- }
11
-
12
- [dir=ltr] #s-verify-modal .s-verify-modal-back {
13
- transform: scale(-1);
14
7
  }
@@ -7,9 +7,13 @@ import Helper from "../../Helpers/Helper";
7
7
  * @slot footer - Replaces the footer, by default it contains: verify button, resend, and timer
8
8
  * @slot after-footer - placeholder position
9
9
  */
10
- export class SallaVerifyModal {
10
+ export class SallaVerify {
11
11
  constructor() {
12
12
  this.initiated = false;
13
+ /**
14
+ * Should render component without modal
15
+ */
16
+ this.display = 'modal';
13
17
  /**
14
18
  * Verifying method
15
19
  */
@@ -30,7 +34,7 @@ export class SallaVerifyModal {
30
34
  (_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
31
35
  (_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('pages.profile.verify'));
32
36
  });
33
- if (this.withoutModal) {
37
+ if (this.display == 'inline') {
34
38
  this.modal = { open: () => '', close: () => '', setTitle: () => '' };
35
39
  return;
36
40
  }
@@ -63,10 +67,10 @@ export class SallaVerifyModal {
63
67
  this.data.type = this.data.type || this.type;
64
68
  this.type = this.data.type;
65
69
  this.resendTimer();
66
- this.otpInputs = document.querySelectorAll('.s-verify-modal-input');
70
+ this.otpInputs = this.body.querySelectorAll('.s-verify-input');
67
71
  if (!this.initiated) {
68
- Helper.on('input', '.s-verify-modal-input', e => salla.helpers.inputDigitsOnly(e.target));
69
- Helper.onKeyUp('.s-verify-modal-input', event => {
72
+ Helper.on('input', '.s-verify-input', e => salla.helpers.inputDigitsOnly(e.target));
73
+ Helper.onKeyUp('.s-verify-input', event => {
70
74
  var _a, _b, _c, _d;
71
75
  let key = event.keyCode || event.charCode;
72
76
  if (event.target.value) {
@@ -79,7 +83,7 @@ export class SallaVerifyModal {
79
83
  }
80
84
  this.toggleOTPSubmit();
81
85
  });
82
- Helper.on('paste', '.s-verify-modal-input', event => {
86
+ Helper.on('paste', '.s-verify-input', event => {
83
87
  let text = salla.helpers.number(event.clipboardData.getData('text')).replace(/[^0-9.]/g, '').replace('..', '.');
84
88
  this.otpInputs.forEach((input, i) => input.value = text[i] || '');
85
89
  this.toggleOTPSubmit();
@@ -89,8 +93,10 @@ export class SallaVerifyModal {
89
93
  this.initiated = true;
90
94
  }
91
95
  this.reset();
92
- !this.withoutModal && ((_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title));
96
+ this.display == 'modal' && ((_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title));
93
97
  this.modal.open();
98
+ // focus the first input after opening the modal
99
+ setTimeout(() => this.otpInputs[0].focus(), 100);
94
100
  }
95
101
  toggleOTPSubmit() {
96
102
  let otp = [];
@@ -144,36 +150,36 @@ export class SallaVerifyModal {
144
150
  .catch(() => this.btn.stop() && this.btn.enable() && this.reset());
145
151
  }
146
152
  render() {
147
- return this.withoutModal ? h(Host, null, this.myBody()) :
148
- h("salla-modal", { icon: "sicon-android-phone", width: "xs", id: "s-verify-modal", ref: modal => this.modal = modal, "modal-title": this.title }, this.myBody());
153
+ return this.display == 'inline' ? h(Host, null, this.myBody()) :
154
+ h("salla-modal", { icon: "sicon-android-phone", width: "xs", class: "s-verify", ref: modal => this.modal = modal, "modal-title": this.title }, this.myBody());
149
155
  }
150
156
  myBody() {
151
- return (h("div", { id: "s-verify-modal" },
152
- h("div", { class: "s-verify-modal-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
157
+ return (h("div", { class: "s-verify-body", ref: body => this.body = body },
158
+ h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
153
159
  h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
154
- h("div", { class: "s-verify-modal-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "text", maxlength: "1", class: "s-verify-modal-input", required: true }))),
155
- h("div", { slot: "footer", class: "s-verify-modal-footer" },
156
- h("salla-button", { class: "s-verify-modal-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')),
157
- h("p", { class: "s-verify-modal-resend-message", ref: el => this.resendMessage = el },
160
+ 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 }))),
161
+ h("div", { slot: "footer", class: "s-verify-footer" },
162
+ 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')),
163
+ h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el },
158
164
  salla.lang.get('blocks.header.resend_after'),
159
- h("b", { class: "s-verify-modal-timer", ref: el => this.timer = el })),
160
- h("a", { href: "#", class: "s-verify-modal-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))),
165
+ h("b", { class: "s-verify-timer", ref: el => this.timer = el })),
166
+ h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))),
161
167
  h("slot", { name: "after-footer" })));
162
168
  }
163
- static get is() { return "salla-verify-modal"; }
169
+ static get is() { return "salla-verify"; }
164
170
  static get originalStyleUrls() { return {
165
- "$": ["salla-verify-modal.scss"]
171
+ "$": ["salla-verify.scss"]
166
172
  }; }
167
173
  static get styleUrls() { return {
168
- "$": ["salla-verify-modal.css"]
174
+ "$": ["salla-verify.css"]
169
175
  }; }
170
176
  static get properties() { return {
171
- "withoutModal": {
172
- "type": "boolean",
177
+ "display": {
178
+ "type": "string",
173
179
  "mutable": false,
174
180
  "complexType": {
175
- "original": "boolean",
176
- "resolved": "boolean",
181
+ "original": "'inline' | 'modal'",
182
+ "resolved": "\"inline\" | \"modal\"",
177
183
  "references": {}
178
184
  },
179
185
  "required": false,
@@ -182,8 +188,9 @@ export class SallaVerifyModal {
182
188
  "tags": [],
183
189
  "text": "Should render component without modal"
184
190
  },
185
- "attribute": "without-modal",
186
- "reflect": false
191
+ "attribute": "display",
192
+ "reflect": false,
193
+ "defaultValue": "'modal'"
187
194
  },
188
195
  "type": {
189
196
  "type": "string",
@@ -26,8 +26,12 @@ fs.readdirSync(componentsPath, {withFileTypes: true})
26
26
  for (const [keyComponent, value] of Object.entries(components)) {
27
27
  console.log('> Processing ' + keyComponent + ' ...');
28
28
  _.forEach(value, function (value, keyUtility) {
29
- keyUtility = '.s-' + keyComponent + '-' + keyUtility;
30
- utilities[keyUtility] = {[`@apply ${value}`]: {}};
29
+ if(typeof value === 'string'){
30
+ keyUtility = '.s-' + keyComponent + '-' + keyUtility;
31
+ utilities[keyUtility] = {[`@apply ${value}`]: {}};
32
+ }else{
33
+ utilities[keyUtility] = value;
34
+ }
31
35
  });
32
36
  console.log('✓ Processed ' + keyComponent + '');
33
37
  }
@@ -6,11 +6,11 @@ module.exports = require('tailwindcss/plugin').withOptions(() => {
6
6
  '.text-md' : {},
7
7
  '.s-has-error' : {'@apply border-red-400 focus:border-red-500': {}},
8
8
  '.rounded-icon' : {'@apply w-16 h-16 flex justify-center items-center rounded-full text-3xl': {}},
9
- '.form-input' : {'@apply w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary dark:focus:border-primary sm:text-sm border-border-color dark:bg-gray-600 dark:border-gray-600 rounded-md': {}},
9
+ '.form-input' : {'@apply w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary dark:focus:border-primary sm:text-sm border-gray-150 dark:bg-gray-600 dark:border-gray-600 rounded-md': {}},
10
10
  '.btn' : {'@apply transition duration-300 flex-1 inline-flex justify-center items-center px-6 pb-2.5 pt-2 text-sm font-bold rounded-md hover:opacity-80 whitespace-nowrap': {}},
11
11
  '.btn-primary' : {'@apply text-primary-reverse border border-primary bg-primary': {}},
12
- '.btn-danger' : {'@apply bg-theme-red text-white hover:opacity-80': {}},
13
- '.btn-outline' : {'@apply text-gray-400 bg-white shadow-sm hover:text-gray-600 border border-border-color': {}},
12
+ '.btn-danger' : {'@apply bg-red-400 text-white hover:opacity-80': {}},
13
+ '.btn-outline' : {'@apply text-gray-400 bg-white shadow-sm hover:text-gray-600 border border-gray-150': {}},
14
14
  '.btn-outline-primary': {'@apply border border-primary text-primary hover:bg-primary hover:text-reverse': {}},
15
15
  });
16
16
 
@@ -1,6 +1,21 @@
1
1
  /* TwilightComponents custom elements */
2
-
3
- import type { Components, JSX } from "../types/components";
2
+ export { SallaAddProductButton as SallaAddProductButton } from '../types/components/salla-add-product-button/salla-add-product-button';
3
+ export { SallaBranches as SallaBranches } from '../types/components/salla-branches/salla-branches';
4
+ export { SallaButton as SallaButton } from '../types/components/salla-button/salla-button';
5
+ export { SallaConditionalFields as SallaConditionalFields } from '../types/components/salla-conditional-fields/salla-conditional-fields';
6
+ export { SallaInfiniteScroll as SallaInfiniteScroll } from '../types/components/salla-infinite-scroll/salla-infinite-scroll';
7
+ export { SallaInstallment as SallaInstallment } from '../types/components/salla-installment/salla-installment';
8
+ export { SallaLocalizationModal as SallaLocalizationModal } from '../types/components/salla-localization-modal/salla-localization-modal';
9
+ export { SallaLoginModal as SallaLoginModal } from '../types/components/salla-login-modal/salla-login-modal';
10
+ export { SallaModal as SallaModal } from '../types/components/salla-modal/salla-modal';
11
+ export { SallaOfferModal as SallaOfferModal } from '../types/components/salla-offer-modal/salla-offer-modal';
12
+ export { SallaProductAvailability as SallaProductAvailability } from '../types/components/salla-product-availability/salla-product-availability';
13
+ export { SallaQuantityInput as SallaQuantityInput } from '../types/components/salla-quantity-input/salla-quantity-input';
14
+ export { SallaRatingModal as SallaRatingModal } from '../types/components/salla-rating-modal/salla-rating-modal';
15
+ export { SallaRatingStars as SallaRatingStars } from '../types/components/salla-rating-stars/salla-rating-stars';
16
+ export { SallaSearch as SallaSearch } from '../types/components/salla-search/salla-search';
17
+ export { SallaTelInput as SallaTelInput } from '../types/components/salla-tel-input/salla-tel-input';
18
+ export { SallaVerify as SallaVerify } from '../types/components/salla-verify/salla-verify';
4
19
 
5
20
  /**
6
21
  * Used to manually set the base path where assets can be found.
@@ -20,7 +35,4 @@ export interface SetPlatformOptions {
20
35
  rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
21
36
  }
22
37
  export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
23
-
24
- export type { Components, JSX };
25
-
26
38
  export * from '../types';
@@ -2,3 +2,20 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
5
+ export { SallaAddProductButton, defineCustomElement as defineCustomElementSallaAddProductButton } from './salla-add-product-button.js';
6
+ export { SallaBranches, defineCustomElement as defineCustomElementSallaBranches } from './salla-branches.js';
7
+ export { SallaButton, defineCustomElement as defineCustomElementSallaButton } from './salla-button.js';
8
+ export { SallaConditionalFields, defineCustomElement as defineCustomElementSallaConditionalFields } from './salla-conditional-fields.js';
9
+ export { SallaInfiniteScroll, defineCustomElement as defineCustomElementSallaInfiniteScroll } from './salla-infinite-scroll.js';
10
+ export { SallaInstallment, defineCustomElement as defineCustomElementSallaInstallment } from './salla-installment.js';
11
+ export { SallaLocalizationModal, defineCustomElement as defineCustomElementSallaLocalizationModal } from './salla-localization-modal.js';
12
+ export { SallaLoginModal, defineCustomElement as defineCustomElementSallaLoginModal } from './salla-login-modal.js';
13
+ export { SallaModal, defineCustomElement as defineCustomElementSallaModal } from './salla-modal.js';
14
+ export { SallaOfferModal, defineCustomElement as defineCustomElementSallaOfferModal } from './salla-offer-modal.js';
15
+ export { SallaProductAvailability, defineCustomElement as defineCustomElementSallaProductAvailability } from './salla-product-availability.js';
16
+ export { SallaQuantityInput, defineCustomElement as defineCustomElementSallaQuantityInput } from './salla-quantity-input.js';
17
+ export { SallaRatingModal, defineCustomElement as defineCustomElementSallaRatingModal } from './salla-rating-modal.js';
18
+ export { SallaRatingStars, defineCustomElement as defineCustomElementSallaRatingStars } from './salla-rating-stars.js';
19
+ export { SallaSearch, defineCustomElement as defineCustomElementSallaSearch } from './salla-search.js';
20
+ export { SallaTelInput, defineCustomElement as defineCustomElementSallaTelInput } from './salla-tel-input.js';
21
+ export { SallaVerify, defineCustomElement as defineCustomElementSallaVerify } from './salla-verify.js';
@@ -22,10 +22,6 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
22
22
  this.donatingAmount = 0;
23
23
  this.productStatus = 'sale';
24
24
  this.productType = 'product';
25
- /**
26
- * Is the button currently disabled
27
- */
28
- this.disabled = false;
29
25
  }
30
26
  getLabel() {
31
27
  if (this.productStatus === 'sale') {
@@ -48,13 +44,20 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
48
44
  * but its work only when the id is the only value is passed via the object
49
45
  * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action
50
46
  */
51
- return salla.cart.quickAdd(Object.entries({
47
+ const data = Object.entries({
52
48
  id: this.productId,
53
49
  donating_amount: this.donatingAmount,
54
50
  quantity: this.quantity
55
- }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {}))
56
- .then((response) => this.success.emit(response))
57
- .catch((error) => this.failed.emit(error));
51
+ }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
52
+ return salla.cart.quickAdd(data)
53
+ .then((response) => {
54
+ console.log("🚀 ~ file: salla-add-product-button.tsx ~ line 67 ~ SallaAddProductButton ~ .then ~ response", response);
55
+ return this.success.emit(response);
56
+ })
57
+ .catch((error) => {
58
+ console.log("🚀 ~ file: salla-add-product-button.tsx ~ line 70 ~ SallaAddProductButton ~ addProductToCart ~ error", error);
59
+ return this.failed.emit(error);
60
+ });
58
61
  }
59
62
  getBtnAttributes() {
60
63
  for (let i = 0; i < this.host.attributes.length; i++) {
@@ -70,11 +73,11 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
70
73
  render() {
71
74
  return (h(Host, null, this.productStatus === 'out-and-notify' && this.channels ?
72
75
  h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), h("slot", null)) :
73
- h("salla-button", Object.assign({ ref: btn => this.btn = btn, 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))));
76
+ 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))));
74
77
  }
75
78
  componentDidRender() {
76
79
  //if label not passed, get label
77
- this.hasLabel || salla.lang.onLoaded(() => { var _a; return (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(this.getLabel() || 'اضافة للسلة'); });
80
+ this.hasLabel || salla.event.on('languages::translations.loaded', () => this.btn.setText(this.getLabel() || 'اضافة للسلة'));
78
81
  }
79
82
  get host() { return this; }
80
83
  static get style() { return sallaAddProductButtonCss; }
@@ -84,8 +87,7 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
84
87
  "donatingAmount": [514, "donating-amount"],
85
88
  "productId": [520, "product-id"],
86
89
  "productStatus": [513, "product-status"],
87
- "productType": [513, "product-type"],
88
- "disabled": [516]
90
+ "productType": [513, "product-type"]
89
91
  }]);
90
92
  function defineCustomElement$1() {
91
93
  if (typeof customElements === "undefined") {
@@ -11,7 +11,7 @@ const SallaBranches$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
11
11
  constructor() {
12
12
  super();
13
13
  this.__registerHost();
14
- this.open = false;
14
+ this.open = true;
15
15
  this.isOpenedBefore = salla.storage.get("branch-choosed-before");
16
16
  this.displayAs = 'default'; //todo:: change it to boolean, isPopup default false
17
17
  this.browseProductsFrom = 'all'; //todo:: get better name
@@ -45,10 +45,12 @@ const SallaBranches$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
45
45
  }
46
46
  //todo:: add description for all @methods
47
47
  async show() {
48
- return this.modal.open();
48
+ var _a;
49
+ return (_a = this.modal) === null || _a === void 0 ? void 0 : _a.open();
49
50
  }
50
51
  async hide() {
51
- return this.modal.close();
52
+ var _a;
53
+ return (_a = this.modal) === null || _a === void 0 ? void 0 : _a.close();
52
54
  }
53
55
  handelChange(event) {
54
56
  this.selected = event.target.value;
@@ -64,7 +66,9 @@ const SallaBranches$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
64
66
  }, 300);
65
67
  }
66
68
  render() {
67
- return (h("salla-modal", { icon: "sicon-store-alt", "modal-title": "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636", "sub-title": "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646", "sub-title-first": true, "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, width: "sm", id: "s-branches-modal", class: "s-hidden" }, h("h4", { class: "s-branches-title" }, this.formTitle()), this.branches.length <= 5 ?
69
+ return (h("salla-modal", { icon: "sicon-store-alt", "modal-title": "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636", "sub-title": "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646", "sub-title-first": true,
70
+ // is-closable={!this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true'}
71
+ ref: (modal) => this.modal = modal, width: "sm", id: "s-branches-modal", class: "s-hidden" }, h("h4", { class: "s-branches-title" }, this.formTitle()), this.branches.length <= 5 ?
68
72
  h("div", { class: "s-branches-space-v" }, this.branches.map((branch) => h("div", { class: "s-branches-input-wrap" }, h("input", { id: this.position + '_branch_' + branch.id, disabled: !branch.open && this.isChoiceable(), name: "lang", type: "radio", value: branch.id, onChange: (event) => this.handelChange(event), class: {
69
73
  's-branches-input': true,
70
74
  'opacity-50': !branch.open,
@@ -78,7 +82,7 @@ const SallaBranches$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
78
82
  h("span", { class: this.statusColor(branch) }, branch.tag)))))
79
83
  :
80
84
  h("select", { class: "s-branches-select", onInput: (event) => this.handelChange(event) }, this.branches.map(branch => (h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق')))), this.isChoiceable() ?
81
- h("slot", { name: "footer" }, h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", wide: true }, salla.lang.get('common.elements.ok')))
85
+ h("slot", { name: "footer" }, h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", width: "wide" }, salla.lang.get('common.elements.ok')))
82
86
  : ''));
83
87
  }
84
88
  componentDidRender() {