feat(appui-tabs): add closeable tabs and auto-hide behavior for content tabs, plus API and events to control them

This commit is contained in:
2025-12-29 23:33:38 +00:00
parent 7b39c871f3
commit 5f67bcfb71
9 changed files with 369 additions and 5 deletions

View File

@@ -120,6 +120,12 @@ export class DeesAppuiBase extends DeesElement {
@property({ type: Boolean })
accessor maincontentTabsVisible: boolean = true;
@property({ type: Boolean })
accessor contentTabsAutoHide: boolean = false;
@property({ type: Number })
accessor contentTabsAutoHideThreshold: number = 0;
// Properties for maincontent
@property({ type: Array })
accessor maincontentTabs: interfaces.IMenuItem[] = [];
@@ -250,7 +256,10 @@ export class DeesAppuiBase extends DeesElement {
.tabs=${this.maincontentTabs}
.selectedTab=${this.maincontentSelectedTab}
.showTabs=${this.maincontentTabsVisible}
.tabsAutoHide=${this.contentTabsAutoHide}
.tabsAutoHideThreshold=${this.contentTabsAutoHideThreshold}
@tab-select=${(e: CustomEvent) => this.handleContentTabSelect(e)}
@tab-close=${(e: CustomEvent) => this.handleContentTabClose(e)}
>
<div class="view-container"></div>
<slot name="maincontent"></slot>
@@ -468,6 +477,16 @@ export class DeesAppuiBase extends DeesElement {
this.maincontentTabsVisible = visible;
}
/**
* Set content tabs auto-hide behavior
* @param enabled - Enable auto-hide feature
* @param threshold - Hide when tabs.length <= threshold (default 0 = hide when no tabs)
*/
public setContentTabsAutoHide(enabled: boolean, threshold: number = 0): void {
this.contentTabsAutoHide = enabled;
this.contentTabsAutoHideThreshold = threshold;
}
/**
* Set a badge on a main menu item
*/
@@ -1020,4 +1039,12 @@ export class DeesAppuiBase extends DeesElement {
composed: true
}));
}
private handleContentTabClose(e: CustomEvent) {
this.dispatchEvent(new CustomEvent('content-tab-close', {
detail: e.detail,
bubbles: true,
composed: true
}));
}
}