import { KbqTabsModule } from '@koobiq/components/tabs';

KbqTab

componentСкопировать ссылку на KbqTab
@Component({ selector: 'kbq-tab', exportAs: 'kbqTab' })
class KbqTab {
    tooltipTitle = input<string | undefined>();
    disabled = input<boolean | undefined>();
    readonly tooltipPlacement = input<KbqPopUpPlacementValues>(
        PopUpPlacements.Right
    );
    readonly textLabel = input<string>('', { alias: 'label' });
    readonly empty = input<boolean>(false);
    readonly tabId = input<string>();
    templateLabel: KbqTabLabel;
    readonly explicitContent: Signal<TemplateRef<any> | undefined>;
    readonly implicitContent: Signal<TemplateRef<any>>;
    get iconOnlyLabel(): boolean;
    readonly stateChanges: Subject<void>;
    position: number | null;
    origin: number | null;
    isActive: boolean;
    get isOverflown(): boolean;
    overflowTooltipTitle: string;
}
disabledinputСкопировать ссылку на disabledboolean | undefined

Whether the tab is disabled: it cannot be selected and has no interactive states.

tooltipPlacementinputСкопировать ссылку на tooltipPlacementKbqPopUpPlacementValues

Placement of the tooltip shown for a truncated or empty label.

labelinputСкопировать ссылку на labelstring

Plain text label for the tab, used when there is no template label.

templateLabelСкопировать ссылку на templateLabelKbqTabLabel

The label template of the tab: the kbqTabLabel in its content, or else the one assigned in code.

explicitContentСкопировать ссылку на explicitContentSignal<TemplateRef<any> | undefined>

Template provided in the tab content that will be used if present, used to enable lazy-loading

implicitContentСкопировать ссылку на implicitContentSignal<TemplateRef<any>>

Template inside the KbqTab view that contains an <ng-content>.

iconOnlyLabelСкопировать ссылку на iconOnlyLabelboolean

Whether the tab label contains only an icon (no text).

stateChangesСкопировать ссылку на stateChangesSubject<void>

Emits whenever the internal state of the tab changes.

positionСкопировать ссылку на positionnumber | null

The relatively indexed position where 0 represents the center, negative is left, and positive represents the right.

originСкопировать ссылку на originnumber | null

The initial relatively index origin of the tab if it was created and selected after there was already a selected tab. Provides context of what position the tab should originate from.

isActiveСкопировать ссылку на isActiveboolean

Whether the tab is currently active. A template that reads it is updated when it changes.

KbqTabGroup

componentСкопировать ссылку на KbqTabGroup

Tab-group component. Supports basic tab pairs (label + content) and includes keyboard navigation.

@Component({ selector: 'kbq-tab-group', exportAs: 'kbqTabGroup' })
class KbqTabGroup {
    readonly transparent = input<boolean>(false);
    readonly onSurface = input<boolean>(false);
    readonly underlined = input<boolean>(false);
    readonly vertical = input<boolean>(false);
    readonly dynamicHeight = input<boolean>(false);
    selectedIndex = model<number | undefined>();
    activeTab = model<KbqTabSelectBy | null | undefined>();
    headerPosition = input<KbqTabHeaderPosition | undefined>();
    animationDuration = input<string | undefined>();
    readonly focusChange = output<KbqTabChangeEvent>();
    readonly animationDone = output<void>();
    readonly selectedTabChange = output<KbqTabChangeEvent>();
    get tabs(): QueryList<KbqTab>;
    readonly tabBodyWrapper: Signal<ElementRef<any>>;
    readonly tabHeader: Signal<KbqTabHeader>;
    get hasSavedState(): boolean;
    focusChanged(index: number): void;
    getTabLabelId(i: number): string;
    getTabContentId(i: number): string;
    setTabBodyWrapperHeight(tabHeight: number): void;
    removeTabBodyWrapperHeight(): void;
    handleClick(
        tab: KbqTab,
        tabHeader: KbqTabHeader,
        index: number
    ): void;
    getTabIndex(
        tab: KbqTab,
        tabHeader: KbqTabHeader,
        index: number
    ): number;
    onSelectFocusedIndex($event: number): void;
    saveState(): void;
    clearSavedState(): void;
}
transparentinputСкопировать ссылку на transparentboolean

