UNPKG

ng-zorro-antd-yj

Version:

An enterprise-class UI components based on Ant Design and Angular

141 lines 8.19 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { Directive, ElementRef, HostListener, Input } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { DateHelperService } from '../i18n/date-helper.service'; var NzTimeValueAccessorDirective = /** @class */ (function () { function NzTimeValueAccessorDirective(dateHelper, elementRef) { this.dateHelper = dateHelper; this.elementRef = elementRef; } /** * @return {?} */ NzTimeValueAccessorDirective.prototype.keyup = /** * @return {?} */ function () { this.changed(); }; /** * @return {?} */ NzTimeValueAccessorDirective.prototype.blur = /** * @return {?} */ function () { this.touched(); }; /** * @return {?} */ NzTimeValueAccessorDirective.prototype.changed = /** * @return {?} */ function () { if (this._onChange) { /** @type {?} */ var value = this.dateHelper.parseTime(this.elementRef.nativeElement.value); this._onChange((/** @type {?} */ (value))); } }; /** * @return {?} */ NzTimeValueAccessorDirective.prototype.touched = /** * @return {?} */ function () { if (this._onTouch) { this._onTouch(); } }; /** * @return {?} */ NzTimeValueAccessorDirective.prototype.setRange = /** * @return {?} */ function () { this.elementRef.nativeElement.focus(); this.elementRef.nativeElement.setSelectionRange(0, this.elementRef.nativeElement.value.length); }; /** * @param {?} value * @return {?} */ NzTimeValueAccessorDirective.prototype.writeValue = /** * @param {?} value * @return {?} */ function (value) { this.elementRef.nativeElement.value = this.dateHelper.format(value, this.nzTime); }; /** * @param {?} fn * @return {?} */ NzTimeValueAccessorDirective.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this._onChange = fn; }; /** * @param {?} fn * @return {?} */ NzTimeValueAccessorDirective.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this._onTouch = fn; }; NzTimeValueAccessorDirective.decorators = [ { type: Directive, args: [{ selector: 'input[nzTime]', providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: NzTimeValueAccessorDirective, multi: true }] },] } ]; /** @nocollapse */ NzTimeValueAccessorDirective.ctorParameters = function () { return [ { type: DateHelperService }, { type: ElementRef } ]; }; NzTimeValueAccessorDirective.propDecorators = { nzTime: [{ type: Input }], keyup: [{ type: HostListener, args: ['keyup',] }], blur: [{ type: HostListener, args: ['blur',] }] }; return NzTimeValueAccessorDirective; }()); export { NzTimeValueAccessorDirective }; if (false) { /** * @type {?} * @private */ NzTimeValueAccessorDirective.prototype._onChange; /** * @type {?} * @private */ NzTimeValueAccessorDirective.prototype._onTouch; /** @type {?} */ NzTimeValueAccessorDirective.prototype.nzTime; /** * @type {?} * @private */ NzTimeValueAccessorDirective.prototype.dateHelper; /** * @type {?} * @private */ NzTimeValueAccessorDirective.prototype.elementRef; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotdGltZS12YWx1ZS1hY2Nlc3Nvci5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZy16b3Jyby1hbnRkLXlqLyIsInNvdXJjZXMiOlsidGltZS1waWNrZXIvbnotdGltZS12YWx1ZS1hY2Nlc3Nvci5kaXJlY3RpdmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsVUFBVSxFQUFFLFlBQVksRUFBRSxLQUFLLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDM0UsT0FBTyxFQUF3QixpQkFBaUIsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3pFLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRWhFO0lBcUNFLHNDQUFvQixVQUE2QixFQUFVLFVBQXNCO1FBQTdELGVBQVUsR0FBVixVQUFVLENBQW1CO1FBQVUsZUFBVSxHQUFWLFVBQVUsQ0FBWTtJQUFHLENBQUM7Ozs7SUEzQnJGLDRDQUFLOzs7SUFETDtRQUVFLElB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