UNPKG

ng-zorro-antd-yj

Version:

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

163 lines 11.6 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { forwardRef, Directive, ElementRef, EventEmitter } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; /** @type {?} */ export var NZ_MENTION_TRIGGER_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((/** * @return {?} */ function () { return NzMentionTriggerDirective; })), multi: true }; var NzMentionTriggerDirective = /** @class */ (function () { function NzMentionTriggerDirective(el) { this.el = el; this.onFocusin = new EventEmitter(); this.onBlur = new EventEmitter(); this.onInput = new EventEmitter(); this.onKeydown = new EventEmitter(); this.onClick = new EventEmitter(); } /** * @return {?} */ NzMentionTriggerDirective.prototype.ngOnDestroy = /** * @return {?} */ function () { this.completeEvents(); }; /** * @return {?} */ NzMentionTriggerDirective.prototype.completeEvents = /** * @return {?} */ function () { this.onFocusin.complete(); this.onBlur.complete(); this.onInput.complete(); this.onKeydown.complete(); this.onClick.complete(); }; /** * @param {?=} caretPos * @return {?} */ NzMentionTriggerDirective.prototype.focus = /** * @param {?=} caretPos * @return {?} */ function (caretPos) { this.el.nativeElement.focus(); this.el.nativeElement.setSelectionRange(caretPos, caretPos); }; /** * @param {?} mention * @return {?} */ NzMentionTriggerDirective.prototype.insertMention = /** * @param {?} mention * @return {?} */ function (mention) { /** @type {?} */ var value = this.el.nativeElement.value; /** @type {?} */ var insertValue = mention.mention.trim() + ' '; /** @type {?} */ var newValue = [ value.slice(0, mention.startPos + 1), insertValue, value.slice(mention.endPos, value.length) ].join(''); this.el.nativeElement.value = newValue; this.focus(mention.startPos + insertValue.length + 1); this.onChange(newValue); this.value = newValue; }; /** * @param {?} value * @return {?} */ NzMentionTriggerDirective.prototype.writeValue = /** * @param {?} value * @return {?} */ function (value) { this.value = value; if (typeof value === 'string') { this.el.nativeElement.value = value; } else { this.el.nativeElement.value = ''; } }; /** * @param {?} fn * @return {?} */ NzMentionTriggerDirective.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ NzMentionTriggerDirective.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this.onTouched = fn; }; NzMentionTriggerDirective.decorators = [ { type: Directive, args: [{ selector: 'input[nzMentionTrigger], textarea[nzMentionTrigger]', providers: [NZ_MENTION_TRIGGER_ACCESSOR], host: { autocomplete: 'off', '(focusin)': 'onFocusin.emit()', '(blur)': 'onBlur.emit()', '(input)': 'onInput.emit($event)', '(keydown)': 'onKeydown.emit($event)', '(click)': 'onClick.emit($event)' } },] } ]; /** @nocollapse */ NzMentionTriggerDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; return NzMentionTriggerDirective; }()); export { NzMentionTriggerDirective }; if (false) { /** @type {?} */ NzMentionTriggerDirective.prototype.onChange; /** @type {?} */ NzMentionTriggerDirective.prototype.onTouched; /** @type {?} */ NzMentionTriggerDirective.prototype.onFocusin; /** @type {?} */ NzMentionTriggerDirective.prototype.onBlur; /** @type {?} */ NzMentionTriggerDirective.prototype.onInput; /** @type {?} */ NzMentionTriggerDirective.prototype.onKeydown; /** @type {?} */ NzMentionTriggerDirective.prototype.onClick; /** @type {?} */ NzMentionTriggerDirective.prototype.value; /** @type {?} */ NzMentionTriggerDirective.prototype.el; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotbWVudGlvbi10cmlnZ2VyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctem9ycm8tYW50ZC15ai8iLCJzb3VyY2VzIjpbIm1lbnRpb24vbnotbWVudGlvbi10cmlnZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLFNBQVMsRUFBRSxVQUFVLEVBQUUsWUFBWSxFQUErQ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