@salla.sa/twilight-components 2.11.110 → 2.11.112

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 (150) hide show
  1. package/README.md +48 -42
  2. package/dist/cjs/{app-globals-c392da62.js → app-globals-38ac4fe8.js} +2 -2
  3. package/dist/cjs/{app-globals-c392da62.js.map → app-globals-38ac4fe8.js.map} +1 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/salla-add-product-button_40.cjs.entry.js +74 -24
  6. package/dist/cjs/salla-add-product-button_40.cjs.entry.js.map +1 -1
  7. package/dist/cjs/salla-filters-widget.cjs.entry.js +5 -27
  8. package/dist/cjs/salla-filters-widget.cjs.entry.js.map +1 -1
  9. package/dist/cjs/salla-filters.cjs.entry.js +8 -4
  10. package/dist/cjs/salla-filters.cjs.entry.js.map +1 -1
  11. package/dist/cjs/salla-price-range.cjs.entry.js +109 -37
  12. package/dist/cjs/salla-price-range.cjs.entry.js.map +1 -1
  13. package/dist/cjs/salla-products-list.cjs.entry.js +85 -59
  14. package/dist/cjs/salla-products-list.cjs.entry.js.map +1 -1
  15. package/dist/cjs/salla-products-slider.cjs.entry.js +12 -4
  16. package/dist/cjs/salla-products-slider.cjs.entry.js.map +1 -1
  17. package/dist/cjs/twilight.cjs.js +2 -2
  18. package/dist/collection/components/salla-filters/salla-filters.js +8 -4
  19. package/dist/collection/components/salla-filters/salla-filters.js.map +1 -1
  20. package/dist/collection/components/salla-filters-widget/salla-filters-widget.js +5 -27
  21. package/dist/collection/components/salla-filters-widget/salla-filters-widget.js.map +1 -1
  22. package/dist/collection/components/salla-login-modal/intefaces.js.map +1 -1
  23. package/dist/collection/components/salla-login-modal/salla-login-modal.js +1 -1
  24. package/dist/collection/components/salla-login-modal/salla-login-modal.js.map +1 -1
  25. package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js +14 -1
  26. package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js.map +1 -1
  27. package/dist/collection/components/salla-price-range/salla-price-range.js +152 -148
  28. package/dist/collection/components/salla-price-range/salla-price-range.js.map +1 -1
  29. package/dist/collection/components/salla-products-list/salla-products-list.js +85 -59
  30. package/dist/collection/components/salla-products-list/salla-products-list.js.map +1 -1
  31. package/dist/collection/components/salla-products-slider/salla-products-slider.js +29 -5
  32. package/dist/collection/components/salla-products-slider/salla-products-slider.js.map +1 -1
  33. package/dist/collection/components/salla-verify/salla-verify.css +12 -0
  34. package/dist/collection/components/salla-verify/salla-verify.js +59 -21
  35. package/dist/collection/components/salla-verify/salla-verify.js.map +1 -1
  36. package/dist/components/index.js +1 -1
  37. package/dist/components/index.js.map +1 -1
  38. package/dist/components/salla-filters-widget2.js +5 -27
  39. package/dist/components/salla-filters-widget2.js.map +1 -1
  40. package/dist/components/salla-filters.js +8 -4
  41. package/dist/components/salla-filters.js.map +1 -1
  42. package/dist/components/salla-login-modal.js +1 -1
  43. package/dist/components/salla-login-modal.js.map +1 -1
  44. package/dist/components/salla-maintenance-alert.js +14 -1
  45. package/dist/components/salla-maintenance-alert.js.map +1 -1
  46. package/dist/components/salla-price-range2.js +113 -43
  47. package/dist/components/salla-price-range2.js.map +1 -1
  48. package/dist/components/salla-products-list.js +85 -59
  49. package/dist/components/salla-products-list.js.map +1 -1
  50. package/dist/components/salla-products-slider.js +13 -5
  51. package/dist/components/salla-products-slider.js.map +1 -1
  52. package/dist/components/salla-verify2.js +60 -22
  53. package/dist/components/salla-verify2.js.map +1 -1
  54. package/dist/esm/{app-globals-663240cc.js → app-globals-3a81b4f2.js} +2 -2
  55. package/dist/esm/{app-globals-663240cc.js.map → app-globals-3a81b4f2.js.map} +1 -1
  56. package/dist/esm/loader.js +2 -2
  57. package/dist/esm/salla-add-product-button_40.entry.js +74 -24
  58. package/dist/esm/salla-add-product-button_40.entry.js.map +1 -1
  59. package/dist/esm/salla-filters-widget.entry.js +5 -27
  60. package/dist/esm/salla-filters-widget.entry.js.map +1 -1
  61. package/dist/esm/salla-filters.entry.js +8 -4
  62. package/dist/esm/salla-filters.entry.js.map +1 -1
  63. package/dist/esm/salla-price-range.entry.js +109 -37
  64. package/dist/esm/salla-price-range.entry.js.map +1 -1
  65. package/dist/esm/salla-products-list.entry.js +85 -59
  66. package/dist/esm/salla-products-list.entry.js.map +1 -1
  67. package/dist/esm/salla-products-slider.entry.js +12 -4
  68. package/dist/esm/salla-products-slider.entry.js.map +1 -1
  69. package/dist/esm/twilight.js +2 -2
  70. package/dist/esm-es5/{app-globals-663240cc.js → app-globals-3a81b4f2.js} +2 -2
  71. package/dist/{twilight/p-dcfa0f39.system.js.map → esm-es5/app-globals-3a81b4f2.js.map} +1 -1
  72. package/dist/esm-es5/loader.js +1 -1
  73. package/dist/esm-es5/loader.js.map +1 -1
  74. package/dist/esm-es5/salla-add-product-button_40.entry.js +4 -4
  75. package/dist/esm-es5/salla-add-product-button_40.entry.js.map +1 -1
  76. package/dist/esm-es5/salla-filters-widget.entry.js +1 -1
  77. package/dist/esm-es5/salla-filters-widget.entry.js.map +1 -1
  78. package/dist/esm-es5/salla-filters.entry.js +1 -1
  79. package/dist/esm-es5/salla-filters.entry.js.map +1 -1
  80. package/dist/esm-es5/salla-price-range.entry.js +2 -2
  81. package/dist/esm-es5/salla-price-range.entry.js.map +1 -1
  82. package/dist/esm-es5/salla-products-list.entry.js +2 -2
  83. package/dist/esm-es5/salla-products-list.entry.js.map +1 -1
  84. package/dist/esm-es5/salla-products-slider.entry.js +1 -1
  85. package/dist/esm-es5/salla-products-slider.entry.js.map +1 -1
  86. package/dist/esm-es5/twilight.js +1 -1
  87. package/dist/esm-es5/twilight.js.map +1 -1
  88. package/dist/twilight/{p-6948b825.js → p-1edec127.js} +2 -2
  89. package/dist/twilight/{p-6948b825.js.map → p-1edec127.js.map} +1 -1
  90. package/dist/twilight/{p-7c6638f5.system.entry.js → p-2739ddc5.system.entry.js} +2 -2
  91. package/dist/twilight/p-2739ddc5.system.entry.js.map +1 -0
  92. package/dist/twilight/p-3212e42c.entry.js +5 -0
  93. package/dist/twilight/p-3212e42c.entry.js.map +1 -0
  94. package/dist/twilight/{p-6404a9a5.system.js → p-37389934.system.js} +2 -2
  95. package/dist/twilight/{p-6404a9a5.system.js.map → p-37389934.system.js.map} +1 -1
  96. package/dist/twilight/{p-dcfa0f39.system.js → p-38496eab.system.js} +2 -2
  97. package/dist/{esm-es5/app-globals-663240cc.js.map → twilight/p-38496eab.system.js.map} +1 -1
  98. package/dist/twilight/p-3f03d17c.system.entry.js +5 -0
  99. package/dist/twilight/p-3f03d17c.system.entry.js.map +1 -0
  100. package/dist/twilight/p-46b7f931.system.entry.js +5 -0
  101. package/dist/twilight/p-46b7f931.system.entry.js.map +1 -0
  102. package/dist/twilight/p-54783694.system.entry.js +5 -0
  103. package/dist/twilight/p-54783694.system.entry.js.map +1 -0
  104. package/dist/twilight/{p-1e4abb42.system.entry.js → p-9a1231a6.system.entry.js} +2 -2
  105. package/dist/twilight/p-9a1231a6.system.entry.js.map +1 -0
  106. package/dist/twilight/{p-9713044b.entry.js → p-b766115a.entry.js} +2 -2
  107. package/dist/twilight/p-b766115a.entry.js.map +1 -0
  108. package/dist/twilight/p-cd5cb2f7.entry.js +5 -0
  109. package/dist/twilight/p-cd5cb2f7.entry.js.map +1 -0
  110. package/dist/twilight/p-d7a62fb3.system.entry.js +5 -0
  111. package/dist/twilight/p-d7a62fb3.system.entry.js.map +1 -0
  112. package/dist/twilight/p-def222e1.entry.js +5 -0
  113. package/dist/twilight/p-def222e1.entry.js.map +1 -0
  114. package/dist/twilight/p-e393f123.entry.js +5 -0
  115. package/dist/twilight/p-e393f123.entry.js.map +1 -0
  116. package/dist/twilight/p-e3dc0687.entry.js +5 -0
  117. package/dist/twilight/p-e3dc0687.entry.js.map +1 -0
  118. package/dist/twilight/twilight.esm.js +1 -1
  119. package/dist/twilight/twilight.esm.js.map +1 -1
  120. package/dist/twilight/twilight.js +1 -1
  121. package/dist/types/components/salla-filters-widget/salla-filters-widget.d.ts +0 -7
  122. package/dist/types/components/salla-login-modal/intefaces.d.ts +1 -0
  123. package/dist/types/components/salla-maintenance-alert/salla-maintenance-alert.d.ts +3 -0
  124. package/dist/types/components/salla-price-range/salla-price-range.d.ts +16 -10
  125. package/dist/types/components/salla-products-list/salla-products-list.d.ts +2 -2
  126. package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +5 -1
  127. package/dist/types/components/salla-verify/salla-verify.d.ts +6 -1
  128. package/dist/types/components.d.ts +14 -8
  129. package/package.json +4 -4
  130. package/dist/twilight/p-1e4abb42.system.entry.js.map +0 -1
  131. package/dist/twilight/p-3b1a0059.entry.js +0 -5
  132. package/dist/twilight/p-3b1a0059.entry.js.map +0 -1
  133. package/dist/twilight/p-41b3e09d.entry.js +0 -5
  134. package/dist/twilight/p-41b3e09d.entry.js.map +0 -1
  135. package/dist/twilight/p-4a743b5e.system.entry.js +0 -5
  136. package/dist/twilight/p-4a743b5e.system.entry.js.map +0 -1
  137. package/dist/twilight/p-62c1b309.entry.js +0 -5
  138. package/dist/twilight/p-62c1b309.entry.js.map +0 -1
  139. package/dist/twilight/p-6349125a.entry.js +0 -5
  140. package/dist/twilight/p-6349125a.entry.js.map +0 -1
  141. package/dist/twilight/p-7c6638f5.system.entry.js.map +0 -1
  142. package/dist/twilight/p-8ee37cc6.entry.js +0 -5
  143. package/dist/twilight/p-8ee37cc6.entry.js.map +0 -1
  144. package/dist/twilight/p-9713044b.entry.js.map +0 -1
  145. package/dist/twilight/p-9e27da8e.system.entry.js +0 -5
  146. package/dist/twilight/p-9e27da8e.system.entry.js.map +0 -1
  147. package/dist/twilight/p-b1f8b436.system.entry.js +0 -5
  148. package/dist/twilight/p-b1f8b436.system.entry.js.map +0 -1
  149. package/dist/twilight/p-c9cdaea6.system.entry.js +0 -5
  150. package/dist/twilight/p-c9cdaea6.system.entry.js.map +0 -1
