@salla.sa/twilight-components 2.13.45 → 2.13.47
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.
- package/dist/cjs/{app-globals-c753e682.js → app-globals-0efa4587.js} +3 -3
- package/dist/cjs/app-globals-0efa4587.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-add-product-button_47.cjs.entry.js +21 -4
- package/dist/cjs/salla-add-product-button_47.cjs.entry.js.map +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/collection/components/salla-breadcrumb/salla-breadcrumb.js +21 -25
- package/dist/collection/components/salla-breadcrumb/salla-breadcrumb.js.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/salla-breadcrumb.js +21 -5
- package/dist/components/salla-breadcrumb.js.map +1 -1
- package/dist/components/salla-quick-buy2.js.map +1 -1
- package/dist/esm/{app-globals-9cbaf3a0.js → app-globals-32c0b133.js} +3 -3
- package/dist/esm/app-globals-32c0b133.js.map +1 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/salla-add-product-button_47.entry.js +21 -4
- package/dist/esm/salla-add-product-button_47.entry.js.map +1 -1
- package/dist/esm/twilight.js +2 -2
- package/dist/esm-es5/app-globals-32c0b133.js +25 -0
- package/dist/esm-es5/app-globals-32c0b133.js.map +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/esm-es5/salla-add-product-button_47.entry.js +1 -1
- package/dist/esm-es5/salla-add-product-button_47.entry.js.map +1 -1
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/esm-es5/twilight.js.map +1 -1
- package/dist/twilight/p-44a3fce3.system.js +25 -0
- package/dist/twilight/p-44a3fce3.system.js.map +1 -0
- package/dist/twilight/{p-08934db3.entry.js → p-66f25bdd.entry.js} +2 -2
- package/dist/twilight/p-66f25bdd.entry.js.map +1 -0
- package/dist/twilight/p-93a162ca.js +25 -0
- package/dist/twilight/p-93a162ca.js.map +1 -0
- package/dist/twilight/{p-1126a332.system.entry.js → p-af130e8a.system.entry.js} +2 -2
- package/dist/twilight/p-af130e8a.system.entry.js.map +1 -0
- package/dist/twilight/{p-c47f4a7d.system.js → p-b9c7fc02.system.js} +2 -2
- package/dist/twilight/{p-c47f4a7d.system.js.map → p-b9c7fc02.system.js.map} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/twilight/twilight.esm.js.map +1 -1
- package/dist/twilight/twilight.js +1 -1
- package/dist/types/components/salla-breadcrumb/salla-breadcrumb.d.ts +0 -4
- package/dist/types/components.d.ts +0 -8
- package/package.json +5 -5
- package/dist/cjs/app-globals-c753e682.js.map +0 -1
- package/dist/esm/app-globals-9cbaf3a0.js.map +0 -1
- package/dist/esm-es5/app-globals-9cbaf3a0.js +0 -25
- package/dist/esm-es5/app-globals-9cbaf3a0.js.map +0 -1
- package/dist/twilight/p-08934db3.entry.js.map +0 -1
- package/dist/twilight/p-1126a332.system.entry.js.map +0 -1
- package/dist/twilight/p-4711d392.js +0 -25
- package/dist/twilight/p-4711d392.js.map +0 -1
- package/dist/twilight/p-59672ac1.system.js +0 -25
- package/dist/twilight/p-59672ac1.system.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) ||
|
|
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!'
|
|
78
|
+
salla.log('salla-breadcrumb:: There is no breadcrumbs!');
|
|
66
79
|
return;
|
|
67
80
|
}
|
|
68
|
-
return (h("ol", { class:
|
|
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; }
|
|
100
117
|
}, [0, "salla-breadcrumb", {
|
|
101
|
-
"items": [1],
|
|
102
118
|
"breadcrumbs": [32]
|
|
103
119
|
}]);
|
|
104
120
|
function defineCustomElement$1() {
|
|
@@ -1 +1 @@
|
|
|
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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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,CAA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AG,CAAC,cAAc,EAAE,IAAI,CAAC,GAAG,qBAAqB,GAAG,sBAAsB,CAAC,CAAC;IAEzH,OAAO,UAAI,KAAK,EAAC,oBAAoB,IACnC,WAAK,KAAK,EAAE,EAAE,wBAAwB,EAAE,IAAI,EAAE,2BAA2B,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, 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}
|