new Tab(parent, propsopt)
Represents a tab component with multiple customizable properties and events.
| Name | Type | Attributes | Description |
|---|---|---|---|
parent | HTMLElement | HTML element that is going to be the parent of the component. | |
props | TComponents. | <optional> | The properties object. |
const tab = new TComponents.Tab(document.body, {
position: 'absolute',
width: 200,
height: 200,
zIndex: 1000,
views: [
{
name: 'Tab 1',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
{
name: 'Tab 2',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
],
activeViewIndex: 0,
});
// Render the component.
tab.render();Extends
Members
activeTab :string
Sets the active tab by its display name.
- string
- Deprecated
- Use `activeViewName` instead.
const tab = new TComponents.Tab(document.body, {
position: 'absolute',
width: 200,
height: 200,
zIndex: 1000,
views: [
{
name: 'Tab 1',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
{
name: 'Tab 2',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
],
activeViewIndex: 0,
});
// Render the component.
tab.render();
tab.activeTab = 'Tab 2'; // Sets the active tab to 'Tab 2'activeViewIndex :number
Sets the active tab view index and updates the active tab in the tab container.
- number
const tab = new TComponents.Tab(document.body, {
position: 'absolute',
width: 200,
height: 200,
zIndex: 1000,
views: [
{
name: 'Tab 1',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
{
name: 'Tab 2',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
],
activeViewIndex: 0,
});
// Render the component.
tab.render();
tab.activeViewIndex = 1; // Sets the active tab to the second tabactiveViewName :string
Sets the active tab by its display name.
- string
const tab = new TComponents.Tab(document.body, {
position: 'absolute',
width: 200,
height: 200,
zIndex: 1000,
views: [
{
name: 'Tab 1',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
{
name: 'Tab 2',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
],
activeViewIndex: 0,
});
// Render the component.
tab.render();
tab.activeViewName = 'Tab 2'; // Sets the active tab to 'Tab 2'tabPosition :string
Sets the tab bar position. The tab position can be top, left, or right.
- string
const tab = new TComponents.Tab(document.body, {
position: 'absolute',
width: 200,
height: 200,
zIndex: 1000,
views: [
{
name: 'Tab 1',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
{
name: 'Tab 2',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
],
activeViewIndex: 0,
});
// Render the component.
tab.render();
tab.tabPosition = 'left'; // Sets the tab position to the leftviews :Array.<any>
An array of Tab's views, each containing properties like id,name, content, active, and child.
- Array.<any>
- Overrides
const tab = new TComponents.Tab(document.body, {
position: 'absolute',
width: 200,
height: 200,
zIndex: 1000,
views: [
{
name: 'Tab 1',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
{
name: 'Tab 2',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
],
activeViewIndex: 0,
});
// Render the component.
tab.render();
if(tab.views.length >= 1){
console.log(tab.views[0].name); // Outputs: 'Tab 1'
};Methods
(protected) _handleTabClick(e) → {void}
Handles the tab click event.
| Name | Type | Description |
|---|---|---|
e | Event | The event object. |
- Type:
- void
(protected) _setActiveView() → {void}
Activates the view at the specified index.
If the tab container is not initialized or the target view cannot be found.
- Type
- Error
- Type:
- void
(protected) _setTabContainerBorder() → {void}
Applies the background color and rounded-corner border to the tab container based on the configured tab position.
- Type:
- void
addTab(tab) → {void}
Adds a new tab to the component. Experimental interfaces are not recommended for use.
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
tab | object | The tab object Properties
|
- To Do
- This is an experimental interface and may change at any time; it is not recommended to use it in the current version.
- Type:
- void
(protected) defaultProps() → {TComponents.TabProps}
Returns the default properties of the tab component.
- Overrides
Default properties.
- Type:
- TComponents.
TabProps
getProps() → {object}
Gets the properties of the tab component.
- Overrides
- Deprecated
- No longer supported interfaces.
The properties object
- Type:
- object
const tab = new TComponents.Tab(document.body, {
position: 'absolute',
width: 200,
height: 200,
zIndex: 1000,
views: [
{
name: 'Tab 1',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
{
name: 'Tab 2',
icon: 'abb-icon abb-icon-home-house_32',
content: `view_${API.generateUUID()}`,
children: [],
},
],
activeViewIndex: 0,
});
// Render the component.
tab.render();
const props = tab.getProps();
console.log(props.views); // Outputs the views array with contentmapComponents() → {object}
Maps components to their identifiers.
- Overrides
- Type:
- object
markup() → {string}
Returns the HTML markup for the tab component.
- Overrides
The HTML markup
- Type:
- string
onInit() → {void}
Initializes the tab component, setting up event handlers and tab container.
- Overrides
If the component fails to initialize.
- Type
- Error
- Type:
- void
onRender() → {void}
Renders the tab component, applying styles and attaching event listeners.
- Overrides
If the component fails to render.
- Type
- Error
- Type:
- void
(static) loadCssClassFromString(css) → {void}
Add css properties to the component
| Name | Type | Description |
|---|---|---|
css | string | The css string to be loaded into style tag |
- Type:
- void
TComponents.Tab.loadCssClassFromString(`
.tc-tab {
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 4px;
}
}`);