@salla.sa/twilight-components 2.11.94 → 2.11.96

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 (76) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-add-product-button_40.cjs.entry.js +11 -5
  3. package/dist/cjs/salla-add-product-button_40.cjs.entry.js.map +1 -1
  4. package/dist/cjs/salla-products-list.cjs.entry.js +31 -8
  5. package/dist/cjs/salla-products-list.cjs.entry.js.map +1 -1
  6. package/dist/cjs/salla-products-slider.cjs.entry.js +2 -3
  7. package/dist/cjs/salla-products-slider.cjs.entry.js.map +1 -1
  8. package/dist/cjs/twilight.cjs.js +1 -1
  9. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +1 -1
  10. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js.map +1 -1
  11. package/dist/collection/components/salla-product-card/salla-product-card.js +5 -2
  12. package/dist/collection/components/salla-product-card/salla-product-card.js.map +1 -1
  13. package/dist/collection/components/salla-products-list/salla-products-list.js +35 -11
  14. package/dist/collection/components/salla-products-list/salla-products-list.js.map +1 -1
  15. package/dist/collection/components/salla-products-slider/salla-products-slider.js +2 -3
  16. package/dist/collection/components/salla-products-slider/salla-products-slider.js.map +1 -1
  17. package/dist/collection/components/salla-progress-bar/salla-progress-bar.js +5 -2
  18. package/dist/collection/components/salla-progress-bar/salla-progress-bar.js.map +1 -1
  19. package/dist/components/salla-add-product-button2.js +1 -1
  20. package/dist/components/salla-add-product-button2.js.map +1 -1
  21. package/dist/components/salla-product-card2.js +5 -2
  22. package/dist/components/salla-product-card2.js.map +1 -1
  23. package/dist/components/salla-products-list.js +33 -9
  24. package/dist/components/salla-products-list.js.map +1 -1
  25. package/dist/components/salla-products-slider.js +2 -3
  26. package/dist/components/salla-products-slider.js.map +1 -1
  27. package/dist/components/salla-progress-bar2.js +5 -2
  28. package/dist/components/salla-progress-bar2.js.map +1 -1
  29. package/dist/esm/loader.js +1 -1
  30. package/dist/esm/salla-add-product-button_40.entry.js +11 -5
  31. package/dist/esm/salla-add-product-button_40.entry.js.map +1 -1
  32. package/dist/esm/salla-products-list.entry.js +31 -8
  33. package/dist/esm/salla-products-list.entry.js.map +1 -1
  34. package/dist/esm/salla-products-slider.entry.js +2 -3
  35. package/dist/esm/salla-products-slider.entry.js.map +1 -1
  36. package/dist/esm/twilight.js +1 -1
  37. package/dist/esm-es5/loader.js +1 -1
  38. package/dist/esm-es5/loader.js.map +1 -1
  39. package/dist/esm-es5/salla-add-product-button_40.entry.js +2 -2
  40. package/dist/esm-es5/salla-add-product-button_40.entry.js.map +1 -1
  41. package/dist/esm-es5/salla-products-list.entry.js +1 -1
  42. package/dist/esm-es5/salla-products-list.entry.js.map +1 -1
  43. package/dist/esm-es5/salla-products-slider.entry.js +1 -1
  44. package/dist/esm-es5/salla-products-slider.entry.js.map +1 -1
  45. package/dist/esm-es5/twilight.js +1 -1
  46. package/dist/esm-es5/twilight.js.map +1 -1
  47. package/dist/twilight/p-009ab1f2.system.entry.js +5 -0
  48. package/dist/twilight/p-009ab1f2.system.entry.js.map +1 -0
  49. package/dist/twilight/{p-b28388c6.entry.js → p-23f7c19e.entry.js} +3 -3
  50. package/dist/twilight/p-23f7c19e.entry.js.map +1 -0
  51. package/dist/twilight/p-437c62e8.system.js +1 -1
  52. package/dist/twilight/p-437c62e8.system.js.map +1 -1
  53. package/dist/twilight/p-69a92ff4.system.entry.js +5 -0
  54. package/dist/twilight/p-69a92ff4.system.entry.js.map +1 -0
  55. package/dist/twilight/{p-152e1cd4.system.entry.js → p-6a906858.system.entry.js} +3 -3
  56. package/dist/twilight/p-6a906858.system.entry.js.map +1 -0
  57. package/dist/twilight/p-a7196205.entry.js +5 -0
  58. package/dist/twilight/p-a7196205.entry.js.map +1 -0
  59. package/dist/twilight/p-ffcd40eb.entry.js +5 -0
  60. package/dist/twilight/p-ffcd40eb.entry.js.map +1 -0
  61. package/dist/twilight/twilight.esm.js +1 -1
  62. package/dist/twilight/twilight.esm.js.map +1 -1
  63. package/dist/types/components/salla-product-card/salla-product-card.d.ts +1 -0
  64. package/dist/types/components/salla-products-list/salla-products-list.d.ts +3 -1
  65. package/dist/types/components.d.ts +2 -2
  66. package/package.json +2 -2
  67. package/dist/twilight/p-07d3cdea.entry.js +0 -5
  68. package/dist/twilight/p-07d3cdea.entry.js.map +0 -1
  69. package/dist/twilight/p-152e1cd4.system.entry.js.map +0 -1
  70. package/dist/twilight/p-1aa9d7fe.system.entry.js +0 -5
  71. package/dist/twilight/p-1aa9d7fe.system.entry.js.map +0 -1
  72. package/dist/twilight/p-5316354e.system.entry.js +0 -5
  73. package/dist/twilight/p-5316354e.system.entry.js.map +0 -1
  74. package/dist/twilight/p-abd87984.entry.js +0 -5
  75. package/dist/twilight/p-abd87984.entry.js.map +0 -1
  76. package/dist/twilight/p-b28388c6.entry.js.map +0 -1
