@@ -44,6 +44,10 @@ export class DocksTabs extends DocksContainer {
4444 @property ( { type : Boolean , reflect : true , attribute : 'hide-tabs' } )
4545 hideTabs : boolean = false ;
4646
47+ /** Tab and nav-toolbar control sizing (`small` | `medium` | `large`). */
48+ @property ( { reflect : true , attribute : 'item-size' } )
49+ itemSize : 'small' | 'medium' | 'large' = 'medium' ;
50+
4751 /** Tab contributions for this container */
4852 @state ( )
4953 private contributions : TabContribution [ ] = [ ] ;
@@ -158,6 +162,14 @@ export class DocksTabs extends DocksContainer {
158162 await this . tryCloseTab ( tabName , true ) ;
159163 }
160164
165+ updateTabLabel ( tabName : string , label : string ) : void {
166+ const contribution = this . contributions . find ( ( c ) => c . name === tabName ) ;
167+ if ( ! contribution ) return ;
168+ contribution . label = label ;
169+ this . contributions = [ ...this . contributions ] ;
170+ this . requestUpdate ( ) ;
171+ }
172+
161173 /**
162174 * Closes every tab in this group. Returns false if the user cancels a dirty-tab prompt.
163175 */
@@ -186,6 +198,11 @@ export class DocksTabs extends DocksContainer {
186198 const contribution = this . contributions . find ( c => c . name === tabName ) ;
187199 if ( ! contribution ) return true ;
188200
201+ if ( contribution . beforeClose ) {
202+ const ok = await contribution . beforeClose ( ) ;
203+ if ( ! ok ) return false ;
204+ }
205+
189206 this . cleanupTabInstance ( tabPanel ) ;
190207 this . clearActiveSignalsIfPartInPanel ( tabPanel ) ;
191208
@@ -367,6 +384,20 @@ export class DocksTabs extends DocksContainer {
367384 return this . placement === "start" || this . placement === "end" ? "vertical" : "horizontal" ;
368385 }
369386
387+ private renderNavToolbar ( navToolbarId : string ) {
388+ if ( ! this . withToolbar || ! navToolbarId ) return nothing ;
389+ return html `
390+ <div class= "nav-toolbar-spacer" slot = "nav" aria-hidden = "true" > </ div>
391+ <docks- to olbar
392+ slot= "nav"
393+ id = ${ navToolbarId }
394+ or ientation= ${ this . withToolbarOrientation ( ) }
395+ align= "center"
396+ size = ${ this . itemSize }
397+ > </ docks- to olbar>
398+ ` ;
399+ }
400+
370401 private renderEmptyState ( ) {
371402 const currentApp = appLoaderService . getCurrentApp ( ) ;
372403 return html `
@@ -389,10 +420,22 @@ export class DocksTabs extends DocksContainer {
389420 }
390421
391422 render ( ) {
392- if ( this . contributions . length === 0 ) {
423+ const containerId = this . containerId ?? this . getAttribute ( 'id' ) ;
424+ const navToolbarId = containerId ? `${ containerId } -toolbar` : '' ;
425+ const hasToolbar = this . withToolbar && ! ! navToolbarId ;
426+
427+ if ( this . contributions . length === 0 && ! hasToolbar ) {
393428 return this . renderEmptyState ( ) ;
394429 }
395- const navToolbarId = this . containerId ? `${ this . containerId } -toolbar` : '' ;
430+
431+ if ( this . contributions . length === 0 ) {
432+ return html `
433+ <wa- tab- group ${ ref ( this . tabGroup ) } placement= ${ this . placement } >
434+ ${ this . renderNavToolbar ( navToolbarId ) }
435+ </ wa- tab- group>
436+ ` ;
437+ }
438+
396439 return html `
397440 <wa- tab- group ${ ref ( this . tabGroup ) } placement= ${ this . placement } >
398441 ${ repeat (
@@ -417,18 +460,7 @@ export class DocksTabs extends DocksContainer {
417460 ` ;
418461 }
419462 ) }
420- ${ this . withToolbar && navToolbarId
421- ? html `
422- <div class= "nav-toolbar-spacer" slot = "nav" aria- hidden= "true"> </ div>
423- <docks- to olbar
424- slot= "nav"
425- id = ${ navToolbarId }
426- or ientation= ${ this . withToolbarOrientation ( ) }
427- align= "center"
428- size= "large"
429- > </ docks- to olbar>
430- `
431- : nothing }
463+ ${ this . renderNavToolbar ( navToolbarId ) }
432464 </ wa- tab- group>
433465 ` ;
434466 }
@@ -513,6 +545,17 @@ export class DocksTabs extends DocksContainer {
513545
514546 wa-tab ::part (base ) {
515547 padding : 3px 0.5rem ;
548+ font-size : var (--wa-font-size-s );
549+ }
550+
551+ : host ([item-size = "small" ]) wa-tab ::part (base ) {
552+ padding : 2px 0.375rem ;
553+ font-size : var (--wa-font-size-xs );
554+ }
555+
556+ : host ([item-size = "large" ]) wa-tab ::part (base ) {
557+ padding : var (--wa-space-s ) 0.75rem ;
558+ font-size : var (--wa-font-size-m );
516559 }
517560
518561 : host ([icon-only ]) wa-tab ::part (base ) {
@@ -523,15 +566,39 @@ export class DocksTabs extends DocksContainer {
523566 padding : var (--wa-space-s );
524567 }
525568
569+ : host ([icon-only ][item-size = "small" ]: is ([placement = "top" ], [placement = "bottom" ])) wa-tab ::part (base ) {
570+ padding : var (--wa-space-xs );
571+ }
572+
573+ : host ([icon-only ][item-size = "large" ]: is ([placement = "top" ], [placement = "bottom" ])) wa-tab ::part (base ) {
574+ padding : var (--wa-space-m );
575+ }
576+
526577 : host ([icon-only ]: is ([placement = "start" ], [placement = "end" ])) wa-tab ::part (base ) {
527578 padding-inline : 0 ;
528579 padding-block : var (--wa-space-s );
529580 }
530581
582+ : host ([icon-only ][item-size = "small" ]: is ([placement = "start" ], [placement = "end" ])) wa-tab ::part (base ) {
583+ padding-block : var (--wa-space-xs );
584+ }
585+
586+ : host ([icon-only ][item-size = "large" ]: is ([placement = "start" ], [placement = "end" ])) wa-tab ::part (base ) {
587+ padding-block : var (--wa-space-m );
588+ }
589+
531590 : host ([icon-only ]) wa-tab wa-icon {
532591 font-size : var (--wa-font-size-l );
533592 }
534593
594+ : host ([icon-only ][item-size = "small" ]) wa-tab wa-icon {
595+ font-size : var (--wa-font-size-m );
596+ }
597+
598+ : host ([icon-only ][item-size = "large" ]) wa-tab wa-icon {
599+ font-size : var (--wa-font-size-xl );
600+ }
601+
535602 : host ([icon-only ]: is ([placement = "start" ], [placement = "end" ])) wa-tab-group ::part (nav ),
536603 : host ([icon-only ]: is ([placement = "start" ], [placement = "end" ])) wa-tab-group ::part (tabs ) {
537604 padding : 0 ;
0 commit comments