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:
@@ -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
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user