Whether the tab strip background should be transparent.

onSurfaceinputСкопировать ссылку на onSurfaceboolean

Whether the group is rendered on a surface rather than on the page background.

underlinedinputСкопировать ссылку на underlinedboolean

Whether the selected tab is marked with an underline instead of a filled background.

verticalinputСкопировать ссылку на verticalboolean

Whether the tab strip is laid out vertically, alongside the content instead of above it.

dynamicHeightinputСкопировать ссылку на dynamicHeightboolean

Whether the tab group should grow to the size of the active tab.

selectedIndexmodelСкопировать ссылку на selectedIndexnumber | undefined

The index of the active tab.

headerPositioninputСкопировать ссылку на headerPositionKbqTabHeaderPosition | undefined

Position of the tab header.

animationDurationinputСкопировать ссылку на animationDurationstring | undefined

Duration for the tab animation. Must be a valid CSS value (e.g. 600ms).

useStateSavinginputСкопировать ссылку на useStateSavingboolean

Whether the component remembers its state across reloads and restores it on the next render. Defaults to true, or to whatever KBQ_STATE_SAVING_ENABLED is provided as.

stateSavingKeyinputСкопировать ссылку на stateSavingKeystring

The key the state is persisted under. While it is empty the key is derived from where the component sits in the document, which moves when the surrounding markup is restructured — an id on the component or any ancestor pins it just as well as this input does.

focusChangeoutputСкопировать ссылку на focusChangeKbqTabChangeEvent

Event emitted when focus has changed within a tab group.

animationDoneoutputСкопировать ссылку на animationDonevoid

Event emitted when the body animation has completed

selectedTabChangeoutputСкопировать ссылку на selectedTabChangeKbqTabChangeEvent

Event emitted when the tab selection has changed.

tabsСкопировать ссылку на tabsQueryList<KbqTab>

The tabs of the group.

hasSavedStateСкопировать ссылку на hasSavedStateboolean

Whether state is currently persisted for this tab group — restored on init, or written since. Always false while useStateSaving is unset, and false again after clearSavedState().

getTabLabelId()Скопировать ссылку на getTabLabelId()string

Returns a unique id for each tab label element

getTabContentId()Скопировать ссылку на getTabContentId()string

Returns a unique id for each tab content element

setTabBodyWrapperHeight()Скопировать ссылку на setTabBodyWrapperHeight()void

Sets the height of the body wrapper to the height of the activating tab if dynamic height property is true.

removeTabBodyWrapperHeight()Скопировать ссылку на removeTabBodyWrapperHeight()void

Removes the height of the tab body wrapper.

handleClick()Скопировать ссылку на handleClick()void

Handle click events, setting new selected index if appropriate.

getTabIndex()Скопировать ссылку на getTabIndex()number

Retrieves the tabindex for the tab. The single 0 follows the header's focus position rather than the selection, so that a disabled selected tab cannot take the whole strip out of the tab order — a disabled tab is -1, never absent, so it stays a roving-tabindex participant.

saveState()Скопировать ссылку на saveState()void

Persists which tab is selected.

Called for every selection a user makes. Both the tab's tabId and its position are stored: the tabId is the only one that survives the tabs being reordered, and the position is all there is when the tabs carry none.

clearSavedState()Скопировать ссылку на clearSavedState()void

Removes the state persisted for this tab group.

Persistence itself stays on — the next selection is written again. Unset useStateSaving to stop it.

KbqTabNavBar

componentСкопировать ссылку на KbqTabNavBar

Navigation component matching the styles of the tab group header.

