diff --git a/packages/main/src/Tab.hbs b/packages/main/src/Tab.hbs index 50eb4be3dad5..585351c89b8b 100644 --- a/packages/main/src/Tab.hbs +++ b/packages/main/src/Tab.hbs @@ -1,3 +1,7 @@
ui5-tab
and ui5-tab-separator
for the intended design.
+ *
+ * @type {sap.ui.webcomponents.main.ITab[]}
+ * @public
+ * @slot subTabs
+ */
+ subTabs: {
+ type: HTMLElement,
+ individualSlots: true,
+ invalidateOnChildChange: {
+ properties: true,
+ slots: false,
+ },
},
},
properties: /** @lends sap.ui.webcomponents.main.Tab.prototype */ {
@@ -122,6 +148,14 @@ const metadata = {
_selected: {
type: Boolean,
},
+
+ _realTab: {
+ type: Object,
+ },
+
+ _isTopLevelTab: {
+ type: Boolean,
+ },
},
events: /** @lends sap.ui.webcomponents.main.Tab.prototype */ {
},
@@ -199,6 +233,31 @@ class Tab extends UI5Element {
return this.getAttribute("stable-dom-ref") || `${this._id}-stable-dom-ref`;
}
+ get requiresExpandButton() {
+ return this.subTabs.length > 0 && this._isTopLevelTab && this._hasOwnContent;
+ }
+
+ get isSingleClickArea() {
+ return this.subTabs.length > 0 && this._isTopLevelTab && !this._hasOwnContent;
+ }
+
+ get isOnSelectedTabPath() {
+ return this._realTab === this || this.tabs.some(subTab => subTab.isOnSelectedTabPath);
+ }
+
+ get _effectiveSlotName() {
+ return this.isOnSelectedTabPath ? this._individualSlot : "disabled-slot";
+ }
+
+ get _defaultSlotName() {
+ return this._realTab === this ? "" : "disabled-slot";
+ }
+
+ get _hasOwnContent() {
+ return this.content.some(node => (node.nodeType !== Node.COMMENT_NODE
+ && (node.nodeType !== Node.TEXT_NODE || node.nodeValue.trim().length !== 0)));
+ }
+
/**
* Returns the DOM reference of the tab that is placed in the header.
* Note: If you need a DOM ref to the tab content please use the getDomRef
method.
@@ -238,13 +297,18 @@ class Tab extends UI5Element {
}
get effectiveSelected() {
- return this.selected || this._selected;
+ const subItemSelected = this.tabs.some(elem => elem.effectiveSelected);
+ return this.selected || this._selected || subItemSelected;
}
get effectiveHidden() {
return !this.effectiveSelected;
}
+ get tabs() {
+ return this.subTabs.filter(tab => !tab.isSeparator);
+ }
+
get ariaLabelledBy() {
const labels = [];
@@ -298,6 +362,10 @@ class Tab extends UI5Element {
classes.push(`ui5-tab-strip-item--${this.design.toLowerCase()}`);
}
+ if (this.isSingleClickArea) {
+ classes.push(`ui5-tab-strip-item--singleClickArea`);
+ }
+
return classes.join(" ");
}
@@ -322,11 +390,15 @@ class Tab extends UI5Element {
classes.push("ui5-tab-overflow-item--disabled");
}
+ if (this.selected) {
+ classes.push("ui5-tab-overflow-item--selectedSubTab");
+ }
+
return classes.join(" ");
}
get overflowState() {
- return this.disabled ? "Inactive" : "Active";
+ return (this.disabled || this.isSingleClickArea) ? "Inactive" : "Active";
}
}
diff --git a/packages/main/src/TabContainer.hbs b/packages/main/src/TabContainer.hbs
index 3e258455c7a7..cad3aa03c046 100644
--- a/packages/main/src/TabContainer.hbs
+++ b/packages/main/src/TabContainer.hbs
@@ -66,18 +66,16 @@
{{#*inline "contentArea"}}
ui5-tabcontainer
can hold two types of entities:
* ui5-tab
- contains all the information on an item (text and icon)ui5-tab-separator
- used to separate tabs with a vertical lineui5-tab-separator
- used to separate tabs with a line