import { h } from "@stencil/core";
/**
 * Anchor 锚点组件
 * 用于跳转到页面内指定锚点位置的超链接列表
 */
export class Anchor {
    /** 锚点项数组 */
    items = [];
    /** 距离窗口顶部偏移（固定时使用） */
    top;
    /** 是否启用固钉模式（affix 包裹） */
    affix = true;
    /** 当前选中项的 key */
    activeKey = '';
    /** 点击锚点项事件 */
    hbClick;
    handleClick = (item, e) => {
        e.preventDefault();
        this.activeKey = item.key;
        this.hbClick.emit({ key: item.key, href: item.href });
    };
    render() {
        const wrapperStyle = {};
        if (this.affix && this.top !== undefined) {
            wrapperStyle.position = 'sticky';
            wrapperStyle.top = `${this.top}px`;
        }
        return (h("div", { key: 'dc32d578ca843183041cfa36765c16972d96eb0a', class: "hb-anchor", style: wrapperStyle }, h("div", { key: '9d70c1be7984c61815bb596328aa78486f077b37', class: "hb-anchor__ink", "aria-hidden": "true" }), h("ul", { key: '208c2b0f328c8815e360347a06531146fdf34359', class: "hb-anchor__list" }, this.items.map((item) => (h("li", { class: "hb-anchor__item" }, h("a", { class: {
                'hb-anchor__link': true,
                'hb-anchor__link--active': this.activeKey === item.key,
            }, href: item.href, "data-key": item.key, onClick: (e) => this.handleClick(item, e) }, item.title)))))));
    }
    static get is() { return "hb-anchor"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["anchor.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["anchor.css"]
        };
    }
    static get properties() {
        return {
            "items": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "AnchorItem[]",
                    "resolved": "AnchorItem[]",
                    "references": {
                        "AnchorItem": {
                            "location": "local",
                            "path": "/Users/vscoderwhy/Desktop/product/web-common/huibo-ui/src/components/Anchor/Anchor.tsx",
                            "id": "src/components/Anchor/Anchor.tsx::AnchorItem"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u951A\u70B9\u9879\u6570\u7EC4"
                },
                "getter": false,
                "setter": false,
                "defaultValue": "[]"
            },
            "top": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number | undefined",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u8DDD\u79BB\u7A97\u53E3\u9876\u90E8\u504F\u79FB\uFF08\u56FA\u5B9A\u65F6\u4F7F\u7528\uFF09"
                },
                "getter": false,
                "setter": false,
                "attribute": "top",
                "reflect": false
            },
            "affix": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u662F\u5426\u542F\u7528\u56FA\u9489\u6A21\u5F0F\uFF08affix \u5305\u88F9\uFF09"
                },
                "getter": false,
                "setter": false,
                "attribute": "affix",
                "reflect": false,
                "defaultValue": "true"
            }
        };
    }
    static get states() {
        return {
            "activeKey": {}
        };
    }
    static get events() {
        return [{
                "method": "hbClick",
                "name": "hbClick",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "\u70B9\u51FB\u951A\u70B9\u9879\u4E8B\u4EF6"
                },
                "complexType": {
                    "original": "AnchorClickDetail",
                    "resolved": "AnchorClickDetail",
                    "references": {
                        "AnchorClickDetail": {
                            "location": "local",
                            "path": "/Users/vscoderwhy/Desktop/product/web-common/huibo-ui/src/components/Anchor/Anchor.tsx",
                            "id": "src/components/Anchor/Anchor.tsx::AnchorClickDetail"
                        }
                    }
                }
            }];
    }
}
//# sourceMappingURL=Anchor.js.map