@Component({
    selector: '[kbqTabNavBar], [kbq-tab-nav-bar]',
    exportAs: 'kbqTabNavBar'
})
class KbqTabNavBar extends KbqPaginatedTabHeader {
    readonly transparent = input<boolean>(false);
    readonly onSurface = input<boolean>(false);
    readonly underlined = input<boolean>(false);
    readonly tabNavPanel = input<KbqTabNavPanel>();
    selectedIndex = input<number | undefined>();
    disablePagination = input<boolean | undefined>();
    vertical = input<boolean | undefined>();
    get tabListContainer(): ElementRef;
    get tabList(): ElementRef;
    get nextPaginator(): ElementRef<HTMLElement>;
    get previousPaginator(): ElementRef<HTMLElement>;
    get items(): QueryList<KbqTabLink>;
    get role(): string | null;
    focusIndex: number;
    readonly selectFocusedIndex: EventEmitter<number>;
    readonly indexFocused: EventEmitter<number>;
    showPaginationControls: boolean;
    disableScrollAfter: boolean;
    disableScrollBefore: boolean;
    readonly elementRef: ElementRef<HTMLElement>;
    updateActiveLink(): void;
    handleKeydown(event: KeyboardEvent): void;
    onContentChanges(): void;
    updatePagination(): void;
    isValidIndex(index: number): boolean;
    setTabFocus(tabIndex: number): void;
    getLayoutDirection(): Direction;
    scrollHeader(direction: ScrollDirection): void;
    handlePaginatorClick(direction: ScrollDirection): void;
    checkPaginationEnabled(): void;
    stopInterval(): void;
    handlePaginatorPress(
        direction: ScrollDirection,
        mouseEvent?: MouseEvent
    ): void;
}
transparentinputСкопировать ссылку на transparentboolean

Whether the nav bar background should be transparent.

underlinedinputСкопировать ссылку на underlinedboolean

Whether the nav bar should be underlined.

tabNavPanelinputСкопировать ссылку на tabNavPanelKbqTabNavPanel

Associated tab panel controlled by the nav bar.

selectedIndexinputСкопировать ссылку на selectedIndexnumber | undefined

The index of the active tab.

disablePaginationinputСкопировать ссылку на disablePaginationboolean | undefined

Whether pagination should be disabled. This can be used to avoid unnecessary layout recalculations if it's known that pagination won't be required.

A vertical header never paginates, so vertical forces this on without overwriting the value the consumer set — turning vertical back off restores it.

verticalinputСкопировать ссылку на verticalboolean | undefined

Whether the tabs should be displayed vertically.

tabListContainerСкопировать ссылку на tabListContainerElementRef

The scroll container of the tab links.

tabListСкопировать ссылку на tabListElementRef

The element that holds the tab links.

nextPaginatorСкопировать ссылку на nextPaginatorElementRef<HTMLElement>

The pagination arrow towards the end of the tab list.

previousPaginatorСкопировать ссылку на previousPaginatorElementRef<HTMLElement>

The pagination arrow towards the beginning of the tab list.

itemsСкопировать ссылку на itemsQueryList<KbqTabLink>

The tab links of the nav bar.

focusIndexСкопировать ссылку на focusIndexnumber

Tracks which element has focus; used for keyboard navigation

selectFocusedIndexСкопировать ссылку на selectFocusedIndexEventEmitter<number>

Event emitted when the option is selected.

indexFocusedСкопировать ссылку на indexFocusedEventEmitter<number>

Event emitted when a label is focused.

showPaginationControlsСкопировать ссылку на showPaginationControlsboolean

Whether the controls for pagination should be displayed

disableScrollAfterСкопировать ссылку на disableScrollAfterboolean

Whether the tab list can be scrolled more towards the end of the tab label list.

disableScrollBeforeСкопировать ссылку на disableScrollBeforeboolean

Whether the tab list can be scrolled more towards the beginning of the tab label list.

onContentChanges()Скопировать ссылку на onContentChanges()void

Callback for when the MutationObserver detects that the content has changed.

updatePagination()Скопировать ссылку на updatePagination()void

Updates the view whether pagination should be enabled or not.

WARNING: Calling this method can be very costly in terms of performance. It should be called as infrequently as possible from outside of the Tabs component as it causes a reflow of the page.

isValidIndex()Скопировать ссылку на isValidIndex()boolean

Determines if an index is valid. If the tabs are not ready yet, we assume that the user is providing a valid index and return true.

setTabFocus()Скопировать ссылку на setTabFocus()void

Sets focus on the HTML element for the label wrapper and scrolls it into the view if scrolling is enabled.

getLayoutDirection()Скопировать ссылку на getLayoutDirection()Direction

The layout direction of the containing app.

scrollHeader()Скопировать ссылку на scrollHeader()void

Moves the tab list in the 'before' or 'after' direction (towards the beginning of the list or the end of the list, respectively).

This is an expensive call that forces a layout reflow to compute box and scroll metrics and should be called sparingly.

