@@ -7,7 +7,6 @@ import {Store} from "../../internal/storage";
77import ZincElement from '../../internal/zinc-element' ;
88
99import styles from './tabs.scss' ;
10- import { HasSlotController } from "../../internal/slot" ;
1110
1211/**
1312 * @summary Short summary of the component's intended use.
@@ -29,25 +28,15 @@ import {HasSlotController} from "../../internal/slot";
2928export default class ZnTabs extends ZincElement {
3029 static styles : CSSResultGroup = unsafeCSS ( styles ) ;
3130
32- private readonly hasSlotController = new HasSlotController ( this , '[default]' , 'actions' , 'footer' ) ;
33-
3431 private _panel : HTMLElement | any ;
3532 private _panels : Map < string , Element [ ] > ;
3633 private _tabs : HTMLElement [ ] = [ ] ;
3734 private _actions : HTMLElement [ ] = [ ] ;
3835 private _knownUri : Map < string , string > = new Map < string , string > ( ) ;
39- // @ts -expect-error
40- private storage : Storage ;
4136
4237 @property ( { attribute : 'master-id' , reflect : true } ) masterId : string ;
4338 @property ( { attribute : 'default-uri' , type : String , reflect : true } ) defaultUri = '' ;
4439
45- @property ( ) caption : string ;
46-
47- @property ( ) description : string ;
48-
49- @property ( { attribute : 'header' , type : String , reflect : true } ) header = '' ;
50-
5140 @property ( { attribute : 'active' , type : String , reflect : true } ) _current = '' ;
5241 @property ( { attribute : 'split' , type : Number , reflect : true } ) _split : any ;
5342 @property ( { attribute : 'split-min' , type : Number , reflect : true } ) _splitMin = 60 ;
@@ -58,7 +47,7 @@ export default class ZnTabs extends ZincElement {
5847 @property ( { attribute : 'no-prefetch' , type : Boolean , reflect : true } ) noPrefetch = false ;
5948 // session storage if not local
6049 @property ( { attribute : 'local-storage' , type : Boolean , reflect : true } ) localStorage : boolean ;
61- @property ( { attribute : 'store-key' } ) storeKey : any = null ;
50+ @property ( { attribute : 'store-key' } ) storeKey : string | null = null ;
6251 @property ( { attribute : 'store-ttl' , type : Number , reflect : true } ) storeTtl = 0 ;
6352
6453 @property ( { attribute : 'padded' , type : Boolean , reflect : true } ) padded = false ;
@@ -151,26 +140,22 @@ export default class ZnTabs extends ZincElement {
151140 } , 10 ) ;
152141
153142 this . addEventListener ( 'zn-menu-select' , ( ) => {
154- setTimeout ( ( ) => {
155- this . reRegisterTabs ( )
156- } , 200 ) ;
143+ setTimeout ( this . reRegisterTabs , 200 ) ;
157144 } , { passive : true } ) ;
158145 }
159146
160147 _prepareTab ( tabId : string ) {
161- for ( let i = 0 ; i < this . _tabs . length ; i ++ )
162- for ( let i = 0 ; i < this . _tabs . length ; i ++ ) {
163- if ( this . _tabs [ i ] . getAttribute ( 'tab' ) == tabId ) {
164- return ;
165- }
148+ for ( const tab of this . _tabs ) {
149+ if ( tab . getAttribute ( 'tab' ) === tabId ) {
150+ return ;
166151 }
152+ }
167153
168- const uriTabs = deepQuerySelectorAll ( "[tab-uri]" , this , '' ) ;
169- for ( let i = 0 ; i < uriTabs . length ; i ++ ) {
170- const uri : any = uriTabs [ i ] . getAttribute ( "tab-uri" ) ;
154+ for ( const uriTab of deepQuerySelectorAll ( "[tab-uri]" , this , '' ) ) {
155+ const uri : string = uriTab . getAttribute ( "tab-uri" ) ! ;
171156 const eleTabId = this . _uriToId ( uri ) ;
172157 if ( eleTabId === tabId ) {
173- this . _createUriPanel ( uriTabs [ i ] , uri , eleTabId ) ;
158+ this . _createUriPanel ( uriTab , uri , eleTabId ) ;
174159 // do not break, as multiple tabs can have the same uri
175160 }
176161 }
@@ -352,13 +337,15 @@ export default class ZnTabs extends ZincElement {
352337 if ( this . _panels . has ( tabId ) ) {
353338 this . _panels . delete ( tabId ) ;
354339 }
355- for ( let j = 0 ; j < this . _tabs . length ; j ++ ) {
356- if ( this . _tabs [ j ] . getAttribute ( 'tab' ) == tabId ) {
357- this . _tabs [ j ] . remove ( ) ;
358- this . _tabs . splice ( j , 1 ) ;
340+
341+ for ( const tab of this . _tabs ) {
342+ if ( tab . getAttribute ( 'tab' ) === tabId ) {
343+ tab . remove ( ) ;
344+ this . _tabs . splice ( this . _tabs . indexOf ( tab ) , 1 ) ;
359345 }
360346 }
361- if ( this . _current == tabId ) {
347+
348+ if ( this . _current === tabId ) {
362349 this . setActiveTab ( '' , true , false ) ;
363350 }
364351 }
@@ -367,6 +354,7 @@ export default class ZnTabs extends ZincElement {
367354 deepQuerySelectorAll ( '[tab]' , this , 'zn-tabs' ) . forEach ( ele => {
368355 this . _addTab ( ele as HTMLElement ) ;
369356 } ) ;
357+
370358 deepQuerySelectorAll ( '[tab-uri]' , this , 'zn-tabs' ) . forEach ( ele => {
371359 if ( ele . getAttribute ( 'tab-uri' ) === "" ) {
372360 ele . setAttribute ( 'tab' , "" ) ;
@@ -386,13 +374,8 @@ export default class ZnTabs extends ZincElement {
386374 }
387375
388376 render ( ) {
389- const hasActionSlot = this . hasSlotController . test ( 'actions' ) ;
390- const hasHeader = this . header && this . header . length > 0 ;
391- const hasCaption = this . caption && this . caption . length > 0 ;
392-
393-
394377 if ( this . _split > 0 ) {
395- let storeKey : any = this . storeKey ;
378+ let storeKey : string | null = this . storeKey ;
396379 if ( storeKey ) {
397380 storeKey += "-split" ;
398381 }
@@ -426,15 +409,6 @@ export default class ZnTabs extends ZincElement {
426409 }
427410
428411 return html `
429- ${ hasHeader || hasCaption || hasActionSlot ? html `
430- < div id ="header ">
431- ${ hasHeader ? html `< h1 > ${ this . header } </ h1 > ` : '' }
432- ${ hasCaption ? html `< h2 > ${ this . caption } </ h2 > ` : '' }
433- ${ hasActionSlot ? html `
434- < div id ="actions ">
435- < slot name ="actions "> </ slot >
436- </ div > ` : '' }
437- </ div > ` : null }
438412 < slot name ="top "> </ slot >
439413 < div id ="mid ">
440414 < slot name ="left "> </ slot >
0 commit comments