@@ -8,9 +8,8 @@ export class SallaProductsList {
8
8
  // State
9
9
  this.page = 1;
10
10
  this.urlPrefix = '';
11
- // this.source = this.source || 'latest';
12
11
  salla.onReady(() => {
13
- this.source = this.source || {
12
+ this.source = {
14
13
  'brands.single': 'brands',
15
14
  'product.index': 'categories',
16
15
  'product.index.latest': 'latest',
@@ -18,7 +17,7 @@ export class SallaProductsList {
18
17
  'product.index.search': 'search',
19
18
  'landing-page': 'landing-page',
20
19
  'product.index.tag': 'tags',
21
- }[salla.config.get('page.slug')] || 'latest';
20
+ }[this.source || salla.config.get('page.slug')] || this.source || 'latest';
22
21
  let parsedSourceValue = this.sourceValue = this.sourceValue || this.getSourceValue();
23
22
  if (this.sourceValue && ['categories', 'brands', 'tags', 'selected'].includes(this.source) && typeof this.sourceValue == 'string') {
24
23
  parsedSourceValue = JSON.parse(this.sourceValue);
@@ -58,12 +57,11 @@ export class SallaProductsList {
58
57
  }
59
58
  }
60
59
  parseFilters(newValue, _) {
61
- this.filters = typeof newValue == 'string' ? JSON.parse(newValue) : newValue;
62
- for (const [key, value] of Object.entries(this.filters)) {
60
+ this.parsedFilters = typeof newValue == 'string' ? JSON.parse(newValue) : newValue;
61
+ this.urlPrefix = '';
62
+ for (const [key, value] of Object.entries(this.parsedFilters)) {
63
63
  if (typeof value == "string") {
64
- this.urlPrefix += `&filters[${key}]=${value}}`;
65
- // TODO: only if there is going to be another type of value
66
- // otherwise we can remove the `else if` check. Just a fail safety
64
+ this.urlPrefix += `&filters[${key}]=${value}`;
67
65
  }
68
66
  else if (Array.isArray(value)) {
69
67
  value.forEach(item => {
@@ -71,6 +69,11 @@ export class SallaProductsList {
71
69
  });
72
70
  }
73
71
  }
72
+ // reset page products
73
+ if (this.source == 'categories') {
74
+ this.wrapper.innerHTML = '';
75
+ this.init();
76
+ }
74
77
  }
75
78
  buildNextPageUrl() {
76
79
  if (this.source === 'json') {
@@ -161,6 +164,26 @@ export class SallaProductsList {
161
164
  this.parsedSourceValue.map(product => this.wrapper.append(this.getItemHTML(product)));
162
165
  return;
163
166
  }
167
+ if (this.source == 'categories') {
168
+ // check if there is a filters in the url
169
+ const filters = window.location.search
170
+ .replace('?', '')
171
+ .split('&')
172
+ .map(item => item.split('='))
173
+ .reduce((acc, [key, value]) => {
174
+ if (key == 'sort') {
175
+ acc[key] = value;
176
+ }
177
+ return acc;
178
+ }, {});
179
+ if (filters) {
180
+ this.filters = filters;
181
+ return;
182
+ }
183
+ }
184
+ this.init();
185
+ }
186
+ init() {
164
187
  this.initiateInfiniteScroll();
165
188
  this.loading();
166
189
  salla.product.fetch({ source: this.source, source_value: this.parsedSourceValue, filters: this.filters, limit: this.limit })
@@ -253,8 +276,8 @@ export class SallaProductsList {
253
276
  "type": "string",
254
277
  "mutable": true,
255
278
  "complexType": {
256
- "original": "string",
257
- "resolved": "string",
279
+ "original": "string | object",
280
+ "resolved": "object | string",
258
281
  "references": {}
259
282
  },
260
283
  "required": false,
@@ -277,7 +300,8 @@ export class SallaProductsList {
277
300
  "isReady": {},
278
301
  "showPlaceholder": {},
279
302
  "urlPrefix": {},
280
- "parsedSourceValue": {}
303
+ "parsedSourceValue": {},
304
+ "parsedFilters": {}
281
305
  }; }
282
306
  static get elementRef() { return "host"; }
283
307
  static get watchers() { return [{
@@ -1 +1 @@
1
- {"version":3,"file":"salla-products-list.js","sourceRoot":"","sources":["../../../src/components/salla-products-list/salla-products-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,WAAW,MAAM,mCAAmC,CAAC;AAM5D,MAAM,OAAO,iBAAiB;EAC5B;IA6GA,QAAQ;IACC,SAAI,GAAW,CAAC,CAAC;IAQjB,cAAS,GAAW,EAAE,CAAC;IArH9B,yCAAyC;IACzC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;MACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI;QAC3B,eAAe,EAAE,QAAQ;QACzB,eAAe,EAAE,YAAY;QAC7B,sBAAsB,EAAE,QAAQ;QAChC,sBAAsB,EAAE,QAAQ;QAChC,sBAAsB,EAAE,QAAQ;QAChC,cAAc,EAAE,cAAc;QAC9B,mBAAmB,EAAE,MAAM;OAC5B,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,QAAQ,CAAC;MAG7C,IAAI,iBAAiB,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;MAErF,IAAI,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,IAAI,CAAC,WAAW,IAAI,QAAQ,EAAE;QACjI,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC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,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACvE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAC5C,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;MAC5E,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KACnF;IACD,OAAO,CAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAI,EAAE,CAAC;EACxE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, Watch } from '@stencil/core';\nimport ShoppingBag from '../../assets/svg/shopping-bag.svg';\n\n@Component({\n tag: 'salla-products-list',\n styleUrl: 'salla-products-list.scss'\n})\nexport class SallaProductsList {\n constructor() {\n // this.source = this.source || 'latest';\n salla.onReady(() => {\n this.source = this.source || {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n }[salla.config.get('page.slug')] || 'latest';\n\n \n let parsedSourceValue = this.sourceValue = this.sourceValue || this.getSourceValue();\n\n if (this.sourceValue && ['categories', 'brands', 'tags', 'selected'].includes(this.source) && typeof this.sourceValue == 'string') {\n parsedSourceValue = JSON.parse(this.sourceValue);\n }\n this.parsedSourceValue = parsedSourceValue;\n this.sourceValueIsValid = !!(this.sourceValue || ['latest', 'offers'].includes(this.source));\n this.buildNextPageUrl();\n this.isReady = true;\n });\n \n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.source}]`);\n return;\n }\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n\n this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.source);\n // Language\n //enhance\n this.status = document.createElement('div');\n this.status.className = 's-infinite-scroll-wrapper';\n this.status.innerHTML = `<div class=\"s-infinite-scroll-status\">\n <p class=\"s-infinite-scroll-last infinite-scroll-last s-hidden\" >${salla.lang.get('common.elements.end_of_content')}</p>\n <p class=\"s-infinite-scroll-error infinite-scroll-error s-hidden\">${salla.lang.get('common.elements.failed_to_load_more')}</p>\n </div>\n <a href=\"#\" class=\"s-infinite-scroll-btn s-button-btn\">\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" style=\"display: none\"></span>\n </a>`;\n this.btnLoader = this.status.querySelector('.s-button-loader');\n salla.lang.onLoaded(() => {\n this.status.querySelector('.s-infinite-scroll-last').innerHTML = salla.lang.get('common.elements.end_of_content');\n this.status.querySelector('.s-infinite-scroll-error').innerHTML = salla.lang.get('common.elements.failed_to_load_more');\n this.placeholderText = salla.lang.get('pages.categories.no_products');\n });\n }\n\n private readonly status: HTMLDivElement;\n private btnLoader: HTMLAnchorElement;\n @Element() host: HTMLElement;\n private wrapper: any;\n private infiniteScroll: any;\n /**\n * The source of the products list\n * @type {string}\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - keyword when `source` = 'search'\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop({mutable: true}) sourceValue: any;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({mutable: true}) limit: number;\n\n /**\n * Filter parameters. JSON STRING or object\n */\n @Prop({mutable: true}) filters: string;\n\n @Watch('limit')\n validateLimitMaximumValue(_newValue: number, _) {\n if (this.limit) {\n this.urlPrefix += `&per_page=${this.limit > 32 ? 32 : this.limit}}`;\n }\n }\n\n @Watch('filters')\n parseFilters(newValue: string | object, _) {\n this.filters = typeof newValue == 'string' ? JSON.parse(newValue) : newValue\n for (const [key, value] of Object.entries(this.filters)) {\n if (typeof value == \"string\") {\n this.urlPrefix += `&filters[${key}]=${value}}`;\n // TODO: only if there is going to be another type of value\n // otherwise we can remove the `else if` check. Just a fail safety\n } else if (Array.isArray(value)) {\n (value as any).forEach(item => {\n this.urlPrefix += `&filters[${key}][]=${item}}`\n })\n }\n }\n }\n\n // State\n @State() page: number = 1;\n @State() nextPage: string;\n @State() hasInfiniteScroll: boolean;\n @State() hasCustomComponent: boolean;\n @State() sourceValueIsValid: boolean;\n @State() placeholderText: string;\n @State() isReady: boolean;\n @State() showPlaceholder: boolean;\n @State() urlPrefix: string = '';\n @State() parsedSourceValue: any;\n\n\n private buildNextPageUrl() {\n if (this.source === 'json') {\n return;\n }\n if (['offers', 'latest'].includes(this.source)) {\n this.nextPage = salla.url.api(`products?source=${this.source}${this.urlPrefix}`);\n return;\n }\n\n if (['search', 'related', 'landing-page'].includes(this.source)) {\n this.nextPage = salla.url.api(`products?source=${this.source}&source_value=${this.parsedSourceValue}${this.urlPrefix}`);\n return;\n }\n\n try {\n this.nextPage = salla.url.api(`products?source=${this.source}&source_value[]=${this.parsedSourceValue.join('&source_value[]=')}${this.urlPrefix}`);\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${this.source}]`);\n this.sourceValueIsValid = false;\n }\n }\n\n private getSourceValue() {\n if (['landing-page'].includes(this.source)) {\n return `${salla.config.get('page.id')}`\n } else if (['categories', 'brands', 'tags'].includes(this.source)){\n return JSON.stringify([salla.config.get('page.id')])\n } \n return this.sourceValue;\n }\n\n private loading(isLoading = true) {\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n\n private getItemHTML(product) {\n let customComponent: string | HTMLElement = this.hasCustomComponent ? 'custom-salla-product-card' : 'salla-product-card';\n customComponent = document.createElement(customComponent);\n customComponent.setAttribute('product', JSON.stringify(product));\n if (this.source == 'landing-page' && !this.hasCustomComponent) {\n customComponent.toggleAttribute('hide-add-btn', true);\n customComponent.toggleAttribute('show-quantity', true);\n customComponent.classList.add('s-product-card-fit-height');\n }\n customComponent.toggleAttribute('shadow-on-hover', true);\n return customComponent;\n }\n\n private initiateInfiniteScroll() {\n if (!this.hasInfiniteScroll) {\n return;\n }\n\n this.host.insertAdjacentElement('afterend', this.status);\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: false,\n nextPage: this.nextPage,\n scrollThreshold: 100,\n }, /* infinite via api*/true);\n\n\n this.infiniteScroll.on('request', () => this.loading())\n this.infiniteScroll.on('load', response => this.infiniteScroll.appendItems(this.handleResponse(response)))\n this.infiniteScroll.on('error', () => {\n this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden')\n this.loading(false);\n });\n }\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n render() {\n if (!this.canRender()) {\n return '';\n }\n if (this.showPlaceholder) {\n return <div class=\"s-products-list-placeholder\">\n <span innerHTML={ShoppingBag}></span>\n <p>{this.placeholderText}</p>\n </div>;\n }\n return (\n <Host class=\"s-products-list\">\n <div class=\"s-products-list-wrapper\" ref={wrapper => this.wrapper = wrapper} />\n </Host>\n );\n }\n\n componentDidLoad() {\n if (!this.canRender()) {\n return;\n }\n if (this.source === 'json') {\n if (!this.parsedSourceValue.length) {\n this.showPlaceholder = true;\n return;\n }\n this.parsedSourceValue.map(product => this.wrapper.append(this.getItemHTML(product)));\n return;\n }\n\n this.initiateInfiniteScroll();\n this.loading();\n salla.product.fetch({source: this.source, source_value: this.parsedSourceValue , filters: this.filters, limit: this.limit})\n .then(res => { \n if (!res.data.length) {\n this.showPlaceholder = true;\n this.loading(false);\n return;\n }\n this.handleResponse(res).forEach(card => this.wrapper.append(card));\n })\n }\n\n private handleResponse(response): Array<HTMLElement> {\n //💡 when source is related, cursor will not be existed\n this.nextPage = response.cursor ? response.cursor.next : this.nextPage;\n this.loading(false);\n if (this.hasInfiniteScroll && !this.nextPage) {\n this.infiniteScroll.option({ scrollThreshold: false, loadOnScroll: false });\n this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');\n }\n return response.data?.map(product => this.getItemHTML(product)) || [];\n }\n}\n"]}
1
+ {"version":3,"file":"salla-products-list.js","sourceRoot":"","sources":["../../../src/components/salla-products-list/salla-products-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,WAAW,MAAM,mCAAmC,CAAC;AAM5D,MAAM,OAAO,iBAAiB;EAC5B;IAkHA,QAAQ;IACC,SAAI,GAAW,CAAC,CAAC;IAQjB,cAAS,GAAW,EAAE,CAAC;IA1H9B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;MACjB,IAAI,CAAC,MAAM,GAAG;QACZ,eAAe,EAAE,QAAQ;QACzB,eAAe,EAAE,YAAY;QAC7B,sBAAsB,EAAE,QAAQ;QAChC,sBAAsB,EAAE,QAAQ;QAChC,sBAAsB,EAAE,QAAQ;QAChC,cAAc,EAAE,cAAc;QAC9B,mBAAmB,EAAE,MAAM;OAC5B,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,IAAG,QAAQ,CAAC;MAG1E,IAAI,iBAAiB,GAAG,IAAI,C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,CAAC;IACvE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAC5C,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;MAC5E,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KACnF;IACD,OAAO,CAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAI,EAAE,CAAC;EACxE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, Watch } from '@stencil/core';\nimport ShoppingBag from '../../assets/svg/shopping-bag.svg';\n\n@Component({\n tag: 'salla-products-list',\n styleUrl: 'salla-products-list.scss'\n})\nexport class SallaProductsList {\n constructor() {\n salla.onReady(() => {\n this.source = {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n }[this.source || salla.config.get('page.slug')] || this.source ||'latest';\n\n\n let parsedSourceValue = this.sourceValue = this.sourceValue || this.getSourceValue();\n\n if (this.sourceValue && ['categories', 'brands', 'tags', 'selected'].includes(this.source) && typeof this.sourceValue == 'string') {\n parsedSourceValue = JSON.parse(this.sourceValue);\n }\n this.parsedSourceValue = parsedSourceValue;\n this.sourceValueIsValid = !!(this.sourceValue || ['latest', 'offers'].includes(this.source));\n this.buildNextPageUrl();\n this.isReady = true;\n });\n\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.source}]`);\n return;\n }\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n\n this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.source);\n // Language\n //enhance\n this.status = document.createElement('div');\n this.status.className = 's-infinite-scroll-wrapper';\n this.status.innerHTML = `<div class=\"s-infinite-scroll-status\">\n <p class=\"s-infinite-scroll-last infinite-scroll-last s-hidden\" >${salla.lang.get('common.elements.end_of_content')}</p>\n <p class=\"s-infinite-scroll-error infinite-scroll-error s-hidden\">${salla.lang.get('common.elements.failed_to_load_more')}</p>\n </div>\n <a href=\"#\" class=\"s-infinite-scroll-btn s-button-btn\">\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" style=\"display: none\"></span>\n </a>`;\n this.btnLoader = this.status.querySelector('.s-button-loader');\n salla.lang.onLoaded(() => {\n this.status.querySelector('.s-infinite-scroll-last').innerHTML = salla.lang.get('common.elements.end_of_content');\n this.status.querySelector('.s-infinite-scroll-error').innerHTML = salla.lang.get('common.elements.failed_to_load_more');\n this.placeholderText = salla.lang.get('pages.categories.no_products');\n });\n }\n\n private readonly status: HTMLDivElement;\n private btnLoader: HTMLAnchorElement;\n @Element() host: HTMLElement;\n private wrapper: any;\n private infiniteScroll: any;\n /**\n * The source of the products list\n * @type {string}\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - keyword when `source` = 'search'\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop({ mutable: true }) sourceValue: any;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({ mutable: true }) limit: number;\n\n /**\n * Filter parameters. JSON STRING or object\n */\n @Prop({ mutable: true }) filters: string | object;\n\n @Watch('limit')\n validateLimitMaximumValue(_newValue: number, _) {\n if (this.limit) {\n this.urlPrefix += `&per_page=${this.limit > 32 ? 32 : this.limit}}`;\n }\n }\n\n @Watch('filters')\n parseFilters(newValue: string | object, _) {\n this.parsedFilters = typeof newValue == 'string' ? JSON.parse(newValue) : newValue\n this.urlPrefix = '';\n\n for (const [key, value] of Object.entries(this.parsedFilters)) {\n if (typeof value == \"string\") {\n this.urlPrefix += `&filters[${key}]=${value}`;\n }\n else if (Array.isArray(value)) {\n (value as any).forEach(item => {\n this.urlPrefix += `&filters[${key}][]=${item}}`\n })\n }\n }\n // reset page products\n if (this.source == 'categories') {\n this.wrapper.innerHTML = '';\n this.init()\n }\n }\n\n // State\n @State() page: number = 1;\n @State() nextPage: string;\n @State() hasInfiniteScroll: boolean;\n @State() hasCustomComponent: boolean;\n @State() sourceValueIsValid: boolean;\n @State() placeholderText: string;\n @State() isReady: boolean;\n @State() showPlaceholder: boolean;\n @State() urlPrefix: string = '';\n @State() parsedSourceValue: any;\n @State() parsedFilters: any;\n\n\n private buildNextPageUrl() {\n if (this.source === 'json') {\n return;\n }\n if (['offers', 'latest'].includes(this.source)) {\n this.nextPage = salla.url.api(`products?source=${this.source}${this.urlPrefix}`);\n return;\n }\n\n if (['search', 'related', 'landing-page'].includes(this.source)) {\n this.nextPage = salla.url.api(`products?source=${this.source}&source_value=${this.parsedSourceValue}${this.urlPrefix}`);\n return;\n }\n\n try {\n this.nextPage = salla.url.api(`products?source=${this.source}&source_value[]=${this.parsedSourceValue.join('&source_value[]=')}${this.urlPrefix}`);\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${this.source}]`);\n this.sourceValueIsValid = false;\n }\n }\n\n private getSourceValue() {\n if (['landing-page'].includes(this.source)) {\n return `${salla.config.get('page.id')}`\n } else if (['categories', 'brands', 'tags'].includes(this.source)) {\n return JSON.stringify([salla.config.get('page.id')])\n }\n return this.sourceValue;\n }\n\n private loading(isLoading = true) {\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n\n private getItemHTML(product) {\n let customComponent: string | HTMLElement = this.hasCustomComponent ? 'custom-salla-product-card' : 'salla-product-card';\n customComponent = document.createElement(customComponent);\n customComponent.setAttribute('product', JSON.stringify(product));\n if (this.source == 'landing-page' && !this.hasCustomComponent) {\n customComponent.toggleAttribute('hide-add-btn', true);\n customComponent.toggleAttribute('show-quantity', true);\n customComponent.classList.add('s-product-card-fit-height');\n }\n customComponent.toggleAttribute('shadow-on-hover', true);\n return customComponent;\n }\n\n private initiateInfiniteScroll() {\n if (!this.hasInfiniteScroll) {\n return;\n }\n\n this.host.insertAdjacentElement('afterend', this.status);\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: false,\n nextPage: this.nextPage,\n scrollThreshold: 100,\n }, /* infinite via api*/true);\n this.infiniteScroll.on('request', () => this.loading())\n this.infiniteScroll.on('load', response => this.infiniteScroll.appendItems(this.handleResponse(response)))\n this.infiniteScroll.on('error', () => {\n this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden')\n this.loading(false);\n });\n }\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n render() {\n if (!this.canRender()) {\n return '';\n }\n if (this.showPlaceholder) {\n return <div class=\"s-products-list-placeholder\">\n <span innerHTML={ShoppingBag}></span>\n <p>{this.placeholderText}</p>\n </div>;\n }\n return (\n <Host class=\"s-products-list\">\n <div class=\"s-products-list-wrapper\" ref={wrapper => this.wrapper = wrapper} />\n </Host>\n );\n }\n\n componentDidLoad() {\n if (!this.canRender()) {\n return;\n }\n if (this.source === 'json') {\n if (!this.parsedSourceValue.length) {\n this.showPlaceholder = true;\n return;\n }\n this.parsedSourceValue.map(product => this.wrapper.append(this.getItemHTML(product)));\n return;\n }\n if (this.source == 'categories') {\n // check if there is a filters in the url\n const filters = window.location.search\n .replace('?', '')\n .split('&')\n .map(item => item.split('='))\n .reduce((acc, [key, value]) => {\n if (key == 'sort') {\n acc[key] = value;\n }\n return acc;\n }, {});\n if (filters) {\n this.filters = filters;\n return;\n }\n }\n this.init();\n }\n\n private init() {\n this.initiateInfiniteScroll();\n this.loading();\n salla.product.fetch({ source: this.source, source_value: this.parsedSourceValue, filters: this.filters, limit: this.limit })\n .then(res => {\n if (!res.data.length) {\n this.showPlaceholder = true;\n this.loading(false);\n return;\n }\n this.handleResponse(res).forEach(card => this.wrapper.append(card));\n })\n }\n private handleResponse(response): Array<HTMLElement> {\n //💡 when source is related, cursor will not be existed\n this.nextPage = response.cursor ? response.cursor.next : this.nextPage;\n this.loading(false);\n if (this.hasInfiniteScroll && !this.nextPage) {\n this.infiniteScroll.option({ scrollThreshold: false, loadOnScroll: false });\n this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');\n }\n return response.data?.map(product => this.getItemHTML(product)) || [];\n }\n}\n"]}
@@ -7,15 +7,14 @@ export class SallaProductsSlider {
7
7
  this.urlPrefix = '';
8
8
  this.apiUrl = '';
9
9
  salla.onReady(() => {
10
- this.source = this.source || {
10
+ this.source = {
11
11
  'brands.single': 'brands',
12
12
  'product.index': 'categories',
13
13
  'product.index.latest': 'latest',
14
14
  'product.index.offers': 'offers',
15
15
  'landing-page': 'landing-page',
16
16
  'product.index.tag': 'tags',
17
- 'product.single': 'related',
18
- }[salla.config.get('page.slug')] || 'latest';
17
+ }[this.source || salla.config.get('page.slug')] || this.source || 'latest';
19
18
  let parsedSourceValue = this.sourceValue = this.sourceValue || this.getSourceValue();
20
19
  if (this.sourceValue && ['categories', 'brands', 'tags', 'selected'].includes(this.source) && typeof this.sourceValue == 'string') {
21
20
  parsedSourceValue = JSON.parse(this.sourceValue);
@@ -1 +1 @@
1
- {"version":3,"file":"salla-products-slider.js","sourceRoot":"","sources":["../../../src/components/salla-products-slider/salla-products-slider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,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,CAAA;MAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACrB,CAAC,CAAC,CAAA;EACJ,CAAC;EAED,MAAM;;IACJ,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;MACnG,OAAO;KACR;IACD,OAAO,CACL,EAAC,IAAI,IAAC,KAAK,EAAC,2BAA2B;MACrC,oBACE,KAAK,EAAC,0BAA0B,EAChC,EAAE,EAAE,IAAI,CAAC,QAAQ,IAAI,qBAAqB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EACnF,IAAI,EAAC,UAAU,iBACF,IAAI,CAAC,UAAU,oBACZ,IAAI,CAAC,QAAQ,qBACZ,IAAI,CAAC,aAAa;QAEnC,WAAK,IAAI,EAAC,OAAO,IACd,MAAA,IAAI,CAAC,YAAY,0CAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAClC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAC1B,CACG,CACO,CACV,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import {Component, Host, h, Prop, Element, State} from '@stencil/core';\n\n@Component({\n tag: 'salla-products-slider',\n styleUrl: 'salla-products-slider.scss'\n})\nexport class SallaProductsSlider {\n constructor() {\n salla.onReady(() => {\n this.source = this.source || {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n 'product.single': 'related',\n }[salla.config.get('page.slug')] || 'latest';\n \n let parsedSourceValue = this.sourceValue = this.sourceValue || this.getSourceValue();\n\n if (this.sourceValue && ['categories', 'brands', 'tags', 'selected'].includes(this.source) && typeof this.sourceValue == 'string') {\n parsedSourceValue = JSON.parse(this.sourceValue);\n }\n this.parsedSourceValue = parsedSourceValue;\n this.sourceValueIsValid = !!(this.sourceValue || ['latest', 'offers'].includes(this.source));\n\n });\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.source}]`);\n return;\n }\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n }\n\n @Element() host: HTMLElement;\n //todo:: support limit, default =10, make sure that maximum is 32,\n\n /**\n * Title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() blockTitle: string;\n\n /**\n * Sub title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() subTitle: string;\n\n /**\n * Slider Id, if not provided will be generated automatically\n * @type {string}\n * @default ''\n * */\n @Prop() sliderId: string;\n\n /**\n * Display 'ALL' URL\n * @type {string}\n * @default ''\n * */\n @Prop() displayAllUrl: string;\n\n /**\n * Source of the products, if api will get the products from the API, if json will get the products from the products prop\n * @type {string}\n * @default ''\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'tags' | 'selected' | 'offers' | 'landing-page';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop() sourceValue: string;\n\n //todo:: remove this\n @State() productsData: any;\n @State() isReady: boolean;\n @State() sourceValueIsValid: boolean;\n @State() hasCustomComponent: boolean;\n @State() urlPrefix: string = '';\n @State() apiUrl: string = '';\n @State() parsedSourceValue: any;\n private getSourceValue() {\n if (['landing-page', 'related'].includes(this.source)) {\n return `${salla.config.get('page.id')}`\n } else if (['categories', 'brands', 'tags'].includes(this.source)) {\n return JSON.stringify([salla.config.get('page.id')])\n }\n return this.sourceValue;\n }\n\n private getItemHTML(product) {\n if (this.hasCustomComponent) {\n return <div class=\"s-products-slider-card\">\n <custom-salla-product-card product={product} source={this.source} source-value={this.sourceValue}/>\n </div>;\n }\n\n return <div class=\"s-products-slider-card\">\n <salla-product-card\n show-quantity={this.source == 'landing-page'}\n hide-add-btn={this.source == 'landing-page'}\n shadow-on-hover={true}\n product={product}/>\n </div>;\n }\n\n getApiUrl() {\n if (this.source === 'json') {\n return;\n }\n if (['offers', 'latest'].includes(this.source)) {\n return salla.url.api(`products?source=${this.source}${this.urlPrefix}`);\n }\n if (['related', 'landing-page'].includes(this.source)) {\n return salla.url.api(`products?source=${this.source}&source_value=${this.sourceValue}${this.urlPrefix}`);\n }\n\n try {\n let ids: Array<number> = JSON.parse(this.sourceValue);\n return salla.url.api(`products?source=${this.source}&source_value[]=${ids.join('&source_value[]=')}${this.urlPrefix}`);\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${this.source}]`);\n this.sourceValueIsValid = false;\n }\n }\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n componentWillLoad() {\n if (this.source === 'json') {\n this.productsData = JSON.parse(this.sourceValue)\n this.isReady = true\n return;\n }\n salla.api.request(this.getApiUrl(), null, 'get').then(res => {\n this.productsData = res.data\n this.isReady = true\n })\n }\n\n render() {\n if ((this.source == 'related' && salla.config.get('product.related_products')) || !this.canRender()) {\n return;\n }\n return (\n <Host class=\"s-products-slider-wrapper\">\n <salla-slider\n class=\"s-products-slider-slider\"\n id={this.sliderId || `s-products-slider-${Math.random().toString(36).substr(2, 9)}`}\n type=\"carousel\"\n block-title={this.blockTitle}\n block-subTitle={this.subTitle}\n display-all-url={this.displayAllUrl}\n >\n <div slot=\"items\">\n {this.productsData?.map((product) =>\n this.getItemHTML(product)\n )}\n </div>\n </salla-slider>\n </Host>\n );\n }\n\n}\n"]}
1
+ {"version":3,"file":"salla-products-slider.js","sourceRoot":"","sources":["../../../src/components/salla-products-slider/salla-products-slider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAMvE,MAAM,OAAO,mBAAmB;EAC9B;IAmFS,cAAS,GAAW,EAAE,CAAC;IACvB,WAAM,GAAW,EAAE,CAAC;IAnF3B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;MACjB,IAAI,CAAC,MAAM,GAAG;QACZ,eAAe,EAAE,QAAQ;QACzB,eAAe,EAAE,YAAY;QAC7B,sBAAsB,EAAE,QAAQ;QAChC,sBAAsB,EAAE,QAAQ;QAChC,cAAc,EAAE,cAAc;QAC9B,mBAAmB,EAAE,MAAM;OAC5B,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,IAAK,QAAQ,CAAC;MAE5E,IAAI,iBAAiB,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;MAErF,IAAI,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,IAAI,CAAC,WAAW,IAAI,QAAQ,EAAE;QACjI,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;OAClD;MACD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;MAC3C,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,Q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-products-slider.scss'\n})\nexport class SallaProductsSlider {\n constructor() {\n salla.onReady(() => {\n this.source = {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n }[this.source || salla.config.get('page.slug')] || this.source || 'latest';\n \n let parsedSourceValue = this.sourceValue = this.sourceValue || this.getSourceValue();\n\n if (this.sourceValue && ['categories', 'brands', 'tags', 'selected'].includes(this.source) && typeof this.sourceValue == 'string') {\n parsedSourceValue = JSON.parse(this.sourceValue);\n }\n this.parsedSourceValue = parsedSourceValue;\n this.sourceValueIsValid = !!(this.sourceValue || ['latest', 'offers'].includes(this.source));\n\n });\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.source}]`);\n return;\n }\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n }\n\n @Element() host: HTMLElement;\n //todo:: support limit, default =10, make sure that maximum is 32,\n\n /**\n * Title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() blockTitle: string;\n\n /**\n * Sub title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() subTitle: string;\n\n /**\n * Slider Id, if not provided will be generated automatically\n * @type {string}\n * @default ''\n * */\n @Prop() sliderId: string;\n\n /**\n * Display 'ALL' URL\n * @type {string}\n * @default ''\n * */\n @Prop() displayAllUrl: string;\n\n /**\n * Source of the products, if api will get the products from the API, if json will get the products from the products prop\n * @type {string}\n * @default ''\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'tags' | 'selected' | 'offers' | 'landing-page';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop() sourceValue: string;\n\n //todo:: remove this\n @State() productsData: any;\n @State() isReady: boolean;\n @State() sourceValueIsValid: boolean;\n @State() hasCustomComponent: boolean;\n @State() urlPrefix: string = '';\n @State() apiUrl: string = '';\n @State() parsedSourceValue: any;\n private getSourceValue() {\n if (['landing-page', 'related'].includes(this.source)) {\n return `${salla.config.get('page.id')}`\n } else if (['categories', 'brands', 'tags'].includes(this.source)) {\n return JSON.stringify([salla.config.get('page.id')])\n }\n return this.sourceValue;\n }\n\n private getItemHTML(product) {\n if (this.hasCustomComponent) {\n return <div class=\"s-products-slider-card\">\n <custom-salla-product-card product={product} source={this.source} source-value={this.sourceValue}/>\n </div>;\n }\n\n return <div class=\"s-products-slider-card\">\n <salla-product-card\n show-quantity={this.source == 'landing-page'}\n hide-add-btn={this.source == 'landing-page'}\n shadow-on-hover={true}\n product={product}/>\n </div>;\n }\n\n getApiUrl() {\n if (this.source === 'json') {\n return;\n }\n if (['offers', 'latest'].includes(this.source)) {\n return salla.url.api(`products?source=${this.source}${this.urlPrefix}`);\n }\n if (['related', 'landing-page'].includes(this.source)) {\n return salla.url.api(`products?source=${this.source}&source_value=${this.sourceValue}${this.urlPrefix}`);\n }\n\n try {\n let ids: Array<number> = JSON.parse(this.sourceValue);\n return salla.url.api(`products?source=${this.source}&source_value[]=${ids.join('&source_value[]=')}${this.urlPrefix}`);\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${this.source}]`);\n this.sourceValueIsValid = false;\n }\n }\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n componentWillLoad() {\n if (this.source === 'json') {\n this.productsData = JSON.parse(this.sourceValue)\n this.isReady = true\n return;\n }\n salla.api.request(this.getApiUrl(), null, 'get').then(res => {\n this.productsData = res.data\n this.isReady = true\n })\n }\n\n render() {\n if ((this.source == 'related' && salla.config.get('product.related_products')) || !this.canRender()) {\n return;\n }\n return (\n <Host class=\"s-products-slider-wrapper\">\n <salla-slider\n class=\"s-products-slider-slider\"\n id={this.sliderId || `s-products-slider-${Math.random().toString(36).substr(2, 9)}`}\n type=\"carousel\"\n block-title={this.blockTitle}\n block-subTitle={this.subTitle}\n display-all-url={this.displayAllUrl}\n >\n <div slot=\"items\">\n {this.productsData?.map((product) =>\n this.getItemHTML(product)\n )}\n </div>\n </salla-slider>\n </Host>\n );\n }\n\n}\n"]}
@@ -11,14 +11,17 @@ export class SallaProgressBar {
11
11
  try {
12
12
  if (this.donation) {
13
13
  let donationJson = typeof this.donation == 'string' ? JSON.parse(this.donation) : this.donation;
14
- if (donationJson.can_donate) {
14
+ if (donationJson.can_donate && donationJson.target_amount) {
15
15
  this.value = donationJson.collected_amount;
16
16
  this.target = donationJson.target_amount;
17
17
  this.header = salla.lang.get('pages.products.target');
18
18
  this.message = donationJson.target_end_date == '0000-00-00' ? '' : salla.lang.get('pages.products.donation_target_date') + ' ' + donationJson.target_end_date;
19
19
  }
20
20
  else {
21
- this.message = donationJson.target_message;
21
+ //in case the product is not enabled target campaign
22
+ this.message = donationJson.target_amount
23
+ ? donationJson.target_message
24
+ : '';
22
25
  }
23
26
  }
24
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"salla-progress-bar.js","sourceRoot":"","sources":["../../../src/components/salla-progress-bar/salla-progress-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAOnD,MAAM,OAAO,gBAAgB;EAE3B;IA6CA;;OAEG;IACsB,WAAM,GAAW,MAAM,CAAC;IA/C/C,IAAI;MACF,IAAI,IAAI,CAAC,QAAQ,EAAE;QACjB,IAAI,YAAY,GAAG,OAAO,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAChG,IAAI,YAAY,CAAC,UAAU,EAAE;UAC3B,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,gBAAgB,CAAC;UAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, h, Prop } from '@stencil/core';\nimport { Donation } from \"../salla-product-options/interfaces\";\n\n@Component({\n tag: 'salla-progress-bar',\n styleUrl: 'salla-progress-bar.scss',\n})\nexport class SallaProgressBar {\n\n constructor() {\n try {\n if (this.donation) {\n let donationJson = typeof this.donation == 'string' ? JSON.parse(this.donation) : this.donation;\n if (donationJson.can_donate) {\n this.value = donationJson.collected_amount;\n this.target = donationJson.target_amount;\n this.header = salla.lang.get('pages.products.target');\n this.message = donationJson.target_end_date == '0000-00-00' ? '' : salla.lang.get('pages.products.donation_target_date') + ' ' + donationJson.target_end_date;\n } else {\n this.message = donationJson.target_message;\n }\n }\n } catch (e) {\n salla.log('Wrong donation json');\n }\n\n salla.lang.onLoaded(() => {\n this.header = this.header?.replace('pages.products.target', salla.lang.get('pages.products.target'))\n this.message = this.message?.replace('pages.products.donation_target_date', salla.lang.get('pages.products.donation_target_date'))\n });\n\n salla.onReady(() => {\n this.color = this.color || salla.config.get('theme.color.primary', \"#ffd5c4\")\n if (!this.unit) {\n this.unit = salla.config.currency().symbol;\n }\n })\n }\n\n /**\n * You can just pass the donation as json string ex: `{\"target_message\":null,\"target_date\":\"2023-04-18\",\"target_end_date\":\"2023-04-18\",\"target_amount\":400,\"collected_amount\":380,\"can_donate\":true}`\n */\n @Prop() donation: string | Donation;\n /**\n * The goal of the progress bar\n */\n @Prop({ mutable: true }) target: number;\n\n /**\n * The progress so far as of the goal.\n */\n @Prop({ mutable: true }) value: number;\n \n \n /**\n * Set height for the wrapper.\n */\n @Prop({ mutable: true }) height: string = \"10px\";\n\n /**\n * Big Title, before the progress bar.\n */\n @Prop({ mutable: true }) header: string;\n\n /**\n * Stripped effect for tje progress bar.\n */\n @Prop({ mutable: true }) stripped: boolean;\n\n /**\n * Subtitle under the progress bar or instead of it if the target not being set.\n */\n @Prop({ mutable: true }) message: string;\n\n /**\n * The unite to be added after the numbers, defaults to: `salla.config.currency().symbol`\n */\n @Prop({ mutable: true }) unit: string;\n\n /**\n * Progress bar color, defaults to: `salla.config.get('theme.color.primary', \"#ffd5c4\")`\n */\n @Prop({ mutable: true }) color: string;\n\n private getPercentage(): number {\n return (this.value / this.target) * 100;\n }\n\n render() {\n if (!this.target && !this.message) {\n return '';\n }\n\n return (\n <div class=\"s-progress-bar-container\">\n {this.header ? <div class=\"s-progress-bar-header\">{this.header}</div> : ''}\n {this.getProgressBar()}\n {this.message ? <span class=\"s-progress-bar-message\">{this.message}</span> : ''}\n </div>\n );\n }\n\n private getProgressBar() {\n return this.target ? [\n <div class=\"s-progress-bar-target-section\">\n <span>{salla.helpers.number(this.value)} {this.unit}</span>\n <span>{salla.helpers.number(this.target)} {this.unit}</span>\n </div>,\n <div class=\"s-progress-bar-wrapper\" style={{ 'height': this.height }}>\n <div class={{ \"s-progress-bar-progress\": true, 's-progress-bar-progress-stripped': this.stripped }}\n style={{ 'width': `${this.getPercentage()}%`, 'background-color': this.color }}>\n </div>\n </div>\n ] : '';\n }\n\n}\n"]}
1
+ {"version":3,"file":"salla-progress-bar.js","sourceRoot":"","sources":["../../../src/components/salla-progress-bar/salla-progress-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAOnD,MAAM,OAAO,gBAAgB;EAE3B;IAgDA;;OAEG;IACsB,WAAM,GAAW,MAAM,CAAC;IAlD/C,IAAI;MACF,IAAI,IAAI,CAAC,QAAQ,EAAE;QACjB,IAAI,YAAY,GAAG,OAAO,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAA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AyB,EAAE,IAAI,EAAE,kCAAkC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAChG,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,CAAC,KAAK,EAAE,GAC1E,CACF;KACP,CAAC,CAAC,CAAC,EAAE,CAAC;EACT,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, h, Prop } from '@stencil/core';\nimport { Donation } from \"../salla-product-options/interfaces\";\n\n@Component({\n tag: 'salla-progress-bar',\n styleUrl: 'salla-progress-bar.scss',\n})\nexport class SallaProgressBar {\n\n constructor() {\n try {\n if (this.donation) {\n let donationJson = typeof this.donation == 'string' ? JSON.parse(this.donation) : this.donation;\n if (donationJson.can_donate && donationJson.target_amount) {\n this.value = donationJson.collected_amount;\n this.target = donationJson.target_amount;\n this.header = salla.lang.get('pages.products.target');\n this.message = donationJson.target_end_date == '0000-00-00' ? '' : salla.lang.get('pages.products.donation_target_date') + ' ' + donationJson.target_end_date;\n } else {\n //in case the product is not enabled target campaign\n this.message = donationJson.target_amount\n ? donationJson.target_message\n : '';\n }\n }\n } catch (e) {\n salla.log('Wrong donation json');\n }\n\n salla.lang.onLoaded(() => {\n this.header = this.header?.replace('pages.products.target', salla.lang.get('pages.products.target'))\n this.message = this.message?.replace('pages.products.donation_target_date', salla.lang.get('pages.products.donation_target_date'))\n });\n\n salla.onReady(() => {\n this.color = this.color || salla.config.get('theme.color.primary', \"#ffd5c4\")\n if (!this.unit) {\n this.unit = salla.config.currency().symbol;\n }\n })\n }\n\n /**\n * You can just pass the donation as json string ex: `{\"target_message\":null,\"target_date\":\"2023-04-18\",\"target_end_date\":\"2023-04-18\",\"target_amount\":400,\"collected_amount\":380,\"can_donate\":true}`\n */\n @Prop() donation: string | Donation;\n /**\n * The goal of the progress bar\n */\n @Prop({ mutable: true }) target: number;\n\n /**\n * The progress so far as of the goal.\n */\n @Prop({ mutable: true }) value: number;\n\n\n /**\n * Set height for the wrapper.\n */\n @Prop({ mutable: true }) height: string = \"10px\";\n\n /**\n * Big Title, before the progress bar.\n */\n @Prop({ mutable: true }) header: string;\n\n /**\n * Stripped effect for tje progress bar.\n */\n @Prop({ mutable: true }) stripped: boolean;\n\n /**\n * Subtitle under the progress bar or instead of it if the target not being set.\n */\n @Prop({ mutable: true }) message: string;\n\n /**\n * The unite to be added after the numbers, defaults to: `salla.config.currency().symbol`\n */\n @Prop({ mutable: true }) unit: string;\n\n /**\n * Progress bar color, defaults to: `salla.config.get('theme.color.primary', \"#ffd5c4\")`\n */\n @Prop({ mutable: true }) color: string;\n\n private getPercentage(): number {\n return (this.value / this.target) * 100;\n }\n\n render() {\n if (!this.target && !this.message) {\n return '';\n }\n\n return (\n <div class=\"s-progress-bar-container\">\n {this.header ? <div class=\"s-progress-bar-header\">{this.header}</div> : ''}\n {this.getProgressBar()}\n {this.message ? <span class=\"s-progress-bar-message\">{this.message}</span> : ''}\n </div>\n );\n }\n\n private getProgressBar() {\n return this.target ? [\n <div class=\"s-progress-bar-target-section\">\n <span>{salla.helpers.number(this.value)} {this.unit}</span>\n <span>{salla.helpers.number(this.target)} {this.unit}</span>\n </div>,\n <div class=\"s-progress-bar-wrapper\" style={{ 'height': this.height }}>\n <div class={{ \"s-progress-bar-progress\": true, 's-progress-bar-progress-stripped': this.stripped }}\n style={{ 'width': `${this.getPercentage()}%`, 'background-color': this.color }}>\n </div>\n </div>\n ] : '';\n }\n\n}\n"]}
@@ -65,7 +65,7 @@ const SallaAddProductButton = /*@__PURE__*/ proxyCustomElement(class extends HTM
65
65
  */
66
66
  const data = Object.entries({
67
67
  id: this.productId,
68
- donating_amount: this.donatingAmount,
68
+ donation_amount: this.donatingAmount,
69
69
  quantity: this.quantity,
70
70
  endpoint: 'quickAdd'
71
71
  }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {});
@@ -1 +1 @@
1
- {"file":"salla-add-product-button2.js","mappings":";;;;;;;;;;;;AAAA,MAAM,wBAAwB,GAAG,sEAAsE;;MCO1F,qBAAqB;EAMhC;;;;;IAJQ,mBAAc,GAAQ,EAAE,CAAC;;;;IAoDV,kBAAa,GAAsC,MAAM,CAAC;;;;IAK1D,gBAAW,GAAqG,SAAS,CAAC;IAWxI,oBAAe,GAAe,EAAE,CAAC;IA/DxC,KAAK,CAAC,OAAO,CAAC;MACZ,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;KACnF,CAAC,CAAC;GACJ;EAsEO,QAAQ;IACd,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,IAAI,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,UAAU,IAAI,GAAG,IAAI,IAAI,CAAC,YAAY,EAAE;MAC3G,OAAOA,iBAAI,CAAC;KACb;IAED,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;MACnE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;KAC9C;IAED,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,EAAE;MACjC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;KACjD;IAED,IAAI,IAAI,CAAC,WAAW,KAAK,UAAU,EAAE;MACnC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;KACtD;;IAGD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;GACzD;EAEO,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O,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;MACnC,OAAO;KACR;IACD,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAElC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAM,OAAA,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA,EAAA,CAAC,CAAC;GAC/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["Cart"],"sources":["./src/components/salla-add-product-button/salla-add-product-button.css?tag=salla-add-product-button","./src/components/salla-add-product-button/salla-add-product-button.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\nsalla-add-product-button[width=wide] {\n width: 100%;\n}\n\n","import {Component, Element, State, Event, EventEmitter, Host, Prop, h} from '@stencil/core';\nimport Cart from '../../assets/svg/cart.svg';\n\n@Component({\n tag: 'salla-add-product-button',\n styleUrl: 'salla-add-product-button.css'\n})\nexport class SallaAddProductButton {\n\n private hostAttributes: any = {};\n private btn?: HTMLSallaButtonElement;\n private passedLabel: string;\n\n constructor() {\n salla.onReady(() => {\n this.showQuickBuy = this.quickBuy && !!salla.config.get('store.settings.buy_now');\n });\n }\n\n /**\n * Channels.\n */\n @Prop({reflect: true}) channels: string;\n\n /**\n * Subscribed Options ex: \"[[139487,2394739],[1212,1544]]\"\n */\n @Prop() subscribedOptions: string;\n\n /**\n * Support Quick Pay Button\n */\n @Prop({reflect: true, mutable: true}) quickBuy: boolean;\n\n /**\n * Product Quantity\n */\n @Prop({reflect: true}) quantity: number;\n\n /**\n * Donating amount.\n */\n @Prop({reflect: true}) donatingAmount: number;\n\n /**\n * Listen to product options availability.\n */\n @Prop({reflect: true}) notifyOptionsAvailability: boolean;\n\n /**\n * Product id\n */\n @Prop({reflect: true}) productId;\n\n /**\n * Support themes that have a sticky bar\n */\n @Prop({reflect: true}) supportStickyBar: boolean;\n /**\n * Product Status.Defaults to `sale`\n */\n @Prop({reflect: true}) productStatus: 'sale' | 'out' | 'out-and-notify' = 'sale';\n\n /**\n * Product type. Defaults to `product`\n */\n @Prop({reflect: true}) productType: 'product' | 'service' | 'codes' | 'digital' | 'food' | 'donating' | 'group_products' | 'booking' = 'product';\n\n /**\n * Custome DOM event emitter when product gets added to cart successfully.\n */\n @Event() success: EventEmitter;\n\n @State() hasOutOfStockOption: boolean;\n\n @State() hasSubscribedOptions: boolean;\n\n @State() selectedOptions: Array<any> = [];\n @State() showQuickBuy: boolean;\n\n /**\n * Custome DOM event emitter when product addition to cart fails.\n */\n @Event() failed: EventEmitter;\n\n @Element() host: HTMLElement;\n\n private getLabel() {\n if (this.productStatus === 'sale' && this.supportStickyBar && window.innerWidth <= 768 && this.showQuickBuy) {\n return Cart;\n }\n\n if (this.productStatus === 'sale' && this.productType === 'booking') {\n return salla.lang.get('pages.cart.book_now');\n }\n\n if (this.productStatus === 'sale') {\n return salla.lang.get('pages.cart.add_to_cart');\n }\n\n if (this.productType !== 'donating') {\n return salla.lang.get('pages.products.out_of_stock');\n }\n\n // donating\n return salla.lang.get('pages.products.donation_exceed');\n }\n\n private addProductToCart(event) {\n\n if (this.productType === 'booking') {\n event.preventDefault();\n return this.addBookingProduct();\n }\n\n // we want to ignore the click action when the type of button is submit a form\n if (this.hostAttributes.type === 'submit') {\n return false;\n }\n event.preventDefault();\n /**\n * by default the quick add is just an alias for add item function\n * but its work only when the id is the only value is passed via the object\n * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action\n */\n const data = Object.entries({\n id: this.productId,\n donating_amount: this.donatingAmount,\n quantity: this.quantity,\n endpoint: 'quickAdd'\n }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {})\n return salla.cart.addItem(data)\n .then(response => {\n this.selectedOptions = [];\n this.success.emit(response);\n })\n .catch(error => this.failed.emit(error));\n\n }\n\n private addBookingProduct() {\n if (salla.config.isGuest()) {\n salla.auth.api.setAfterLoginEvent('booking::add', this.productId);\n salla.event.dispatch('login::open');\n return;\n }\n return salla.booking.add(this.productId)\n .then(resp => this.success.emit(resp))\n .catch(error => this.failed.emit(error))\n }\n\n private getBtnAttributes() {\n for (let i = 0; i < this.host.attributes.length; i++) {\n if (!['id', 'class'].includes(this.host.attributes[i].name)) {\n this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;\n }\n }\n\n return this.hostAttributes;\n }\n\n private getQuickBuyBtnAttributes() {\n return {\n ...this.getBtnAttributes(),\n type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : this.productType == 'donating' ? 'donate' : 'buy'\n }\n }\n\n\n componentWillLoad(): void {\n this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();\n if (!!this.passedLabel && window.innerWidth >= 768) {\n this.btn?.setText(this.passedLabel);\n return;\n }\n if (this.host.hasAttribute('type') && this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {\n window.addEventListener('resize', () => {\n if (window.innerWidth >= 768 && !!this.passedLabel) {\n this.btn?.setText(this.passedLabel)\n } else {\n this.btn?.setText(this.getLabel())\n }\n });\n }\n }\n\n\n render() {\n //TODO:: find a better fix, this is a patch for issue that duplicates the buttons more than twice @see the screenshot inside this folder\n if (this.host.closest('.swiper-slide')?.classList.contains('swiper-slide-duplicate')) {\n return ''\n }\n if (this.hasSubscribedOptions) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()} is-subscribed={true}>\n <span class=\"s-hidden\"><slot/></span>\n </salla-product-availability>\n </Host>;\n }\n\n if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()}>\n <span class=\"s-hidden\"><slot/></span>\n </salla-product-availability>\n </Host>;\n }\n\n return <Host class={{\n 's-add-product-button-with-quick-buy': this.showQuickBuy,\n 's-add-product-button-with-sticky-bar': this.supportStickyBar\n }}>\n <salla-button color={this.productStatus === 'sale' ? 'primary' : 'light'}\n type=\"button\"\n fill={this.productStatus === 'sale' ? 'solid' : 'outline'}\n ref={el => this.btn = el as HTMLSallaButtonElement}\n onClick={event => this.addProductToCart(event)}\n disabled={this.productStatus !== 'sale'}\n {...this.getBtnAttributes()}\n loader-position=\"center\"\n >\n <slot/>\n </salla-button>\n {this.showQuickBuy ? <salla-quick-buy {...this.getQuickBuyBtnAttributes()} /> : ''}\n </Host>;\n }\n\n componentDidLoad() {\n if (!this.notifyOptionsAvailability) {\n return;\n }\n\n salla.event.on('product-options::change', async data => {\n if (!['thumbnail', 'color', 'single-option'].includes(data.option.type)) {\n return;\n }\n this.hasSubscribedOptions = false;\n this.selectedOptions = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.getSelectedOptions();\n this.hasOutOfStockOption = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.hasOutOfStockOption();\n let subscribedDetails = salla.storage.get(`product-${this.productId}-subscribed-options`);\n\n if (!subscribedDetails && !this.subscribedOptions || !this.hasOutOfStockOption) {\n return;\n }\n\n if (salla.config.isGuest()) {\n const parsedSubscribedDetails = subscribedDetails ? subscribedDetails.map(ids => ids.split(',').map(id => parseInt(id))) : [];\n\n this.hasSubscribedOptions = parsedSubscribedDetails.length > 0 && parsedSubscribedDetails.some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n );\n } else {\n this.hasSubscribedOptions = this.subscribedOptions && this.subscribedOptions !== 'null' && this.subscribedOptions !== '[]' ? JSON.parse(this.subscribedOptions).some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n ) : false;\n }\n });\n\n\n }\n\n componentDidRender(): void {\n //if label not passed, get label\n if (!!this.passedLabel && (!this.supportStickyBar || window.innerWidth >= 768)) {\n // if passed label, set it\n this.btn?.setText(this.passedLabel)\n return;\n }\n this.btn?.setText(this.getLabel())\n\n salla.lang.onLoaded(() => this.btn?.setText(this.getLabel()));\n }\n}\n"],"version":3}
1
+ {"file":"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AK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAM,OAAA,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA,EAAA,CAAC,CAAC;GAC/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["Cart"],"sources":["./src/components/salla-add-product-button/salla-add-product-button.css?tag=salla-add-product-button","./src/components/salla-add-product-button/salla-add-product-button.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\nsalla-add-product-button[width=wide] {\n width: 100%;\n}\n\n","import {Component, Element, State, Event, EventEmitter, Host, Prop, h} from '@stencil/core';\nimport Cart from '../../assets/svg/cart.svg';\n\n@Component({\n tag: 'salla-add-product-button',\n styleUrl: 'salla-add-product-button.css'\n})\nexport class SallaAddProductButton {\n\n private hostAttributes: any = {};\n private btn?: HTMLSallaButtonElement;\n private passedLabel: string;\n\n constructor() {\n salla.onReady(() => {\n this.showQuickBuy = this.quickBuy && !!salla.config.get('store.settings.buy_now');\n });\n }\n\n /**\n * Channels.\n */\n @Prop({reflect: true}) channels: string;\n\n /**\n * Subscribed Options ex: \"[[139487,2394739],[1212,1544]]\"\n */\n @Prop() subscribedOptions: string;\n\n /**\n * Support Quick Pay Button\n */\n @Prop({reflect: true, mutable: true}) quickBuy: boolean;\n\n /**\n * Product Quantity\n */\n @Prop({reflect: true}) quantity: number;\n\n /**\n * Donating amount.\n */\n @Prop({reflect: true}) donatingAmount: number;\n\n /**\n * Listen to product options availability.\n */\n @Prop({reflect: true}) notifyOptionsAvailability: boolean;\n\n /**\n * Product id\n */\n @Prop({reflect: true}) productId;\n\n /**\n * Support themes that have a sticky bar\n */\n @Prop({reflect: true}) supportStickyBar: boolean;\n /**\n * Product Status.Defaults to `sale`\n */\n @Prop({reflect: true}) productStatus: 'sale' | 'out' | 'out-and-notify' = 'sale';\n\n /**\n * Product type. Defaults to `product`\n */\n @Prop({reflect: true}) productType: 'product' | 'service' | 'codes' | 'digital' | 'food' | 'donating' | 'group_products' | 'booking' = 'product';\n\n /**\n * Custome DOM event emitter when product gets added to cart successfully.\n */\n @Event() success: EventEmitter;\n\n @State() hasOutOfStockOption: boolean;\n\n @State() hasSubscribedOptions: boolean;\n\n @State() selectedOptions: Array<any> = [];\n @State() showQuickBuy: boolean;\n\n /**\n * Custome DOM event emitter when product addition to cart fails.\n */\n @Event() failed: EventEmitter;\n\n @Element() host: HTMLElement;\n\n private getLabel() {\n if (this.productStatus === 'sale' && this.supportStickyBar && window.innerWidth <= 768 && this.showQuickBuy) {\n return Cart;\n }\n\n if (this.productStatus === 'sale' && this.productType === 'booking') {\n return salla.lang.get('pages.cart.book_now');\n }\n\n if (this.productStatus === 'sale') {\n return salla.lang.get('pages.cart.add_to_cart');\n }\n\n if (this.productType !== 'donating') {\n return salla.lang.get('pages.products.out_of_stock');\n }\n\n // donating\n return salla.lang.get('pages.products.donation_exceed');\n }\n\n private addProductToCart(event) {\n\n if (this.productType === 'booking') {\n event.preventDefault();\n return this.addBookingProduct();\n }\n\n // we want to ignore the click action when the type of button is submit a form\n if (this.hostAttributes.type === 'submit') {\n return false;\n }\n event.preventDefault();\n /**\n * by default the quick add is just an alias for add item function\n * but its work only when the id is the only value is passed via the object\n * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action\n */\n const data = Object.entries({\n id: this.productId,\n donation_amount: this.donatingAmount,\n quantity: this.quantity,\n endpoint: 'quickAdd'\n }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {})\n return salla.cart.addItem(data)\n .then(response => {\n this.selectedOptions = [];\n this.success.emit(response);\n })\n .catch(error => this.failed.emit(error));\n\n }\n\n private addBookingProduct() {\n if (salla.config.isGuest()) {\n salla.auth.api.setAfterLoginEvent('booking::add', this.productId);\n salla.event.dispatch('login::open');\n return;\n }\n return salla.booking.add(this.productId)\n .then(resp => this.success.emit(resp))\n .catch(error => this.failed.emit(error))\n }\n\n private getBtnAttributes() {\n for (let i = 0; i < this.host.attributes.length; i++) {\n if (!['id', 'class'].includes(this.host.attributes[i].name)) {\n this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;\n }\n }\n\n return this.hostAttributes;\n }\n\n private getQuickBuyBtnAttributes() {\n return {\n ...this.getBtnAttributes(),\n type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : this.productType == 'donating' ? 'donate' : 'buy'\n }\n }\n\n\n componentWillLoad(): void {\n this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();\n if (!!this.passedLabel && window.innerWidth >= 768) {\n this.btn?.setText(this.passedLabel);\n return;\n }\n if (this.host.hasAttribute('type') && this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {\n window.addEventListener('resize', () => {\n if (window.innerWidth >= 768 && !!this.passedLabel) {\n this.btn?.setText(this.passedLabel)\n } else {\n this.btn?.setText(this.getLabel())\n }\n });\n }\n }\n\n\n render() {\n //TODO:: find a better fix, this is a patch for issue that duplicates the buttons more than twice @see the screenshot inside this folder\n if (this.host.closest('.swiper-slide')?.classList.contains('swiper-slide-duplicate')) {\n return ''\n }\n if (this.hasSubscribedOptions) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()} is-subscribed={true}>\n <span class=\"s-hidden\"><slot/></span>\n </salla-product-availability>\n </Host>;\n }\n\n if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()}>\n <span class=\"s-hidden\"><slot/></span>\n </salla-product-availability>\n </Host>;\n }\n\n return <Host class={{\n 's-add-product-button-with-quick-buy': this.showQuickBuy,\n 's-add-product-button-with-sticky-bar': this.supportStickyBar\n }}>\n <salla-button color={this.productStatus === 'sale' ? 'primary' : 'light'}\n type=\"button\"\n fill={this.productStatus === 'sale' ? 'solid' : 'outline'}\n ref={el => this.btn = el as HTMLSallaButtonElement}\n onClick={event => this.addProductToCart(event)}\n disabled={this.productStatus !== 'sale'}\n {...this.getBtnAttributes()}\n loader-position=\"center\"\n >\n <slot/>\n </salla-button>\n {this.showQuickBuy ? <salla-quick-buy {...this.getQuickBuyBtnAttributes()} /> : ''}\n </Host>;\n }\n\n componentDidLoad() {\n if (!this.notifyOptionsAvailability) {\n return;\n }\n\n salla.event.on('product-options::change', async data => {\n if (!['thumbnail', 'color', 'single-option'].includes(data.option.type)) {\n return;\n }\n this.hasSubscribedOptions = false;\n this.selectedOptions = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.getSelectedOptions();\n this.hasOutOfStockOption = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.hasOutOfStockOption();\n let subscribedDetails = salla.storage.get(`product-${this.productId}-subscribed-options`);\n\n if (!subscribedDetails && !this.subscribedOptions || !this.hasOutOfStockOption) {\n return;\n }\n\n if (salla.config.isGuest()) {\n const parsedSubscribedDetails = subscribedDetails ? subscribedDetails.map(ids => ids.split(',').map(id => parseInt(id))) : [];\n\n this.hasSubscribedOptions = parsedSubscribedDetails.length > 0 && parsedSubscribedDetails.some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n );\n } else {\n this.hasSubscribedOptions = this.subscribedOptions && this.subscribedOptions !== 'null' && this.subscribedOptions !== '[]' ? JSON.parse(this.subscribedOptions).some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n ) : false;\n }\n });\n\n\n }\n\n componentDidRender(): void {\n //if label not passed, get label\n if (!!this.passedLabel && (!this.supportStickyBar || window.innerWidth >= 768)) {\n // if passed label, set it\n this.btn?.setText(this.passedLabel)\n return;\n }\n this.btn?.setText(this.getLabel())\n\n salla.lang.onLoaded(() => this.btn?.setText(this.getLabel()));\n }\n}\n"],"version":3}
@@ -121,12 +121,15 @@ const SallaProductCard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
121
121
  h("p", { class: "s-product-card-content-subtitle" }, (_t = this.productData) === null || _t === void 0 ? void 0 : _t.subtitle)
122
122
  : ''), ((_u = this.productData) === null || _u === void 0 ? void 0 : _u.is_donation) && !this.minimal && !this.fullImage ?
123
123
  [h("salla-progress-bar", { donation: (_v = this.productData) === null || _v === void 0 ? void 0 : _v.donation }), h("div", { class: "s-product-card-donation-input" }, ((_w = this.productData) === null || _w === void 0 ? void 0 : _w.can_donate) ?
124
- [h("label", { htmlFor: "donation-amount" }, this.donationAmount, " ", h("span", null, "*")), h("input", { type: "text", "data-digits": true, id: "donation-amount", name: "donating_amount", class: "s-form-control", placeholder: this.donationAmount })]
124
+ [h("label", { htmlFor: "donation-amount" }, this.donationAmount, " ", h("span", null, "*")), h("input", { type: "text", onInput: e => {
125
+ salla.helpers.inputDigitsOnly(e.target);
126
+ this.addBtn.donatingAmount = e.target.value;
127
+ }, id: "donation-amount", name: "donating_amount", class: "s-form-control", placeholder: this.donationAmount })]
125
128
  : '')]
126
129
  : '', h("div", { class: { 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial } }, this.getProductPrice()), this.isSpecial && this.productData.discount_ends
127
130
  ? h("salla-count-down", { date: this.formatDate(this.productData.discount_ends), "end-of-day": true, boxed: true, labeled: true })
128
131
  : '', !this.hideAddBtn ?
129
- h("div", { class: "s-product-card-content-footer" }, h("salla-add-product-button", { fill: "outline", width: "wide", "product-id": this.productData.id, "product-status": this.productData.status, "product-type": this.productData.type }, h("slot", { name: "add-to-cart-label" }, this.productData.add_to_cart_label)), this.horizontal || this.fullImage ?
132
+ h("div", { class: "s-product-card-content-footer" }, h("salla-add-product-button", { fill: "outline", width: "wide", ref: el => this.addBtn = el, "product-id": this.productData.id, "product-status": this.productData.status, "product-type": this.productData.type }, h("slot", { name: "add-to-cart-label" }, this.productData.add_to_cart_label)), this.horizontal || this.fullImage ?
130
133
  h("salla-button", { shape: "icon", fill: "none", color: "light", ref: el => this.wishlistBtn = el, "aria-label": "Add or remove to wishlist", class: "s-product-card-wishlist-btn animated", onClick: () => salla.wishlist.toggle(this.productData.id), "data-id": "{{ product.id }}" }, h("span", { class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AgB,0CAAE,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,CAAC,CAAC;IAC5F,IAAI,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,QAAQ,KAAI,IAAI,CAAC,SAAS,EAAE;MAChD,IAAI,CAAC,aAAa,EAAE,CAAC;KACtB;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;MACrG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/salla-product-card/salla-product-card.scss?tag=salla-product-card","./src/components/salla-product-card/salla-product-card.tsx"],"sourcesContent":[".s-product-card {\n &-entry {}\n\n &-image {\n &::before {\n font-family: \"sallaicons\";\n content: \"\\ec1f\" !important;\n }\n }\n\n &-vertical {}\n\n &-horizontal {}\n\n &-fit-height {}\n\n &-special {}\n\n &-full-image {}\n\n &-minimal {}\n\n &-donation {}\n\n &-shadow {}\n\n &-out-of-stock {}\n\n &-wishlist-btn {}\n\n &-content {\n &-main {}\n\n &-sub {}\n\n &-footer {}\n\n &-title {}\n\n &-subtitle {}\n\n &-pie {\n &-svg {\n circle {\n transition: stroke-dashoffset 1s linear;\n -webkit-transition: stroke-dashoffset 1s linear;\n -moz-transition: stroke-dashoffset 1s linear;\n -ms-transition: stroke-dashoffset 1s linear;\n -o-transition: stroke-dashoffset 1s linear;\n stroke: #E8EDF2;\n stroke-width: 2px;\n stroke-linecap: round;\n fill: none\n }\n\n &-base {}\n\n &-bar {\n stroke: var(--color-primary) !important;\n stroke-dasharray: 100 100;\n stroke-dashoffset: 100\n }\n }\n }\n\n // for special card\n &-extra-padding {}\n }\n\n &-donation-input {}\n}\n","import {Component, Host, h, Prop, State, Element} from '@stencil/core';\nimport Heart from '../../assets/svg/heart.svg';\n\n/**\n * @slot add-to-cart-label - Add to cart label.\n */\n@Component({\n tag: 'salla-product-card',\n styleUrl: 'salla-product-card.scss',\n assetsDirs: ['assets']\n})\n\nexport class SallaProductCard {\n constructor() {\n // Store configs\n salla.onReady(() => {\n this.fitImageHeight = salla.config.get('store.settings.product.fit_type');\n salla.wishlist.event.onAdded((_res, id) => this.toggleFavoriteIcon(true, id));\n salla.wishlist.event.onRemoved((_res, id) => this.toggleFavoriteIcon(false, id));\n this.placeholder = salla.url.asset(salla.config.get('theme.settings.placeholder'));\n });\n\n // Language\n salla.lang.onLoaded(() => {\n this.remained = salla.lang.get('pages.products.remained');\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.startingPrice = salla.lang.get('pages.products.starting_price');\n this.addToCart = salla.lang.get('pages.cart.add_to_cart');\n this.outOfStock = salla.lang.get('pages.products.out_of_stock');\n })\n\n // Parse product data\n if (this.product) {\n try {\n this.productData = typeof this.product == 'object' ? this.product : JSON.parse(this.product);\n return;\n } catch (e) {\n salla.log('Bad json passed via product prop');\n }\n }\n }\n\n @Element() host: HTMLElement;\n // State\n @State() productData: any;\n @State() fitImageHeight: boolean;\n @State() remained: string;\n @State() outOfStock: string;\n @State() donationAmount: string;\n @State() startingPrice: string;\n @State() addToCart: string;\n @State() placeholder: string;\n\n\n // Refs\n private pie: any;\n private wishlistBtn: HTMLSallaButtonElement;\n\n // Props\n\n\n /**\n * Product information.\n */\n @Prop() product: string;\n\n /**\n * Horizontal card.\n */\n @Prop() horizontal: boolean;\n\n /**\n * Support shadow on hover.\n */\n @Prop() shadowOnHover: boolean;\n\n /**\n * Hide add to cart button.\n */\n @Prop() hideAddBtn: boolean;\n\n /**\n * Full image card.\n */\n @Prop() fullImage: boolean;\n\n /**\n * Minimal card.\n */\n @Prop() minimal: boolean;\n\n /**\n * Special card.\n */\n @Prop() isSpecial: boolean;\n\n /**\n * Show quantity.\n */\n @Prop() showQuantity: boolean;\n\n\n // Private Methods\n private initCircleBar() {\n let qty = this.productData.quantity,\n total = this.productData.quantity > 100 ? this.productData.quantity * 2 : 100,\n roundPercent = (qty / total) * 100,\n bar = this.pie.querySelector('.s-product-card-content-pie-svg-bar'),\n strokeDashOffsetValue = 100 - roundPercent;\n bar.style.strokeDashoffset = strokeDashOffsetValue;\n }\n\n private toggleFavoriteIcon(isAdded = true, id = null) {\n if (id && id !== this.productData.id) {\n return;\n }\n this.wishlistBtn?.classList.toggle('s-product-card-wishlist-added', isAdded);\n }\n\n private formatDate(date) {\n let d = new Date(date);\n return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;\n }\n\n private getProductBadge() {\n if (this.productData.promotion_title) {\n return <div class=\"s-product-card-promotion-title\">{this.productData.promotion_title}</div>\n }\n if (this.showQuantity && this.productData?.quantity) {\n return <div\n class=\"s-product-card-quantity\">{this.remained} {salla.helpers.number(this.productData?.quantity)}</div>\n }\n if (this.showQuantity && this.productData?.is_out_of_stock) {\n return <div class=\"s-product-card-out-badge\">{this.outOfStock}</div>\n }\n return '';\n\n }\n\n getPriceFormat(price) {\n if (!price) {\n return;\n }\n\n return salla.money(price);\n }\n\n private getProductPrice() {\n if (this.productData.is_on_sale) {\n return <div class=\"s-product-card-sale-price\">\n <h4>{this.getPriceFormat(this.productData.sale_price)}</h4>\n <span>{this.getPriceFormat(this.productData?.regular_price)}</span>\n </div>;\n }\n if (this.productData.starting_price) {\n return <div class=\"s-product-card-starting-price\"><p>{this.startingPrice}</p>\n <h4> {this.getPriceFormat(this.productData?.starting_price)} </h4></div>\n }\n return <h4 class=\"s-product-card-price\">{this.getPriceFormat(this.productData?.price)}</h4>\n }\n\n render() {\n const classes = {\n 's-product-card-entry': true,\n 's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-horizontal': this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-fit-height': this.fitImageHeight && !this.isSpecial && !this.fullImage && !this.minimal,\n 's-product-card-special': this.isSpecial,\n 's-product-card-full-image': this.fullImage,\n 's-product-card-minimal': this.minimal,\n 's-product-card-donation': this.productData?.is_donation,\n 's-product-card-shadow': this.shadowOnHover,\n 's-product-card-out-of-stock': this.productData?.is_out_of_stock,\n };\n return (\n <Host id={`product-${this.productData?.id}`} class={classes}>\n <div class={!this.fullImage ? 's-product-card-image' : 's-product-card-image-full'}>\n <a href={this.productData?.url}>\n <img class={`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)\n ? 'contain'\n : this.fitImageHeight\n ? this.fitImageHeight\n : 'cover'} lazy`}\n src={this.placeholder}\n alt={this.productData?.image?.alt}\n data-src={this.productData?.image?.url || this.productData?.thumbnail}\n />\n {!this.fullImage && !this.minimal ? this.getProductBadge() : ''}\n </a>\n {this.fullImage && <a href={this.productData?.url} class=\"s-product-card-overlay\"/>}\n {!this.horizontal && !this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n aria-label=\"Add or remove to wishlist\"\n ref={el => this.wishlistBtn = el}\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}>\n <span innerHTML={Heart}/>\n </salla-button> : ''\n }\n </div>\n <div class=\"s-product-card-content\">\n {this.isSpecial && this.productData?.quantity ?\n <div class=\"s-product-card-content-pie\" ref={pie => this.pie = pie}>\n <span>\n <b>{salla.helpers.number(this.productData?.quantity)}</b>\n {this.remained}\n </span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-2 -1 36 34\" class=\"s-product-card-content-pie-svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-base\"/>\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-bar\"/>\n </svg>\n </div>\n : ''}\n\n <div class={{'s-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial}}>\n <h3 class=\"s-product-card-content-title\">\n <a href={this.productData?.url}>{this.productData?.name}</a>\n </h3>\n\n {this.productData?.subtitle && !this.minimal ?\n <p class=\"s-product-card-content-subtitle\">{this.productData?.subtitle}</p>\n : ''}\n </div>\n {this.productData?.is_donation && !this.minimal && !this.fullImage ?\n [<salla-progress-bar donation={this.productData?.donation}/>,\n <div class=\"s-product-card-donation-input\">\n {this.productData?.can_donate ?\n [<label htmlFor=\"donation-amount\">{this.donationAmount} <span>*</span></label>,\n <input\n type=\"text\"\n data-digits\n id=\"donation-amount\"\n name=\"donating_amount\"\n class=\"s-form-control\"\n placeholder={this.donationAmount}/>]\n : ''}\n </div>]\n : ''}\n <div class={{'s-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial}}>\n {this.getProductPrice()}\n </div>\n\n {this.isSpecial && this.productData.discount_ends\n ? <salla-count-down date={this.formatDate(this.productData.discount_ends)} end-of-day={true} boxed={true}\n labeled={true}/>\n : ''}\n\n\n {!this.hideAddBtn ?\n <div class=\"s-product-card-content-footer\">\n {/* @ts-ignore */}\n <salla-add-product-button fill=\"outline\" width=\"wide\"\n product-id={this.productData.id}\n product-status={this.productData.status}\n product-type={this.productData.type}>\n <slot name=\"add-to-cart-label\">{this.productData.add_to_cart_label}</slot>\n </salla-add-product-button>\n\n {this.horizontal || this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n ref={el => this.wishlistBtn = el}\n aria-label=\"Add or remove to wishlist\"\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}\n data-id=\"{{ product.id }}\">\n <span class=\"text-xl\" innerHTML={Heart}/>\n </salla-button>\n : ''}\n </div>\n : ''}\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n document.lazyLoadInstance?.update(document.querySelectorAll('.s-product-card-image .lazy'));\n if (this.productData?.quantity && this.isSpecial) {\n this.initCircleBar();\n }\n\n if (!salla.config.isGuest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AO,EAAE,MAAM,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,aACjD,kBAAkB,IAC1B,YAAM,KAAK,EAAC,SAAS,EAAC,SAAS,EAAE,KAAK,GAAI,CAC7B;UACb,EAAE,CACF;QACJ,EAAE,CACF,CACD,EACP;GACH;EAED,gBAAgB;;IACd,MAAA,QAAQ,CAAC,gBAAgB,0CAAE,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,CAAC,CAAC;IAC5F,IAAI,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,QAAQ,KAAI,IAAI,CAAC,SAAS,EAAE;MAChD,IAAI,CAAC,aAAa,EAAE,CAAC;KACtB;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;MACrG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/salla-product-card/salla-product-card.scss?tag=salla-product-card","./src/components/salla-product-card/salla-product-card.tsx"],"sourcesContent":[".s-product-card {\n &-entry {}\n\n &-image {\n &::before {\n font-family: \"sallaicons\";\n content: \"\\ec1f\" !important;\n }\n }\n\n &-vertical {}\n\n &-horizontal {}\n\n &-fit-height {}\n\n &-special {}\n\n &-full-image {}\n\n &-minimal {}\n\n &-donation {}\n\n &-shadow {}\n\n &-out-of-stock {}\n\n &-wishlist-btn {}\n\n &-content {\n &-main {}\n\n &-sub {}\n\n &-footer {}\n\n &-title {}\n\n &-subtitle {}\n\n &-pie {\n &-svg {\n circle {\n transition: stroke-dashoffset 1s linear;\n -webkit-transition: stroke-dashoffset 1s linear;\n -moz-transition: stroke-dashoffset 1s linear;\n -ms-transition: stroke-dashoffset 1s linear;\n -o-transition: stroke-dashoffset 1s linear;\n stroke: #E8EDF2;\n stroke-width: 2px;\n stroke-linecap: round;\n fill: none\n }\n\n &-base {}\n\n &-bar {\n stroke: var(--color-primary) !important;\n stroke-dasharray: 100 100;\n stroke-dashoffset: 100\n }\n }\n }\n\n // for special card\n &-extra-padding {}\n }\n\n &-donation-input {}\n}\n","import { Component, Host, h, Prop, State, Element } from '@stencil/core';\nimport Heart from '../../assets/svg/heart.svg';\n\n/**\n * @slot add-to-cart-label - Add to cart label.\n */\n@Component({\n tag: 'salla-product-card',\n styleUrl: 'salla-product-card.scss',\n assetsDirs: ['assets']\n})\n\nexport class SallaProductCard {\n constructor() {\n // Store configs\n salla.onReady(() => {\n this.fitImageHeight = salla.config.get('store.settings.product.fit_type');\n salla.wishlist.event.onAdded((_res, id) => this.toggleFavoriteIcon(true, id));\n salla.wishlist.event.onRemoved((_res, id) => this.toggleFavoriteIcon(false, id));\n this.placeholder = salla.url.asset(salla.config.get('theme.settings.placeholder'));\n });\n\n // Language\n salla.lang.onLoaded(() => {\n this.remained = salla.lang.get('pages.products.remained');\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.startingPrice = salla.lang.get('pages.products.starting_price');\n this.addToCart = salla.lang.get('pages.cart.add_to_cart');\n this.outOfStock = salla.lang.get('pages.products.out_of_stock');\n })\n\n // Parse product data\n if (this.product) {\n try {\n this.productData = typeof this.product == 'object' ? this.product : JSON.parse(this.product);\n return;\n } catch (e) {\n salla.log('Bad json passed via product prop');\n }\n }\n }\n\n @Element() host: HTMLElement;\n // State\n @State() productData: any;\n @State() fitImageHeight: boolean;\n @State() remained: string;\n @State() outOfStock: string;\n @State() donationAmount: string;\n @State() startingPrice: string;\n @State() addToCart: string;\n @State() placeholder: string;\n\n\n // Refs\n private pie: any;\n private wishlistBtn: HTMLSallaButtonElement;\n private addBtn: HTMLSallaAddProductButtonElement;\n\n // Props\n\n\n /**\n * Product information.\n */\n @Prop() product: string;\n\n /**\n * Horizontal card.\n */\n @Prop() horizontal: boolean;\n\n /**\n * Support shadow on hover.\n */\n @Prop() shadowOnHover: boolean;\n\n /**\n * Hide add to cart button.\n */\n @Prop() hideAddBtn: boolean;\n\n /**\n * Full image card.\n */\n @Prop() fullImage: boolean;\n\n /**\n * Minimal card.\n */\n @Prop() minimal: boolean;\n\n /**\n * Special card.\n */\n @Prop() isSpecial: boolean;\n\n /**\n * Show quantity.\n */\n @Prop() showQuantity: boolean;\n\n\n // Private Methods\n private initCircleBar() {\n let qty = this.productData.quantity,\n total = this.productData.quantity > 100 ? this.productData.quantity * 2 : 100,\n roundPercent = (qty / total) * 100,\n bar = this.pie.querySelector('.s-product-card-content-pie-svg-bar'),\n strokeDashOffsetValue = 100 - roundPercent;\n bar.style.strokeDashoffset = strokeDashOffsetValue;\n }\n\n private toggleFavoriteIcon(isAdded = true, id = null) {\n if (id && id !== this.productData.id) {\n return;\n }\n this.wishlistBtn?.classList.toggle('s-product-card-wishlist-added', isAdded);\n }\n\n private formatDate(date) {\n let d = new Date(date);\n return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;\n }\n\n private getProductBadge() {\n if (this.productData.promotion_title) {\n return <div class=\"s-product-card-promotion-title\">{this.productData.promotion_title}</div>\n }\n if (this.showQuantity && this.productData?.quantity) {\n return <div\n class=\"s-product-card-quantity\">{this.remained} {salla.helpers.number(this.productData?.quantity)}</div>\n }\n if (this.showQuantity && this.productData?.is_out_of_stock) {\n return <div class=\"s-product-card-out-badge\">{this.outOfStock}</div>\n }\n return '';\n\n }\n\n getPriceFormat(price) {\n if (!price) {\n return;\n }\n\n return salla.money(price);\n }\n\n private getProductPrice() {\n if (this.productData.is_on_sale) {\n return <div class=\"s-product-card-sale-price\">\n <h4>{this.getPriceFormat(this.productData.sale_price)}</h4>\n <span>{this.getPriceFormat(this.productData?.regular_price)}</span>\n </div>;\n }\n if (this.productData.starting_price) {\n return <div class=\"s-product-card-starting-price\"><p>{this.startingPrice}</p>\n <h4> {this.getPriceFormat(this.productData?.starting_price)} </h4></div>\n }\n return <h4 class=\"s-product-card-price\">{this.getPriceFormat(this.productData?.price)}</h4>\n }\n\n render() {\n const classes = {\n 's-product-card-entry': true,\n 's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-horizontal': this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-fit-height': this.fitImageHeight && !this.isSpecial && !this.fullImage && !this.minimal,\n 's-product-card-special': this.isSpecial,\n 's-product-card-full-image': this.fullImage,\n 's-product-card-minimal': this.minimal,\n 's-product-card-donation': this.productData?.is_donation,\n 's-product-card-shadow': this.shadowOnHover,\n 's-product-card-out-of-stock': this.productData?.is_out_of_stock,\n };\n return (\n <Host id={`product-${this.productData?.id}`} class={classes}>\n <div class={!this.fullImage ? 's-product-card-image' : 's-product-card-image-full'}>\n <a href={this.productData?.url}>\n <img class={`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)\n ? 'contain'\n : this.fitImageHeight\n ? this.fitImageHeight\n : 'cover'} lazy`}\n src={this.placeholder}\n alt={this.productData?.image?.alt}\n data-src={this.productData?.image?.url || this.productData?.thumbnail}\n />\n {!this.fullImage && !this.minimal ? this.getProductBadge() : ''}\n </a>\n {this.fullImage && <a href={this.productData?.url} class=\"s-product-card-overlay\" />}\n {!this.horizontal && !this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n aria-label=\"Add or remove to wishlist\"\n ref={el => this.wishlistBtn = el}\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}>\n <span innerHTML={Heart} />\n </salla-button> : ''\n }\n </div>\n <div class=\"s-product-card-content\">\n {this.isSpecial && this.productData?.quantity ?\n <div class=\"s-product-card-content-pie\" ref={pie => this.pie = pie}>\n <span>\n <b>{salla.helpers.number(this.productData?.quantity)}</b>\n {this.remained}\n </span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-2 -1 36 34\" class=\"s-product-card-content-pie-svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n : ''}\n\n <div class={{ 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n <h3 class=\"s-product-card-content-title\">\n <a href={this.productData?.url}>{this.productData?.name}</a>\n </h3>\n\n {this.productData?.subtitle && !this.minimal ?\n <p class=\"s-product-card-content-subtitle\">{this.productData?.subtitle}</p>\n : ''}\n </div>\n {this.productData?.is_donation && !this.minimal && !this.fullImage ?\n [<salla-progress-bar donation={this.productData?.donation} />,\n <div class=\"s-product-card-donation-input\">\n {this.productData?.can_donate ?\n [<label htmlFor=\"donation-amount\">{this.donationAmount} <span>*</span></label>,\n <input\n type=\"text\"\n onInput={e => {\n salla.helpers.inputDigitsOnly(e.target);\n this.addBtn.donatingAmount = (e.target as any).value;\n }}\n id=\"donation-amount\"\n name=\"donating_amount\"\n class=\"s-form-control\"\n placeholder={this.donationAmount} />]\n : ''}\n </div>]\n : ''}\n <div class={{ 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n {this.getProductPrice()}\n </div>\n\n {this.isSpecial && this.productData.discount_ends\n ? <salla-count-down date={this.formatDate(this.productData.discount_ends)} end-of-day={true} boxed={true}\n labeled={true} />\n : ''}\n\n\n {!this.hideAddBtn ?\n <div class=\"s-product-card-content-footer\">\n {/* @ts-ignore */}\n <salla-add-product-button fill=\"outline\" width=\"wide\"\n ref={el => this.addBtn = el}\n product-id={this.productData.id}\n product-status={this.productData.status}\n product-type={this.productData.type}>\n <slot name=\"add-to-cart-label\">{this.productData.add_to_cart_label}</slot>\n </salla-add-product-button>\n\n {this.horizontal || this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n ref={el => this.wishlistBtn = el}\n aria-label=\"Add or remove to wishlist\"\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}\n data-id=\"{{ product.id }}\">\n <span class=\"text-xl\" innerHTML={Heart} />\n </salla-button>\n : ''}\n </div>\n : ''}\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n document.lazyLoadInstance?.update(document.querySelectorAll('.s-product-card-image .lazy'));\n if (this.productData?.quantity && this.isSpecial) {\n this.initCircleBar();\n }\n\n if (!salla.config.isGuest() && salla.storage.get('salla::wishlist', []).includes(this.productData.id)) {\n this.toggleFavoriteIcon();\n }\n }\n\n}\n"],"version":3}