399 lines
19 KiB
JavaScript
399 lines
19 KiB
JavaScript
|
import { trigger, state, style, transition, animate } from '@angular/animations';
|
||
|
import * as i1 from '@angular/common';
|
||
|
import { CommonModule } from '@angular/common';
|
||
|
import * as i0 from '@angular/core';
|
||
|
import { EventEmitter, booleanAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ContentChild, ContentChildren, NgModule } from '@angular/core';
|
||
|
import { Footer, PrimeTemplate, SharedModule } from 'primeng/api';
|
||
|
import { MinusIcon } from 'primeng/icons/minus';
|
||
|
import { PlusIcon } from 'primeng/icons/plus';
|
||
|
import * as i2 from 'primeng/ripple';
|
||
|
import { RippleModule } from 'primeng/ripple';
|
||
|
import { UniqueComponentId } from 'primeng/utils';
|
||
|
|
||
|
/**
|
||
|
* Panel is a container with the optional content toggle feature.
|
||
|
* @group Components
|
||
|
*/
|
||
|
class Panel {
|
||
|
el;
|
||
|
/**
|
||
|
* Defines if content of panel can be expanded and collapsed.
|
||
|
* @group Props
|
||
|
*/
|
||
|
toggleable;
|
||
|
/**
|
||
|
* Header text of the panel.
|
||
|
* @group Props
|
||
|
*/
|
||
|
header;
|
||
|
/**
|
||
|
* Defines the initial state of panel content, supports one or two-way binding as well.
|
||
|
* @group Props
|
||
|
*/
|
||
|
collapsed;
|
||
|
/**
|
||
|
* Inline style of the component.
|
||
|
* @group Props
|
||
|
*/
|
||
|
style;
|
||
|
/**
|
||
|
* Style class of the component.
|
||
|
* @group Props
|
||
|
*/
|
||
|
styleClass;
|
||
|
/**
|
||
|
* Position of the icons.
|
||
|
* @group Props
|
||
|
*/
|
||
|
iconPos = 'end';
|
||
|
/**
|
||
|
* Expand icon of the toggle button.
|
||
|
* @group Props
|
||
|
* @deprecated since v15.4.2, use `headericons` template instead.
|
||
|
*/
|
||
|
expandIcon;
|
||
|
/**
|
||
|
* Collapse icon of the toggle button.
|
||
|
* @group Props
|
||
|
* @deprecated since v15.4.2, use `headericons` template instead.
|
||
|
*/
|
||
|
collapseIcon;
|
||
|
/**
|
||
|
* Specifies if header of panel cannot be displayed.
|
||
|
* @group Props
|
||
|
* @deprecated since v15.4.2, use `headericons` template instead.
|
||
|
*/
|
||
|
showHeader = true;
|
||
|
/**
|
||
|
* Specifies the toggler element to toggle the panel content.
|
||
|
* @group Props
|
||
|
*/
|
||
|
toggler = 'icon';
|
||
|
/**
|
||
|
* Transition options of the animation.
|
||
|
* @group Props
|
||
|
*/
|
||
|
transitionOptions = '400ms cubic-bezier(0.86, 0, 0.07, 1)';
|
||
|
/**
|
||
|
* Emitted when the collapsed changes.
|
||
|
* @param {boolean} value - New Value.
|
||
|
* @group Emits
|
||
|
*/
|
||
|
collapsedChange = new EventEmitter();
|
||
|
/**
|
||
|
* Callback to invoke before panel toggle.
|
||
|
* @param {PanelBeforeToggleEvent} event - Custom panel toggle event
|
||
|
* @group Emits
|
||
|
*/
|
||
|
onBeforeToggle = new EventEmitter();
|
||
|
/**
|
||
|
* Callback to invoke after panel toggle.
|
||
|
* @param {PanelAfterToggleEvent} event - Custom panel toggle event
|
||
|
* @group Emits
|
||
|
*/
|
||
|
onAfterToggle = new EventEmitter();
|
||
|
footerFacet;
|
||
|
templates;
|
||
|
iconTemplate;
|
||
|
animating;
|
||
|
headerTemplate;
|
||
|
contentTemplate;
|
||
|
footerTemplate;
|
||
|
headerIconTemplate;
|
||
|
id = UniqueComponentId();
|
||
|
get buttonAriaLabel() {
|
||
|
return this.header;
|
||
|
}
|
||
|
constructor(el) {
|
||
|
this.el = el;
|
||
|
}
|
||
|
ngAfterContentInit() {
|
||
|
this.templates.forEach((item) => {
|
||
|
switch (item.getType()) {
|
||
|
case 'header':
|
||
|
this.headerTemplate = item.template;
|
||
|
break;
|
||
|
case 'content':
|
||
|
this.contentTemplate = item.template;
|
||
|
break;
|
||
|
case 'footer':
|
||
|
this.footerTemplate = item.template;
|
||
|
break;
|
||
|
case 'icons':
|
||
|
this.iconTemplate = item.template;
|
||
|
break;
|
||
|
case 'headericons':
|
||
|
this.headerIconTemplate = item.template;
|
||
|
break;
|
||
|
default:
|
||
|
this.contentTemplate = item.template;
|
||
|
break;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
onHeaderClick(event) {
|
||
|
if (this.toggler === 'header') {
|
||
|
this.toggle(event);
|
||
|
}
|
||
|
}
|
||
|
onIconClick(event) {
|
||
|
if (this.toggler === 'icon') {
|
||
|
this.toggle(event);
|
||
|
}
|
||
|
}
|
||
|
toggle(event) {
|
||
|
if (this.animating) {
|
||
|
return false;
|
||
|
}
|
||
|
this.animating = true;
|
||
|
this.onBeforeToggle.emit({ originalEvent: event, collapsed: this.collapsed });
|
||
|
if (this.toggleable) {
|
||
|
if (this.collapsed)
|
||
|
this.expand();
|
||
|
else
|
||
|
this.collapse();
|
||
|
}
|
||
|
event.preventDefault();
|
||
|
}
|
||
|
expand() {
|
||
|
this.collapsed = false;
|
||
|
this.collapsedChange.emit(this.collapsed);
|
||
|
}
|
||
|
collapse() {
|
||
|
this.collapsed = true;
|
||
|
this.collapsedChange.emit(this.collapsed);
|
||
|
}
|
||
|
getBlockableElement() {
|
||
|
return this.el.nativeElement.children[0];
|
||
|
}
|
||
|
onKeyDown(event) {
|
||
|
if (event.code === 'Enter' || event.code === 'Space') {
|
||
|
this.toggle(event);
|
||
|
event.preventDefault();
|
||
|
}
|
||
|
}
|
||
|
onToggleDone(event) {
|
||
|
this.animating = false;
|
||
|
this.onAfterToggle.emit({ originalEvent: event, collapsed: this.collapsed });
|
||
|
}
|
||
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Panel, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
||
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: Panel, selector: "p-panel", inputs: { toggleable: ["toggleable", "toggleable", booleanAttribute], header: "header", collapsed: ["collapsed", "collapsed", booleanAttribute], style: "style", styleClass: "styleClass", iconPos: "iconPos", expandIcon: "expandIcon", collapseIcon: "collapseIcon", showHeader: ["showHeader", "showHeader", booleanAttribute], toggler: "toggler", transitionOptions: "transitionOptions" }, outputs: { collapsedChange: "collapsedChange", onBeforeToggle: "onBeforeToggle", onAfterToggle: "onAfterToggle" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "footerFacet", first: true, predicate: Footer, descendants: true }, { propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: `
|
||
|
<div [attr.id]="id" [attr.data-pc-name]="'panel'" [ngClass]="{ 'p-panel p-component': true, 'p-panel-toggleable': toggleable, 'p-panel-expanded': !collapsed && toggleable }" [ngStyle]="style" [class]="styleClass">
|
||
|
<div class="p-panel-header" *ngIf="showHeader" (click)="onHeaderClick($event)" [attr.id]="id + '-titlebar'">
|
||
|
<span class="p-panel-title" *ngIf="header" [attr.id]="id + '_header'">{{ header }}</span>
|
||
|
<ng-content select="p-header"></ng-content>
|
||
|
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
||
|
<div class="p-panel-icons" [ngClass]="{ 'p-panel-icons-start': iconPos === 'start', 'p-panel-icons-end': iconPos === 'end', 'p-panel-icons-center': iconPos === 'center' }">
|
||
|
<ng-template *ngTemplateOutlet="iconTemplate"></ng-template>
|
||
|
<button
|
||
|
*ngIf="toggleable"
|
||
|
[attr.id]="id + '_header'"
|
||
|
pRipple
|
||
|
type="button"
|
||
|
role="button"
|
||
|
class="p-panel-header-icon p-panel-toggler p-link"
|
||
|
[attr.aria-label]="buttonAriaLabel"
|
||
|
[attr.aria-controls]="id + '_content'"
|
||
|
[attr.aria-expanded]="!collapsed"
|
||
|
(click)="onIconClick($event)"
|
||
|
(keydown)="onKeyDown($event)"
|
||
|
>
|
||
|
<ng-container *ngIf="!headerIconTemplate">
|
||
|
<ng-container *ngIf="!collapsed">
|
||
|
<span *ngIf="expandIcon" [class]="expandIcon" [ngClass]="iconClass"></span>
|
||
|
<MinusIcon *ngIf="!expandIcon" [styleClass]="iconClass" />
|
||
|
</ng-container>
|
||
|
|
||
|
<ng-container *ngIf="collapsed">
|
||
|
<span *ngIf="collapseIcon" [class]="collapseIcon" [ngClass]="iconClass"></span>
|
||
|
<PlusIcon *ngIf="!collapseIcon" [styleClass]="iconClass" />
|
||
|
</ng-container>
|
||
|
</ng-container>
|
||
|
|
||
|
<ng-template *ngTemplateOutlet="headerIconTemplate; context: { $implicit: collapsed }"></ng-template>
|
||
|
</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div
|
||
|
class="p-toggleable-content"
|
||
|
[id]="id + '_content'"
|
||
|
role="region"
|
||
|
[attr.aria-labelledby]="id + '_header'"
|
||
|
[attr.aria-hidden]="collapsed"
|
||
|
[attr.tabindex]="collapsed ? '-1' : undefined"
|
||
|
[@panelContent]="
|
||
|
collapsed
|
||
|
? { value: 'hidden', params: { transitionParams: animating ? transitionOptions : '0ms', height: '0', opacity: '0' } }
|
||
|
: { value: 'visible', params: { transitionParams: animating ? transitionOptions : '0ms', height: '*', opacity: '1' } }
|
||
|
"
|
||
|
(@panelContent.done)="onToggleDone($event)"
|
||
|
>
|
||
|
<div class="p-panel-content">
|
||
|
<ng-content></ng-content>
|
||
|
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
|
||
|
</div>
|
||
|
|
||
|
<div class="p-panel-footer" *ngIf="footerFacet || footerTemplate">
|
||
|
<ng-content select="p-footer"></ng-content>
|
||
|
<ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
`, isInline: true, styles: ["@layer primeng{.p-panel-header{display:flex;align-items:center}.p-panel-title{line-height:1;order:1}.p-panel-header-icon{display:inline-flex;justify-content:center;align-items:center;cursor:pointer;text-decoration:none;overflow:hidden;position:relative}.p-panel-toggleable.p-panel-expanded>.p-toggleable-content:not(.ng-animating){overflow:visible}.p-panel-toggleable .p-toggleable-content{overflow:hidden}}\n"], dependencies: [{ kind: "directive", type: i0.forwardRef(() => i1.NgClass), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgIf), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgTemplateOutlet), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgStyle), selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i0.forwardRef(() => i2.Ripple), selector: "[pRipple]" }, { kind: "component", type: i0.forwardRef(() => PlusIcon), selector: "PlusIcon" }, { kind: "component", type: i0.forwardRef(() => MinusIcon), selector: "MinusIcon" }], animations: [
|
||
|
trigger('panelContent', [
|
||
|
state('hidden', style({
|
||
|
height: '0'
|
||
|
})),
|
||
|
state('void', style({
|
||
|
height: '{{height}}'
|
||
|
}), { params: { height: '0' } }),
|
||
|
state('visible', style({
|
||
|
height: '*'
|
||
|
})),
|
||
|
transition('visible <=> hidden', [animate('{{transitionParams}}')]),
|
||
|
transition('void => hidden', animate('{{transitionParams}}')),
|
||
|
transition('void => visible', animate('{{transitionParams}}'))
|
||
|
])
|
||
|
], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
||
|
}
|
||
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Panel, decorators: [{
|
||
|
type: Component,
|
||
|
args: [{ selector: 'p-panel', template: `
|
||
|
<div [attr.id]="id" [attr.data-pc-name]="'panel'" [ngClass]="{ 'p-panel p-component': true, 'p-panel-toggleable': toggleable, 'p-panel-expanded': !collapsed && toggleable }" [ngStyle]="style" [class]="styleClass">
|
||
|
<div class="p-panel-header" *ngIf="showHeader" (click)="onHeaderClick($event)" [attr.id]="id + '-titlebar'">
|
||
|
<span class="p-panel-title" *ngIf="header" [attr.id]="id + '_header'">{{ header }}</span>
|
||
|
<ng-content select="p-header"></ng-content>
|
||
|
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
||
|
<div class="p-panel-icons" [ngClass]="{ 'p-panel-icons-start': iconPos === 'start', 'p-panel-icons-end': iconPos === 'end', 'p-panel-icons-center': iconPos === 'center' }">
|
||
|
<ng-template *ngTemplateOutlet="iconTemplate"></ng-template>
|
||
|
<button
|
||
|
*ngIf="toggleable"
|
||
|
[attr.id]="id + '_header'"
|
||
|
pRipple
|
||
|
type="button"
|
||
|
role="button"
|
||
|
class="p-panel-header-icon p-panel-toggler p-link"
|
||
|
[attr.aria-label]="buttonAriaLabel"
|
||
|
[attr.aria-controls]="id + '_content'"
|
||
|
[attr.aria-expanded]="!collapsed"
|
||
|
(click)="onIconClick($event)"
|
||
|
(keydown)="onKeyDown($event)"
|
||
|
>
|
||
|
<ng-container *ngIf="!headerIconTemplate">
|
||
|
<ng-container *ngIf="!collapsed">
|
||
|
<span *ngIf="expandIcon" [class]="expandIcon" [ngClass]="iconClass"></span>
|
||
|
<MinusIcon *ngIf="!expandIcon" [styleClass]="iconClass" />
|
||
|
</ng-container>
|
||
|
|
||
|
<ng-container *ngIf="collapsed">
|
||
|
<span *ngIf="collapseIcon" [class]="collapseIcon" [ngClass]="iconClass"></span>
|
||
|
<PlusIcon *ngIf="!collapseIcon" [styleClass]="iconClass" />
|
||
|
</ng-container>
|
||
|
</ng-container>
|
||
|
|
||
|
<ng-template *ngTemplateOutlet="headerIconTemplate; context: { $implicit: collapsed }"></ng-template>
|
||
|
</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div
|
||
|
class="p-toggleable-content"
|
||
|
[id]="id + '_content'"
|
||
|
role="region"
|
||
|
[attr.aria-labelledby]="id + '_header'"
|
||
|
[attr.aria-hidden]="collapsed"
|
||
|
[attr.tabindex]="collapsed ? '-1' : undefined"
|
||
|
[@panelContent]="
|
||
|
collapsed
|
||
|
? { value: 'hidden', params: { transitionParams: animating ? transitionOptions : '0ms', height: '0', opacity: '0' } }
|
||
|
: { value: 'visible', params: { transitionParams: animating ? transitionOptions : '0ms', height: '*', opacity: '1' } }
|
||
|
"
|
||
|
(@panelContent.done)="onToggleDone($event)"
|
||
|
>
|
||
|
<div class="p-panel-content">
|
||
|
<ng-content></ng-content>
|
||
|
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
|
||
|
</div>
|
||
|
|
||
|
<div class="p-panel-footer" *ngIf="footerFacet || footerTemplate">
|
||
|
<ng-content select="p-footer"></ng-content>
|
||
|
<ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
`, animations: [
|
||
|
trigger('panelContent', [
|
||
|
state('hidden', style({
|
||
|
height: '0'
|
||
|
})),
|
||
|
state('void', style({
|
||
|
height: '{{height}}'
|
||
|
}), { params: { height: '0' } }),
|
||
|
state('visible', style({
|
||
|
height: '*'
|
||
|
})),
|
||
|
transition('visible <=> hidden', [animate('{{transitionParams}}')]),
|
||
|
transition('void => hidden', animate('{{transitionParams}}')),
|
||
|
transition('void => visible', animate('{{transitionParams}}'))
|
||
|
])
|
||
|
], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
||
|
class: 'p-element'
|
||
|
}, styles: ["@layer primeng{.p-panel-header{display:flex;align-items:center}.p-panel-title{line-height:1;order:1}.p-panel-header-icon{display:inline-flex;justify-content:center;align-items:center;cursor:pointer;text-decoration:none;overflow:hidden;position:relative}.p-panel-toggleable.p-panel-expanded>.p-toggleable-content:not(.ng-animating){overflow:visible}.p-panel-toggleable .p-toggleable-content{overflow:hidden}}\n"] }]
|
||
|
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { toggleable: [{
|
||
|
type: Input,
|
||
|
args: [{ transform: booleanAttribute }]
|
||
|
}], header: [{
|
||
|
type: Input
|
||
|
}], collapsed: [{
|
||
|
type: Input,
|
||
|
args: [{ transform: booleanAttribute }]
|
||
|
}], style: [{
|
||
|
type: Input
|
||
|
}], styleClass: [{
|
||
|
type: Input
|
||
|
}], iconPos: [{
|
||
|
type: Input
|
||
|
}], expandIcon: [{
|
||
|
type: Input
|
||
|
}], collapseIcon: [{
|
||
|
type: Input
|
||
|
}], showHeader: [{
|
||
|
type: Input,
|
||
|
args: [{ transform: booleanAttribute }]
|
||
|
}], toggler: [{
|
||
|
type: Input
|
||
|
}], transitionOptions: [{
|
||
|
type: Input
|
||
|
}], collapsedChange: [{
|
||
|
type: Output
|
||
|
}], onBeforeToggle: [{
|
||
|
type: Output
|
||
|
}], onAfterToggle: [{
|
||
|
type: Output
|
||
|
}], footerFacet: [{
|
||
|
type: ContentChild,
|
||
|
args: [Footer]
|
||
|
}], templates: [{
|
||
|
type: ContentChildren,
|
||
|
args: [PrimeTemplate]
|
||
|
}] } });
|
||
|
class PanelModule {
|
||
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: PanelModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
||
|
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: PanelModule, declarations: [Panel], imports: [CommonModule, SharedModule, RippleModule, PlusIcon, MinusIcon], exports: [Panel, SharedModule] });
|
||
|
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: PanelModule, imports: [CommonModule, SharedModule, RippleModule, PlusIcon, MinusIcon, SharedModule] });
|
||
|
}
|
||
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: PanelModule, decorators: [{
|
||
|
type: NgModule,
|
||
|
args: [{
|
||
|
imports: [CommonModule, SharedModule, RippleModule, PlusIcon, MinusIcon],
|
||
|
exports: [Panel, SharedModule],
|
||
|
declarations: [Panel]
|
||
|
}]
|
||
|
}] });
|
||
|
|
||
|
/**
|
||
|
* Generated bundle index. Do not edit.
|
||
|
*/
|
||
|
|
||
|
export { Panel, PanelModule };
|
||
|
//# sourceMappingURL=primeng-panel.mjs.map
|