UNPKG

@synergy-design-system/components

Version:

This package provides the base of the Synergy Design System as native web components. It uses [lit](https://www.lit.dev) and parts of [shoelace](https://shoelace.style/). Synergy officially supports the latest two versions of all major browsers (as define

124 lines (118 loc) 3.81 kB
import { breadcrumb_item_custom_styles_default } from "./chunk.77CVXMWD.js"; import { breadcrumb_item_styles_default } from "./chunk.O6ZH6AOI.js"; import { HasSlotController } from "./chunk.WVVQK5TE.js"; import { watch } from "./chunk.BVZQ6QSY.js"; import { component_styles_default } from "./chunk.NLYVOJGK.js"; import { SynergyElement } from "./chunk.3THJTCRO.js"; import { __decorateClass } from "./chunk.Z4XV3SMG.js"; // src/components/breadcrumb-item/breadcrumb-item.component.ts import { classMap } from "lit/directives/class-map.js"; import { html } from "lit"; import { ifDefined } from "lit/directives/if-defined.js"; import { property, query, state } from "lit/decorators.js"; var SynBreadcrumbItem = class extends SynergyElement { constructor() { super(...arguments); this.hasSlotController = new HasSlotController(this, "prefix", "suffix"); this.renderType = "button"; this.rel = "noreferrer noopener"; } setRenderType() { const hasDropdown = this.defaultSlot.assignedElements({ flatten: true }).filter((i) => i.tagName.toLowerCase() === "syn-dropdown").length > 0; if (this.href) { this.renderType = "link"; return; } if (hasDropdown) { this.renderType = "dropdown"; return; } this.renderType = "button"; } hrefChanged() { this.setRenderType(); } handleSlotChange() { this.setRenderType(); } render() { return html` <div part="base" class=${classMap({ "breadcrumb-item": true, "breadcrumb-item--has-prefix": this.hasSlotController.test("prefix"), "breadcrumb-item--has-suffix": this.hasSlotController.test("suffix") })} > <span part="prefix" class="breadcrumb-item__prefix"> <slot name="prefix"></slot> </span> ${this.renderType === "link" ? html` <a part="label" class="breadcrumb-item__label breadcrumb-item__label--link" href="${this.href}" target="${ifDefined(this.target ? this.target : void 0)}" rel=${ifDefined(this.target ? this.rel : void 0)} > <slot @slotchange=${this.handleSlotChange}></slot> </a> ` : ""} ${this.renderType === "button" ? html` <button part="label" type="button" class="breadcrumb-item__label breadcrumb-item__label--button"> <slot @slotchange=${this.handleSlotChange}></slot> </button> ` : ""} ${this.renderType === "dropdown" ? html` <div part="label" class="breadcrumb-item__label breadcrumb-item__label--drop-down"> <slot @slotchange=${this.handleSlotChange}></slot> </div> ` : ""} <span part="suffix" class="breadcrumb-item__suffix"> <slot name="suffix"></slot> </span> <span part="separator" class="breadcrumb-item__separator" aria-hidden="true"> <slot name="separator"></slot> </span> </div> `; } }; SynBreadcrumbItem.styles = [component_styles_default, breadcrumb_item_styles_default, breadcrumb_item_custom_styles_default]; __decorateClass([ query("slot:not([name])") ], SynBreadcrumbItem.prototype, "defaultSlot", 2); __decorateClass([ state() ], SynBreadcrumbItem.prototype, "renderType", 2); __decorateClass([ property() ], SynBreadcrumbItem.prototype, "href", 2); __decorateClass([ property() ], SynBreadcrumbItem.prototype, "target", 2); __decorateClass([ property() ], SynBreadcrumbItem.prototype, "rel", 2); __decorateClass([ watch("href", { waitUntilFirstUpdate: true }) ], SynBreadcrumbItem.prototype, "hrefChanged", 1); export { SynBreadcrumbItem }; //# sourceMappingURL=chunk.IIHU63KV.js.map