UNPKG

5.95 kBSource Map (JSON)View Raw
1{"version":3,"file":"primeng-inplace.js","sources":["../../src/app/components/inplace/inplace.ts","../../src/app/components/inplace/primeng-inplace.ts"],"sourcesContent":["import {NgModule,Component,Input,Output,EventEmitter,ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, AfterContentInit, TemplateRef, QueryList, ContentChildren} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {ButtonModule} from 'primeng/button';\nimport {PrimeTemplate} from 'primeng/api';\n\n@Component({\n selector: 'p-inplaceDisplay',\n template: '<ng-content></ng-content>'\n})\nexport class InplaceDisplay {}\n\n@Component({\n selector: 'p-inplaceContent',\n template: '<ng-content></ng-content>'\n})\nexport class InplaceContent {}\n\n@Component({\n selector: 'p-inplace',\n template: `\n <div [ngClass]=\"{'p-inplace p-component': true, 'p-inplace-closable': closable}\" [ngStyle]=\"style\" [class]=\"styleClass\">\n <div class=\"p-inplace-display\" (click)=\"onActivateClick($event)\" tabindex=\"0\" (keydown)=\"onKeydown($event)\" \n [ngClass]=\"{'p-disabled':disabled}\" *ngIf=\"!active\">\n <ng-content select=\"[pInplaceDisplay]\"></ng-content>\n <ng-container *ngTemplateOutlet=\"displayTemplate\"></ng-container>\n </div>\n <div class=\"p-inplace-content\" *ngIf=\"active\">\n <ng-content select=\"[pInplaceContent]\"></ng-content>\n <ng-container *ngTemplateOutlet=\"contentTemplate\"></ng-container>\n <button type=\"button\" [icon]=\"closeIcon\" pButton (click)=\"onDeactivateClick($event)\" *ngIf=\"closable\"></button>\n </div>\n </div>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./inplace.css']\n})\nexport class Inplace implements AfterContentInit {\n\n @Input() active: boolean;\n\n @Input() closable: boolean;\n\n @Input() disabled: boolean;\n\n @Input() preventClick: boolean;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() closeIcon: string = 'pi pi-times';\n\n @ContentChildren(PrimeTemplate) templates: QueryList<any>;\n\n @Output() onActivate: EventEmitter<any> = new EventEmitter();\n\n @Output() onDeactivate: EventEmitter<any> = new EventEmitter();\n\n hover: boolean;\n\n displayTemplate: TemplateRef<any>;\n\n contentTemplate: TemplateRef<any>;\n\n constructor(public cd: ChangeDetectorRef) {}\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'display':\n this.displayTemplate = item.template;\n break;\n\n case 'content':\n this.contentTemplate = item.template;\n break;\n }\n });\n }\n\n onActivateClick(event) {\n if (!this.preventClick)\n this.activate(event);\n }\n\n onDeactivateClick(event) {\n if (!this.preventClick)\n this.deactivate(event);\n }\n\n activate(event?: Event) {\n if (!this.disabled) {\n this.active = true;\n this.onActivate.emit(event);\n this.cd.markForCheck();\n }\n }\n\n deactivate(event?: Event) {\n if (!this.disabled) {\n this.active = false;\n this.hover = false;\n this.onDeactivate.emit(event);\n this.cd.markForCheck();\n }\n }\n\n onKeydown(event: KeyboardEvent) {\n if (event.which === 13) {\n this.activate(event);\n event.preventDefault();\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule,ButtonModule],\n exports: [Inplace,InplaceDisplay,InplaceContent,ButtonModule],\n declarations: [Inplace,InplaceDisplay,InplaceContent]\n})\nexport class InplaceModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;MASa,cAAc;;;YAJ1B,SAAS,SAAC;gBACP,QAAQ,EAAE,kBAAkB;gBAC5B,QAAQ,EAAE,2BAA2B;aACxC;;MAOY,cAAc;;;YAJ1B,SAAS,SAAC;gBACP,QAAQ,EAAE,kBAAkB;gBAC5B,QAAQ,EAAE,2BAA2B;aACxC;;MAuBY,OAAO;IA4BhB,YAAmB,EAAqB;QAArB,OAAE,GAAF,EAAE,CAAmB;QAd/B,cAAS,GAAW,aAAa,CAAC;QAIjC,eAAU,GAAsB,IAAI,YAAY,EAAE,CAAC;QAEnD,iBAAY,GAAsB,IAAI,YAAY,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