UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

5 lines (4 loc) 2.71 kB
/*! All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://github.com/Esri/calcite-design-system/blob/dev/LICENSE.md for details. v3.2.1 */ import{c as h}from"./3ADX47DD.js";import{a as d}from"./NNVH7JUI.js";import{E as o,F as a,I as i,R as r,c,d as l}from"./BJZTU5BQ.js";var b={container:"container",content:"content"},p=c`:host{display:none}:host,.container,.content{block-size:100%;inline-size:100%}:host([selected]),:host([selected]) .container{display:flex;flex-direction:column}.content{box-sizing:border-box;padding-block:var(--calcite-tab-content-space-y, var(--calcite-tab-content-block-padding, var(--calcite-internal-tab-content-space-y)))}.scale-s{--calcite-internal-tab-content-space-y: .25rem;font-size:var(--calcite-font-size-sm);line-height:1rem}.scale-m{--calcite-internal-tab-content-space-y: .5rem;font-size:var(--calcite-font-size);line-height:1rem}.scale-l{--calcite-internal-tab-content-space-y: .625rem;font-size:var(--calcite-font-size-md);line-height:1.25rem}.container{display:none;block-size:100%;inline-size:100%;overflow:auto;outline-color:transparent}.container:focus{outline:2px solid var(--calcite-color-focus, var(--calcite-ui-focus-color, var(--calcite-color-brand)));outline-offset:calc(-2px*(1 - (2*clamp(0,var(--calcite-offset-invert-focus),1))))}:host([hidden]){display:none}[hidden]{display:none}`,n=class extends o{constructor(){super(),this.guid=`calcite-tab-title-${d()}`,this.scale="m",this.selected=!1,this.listenOn(document.body,"calciteInternalTabChange",this.internalTabChangeHandler)}static{this.properties={labeledBy:[16,{},{state:!0}],scale:1,selected:[7,{},{reflect:!0,type:Boolean}],tab:[3,{},{reflect:!0}]}}static{this.styles=p}async getTabIndex(){return Array.prototype.indexOf.call(h(this.el.parentElement.children).filter(e=>e.matches("calcite-tab")),this.el)}_updateAriaInfo(e=[],s=[]){this.labeledBy=s[e.indexOf(this.el.id)]||null}connectedCallback(){super.connectedCallback(),this.parentTabsEl=this.el.closest("calcite-tabs")}disconnectedCallback(){super.disconnectedCallback(),document.body?.dispatchEvent(new CustomEvent("calciteTabUnregister",{detail:this.el}))}internalTabChangeHandler(e){e.composedPath().find(t=>t.tagName==="CALCITE-TABS")===this.parentTabsEl&&(this.tab?this.selected=this.tab===e.detail.tab:this.getTabIndex().then(t=>{this.selected=t===e.detail.tab}),e.stopPropagation())}render(){let e=this.el.id||this.guid;return i(this.el,"aria-labelledby",this.labeledBy),i(this.el,"id",e),l`<div class=${a({[b.container]:!0,[`scale-${this.scale}`]:!0})} role=tabpanel .tabIndex=${this.selected?0:-1}><section class=${a(b.content)}><slot></slot></section></div>`}};r("calcite-tab",n);export{n as Tab};