@salla.sa/twilight-components 2.13.46 → 2.13.48

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 (43) hide show
  1. package/dist/cjs/app-globals-0efa4587.js.map +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-add-product-button_47.cjs.entry.js +23 -5
  4. package/dist/cjs/salla-add-product-button_47.cjs.entry.js.map +1 -1
  5. package/dist/cjs/twilight.cjs.js +1 -1
  6. package/dist/collection/components/salla-breadcrumb/salla-breadcrumb.js +21 -25
  7. package/dist/collection/components/salla-breadcrumb/salla-breadcrumb.js.map +1 -1
  8. package/dist/collection/components/salla-comments/salla-comments.js +20 -1
  9. package/dist/collection/components/salla-comments/salla-comments.js.map +1 -1
  10. package/dist/components/index.js.map +1 -1
  11. package/dist/components/salla-breadcrumb.js +21 -5
  12. package/dist/components/salla-breadcrumb.js.map +1 -1
  13. package/dist/components/salla-comments.js +3 -1
  14. package/dist/components/salla-comments.js.map +1 -1
  15. package/dist/components/salla-quick-buy2.js.map +1 -1
  16. package/dist/esm/app-globals-32c0b133.js.map +1 -1
  17. package/dist/esm/loader.js +1 -1
  18. package/dist/esm/salla-add-product-button_47.entry.js +23 -5
  19. package/dist/esm/salla-add-product-button_47.entry.js.map +1 -1
  20. package/dist/esm/twilight.js +1 -1
  21. package/dist/esm-es5/app-globals-32c0b133.js.map +1 -1
  22. package/dist/esm-es5/loader.js +1 -1
  23. package/dist/esm-es5/loader.js.map +1 -1
  24. package/dist/esm-es5/salla-add-product-button_47.entry.js +2 -2
  25. package/dist/esm-es5/salla-add-product-button_47.entry.js.map +1 -1
  26. package/dist/esm-es5/twilight.js +1 -1
  27. package/dist/esm-es5/twilight.js.map +1 -1
  28. package/dist/twilight/{p-08934db3.entry.js → p-00f68eb0.entry.js} +3 -3
  29. package/dist/twilight/p-00f68eb0.entry.js.map +1 -0
  30. package/dist/twilight/p-44a3fce3.system.js.map +1 -1
  31. package/dist/twilight/{p-1126a332.system.entry.js → p-8a76175f.system.entry.js} +3 -3
  32. package/dist/twilight/p-8a76175f.system.entry.js.map +1 -0
  33. package/dist/twilight/p-93a162ca.js.map +1 -1
  34. package/dist/twilight/p-b9c7fc02.system.js +1 -1
  35. package/dist/twilight/p-b9c7fc02.system.js.map +1 -1
  36. package/dist/twilight/twilight.esm.js +1 -1
  37. package/dist/twilight/twilight.esm.js.map +1 -1
  38. package/dist/types/components/salla-breadcrumb/salla-breadcrumb.d.ts +0 -4
  39. package/dist/types/components/salla-comments/salla-comments.d.ts +4 -0
  40. package/dist/types/components.d.ts +8 -8
  41. package/package.json +5 -5
  42. package/dist/twilight/p-08934db3.entry.js.map +0 -1
  43. package/dist/twilight/p-1126a332.system.entry.js.map +0 -1
@@ -11,14 +11,23 @@ const SallaBreadcrumb$1 = /*@__PURE__*/ proxyCustomElement(class SallaBreadcrumb
11
11
  super();
12
12
  this.__registerHost();
13
13
  var _a, _b;
14
- this.items = undefined;
15
14
  this.breadcrumbs = undefined;
16
15
  // Initialize slot HTML or use default if not provided
17
- this.itemSlot = ((_a = this.host.querySelector('[slot="item"]')) === null || _a === void 0 ? void 0 : _a.outerHTML) || '<li class="s-breadcrumb-item"><a href={url}>{title}</a></li>';
16
+ this.itemSlot = ((_a = this.host.querySelector('[slot="item"]')) === null || _a === void 0 ? void 0 : _a.outerHTML) || `<li class="s-breadcrumb-item"><a href={url}>{title}</a></li>`;
18
17
  this.iconSlot = (_b = this.host.querySelector('[slot="icon"]')) === null || _b === void 0 ? void 0 : _b.outerHTML;
19
18
  }
