FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
collection
/
components
/
ui
/
tab
Edit File: sc-tab.js
import{h}from"@stencil/core";import{isRtl}from"../../../functions/page-align";let id=0;export class ScTab{constructor(){this.componentId="tab-"+ ++id,this.panel="",this.href=void 0,this.active=!1,this.disabled=!1,this.count=void 0,this.hasPrefix=!1,this.hasSuffix=!1}async triggerFocus(e){this.tab.focus(e)}async triggerBlur(){this.tab.blur()}handleSlotChange(){this.hasPrefix=!!this.el.querySelector('[slot="prefix"]'),this.hasSuffix=!!this.el.querySelector('[slot="suffix"]')}render(){this.el.id=this.el.id||this.componentId;const e=this.href?"a":"div";return h(e,{key:"4745e4bb5033eca682ef701ac4af8dbdd45faadc",part:"base "+(this.active?"active":""),href:this.href,class:{tab:!0,"tab--active":this.active,"tab--disabled":this.disabled,"tab--has-prefix":this.hasPrefix,"tab--has-suffix":this.hasSuffix,"tab--is-rtl":isRtl()},ref:e=>this.tab=e,role:"tab","aria-disabled":this.disabled?"true":"false","aria-selected":this.active?"true":"false",tabindex:this.disabled?"-1":"0"},h("span",{key:"067c3683e10ac2a3e7e14cbc18f711c841c1064c",part:"prefix",class:"tab__prefix"},h("slot",{key:"2df3aa3e7976d92c8cf2143d4027cde76ea1354a",onSlotchange:()=>this.handleSlotChange(),name:"prefix"})),h("div",{key:"dbc3e0d39a52dabc870628e5c47709bf3e076814",class:"tab__content",part:"content"},h("slot",{key:"d88ae7a27547a35df3e3da3cb4d0ad514f3d88c2"})),h("span",{key:"a44f59707b81b018279d7451835636e2d3938aaa",part:"suffix",class:"tab__suffix"},h("slot",{key:"a09cbe90a13403c6c4c366988bc1672f9a42d23f",onSlotchange:()=>this.handleSlotChange(),name:"suffix"})),h("slot",{key:"6ab17577589590037f96685248a9412298a598d0",name:"suffix"},!!this.count&&h("div",{key:"ff70db95fefdc6fcf2bbf4becbfba24c5726c571",class:"tab__counter",part:"counter"},this.count)))}static get is(){return"sc-tab"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["sc-tab.scss"]}}static get styleUrls(){return{$:["sc-tab.css"]}}static get properties(){return{panel:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The name of the tab panel the tab will control. The panel must be located in the same tab group."},attribute:"panel",reflect:!0,defaultValue:"''"},href:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:""},attribute:"href",reflect:!0},active:{type:"boolean",mutable:!1,complexType:{original:"boolean",resolved:"boolean",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Draws the tab in an active state."},attribute:"active",reflect:!0,defaultValue:"false"},disabled:{type:"boolean",mutable:!1,complexType:{original:"boolean",resolved:"boolean",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Draws the tab in a disabled state."},attribute:"disabled",reflect:!0,defaultValue:"false"},count:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:""},attribute:"count",reflect:!1}}}static get states(){return{hasPrefix:{},hasSuffix:{}}}static get events(){return[{method:"scClose",name:"scClose",bubbles:!0,cancelable:!0,composed:!0,docs:{tags:[],text:"Close event"},complexType:{original:"void",resolved:"void",references:{}}}]}static get methods(){return{triggerFocus:{complexType:{signature:"(options?: FocusOptions) => Promise<void>",parameters:[{name:"options",type:"FocusOptions",docs:""}],references:{Promise:{location:"global",id:"global::Promise"},FocusOptions:{location:"global",id:"global::FocusOptions"}},return:"Promise<void>"},docs:{text:"Sets focus to the tab.",tags:[]}},triggerBlur:{complexType:{signature:"() => Promise<void>",parameters:[],references:{Promise:{location:"global",id:"global::Promise"}},return:"Promise<void>"},docs:{text:"Removes focus from the tab.",tags:[]}}}}static get elementRef(){return"el"}}
Save
Back