/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */
import { Host, h } from "@stencil/core";
import { getIonTheme } from "../../global/ionic-global";
/**
 * @virtualProp {"ios" | "md"} mode - The mode determines the platform behaviors of the component.
 * @virtualProp {"ios" | "md" | "ionic"} theme - The theme determines the visual appearance of the component.
 */
export class List {
    constructor() {
        /**
         * If `true`, the list will have margin around it and rounded corners.
         */
        this.inset = false;
    }
    /**
     * If `ion-item-sliding` are used inside the list, this method closes
     * any open sliding item.
     *
     * Returns `true` if an actual `ion-item-sliding` is closed.
     */
    async closeSlidingItems() {
        const item = this.el.querySelector('ion-item-sliding');
        if (item === null || item === void 0 ? void 0 : item.closeOpened) {
            return item.closeOpened();
        }
        return false;
    }
    getShape() {
        const theme = getIonTheme(this);
        const { shape, inset } = this;
        // TODO(ROU-10831): Remove theme check when shapes are defined for all themes.
        if (theme !== 'ionic') {
            return undefined;
        }
        if (shape === undefined && inset) {
            return 'round';
        }
        if (shape === undefined) {
            return 'rectangular';
        }
        return shape;
    }
    render() {
        const theme = getIonTheme(this);
        const shape = this.getShape();
        const { lines, inset } = this;
        return (h(Host, { key: '7deda9d813391cac1c4156fb9e9fd1f1a43cdea8', role: "list", class: {
                [theme]: true,
                // Used internally for styling
                [`list-${theme}`]: true,
                'list-inset': inset,
                [`list-lines-${lines}`]: lines !== undefined,
                [`list-${theme}-lines-${lines}`]: lines !== undefined,
                [`list-${shape}`]: shape !== undefined,
            } }));
    }
    static get is() { return "ion-list"; }
    static get originalStyleUrls() {
        return {
            "ios": ["list.ios.scss"],
            "md": ["list.md.scss"],
            "ionic": ["list.ionic.scss"]
        };
    }
    static get styleUrls() {
        return {
            "ios": ["list.ios.css"],
            "md": ["list.md.css"],
            "ionic": ["list.ionic.css"]
        };
    }
    static get properties() {
        return {
            "lines": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'full' | 'inset' | 'none'",
                    "resolved": "\"full\" | \"inset\" | \"none\" | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "How the bottom border should be displayed on all items."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "lines"
            },
            "inset": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "If `true`, the list will have margin around it and rounded corners."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "inset",
                "defaultValue": "false"
            },
            "shape": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'soft' | 'round' | 'rectangular'",
                    "resolved": "\"rectangular\" | \"round\" | \"soft\" | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Set to `\"soft\"` for slightly rounded corners,\n`\"round\"` for fully rounded corners,\nor `\"rectangular\"` for no rounded corners.\n\nDefaults to `\"round\"` for the `ionic` theme\nwhen inset is `true`\ndefaults to `\"rectangular\"` for the `ionic`\ntheme when inset is `false`,\nundefined for all other themes."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "shape"
            }
        };
    }
    static get methods() {
        return {
            "closeSlidingItems": {
                "complexType": {
                    "signature": "() => Promise<boolean>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<boolean>"
                },
                "docs": {
                    "text": "If `ion-item-sliding` are used inside the list, this method closes\nany open sliding item.\n\nReturns `true` if an actual `ion-item-sliding` is closed.",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "el"; }
}
