import { h } from "@stencil/core";
import { TagSize } from "./tag-size.enum";
import { _t } from "../../../text";
/**
 * @swedishName Tagg
 */
export class Tag {
    constructor() {
        this.afText = undefined;
        this.afNoIcon = false;
        this.afAriaLabel = undefined;
        this.afSize = TagSize.SMALL;
        this.afBreakWords = false;
    }
    clickHandler(e) {
        e.stopPropagation();
        this.afOnClick.emit(e);
    }
    get ariaLabel() {
        const showIcon = !this.afNoIcon;
        if (this.afAriaLabel) {
            return this.afAriaLabel;
        }
        else if (showIcon) {
            return _t.removeItem(this.afText);
        }
        return this.afText;
    }
    render() {
        return (h("digi-button", { key: '55cce70f4de26f0a2b8650cb8ffb683b62d39157', onAfOnClick: (e) => this.clickHandler(e), "af-variation": "secondary", "af-size": this.afSize, class: "digi-tag", "af-aria-label": this.ariaLabel }, this.afText, !this.afNoIcon && h("digi-icon-x", { key: '8c4b1ff744288216ea42bd6c66826ea6fdcc7dce', slot: "icon-secondary" })));
    }
    static get is() { return "digi-tag"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "$": ["tag.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["tag.css"]
        };
    }
    static get properties() {
        return {
            "afText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set the tag text."
                        }],
                    "text": "S\u00E4tter taggens text."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-text",
                "reflect": false
            },
            "afNoIcon": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Removes the tag icon. Defaults to false."
                        }],
                    "text": "Tar bort taggens ikon. Falskt som f\u00F6rvalt."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-no-icon",
                "reflect": false,
                "defaultValue": "false"
            },
            "afAriaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set button `aria-label` attribute."
                        }],
                    "text": "S\u00E4tt attributet 'aria-label'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-aria-label",
                "reflect": false
            },
            "afSize": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "TagSize",
                    "resolved": "TagSize.MEDIUM | TagSize.SMALL",
                    "references": {
                        "TagSize": {
                            "location": "import",
                            "path": "./tag-size.enum",
                            "id": "src/components/_tag/tag/tag-size.enum.ts::TagSize"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Sets tag size."
                        }],
                    "text": "S\u00E4tter taggens storlek."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-size",
                "reflect": false,
                "defaultValue": "TagSize.SMALL"
            },
            "afBreakWords": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Allow breaking long words on overflow."
                        }],
                    "text": "Bryt l\u00E5nga ord vid overflow."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-break-words",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get events() {
        return [{
                "method": "afOnClick",
                "name": "afOnClick",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "The tag elements 'onclick' event."
                        }],
                    "text": "Taggelementets 'onclick'-event."
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }];
    }
}
