| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 | 
							- /*!
 
-  * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
 
-  * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
 
-  * v1.0.0-beta.97
 
-  */
 
- import { h, Host } from "@stencil/core";
 
- import { guid } from "../../utils/guid";
 
- import { nodeListToArray } from "../../utils/dom";
 
- /**
 
-  * @slot - A slot for adding content to the component.
 
-  */
 
- export class Tab {
 
-   constructor() {
 
-     /**
 
-      * When `true`, the component's contents are selected.
 
-      *
 
-      * Only one tab can be selected within the `calcite-tabs` parent.
 
-      *
 
-      * @deprecated Use `selected` instead.
 
-      */
 
-     this.active = false;
 
-     /**
 
-      * When `true`, the component's contents are selected.
 
-      *
 
-      * Only one tab can be selected within the `calcite-tabs` parent.
 
-      */
 
-     this.selected = false;
 
-     /**
 
-      * @internal
 
-      */
 
-     this.scale = "m";
 
-     this.guid = `calcite-tab-title-${guid()}`;
 
-   }
 
-   activeHandler(value) {
 
-     this.selected = value;
 
-   }
 
-   selectedHandler(value) {
 
-     this.active = value;
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Lifecycle
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   render() {
 
-     const id = this.el.id || this.guid;
 
-     return (h(Host, { "aria-labelledby": this.labeledBy, id: id }, h("div", { class: "container", role: "tabpanel", tabIndex: this.selected ? 0 : -1 }, h("section", null, h("slot", null)))));
 
-   }
 
-   connectedCallback() {
 
-     this.parentTabsEl = this.el.closest("calcite-tabs");
 
-     const isSelected = this.selected || this.active;
 
-     if (isSelected) {
 
-       this.activeHandler(isSelected);
 
-       this.selectedHandler(isSelected);
 
-     }
 
-   }
 
-   componentDidLoad() {
 
-     this.calciteInternalTabRegister.emit();
 
-   }
 
-   componentWillRender() {
 
-     var _a;
 
-     this.scale = (_a = this.parentTabsEl) === null || _a === void 0 ? void 0 : _a.scale;
 
-   }
 
-   disconnectedCallback() {
 
-     var _a;
 
-     // Dispatching to body in order to be listened by other elements that are still connected to the DOM.
 
-     (_a = document.body) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent("calciteTabUnregister", {
 
-       detail: this.el
 
-     }));
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Event Listeners
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   internalTabChangeHandler(event) {
 
-     const targetTabsEl = event
 
-       .composedPath()
 
-       .find((el) => el.tagName === "CALCITE-TABS");
 
-     // to allow `<calcite-tabs>` to be nested we need to make sure this
 
-     // `calciteTabChange` event was actually fired from a within the same
 
-     // `<calcite-tabs>` that is the a parent of this tab.
 
-     if (targetTabsEl !== this.parentTabsEl) {
 
-       return;
 
-     }
 
-     if (this.tab) {
 
-       this.selected = this.tab === event.detail.tab;
 
-     }
 
-     else {
 
-       this.getTabIndex().then((index) => {
 
-         this.selected = index === event.detail.tab;
 
-       });
 
-     }
 
-     event.stopPropagation();
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Public Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   /**
 
-    * Returns the index of the component item within the tab array.
 
-    */
 
-   async getTabIndex() {
 
-     return Array.prototype.indexOf.call(nodeListToArray(this.el.parentElement.children).filter((el) => el.matches("calcite-tab")), this.el);
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Private Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   /**
 
-    * @param tabIds
 
-    * @param titleIds
 
-    * @internal
 
-    */
 
-   async updateAriaInfo(tabIds = [], titleIds = []) {
 
-     this.labeledBy = titleIds[tabIds.indexOf(this.el.id)] || null;
 
-   }
 
-   static get is() { return "calcite-tab"; }
 
-   static get encapsulation() { return "shadow"; }
 
-   static get originalStyleUrls() {
 
-     return {
 
-       "$": ["tab.scss"]
 
-     };
 
-   }
 
-   static get styleUrls() {
 
-     return {
 
-       "$": ["tab.css"]
 
-     };
 
-   }
 
-   static get properties() {
 
-     return {
 
-       "tab": {
 
-         "type": "string",
 
-         "mutable": false,
 
-         "complexType": {
 
-           "original": "string",
 
-           "resolved": "string",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": true,
 
-         "docs": {
 
-           "tags": [],
 
-           "text": "Specifies a unique name for the component.\n\nWhen specified, use the same value on the `calcite-tab-title`."
 
-         },
 
-         "attribute": "tab",
 
-         "reflect": true
 
-       },
 
-       "active": {
 
-         "type": "boolean",
 
-         "mutable": true,
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "deprecated",
 
-               "text": "Use `selected` instead."
 
-             }],
 
-           "text": "When `true`, the component's contents are selected.\n\nOnly one tab can be selected within the `calcite-tabs` parent."
 
-         },
 
-         "attribute": "active",
 
-         "reflect": true,
 
-         "defaultValue": "false"
 
-       },
 
-       "selected": {
 
-         "type": "boolean",
 
-         "mutable": true,
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [],
 
-           "text": "When `true`, the component's contents are selected.\n\nOnly one tab can be selected within the `calcite-tabs` parent."
 
-         },
 
-         "attribute": "selected",
 
-         "reflect": true,
 
-         "defaultValue": "false"
 
-       },
 
-       "scale": {
 
-         "type": "string",
 
-         "mutable": true,
 
-         "complexType": {
 
-           "original": "Scale",
 
-           "resolved": "\"l\" | \"m\" | \"s\"",
 
-           "references": {
 
-             "Scale": {
 
-               "location": "import",
 
-               "path": "../interfaces"
 
-             }
 
-           }
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "internal",
 
-               "text": undefined
 
-             }],
 
-           "text": ""
 
-         },
 
-         "attribute": "scale",
 
-         "reflect": true,
 
-         "defaultValue": "\"m\""
 
-       }
 
-     };
 
