import { MDCSnackbar } from '@material/snackbar';
import { h } from '@stencil/core';
export class Snackbar {
    constructor() {
        this.timeout = 4000;
    }
    componentDidLoad() {
        this.mdcSnackbar = new MDCSnackbar(this.snackbarEl);
        this.mdcSnackbar.labelText = this.label;
        this.mdcSnackbar.timeoutMs = this.timeout;
        this.mdcSnackbar.open();
        this.mdcSnackbar.listen('MDCSnackbar:closed', (ev) => this.handleClose(ev));
    }
    handleClose(event) {
        this.close.emit(null);
        if (this.actionHandler && 'action' === event.detail.reason) {
            this.actionHandler();
        }
    }
    getClasses() {
        return {
            'mdc-snackbar': true,
            'mdc-snackbar--stacked': this.stacked,
            'mdc-snackbar--leading': this.leading
        };
    }
    render() {
        return (h("div", { class: this.getClasses(), ref: snackbar => this.snackbarEl = snackbar },
            h("div", { class: "mdc-snackbar__surface" },
                h("div", { class: "mdc-snackbar__label", role: "status", "aria-live": "polite" }),
                h("div", { class: "mdc-snackbar__actions" },
                    this.actionText && h("button", { type: "button", class: "mdc-button mdc-snackbar__action" }, this.actionText),
                    this.dismissButton && h("button", { type: "button", class: "mdc-icon-button mdc-snackbar__dismiss material-icons", title: "Fermer" }, "close")))));
    }
    static get is() { return "materials-snackbar"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() { return {
        "$": ["snackbar.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["snackbar.css"]
    }; }
    static get properties() { return {
        "label": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label",
            "reflect": false
        },
        "stacked": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "stacked",
            "reflect": false
        },
        "leading": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "leading",
            "reflect": false
        },
        "dismissButton": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "dismiss-button",
            "reflect": false
        },
        "actionText": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "action-text",
            "reflect": false
        },
        "timeout": {
            "type": "number",
            "mutable": false,
            "complexType": {
                "original": "number",
                "resolved": "number",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "timeout",
            "reflect": false,
            "defaultValue": "4000"
        },
        "actionHandler": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "Function",
                "resolved": "Function",
                "references": {
                    "Function": {
                        "location": "global"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        }
    }; }
    static get events() { return [{
            "method": "close",
            "name": "close",
            "bubbles": true,
            "cancelable": true,
            "composed": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "complexType": {
                "original": "any",
                "resolved": "any",
                "references": {}
            }
        }]; }
}