@@ -6,64 +6,137 @@ export class SallaPriceRange {
6
6
  constructor() {
7
7
  this.minPrice = 1000;
8
8
  this.maxPrice = 5000;
9
+ this.option = undefined;
10
+ this.filtersData = undefined;
9
11
  this.min = 0;
10
12
  this.max = 10000;
11
13
  this.minthumb = 0;
12
14
  this.maxthumb = 0;
15
+ this.priceOptions = undefined;
16
+ this.generatePriceOptions();
13
17
  }
14
- componentWillLoad() {
15
- this.minTrigger();
16
- this.maxTrigger();
18
+ async reset() {
19
+ var _a, _b;
20
+ //@ts-ignore
21
+ this.minInput.value = `${((_b = (_a = this.option) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.min) || 0}`;
22
+ this.maxInput.value = `${this.max}`;
17
23
  }
18
- async minTrigger(event = null) {
19
- let value = event ? event.target.value * 1 : null;
20
- this.minInputValidation(value);
21
- this.minthumb = ((this.minPrice - this.min) / (this.max - this.min)) * 100;
22
- this.changeLeftHandle();
23
- this.isReady && this.minPriceSelected.emit(value);
24
+ generatePriceOptions() {
25
+ const MAX_PRICE = this.max;
26
+ let option1 = Math.floor(MAX_PRICE / 100);
27
+ if (option1 < 1) {
28
+ option1 = Math.floor(MAX_PRICE / 10);
29
+ }
30
+ let option2 = Math.floor(MAX_PRICE / 2);
31
+ let option3 = Math.floor((MAX_PRICE / 3) * 2);
32
+ this.priceOptions = [option1, option2, option3];
33
+ // to be removed
34
+ console.log(`Price options for max price ${MAX_PRICE}: ${this.priceOptions.join(', ')}`);
35
+ }
36
+ getPriceLabel(price) {
37
+ if (price == Math.floor(this.max / 100)) {
38
+ return `اقل من ${salla.money(price)}`;
39
+ }
40
+ else if (price == Math.floor(this.max / 2)) {
41
+ return `${salla.money(this.priceOptions[0])} الى ${salla.money(this.priceOptions[2])}`;
42
+ }
43
+ else {
44
+ return `أكثر من ${salla.money(price)}`;
45
+ }
46
+ }
47
+ handleMinMaxPrice(event, option) {
48
+ const [firstOption, secondOption, thirdOption] = this.priceOptions;
49
+ switch (option) {
50
+ case firstOption:
51
+ this.minPrice = 0;
52
+ this.maxPrice = firstOption;
53
+ break;
54
+ case secondOption:
55
+ this.minPrice = firstOption;
56
+ this.maxPrice = thirdOption;
57
+ break;
58
+ case thirdOption:
59
+ this.minPrice = thirdOption;
60
+ this.maxPrice = this.max;
61
+ break;
62
+ default:
63
+ throw new Error(`Invalid price option: ${option}`);
64
+ }
65
+ // Update the input values
66
+ this.minInput.value = `${this.minPrice}`;
67
+ this.maxInput.value = `${this.maxPrice}`;
68
+ this.changedEventHandler(event);
24
69
  }
25
- async maxTrigger(event = null) {
70
+ async changedEventHandler(event, isMin = false) {
26
71
  let value = event ? event.target.value * 1 : null;
27
- this.maxInputValidation(value);
28
- this.maxthumb = 100 - (((this.maxPrice - this.min) / (this.max - this.min)) * 100);
29
- this.changeRightHandle();
30
- this.isReady && this.maxPriceSelected.emit(value);
72
+ if (isMin) {
73
+ this.minInputValidation(value);
74
+ this.minthumb = ((this.minPrice - this.min) / (this.max - this.min)) * 100;
75
+ }
76
+ else {
77
+ this.maxInputValidation(value);
78
+ this.maxthumb = 100 - (((this.maxPrice - this.min) / (this.max - this.min)) * 100);
79
+ }
80
+ this.isReady && this.changed.emit({
81
+ event: event,
82
+ option: this.option,
83
+ value: { max: this.maxPrice, min: this.minPrice }
84
+ });
31
85
  }
32
- async minInputValidation(value) {
33
- if (value && (value > this.max || value > this.maxPrice))
86
+ minInputValidation(value) {
87
+ if (value && (value > this.max || value > this.maxPrice)) {
88
+ // this.minPrice = this.maxPrice;
34
89
  return;
35
- else if (value < this.min) {
90
+ }
91
+ if (value < this.min) {
36
92
  this.minPrice = this.min;
93
+ return;
37
94
  }
38
- else {
39
- value && (this.minPrice = value);
95
+ if (value) {
96
+ this.minPrice = value;
40
97
  }
41
98
  }
42
- async maxInputValidation(value) {
43
- if (value && (value < this.min || value < this.minPrice))
99
+ maxInputValidation(value) {
100
+ if (value && (value < this.min || value < this.minPrice)) {
101
+ // this.maxPrice = this.minPrice;
44
102
  return;
45
- else if (value > this.max) {
103
+ }
104
+ if (value > this.max) {
46
105
  this.maxPrice = this.max;
106
+ return;
47
107
  }
48
- else {
49
- value && (this.maxPrice = value);
108
+ if (value) {
109
+ this.maxPrice = value;
50
110
  }
51
111
  }
52
- async changeRightHandle() {
53
- this.rightHandle && (this.rightHandle.style.right = `${this.maxthumb}%`);
54
- this.activeBar && (this.activeBar.style.right = `${this.maxthumb}%`);
55
- }
56
- async changeLeftHandle() {
57
- this.leftHandle && (this.leftHandle.style.left = `${this.minthumb}%`);
58
- this.activeBar && (this.activeBar.style.left = `${this.minthumb}%`);
112
+ isChecked(option) {
113
+ if (option == Math.floor(this.max / 100)) {
114
+ return this.minPrice == 0 && this.maxPrice == option;
115
+ }
116
+ if (option == Math.floor(this.max / 2)) {
117
+ return this.minPrice == this.priceOptions[0] && this.maxPrice == this.priceOptions[2];
118
+ }
119
+ if (option == Math.floor((this.max / 3) * 2)) {
120
+ return this.minPrice == option && this.maxPrice == this.max;
121
+ }
59
122
  }
60
123
  render() {
61
- return (h(Host, null, h("div", { style: { direction: 'ltr' }, class: "flex justify-center items-center" }, h("div", { class: "relative max-w-xl w-full" }, h("div", { class: "rtl-range-slider" }, h("input", { type: "range", step: "100", min: this.min, max: this.max, onInput: (event) => this.minTrigger(event), value: this.minPrice, class: "s-price-range-input" }), h("input", { type: "range", step: "100", min: this.min, max: this.max, onInput: (event) => this.maxTrigger(event), value: this.maxPrice, class: "s-price-range-input" }), h("div", { class: "s-price-range-bar-container" }, h("div", { class: "s-price-range-bar" }), h("div", { class: "s-price-range-active-bar", ref: (el) => this.activeBar = el }), h("div", { class: "s-price-range-left-handle", ref: (el) => this.leftHandle = el }), h("div", { class: "s-price-range-right-handle", ref: (el) => this.rightHandle = el }))), h("div", { class: "s-price-range-inputs" }, h("div", { class: "s-price-range-relative" }, h("div", { class: "s-price-range-currency" }, " ", salla.config.currency().symbol), h("input", { type: "number", maxlength: "5", onInput: (event) => this.minTrigger(event), value: this.minPrice, class: "s-price-range-number-input" })), h("div", { class: "s-price-range-gray-text" }, " - "), h("div", { class: "s-price-range-relative" }, h("div", { class: "s-price-range-currency" }, " ", salla.config.currency().symbol), h("input", { type: "number", maxlength: "5", onInput: (event) => this.maxTrigger(event), value: this.maxPrice, class: "s-price-range-number-input", placeholder: "0.00", "aria-describedby": "price-currency" })))))));
124
+ return (h(Host, null, this.priceOptions && this.priceOptions.map((option, index) => {
125
+ return h("label", { class: "s-filters-label", htmlFor: `${option}-${index}` }, h("input", { id: `${option}-${index}`, name: "price", type: "radio", checked: this.isChecked(option), class: "s-filters-radio", onChange: e => this.handleMinMaxPrice(e, option) }), this.getPriceLabel(option));
126
+ }), h("div", { class: "flex justify-center items-center" }, h("div", { class: "relative max-w-xl w-full" }, h("div", { class: "s-price-range-inputs" }, h("div", { class: "s-price-range-relative" }, h("div", { class: "s-price-range-currency" }, " ", salla.config.currency().symbol), h("input", { type: "number", maxlength: "5", ref: el => this.minInput = el, onInput: (event) => this.changedEventHandler(event, true),
127
+ // value={this.minPrice}
128
+ placeholder: "\u0645\u0646", class: "s-price-range-number-input" })), h("div", { class: "s-price-range-gray-text" }, " -"), h("div", { class: "s-price-range-relative" }, h("div", { class: "s-price-range-currency" }, " ", salla.config.currency().symbol), h("input", { type: "number", maxlength: "5", placeholder: "\u0627\u0644\u0649", ref: el => this.maxInput = el, onInput: (event) => this.changedEventHandler(event),
129
+ // value={this.maxPrice}
130
+ class: "s-price-range-number-input", "aria-describedby": "price-currency" })))))));
62
131
  }
63
132
  componentDidLoad() {
64
- // this.max=this.maxPrice;
65
- this.changeLeftHandle();
66
- this.changeRightHandle();
133
+ var _a;
134
+ if (this.filtersData && ((_a = this.filtersData) === null || _a === void 0 ? void 0 : _a.price)) {
135
+ this.minPrice = this.filtersData.price.min;
136
+ this.maxPrice = this.filtersData.price.max;
137
+ this.maxInput.value = `${this.maxPrice}`;
138
+ this.minInput.value = `${this.minPrice}`;
139
+ }
67
140
  this.isReady = true;
68
141
  }
69
142
  static get is() { return "salla-price-range"; }
@@ -114,6 +187,43 @@ export class SallaPriceRange {
114
187
  "attribute": "max-price",
115
188
  "reflect": false,
116
189
  "defaultValue": "5000"
190
+ },
191
+ "option": {
192
+ "type": "unknown",
193
+ "mutable": false,
194
+ "complexType": {
195
+ "original": "Filter",
196
+ "resolved": "Filter",
197
+ "references": {
198
+ "Filter": {
199
+ "location": "import",
200
+ "path": "../salla-filters/interfaces"
201
+ }
202
+ }
203
+ },
204
+ "required": false,
205
+ "optional": false,
206
+ "docs": {
207
+ "tags": [],
208
+ "text": ""
209
+ }
210
+ },
211
+ "filtersData": {
212
+ "type": "any",
213
+ "mutable": false,
214
+ "complexType": {
215
+ "original": "any",
216
+ "resolved": "any",
217
+ "references": {}
218
+ },
219
+ "required": false,
220
+ "optional": false,
221
+ "docs": {
222
+ "tags": [],
223
+ "text": ""
224
+ },
225
+ "attribute": "filters-data",
226
+ "reflect": true
117
227
  }
118
228
  };
119
229
  }
@@ -122,13 +232,14 @@ export class SallaPriceRange {
122
232
  "min": {},
123
233
  "max": {},
124
234
  "minthumb": {},
125
- "maxthumb": {}
235
+ "maxthumb": {},
236
+ "priceOptions": {}
126
237
  };
127
238
  }
128
239
  static get events() {
129
240
  return [{
130
- "method": "minPriceSelected",
131
- "name": "minPriceSelected",
241
+ "method": "changed",
242
+ "name": "changed",
132
243
  "bubbles": true,
133
244
  "cancelable": true,
134
245
  "composed": true,
@@ -137,122 +248,15 @@ export class SallaPriceRange {
137
248
  "text": ""
138
249
  },
139
250
  "complexType": {
140
- "original": "number",
141
- "resolved": "number",
142
- "references": {}
143
- }
144
- }, {
145
- "method": "maxPriceSelected",
146
- "name": "maxPriceSelected",
147
- "bubbles": true,
148
- "cancelable": true,
149
- "composed": true,
150
- "docs": {
151
- "tags": [],
152
- "text": ""
153
- },
154
- "complexType": {
155
- "original": "number",
156
- "resolved": "number",
251
+ "original": "any",
252
+ "resolved": "any",
157
253
  "references": {}
158
254
  }
159
255
  }];
160
256
  }
161
257
  static get methods() {
162
258
  return {
163
- "minTrigger": {
164
- "complexType": {
165
- "signature": "(event?: any) => Promise<void>",
166
- "parameters": [{
167
- "tags": [],
168
- "text": ""
169
- }],
170
- "references": {
171
- "Promise": {
172
- "location": "global"
173
- }
174
- },
175
- "return": "Promise<void>"
176
- },
177
- "docs": {
178
- "text": "",
179
- "tags": []
180
- }
181
- },
182
- "maxTrigger": {
183
- "complexType": {
184
- "signature": "(event?: any) => Promise<void>",
185
- "parameters": [{
186
- "tags": [],
187
- "text": ""
188
- }],
189
- "references": {
190
- "Promise": {
191
- "location": "global"
192
- }
193
- },
194
- "return": "Promise<void>"
195
- },
196
- "docs": {
197
- "text": "",
198
- "tags": []
199
- }
200
- },
201
- "minInputValidation": {
202
- "complexType": {
203
- "signature": "(value: any) => Promise<void>",
204
- "parameters": [{
205
- "tags": [],
206
- "text": ""
207
- }],
208
- "references": {
209
- "Promise": {
210
- "location": "global"
211
- }
212
- },
213
- "return": "Promise<void>"
214
- },
215
- "docs": {
216
- "text": "",
217
- "tags": []
218
- }
219
- },
220
- "maxInputValidation": {
221
- "complexType": {
222
- "signature": "(value: any) => Promise<void>",
223
- "parameters": [{
224
- "tags": [],
225
- "text": ""
226
- }],
227
- "references": {
228
- "Promise": {
229
- "location": "global"
230
- }
231
- },
232
- "return": "Promise<void>"
233
- },
234
- "docs": {
235
- "text": "",
236
- "tags": []
237
- }
238
- },
239
- "changeRightHandle": {
240
- "complexType": {
241
- "signature": "() => Promise<void>",
242
- "parameters": [],
243
- "references": {
244
- "Promise": {
245
- "location": "global"
246
- }
247
- },
248
- "return": "Promise<void>"
249
- },
250
- "docs": {
251
- "text": "",
252
- "tags": []
253
- }
254
- },
255
- "changeLeftHandle": {
259
+ "reset": {
256
260
  "complexType": {
257
261
  "signature": "() => Promise<void>",
258
262
  "parameters": [],
@@ -1 +1 @@
1
- {"version":3,"file":"salla-price-range.js","sourceRoot":"","sources":["../../../src/components/salla-price-range/salla-price-range.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Host, h, Method, State, Prop, Event, EventEmitter} from '@stencil/core';\n\n@Component({\n tag: 'salla-price-range',\n styleUrl: 'salla-price-range.scss',\n})\nexport class SallaPriceRange {\n @Prop({mutable: true}) minPrice = 1000;\n @Prop({mutable: true}) maxPrice = 5000;\n @State() min = 0;\n @State() max = 10000;\n\n @State() minthumb = 0;\n @State() maxthumb = 0;\n\n @Event() minPriceSelected: EventEmitter<number>;\n @Event() maxPriceSelected: EventEmitter<number>;\n\n isReady: Boolean;\n rightHandle: HTMLDivElement;\n leftHandle: HTMLDivElement;\n activeBar: HTMLDivElement;\n\n componentWillLoad() {\n this.minTrigger();\n this.maxTrigger();\n }\n\n @Method()\n async minTrigger(event = null) {\n let value = event ? event.target.value * 1 : null\n this.minInputValidation(value);\n this.minthumb = ((this.minPrice - this.min) / (this.max - this.min)) * 100;\n this.changeLeftHandle()\n \n this.isReady && this.minPriceSelected.emit(value);\n }\n\n @Method()\n async maxTrigger(event = null) {\n let value = event ? event.target.value * 1 : null\n this.maxInputValidation(value)\n this.maxthumb = 100 - (((this.maxPrice - this.min) / (this.max - this.min)) * 100);\n this.changeRightHandle()\n \n this.isReady && this.maxPriceSelected.emit(value);\n }\n\n @Method()\n async minInputValidation(value) {\n if (value && (value > this.max || value > this.maxPrice)) return;\n else if (value < this.min) {\n this.minPrice = this.min;\n } else {\n value && (this.minPrice = value)\n }\n }\n\n @Method()\n async maxInputValidation(value) {\n if (value && (value < this.min || value < this.minPrice)) return;\n else if (value > this.max) {\n this.maxPrice = this.max;\n } else {\n value && (this.maxPrice = value)\n }\n }\n\n @Method()\n async changeRightHandle() {\n this.rightHandle && (this.rightHandle.style.right = `${this.maxthumb}%`);\n this.activeBar && (this.activeBar.style.right = `${this.maxthumb}%`);\n }\n\n @Method()\n async changeLeftHandle() {\n this.leftHandle && (this.leftHandle.style.left = `${this.minthumb}%`);\n this.activeBar && (this.activeBar.style.left = `${this.minthumb}%`);\n }\n\n\n render() {\n return (\n <Host>\n <div style={{direction: 'ltr'}} class=\"flex justify-center items-center\">\n <div class=\"relative max-w-xl w-full\">\n <div class=\"rtl-range-slider\">\n <input\n type=\"range\"\n step=\"100\"\n min={this.min} max={this.max}\n onInput={(event) => this.minTrigger(event)}\n value={this.minPrice}\n class=\"s-price-range-input\"\n />\n\n <input\n type=\"range\"\n step=\"100\"\n min={this.min}\n max={this.max}\n onInput={(event) => this.maxTrigger(event)}\n value={this.maxPrice}\n class=\"s-price-range-input\"\n />\n\n <div class=\"s-price-range-bar-container\">\n <div class=\"s-price-range-bar\"/>\n <div class=\"s-price-range-active-bar\" ref={(el) => this.activeBar = el}/>\n <div class=\"s-price-range-left-handle\" ref={(el) => this.leftHandle = el}/>\n <div class=\"s-price-range-right-handle\" ref={(el) => this.rightHandle = el}/>\n </div>\n\n </div>\n\n\n <div class=\"s-price-range-inputs\">\n <div class=\"s-price-range-relative\">\n <div class=\"s-price-range-currency\"> {salla.config.currency().symbol}</div>\n <input\n type=\"number\"\n maxlength=\"5\"\n onInput={(event) => this.minTrigger(event)}\n value={this.minPrice}\n class=\"s-price-range-number-input\"\n />\n </div>\n\n <div class=\"s-price-range-gray-text\"> - </div>\n <div class=\"s-price-range-relative\">\n <div class=\"s-price-range-currency\"> {salla.config.currency().symbol}</div>\n <input type=\"number\" maxlength=\"5\"\n onInput={(event) => this.maxTrigger(event)}\n value={this.maxPrice}\n class=\"s-price-range-number-input\" placeholder=\"0.00\" aria-describedby=\"price-currency\"/>\n </div>\n\n </div>\n\n </div>\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n // this.max=this.maxPrice;\n this.changeLeftHandle()\n this.changeRightHandle()\n this.isReady = true;\n }\n}\n"]}
1
+ {"version":3,"file":"salla-price-range.js","sourceRoot":"","sources":["../../../src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wBAAwB;cACjC,WAAK,KAAK,EAAC,wBAAwB;;gBAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAO;cAC3E,aAAO,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,GAAG,EAChC,WAAW,EAAC,oBAAK,EACjB,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,EAC7B,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;gBACnD,wBAAwB;gBACxB,KAAK,EAAC,4BAA4B,sBAAkB,gBAAgB,GAAG,CACrE,CACF,CACF,CACF,CACD,CACR,CAAC;EACJ,CAAC;EAED,gBAAgB;;IACd,IAAI,IAAI,CAAC,WAAW,KAAI,MAAA,IAAI,CAAC,WAAW,0CAAE,KAAK,CAAA,EAAE;MAC/C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC;MAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC;MAC3C,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;MACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;KAC1C;IACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;EACtB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, State, Prop, Event, Method } from '@stencil/core';\nimport { Filter } from \"../salla-filters/interfaces\";\n\n@Component({\n tag: 'salla-price-range',\n styleUrl: 'salla-price-range.scss',\n})\nexport class SallaPriceRange {\n constructor() {\n this.generatePriceOptions();\n }\n @Prop({ mutable: true }) minPrice = 1000;\n @Prop({ mutable: true }) maxPrice = 5000;\n @Prop({ reflect: true }) option: Filter;\n @Prop({ reflect: true }) filtersData: any;\n @State() min = 0;\n @State() max = 10000;\n\n @State() minthumb = 0;\n @State() maxthumb = 0;\n @State() priceOptions: any;\n\n @Event() changed: any;\n\n isReady: Boolean;\n rightHandle: HTMLDivElement;\n leftHandle: HTMLDivElement;\n activeBar: HTMLDivElement;\n minInput: HTMLInputElement;\n maxInput: HTMLInputElement;\n\n @Method()\n async reset() {\n //@ts-ignore\n this.minInput.value = `${this.option?.values?.min || 0}`;\n this.maxInput.value = `${this.max}`;\n }\n\n private generatePriceOptions() {\n const MAX_PRICE = this.max;\n let option1 = Math.floor(MAX_PRICE / 100);\n if (option1 < 1) {\n option1 = Math.floor(MAX_PRICE / 10);\n }\n let option2 = Math.floor(MAX_PRICE / 2);\n let option3 = Math.floor((MAX_PRICE / 3) * 2);\n this.priceOptions = [option1, option2, option3];\n\n // to be removed\n console.log(`Price options for max price ${MAX_PRICE}: ${this.priceOptions.join(', ')}`);\n }\n private getPriceLabel(price) {\n if (price == Math.floor(this.max / 100)) {\n return `اقل من ${salla.money(price)}`;\n } else if (price == Math.floor(this.max / 2)) {\n return `${salla.money(this.priceOptions[0])} الى ${salla.money(this.priceOptions[2])}`;\n } else {\n return `أكثر من ${salla.money(price)}`;\n }\n }\n\n private handleMinMaxPrice(event: Event, option: string): void {\n const [firstOption, secondOption, thirdOption] = this.priceOptions;\n switch (option) {\n case firstOption:\n this.minPrice = 0;\n this.maxPrice = firstOption;\n break;\n case secondOption:\n this.minPrice = firstOption;\n this.maxPrice = thirdOption;\n break;\n case thirdOption:\n this.minPrice = thirdOption;\n this.maxPrice = this.max;\n break;\n default:\n throw new Error(`Invalid price option: ${option}`);\n }\n\n // Update the input values\n this.minInput.value = `${this.minPrice}`;\n this.maxInput.value = `${this.maxPrice}`;\n this.changedEventHandler(event);\n }\n\n private async changedEventHandler(event, isMin = false) {\n\n let value = event ? event.target.value * 1 : null\n if (isMin) {\n this.minInputValidation(value);\n this.minthumb = ((this.minPrice - this.min) / (this.max - this.min)) * 100;\n } else {\n this.maxInputValidation(value)\n this.maxthumb = 100 - (((this.maxPrice - this.min) / (this.max - this.min)) * 100);\n }\n\n\n this.isReady && this.changed.emit({\n event: event,\n option: this.option,\n value: { max: this.maxPrice, min: this.minPrice }\n })\n }\n\n\n minInputValidation(value) {\n if (value && (value > this.max || value > this.maxPrice)) {\n // this.minPrice = this.maxPrice;\n return;\n }\n\n if (value < this.min) {\n this.minPrice = this.min;\n return;\n }\n\n if (value) {\n this.minPrice = value;\n }\n }\n\n maxInputValidation(value) {\n if (value && (value < this.min || value < this.minPrice)) {\n // this.maxPrice = this.minPrice;\n return;\n }\n if (value > this.max) {\n this.maxPrice = this.max;\n return;\n }\n\n if (value) {\n this.maxPrice = value;\n }\n }\n private isChecked(option) {\n if (option == Math.floor(this.max / 100)) {\n return this.minPrice == 0 && this.maxPrice == option;\n }\n if (option == Math.floor(this.max / 2)) {\n return this.minPrice == this.priceOptions[0] && this.maxPrice == this.priceOptions[2];\n }\n if (option == Math.floor((this.max / 3) * 2)) {\n\n return this.minPrice == option && this.maxPrice == this.max;\n }\n }\n\n\n render() {\n return (\n <Host>\n {\n this.priceOptions && this.priceOptions.map((option, index) => {\n return <label class=\"s-filters-label\" htmlFor={`${option}-${index}`}>\n <input\n id={`${option}-${index}`}\n name=\"price\"\n type=\"radio\"\n checked={this.isChecked(option)}\n class=\"s-filters-radio\"\n onChange={e => this.handleMinMaxPrice(e, option)}\n />\n {this.getPriceLabel(option)}\n </label>\n })\n }\n\n\n <div class=\"flex justify-center items-center\">\n <div class=\"relative max-w-xl w-full\">\n <div class=\"s-price-range-inputs\">\n <div class=\"s-price-range-relative\">\n <div class=\"s-price-range-currency\"> {salla.config.currency().symbol}</div>\n <input\n type=\"number\"\n maxlength=\"5\"\n ref={el => this.minInput = el}\n onInput={(event) => this.changedEventHandler(event, true)}\n // value={this.minPrice}\n placeholder=\"من\"\n class=\"s-price-range-number-input\"\n />\n </div>\n\n <div class=\"s-price-range-gray-text\"> -</div>\n <div class=\"s-price-range-relative\">\n <div class=\"s-price-range-currency\"> {salla.config.currency().symbol}</div>\n <input type=\"number\" maxlength=\"5\"\n placeholder=\"الى\"\n ref={el => this.maxInput = el}\n onInput={(event) => this.changedEventHandler(event)}\n // value={this.maxPrice}\n class=\"s-price-range-number-input\" aria-describedby=\"price-currency\" />\n </div>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n if (this.filtersData && this.filtersData?.price) {\n this.minPrice = this.filtersData.price.min;\n this.maxPrice = this.filtersData.price.max;\n this.maxInput.value = `${this.maxPrice}`;\n this.minInput.value = `${this.minPrice}`;\n }\n this.isReady = true;\n }\n}\n"]}
@@ -21,10 +21,21 @@ export class SallaProductsList {
21
21
  this.isReady = undefined;
22
22
  this.showPlaceholder = undefined;
23
23
  this.parsedFilters = undefined;
24
+ }
25
+ connectedCallback() {
24
26
  salla.onReady(() => {
25
27
  this.hasCustomComponent = !!customElements.get('custom-salla-product-card');
26
28
  this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());
27
29
  this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.getSource());
30
+ try {
31
+ let searchParams = new URLSearchParams(window.location.search);
32
+ this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');
33
+ let filters = searchParams.get('filters');
34
+ this.parsedFilters = filters ? JSON.parse(decodeURIComponent(filters)) : {};
35
+ }
36
+ catch (e) {
37
+ salla.logger.warn('failed to get filters from url', e.message);
38
+ }
28
39
  this.buildNextPageUrl();
29
40
  this.createStatusDom();
30
41
  this.isReady = true;
@@ -35,22 +46,12 @@ export class SallaProductsList {
35
46
  }
36
47
  salla.event.on('salla-filters::changed', filters => this.setFilters(filters));
37
48
  }
38
- connectedCallback() {
39
- try {
40
- let searchParams = new URLSearchParams(window.location.search);
41
- this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');
42
- let filters = searchParams.get('filters');
43
- this.parsedFilters = filters ? JSON.parse(decodeURIComponent(filters)) : {};
44
- }
45
- catch (e) {
46
- salla.logger.warn('failed to get filters from url', e.message);
47
- }
48
- }
49
49
  async setFilters(filters) {
50
50
  this.parsedFilters = filters;
51
51
  return this.reload();
52
52
  }
53
53
  async reload() {
54
+ salla.infiniteScroll.destroy(this.infiniteScroll);
54
55
  this.buildNextPageUrl();
55
56
  this.wrapper.innerHTML = '';
56
57
  this.init();
@@ -89,52 +90,53 @@ export class SallaProductsList {
89
90
  this.placeholderText = salla.lang.get('pages.categories.no_products');
90
91
  });
91
92
  }
93
+ initBaseNextPageUrl(source) {
94
+ this.nextPage = salla.url.api(`products?source=${source}`);
95
+ if (this.limit) {
96
+ this.nextPage += `&per_page=${this.limit > 32 ? 32 : this.limit}`;
97
+ }
98
+ if (this.sortBy) {
99
+ this.nextPage += `&sort=${this.sortBy}`;
100
+ }
101
+ // if (!this.isFilterable()) {
102
+ // return this.nextPage;
103
+ // }
104
+ this.nextPage += '&filterable=1';
105
+ for (const [key, value] of Object.entries(this.parsedFilters || {})) {
106
+ if (["string", "number"].includes(typeof value)) {
107
+ this.nextPage += `&filters[${key}]=${value}`;
108
+ }
109
+ else if (Array.isArray(value)) {
110
+ value.forEach(item => this.nextPage += `&filters[${key}][]=${item}`);
111
+ }
112
+ else if (typeof value === 'object') {
113
+ for (const [k, v] of Object.entries(value)) {
114
+ this.nextPage += `&filters[${key}][${k}]=${v}`;
115
+ }
116
+ }
117
+ }
118
+ }
92
119
  buildNextPageUrl() {
93
120
  let source = this.getSource();
94
121
  if (source === 'json') {
95
122
  return;
96
123
  }
97
- let urlPrefix = this.getUrlPrefix();
124
+ this.initBaseNextPageUrl(source);
98
125
  if (this.isSourceWithoutValue()) {
99
- this.nextPage = salla.url.api(`products?source=${source}${urlPrefix}`);
100
126
  return;
101
127
  }
102
128
  if (['search', 'related', 'landing-page'].includes(source)) {
103
- this.nextPage = salla.url.api(`products?source=${source}&source_value=${this.getSourceValue()}${urlPrefix}`);
129
+ this.nextPage += `&source_value=${this.getSourceValue()}`;
104
130
  return;
105
131
  }
106
132
  try {
107
- this.nextPage = salla.url.api(`products?source=${source}&source_value[]=${this.getSourceValue().join('&source_value[]=')}${urlPrefix}`);
133
+ this.nextPage += `&source_value[]=${this.getSourceValue().join('&source_value[]=')}`;
108
134
  }
109
135
  catch (e) {
110
136
  salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${source}]`);
111
137
  this.sourceValueIsValid = false;
112
138
  }
113
139
  }
114
- getUrlPrefix() {
115
- let urlPrefix = '';
116
- if (this.limit) {
117
- urlPrefix = `&per_page=${this.limit > 32 ? 32 : this.limit}`;
118
- }
119
- if (this.sortBy) {
120
- urlPrefix = `&sort=${this.sortBy}`;
121
- }
122
- if (!this.isFilterable()) {
123
- return urlPrefix;
124
- }
125
- urlPrefix += '&filterable=1';
126
- for (const [key, value] of Object.entries(this.parsedFilters || {})) {
127
- if (typeof value == "string") {
128
- urlPrefix += `&filters[${key}]=${value}`;
129
- }
130
- else if (Array.isArray(value)) {
131
- value.forEach(item => {
132
- urlPrefix += `&filters[${key}][]=${item}}`;
133
- });
134
- }
135
- }
136
- return urlPrefix;
137
- }
138
140
  getSource() {
139
141
  return {
140
142
  'brands.single': 'brands',
@@ -184,10 +186,25 @@ export class SallaProductsList {
184
186
  }
185
187
  if (this.horizontalCards && !this.hasCustomComponent) {
186
188
  customComponent.toggleAttribute('horizontal', true);
189
+ customComponent.toggleAttribute('shadow-on-hover', true);
187
190
  }
188
- customComponent.toggleAttribute('shadow-on-hover', true);
189
191
  return customComponent;
190
192
  }
193
+ fetchProducts() {
194
+ salla.product.fetch({
195
+ source: this.getSource(),
196
+ source_value: this.getSourceValue(),
197
+ limit: this.limit
198
+ })
199
+ .then(res => {
200
+ if (!res.data.length) {
201
+ this.showPlaceholder = true;
202
+ this.loading(false);
203
+ return;
204
+ }
205
+ this.handleResponse(res).forEach(card => this.wrapper.append(card));
206
+ });
207
+ }
191
208
  initiateInfiniteScroll() {
192
209
  if (!this.hasInfiniteScroll) {
193
210
  return;
@@ -200,11 +217,27 @@ export class SallaProductsList {
200
217
  scrollThreshold: 100,
201
218
  }, /* infinite via api*/ true);
202
219
  this.infiniteScroll.on('request', () => this.loading());
203
- this.infiniteScroll.on('load', response => this.infiniteScroll.appendItems(this.handleResponse(response)));
220
+ this.infiniteScroll.on('load', response => {
221
+ var _a;
222
+ if (!((_a = response.data) === null || _a === void 0 ? void 0 : _a.length)) {
223
+ this.showPlaceholder = true;
224
+ salla.infiniteScroll.destroy(this.infiniteScroll);
225
+ this.loading(false);
226
+ return;
227
+ }
228
+ else {
229
+ this.showPlaceholder = false;
230
+ }
231
+ this.infiniteScroll.appendItems(this.handleResponse(response));
232
+ if (this.infiniteScroll.pageIndex == 2) {
233
+ this.animateItems();
234
+ }
235
+ });
204
236
  this.infiniteScroll.on('error', () => {
205
237
  this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden');
206
238
  this.loading(false);
207
239
  });
240
+ salla.onReady(() => salla.infiniteScroll.loadNextPage(this.infiniteScroll));
208
241
  }
209
242
  canRender() {
210
243
  return this.sourceValueIsValid && this.isReady;
@@ -227,6 +260,7 @@ export class SallaProductsList {
227
260
  if (!this.canRender()) {
228
261
  return;
229
262
  }
263
+ // Handle json source
230
264
  if (this.getSource() === 'json') {
231
265
  if (!this.getSourceValue().length) {
232
266
  this.showPlaceholder = true;
@@ -235,34 +269,26 @@ export class SallaProductsList {
235
269
  this.getSourceValue().map(product => this.wrapper.append(this.getItemHTML(product)));
236
270
  return;
237
271
  }
272
+ // Handle selected source
273
+ if (this.getSource() === 'selected') {
274
+ if (!this.getSourceValue().length) {
275
+ this.showPlaceholder = true;
276
+ return;
277
+ }
278
+ this.fetchProducts();
279
+ return;
280
+ }
238
281
  this.init();
239
282
  }
240
283
  init() {
241
284
  this.initiateInfiniteScroll();
242
285
  this.loading();
243
- salla.product.fetch({
244
- source: this.getSource(),
245
- source_value: this.getSourceValue(),
246
- filters: this.parsedFilters,
247
- limit: this.limit,
248
- filterable: this.isFilterable() ? 1 : 0,
249
- sort: this.sortBy,
250
- })
251
- .then(res => {
252
- var _a;
253
- if (!((_a = res.data) === null || _a === void 0 ? void 0 : _a.length)) {
254
- this.showPlaceholder = true;
255
- this.loading(false);
256
- return;
257
- }
258
- this.handleResponse(res).forEach(card => this.wrapper.append(card));
259
- this.animateItems();
260
- });
261
286
  }
262
287
  handleResponse(response) {
263
288
  var _a;
264
289
  //💡 when source is related, cursor will not be existed
265
290
  if (response.filters && this.isFilterable()) {
291
+ this.filtersResults = true;
266
292
  salla.event.emit('filters::fetched', { filters: response.filters });
267
293
  }
268
294
  else if (this.isFilterable()) {