TComponents. Tab

new Tab(parent, propsopt)

Represents a tab component with multiple customizable properties and events.

Parameters:
NameTypeAttributesDescription
parentHTMLElement

HTML element that is going to be the parent of the component.

propsTComponents.TabProps<optional>

The properties object.

Example
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.

Type:
  • string
Deprecated
  • Use `activeViewName` instead.
Example
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.

Type:
  • number
Example
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 tab

activeViewName :string

Sets the active tab by its display name.

Type:
  • string
Example
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.

Type:
  • string
Example
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 left

views :Array.<any>

An array of Tab's views, each containing properties like id,name, content, active, and child.

Type:
  • Array.<any>
Example
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.

Parameters:
NameTypeDescription
eEvent

The event object.

Returns:
Type: 
void

(protected) _setActiveView() → {void}

Activates the view at the specified index.

Throws:

If the tab container is not initialized or the target view cannot be found.

Type
Error
Returns:
Type: 
void

(protected) _setTabContainerBorder() → {void}

Applies the background color and rounded-corner border to the tab container based on the configured tab position.

Returns:
Type: 
void

addTab(tab) → {void}

Adds a new tab to the component. Experimental interfaces are not recommended for use.

Parameters:
NameTypeDescription
tabobject

The tab object

Properties
NameTypeDescription
namestring

The name of the tab

contentstring

The content of the tab

To Do
  • This is an experimental interface and may change at any time; it is not recommended to use it in the current version.
Returns:
Type: 
void

(protected) defaultProps() → {TComponents.TabProps}

Returns the default properties of the tab component.

Returns:

Default properties.

Type: 
TComponents.TabProps

getProps() → {object}

Gets the properties of the tab component.

Deprecated
  • No longer supported interfaces.
Returns:

The properties object

Type: 
object
Example
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 content

mapComponents() → {object}

Maps components to their identifiers.

Returns:
Type: 
object

markup() → {string}

Returns the HTML markup for the tab component.

Returns:

The HTML markup

Type: 
string

onInit() → {void}

Initializes the tab component, setting up event handlers and tab container.

Throws:

If the component fails to initialize.

Type
Error
Returns:
Type: 
void

onRender() → {void}

Renders the tab component, applying styles and attaching event listeners.

Throws:

If the component fails to render.

Type
Error
Returns:
Type: 
void

(static) loadCssClassFromString(css) → {void}

Add css properties to the component

Parameters:
NameTypeDescription
cssstring

The css string to be loaded into style tag

Returns:
Type: 
void
Example
TComponents.Tab.loadCssClassFromString(`
  .tc-tab {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
  }
}`);