{"version":3,"file":"primeng-terminal.umd.js","sources":["../../src/app/components/terminal/terminalservice.ts","../../src/app/components/terminal/terminal.ts","../../src/app/components/terminal/primeng-terminal.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\n\n@Injectable()\nexport class TerminalService {\n \n private commandSource = new Subject();\n private responseSource = new Subject();\n \n commandHandler = this.commandSource.asObservable();\n responseHandler = this.responseSource.asObservable();\n \n sendCommand(command: string) {\n if (command) {\n this.commandSource.next(command);\n }\n }\n \n sendResponse(response: string) {\n if (response) {\n this.responseSource.next(response);\n }\n }\n}","import {NgModule,Component,AfterViewInit,AfterViewChecked,OnDestroy,Input,ElementRef,ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef} from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\nimport {TerminalService} from './terminalservice';\nimport {Subscription} from 'rxjs';\n\n@Component({\n selector: 'p-terminal',\n template: `\n
\n
{{welcomeMessage}}
\n
\n
\n {{prompt}}\n {{command.text}}\n
{{command.response}}
\n
\n
\n
\n {{prompt}}\n \n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./terminal.css']\n})\nexport class Terminal implements AfterViewInit,AfterViewChecked,OnDestroy {\n\n @Input() welcomeMessage: string;\n\n @Input() prompt: string;\n \n @Input() style: any;\n \n @Input() styleClass: string;\n \n commands: any[] = [];\n \n command: string;\n \n container: Element;\n \n commandProcessed: boolean;\n \n subscription: Subscription;\n \n constructor(public el: ElementRef, public terminalService: TerminalService, public cd: ChangeDetectorRef) {\n this.subscription = terminalService.responseHandler.subscribe(response => {\n this.commands[this.commands.length - 1].response = response;\n this.commandProcessed = true;\n });\n }\n \n ngAfterViewInit() {\n this.container = DomHandler.find(this.el.nativeElement, '.p-terminal')[0];\n }\n \n ngAfterViewChecked() {\n if (this.commandProcessed) {\n this.container.scrollTop = this.container.scrollHeight;\n this.commandProcessed = false;\n }\n }\n \n @Input()\n set response(value: string) {\n if (value) {\n this.commands[this.commands.length - 1].response = value;\n this.commandProcessed = true;\n }\n }\n \n handleCommand(event: KeyboardEvent) {\n if (event.keyCode == 13) {\n this.commands.push({text: this.command});\n this.terminalService.sendCommand(this.command);\n this.command = '';\n }\n }\n \n focus(element: HTMLElement) {\n element.focus();\n }\n \n ngOnDestroy() {\n if (this.subscription) {\n this.subscription.unsubscribe();\n }\n }\n \n}\n\n@NgModule({\n imports: [CommonModule,FormsModule],\n exports: [Terminal],\n declarations: [Terminal]\n})\nexport class TerminalModule { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["Subject","Injectable","DomHandler","Component","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","ChangeDetectorRef","Input","NgModule","CommonModule","FormsModule"],"mappings":";;;;;;;QAGA;YAGY,kBAAa,GAAG,IAAIA,YAAO,EAAU,CAAC;YACtC,mBAAc,GAAG,IAAIA,YAAO,EAAU,CAAC;YAE/C,mBAAc,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;YACnD,oBAAe,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;SAaxD;QAXG,qCAAW,GAAX,UAAY,OAAe;YACvB,IAAI,OAAO,EAAE;gBACT,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACpC;SACJ;QAED,sCAAY,GAAZ,UAAa,QAAgB;YACzB,IAAI,QAAQ,EAAE;gBACV,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACtC;SACJ;;;;gBAnBJC,eAAU;;;;QC8CP,kBAAmB,EAAc,EAAS,eAAgC,EAAS,EAAqB;YAAxG,iBAKC;YALkB,OAAE,GAAF,EAAE,CAAY;YAAS,oBAAe,GAAf,eAAe,CAAiB;YAAS,OAAE,GAAF,EAAE,CAAmB;YAVxG,aAAQ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