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

148 lines (145 loc) 4.18 kB
import { icon_button_styles_default } from "./chunk.DZ7YIR5N.js"; import { icon_button_custom_styles_default } from "./chunk.E3Z62YYT.js"; import { SynIcon } from "./chunk.RCBSMXQH.js"; import { enableDefaultSettings } from "./chunk.HYFCK7MM.js"; import { component_styles_default } from "./chunk.NLYVOJGK.js"; import { SynergyElement } from "./chunk.3THJTCRO.js"; import { __decorateClass } from "./chunk.Z4XV3SMG.js"; // src/components/icon-button/icon-button.component.ts import { classMap } from "lit/directives/class-map.js"; import { html, literal } from "lit/static-html.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { property, query, state } from "lit/decorators.js"; var SynIconButton = class extends SynergyElement { constructor() { super(...arguments); this.hasFocus = false; this.label = ""; this.size = "inherit"; this.color = "currentColor"; this.disabled = false; } handleBlur() { this.hasFocus = false; this.emit("syn-blur"); } handleFocus() { this.hasFocus = true; this.emit("syn-focus"); } handleClick(event) { if (this.disabled) { event.preventDefault(); event.stopPropagation(); } } /** Simulates a click on the icon button. */ click() { this.button.click(); } /** Sets focus on the icon button. */ focus(options) { this.button.focus(options); } /** Removes focus from the icon button. */ blur() { this.button.blur(); } render() { const isLink = this.href ? true : false; const tag = isLink ? literal`a` : literal`button`; return html` <${tag} part="base" class=${classMap({ "icon-button": true, "icon-button--disabled": !isLink && this.disabled, "icon-button--focused": this.hasFocus, "icon-button--small": this.size === "small", "icon-button--medium": this.size === "medium", "icon-button--large": this.size === "large" })} ?disabled=${ifDefined(isLink ? void 0 : this.disabled)} type=${ifDefined(isLink ? void 0 : "button")} href=${ifDefined(isLink ? this.href : void 0)} target=${ifDefined(isLink ? this.target : void 0)} download=${ifDefined(isLink ? this.download : void 0)} rel=${ifDefined(isLink && this.target ? "noreferrer noopener" : void 0)} role=${ifDefined(isLink ? void 0 : "button")} aria-disabled=${this.disabled ? "true" : "false"} aria-label="${this.label}" tabindex=${this.disabled ? "-1" : "0"} @blur=${this.handleBlur} @focus=${this.handleFocus} @click=${this.handleClick} > <syn-icon class="icon-button__icon" name=${ifDefined(this.name)} library=${ifDefined(this.library)} src=${ifDefined(this.src)} aria-hidden="true" ></syn-icon> </${tag}> `; } }; SynIconButton.styles = [component_styles_default, icon_button_styles_default, icon_button_custom_styles_default]; SynIconButton.dependencies = { "syn-icon": SynIcon }; __decorateClass([ query(".icon-button") ], SynIconButton.prototype, "button", 2); __decorateClass([ state() ], SynIconButton.prototype, "hasFocus", 2); __decorateClass([ property() ], SynIconButton.prototype, "name", 2); __decorateClass([ property() ], SynIconButton.prototype, "library", 2); __decorateClass([ property() ], SynIconButton.prototype, "src", 2); __decorateClass([ property() ], SynIconButton.prototype, "href", 2); __decorateClass([ property() ], SynIconButton.prototype, "target", 2); __decorateClass([ property() ], SynIconButton.prototype, "download", 2); __decorateClass([ property() ], SynIconButton.prototype, "label", 2); __decorateClass([ property({ reflect: true }) ], SynIconButton.prototype, "size", 2); __decorateClass([ property({ reflect: true }) ], SynIconButton.prototype, "color", 2); __decorateClass([ property({ type: Boolean, reflect: true }) ], SynIconButton.prototype, "disabled", 2); SynIconButton = __decorateClass([ enableDefaultSettings("SynIconButton") ], SynIconButton); export { SynIconButton }; //# sourceMappingURL=chunk.RJPPRJP3.js.map