@nativescript-community/ui-material-textview
Version:
Material Design Text views allow users to input text into your app.
69 lines (64 loc) • 3.43 kB
JavaScript
import * as i0 from '@angular/core';
import { forwardRef, Directive, NgModule } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { BaseValueAccessor, registerElement } from '@nativescript/angular';
import { TextView } from '@nativescript-community/ui-material-textview';
const TEXT_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => TextValueAccessor),
multi: true
};
/**
* The accessor for writing a text and listening to changes that is used by the
* {@link NgModel} directives.
*
* ### Example
* ```
* <MDTextView [(ngModel)]="model.test"></MDTextView>
* ```
*/
class TextValueAccessor extends BaseValueAccessor {
// tslint:disable-line:directive-class-suffix
constructor(elementRef) {
super(elementRef.nativeElement);
}
writeValue(value) {
const normalized = super.normalizeValue(value);
this.view.text = normalized;
}
static ɵfac = function TextValueAccessor_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TextValueAccessor)(i0.ɵɵdirectiveInject(i0.ElementRef)); };
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TextValueAccessor, selectors: [["MDTextView", "ngModel", ""], ["MDTextView", "formControlName", ""], ["MDTextView", "formControl", ""]], hostBindings: function TextValueAccessor_HostBindings(rf, ctx) { if (rf & 1) {
i0.ɵɵlistener("blur", function TextValueAccessor_blur_HostBindingHandler() { return ctx.onTouched(); })("textChange", function TextValueAccessor_textChange_HostBindingHandler($event) { return ctx.onChange($event.value); });
} }, features: [i0.ɵɵProvidersFeature([TEXT_VALUE_ACCESSOR]), i0.ɵɵInheritDefinitionFeature] });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TextValueAccessor, [{
type: Directive,
args: [{
selector: 'MDTextView[ngModel],MDTextView[formControlName],MDTextView[formControl]',
providers: [TEXT_VALUE_ACCESSOR],
host: {
'(blur)': 'onTouched()',
'(textChange)': 'onChange($event.value)'
}
}]
}], () => [{ type: i0.ElementRef }], null); })();
const FORMS_DIRECTIVES = [TextValueAccessor];
class NativeScriptMaterialTextViewModule {
static ɵfac = function NativeScriptMaterialTextViewModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || NativeScriptMaterialTextViewModule)(); };
static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: NativeScriptMaterialTextViewModule });
static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NativeScriptMaterialTextViewModule, [{
type: NgModule,
args: [{
imports: FORMS_DIRECTIVES,
exports: FORMS_DIRECTIVES,
}]
}], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(NativeScriptMaterialTextViewModule, { imports: [TextValueAccessor], exports: [TextValueAccessor] }); })();
registerElement('MDTextView', () => TextView);
/**
* Generated bundle index. Do not edit.
*/
export { FORMS_DIRECTIVES, NativeScriptMaterialTextViewModule, TextValueAccessor };
//# sourceMappingURL=nativescript-community-ui-material-textview-angular.mjs.map