UNPKG

@progress/kendo-angular-layout

Version:

Kendo UI for Angular Layout Package - a collection of components to create professional application layoyts

121 lines (120 loc) 3.33 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { isPresent } from "../common/util"; /** * @hidden * * Checks if the current target is a TabStrip tab element */ export const isTabElement = (target) => { const targetId = target.getAttribute('id'); if (isPresent(targetId) || targetId.indexOf('k-tabstrip-tab-') >= 0) { return true; } return false; }; /** * @hidden * * Checks if the current tab is closable. Depends on the value of the TabStrip closable property. */ export const isTabClosable = (tab, tabStripClosable) => { if (tab.closable !== undefined) { return tab.closable; } return tabStripClosable; }; /** * @hidden * * Checks if the TabStrip scroll buttons will be rendered. Depends on the value of the TabStrip scrollable settings. */ export const tabStripHasScrollButtons = (scrollableSettings) => { const visible = scrollableSettings.enabled && scrollableSettings.scrollButtons !== 'hidden'; const position = scrollableSettings.scrollButtonsPosition; return { visible, position }; }; /** * @hidden * * Checks if the TabStrip mouse scroll will be enabled. Depends on the value of the TabStrip scrollable settings. */ export const mouseScrollEnabled = (scrollableSettings) => { return scrollableSettings.enabled && scrollableSettings.mouseScroll; }; /** * @hidden * * Retrieves the current active tab element and its index. * This could either be the currently selected tab or the currently focused tab. */ export const getActiveTab = (tabs) => { let focusedTab; let selectedTab; let focusedIndex = -1; let selectedIndex = -1; tabs.forEach((tab, index) => { if (tab.selected) { selectedTab = tab; selectedIndex = index; } else if (tab.focused) { focusedTab = tab; focusedIndex = index; } }); return focusedIndex >= 0 ? { tab: focusedTab, index: focusedIndex } : { tab: selectedTab, index: selectedIndex }; }; /** * @hidden */ export const getTabByIndex = (tabs, index) => { const filtered = tabs.filter((_tab, i) => i === index); if (filtered.length > 0) { return filtered[0]; } return null; }; /** * @hidden */ export const getTabHeaderByIndex = (tabHeaderContainers, index) => { const filtered = tabHeaderContainers.filter((_tabHeader, i) => i === index); if (filtered.length > 0) { return filtered[0]; } return null; }; /** * @hidden */ export const resetTabFocus = (tabs) => { tabs.forEach((tab) => { tab.focused = false; }); }; /** * @hidden */ export const resetTabSelection = (tabs) => { tabs.forEach((tab) => { tab.selected = false; }); }; /** * @hidden */ export const isTablistHorizontal = (tabPosition) => tabPosition === 'top' || tabPosition === 'bottom'; /** * @hidden */ export const getId = (prefix, tabStripId, tabIndex) => { return `${prefix}-${tabStripId}-${tabIndex}`; };