File

src/input/password.directive.ts

Implements

AfterViewInit

Metadata

Index

Properties
Methods
Inputs
HostBindings
Accessors

Constructor

constructor(elementRef: ElementRef, renderer: Renderer2)
Parameters :
Name Type Optional
elementRef ElementRef No
renderer Renderer2 No

Inputs

invalid
Type : boolean
Default value : false
size
Type : "sm" | "md" | "lg"
Default value : "md"

Input field render size

skeleton
Type : boolean
Default value : false
theme
Type : "light" | "dark"
Default value : "dark"
type
Type : string
warn
Type : boolean
Default value : false

HostBindings

attr.data-invalid
Type : boolean
class.cds--layout--size-lg
Type : boolean
class.cds--layout--size-md
Type : boolean
class.cds--layout--size-sm
Type : boolean
class.cds--password-input
Type : boolean
Default value : true
class.cds--text-input
Type : boolean
Default value : true
class.cds--text-input--lg
Type : boolean
class.cds--text-input--light
Type : boolean
class.cds--text-input--md
Type : boolean
class.cds--text-input--sm
Type : boolean

Methods

ngAfterViewInit
ngAfterViewInit()
Returns : void

Properties

Private _type
Type : string
Default value : "password"
inputClass
Default value : true
Decorators :
@HostBinding('class.cds--text-input')
passwordInputClass
Default value : true
Decorators :
@HostBinding('class.cds--password-input')

Accessors

type
settype(type: string)
Parameters :
Name Type Optional
type string No
Returns : void
isSizeSm
getisSizeSm()
isSizeMd
getisSizeMd()
isSizelg
getisSizelg()
sizeSm
getsizeSm()
sizeMd
getsizeMd()
sizelg
getsizelg()
isLightTheme
getisLightTheme()
getInvalidAttribute
getgetInvalidAttribute()
import {
	Directive,
	HostBinding,
	Input,
	Renderer2,
	ElementRef,
	AfterViewInit
} from "@angular/core";

@Directive({
	selector: "[cdsPassword], [ibmPassword]"
})
export class PasswordInput implements AfterViewInit {

	@Input() set type(type: string) {
		if (type) {
			this._type = type;
			if (this.elementRef) {
				this.renderer.setAttribute(this.elementRef.nativeElement, "type", this._type);
			}
		}
	}
	@HostBinding("class.cds--password-input") passwordInputClass = true;

	/**
	 * @todo - remove `cds--text-input--${size}` classes in v12
	 */
	@HostBinding("class.cds--text-input--sm") get isSizeSm() {
		return this.size === "sm";
	}
	@HostBinding("class.cds--text-input--md") get isSizeMd() {
		return this.size === "md";
	}
	@HostBinding("class.cds--text-input--lg") get isSizelg() {
		return this.size === "lg";
	}

	// Size
	@HostBinding("class.cds--layout--size-sm") get sizeSm() {
		return this.size === "sm";
	}
	@HostBinding("class.cds--layout--size-md") get sizeMd() {
		return this.size === "md";
	}
	@HostBinding("class.cds--layout--size-lg") get sizelg() {
		return this.size === "lg";
	}
	@HostBinding("class.cds--text-input--light") get isLightTheme() {
		return this.theme === "light";
	}

	@HostBinding("class.cds--text-input") inputClass = true;
	@HostBinding("class.cds--text-input--invalid") @Input() invalid = false;
	@HostBinding("class.cds--text-input--warning") @Input() warn = false;
	@HostBinding("class.cds--skeleton") @Input() skeleton = false;

	/**
	 * @deprecated since v5 - Use `cdsLayer` directive instead
	 * `light` or `dark` input theme
	 */
	@Input() theme: "light" | "dark" = "dark";

	/**
	 * Input field render size
	 */
	@Input() size: "sm" | "md" | "lg" = "md";

	@HostBinding("attr.data-invalid") get getInvalidAttribute() {
		return this.invalid ? true : undefined;
	}

	private _type = "password";

	constructor(protected elementRef: ElementRef, protected renderer: Renderer2) { }

	ngAfterViewInit(): void {
		this.renderer.setAttribute(this.elementRef.nativeElement, "type", this._type);
	}
}

results matching ""

    No results matching ""