-   }
 
-   static get states() {
 
-     return {
 
-       "labeledBy": {}
 
-     };
 
-   }
 
-   static get events() {
 
-     return [{
 
-         "method": "calciteInternalTabRegister",
 
-         "name": "calciteInternalTabRegister",
 
-         "bubbles": true,
 
-         "cancelable": false,
 
-         "composed": true,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "internal",
 
-               "text": undefined
 
-             }],
 
-           "text": ""
 
-         },
 
-         "complexType": {
 
-           "original": "void",
 
-           "resolved": "void",
 
-           "references": {}
 
-         }
 
-       }];
 
-   }
 
-   static get methods() {
 
-     return {
 
-       "getTabIndex": {
 
-         "complexType": {
 
-           "signature": "() => Promise<number>",
 
-           "parameters": [],
 
-           "references": {
 
-             "Promise": {
 
-               "location": "global"
 
-             }
 
-           },
 
-           "return": "Promise<number>"
 
-         },
 
-         "docs": {
 
-           "text": "Returns the index of the component item within the tab array.",
 
-           "tags": []
 
-         }
 
-       },
 
-       "updateAriaInfo": {
 
-         "complexType": {
 
-           "signature": "(tabIds?: string[], titleIds?: string[]) => Promise<void>",
 
-           "parameters": [{
 
-               "tags": [{
 
-                   "name": "param",
 
-                   "text": "tabIds"
 
-                 }],
 
-               "text": ""
 
-             }, {
 
-               "tags": [{
 
-                   "name": "param",
 
-                   "text": "titleIds"
 
-                 }],
 
-               "text": ""
 
-             }],
 
-           "references": {
 
-             "Promise": {
 
-               "location": "global"
 
-             }
 
-           },
 
-           "return": "Promise<void>"
 
-         },
 
-         "docs": {
 
-           "text": "",
 
-           "tags": [{
 
-               "name": "param",
 
-               "text": "tabIds"
 
-             }, {
 
-               "name": "param",
 
-               "text": "titleIds"
 
-             }, {
 
-               "name": "internal",
 
-               "text": undefined
 
-             }]
 
-         }
 
-       }
 
-     };
 
-   }
 
-   static get elementRef() { return "el"; }
 
-   static get watchers() {
 
-     return [{
 
-         "propName": "active",
 
-         "methodName": "activeHandler"
 
-       }, {
 
-         "propName": "selected",
 
-         "methodName": "selectedHandler"
 
-       }];
 
-   }
 
-   static get listeners() {
 
-     return [{
 
-         "name": "calciteInternalTabChange",
 
-         "method": "internalTabChangeHandler",
 
-         "target": "body",
 
-         "capture": false,
 
-         "passive": false
 
-       }];
 
-   }
 
- }
 
 
  |