UNPKG

@taiga-ui/kit

Version:
140 lines (135 loc) 7.07 kB
import { __extends, __decorate, __param } from 'tslib'; import { Optional, Self, Inject, ChangeDetectorRef, ViewChild, Component, ChangeDetectionStrategy, forwardRef, NgModule } from '@angular/core'; import { NgControl, FormsModule } from '@angular/forms'; import { TUI_FOCUSABLE_ITEM_ACCESSOR, AbstractTuiControl } from '@taiga-ui/cdk'; import { TuiTextfieldSizeDirective, TUI_TEXTFIELD_SIZE, TuiPrimitiveTextfieldComponent, TuiSvgModule, TuiHintModule, TuiPrimitiveTextfieldModule, TuiTextfieldControllerModule } from '@taiga-ui/core'; import { TUI_PASSWORD_TEXTS } from '@taiga-ui/kit/tokens'; import { Observable } from 'rxjs'; import { CommonModule } from '@angular/common'; import { PolymorpheusModule } from '@tinkoff/ng-polymorpheus'; // @dynamic var TuiInputPasswordComponent = /** @class */ (function (_super) { __extends(TuiInputPasswordComponent, _super); function TuiInputPasswordComponent(control, changeDetectorRef, textfieldSize, passwordTexts$) { var _this = _super.call(this, control, changeDetectorRef) || this; _this.textfieldSize = textfieldSize; _this.passwordTexts$ = passwordTexts$; _this.isPasswordHidden = true; return _this; } TuiInputPasswordComponent_1 = TuiInputPasswordComponent; Object.defineProperty(TuiInputPasswordComponent.prototype, "nativeFocusableElement", { get: function () { return this.computedDisabled || !this.textfield ? null : this.textfield.nativeFocusableElement; }, enumerable: true, configurable: true }); Object.defineProperty(TuiInputPasswordComponent.prototype, "focused", { get: function () { return !!this.textfield && this.textfield.focused; }, enumerable: true, configurable: true }); Object.defineProperty(TuiInputPasswordComponent.prototype, "icon", { get: function () { if (this.textfieldSize.size === 's') { return this.isPasswordHidden ? 'tuiIconEyeClosed' : 'tuiIconEyeOpen'; } return this.isPasswordHidden ? 'tuiIconHideLarge' : 'tuiIconShowLarge'; }, enumerable: true, configurable: true }); Object.defineProperty(TuiInputPasswordComponent.prototype, "inputType", { get: function () { return this.isPasswordHidden || !this.hasEyeIcon ? 'password' : 'text'; }, enumerable: true, configurable: true }); Object.defineProperty(TuiInputPasswordComponent.prototype, "hasEyeIcon", { get: function () { return !(this.disabled || this.readOnly); }, enumerable: true, configurable: true }); TuiInputPasswordComponent.prototype.onValueChange = function (textValue) { this.updateValue(textValue); }; TuiInputPasswordComponent.prototype.onFocused = function (focused) { this.updateFocused(focused); }; TuiInputPasswordComponent.prototype.onHovered = function (hovered) { this.updateHovered(hovered); }; TuiInputPasswordComponent.prototype.onPressed = function (pressed) { this.updatePressed(pressed); }; TuiInputPasswordComponent.prototype.togglePasswordVisibility = function () { this.isPasswordHidden = !this.isPasswordHidden; }; TuiInputPasswordComponent.prototype.getFallbackValue = function () { return ''; }; var TuiInputPasswordComponent_1; TuiInputPasswordComponent.ctorParameters = function () { return [ { type: NgControl, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NgControl,] }] }, { type: ChangeDetectorRef, decorators: [{ type: Inject, args: [ChangeDetectorRef,] }] }, { type: TuiTextfieldSizeDirective, decorators: [{ type: Inject, args: [TUI_TEXTFIELD_SIZE,] }] }, { type: Observable, decorators: [{ type: Inject, args: [TUI_PASSWORD_TEXTS,] }] } ]; }; __decorate([ ViewChild(TuiPrimitiveTextfieldComponent) ], TuiInputPasswordComponent.prototype, "textfield", void 0); TuiInputPasswordComponent = TuiInputPasswordComponent_1 = __decorate([ Component({ selector: 'tui-input-password', template: "<tui-primitive-textfield\n class=\"textfield\"\n [pseudoFocused]=\"pseudoFocused\"\n [pseudoHovered]=\"pseudoHovered\"\n [pseudoPressed]=\"pseudoPressed\"\n [invalid]=\"computedInvalid\"\n [focusable]=\"focusable\"\n [nativeId]=\"nativeId\"\n [tuiTextfieldType]=\"inputType\"\n [disabled]=\"disabled\"\n [readOnly]=\"readOnly\"\n [iconContent]=\"hasEyeIcon ? iconContent : null\"\n [value]=\"value\"\n (valueChange)=\"onValueChange($event)\"\n (focusedChange)=\"onFocused($event)\"\n (hoveredChange)=\"onHovered($event)\"\n (pressedChange)=\"onPressed($event)\"\n>\n <ng-content></ng-content>\n</tui-primitive-textfield>\n\n<ng-template #iconContent>\n <tui-svg\n automation-id=\"tui-password__icon\"\n class=\"icon\"\n tuiHintId=\"not_required\"\n [tuiHint]=\"hintContent\"\n [src]=\"icon\"\n (click)=\"togglePasswordVisibility()\"\n ></tui-svg>\n</ng-template>\n\n<ng-template #hintContent=\"polymorpheus\" polymorpheus>\n <ng-container *ngIf=\"passwordTexts$ | async as texts\">\n {{isPasswordHidden ? texts[0] : texts[1]}}\n </ng-container>\n</ng-template>\n", changeDetection: ChangeDetectionStrategy.OnPush, providers: [ { provide: TUI_FOCUSABLE_ITEM_ACCESSOR, useExisting: forwardRef(function () { return TuiInputPasswordComponent_1; }), }, ], styles: [":host{display:block;border-radius:var(--tui-radius-m)}.icon{cursor:pointer;pointer-events:auto}.textfield{border-radius:inherit}"] }), __param(0, Optional()), __param(0, Self()), __param(0, Inject(NgControl)), __param(1, Inject(ChangeDetectorRef)), __param(2, Inject(TUI_TEXTFIELD_SIZE)), __param(3, Inject(TUI_PASSWORD_TEXTS)) ], TuiInputPasswordComponent); return TuiInputPasswordComponent; }(AbstractTuiControl)); var TuiInputPasswordModule = /** @class */ (function () { function TuiInputPasswordModule() { } TuiInputPasswordModule = __decorate([ NgModule({ imports: [ CommonModule, FormsModule, PolymorpheusModule, TuiSvgModule, TuiHintModule, TuiPrimitiveTextfieldModule, TuiTextfieldControllerModule, ], declarations: [TuiInputPasswordComponent], exports: [TuiInputPasswordComponent], }) ], TuiInputPasswordModule); return TuiInputPasswordModule; }()); /** * Generated bundle index. Do not edit. */ export { TuiInputPasswordComponent, TuiInputPasswordModule }; //# sourceMappingURL=taiga-ui-kit-components-input-password.js.map