20
19
  componentWillLoad() {
21
20
  return (new Promise(resolve => salla.onReady(() => salla.lang.onLoaded(resolve))))
21
+ .then(() => {
22
+ if (salla.url.is_page('index')) {
23
+ throw new Error('salla-breadcrumb:: breadcrumb not supported on home page');
24
+ }
25
+ })
26
+ .then(() => {
27
+ if (!salla.config.get('theme.settings.is_breadcrumbs_enabled', true)) {
28
+ throw new Error('salla-breadcrumb:: merchant disabled the feature');
29
+ }
30
+ })
22
31
  .then(() => {
23
32
  const page = salla.config.get("page");
24
33
  if (!page || !page.slug) {
@@ -44,6 +53,10 @@ const SallaBreadcrumb$1 = /*@__PURE__*/ proxyCustomElement(class SallaBreadcrumb
44
53
  if (page.slug == 'brands.single') {
45
54
  this.breadcrumbs.push({ title: salla.lang.get('common.titles.brands'), url: salla.url.get('brands') });
46
55
  }
56
+ //inject loyalty on the breadcrumb, for some reason salla.config.get('page.title') not passed!!
57
+ if (!page.title && page.slug == "loyalty") {
58
+ this.breadcrumbs.push({ title: salla.lang.get('common.titles.loyalty_program'), url: salla.url.get('loyalty') });
59
+ }
47
60
  //add the current page title as the last breadcrumb item, only if it's not set before
48
61
  if (page.title && !['customer.profile', 'brands.index', 'blog.index'].includes(page.slug)) {
49
62
  this.breadcrumbs.push({ title: page.title });
@@ -62,10 +75,14 @@ const SallaBreadcrumb$1 = /*@__PURE__*/ proxyCustomElement(class SallaBreadcrumb
62
75
  */
63
76
  render() {
64
77
  if (this.breadcrumbs.length <= 1) {
65
- salla.log('salla-breadcrumb:: There is no breadcrumbs!', this.breadcrumbs);
78
+ salla.log('salla-breadcrumb:: There is no breadcrumbs!');
66
79
  return;
67
80
  }
68
- return (h("ol", { class: "s-breadcrumb-wrapper" }, this.breadcrumbs.map(item => [
81
+ return (h("ol", { class: {
82
+ "s-breadcrumb-wrapper": true,
83
+ "s-breadcrumb-dark": salla.url.is_page('loyalty'),
84
+ "s-breadcrumb-primary-reverse": salla.config.get('page.slug').includes('customer')
85
+ } }, this.breadcrumbs.map(item => [
69
86
  h("div", { class: "s-breadcrumb-slot", innerHTML: this.itemSlot.replace(/\{url\}/g, item.url).replace(/\{title\}/g, item.title) }),
70
87
  this.getArrowDomForItem(item),
71
88
  ])));
@@ -98,7 +115,6 @@ const SallaBreadcrumb$1 = /*@__PURE__*/ proxyCustomElement(class SallaBreadcrumb
98
115
  get host() { return this; }
99
116
  static get style() { return sallaBreadcrumbCss; }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A2B,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,GAAQ,CACpH,CAAC;GACP;;;;;;;EAQD,kBAAkB;;;IAEhB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,mDAAmD,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;;IAGvI,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,0CAAE,MAAM,EAAE,CAAC;IACnD,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,0CAAE,MAAM,EAAE,CAAC;;IAGnD,IAAI,MAAM,GAAG,MAAA,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC/G,MAAM,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;GACjD;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaBreadcrumb"],"sources":["src/components/salla-breadcrumb/salla-breadcrumb.scss?tag=salla-breadcrumb","src/components/salla-breadcrumb/salla-breadcrumb.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import { Component, Prop, State, h, Element } from '@stencil/core';\nimport { BreadcrumbItem } from './interfaces';\nimport KeyBoardArrowLeftIcon from \"../../assets/svg/keyboard_arrow_left.svg\"\nimport KeyBoardArrowRightIcon from \"../../assets/svg/keyboard_arrow_right.svg\"\n\n/**\n * @name SallaBreadcrumb\n * @description A StencilJS component for rendering breadcrumb navigation.\n * @tag salla-breadcrumb\n *\n * @slot item - Replaces breadcrumb item, has replaceable props `{url}`, `{title}`.\n * @slot icon - Replaces breadcrumb arrow icon.\n */\n@Component({\n tag: 'salla-breadcrumb',\n styleUrl: 'salla-breadcrumb.scss',\n})\nexport class SallaBreadcrumb {\n constructor() {\n\n // Initialize slot HTML or use default if not provided\n this.itemSlot = this.host.querySelector('[slot=\"item\"]')?.outerHTML || '<li class=\"s-breadcrumb-item\"><a href={url}>{title}</a></li>';\n this.iconSlot = this.host.querySelector('[slot=\"icon\"]')?.outerHTML\n }\n\n @Element() host: HTMLElement;\n\n /**\n * Breadcrumb items in array\n */\n @Prop() items: string;\n\n private readonly itemSlot: string;\n private readonly iconSlot: string;\n\n @State() breadcrumbs: BreadcrumbItem[];\n componentWillLoad() {\n return (new Promise(resolve => salla.onReady(() => salla.lang.onLoaded(resolve))))\n .then(() => {\n const page = salla.config.get(\"page\");\n if (!page || !page.slug) {\n salla.logger.error('salla-breadcrumbs:: page object not existed on salla.config.get(\"page\")!');\n return [];\n }\n\n //get from api on these pages\n if (['product.single', 'product.index'].includes(page.slug)) {\n return salla.api.navigation.fetchBreadcrumbs({ page: page.slug, id: page.id, referrer: document.referrer })\n .then(resp => this.breadcrumbs = resp.data);\n }\n\n //otherwise generate the breadcrumb\n\n this.breadcrumbs = [{ title: salla.lang.get('common.titles.home'), url: salla.url.get('') }];\n\n //inject my_account on the breadcrumb\n if (page.slug.includes(\"customer\")) {\n this.breadcrumbs.push({ title: salla.lang.get('common.titles.profile'), url: salla.url.get('profile') });\n }\n\n //inject blog on the breadcrumb\n if (page.slug.includes(\"blog\")) {\n this.breadcrumbs.push({ title: salla.lang.get('blocks.footer.blog'), url: salla.url.get('blog') });\n }\n\n //inject brands on the breadcrumb\n if (page.slug == 'brands.single') {\n this.breadcrumbs.push({ title: salla.lang.get('common.titles.brands'), url: salla.url.get('brands') });\n }\n\n //add the current page title as the last breadcrumb item, only if it's not set before\n if (page.title && !['customer.profile', 'brands.index', 'blog.index'].includes(page.slug)) {\n this.breadcrumbs.push({ title: page.title });\n }\n\n return this.breadcrumbs;\n })\n .then(() => this.breadcrumbs.length && (this.breadcrumbs[this.breadcrumbs.length - 1].is_last = true))\n .catch((error) => {\n salla.logger.error('salla-breadcrumb:: unexpected error!', error);\n this.breadcrumbs = [];\n });\n }\n\n /**\n * Renders the breadcrumb component.\n * @returns JSX for rendering breadcrumbs.\n */\n render() {\n if (this.breadcrumbs.length <= 1) {\n salla.log('salla-breadcrumb:: There is no breadcrumbs!', this.breadcrumbs);\n return;\n }\n return (\n <ol class=\"s-breadcrumb-wrapper\">\n {this.breadcrumbs.map(item => [\n <div class=\"s-breadcrumb-slot\" innerHTML={this.itemSlot.replace(/\\{url\\}/g, item.url).replace(/\\{title\\}/g, item.title)}></div>,\n this.getArrowDomForItem(item),\n ]\n )}\n </ol>\n );\n }\n\n private getArrowDomForItem(item: BreadcrumbItem) {\n if (item.is_last) {\n return '';\n }\n let iconDom = this.iconSlot || (salla.config.get('theme.is_rtl', true) ? KeyBoardArrowLeftIcon : KeyBoardArrowRightIcon);\n\n return <li class=\"s-breadcrumb-arrow\">\n <div class={{ \"s-breadcrumb-icon-slot\": true, \"s-breadcrumb-default-icon\": !this.iconSlot }} innerHTML={iconDom}></div>\n </li>;\n }\n\n /**\n * Lifecycle method called after the component is rendered.\n * - Reduces the number of elements in the DOM.\n * - Removes unnecessary slots parent elements.\n * - Replaces the last anchor tag in the breadcrumb with its content.\n */\n componentDidRender() {\n // Reduces the number of elements in the DOM\n this.host.querySelectorAll('.s-breadcrumb-slot').forEach(el => el.replaceWith(el.firstChild));\n this.host.querySelectorAll('.s-breadcrumb-icon-slot.s-breadcrumb-default-icon').forEach(el => el.replaceWith(el.querySelector('svg')));\n\n // Removes the slots parent elements if exists\n this.host.querySelector('[slot=\"item\"]')?.remove();\n this.host.querySelector('[slot=\"icon\"]')?.remove();\n\n // Removes the last anchor tag in the breadcrumb\n let lastEl = this.host.querySelectorAll('.s-breadcrumb-item')[this.breadcrumbs.length - 1]?.querySelector('a');\n lastEl && lastEl.replaceWith(lastEl.firstChild);\n }\n}\n"],"version":3}
1
+ {"file":"salla-breadcrumb.js","mappings":";;;;;;AAAA,MAAM,kBAAkB,GAAG,sBAAsB;;MCiBpCA,iBAAe;EAC1B;;;;;;IAGE,IAAI,CAAC,QAAQ,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,0CAAE,SAAS,KAAI,8DAA8D,CAAC;IACtI,IAAI,CAAC,QAAQ,GAAG,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,0CAAE,SAAS,CAAA;GACpE;EAaD,iBAAiB;IACf,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;OAC9E,IAAI,CAAC;MACJ,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;OAC7E;KACF,CAAC;OACD,IAAI,CAAC;MACJ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,uCAAuC,EAAE,IAAI,CAAC,EAAE;QACpE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;OACrE;KACF,CAAC;OACD,IAAI,CAAC;MACJ,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;MACtC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QACvB,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,0EAA0E,CAAC,CAAC;QAC/F,OAAO,EAAE,CAAC;OACX;;MAGD,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC,QAAQ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,CAAC,aAAa,CAAC,eAAe,CAAC,0CAAE,MAAM,EAAE,CAAC;IACnD,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,0CAAE,MAAM,EAAE,CAAC;;IAGnD,IAAI,MAAM,GAAG,MAAA,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC/G,MAAM,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;GACjD;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaBreadcrumb"],"sources":["src/components/salla-breadcrumb/salla-breadcrumb.scss?tag=salla-breadcrumb","src/components/salla-breadcrumb/salla-breadcrumb.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import { Component, State, h, Element } from '@stencil/core';\nimport { BreadcrumbItem } from './interfaces';\nimport KeyBoardArrowLeftIcon from \"../../assets/svg/keyboard_arrow_left.svg\"\nimport KeyBoardArrowRightIcon from \"../../assets/svg/keyboard_arrow_right.svg\"\n\n/**\n * @name SallaBreadcrumb\n * @description A StencilJS component for rendering breadcrumb navigation.\n * @tag salla-breadcrumb\n *\n * @slot item - Replaces breadcrumb item, has replaceable props `{url}`, `{title}`.\n * @slot icon - Replaces breadcrumb arrow icon.\n */\n@Component({\n tag: 'salla-breadcrumb',\n styleUrl: 'salla-breadcrumb.scss',\n})\nexport class SallaBreadcrumb {\n constructor() {\n\n // Initialize slot HTML or use default if not provided\n this.itemSlot = this.host.querySelector('[slot=\"item\"]')?.outerHTML || `<li class=\"s-breadcrumb-item\"><a href={url}>{title}</a></li>`;\n this.iconSlot = this.host.querySelector('[slot=\"icon\"]')?.outerHTML\n }\n\n @Element() host: HTMLElement;\n\n // /**\n // * Breadcrumb items in array\n // */\n // @Prop() items: string;\n\n private readonly itemSlot: string;\n private readonly iconSlot: string;\n\n @State() breadcrumbs: BreadcrumbItem[];\n componentWillLoad() {\n return (new Promise(resolve => salla.onReady(() => salla.lang.onLoaded(resolve))))\n .then(() => {\n if (salla.url.is_page('index')) {\n throw new Error('salla-breadcrumb:: breadcrumb not supported on home page');\n }\n })\n .then(() => {\n if (!salla.config.get('theme.settings.is_breadcrumbs_enabled', true)) {\n throw new Error('salla-breadcrumb:: merchant disabled the feature');\n }\n })\n .then(() => {\n const page = salla.config.get(\"page\");\n if (!page || !page.slug) {\n salla.logger.error('salla-breadcrumbs:: page object not existed on salla.config.get(\"page\")!');\n return [];\n }\n\n //get from api on these pages\n if (['product.single', 'product.index'].includes(page.slug)) {\n return salla.api.navigation.fetchBreadcrumbs({ page: page.slug, id: page.id, referrer: document.referrer })\n .then(resp => this.breadcrumbs = resp.data);\n }\n\n //otherwise generate the breadcrumb\n\n this.breadcrumbs = [{ title: salla.lang.get('common.titles.home'), url: salla.url.get('') }];\n\n //inject my_account on the breadcrumb\n if (page.slug.includes(\"customer\")) {\n this.breadcrumbs.push({ title: salla.lang.get('common.titles.profile'), url: salla.url.get('profile') });\n }\n\n //inject blog on the breadcrumb\n if (page.slug.includes(\"blog\")) {\n this.breadcrumbs.push({ title: salla.lang.get('blocks.footer.blog'), url: salla.url.get('blog') });\n }\n\n //inject brands on the breadcrumb\n if (page.slug == 'brands.single') {\n this.breadcrumbs.push({ title: salla.lang.get('common.titles.brands'), url: salla.url.get('brands') });\n }\n\n //inject loyalty on the breadcrumb, for some reason salla.config.get('page.title') not passed!!\n if (!page.title && page.slug == \"loyalty\") {\n this.breadcrumbs.push({ title: salla.lang.get('common.titles.loyalty_program'), url: salla.url.get('loyalty') });\n }\n\n //add the current page title as the last breadcrumb item, only if it's not set before\n if (page.title && !['customer.profile', 'brands.index', 'blog.index'].includes(page.slug)) {\n this.breadcrumbs.push({ title: page.title });\n }\n\n return this.breadcrumbs;\n })\n .then(() => this.breadcrumbs.length && (this.breadcrumbs[this.breadcrumbs.length - 1].is_last = true))\n .catch((error) => {\n salla.logger.error('salla-breadcrumb:: unexpected error!', error);\n this.breadcrumbs = [];\n });\n }\n\n /**\n * Renders the breadcrumb component.\n * @returns JSX for rendering breadcrumbs.\n */\n render() {\n if (this.breadcrumbs.length <= 1) {\n salla.log('salla-breadcrumb:: There is no breadcrumbs!');\n return;\n }\n return (\n <ol class={{\n \"s-breadcrumb-wrapper\": true,\n \"s-breadcrumb-dark\": salla.url.is_page('loyalty'),\n \"s-breadcrumb-primary-reverse\": salla.config.get('page.slug').includes('customer')\n }}>\n {this.breadcrumbs.map(item => [\n <div class=\"s-breadcrumb-slot\" innerHTML={this.itemSlot.replace(/\\{url\\}/g, item.url).replace(/\\{title\\}/g, item.title)}></div>,\n this.getArrowDomForItem(item),\n ]\n )}\n </ol>\n );\n }\n\n private getArrowDomForItem(item: BreadcrumbItem) {\n if (item.is_last) {\n return '';\n }\n let iconDom = this.iconSlot || (salla.config.get('theme.is_rtl', true) ? KeyBoardArrowLeftIcon : KeyBoardArrowRightIcon);\n\n return <li class=\"s-breadcrumb-arrow\">\n <div class={{ \"s-breadcrumb-icon-slot\": true, \"s-breadcrumb-default-icon\": !this.iconSlot }} innerHTML={iconDom}></div>\n </li>;\n }\n\n /**\n * Lifecycle method called after the component is rendered.\n * - Reduces the number of elements in the DOM.\n * - Removes unnecessary slots parent elements.\n * - Replaces the last anchor tag in the breadcrumb with its content.\n */\n componentDidRender() {\n // Reduces the number of elements in the DOM\n this.host.querySelectorAll('.s-breadcrumb-slot').forEach(el => el.replaceWith(el.firstChild));\n this.host.querySelectorAll('.s-breadcrumb-icon-slot.s-breadcrumb-default-icon').forEach(el => el.replaceWith(el.querySelector('svg')));\n\n // Removes the slots parent elements if exists\n this.host.querySelector('[slot=\"item\"]')?.remove();\n this.host.querySelector('[slot=\"icon\"]')?.remove();\n\n // Removes the last anchor tag in the breadcrumb\n let lastEl = this.host.querySelectorAll('.s-breadcrumb-item')[this.breadcrumbs.length - 1]?.querySelector('a');\n lastEl && lastEl.replaceWith(lastEl.firstChild);\n }\n}\n"],"version":3}
@@ -27,6 +27,7 @@ const SallaComments$1 = /*@__PURE__*/ proxyCustomElement(class SallaComments ext
27
27
  this.blockTitle = undefined;
28
28
  this.hideTitle = undefined;
29
29
  this.type = CommentType.PAGE;
30
+ this.showFormAvatar = false;
30
31
  this.comments = undefined;
31
32
  this.pagination = undefined;
32
33
  this.total = undefined;
@@ -162,7 +163,7 @@ const SallaComments$1 = /*@__PURE__*/ proxyCustomElement(class SallaComments ext
162
163
  render() {
163
164
  // We should show a different placeholder for pages and products (WIP)
164
165
  if (this.showPlaceholder) {
165
- return (h("div", null, !!this.total && !this.hideTitle ? h("h2", { class: "s-comments-title" }, this.blockTitle ? this.blockTitle : this.comment_title) : '', !this.hideForm && h("salla-comment-form", { type: this.type, "item-id": this.itemId }), h("div", { class: "no-content-placeholder--comments" }, h("i", { class: "sicon-chat-bubbles text-5xl block mb-5 text-gray-400" }), h("p", { class: "text-sm" }, this.noComments))));
166
+ return (h("div", null, !!this.total && !this.hideTitle ? h("h2", { class: "s-comments-title" }, this.blockTitle ? this.blockTitle : this.comment_title) : '', !this.hideForm && h("salla-comment-form", { "show-avatar": this.showFormAvatar, type: this.type, "item-id": this.itemId }), h("div", { class: "no-content-placeholder--comments" }, h("i", { class: "sicon-chat-bubbles text-5xl block mb-5 text-gray-400" }), h("p", { class: "text-sm" }, this.noComments))));
166
167
  }
167
168
  return (h("div", { class: `s-comments s-comments-${this.type}` }, h("div", { class: `${this.type == CommentType.PAGE ? "s-comments-page-container" : "s-comments-container"}` }, !!this.total && !this.hideTitle ? h("h2", { class: "s-comments-title" }, this.blockTitle ? this.blockTitle : this.comment_title) : '', !this.hideForm && h("salla-comment-form", { type: this.type, "item-id": this.itemId }), !!this.total && h("h2", { class: "s-comments-count-label", innerHTML: this.pluralize(this.comment_name, this.total) }), h("div", { ref: wrapper => this.wrapper = wrapper }), this.nextPage && (h("div", { class: "s-infinite-scroll-wrapper", ref: status => this.status = status }, h("button", { onClick: () => this.loadMore(), class: "s-infinite-scroll-btn s-button-btn s-button-primary" }, h("span", { class: "s-button-text s-infinite-scroll-btn-text" }, this.loadMoreText ? this.loadMoreText : salla.lang.get('common.elements.load_more')), h("span", { class: "s-button-loader s-button-loader-center s-infinite-scroll-btn-loader", ref: btnLoader => this.btnLoader = btnLoader, style: { "display": "none" } })))))));
168
169
  }
@@ -178,6 +179,7 @@ const SallaComments$1 = /*@__PURE__*/ proxyCustomElement(class SallaComments ext
178
179
  "blockTitle": [1, "block-title"],
179
180
  "hideTitle": [4, "hide-title"],
180
181
  "type": [1],
182
+ "showFormAvatar": [4, "show-form-avatar"],
181
183
  "comments": [32],
182
184
  "pagination": [32],
183
185
  "total": [32],
@@ -1 +1 @@
1
- {"file":"salla-comments.js","mappings":";;;;;;;;;;;AAAA,IAAY,WAGX;AAHD,WAAY,WAAW;EACnB,4BAAY,CAAA;EACZ,kCAAmB,CAAA;AACvB,CAAC,EAHW,WAAW,KAAX,WAAW;;ACAvB,MAAM,gBAAgB,GAAG,sBAAsB;;MCQlCA,eAAa;EAExB;;;;;;;;gBAoCuD,WAAW,CAAC,IAAI;;;;;;sBAgBzC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,6BAA6B,CAAC;yBAClD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC;wBACxC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC;;IArD/D,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;MAClB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;MAC5D,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;MAC7D,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;KAC5D,CAAC,CAAA;GACH;;;E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AAE,OAAO,IAAI,IAAI,CAAC,OAAO,GAAG,OAAO,GAAQ,EAGlD,IAAI,CAAC,QAAQ,KACZ,WAAK,KAAK,EAAC,2BAA2B,EAAC,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,IACxE,cAAQ,OAAO,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAC,qDAAqD,IACjG,YAAM,KAAK,EAAC,0CAA0C,IAAE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAQ,EACnJ,YAAM,KAAK,EAAC,qEAAqE,EAAC,GAAG,EAAE,SAAS,IAAI,IAAI,CAAC,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAS,CAC9J,CACL,CACP,CACG,CACF,EAEN;GACH;EAID,MAAM,iBAAiB;IACrB,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;GAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaComments"],"sources":["src/components/salla-comments/interfaces.ts","src/components/salla-comments/salla-comments.scss?tag=salla-comments","src/components/salla-comments/salla-comments.tsx"],"sourcesContent":["export enum CommentType {\n PAGE= \"page\",\n PRODUCT = \"product\"\n}\n\nexport interface Comment {\n id?: number;\n avatar?: string;\n name?: string;\n has_order?: boolean;\n date?: string;\n rating?: number;\n content?: string;\n is_pending?: boolean;\n replies?: Comment[];\n customer?: Customer;\n type?: string;\n created_at?: CreatedAt;\n}\nexport interface CreatedAt {\n date?: Date;\n timezone_type?: number;\n timezone?: string;\n}\nexport interface UserComments {\n id?: number;\n type?: string;\n next_page?: string;\n comments?: Comment[];\n}\n\n// Pagination\nexport interface Pagination {\n count?: number;\n total?: number;\n perPage?: number;\n currentPage?: number;\n totalPages?: number;\n links?: Links;\n}\nexport interface Customer {\n id?: number;\n name?: string;\n mobile?: string;\n email?: string;\n avatar?: string;\n country?: string;\n city?: string;\n}\nexport interface Links {\n next?: string;\n}\n",":host {\n display: block;\n}\n","import { Component, Prop, State, Element, h } from '@stencil/core';\nimport { CommentType, UserComments, Pagination } from './interfaces';\nimport anime from 'animejs';\nimport Helper from '../../Helpers/Helper';\n@Component({\n tag: 'salla-comments',\n styleUrl: 'salla-comments.scss',\n})\nexport class SallaComments {\n\n constructor() {\n salla.lang.onLoaded(() => {\n this.comment_title = salla.lang.get('blocks.comments.title')\n this.comment_name = salla.lang.get('blocks.comments.comment')\n this.noComments = salla.lang.get('pages.rating.no_ratings')\n })\n }\n\n /**\n * Page or product ID\n */\n @Prop() itemId!: number;\n\n /**\n * Load more text\n */\n @Prop() loadMoreText: string;\n\n /**\n * Load more text\n */\n @Prop() hideForm: boolean;\n\n /**\n * Block Title\n */\n @Prop() blockTitle: string;\n \n /**\n * Hide Title\n */\n @Prop() hideTitle: boolean;\n\n /**\n * Comment Type\n */\n @Prop() type: CommentType.PAGE | CommentType.PRODUCT = CommentType.PAGE;\n\n @State() comments: UserComments[];\n @State() pagination: Pagination;\n @State() total: number;\n @State() showPlaceholder: boolean;\n @State() nextPage: string;\n\n private status: any;\n private btnLoader: any;\n private infiniteScroll: any;\n private wrapper: any;\n\n @Element() host: HTMLElement;\n\n // Translations\n @State() noComments: string = salla.lang.get('blocks.comments.no_comments');\n @State() comment_title = salla.lang.get('blocks.comments.title')\n @State() comment_name = salla.lang.get('blocks.comments.comment')\n @State() placeholder_text: string;\n\n // TOOD: it's a good idea to move this into lang.js\n // Pluralize a string based on the count\n private pluralize(phrases: string, count: number): string {\n const options = phrases.split('|');\n\n const conditions = [\n { condition: count === 0, index: 0 },\n { condition: count === 1, index: 1 },\n { condition: count === 2, index: 2 },\n { condition: count > 2 && count <= 10, index: 3 },\n { condition: count >= 11, index: 4 }\n ];\n\n const { index } = conditions.find(({ condition }) => condition) || { index: options.length - 1 };\n\n const selectedOption = options[index];\n return selectedOption.replace(':count', salla.helpers.number(count.toString()))\n .replace(/\\{[0-9]+\\}/g, '')\n .replace(/\\[\\d+,\\d+\\]|\\[11,\\*\\]/g, '');\n }\n\n\n\n // Initiate infinite scroll\n private initiateInfiniteScroll() {\n if (!this.wrapper) {\n console.error('Wrapper is undefined. Cannot initiate infinite scroll.');\n return;\n }\n\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: true,\n nextPage: this.nextPage,\n scrollThreshold: false,\n }, true);\n\n this.infiniteScroll?.on('request', _response => {\n this.loading();\n });\n this.infiniteScroll?.on('load', response => {\n this.pagination = response.pagination;\n this.nextPage = typeof response.pagination.links == 'object' && !!response.pagination.links.next ? response.pagination.links.next : null;\n this.handleResponse(response).forEach(card => this.wrapper.append(card));\n\n let items = this.host.querySelectorAll('salla-comment-item:not(.animated):not(.s-comments-item-admin)');\n this.animateItems(items);\n this.loading(false);\n });\n this.infiniteScroll?.on('error', (e) => {\n salla.console.error('Error loading more comments:', e);\n });\n }\n\n // Show/hide loading\n private loading(isLoading = true) {\n let btnText = this.status?.querySelector('.s-button-text');\n if (btnText) {\n Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n }\n\n // Animate newly added items\n private animateItems(items) {\n anime({\n targets: items,\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n easing: 'easeOutExpo',\n complete: function (_anim) {\n items.forEach(item => {\n item.classList.add('animated');\n })\n }\n\n })\n }\n\n // Get comment item HTML\n private getCommentHTML(comment) {\n const commentItem = document.createElement('salla-comment-item') as HTMLSallaCommentItemElement;\n commentItem.comment = comment;\n\n return commentItem;\n }\n\n\n\n // Parse response and return an array of comment items to be appended to the wrapper\n private handleResponse(response): Array<HTMLElement> {\n return response.data?.map(comment => this.getCommentHTML(comment)) || [];\n }\n\n\n\n // Load initial data\n private async loadInitialData() {\n this.loading();\n try {\n const resp = await (this.type == CommentType.PAGE\n ? salla.api.comment.getPageComments(this.itemId)\n : salla.api.comment.getProductComments(this.itemId));\n if (!resp.data || !resp.data.length) {\n this.showPlaceholder = false;\n this.loading(false);\n return;\n }\n this.comments = resp.data;\n this.pagination = resp.pagination;\n this.total = resp.pagination.total;\n this.nextPage = typeof resp.pagination.links == 'object' && !!resp.pagination.links.next ? resp.pagination.links.next : null;\n\n\n setTimeout(() => {\n this.handleResponse(resp).forEach(card => this.wrapper.append(card));\n this.initiateInfiniteScroll(); // Initiate infinite scroll after the initial data is loaded\n let items = this.wrapper.querySelectorAll('salla-comment-item:not(.animated)');\n this.animateItems(items);\n }, 100);\n } catch (error) {\n console.error('Error loading initial data:', error);\n this.showPlaceholder = true;\n this.loading(false);\n }\n }\n\n // Get next page\n async loadMore() {\n this.infiniteScroll?.loadNextPage();\n }\n\n render() {\n // We should show a different placeholder for pages and products (WIP)\n if (this.showPlaceholder) {\n return (\n <div>\n {!!this.total && !this.hideTitle ? <h2 class=\"s-comments-title\">{this.blockTitle ? this.blockTitle : this.comment_title}</h2> : ''}\n {!this.hideForm && <salla-comment-form type={this.type} item-id={this.itemId}></salla-comment-form>}\n <div class=\"no-content-placeholder--comments\">\n <i class=\"sicon-chat-bubbles text-5xl block mb-5 text-gray-400\"></i>\n <p class=\"text-sm\">{this.noComments}</p>\n </div>\n </div>\n )\n }\n return (\n <div class={`s-comments s-comments-${this.type}`}>\n <div class={`${this.type == CommentType.PAGE ? \"s-comments-page-container\" : \"s-comments-container\"}`} >\n {!!this.total && !this.hideTitle ? <h2 class=\"s-comments-title\">{this.blockTitle ? this.blockTitle : this.comment_title}</h2> : ''}\n {!this.hideForm && <salla-comment-form type={this.type} item-id={this.itemId}></salla-comment-form>}\n\n {!!this.total && <h2 class=\"s-comments-count-label\" innerHTML={this.pluralize(this.comment_name, this.total)}></h2>}\n <div ref={wrapper => this.wrapper = wrapper}></div>\n\n\n {this.nextPage && (\n <div class=\"s-infinite-scroll-wrapper\" ref={status => this.status = status}>\n <button onClick={() => this.loadMore()} class=\"s-infinite-scroll-btn s-button-btn s-button-primary\">\n <span class=\"s-button-text s-infinite-scroll-btn-text\">{this.loadMoreText ? this.loadMoreText : salla.lang.get('common.elements.load_more')}</span>\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" ref={btnLoader => this.btnLoader = btnLoader} style={{ \"display\": \"none\" }}></span>\n </button>\n </div>\n )}\n </div>\n </div>\n\n );\n }\n\n\n\n async componentWillLoad() {\n await this.loadInitialData(); // Load initial data before rendering the component\n }\n\n}\n"],"version":3}
1
+ {"file":"salla-comments.js","mappings":";;;;;;;;;;;AAAA,IAAY,WAGX;AAHD,WAAY,WAAW;EACnB,4BAAY,CAAA;EACZ,kCAAmB,CAAA;AACvB,CAAC,EAHW,WAAW,KAAX,WAAW;;ACAvB,MAAM,gBAAgB,GAAG,sBAAsB;;MCQlCA,eAAa;EAExB;;;;;;;;gBAoCuD,WAAW,CAAC,IAAI;0BAKrC,KAAK;;;;;;sBAgBT,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,6BAA6B,CAAC;yBAClD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC;wBACxC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC;;IA1D/D,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;MAClB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;MAC5D,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;MAC7D,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;KAC5D,CAAC,CAAA;GACH;;;EA0DO,SAAS,CAAC,OAAe,EAAE,KAAa;IAC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,IAAI,CAAC,OAAO,GAAG,OAAO,GAAQ,EAGlD,IAAI,CAAC,QAAQ,KACZ,WAAK,KAAK,EAAC,2BAA2B,EAAC,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,IACxE,cAAQ,OAAO,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAC,qDAAqD,IACjG,YAAM,KAAK,EAAC,0CAA0C,IAAE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAQ,EACnJ,YAAM,KAAK,EAAC,qEAAqE,EAAC,GAAG,EAAE,SAAS,IAAI,IAAI,CAAC,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAS,CAC9J,CACL,CACP,CACG,CACF,EAEN;GACH;EAID,MAAM,iBAAiB;IACrB,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;GAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaComments"],"sources":["src/components/salla-comments/interfaces.ts","src/components/salla-comments/salla-comments.scss?tag=salla-comments","src/components/salla-comments/salla-comments.tsx"],"sourcesContent":["export enum CommentType {\n PAGE= \"page\",\n PRODUCT = \"product\"\n}\n\nexport interface Comment {\n id?: number;\n avatar?: string;\n name?: string;\n has_order?: boolean;\n date?: string;\n rating?: number;\n content?: string;\n is_pending?: boolean;\n replies?: Comment[];\n customer?: Customer;\n type?: string;\n created_at?: CreatedAt;\n}\nexport interface CreatedAt {\n date?: Date;\n timezone_type?: number;\n timezone?: string;\n}\nexport interface UserComments {\n id?: number;\n type?: string;\n next_page?: string;\n comments?: Comment[];\n}\n\n// Pagination\nexport interface Pagination {\n count?: number;\n total?: number;\n perPage?: number;\n currentPage?: number;\n totalPages?: number;\n links?: Links;\n}\nexport interface Customer {\n id?: number;\n name?: string;\n mobile?: string;\n email?: string;\n avatar?: string;\n country?: string;\n city?: string;\n}\nexport interface Links {\n next?: string;\n}\n",":host {\n display: block;\n}\n","import { Component, Prop, State, Element, h } from '@stencil/core';\nimport { CommentType, UserComments, Pagination } from './interfaces';\nimport anime from 'animejs';\nimport Helper from '../../Helpers/Helper';\n@Component({\n tag: 'salla-comments',\n styleUrl: 'salla-comments.scss',\n})\nexport class SallaComments {\n\n constructor() {\n salla.lang.onLoaded(() => {\n this.comment_title = salla.lang.get('blocks.comments.title')\n this.comment_name = salla.lang.get('blocks.comments.comment')\n this.noComments = salla.lang.get('pages.rating.no_ratings')\n })\n }\n\n /**\n * Page or product ID\n */\n @Prop() itemId!: number;\n\n /**\n * Load more text\n */\n @Prop() loadMoreText: string;\n\n /**\n * Load more text\n */\n @Prop() hideForm: boolean;\n\n /**\n * Block Title\n */\n @Prop() blockTitle: string;\n \n /**\n * Hide Title\n */\n @Prop() hideTitle: boolean;\n\n /**\n * Comment Type\n */\n @Prop() type: CommentType.PAGE | CommentType.PRODUCT = CommentType.PAGE;\n\n /**\n * Show or hide avatar\n */\n @Prop() showFormAvatar: boolean = false;\n\n @State() comments: UserComments[];\n @State() pagination: Pagination;\n @State() total: number;\n @State() showPlaceholder: boolean;\n @State() nextPage: string;\n\n private status: any;\n private btnLoader: any;\n private infiniteScroll: any;\n private wrapper: any;\n\n @Element() host: HTMLElement;\n\n // Translations\n @State() noComments: string = salla.lang.get('blocks.comments.no_comments');\n @State() comment_title = salla.lang.get('blocks.comments.title')\n @State() comment_name = salla.lang.get('blocks.comments.comment')\n @State() placeholder_text: string;\n\n // TOOD: it's a good idea to move this into lang.js\n // Pluralize a string based on the count\n private pluralize(phrases: string, count: number): string {\n const options = phrases.split('|');\n\n const conditions = [\n { condition: count === 0, index: 0 },\n { condition: count === 1, index: 1 },\n { condition: count === 2, index: 2 },\n { condition: count > 2 && count <= 10, index: 3 },\n { condition: count >= 11, index: 4 }\n ];\n\n const { index } = conditions.find(({ condition }) => condition) || { index: options.length - 1 };\n\n const selectedOption = options[index];\n return selectedOption.replace(':count', salla.helpers.number(count.toString()))\n .replace(/\\{[0-9]+\\}/g, '')\n .replace(/\\[\\d+,\\d+\\]|\\[11,\\*\\]/g, '');\n }\n\n\n\n // Initiate infinite scroll\n private initiateInfiniteScroll() {\n if (!this.wrapper) {\n console.error('Wrapper is undefined. Cannot initiate infinite scroll.');\n return;\n }\n\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: true,\n nextPage: this.nextPage,\n scrollThreshold: false,\n }, true);\n\n this.infiniteScroll?.on('request', _response => {\n this.loading();\n });\n this.infiniteScroll?.on('load', response => {\n this.pagination = response.pagination;\n this.nextPage = typeof response.pagination.links == 'object' && !!response.pagination.links.next ? response.pagination.links.next : null;\n this.handleResponse(response).forEach(card => this.wrapper.append(card));\n\n let items = this.host.querySelectorAll('salla-comment-item:not(.animated):not(.s-comments-item-admin)');\n this.animateItems(items);\n this.loading(false);\n });\n this.infiniteScroll?.on('error', (e) => {\n salla.console.error('Error loading more comments:', e);\n });\n }\n\n // Show/hide loading\n private loading(isLoading = true) {\n let btnText = this.status?.querySelector('.s-button-text');\n if (btnText) {\n Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n }\n\n // Animate newly added items\n private animateItems(items) {\n anime({\n targets: items,\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n easing: 'easeOutExpo',\n complete: function (_anim) {\n items.forEach(item => {\n item.classList.add('animated');\n })\n }\n\n })\n }\n\n // Get comment item HTML\n private getCommentHTML(comment) {\n const commentItem = document.createElement('salla-comment-item') as HTMLSallaCommentItemElement;\n commentItem.comment = comment;\n\n return commentItem;\n }\n\n\n\n // Parse response and return an array of comment items to be appended to the wrapper\n private handleResponse(response): Array<HTMLElement> {\n return response.data?.map(comment => this.getCommentHTML(comment)) || [];\n }\n\n\n\n // Load initial data\n private async loadInitialData() {\n this.loading();\n try {\n const resp = await (this.type == CommentType.PAGE\n ? salla.api.comment.getPageComments(this.itemId)\n : salla.api.comment.getProductComments(this.itemId));\n if (!resp.data || !resp.data.length) {\n this.showPlaceholder = false;\n this.loading(false);\n return;\n }\n this.comments = resp.data;\n this.pagination = resp.pagination;\n this.total = resp.pagination.total;\n this.nextPage = typeof resp.pagination.links == 'object' && !!resp.pagination.links.next ? resp.pagination.links.next : null;\n\n\n setTimeout(() => {\n this.handleResponse(resp).forEach(card => this.wrapper.append(card));\n this.initiateInfiniteScroll(); // Initiate infinite scroll after the initial data is loaded\n let items = this.wrapper.querySelectorAll('salla-comment-item:not(.animated)');\n this.animateItems(items);\n }, 100);\n } catch (error) {\n console.error('Error loading initial data:', error);\n this.showPlaceholder = true;\n this.loading(false);\n }\n }\n\n // Get next page\n async loadMore() {\n this.infiniteScroll?.loadNextPage();\n }\n\n render() {\n // We should show a different placeholder for pages and products (WIP)\n if (this.showPlaceholder) {\n return (\n <div>\n {!!this.total && !this.hideTitle ? <h2 class=\"s-comments-title\">{this.blockTitle ? this.blockTitle : this.comment_title}</h2> : ''}\n {!this.hideForm && <salla-comment-form show-avatar={this.showFormAvatar} type={this.type} item-id={this.itemId}></salla-comment-form>}\n <div class=\"no-content-placeholder--comments\">\n <i class=\"sicon-chat-bubbles text-5xl block mb-5 text-gray-400\"></i>\n <p class=\"text-sm\">{this.noComments}</p>\n </div>\n </div>\n )\n }\n return (\n <div class={`s-comments s-comments-${this.type}`}>\n <div class={`${this.type == CommentType.PAGE ? \"s-comments-page-container\" : \"s-comments-container\"}`} >\n {!!this.total && !this.hideTitle ? <h2 class=\"s-comments-title\">{this.blockTitle ? this.blockTitle : this.comment_title}</h2> : ''}\n {!this.hideForm && <salla-comment-form type={this.type} item-id={this.itemId}></salla-comment-form>}\n\n {!!this.total && <h2 class=\"s-comments-count-label\" innerHTML={this.pluralize(this.comment_name, this.total)}></h2>}\n <div ref={wrapper => this.wrapper = wrapper}></div>\n\n\n {this.nextPage && (\n <div class=\"s-infinite-scroll-wrapper\" ref={status => this.status = status}>\n <button onClick={() => this.loadMore()} class=\"s-infinite-scroll-btn s-button-btn s-button-primary\">\n <span class=\"s-button-text s-infinite-scroll-btn-text\">{this.loadMoreText ? this.loadMoreText : salla.lang.get('common.elements.load_more')}</span>\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" ref={btnLoader => this.btnLoader = btnLoader} style={{ \"display\": \"none\" }}></span>\n </button>\n </div>\n )}\n </div>\n </div>\n\n );\n }\n\n\n\n async componentWillLoad() {\n await this.loadInitialData(); // Load initial data before rendering the component\n }\n\n}\n"],"version":3}