UNPKG

7.85 kBSource Map (JSON)View Raw
1{"version":3,"file":"primeng-fieldset.js","sources":["../../src/app/components/fieldset/fieldset.ts","../../src/app/components/fieldset/primeng-fieldset.ts"],"sourcesContent":["import {NgModule,Component,Input,Output,EventEmitter,ElementRef,ChangeDetectionStrategy, ViewEncapsulation, AfterContentInit, QueryList, ContentChildren, TemplateRef} from '@angular/core';\nimport {trigger,state,style,transition,animate} from '@angular/animations';\nimport {CommonModule} from '@angular/common';\nimport {SharedModule, PrimeTemplate} from 'primeng/api';\nimport {BlockableUI} from 'primeng/api';\nimport {RippleModule} from 'primeng/ripple'; \n\nlet idx: number = 0;\n\n@Component({\n selector: 'p-fieldset',\n template: `\n <fieldset [attr.id]=\"id\" [ngClass]=\"{'p-fieldset p-component': true, 'p-fieldset-toggleable': toggleable}\" [ngStyle]=\"style\" [class]=\"styleClass\">\n <legend class=\"p-fieldset-legend\">\n <ng-container *ngIf=\"toggleable; else legendContent\">\n <a tabindex=\"0\" (click)=\"toggle($event)\" (keydown.enter)=\"toggle($event)\" [attr.aria-controls]=\"id + '-content'\" [attr.aria-expanded]=\"!collapsed\" pRipple>\n <span class=\"p-fieldset-toggler pi\" *ngIf=\"toggleable\" [ngClass]=\"{'pi-minus': !collapsed,'pi-plus':collapsed}\"></span>\n <ng-container *ngTemplateOutlet=\"legendContent\"></ng-container>\n </a>\n </ng-container>\n <ng-template #legendContent>\n <span class=\"p-fieldset-legend-text\">{{legend}}</span>\n <ng-content select=\"p-header\"></ng-content>\n <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n </ng-template>\n </legend>\n <div [attr.id]=\"id + '-content'\" class=\"p-toggleable-content\" [@fieldsetContent]=\"collapsed ? {value: 'hidden', params: {transitionParams: transitionOptions, height: '0'}} : {value: 'visible', params: {transitionParams: animating ? transitionOptions : '0ms', height: '*'}}\" \n [attr.aria-labelledby]=\"id\" [attr.aria-hidden]=\"collapsed\"\n (@fieldsetContent.done)=\"onToggleDone($event)\" role=\"region\">\n <div class=\"p-fieldset-content\">\n <ng-content></ng-content>\n <ng-container *ngTemplateOutlet=\"contentTemplate\"></ng-container>\n </div>\n </div>\n </fieldset>\n `,\n animations: [\n trigger('fieldsetContent', [\n state('hidden', style({\n height: '0',\n overflow: 'hidden'\n })),\n state('visible', style({\n height: '*'\n })),\n transition('visible <=> hidden', [style({overflow: 'hidden'}), animate('{{transitionParams}}')]),\n transition('void => *', animate(0))\n ])\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./fieldset.css']\n})\nexport class Fieldset implements AfterContentInit,BlockableUI {\n\n @Input() legend: string;\n\n @Input() toggleable: boolean;\n\n @Input() collapsed: boolean = false;\n\n @Output() collapsedChange: EventEmitter<any> = new EventEmitter();\n \n @Output() onBeforeToggle: EventEmitter<any> = new EventEmitter();\n\n @Output() onAfterToggle: EventEmitter<any> = new EventEmitter();\n \n @Input() style: any;\n \n @Input() styleClass: string;\n\n @Input() transitionOptions: string = '400ms cubic-bezier(0.86, 0, 0.07, 1)';\n\n @ContentChildren(PrimeTemplate) templates: QueryList<any>;\n \n public animating: boolean;\n\n headerTemplate: TemplateRef<any>;\n\n contentTemplate: TemplateRef<any>;\n \n constructor(private el: ElementRef) {}\n \n id: string = `p-fieldset-${idx++}`;\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'header':\n this.headerTemplate = item.template;\n break;\n\n case 'content':\n this.contentTemplate = item.template;\n break;\n }\n });\n }\n \n toggle(event) {\n if (this.animating) {\n return false;\n }\n \n this.animating = true;\n this.onBeforeToggle.emit({originalEvent: event, collapsed: this.collapsed});\n \n if (this.collapsed)\n this.expand(event);\n else\n this.collapse(event);\n \n this.onAfterToggle.emit({originalEvent: event, collapsed: this.collapsed}); \n event.preventDefault();\n }\n \n expand(event) {\n this.collapsed = false;\n this.collapsedChange.emit(this.collapsed);\n }\n \n collapse(event) {\n this.collapsed = true;\n this.collapsedChange.emit(this.collapsed);\n }\n \n getBlockableElement(): HTMLElement {\n return this.el.nativeElement.children[0];\n }\n \n onToggleDone(event: Event) {\n this.animating = false;\n }\n\n}\n\n@NgModule({\n imports: [CommonModule,RippleModule],\n exports: [Fieldset,SharedModule],\n declarations: [Fieldset]\n})\nexport class FieldsetModule { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;AAOA,IAAI,GAAG,GAAW,CAAC,CAAC;MA8CP,QAAQ;IA4BjB,YAAoB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;QAtBzB,cAAS,GAAY,KAAK,CAAC;QAE1B,oBAAe,GAAsB,IAAI,YAAY,EAAE,CAAC;QAExD,mBAAc,GAAsB,IAAI,YAAY,EAAE,CAAC;QAEvD,kBAAa,GAAsB,IAAI,YAAY,EAAE,CAAC;QAMvD,sBAAiB,GAAW,sCAAsC,CAAC;QAY5E,OAAE,GAAW,cAAc,GAAG,EAAE,EAAE,CAAC;KAFG;IAItC,kBAAkB;QACd,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI;YACxB,QAAO,IAAI,CAAC,OAAO,EAAE;gBACjB,KAAK,QAAQ;oBACT,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC;oBACxC,MAAM;gBAEN,KAAK,SAAS;oBACV,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC;oBACzC,MAAM;aACT;SACJ,CAAC,CAAC;KACN;IAED,MAAM,CAAC,KAAK;QACR,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAC,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAC,CAAC,CAAC;QAE5E,IAAI,IAAI,CAAC,SAAS;YACd,IAAI,CAAC,MAAM,C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