import { h } from "@stencil/core";
/**
 * Notification 通知提醒组件
 * 悬浮出现在页面角落，用于系统中较复杂的反馈。
 */
export class Notification {
    el;
    /** 唯一标识 */
    id = '';
    /** 通知类型 */
    type = 'info';
    /** 标题 */
    title = '';
    /** 描述文字 */
    message = '';
    /** 显示时间（毫秒），0 为不自动关闭 */
    duration = 4500;
    /** 出现位置 */
    position = 'top-right';
    /** 是否显示关闭按钮 */
    showClose = true;
    /** 是否显示（受控） */
    visible = true;
    /** 关闭事件 */
    hbClose;
    timer = null;
    componentDidLoad() {
        if (this.visible && this.duration > 0) {
            this.timer = setTimeout(() => this.close(), this.duration);
        }
    }
    disconnectedCallback() {
        if (this.timer) {
            clearTimeout(this.timer);
            this.timer = null;
        }
    }
    close = () => {
        if (this.timer) {
            clearTimeout(this.timer);
            this.timer = null;
        }
        this.visible = false;
        this.hbClose.emit(this.id);
    };
    render() {
        return (h("div", { key: '9848b6a924f89df2fa9996742f06986ad8c33da5', class: {
                'hb-notification': true,
                [`hb-notification--${this.type}`]: true,
                [`hb-notification--${this.position}`]: true,
                'hb-notification--visible': this.visible,
            }, role: "alert" }, h("div", { key: 'a15adaf1401116e0dd462fa2a9abf56595052069', class: "hb-notification__icon", "aria-hidden": "true" }, h("span", { key: '7d56d7ce4760963f1bd7c214c5d19c9003e302ee', class: `hb-notification__icon-sign hb-notification__icon-sign--${this.type}` })), h("div", { key: '881c23e049f6870a4f2a4db347fdfaedc331708e', class: "hb-notification__content" }, this.title && h("div", { key: '034c55a3d5b0b4bbb27657db8f2f35bf917caf91', class: "hb-notification__title" }, this.title), this.message && h("div", { key: '0d49cebbf4e1db0baa953691c7519a2a8469563d', class: "hb-notification__message" }, this.message)), this.showClose && (h("button", { key: '180dc1d07aa4993a25ef97e92eb8ab4700e6c120', type: "button", class: "hb-notification__close", onClick: this.close, "aria-label": "\u5173\u95ED" }, "\u00D7"))));
    }
    static get is() { return "hb-notification"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["notification.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["notification.css"]
        };
    }
    static get properties() {
        return {
            "id": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u552F\u4E00\u6807\u8BC6"
                },
                "getter": false,
                "setter": false,
                "attribute": "id",
                "reflect": false,
                "defaultValue": "''"
            },
            "type": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "NotificationType",
                    "resolved": "\"error\" | \"info\" | \"success\" | \"warning\"",
                    "references": {
                        "NotificationType": {
                            "location": "local",
                            "path": "/Users/vscoderwhy/Desktop/product/web-common/huibo-ui/src/components/Notification/Notification.tsx",
                            "id": "src/components/Notification/Notification.tsx::NotificationType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u901A\u77E5\u7C7B\u578B"
                },
                "getter": false,
                "setter": false,
                "attribute": "type",
                "reflect": false,
                "defaultValue": "'info'"
            },
            "title": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u6807\u9898"
                },
                "getter": false,
                "setter": false,
                "attribute": "title",
                "reflect": false,
                "defaultValue": "''"
            },
            "message": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u63CF\u8FF0\u6587\u5B57"
                },
                "getter": false,
                "setter": false,
                "attribute": "message",
                "reflect": false,
                "defaultValue": "''"
            },
            "duration": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u663E\u793A\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C0 \u4E3A\u4E0D\u81EA\u52A8\u5173\u95ED"
                },
                "getter": false,
                "setter": false,
                "attribute": "duration",
                "reflect": false,
                "defaultValue": "4500"
            },
            "position": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "NotificationPosition",
                    "resolved": "\"bottom-left\" | \"bottom-right\" | \"top-left\" | \"top-right\"",
                    "references": {
                        "NotificationPosition": {
                            "location": "local",
                            "path": "/Users/vscoderwhy/Desktop/product/web-common/huibo-ui/src/components/Notification/Notification.tsx",
                            "id": "src/components/Notification/Notification.tsx::NotificationPosition"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u51FA\u73B0\u4F4D\u7F6E"
                },
                "getter": false,
                "setter": false,
                "attribute": "position",
                "reflect": false,
                "defaultValue": "'top-right'"
            },
            "showClose": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u662F\u5426\u663E\u793A\u5173\u95ED\u6309\u94AE"
                },
                "getter": false,
                "setter": false,
                "attribute": "show-close",
                "reflect": false,
                "defaultValue": "true"
            },
            "visible": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u662F\u5426\u663E\u793A\uFF08\u53D7\u63A7\uFF09"
                },
                "getter": false,
                "setter": false,
                "attribute": "visible",
                "reflect": false,
                "defaultValue": "true"
            }
        };
    }
    static get events() {
        return [{
                "method": "hbClose",
                "name": "hbClose",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "\u5173\u95ED\u4E8B\u4EF6"
                },
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=Notification.js.map
