Icard/angular-clarity-master(work.../node_modules/primeng/fesm2022/primeng-dock.mjs

444 lines
24 KiB
JavaScript
Raw Permalink Normal View History

2024-07-16 15:23:22 +00:00
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ContentChildren, ViewChild, NgModule } from '@angular/core';
import * as i2 from '@angular/router';
import { RouterModule } from '@angular/router';
import { PrimeTemplate, SharedModule } from 'primeng/api';
import * as i3 from 'primeng/ripple';
import { RippleModule } from 'primeng/ripple';
import * as i4 from 'primeng/tooltip';
import { TooltipModule } from 'primeng/tooltip';
import { UniqueComponentId, ObjectUtils } from 'primeng/utils';
import { DomHandler } from 'primeng/dom';
/**
* Dock is a navigation component consisting of menuitems.
* @group Components
*/
class Dock {
el;
cd;
/**
* Current id state as a string.
* @group Props
*/
id;
/**
* Inline style of the element.
* @group Props
*/
style;
/**
* Class of the element.
* @group Props
*/
styleClass;
/**
* MenuModel instance to define the action items.
* @group Props
*/
model = null;
/**
* Position of element.
* @group Props
*/
position = 'bottom';
/**
* Defines a string that labels the input for accessibility.
* @group Props
*/
ariaLabel;
/**
* Defines a string that labels the dropdown button for accessibility.
* @group Props
*/
ariaLabelledBy;
/**
* Callback to execute when button is focused.
* @param {FocusEvent} event - Focus event.
* @group Emits
*/
onFocus = new EventEmitter();
/**
* Callback to invoke when the component loses focus.
* @param {FocusEvent} event - Focus event.
* @group Emits
*/
onBlur = new EventEmitter();
templates;
listViewChild;
itemTemplate;
currentIndex;
tabindex = 0;
focused = false;
focusedOptionIndex = -1;
get focusedOptionId() {
return this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : null;
}
constructor(el, cd) {
this.el = el;
this.cd = cd;
this.currentIndex = -3;
}
ngOnInit() {
this.id = this.id || UniqueComponentId();
}
ngAfterContentInit() {
this.templates?.forEach((item) => {
switch (item.getType()) {
case 'item':
this.itemTemplate = item.template;
break;
default:
this.itemTemplate = item.template;
break;
}
});
}
getItemId(item, index) {
return item && item?.id ? item.id : `${index}`;
}
getItemProp(processedItem, name) {
return processedItem && processedItem.item ? ObjectUtils.getItemValue(processedItem.item[name]) : undefined;
}
disabled(item) {
return typeof item.disabled === 'function' ? item.disabled() : item.disabled;
}
isItemActive(id) {
return id === this.focusedOptionIndex;
}
onListMouseLeave() {
this.currentIndex = -3;
this.cd.markForCheck();
}
onItemMouseEnter(index) {
this.currentIndex = index;
if (index === 1) {
}
this.cd.markForCheck();
}
onItemClick(e, item) {
if (item.command) {
item.command({ originalEvent: e, item });
}
}
onListFocus(event) {
this.focused = true;
this.changeFocusedOptionIndex(0);
this.onFocus.emit(event);
}
onListBlur(event) {
this.focused = false;
this.focusedOptionIndex = -1;
this.onBlur.emit(event);
}
onListKeyDown(event) {
switch (event.code) {
case 'ArrowDown': {
if (this.position === 'left' || this.position === 'right')
this.onArrowDownKey();
event.preventDefault();
break;
}
case 'ArrowUp': {
if (this.position === 'left' || this.position === 'right')
this.onArrowUpKey();
event.preventDefault();
break;
}
case 'ArrowRight': {
if (this.position === 'top' || this.position === 'bottom')
this.onArrowDownKey();
event.preventDefault();
break;
}
case 'ArrowLeft': {
if (this.position === 'top' || this.position === 'bottom')
this.onArrowUpKey();
event.preventDefault();
break;
}
case 'Home': {
this.onHomeKey();
event.preventDefault();
break;
}
case 'End': {
this.onEndKey();
event.preventDefault();
break;
}
case 'Enter':
case 'Space': {
this.onSpaceKey();
event.preventDefault();
break;
}
default:
break;
}
}
onArrowDownKey() {
const optionIndex = this.findNextOptionIndex(this.focusedOptionIndex);
this.changeFocusedOptionIndex(optionIndex);
}
onArrowUpKey() {
const optionIndex = this.findPrevOptionIndex(this.focusedOptionIndex);
this.changeFocusedOptionIndex(optionIndex);
}
onHomeKey() {
this.changeFocusedOptionIndex(0);
}
onEndKey() {
this.changeFocusedOptionIndex(DomHandler.find(this.listViewChild.nativeElement, 'li[data-pc-section="menuitem"][data-p-disabled="false"]').length - 1);
}
onSpaceKey() {
const element = DomHandler.findSingle(this.listViewChild.nativeElement, `li[id="${`${this.focusedOptionIndex}`}"]`);
const anchorElement = element && DomHandler.findSingle(element, '[data-pc-section="action"]');
anchorElement ? anchorElement.click() : element && element.click();
}
findNextOptionIndex(index) {
const menuitems = DomHandler.find(this.listViewChild.nativeElement, 'li[data-pc-section="menuitem"][data-p-disabled="false"]');
const matchedOptionIndex = [...menuitems].findIndex((link) => link.id === index);
return matchedOptionIndex > -1 ? matchedOptionIndex + 1 : 0;
}
changeFocusedOptionIndex(index) {
const menuitems = DomHandler.find(this.listViewChild.nativeElement, 'li[data-pc-section="menuitem"][data-p-disabled="false"]');
let order = index >= menuitems.length ? menuitems.length - 1 : index < 0 ? 0 : index;
this.focusedOptionIndex = menuitems[order].getAttribute('id');
}
findPrevOptionIndex(index) {
const menuitems = DomHandler.find(this.listViewChild.nativeElement, 'li[data-pc-section="menuitem"][data-p-disabled="false"]');
const matchedOptionIndex = [...menuitems].findIndex((link) => link.id === index);
return matchedOptionIndex > -1 ? matchedOptionIndex - 1 : 0;
}
get containerClass() {
return {
['p-dock p-component ' + ` p-dock-${this.position}`]: true
};
}
isClickableRouterLink(item) {
return item.routerLink && !item.disabled;
}
itemClass(item, index) {
return {
'p-dock-item': true,
'p-dock-item-second-prev': this.currentIndex - 2 === index,
'p-dock-item-prev': this.currentIndex - 1 === index,
'p-dock-item-current': this.currentIndex === index,
'p-dock-item-next': this.currentIndex + 1 === index,
'p-dock-item-second-next': this.currentIndex + 2 === index,
'p-focus': this.isItemActive(this.getItemId(item, index))
};
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Dock, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.7", type: Dock, selector: "p-dock", inputs: { id: "id", style: "style", styleClass: "styleClass", model: "model", position: "position", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy" }, outputs: { onFocus: "onFocus", onBlur: "onBlur" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "listViewChild", first: true, predicate: ["list"], descendants: true }], ngImport: i0, template: `
<div [ngClass]="containerClass" [ngStyle]="style" [class]="styleClass" [attr.data-pc-name]="'dock'">
<div class="p-dock-list-container">
<ul
#list
[attr.id]="id"
class="p-dock-list"
role="menu"
[attr.aria-orientation]="position === 'bottom' || position === 'top' ? 'horizontal' : 'vertical'"
[attr.aria-activedescendant]="focused ? focusedOptionId : undefined"
[tabindex]="tabindex"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledby]="ariaLabelledBy"
[attr.data-pc-section]="'menu'"
(focus)="onListFocus($event)"
(blur)="onListBlur($event)"
(keydown)="onListKeyDown($event)"
(mouseleave)="onListMouseLeave()"
>
<li
*ngFor="let item of model; let i = index"
[attr.id]="getItemId(item, i)"
[ngClass]="itemClass(item, i)"
role="menuitem"
[attr.aria-label]="item.label"
[attr.aria-disabled]="disabled(item)"
(click)="onItemClick($event, item)"
(mouseenter)="onItemMouseEnter(i)"
[attr.data-pc-section]="'menuitem'"
[attr.data-p-focused]="isItemActive(getItemId(item, i))"
[attr.data-p-disabled]="disabled(item) || false"
>
<div class="p-menuitem-content" [attr.data-pc-section]="'content'">
<a
*ngIf="isClickableRouterLink(item); else elseBlock"
pRipple
[routerLink]="item.routerLink"
[queryParams]="item.queryParams"
[ngClass]="{ 'p-disabled': item.disabled }"
class="p-dock-link"
[routerLinkActiveOptions]="item.routerLinkActiveOptions || { exact: false }"
[target]="item.target"
[attr.tabindex]="item.disabled || readonly ? null : item.tabindex ? item.tabindex : '-1'"
pTooltip
[tooltipOptions]="item.tooltipOptions"
[fragment]="item.fragment"
[queryParamsHandling]="item.queryParamsHandling"
[preserveFragment]="item.preserveFragment"
[skipLocationChange]="item.skipLocationChange"
[replaceUrl]="item.replaceUrl"
[state]="item.state"
[attr.aria-hidden]="true"
>
<span class="p-dock-action-icon" *ngIf="item.icon && !itemTemplate" [ngClass]="item.icon" [ngStyle]="item.iconStyle"></span>
<ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item }"></ng-container>
</a>
<ng-template #elseBlock>
<a
[tooltipPosition]="item.tooltipPosition"
[attr.href]="item.url || null"
class="p-dock-link"
pRipple
pTooltip
[tooltipOptions]="item.tooltipOptions"
[ngClass]="{ 'p-disabled': item.disabled }"
[target]="item.target"
[attr.tabindex]="item.disabled || (i !== activeIndex && readonly) ? null : item.tabindex ? item.tabindex : '-1'"
[attr.aria-hidden]="true"
>
<span class="p-dock-action-icon" *ngIf="item.icon && !itemTemplate" [ngClass]="item.icon" [ngStyle]="item.iconStyle"></span>
<ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item }"></ng-container>
</a>
</ng-template>
</div>
</li>
</ul>
</div>
</div>
`, isInline: true, styles: ["@layer primeng{.p-dock{position:absolute;z-index:1;display:flex;justify-content:center;align-items:center;pointer-events:none}.p-dock-list-container{display:flex;pointer-events:auto}.p-dock-list{margin:0;padding:0;list-style:none;display:flex;align-items:center;justify-content:center}.p-dock-item{transition:all .2s cubic-bezier(.4,0,.2,1);will-change:transform}.p-dock-link{display:flex;flex-direction:column;align-items:center;justify-content:center;position:relative;overflow:hidden;cursor:default}.p-dock-item-second-prev,.p-dock-item-second-next{transform:scale(1.2)}.p-dock-item-prev,.p-dock-item-next{transform:scale(1.4)}.p-dock-item-current{transform:scale(1.6);z-index:1}.p-dock-top{left:0;top:0;width:100%}.p-dock-top .p-dock-item{transform-origin:center top}.p-dock-bottom{left:0;bottom:0;width:100%}.p-dock-bottom .p-dock-item{transform-origin:center bottom}.p-dock-right{right:0;top:0;height:100%}.p-dock-right .p-dock-item{transform-origin:center right}.p-dock-right .p-dock-list{flex-direction:column}.p-dock-left{left:0;top:0;height:100%}.p-dock-left .p-dock-item{transform-origin:center left}.p-dock-left .p-dock-list{flex-direction:column}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i3.Ripple, selector: "[pRipple]" }, { kind: "directive", type: i4.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Dock, decorators: [{
type: Component,
args: [{ selector: 'p-dock', template: `
<div [ngClass]="containerClass" [ngStyle]="style" [class]="styleClass" [attr.data-pc-name]="'dock'">
<div class="p-dock-list-container">
<ul
#list
[attr.id]="id"
class="p-dock-list"
role="menu"
[attr.aria-orientation]="position === 'bottom' || position === 'top' ? 'horizontal' : 'vertical'"
[attr.aria-activedescendant]="focused ? focusedOptionId : undefined"
[tabindex]="tabindex"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledby]="ariaLabelledBy"
[attr.data-pc-section]="'menu'"
(focus)="onListFocus($event)"
(blur)="onListBlur($event)"
(keydown)="onListKeyDown($event)"
(mouseleave)="onListMouseLeave()"
>
<li
*ngFor="let item of model; let i = index"
[attr.id]="getItemId(item, i)"
[ngClass]="itemClass(item, i)"
role="menuitem"
[attr.aria-label]="item.label"
[attr.aria-disabled]="disabled(item)"
(click)="onItemClick($event, item)"
(mouseenter)="onItemMouseEnter(i)"
[attr.data-pc-section]="'menuitem'"
[attr.data-p-focused]="isItemActive(getItemId(item, i))"
[attr.data-p-disabled]="disabled(item) || false"
>
<div class="p-menuitem-content" [attr.data-pc-section]="'content'">
<a
*ngIf="isClickableRouterLink(item); else elseBlock"
pRipple
[routerLink]="item.routerLink"
[queryParams]="item.queryParams"
[ngClass]="{ 'p-disabled': item.disabled }"
class="p-dock-link"
[routerLinkActiveOptions]="item.routerLinkActiveOptions || { exact: false }"
[target]="item.target"
[attr.tabindex]="item.disabled || readonly ? null : item.tabindex ? item.tabindex : '-1'"
pTooltip
[tooltipOptions]="item.tooltipOptions"
[fragment]="item.fragment"
[queryParamsHandling]="item.queryParamsHandling"
[preserveFragment]="item.preserveFragment"
[skipLocationChange]="item.skipLocationChange"
[replaceUrl]="item.replaceUrl"
[state]="item.state"
[attr.aria-hidden]="true"
>
<span class="p-dock-action-icon" *ngIf="item.icon && !itemTemplate" [ngClass]="item.icon" [ngStyle]="item.iconStyle"></span>
<ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item }"></ng-container>
</a>
<ng-template #elseBlock>
<a
[tooltipPosition]="item.tooltipPosition"
[attr.href]="item.url || null"
class="p-dock-link"
pRipple
pTooltip
[tooltipOptions]="item.tooltipOptions"
[ngClass]="{ 'p-disabled': item.disabled }"
[target]="item.target"
[attr.tabindex]="item.disabled || (i !== activeIndex && readonly) ? null : item.tabindex ? item.tabindex : '-1'"
[attr.aria-hidden]="true"
>
<span class="p-dock-action-icon" *ngIf="item.icon && !itemTemplate" [ngClass]="item.icon" [ngStyle]="item.iconStyle"></span>
<ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item }"></ng-container>
</a>
</ng-template>
</div>
</li>
</ul>
</div>
</div>
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
class: 'p-element'
}, styles: ["@layer primeng{.p-dock{position:absolute;z-index:1;display:flex;justify-content:center;align-items:center;pointer-events:none}.p-dock-list-container{display:flex;pointer-events:auto}.p-dock-list{margin:0;padding:0;list-style:none;display:flex;align-items:center;justify-content:center}.p-dock-item{transition:all .2s cubic-bezier(.4,0,.2,1);will-change:transform}.p-dock-link{display:flex;flex-direction:column;align-items:center;justify-content:center;position:relative;overflow:hidden;cursor:default}.p-dock-item-second-prev,.p-dock-item-second-next{transform:scale(1.2)}.p-dock-item-prev,.p-dock-item-next{transform:scale(1.4)}.p-dock-item-current{transform:scale(1.6);z-index:1}.p-dock-top{left:0;top:0;width:100%}.p-dock-top .p-dock-item{transform-origin:center top}.p-dock-bottom{left:0;bottom:0;width:100%}.p-dock-bottom .p-dock-item{transform-origin:center bottom}.p-dock-right{right:0;top:0;height:100%}.p-dock-right .p-dock-item{transform-origin:center right}.p-dock-right .p-dock-list{flex-direction:column}.p-dock-left{left:0;top:0;height:100%}.p-dock-left .p-dock-item{transform-origin:center left}.p-dock-left .p-dock-list{flex-direction:column}}\n"] }]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], propDecorators: { id: [{
type: Input
}], style: [{
type: Input
}], styleClass: [{
type: Input
}], model: [{
type: Input
}], position: [{
type: Input
}], ariaLabel: [{
type: Input
}], ariaLabelledBy: [{
type: Input
}], onFocus: [{
type: Output
}], onBlur: [{
type: Output
}], templates: [{
type: ContentChildren,
args: [PrimeTemplate]
}], listViewChild: [{
type: ViewChild,
args: ['list', { static: false }]
}] } });
class DockModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: DockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: DockModule, declarations: [Dock], imports: [CommonModule, RouterModule, RippleModule, TooltipModule], exports: [Dock, SharedModule, TooltipModule, RouterModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: DockModule, imports: [CommonModule, RouterModule, RippleModule, TooltipModule, SharedModule, TooltipModule, RouterModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: DockModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule, RouterModule, RippleModule, TooltipModule],
exports: [Dock, SharedModule, TooltipModule, RouterModule],
declarations: [Dock]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { Dock, DockModule };
//# sourceMappingURL=primeng-dock.mjs.map