import { Component, Optional, ElementRef, EventEmitter, Input, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core'; import { NgControl } from '@angular/forms'; import { App } from '../app/app'; import { Config } from '../../config/config'; import { Content } from '../content/content'; import { Form } from '../../util/form'; import { InputBase } from './input-base'; import { isTrueProperty } from '../../util/util'; import { Item } from '../item/item'; import { NativeInput, NextInput } from './native-input'; import { NavController } from '../../navigation/nav-controller'; import { Platform } from '../../platform/platform'; /** * @name Input * @description * * `ion-input` is meant for text type inputs only, such as `text`, * `password`, `email`, `number`, `search`, `tel`, and `url`. Ionic * still uses an actual `` HTML element within the * component, however, with Ionic wrapping the native HTML input * element it's able to better handle the user experience and * interactivity. * * Similarily, `` should be used in place of `' + '' + '
', encapsulation: ViewEncapsulation.None, }) export class TextArea extends InputBase { constructor( config: Config, form: Form, @Optional() item: Item, app: App, platform: Platform, elementRef: ElementRef, renderer: Renderer, @Optional() scrollView: Content, @Optional() nav: NavController, @Optional() ngControl: NgControl ) { super(config, form, item, app, platform, elementRef, renderer, scrollView, nav, ngControl); this.mode = config.get('mode'); } /** * @input {string} The placeholder for the textarea */ @Input() placeholder: string = ''; /** * @input {string} The value of the textarea */ @Input() get value() { return this._value; } set value(val: any) { super.setValue(val); } /** * @input {bool} Whether the textarea should be disabled or not */ @Input() get disabled() { return this._disabled; } set disabled(val: any) { super.setDisabled(val); } /** * @input {string} The mode to apply to this component. */ @Input() set mode(val: string) { this._setMode(val); } /** * @private */ @ViewChild(NativeInput) set _nativeInput(nativeInput: NativeInput) { super.setNativeInput(nativeInput); } /** * @private */ @ViewChild(NextInput) set _nextInput(nextInput: NextInput) { super.setNextInput(nextInput); } /** * @output {event} Expression to call when the textarea no longer has focus */ @Output() blur: EventEmitter = new EventEmitter(); /** * @output {event} Expression to call when the textarea has focus */ @Output() focus: EventEmitter = new EventEmitter(); /** * @private */ ngOnInit() { if (this._item) { this._item.setElementClass('item-textarea', true); this._item.setElementClass('item-input', true); this._item.registerInput(this._type); } } /** * @private */ ngAfterContentChecked() { this.setItemInputControlCss(); } /** * @private */ ngOnDestroy() { this._form.deregister(this); } /** * @private */ inputBlurred(ev: UIEvent) { this.blur.emit(ev); } /** * @private */ inputFocused(ev: UIEvent) { this.focus.emit(ev); } }