handlePaginatorClick()Скопировать ссылку на handlePaginatorClick()void

Handles click events on the pagination arrows.

checkPaginationEnabled()Скопировать ссылку на checkPaginationEnabled()void

Evaluate whether the pagination controls should be displayed. If the scroll width of the tab list is wider than the size of the header container, then the pagination controls should be shown.

This is an expensive call that forces a layout reflow to compute box and scroll metrics and should be called sparingly.

stopInterval()Скопировать ссылку на stopInterval()void

Stops the currently-running paginator interval.

handlePaginatorPress()Скопировать ссылку на handlePaginatorPress()void

Handles the user pressing down on one of the paginators. Starts scrolling the header after a certain amount of time.

Parameters
directionScrollDirection

In which direction the paginator should be scrolled.

KbqAlignTabsCenterCssStyler

directiveСкопировать ссылку на KbqAlignTabsCenterCssStyler
@Directive({
    selector: 'kbq-tab-group[kbq-align-tabs-center], [kbq-tab-nav-bar][kbq-align-tabs-center], [kbqTabNavBar][kbq-align-tabs-center]'
})
class KbqAlignTabsCenterCssStyler {}

KbqAlignTabsEndCssStyler

directiveСкопировать ссылку на KbqAlignTabsEndCssStyler
@Directive({
    selector: 'kbq-tab-group[kbq-align-tabs-end], [kbq-tab-nav-bar][kbq-align-tabs-end], [kbqTabNavBar][kbq-align-tabs-end]'
})
class KbqAlignTabsEndCssStyler {}

KbqStretchTabsCssStyler

directiveСкопировать ссылку на KbqStretchTabsCssStyler
@Directive({
    selector: 'kbq-tab-group[kbq-stretch-tabs], [kbq-tab-nav-bar][kbq-stretch-tabs], [kbqTabNavBar][kbq-stretch-tabs]'
})
class KbqStretchTabsCssStyler {}

KbqTabContent

directiveСкопировать ссылку на KbqTabContent

Decorates the ng-template tags and reads out the template from it.

@Directive({ selector: '[kbqTabContent]' })
class KbqTabContent {
    template: TemplateRef<any>;
}

KbqTabLabel

directiveСкопировать ссылку на KbqTabLabel

Used to flag tab labels for use with the portal directive

@Directive({ selector: '[kbq-tab-label], [kbqTabLabel]' })
class KbqTabLabel extends CdkPortal {
    readonly iconOnly = input<boolean>(false);
    templateRef: TemplateRef<C>;
    viewContainerRef: ViewContainerRef;
    context?: C;
    injector?: Injector;
    get origin(): ElementRef<any>;
    get isAttached(): boolean;
    attach(host: PortalOutlet, context?: C): EmbeddedViewRef<C>;
    detach(): void;
    setAttachedHost(host: PortalOutlet | null): void;
}
iconOnlyinputСкопировать ссылку на iconOnlyboolean

Whether the tab contains only an icon without a label.

templateRefСкопировать ссылку на templateRefTemplateRef<C>

The embedded template that will be used to instantiate an embedded View in the host.

viewContainerRefСкопировать ссылку на viewContainerRefViewContainerRef

Reference to the ViewContainer into which the template will be stamped out.

contextoptionalСкопировать ссылку на contextC

Contextual data to be passed in to the embedded view.

injectoroptionalСкопировать ссылку на injectorInjector

The injector to use for the embedded view.

isAttachedСкопировать ссылку на isAttachedboolean

Whether this portal is attached to a host.

attach()Скопировать ссылку на attach()EmbeddedViewRef<C>

Attach the portal to the provided PortalOutlet. When a context is provided it will override the context property of the TemplatePortal instance.

setAttachedHost()Скопировать ссылку на setAttachedHost()void

Sets the PortalOutlet reference without performing attach(). This is used directly by the PortalOutlet when it is performing an attach() or detach().

KbqTabLink

directiveСкопировать ссылку на KbqTabLink

Link inside of a KbqTabNavBar.

@Directive({ selector: '[kbqTabLink], [kbq-tab-link]', exportAs: 'kbqTabLink' })
class KbqTabLink {
    id = input<string | undefined>();
    active = input<boolean | undefined>();
    disabled = input<boolean | undefined>();
    get vertical(): boolean;
    get underlined(): boolean;
    readonly elementRef: ElementRef<HTMLElement>;
    focus(): void;
}

