575 lines
31 KiB
JavaScript
575 lines
31 KiB
JavaScript
|
import * as i2 from '@angular/common';
|
||
|
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
||
|
import * as i0 from '@angular/core';
|
||
|
import { EventEmitter, signal, PLATFORM_ID, booleanAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Inject, Input, Output, ViewChild, ViewChildren, ContentChildren, NgModule } from '@angular/core';
|
||
|
import * as i1 from '@angular/router';
|
||
|
import { RouterModule } from '@angular/router';
|
||
|
import { PrimeTemplate, SharedModule } from 'primeng/api';
|
||
|
import { DomHandler } from 'primeng/dom';
|
||
|
import { ChevronLeftIcon } from 'primeng/icons/chevronleft';
|
||
|
import { ChevronRightIcon } from 'primeng/icons/chevronright';
|
||
|
import * as i3 from 'primeng/ripple';
|
||
|
import { RippleModule } from 'primeng/ripple';
|
||
|
import * as i4 from 'primeng/tooltip';
|
||
|
import { TooltipModule } from 'primeng/tooltip';
|
||
|
import { ObjectUtils } from 'primeng/utils';
|
||
|
|
||
|
/**
|
||
|
* TabMenu is a navigation component that displays items as tab headers.
|
||
|
* @group Components
|
||
|
*/
|
||
|
class TabMenu {
|
||
|
platformId;
|
||
|
router;
|
||
|
route;
|
||
|
cd;
|
||
|
/**
|
||
|
* An array of menuitems.
|
||
|
* @group Props
|
||
|
*/
|
||
|
set model(value) {
|
||
|
this._model = value;
|
||
|
this._focusableItems = (this._model || []).reduce((result, item) => {
|
||
|
result.push(item);
|
||
|
return result;
|
||
|
}, []);
|
||
|
}
|
||
|
get model() {
|
||
|
return this._model;
|
||
|
}
|
||
|
/**
|
||
|
* Defines the default active menuitem
|
||
|
* @group Props
|
||
|
*/
|
||
|
set activeItem(value) {
|
||
|
this._activeItem = value;
|
||
|
this.activeItemChange.emit(value);
|
||
|
this.tabChanged = true;
|
||
|
}
|
||
|
get activeItem() {
|
||
|
return this._activeItem;
|
||
|
}
|
||
|
/**
|
||
|
* When enabled displays buttons at each side of the tab headers to scroll the tab list.
|
||
|
* @group Props
|
||
|
*/
|
||
|
scrollable;
|
||
|
/**
|
||
|
* Defines if popup mode enabled.
|
||
|
*/
|
||
|
popup;
|
||
|
/**
|
||
|
* Inline style of the element.
|
||
|
* @group Props
|
||
|
*/
|
||
|
style;
|
||
|
/**
|
||
|
* Class of the element.
|
||
|
* @group Props
|
||
|
*/
|
||
|
styleClass;
|
||
|
/**
|
||
|
* Defines a string value that labels an interactive element.
|
||
|
* @group Props
|
||
|
*/
|
||
|
ariaLabel;
|
||
|
/**
|
||
|
* Identifier of the underlying input element.
|
||
|
* @group Props
|
||
|
*/
|
||
|
ariaLabelledBy;
|
||
|
/**
|
||
|
* Event fired when a tab is selected.
|
||
|
* @param {MenuItem} item - Menu item.
|
||
|
* @group Emits
|
||
|
*/
|
||
|
activeItemChange = new EventEmitter();
|
||
|
content;
|
||
|
navbar;
|
||
|
inkbar;
|
||
|
prevBtn;
|
||
|
nextBtn;
|
||
|
tabLink;
|
||
|
tab;
|
||
|
templates;
|
||
|
itemTemplate;
|
||
|
previousIconTemplate;
|
||
|
nextIconTemplate;
|
||
|
tabChanged;
|
||
|
backwardIsDisabled = true;
|
||
|
forwardIsDisabled = false;
|
||
|
timerIdForInitialAutoScroll = null;
|
||
|
_focusableItems;
|
||
|
_model;
|
||
|
_activeItem;
|
||
|
focusedItemInfo = signal(null);
|
||
|
get focusableItems() {
|
||
|
if (!this._focusableItems || !this._focusableItems.length) {
|
||
|
this._focusableItems = (this.model || []).reduce((result, item) => {
|
||
|
result.push(item);
|
||
|
return result;
|
||
|
}, []);
|
||
|
}
|
||
|
return this._focusableItems;
|
||
|
}
|
||
|
constructor(platformId, router, route, cd) {
|
||
|
this.platformId = platformId;
|
||
|
this.router = router;
|
||
|
this.route = route;
|
||
|
this.cd = cd;
|
||
|
}
|
||
|
ngAfterContentInit() {
|
||
|
this.templates?.forEach((item) => {
|
||
|
switch (item.getType()) {
|
||
|
case 'item':
|
||
|
this.itemTemplate = item.template;
|
||
|
break;
|
||
|
case 'nexticon':
|
||
|
this.nextIconTemplate = item.template;
|
||
|
break;
|
||
|
case 'previousicon':
|
||
|
this.previousIconTemplate = item.template;
|
||
|
break;
|
||
|
default:
|
||
|
this.itemTemplate = item.template;
|
||
|
break;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
ngAfterViewInit() {
|
||
|
if (isPlatformBrowser(this.platformId)) {
|
||
|
this.updateInkBar();
|
||
|
this.initAutoScrollForActiveItem();
|
||
|
this.initButtonState();
|
||
|
}
|
||
|
}
|
||
|
ngAfterViewChecked() {
|
||
|
if (isPlatformBrowser(this.platformId)) {
|
||
|
this.updateInkBar();
|
||
|
this.tabChanged = false;
|
||
|
}
|
||
|
}
|
||
|
ngOnDestroy() {
|
||
|
this.clearAutoScrollHandler();
|
||
|
}
|
||
|
isActive(item) {
|
||
|
if (item.routerLink) {
|
||
|
const routerLink = Array.isArray(item.routerLink) ? item.routerLink : [item.routerLink];
|
||
|
return this.router.isActive(this.router.createUrlTree(routerLink, { relativeTo: this.route }).toString(), item.routerLinkActiveOptions?.exact ?? item.routerLinkActiveOptions ?? false);
|
||
|
}
|
||
|
return item === this.activeItem;
|
||
|
}
|
||
|
getItemProp(item, name) {
|
||
|
return item ? ObjectUtils.getItemValue(item[name]) : undefined;
|
||
|
}
|
||
|
visible(item) {
|
||
|
return typeof item.visible === 'function' ? item.visible() : item.visible !== false;
|
||
|
}
|
||
|
disabled(item) {
|
||
|
return typeof item.disabled === 'function' ? item.disabled() : item.disabled;
|
||
|
}
|
||
|
onMenuItemFocus(item) {
|
||
|
this.focusedItemInfo.set(item);
|
||
|
}
|
||
|
itemClick(event, item) {
|
||
|
if (item.disabled) {
|
||
|
event.preventDefault();
|
||
|
return;
|
||
|
}
|
||
|
if (!item.url && !item.routerLink) {
|
||
|
event.preventDefault();
|
||
|
}
|
||
|
if (item.command) {
|
||
|
item.command({
|
||
|
originalEvent: event,
|
||
|
item: item
|
||
|
});
|
||
|
}
|
||
|
this.activeItem = item;
|
||
|
this.activeItemChange.emit(item);
|
||
|
this.tabChanged = true;
|
||
|
this.cd.markForCheck();
|
||
|
}
|
||
|
onKeydownItem(event, index, item) {
|
||
|
let i = index;
|
||
|
let foundElement = {};
|
||
|
const tabLinks = this.tabLink.toArray();
|
||
|
const tabs = this.tab.toArray();
|
||
|
switch (event.code) {
|
||
|
case 'ArrowRight':
|
||
|
foundElement = this.findNextItem(tabs, i);
|
||
|
i = foundElement['i'];
|
||
|
break;
|
||
|
case 'ArrowLeft':
|
||
|
foundElement = this.findPrevItem(tabs, i);
|
||
|
i = foundElement['i'];
|
||
|
break;
|
||
|
case 'End':
|
||
|
foundElement = this.findPrevItem(tabs, this.model.length);
|
||
|
i = foundElement['i'];
|
||
|
event.preventDefault();
|
||
|
break;
|
||
|
case 'Home':
|
||
|
foundElement = this.findNextItem(tabs, -1);
|
||
|
i = foundElement['i'];
|
||
|
event.preventDefault();
|
||
|
break;
|
||
|
case 'Space':
|
||
|
case 'Enter':
|
||
|
this.itemClick(event, item);
|
||
|
break;
|
||
|
case 'Tab':
|
||
|
this.onTabKeyDown(tabLinks);
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
if (tabLinks[i] && tabLinks[index]) {
|
||
|
tabLinks[index].nativeElement.tabIndex = '-1';
|
||
|
tabLinks[i].nativeElement.tabIndex = '0';
|
||
|
tabLinks[i].nativeElement.focus();
|
||
|
}
|
||
|
this.cd.markForCheck();
|
||
|
}
|
||
|
onTabKeyDown(tabLinks) {
|
||
|
tabLinks.forEach((item) => {
|
||
|
item.nativeElement.tabIndex = DomHandler.getAttribute(item.nativeElement.parentElement, 'data-p-highlight') ? '0' : '-1';
|
||
|
});
|
||
|
}
|
||
|
findNextItem(items, index) {
|
||
|
let i = index + 1;
|
||
|
if (i >= items.length) {
|
||
|
return { nextItem: items[items.length], i: items.length };
|
||
|
}
|
||
|
let nextItem = items[i];
|
||
|
if (nextItem)
|
||
|
return DomHandler.getAttribute(nextItem.nativeElement, 'data-p-disabled') ? this.findNextItem(items, i) : { nextItem: nextItem.nativeElement, i };
|
||
|
else
|
||
|
return null;
|
||
|
}
|
||
|
findPrevItem(items, index) {
|
||
|
let i = index - 1;
|
||
|
if (i < 0) {
|
||
|
return { prevItem: items[0], i: 0 };
|
||
|
}
|
||
|
let prevItem = items[i];
|
||
|
if (prevItem)
|
||
|
return DomHandler.getAttribute(prevItem.nativeElement, 'data-p-disabled') ? this.findPrevItem(items, i) : { prevItem: prevItem.nativeElement, i };
|
||
|
else
|
||
|
return null;
|
||
|
}
|
||
|
updateInkBar() {
|
||
|
const tabHeader = DomHandler.findSingle(this.navbar?.nativeElement, 'li.p-highlight');
|
||
|
if (tabHeader) {
|
||
|
this.inkbar.nativeElement.style.width = DomHandler.getWidth(tabHeader) + 'px';
|
||
|
this.inkbar.nativeElement.style.left = DomHandler.getOffset(tabHeader).left - DomHandler.getOffset(this.navbar?.nativeElement).left + 'px';
|
||
|
}
|
||
|
}
|
||
|
getVisibleButtonWidths() {
|
||
|
return [this.prevBtn?.nativeElement, this.nextBtn?.nativeElement].reduce((acc, el) => (el ? acc + DomHandler.getWidth(el) : acc), 0);
|
||
|
}
|
||
|
updateButtonState() {
|
||
|
const content = this.content?.nativeElement;
|
||
|
const { scrollLeft, scrollWidth } = content;
|
||
|
const width = DomHandler.getWidth(content);
|
||
|
this.backwardIsDisabled = scrollLeft === 0;
|
||
|
this.forwardIsDisabled = parseInt(scrollLeft) === scrollWidth - width;
|
||
|
}
|
||
|
updateScrollBar(index) {
|
||
|
const tabHeader = this.navbar?.nativeElement.children[index];
|
||
|
if (!tabHeader) {
|
||
|
return;
|
||
|
}
|
||
|
tabHeader.scrollIntoView({ block: 'nearest', inline: 'center' });
|
||
|
}
|
||
|
onScroll(event) {
|
||
|
this.scrollable && this.updateButtonState();
|
||
|
event.preventDefault();
|
||
|
}
|
||
|
navBackward() {
|
||
|
const content = this.content?.nativeElement;
|
||
|
const width = DomHandler.getWidth(content) - this.getVisibleButtonWidths();
|
||
|
const pos = content.scrollLeft - width;
|
||
|
content.scrollLeft = pos <= 0 ? 0 : pos;
|
||
|
}
|
||
|
navForward() {
|
||
|
const content = this.content?.nativeElement;
|
||
|
const width = DomHandler.getWidth(content) - this.getVisibleButtonWidths();
|
||
|
const pos = content.scrollLeft + width;
|
||
|
const lastPos = content.scrollWidth - width;
|
||
|
content.scrollLeft = pos >= lastPos ? lastPos : pos;
|
||
|
}
|
||
|
initAutoScrollForActiveItem() {
|
||
|
if (!this.scrollable) {
|
||
|
return;
|
||
|
}
|
||
|
this.clearAutoScrollHandler();
|
||
|
// We have to wait for the rendering and then can scroll to element.
|
||
|
this.timerIdForInitialAutoScroll = setTimeout(() => {
|
||
|
const activeItem = this.model.findIndex((menuItem) => this.isActive(menuItem));
|
||
|
if (activeItem !== -1) {
|
||
|
this.updateScrollBar(activeItem);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
clearAutoScrollHandler() {
|
||
|
if (this.timerIdForInitialAutoScroll) {
|
||
|
clearTimeout(this.timerIdForInitialAutoScroll);
|
||
|
this.timerIdForInitialAutoScroll = null;
|
||
|
}
|
||
|
}
|
||
|
initButtonState() {
|
||
|
if (this.scrollable) {
|
||
|
// We have to wait for the rendering and then retrieve the actual size element from the DOM.
|
||
|
// in future `Promise.resolve` can be changed to `queueMicrotask` (if ie11 support will be dropped)
|
||
|
Promise.resolve().then(() => {
|
||
|
this.updateButtonState();
|
||
|
this.cd.markForCheck();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TabMenu, deps: [{ token: PLATFORM_ID }, { token: i1.Router }, { token: i1.ActivatedRoute }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
||
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: TabMenu, selector: "p-tabMenu", inputs: { model: "model", activeItem: "activeItem", scrollable: ["scrollable", "scrollable", booleanAttribute], popup: ["popup", "popup", booleanAttribute], style: "style", styleClass: "styleClass", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy" }, outputs: { activeItemChange: "activeItemChange" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true }, { propertyName: "navbar", first: true, predicate: ["navbar"], descendants: true }, { propertyName: "inkbar", first: true, predicate: ["inkbar"], descendants: true }, { propertyName: "prevBtn", first: true, predicate: ["prevBtn"], descendants: true }, { propertyName: "nextBtn", first: true, predicate: ["nextBtn"], descendants: true }, { propertyName: "tabLink", predicate: ["tabLink"], descendants: true }, { propertyName: "tab", predicate: ["tab"], descendants: true }], ngImport: i0, template: `
|
||
|
<div [ngClass]="{ 'p-tabmenu p-component': true, 'p-tabmenu-scrollable': scrollable }" [ngStyle]="style" [class]="styleClass">
|
||
|
<div class="p-tabmenu-nav-container">
|
||
|
<button *ngIf="scrollable && !backwardIsDisabled" #prevBtn class="p-tabmenu-nav-prev p-tabmenu-nav-btn p-link" (click)="navBackward()" type="button" role="navigation" pRipple>
|
||
|
<ChevronLeftIcon *ngIf="!previousIconTemplate" [attr.aria-hidden]="true" />
|
||
|
<ng-template *ngTemplateOutlet="previousIconTemplate"></ng-template>
|
||
|
</button>
|
||
|
<div #content class="p-tabmenu-nav-content" (scroll)="onScroll($event)">
|
||
|
<ul #navbar class="p-tabmenu-nav p-reset" role="menubar" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-label]="ariaLabel">
|
||
|
<li
|
||
|
#tab
|
||
|
*ngFor="let item of focusableItems; let i = index"
|
||
|
role="presentation"
|
||
|
[ngStyle]="item.style"
|
||
|
[class]="item.styleClass"
|
||
|
[attr.data-p-disabled]="disabled(item)"
|
||
|
[attr.data-p-highlight]="focusedItemInfo() === item"
|
||
|
(click)="itemClick($event, item)"
|
||
|
(keydown)="onKeydownItem($event, i, item)"
|
||
|
(focus)="onMenuItemFocus(item)"
|
||
|
[ngClass]="{ 'p-tabmenuitem': true, 'p-disabled': getItemProp(item, 'disabled'), 'p-highlight': isActive(item), 'p-hidden': item.visible === false }"
|
||
|
pTooltip
|
||
|
[tooltipOptions]="item.tooltipOptions"
|
||
|
>
|
||
|
<a
|
||
|
#tabLink
|
||
|
*ngIf="!item.routerLink && !itemTemplate"
|
||
|
class="p-menuitem-link"
|
||
|
role="menuitem"
|
||
|
[attr.href]="getItemProp(item, 'url')"
|
||
|
[attr.id]="getItemProp(item, 'id')"
|
||
|
[attr.aria-disabled]="disabled(item)"
|
||
|
[attr.aria-label]="getItemProp(item, 'label')"
|
||
|
[attr.tabindex]="disabled(item) ? -1 : 0"
|
||
|
[target]="getItemProp(item, 'target')"
|
||
|
pRipple
|
||
|
>
|
||
|
<ng-container>
|
||
|
<span class="p-menuitem-icon" [ngClass]="item.icon" *ngIf="item.icon" [ngStyle]="item.iconStyle"></span>
|
||
|
<span class="p-menuitem-text" *ngIf="item.escape !== false; else htmlLabel">{{ getItemProp(item, 'label') }}</span>
|
||
|
<ng-template #htmlLabel><span class="p-menuitem-text" [innerHTML]="getItemProp(item, 'label')"></span></ng-template>
|
||
|
<span class="p-menuitem-badge" *ngIf="item.badge" [ngClass]="item.badgeStyleClass">{{ getItemProp(item, 'badge') }}</span>
|
||
|
</ng-container>
|
||
|
</a>
|
||
|
<a
|
||
|
#tabLink
|
||
|
*ngIf="item.routerLink && !itemTemplate"
|
||
|
[routerLink]="item.routerLink"
|
||
|
[queryParams]="item.queryParams"
|
||
|
[routerLinkActive]="'p-menuitem-link-active'"
|
||
|
[routerLinkActiveOptions]="item.routerLinkActiveOptions || { exact: false }"
|
||
|
role="menuitem"
|
||
|
class="p-menuitem-link"
|
||
|
[target]="item.target"
|
||
|
[attr.id]="getItemProp(item, 'id')"
|
||
|
[attr.aria-disabled]="disabled(item)"
|
||
|
[attr.aria-label]="getItemProp(item, 'label')"
|
||
|
[attr.tabindex]="disabled(item) ? -1 : 0"
|
||
|
[fragment]="item.fragment"
|
||
|
[queryParamsHandling]="item.queryParamsHandling"
|
||
|
[preserveFragment]="item.preserveFragment"
|
||
|
[skipLocationChange]="item.skipLocationChange"
|
||
|
[replaceUrl]="item.replaceUrl"
|
||
|
[state]="item.state"
|
||
|
pRipple
|
||
|
>
|
||
|
<ng-container>
|
||
|
<span class="p-menuitem-icon" [attr.aria-hidden]="true" [ngClass]="item.icon" *ngIf="item.icon" [ngStyle]="item.iconStyle"></span>
|
||
|
<span class="p-menuitem-text" *ngIf="item.escape !== false; else htmlRouteLabel">{{ getItemProp(item, 'label') }}</span>
|
||
|
<ng-template #htmlRouteLabel><span class="p-menuitem-text" [innerHTML]="getItemProp(item, 'label')"></span></ng-template>
|
||
|
<span class="p-menuitem-badge" *ngIf="item.badge" [ngClass]="item.badgeStyleClass">{{ getItemProp(item, 'badge') }}</span>
|
||
|
</ng-container>
|
||
|
</a>
|
||
|
<ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item, index: i }"></ng-container>
|
||
|
</li>
|
||
|
<li #inkbar class="p-tabmenu-ink-bar" role="none"></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<button *ngIf="scrollable && !forwardIsDisabled" #nextBtn class="p-tabmenu-nav-next p-tabmenu-nav-btn p-link" (click)="navForward()" type="button" role="navigation" pRipple>
|
||
|
<ChevronRightIcon *ngIf="!previousIconTemplate" [attr.aria-hidden]="true" />
|
||
|
<ng-template *ngTemplateOutlet="nextIconTemplate"></ng-template>
|
||
|
</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
`, isInline: true, styles: ["@layer primeng{.p-tabmenu-nav-container{position:relative}.p-tabmenu-scrollable .p-tabmenu-nav-container{overflow:hidden}.p-tabmenu-nav-content{overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scrollbar-width:none;overscroll-behavior:contain auto}.p-tabmenu-nav-btn{position:absolute;top:0;z-index:2;height:100%;display:flex;align-items:center;justify-content:center}.p-tabmenu-nav-prev{left:0}.p-tabmenu-nav-next{right:0}.p-tabview-nav-content::-webkit-scrollbar{display:none}.p-tabmenu-nav{display:flex;margin:0;padding:0;list-style-type:none;flex-wrap:nowrap}.p-tabmenu-nav a{cursor:pointer;-webkit-user-select:none;user-select:none;display:flex;align-items:center;position:relative;text-decoration:none;overflow:hidden}.p-tabmenu-nav a:focus{z-index:1}.p-tabmenu-nav .p-menuitem-text{line-height:1;white-space:nowrap}.p-tabmenu-ink-bar{display:none;z-index:1}.p-tabmenu-nav-content::-webkit-scrollbar{display:none}.p-tabmenuitem:not(.p-hidden){display:flex}}\n"], dependencies: [{ kind: "directive", type: i0.forwardRef(() => i2.NgClass), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i0.forwardRef(() => i2.NgForOf), selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i0.forwardRef(() => i2.NgIf), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i0.forwardRef(() => i2.NgTemplateOutlet), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i0.forwardRef(() => i2.NgStyle), selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i0.forwardRef(() => i1.RouterLink), selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i0.forwardRef(() => i1.RouterLinkActive), selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "ariaCurrentWhenActive", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }, { kind: "directive", type: i0.forwardRef(() => i3.Ripple), selector: "[pRipple]" }, { kind: "directive", type: i0.forwardRef(() => i4.Tooltip), selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "component", type: i0.forwardRef(() => ChevronLeftIcon), selector: "ChevronLeftIcon" }, { kind: "component", type: i0.forwardRef(() => ChevronRightIcon), selector: "ChevronRightIcon" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
||
|
}
|
||
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TabMenu, decorators: [{
|
||
|
type: Component,
|
||
|
args: [{ selector: 'p-tabMenu', template: `
|
||
|
<div [ngClass]="{ 'p-tabmenu p-component': true, 'p-tabmenu-scrollable': scrollable }" [ngStyle]="style" [class]="styleClass">
|
||
|
<div class="p-tabmenu-nav-container">
|
||
|
<button *ngIf="scrollable && !backwardIsDisabled" #prevBtn class="p-tabmenu-nav-prev p-tabmenu-nav-btn p-link" (click)="navBackward()" type="button" role="navigation" pRipple>
|
||
|
<ChevronLeftIcon *ngIf="!previousIconTemplate" [attr.aria-hidden]="true" />
|
||
|
<ng-template *ngTemplateOutlet="previousIconTemplate"></ng-template>
|
||
|
</button>
|
||
|
<div #content class="p-tabmenu-nav-content" (scroll)="onScroll($event)">
|
||
|
<ul #navbar class="p-tabmenu-nav p-reset" role="menubar" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-label]="ariaLabel">
|
||
|
<li
|
||
|
#tab
|
||
|
*ngFor="let item of focusableItems; let i = index"
|
||
|
role="presentation"
|
||
|
[ngStyle]="item.style"
|
||
|
[class]="item.styleClass"
|
||
|
[attr.data-p-disabled]="disabled(item)"
|
||
|
[attr.data-p-highlight]="focusedItemInfo() === item"
|
||
|
(click)="itemClick($event, item)"
|
||
|
(keydown)="onKeydownItem($event, i, item)"
|
||
|
(focus)="onMenuItemFocus(item)"
|
||
|
[ngClass]="{ 'p-tabmenuitem': true, 'p-disabled': getItemProp(item, 'disabled'), 'p-highlight': isActive(item), 'p-hidden': item.visible === false }"
|
||
|
pTooltip
|
||
|
[tooltipOptions]="item.tooltipOptions"
|
||
|
>
|
||
|
<a
|
||
|
#tabLink
|
||
|
*ngIf="!item.routerLink && !itemTemplate"
|
||
|
class="p-menuitem-link"
|
||
|
role="menuitem"
|
||
|
[attr.href]="getItemProp(item, 'url')"
|
||
|
[attr.id]="getItemProp(item, 'id')"
|
||
|
[attr.aria-disabled]="disabled(item)"
|
||
|
[attr.aria-label]="getItemProp(item, 'label')"
|
||
|
[attr.tabindex]="disabled(item) ? -1 : 0"
|
||
|
[target]="getItemProp(item, 'target')"
|
||
|
pRipple
|
||
|
>
|
||
|
<ng-container>
|
||
|
<span class="p-menuitem-icon" [ngClass]="item.icon" *ngIf="item.icon" [ngStyle]="item.iconStyle"></span>
|
||
|
<span class="p-menuitem-text" *ngIf="item.escape !== false; else htmlLabel">{{ getItemProp(item, 'label') }}</span>
|
||
|
<ng-template #htmlLabel><span class="p-menuitem-text" [innerHTML]="getItemProp(item, 'label')"></span></ng-template>
|
||
|
<span class="p-menuitem-badge" *ngIf="item.badge" [ngClass]="item.badgeStyleClass">{{ getItemProp(item, 'badge') }}</span>
|
||
|
</ng-container>
|
||
|
</a>
|
||
|
<a
|
||
|
#tabLink
|
||
|
*ngIf="item.routerLink && !itemTemplate"
|
||
|
[routerLink]="item.routerLink"
|
||
|
[queryParams]="item.queryParams"
|
||
|
[routerLinkActive]="'p-menuitem-link-active'"
|
||
|
[routerLinkActiveOptions]="item.routerLinkActiveOptions || { exact: false }"
|
||
|
role="menuitem"
|
||
|
class="p-menuitem-link"
|
||
|
[target]="item.target"
|
||
|
[attr.id]="getItemProp(item, 'id')"
|
||
|
[attr.aria-disabled]="disabled(item)"
|
||
|
[attr.aria-label]="getItemProp(item, 'label')"
|
||
|
[attr.tabindex]="disabled(item) ? -1 : 0"
|
||
|
[fragment]="item.fragment"
|
||
|
[queryParamsHandling]="item.queryParamsHandling"
|
||
|
[preserveFragment]="item.preserveFragment"
|
||
|
[skipLocationChange]="item.skipLocationChange"
|
||
|
[replaceUrl]="item.replaceUrl"
|
||
|
[state]="item.state"
|
||
|
pRipple
|
||
|
>
|
||
|
<ng-container>
|
||
|
<span class="p-menuitem-icon" [attr.aria-hidden]="true" [ngClass]="item.icon" *ngIf="item.icon" [ngStyle]="item.iconStyle"></span>
|
||
|
<span class="p-menuitem-text" *ngIf="item.escape !== false; else htmlRouteLabel">{{ getItemProp(item, 'label') }}</span>
|
||
|
<ng-template #htmlRouteLabel><span class="p-menuitem-text" [innerHTML]="getItemProp(item, 'label')"></span></ng-template>
|
||
|
<span class="p-menuitem-badge" *ngIf="item.badge" [ngClass]="item.badgeStyleClass">{{ getItemProp(item, 'badge') }}</span>
|
||
|
</ng-container>
|
||
|
</a>
|
||
|
<ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item, index: i }"></ng-container>
|
||
|
</li>
|
||
|
<li #inkbar class="p-tabmenu-ink-bar" role="none"></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<button *ngIf="scrollable && !forwardIsDisabled" #nextBtn class="p-tabmenu-nav-next p-tabmenu-nav-btn p-link" (click)="navForward()" type="button" role="navigation" pRipple>
|
||
|
<ChevronRightIcon *ngIf="!previousIconTemplate" [attr.aria-hidden]="true" />
|
||
|
<ng-template *ngTemplateOutlet="nextIconTemplate"></ng-template>
|
||
|
</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
||
|
class: 'p-element'
|
||
|
}, styles: ["@layer primeng{.p-tabmenu-nav-container{position:relative}.p-tabmenu-scrollable .p-tabmenu-nav-container{overflow:hidden}.p-tabmenu-nav-content{overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scrollbar-width:none;overscroll-behavior:contain auto}.p-tabmenu-nav-btn{position:absolute;top:0;z-index:2;height:100%;display:flex;align-items:center;justify-content:center}.p-tabmenu-nav-prev{left:0}.p-tabmenu-nav-next{right:0}.p-tabview-nav-content::-webkit-scrollbar{display:none}.p-tabmenu-nav{display:flex;margin:0;padding:0;list-style-type:none;flex-wrap:nowrap}.p-tabmenu-nav a{cursor:pointer;-webkit-user-select:none;user-select:none;display:flex;align-items:center;position:relative;text-decoration:none;overflow:hidden}.p-tabmenu-nav a:focus{z-index:1}.p-tabmenu-nav .p-menuitem-text{line-height:1;white-space:nowrap}.p-tabmenu-ink-bar{display:none;z-index:1}.p-tabmenu-nav-content::-webkit-scrollbar{display:none}.p-tabmenuitem:not(.p-hidden){display:flex}}\n"] }]
|
||
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
||
|
type: Inject,
|
||
|
args: [PLATFORM_ID]
|
||
|
}] }, { type: i1.Router }, { type: i1.ActivatedRoute }, { type: i0.ChangeDetectorRef }], propDecorators: { model: [{
|
||
|
type: Input
|
||
|
}], activeItem: [{
|
||
|
type: Input
|
||
|
}], scrollable: [{
|
||
|
type: Input,
|
||
|
args: [{ transform: booleanAttribute }]
|
||
|
}], popup: [{
|
||
|
type: Input,
|
||
|
args: [{ transform: booleanAttribute }]
|
||
|
}], style: [{
|
||
|
type: Input
|
||
|
}], styleClass: [{
|
||
|
type: Input
|
||
|
}], ariaLabel: [{
|
||
|
type: Input
|
||
|
}], ariaLabelledBy: [{
|
||
|
type: Input
|
||
|
}], activeItemChange: [{
|
||
|
type: Output
|
||
|
}], content: [{
|
||
|
type: ViewChild,
|
||
|
args: ['content']
|
||
|
}], navbar: [{
|
||
|
type: ViewChild,
|
||
|
args: ['navbar']
|
||
|
}], inkbar: [{
|
||
|
type: ViewChild,
|
||
|
args: ['inkbar']
|
||
|
}], prevBtn: [{
|
||
|
type: ViewChild,
|
||
|
args: ['prevBtn']
|
||
|
}], nextBtn: [{
|
||
|
type: ViewChild,
|
||
|
args: ['nextBtn']
|
||
|
}], tabLink: [{
|
||
|
type: ViewChildren,
|
||
|
args: ['tabLink']
|
||
|
}], tab: [{
|
||
|
type: ViewChildren,
|
||
|
args: ['tab']
|
||
|
}], templates: [{
|
||
|
type: ContentChildren,
|
||
|
args: [PrimeTemplate]
|
||
|
}] } });
|
||
|
class TabMenuModule {
|
||
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TabMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
||
|
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: TabMenuModule, declarations: [TabMenu], imports: [CommonModule, RouterModule, SharedModule, RippleModule, TooltipModule, ChevronLeftIcon, ChevronRightIcon], exports: [TabMenu, RouterModule, SharedModule, TooltipModule] });
|
||
|
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TabMenuModule, imports: [CommonModule, RouterModule, SharedModule, RippleModule, TooltipModule, ChevronLeftIcon, ChevronRightIcon, RouterModule, SharedModule, TooltipModule] });
|
||
|
}
|
||
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: TabMenuModule, decorators: [{
|
||
|
type: NgModule,
|
||
|
args: [{
|
||
|
imports: [CommonModule, RouterModule, SharedModule, RippleModule, TooltipModule, ChevronLeftIcon, ChevronRightIcon],
|
||
|
exports: [TabMenu, RouterModule, SharedModule, TooltipModule],
|
||
|
declarations: [TabMenu]
|
||
|
}]
|
||
|
}] });
|
||
|
|
||
|
/**
|
||
|
* Generated bundle index. Do not edit.
|
||
|
*/
|
||
|
|
||
|
export { TabMenu, TabMenuModule };
|
||
|
//# sourceMappingURL=primeng-tabmenu.mjs.map
|