KbqTabNavPanel

directiveСкопировать ссылку на KbqTabNavPanel

Tab panel component associated with KbqTabNav.

@Directive({ selector: '[kbqTabNavPanel]', exportAs: 'kbqTabNavPanel' })
class KbqTabNavPanel {
    readonly id = input<string>(`kbq-tab-nav-panel-${nextUniqueId++}`);
    activeTabId?: string;
}
idinputСкопировать ссылку на idstring

Unique id for the tab panel.

activeTabIdoptionalСкопировать ссылку на activeTabIdstring

Id of the active tab in the nav bar.

KbqVerticalTabsCssStyler

directiveDeprecatedСкопировать ссылку на KbqVerticalTabsCssStyler

No-op. The vertical layout class is bound from KbqTabGroup/KbqTabNavBar themselves, so it follows the vertical value instead of merely the presence of the attribute. Will be removed in a future major version — stop importing it.

@Directive({
    selector: 'kbq-tab-group[vertical], [kbq-tab-nav-bar][vertical], [kbqTabNavBar][vertical]'
})
class KbqVerticalTabsCssStyler {}

KbqTabChangeEvent

classСкопировать ссылку на KbqTabChangeEvent

A simple change event emitted on focus or selection changes.

class KbqTabChangeEvent {
    index: number;
    tab: KbqTab;
}
indexСкопировать ссылку на indexnumber

Index of the currently-selected tab.

tabСкопировать ссылку на tabKbqTab

Reference to the currently-selected tab.

KbqPaginatedTabHeaderItem

typeСкопировать ссылку на KbqPaginatedTabHeaderItem

Item inside a paginated tab header.

type KbqPaginatedTabHeaderItem = FocusableOption & {
    elementRef: ElementRef;
};

KbqTabBodyPositionState

typeСкопировать ссылку на KbqTabBodyPositionState

These position states are used internally as the translation states of the tab body. Setting the position state to left, right, or center will transition the tab body from its current position to its respective state. If there is not current position (void, in the case of a new tab body), then there will be no transition to its state.

In the case of a new tab body that should immediately be centered with an animating transition, then left-origin-center or right-origin-center can be used, which will use left or right as its pseudo-prior state.

type KbqTabBodyPositionState = 'left' | 'center' | 'right' | 'left-origin-center' | 'right-origin-center';

KbqTabHeaderPosition

typeСкопировать ссылку на KbqTabHeaderPosition

Possible positions for the tab header.

type KbqTabHeaderPosition = 'above' | 'below';

KbqTabsConfig

interfaceСкопировать ссылку на KbqTabsConfig

Object that can be used to configure the default options for the tabs module.

interface KbqTabsConfig {
    animationDuration?: string;
}
animationDurationoptionalСкопировать ссылку на animationDurationstring

Duration for the tab animation. Must be a valid CSS value (e.g. 600ms).

KbqTabSelectBy

typeСкопировать ссылку на KbqTabSelectBy
type KbqTabSelectBy = string | number | ((tabs: KbqTab[]) => KbqTab | null);

KbqTabsState

interfaceСкопировать ссылку на KbqTabsState

The persisted state of a tab group — which tab was selected.

Both are stored: tabId is the only identifier that survives a reordering, and index is all there is when the tabs carry no tabId.

interface KbqTabsState {
    tabId: string | null;
    index: number;
}

ScrollDirection

typeСкопировать ссылку на ScrollDirection

The directions that scrolling can go in when the header's tabs exceed the header width. 'After' will scroll the header towards the end of the tabs list and 'before' will scroll towards the beginning of the list.

type ScrollDirection = 'after' | 'before';

KBQ_TAB_LABEL

constСкопировать ссылку на KBQ_TAB_LABEL
const KBQ_TAB_LABEL: InjectionToken<KbqTabLabel>;

KBQ_TABS_CONFIG

constСкопировать ссылку на KBQ_TABS_CONFIG

Injection token that can be used to provide the default options the tabs module.

const KBQ_TABS_CONFIG: InjectionToken<KbqTabsConfig>;
Предложения по улучшению
Если вы нашли ошибку или хотите доработать статью, создайте запрос на GitHub.