UNPKG

primeng

Version:

PrimeNG is an open source UI library for Angular featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeB

1,146 lines (1,135 loc) 50.4 kB
import { trigger, transition, style as style$1, animate } from '@angular/animations'; import * as i1 from '@angular/common'; import { isPlatformBrowser, CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { Injectable, input, booleanAttribute, inject, computed, signal, HostListener, Input, Directive, Pipe, forwardRef, EventEmitter, numberAttribute, ContentChildren, ContentChild, ViewChild, Output, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { addClass, absolutePosition, removeClass, hasClass, isTouchDevice, getOuterWidth, relativePosition } from '@primeuix/utils'; import { OverlayService, TranslationKeys, SharedModule, PrimeTemplate } from 'primeng/api'; import { AutoFocus } from 'primeng/autofocus'; import { BaseEditableHolder } from 'primeng/baseeditableholder'; import { BaseInput } from 'primeng/baseinput'; import { DomHandler, ConnectedOverlayScrollHandler } from 'primeng/dom'; import { Fluid } from 'primeng/fluid'; import { TimesIcon, EyeSlashIcon, EyeIcon } from 'primeng/icons'; import { InputText } from 'primeng/inputtext'; import { ZIndexUtils } from 'primeng/utils'; import { style } from '@primeuix/styles/password'; import { BaseStyle } from 'primeng/base'; const theme = /*css*/ ` ${style} /* For PrimeNG */ p-password.ng-invalid.ng-dirty .p-inputtext { border-color: dt('inputtext.invalid.border.color'); } p-password.ng-invalid.ng-dirty .p-inputtext:enabled:focus { border-color: dt('inputtext.focus.border.color'); } p-password.ng-invalid.ng-dirty .p-inputtext::placeholder { color: dt('inputtext.invalid.placeholder.color'); } .p-password-fluid-directive { width: 100%; } `; const inlineStyles = { root: ({ instance }) => ({ position: instance.$appendTo() === 'self' ? 'relative' : undefined }), overlay: { position: 'absolute' } }; const classes = { root: ({ instance }) => [ 'p-password p-component p-inputwrapper', { 'p-inputwrapper-filled': instance.$filled(), 'p-variant-filled': instance.$variant() === 'filled', 'p-inputwrapper-focus': instance.focused, 'p-password-fluid': instance.hasFluid } ], rootDirective: ({ instance }) => [ 'p-password p-inputtext p-component p-inputwrapper', { 'p-inputwrapper-filled': instance.$filled(), 'p-variant-filled': instance.$variant() === 'filled', 'p-password-fluid-directive': instance.hasFluid } ], pcInputText: 'p-password-input', maskIcon: 'p-password-toggle-mask-icon p-password-mask-icon', unmaskIcon: 'p-password-toggle-mask-icon p-password-unmask-icon', overlay: 'p-password-overlay p-component', content: 'p-password-content', meter: 'p-password-meter', meterLabel: ({ instance }) => `p-password-meter-label ${instance.meter ? 'p-password-meter-' + instance.meter.strength : ''}`, meterText: 'p-password-meter-text', clearIcon: 'p-password-clear-icon' }; class PasswordStyle extends BaseStyle { name = 'password'; theme = theme; classes = classes; inlineStyles = inlineStyles; static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PasswordStyle, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PasswordStyle }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PasswordStyle, decorators: [{ type: Injectable }] }); /** * * Password displays strength indicator for password fields. * * [Live Demo](https://www.primeng.org/password/) * * @module passwordstyle * */ var PasswordClasses; (function (PasswordClasses) { /** * Class name of the root element */ PasswordClasses["root"] = "p-password"; /** * Class name of the pt input element */ PasswordClasses["pcInputText"] = "p-password-input"; /** * Class name of the mask icon element */ PasswordClasses["maskIcon"] = "p-password-mask-icon"; /** * Class name of the unmask icon element */ PasswordClasses["unmaskIcon"] = "p-password-unmask-icon"; /** * Class name of the overlay element */ PasswordClasses["overlay"] = "p-password-overlay"; /** * Class name of the meter element */ PasswordClasses["meter"] = "p-password-meter"; /** * Class name of the meter label element */ PasswordClasses["meterLabel"] = "p-password-meter-label"; /** * Class name of the meter text element */ PasswordClasses["meterText"] = "p-password-meter-text"; /** * Class name of the clear icon */ PasswordClasses["clearIcon"] = "p-password-clear-icon"; })(PasswordClasses || (PasswordClasses = {})); /** * Password directive. * @group Components */ class PasswordDirective extends BaseEditableHolder { zone; /** * Text to prompt password entry. Defaults to PrimeNG I18N API configuration. * @group Props */ promptLabel = 'Enter a password'; /** * Text for a weak password. Defaults to PrimeNG I18N API configuration. * @group Props */ weakLabel = 'Weak'; /** * Text for a medium password. Defaults to PrimeNG I18N API configuration. * @group Props */ mediumLabel = 'Medium'; /** * Text for a strong password. Defaults to PrimeNG I18N API configuration. * @group Props */ strongLabel = 'Strong'; /** * Whether to show the strength indicator or not. * @group Props */ feedback = true; /** * Sets the visibility of the password field. * @defaultValue false * @type boolean * @group Props */ set showPassword(show) { this.el.nativeElement.type = show ? 'text' : 'password'; } /** * Specifies the input variant of the component. * @defaultValue 'outlined' * @group Props */ variant = input(...(ngDevMode ? [undefined, { debugName: "variant" }] : [])); /** * Spans 100% width of the container when enabled. * @defaultValue false * @group Props */ fluid = input(undefined, ...(ngDevMode ? [{ debugName: "fluid", transform: booleanAttribute }] : [{ transform: booleanAttribute }])); /** * Specifies the size of the component. * @defaultValue undefined * @group Props */ size = input(undefined, ...(ngDevMode ? [{ debugName: "size", alias: 'pSize' }] : [{ alias: 'pSize' }])); pcFluid = inject(Fluid, { optional: true, host: true, skipSelf: true }); $variant = computed(() => this.variant() || this.config.inputStyle() || this.config.inputVariant(), ...(ngDevMode ? [{ debugName: "$variant" }] : [])); get hasFluid() { return this.fluid() ?? !!this.pcFluid; } panel; meter; info; filled; content; label; scrollHandler; documentResizeListener; _componentStyle = inject(PasswordStyle); constructor(zone) { super(); this.zone = zone; } onInput(e) { this.writeModelValue(this.el.nativeElement.value); } createPanel() { if (isPlatformBrowser(this.platformId)) { this.panel = this.renderer.createElement('div'); this.renderer.addClass(this.panel, 'p-password-overlay'); this.renderer.addClass(this.panel, 'p-component'); this.content = this.renderer.createElement('div'); this.renderer.addClass(this.content, 'p-password-content'); this.renderer.appendChild(this.panel, this.content); this.meter = this.renderer.createElement('div'); this.renderer.addClass(this.meter, 'p-password-meter'); this.renderer.appendChild(this.content, this.meter); this.label = this.renderer.createElement('div'); this.renderer.addClass(this.label, 'p-password-meter-label'); this.renderer.appendChild(this.meter, this.label); this.info = this.renderer.createElement('div'); this.renderer.addClass(this.info, 'p-password-meter-text'); this.renderer.setProperty(this.info, 'textContent', this.promptLabel); this.renderer.appendChild(this.content, this.info); this.renderer.setStyle(this.panel, 'minWidth', `${this.el.nativeElement.offsetWidth}px`); this.renderer.appendChild(document.body, this.panel); this.updateMeter(); } } showOverlay() { if (this.feedback) { if (!this.panel) { this.createPanel(); } this.renderer.setStyle(this.panel, 'zIndex', String(++DomHandler.zindex)); this.renderer.setStyle(this.panel, 'display', 'block'); this.zone.runOutsideAngular(() => { setTimeout(() => { addClass(this.panel, 'p-connected-overlay-visible'); this.bindScrollListener(); this.bindDocumentResizeListener(); }, 1); }); absolutePosition(this.panel, this.el.nativeElement); } } hideOverlay() { if (this.feedback && this.panel) { addClass(this.panel, 'p-connected-overlay-hidden'); removeClass(this.panel, 'p-connected-overlay-visible'); this.unbindScrollListener(); this.unbindDocumentResizeListener(); this.zone.runOutsideAngular(() => { setTimeout(() => { this.ngOnDestroy(); }, 150); }); } } onFocus() { this.showOverlay(); } onBlur() { this.hideOverlay(); } labelSignal = signal('', ...(ngDevMode ? [{ debugName: "labelSignal" }] : [])); onKeyup(e) { if (this.feedback) { let value = e.target.value, label = null, meterPos = null; if (value.length === 0) { label = this.promptLabel; meterPos = '0px 0px'; } else { var score = this.testStrength(value); if (score < 30) { label = this.weakLabel; meterPos = '0px -10px'; } else if (score >= 30 && score < 80) { label = this.mediumLabel; meterPos = '0px -20px'; } else if (score >= 80) { label = this.strongLabel; meterPos = '0px -30px'; } this.labelSignal.set(label); this.updateMeter(); } if (!this.panel || !hasClass(this.panel, 'p-connected-overlay-visible')) { this.showOverlay(); } this.renderer.setStyle(this.meter, 'backgroundPosition', meterPos); this.info.textContent = label; } } updateMeter() { if (this.labelSignal()) { const label = this.labelSignal(); const strengthClass = this.strengthClass(label.toLowerCase()); const width = this.getWidth(label.toLowerCase()); this.renderer.addClass(this.meter, strengthClass); this.renderer.setStyle(this.meter, 'width', width); this.info.textContent = label; } } getWidth(label) { return label === 'weak' ? '33.33%' : label === 'medium' ? '66.66%' : label === 'strong' ? '100%' : ''; } strengthClass(label) { return `p-password-meter${label ? `-${label}` : ''}`; } testStrength(str) { let grade = 0; let val; val = str.match('[0-9]'); grade += this.normalize(val ? val.length : 1 / 4, 1) * 25; val = str.match('[a-zA-Z]'); grade += this.normalize(val ? val.length : 1 / 2, 3) * 10; val = str.match('[!@#$%^&*?_~.,;=]'); grade += this.normalize(val ? val.length : 1 / 6, 1) * 35; val = str.match('[A-Z]'); grade += this.normalize(val ? val.length : 1 / 6, 1) * 30; grade *= str.length / 8; return grade > 100 ? 100 : grade; } normalize(x, y) { let diff = x - y; if (diff <= 0) return x / y; else return 1 + 0.5 * (x / (x + y / 4)); } bindScrollListener() { if (!this.scrollHandler) { this.scrollHandler = new ConnectedOverlayScrollHandler(this.el.nativeElement, () => { if (hasClass(this.panel, 'p-connected-overlay-visible')) { this.hideOverlay(); } }); } this.scrollHandler.bindScrollListener(); } unbindScrollListener() { if (this.scrollHandler) { this.scrollHandler.unbindScrollListener(); } } bindDocumentResizeListener() { if (isPlatformBrowser(this.platformId)) { if (!this.documentResizeListener) { const window = this.document.defaultView; this.documentResizeListener = this.renderer.listen(window, 'resize', this.onWindowResize.bind(this)); } } } unbindDocumentResizeListener() { if (this.documentResizeListener) { this.documentResizeListener(); this.documentResizeListener = null; } } onWindowResize() { if (!isTouchDevice()) { this.hideOverlay(); } } ngOnDestroy() { if (this.panel) { if (this.scrollHandler) { this.scrollHandler.destroy(); this.scrollHandler = null; } this.unbindDocumentResizeListener(); this.renderer.removeChild(this.document.body, this.panel); this.panel = null; this.meter = null; this.info = null; } super.ngOnDestroy(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PasswordDirective, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.3", type: PasswordDirective, isStandalone: true, selector: "[pPassword]", inputs: { promptLabel: { classPropertyName: "promptLabel", publicName: "promptLabel", isSignal: false, isRequired: false, transformFunction: null }, weakLabel: { classPropertyName: "weakLabel", publicName: "weakLabel", isSignal: false, isRequired: false, transformFunction: null }, mediumLabel: { classPropertyName: "mediumLabel", publicName: "mediumLabel", isSignal: false, isRequired: false, transformFunction: null }, strongLabel: { classPropertyName: "strongLabel", publicName: "strongLabel", isSignal: false, isRequired: false, transformFunction: null }, feedback: { classPropertyName: "feedback", publicName: "feedback", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, showPassword: { classPropertyName: "showPassword", publicName: "showPassword", isSignal: false, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "pSize", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "onInput($event)", "focus": "onFocus()", "blur": "onBlur()", "keyup": "onKeyup($event)" }, properties: { "class": "cx('rootDirective')" } }, providers: [PasswordStyle], usesInheritance: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PasswordDirective, decorators: [{ type: Directive, args: [{ selector: '[pPassword]', standalone: true, host: { '[class]': "cx('rootDirective')" }, providers: [PasswordStyle] }] }], ctorParameters: () => [{ type: i0.NgZone }], propDecorators: { promptLabel: [{ type: Input }], weakLabel: [{ type: Input }], mediumLabel: [{ type: Input }], strongLabel: [{ type: Input }], feedback: [{ type: Input, args: [{ transform: booleanAttribute }] }], showPassword: [{ type: Input }], onInput: [{ type: HostListener, args: ['input', ['$event']] }], onFocus: [{ type: HostListener, args: ['focus'] }], onBlur: [{ type: HostListener, args: ['blur'] }], onKeyup: [{ type: HostListener, args: ['keyup', ['$event']] }] } }); class MapperPipe { transform(value, mapper, ...args) { return mapper(value, ...args); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: MapperPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.3", ngImport: i0, type: MapperPipe, isStandalone: true, name: "mapper" }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: MapperPipe, decorators: [{ type: Pipe, args: [{ name: 'mapper', pure: true, standalone: true }] }] }); const Password_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => Password), multi: true }; /** * Password displays strength indicator for password fields. * @group Components */ class Password extends BaseInput { /** * Defines a string that labels the input for accessibility. * @group Props */ ariaLabel; /** * Specifies one or more IDs in the DOM that labels the input field. * @group Props */ ariaLabelledBy; /** * Label of the input for accessibility. * @group Props */ label; /** * Text to prompt password entry. Defaults to PrimeNG I18N API configuration. * @group Props */ promptLabel; /** * Regex value for medium regex. * @group Props */ mediumRegex = '^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})'; /** * Regex value for strong regex. * @group Props */ strongRegex = '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})'; /** * Text for a weak password. Defaults to PrimeNG I18N API configuration. * @group Props */ weakLabel; /** * Text for a medium password. Defaults to PrimeNG I18N API configuration. * @group Props */ mediumLabel; /** * specifies the maximum number of characters allowed in the input element. * @deprecated since v20.0.0, use maxlength instead. * @group Props */ maxLength; /** * Text for a strong password. Defaults to PrimeNG I18N API configuration. * @group Props */ strongLabel; /** * Identifier of the accessible input element. * @group Props */ inputId; /** * Whether to show the strength indicator or not. * @group Props */ feedback = true; /** * Whether to show an icon to display the password as plain text. * @group Props */ toggleMask; /** * Style class of the input field. * @group Props */ inputStyleClass; /** * Style class of the element. * @deprecated since v20.0.0, use `class` instead. * @group Props */ styleClass; /** * Inline style of the input field. * @group Props */ inputStyle; /** * Transition options of the show animation. * @group Props */ showTransitionOptions = '.12s cubic-bezier(0, 0, 0.2, 1)'; /** * Transition options of the hide animation. * @group Props */ hideTransitionOptions = '.1s linear'; /** * Specify automated assistance in filling out password by browser. * @group Props */ autocomplete; /** * Advisory information to display on input. * @group Props */ placeholder; /** * When enabled, a clear icon is displayed to clear the value. * @group Props */ showClear = false; /** * When present, it specifies that the component should automatically get focus on load. * @group Props */ autofocus; /** * Index of the element in tabbing order. * @group Props */ tabindex; /** * Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name). * @defaultValue 'self' * @group Props */ appendTo = input(undefined, ...(ngDevMode ? [{ debugName: "appendTo" }] : [])); /** * Callback to invoke when the component receives focus. * @param {Event} event - Browser event. * @group Emits */ onFocus = new EventEmitter(); /** * Callback to invoke when the component loses focus. * @param {Event} event - Browser event. * @group Emits */ onBlur = new EventEmitter(); /** * Callback to invoke when clear button is clicked. * @group Emits */ onClear = new EventEmitter(); input; contentTemplate; footerTemplate; headerTemplate; clearIconTemplate; hideIconTemplate; showIconTemplate; templates; $appendTo = computed(() => this.appendTo() || this.config.overlayAppendTo(), ...(ngDevMode ? [{ debugName: "$appendTo" }] : [])); _contentTemplate; _footerTemplate; _headerTemplate; _clearIconTemplate; _hideIconTemplate; _showIconTemplate; overlayVisible = false; meter; infoText; focused = false; unmasked = false; mediumCheckRegExp; strongCheckRegExp; resizeListener; scrollHandler; overlay; value = null; translationSubscription; _componentStyle = inject(PasswordStyle); overlayService = inject(OverlayService); ngOnInit() { super.ngOnInit(); this.infoText = this.promptText(); this.mediumCheckRegExp = new RegExp(this.mediumRegex); this.strongCheckRegExp = new RegExp(this.strongRegex); this.translationSubscription = this.config.translationObserver.subscribe(() => { this.updateUI(this.value || ''); }); } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'content': this._contentTemplate = item.template; break; case 'header': this._headerTemplate = item.template; break; case 'footer': this._footerTemplate = item.template; break; case 'clearicon': this._clearIconTemplate = item.template; break; case 'hideicon': this._hideIconTemplate = item.template; break; case 'showicon': this._showIconTemplate = item.template; break; default: this._contentTemplate = item.template; break; } }); } onAnimationStart(event) { switch (event.toState) { case 'visible': this.overlay = event.element; ZIndexUtils.set('overlay', this.overlay, this.config.zIndex.overlay); this.attrSelector && this.overlay.setAttribute(this.attrSelector, ''); this.appendContainer(); this.alignOverlay(); this.bindScrollListener(); this.bindResizeListener(); break; case 'void': this.unbindScrollListener(); this.unbindResizeListener(); this.overlay = null; break; } } onAnimationEnd(event) { switch (event.toState) { case 'void': ZIndexUtils.clear(event.element); break; } } appendContainer() { DomHandler.appendOverlay(this.overlay, this.$appendTo() === 'body' ? this.document.body : this.$appendTo(), this.$appendTo()); } alignOverlay() { this.overlay.style.minWidth = getOuterWidth(this.input.nativeElement) + 'px'; if (this.$appendTo() === 'self') relativePosition(this.overlay, this.input?.nativeElement); else absolutePosition(this.overlay, this.input?.nativeElement); } onInput(event) { this.value = event.target.value; this.onModelChange(this.value); } onInputFocus(event) { this.focused = true; if (this.feedback) { this.overlayVisible = true; } this.onFocus.emit(event); } onInputBlur(event) { this.focused = false; if (this.feedback) { this.overlayVisible = false; } this.onModelTouched(); this.onBlur.emit(event); } onKeyUp(event) { if (this.feedback) { let value = event.target.value; this.updateUI(value); if (event.code === 'Escape') { this.overlayVisible && (this.overlayVisible = false); return; } if (!this.overlayVisible) { this.overlayVisible = true; } } } updateUI(value) { let label = null; let meter = null; switch (this.testStrength(value)) { case 1: label = this.weakText(); meter = { strength: 'weak', width: '33.33%' }; break; case 2: label = this.mediumText(); meter = { strength: 'medium', width: '66.66%' }; break; case 3: label = this.strongText(); meter = { strength: 'strong', width: '100%' }; break; default: label = this.promptText(); meter = null; break; } this.meter = meter; this.infoText = label; } onMaskToggle() { this.unmasked = !this.unmasked; } onOverlayClick(event) { this.overlayService.add({ originalEvent: event, target: this.el.nativeElement }); } testStrength(str) { let level = 0; if (this.strongCheckRegExp.test(str)) level = 3; else if (this.mediumCheckRegExp.test(str)) level = 2; else if (str.length) level = 1; return level; } bindScrollListener() { if (isPlatformBrowser(this.platformId)) { if (!this.scrollHandler) { this.scrollHandler = new ConnectedOverlayScrollHandler(this.input.nativeElement, () => { if (this.overlayVisible) { this.overlayVisible = false; } }); } this.scrollHandler.bindScrollListener(); } } bindResizeListener() { if (isPlatformBrowser(this.platformId)) { if (!this.resizeListener) { const window = this.document.defaultView; this.resizeListener = this.renderer.listen(window, 'resize', () => { if (this.overlayVisible && !isTouchDevice()) { this.overlayVisible = false; } }); } } } unbindScrollListener() { if (this.scrollHandler) { this.scrollHandler.unbindScrollListener(); } } unbindResizeListener() { if (this.resizeListener) { this.resizeListener(); this.resizeListener = null; } } promptText() { return this.promptLabel || this.getTranslation(TranslationKeys.PASSWORD_PROMPT); } weakText() { return this.weakLabel || this.getTranslation(TranslationKeys.WEAK); } mediumText() { return this.mediumLabel || this.getTranslation(TranslationKeys.MEDIUM); } strongText() { return this.strongLabel || this.getTranslation(TranslationKeys.STRONG); } restoreAppend() { if (this.overlay && this.$appendTo()) { if (this.$appendTo() === 'body') this.renderer.removeChild(this.document.body, this.overlay); else this.document.getElementById(this.$appendTo()).removeChild(this.overlay); } } inputType(unmasked) { return unmasked ? 'text' : 'password'; } getTranslation(option) { return this.config.getTranslation(option); } clear() { this.value = null; this.onModelChange(this.value); this.writeValue(this.value); this.onClear.emit(); } /** * @override * * @see {@link BaseEditableHolder.writeControlValue} * Writes the value to the control. */ writeControlValue(value, setModelValue) { if (value === undefined) this.value = null; else this.value = value; if (this.feedback) this.updateUI(this.value || ''); setModelValue(this.value); this.cd.markForCheck(); } ngOnDestroy() { if (this.overlay) { ZIndexUtils.clear(this.overlay); this.overlay = null; } this.restoreAppend(); this.unbindResizeListener(); if (this.scrollHandler) { this.scrollHandler.destroy(); this.scrollHandler = null; } if (this.translationSubscription) { this.translationSubscription.unsubscribe(); } super.ngOnDestroy(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: Password, deps: null, target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.3", type: Password, isStandalone: true, selector: "p-password", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: false, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "ariaLabelledBy", isSignal: false, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: false, isRequired: false, transformFunction: null }, promptLabel: { classPropertyName: "promptLabel", publicName: "promptLabel", isSignal: false, isRequired: false, transformFunction: null }, mediumRegex: { classPropertyName: "mediumRegex", publicName: "mediumRegex", isSignal: false, isRequired: false, transformFunction: null }, strongRegex: { classPropertyName: "strongRegex", publicName: "strongRegex", isSignal: false, isRequired: false, transformFunction: null }, weakLabel: { classPropertyName: "weakLabel", publicName: "weakLabel", isSignal: false, isRequired: false, transformFunction: null }, mediumLabel: { classPropertyName: "mediumLabel", publicName: "mediumLabel", isSignal: false, isRequired: false, transformFunction: null }, maxLength: { classPropertyName: "maxLength", publicName: "maxLength", isSignal: false, isRequired: false, transformFunction: numberAttribute }, strongLabel: { classPropertyName: "strongLabel", publicName: "strongLabel", isSignal: false, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: false, isRequired: false, transformFunction: null }, feedback: { classPropertyName: "feedback", publicName: "feedback", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, toggleMask: { classPropertyName: "toggleMask", publicName: "toggleMask", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, inputStyleClass: { classPropertyName: "inputStyleClass", publicName: "inputStyleClass", isSignal: false, isRequired: false, transformFunction: null }, styleClass: { classPropertyName: "styleClass", publicName: "styleClass", isSignal: false, isRequired: false, transformFunction: null }, inputStyle: { classPropertyName: "inputStyle", publicName: "inputStyle", isSignal: false, isRequired: false, transformFunction: null }, showTransitionOptions: { classPropertyName: "showTransitionOptions", publicName: "showTransitionOptions", isSignal: false, isRequired: false, transformFunction: null }, hideTransitionOptions: { classPropertyName: "hideTransitionOptions", publicName: "hideTransitionOptions", isSignal: false, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: false, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: false, isRequired: false, transformFunction: numberAttribute }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onFocus: "onFocus", onBlur: "onBlur", onClear: "onClear" }, host: { attributes: { "data-pc-name": "password", "data-pc-section": "root" }, properties: { "class": "cn(cx('root'), styleClass)", "style": "sx('root')" } }, providers: [Password_VALUE_ACCESSOR, PasswordStyle], queries: [{ propertyName: "contentTemplate", first: true, predicate: ["content"] }, { propertyName: "footerTemplate", first: true, predicate: ["footer"] }, { propertyName: "headerTemplate", first: true, predicate: ["header"] }, { propertyName: "clearIconTemplate", first: true, predicate: ["clearicon"] }, { propertyName: "hideIconTemplate", first: true, predicate: ["hideicon"] }, { propertyName: "showIconTemplate", first: true, predicate: ["showicon"] }, { propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true }], usesInheritance: true, ngImport: i0, template: ` <input #input [attr.label]="label" [attr.aria-label]="ariaLabel" [attr.aria-labelledBy]="ariaLabelledBy" [attr.id]="inputId" [attr.tabindex]="tabindex" pInputText [pSize]="size()" [ngStyle]="inputStyle" [class]="cn(cx('pcInputText'), inputStyleClass)" [attr.type]="unmasked ? 'text' : 'password'" [attr.placeholder]="placeholder" [attr.autocomplete]="autocomplete" [value]="value" [variant]="$variant()" [attr.name]="name()" [attr.maxlength]="maxlength() || maxLength" [attr.minlength]="minlength()" [attr.required]="required() ? '' : undefined" [attr.disabled]="$disabled() ? '' : undefined" [invalid]="invalid()" (input)="onInput($event)" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" (keyup)="onKeyUp($event)" [attr.data-pc-section]="'input'" [pAutoFocus]="autofocus" /> <ng-container *ngIf="showClear && value != null"> <svg data-p-icon="times" *ngIf="!clearIconTemplate && !_clearIconTemplate" [class]="cx('clearIcon')" (click)="clear()" [attr.data-pc-section]="'clearIcon'" /> <span (click)="clear()" [class]="cx('clearIcon')" [attr.data-pc-section]="'clearIcon'"> <ng-template *ngTemplateOutlet="clearIconTemplate || _clearIconTemplate"></ng-template> </span> </ng-container> <ng-container *ngIf="toggleMask"> <ng-container *ngIf="unmasked"> <svg data-p-icon="eyeslash" [class]="cx('maskIcon')" *ngIf="!hideIconTemplate && !_hideIconTemplate" (click)="onMaskToggle()" [attr.data-pc-section]="'hideIcon'" /> <span *ngIf="hideIconTemplate || _hideIconTemplate" (click)="onMaskToggle()"> <ng-template *ngTemplateOutlet="hideIconTemplate || _hideIconTemplate; context: { class: cx('maskIcon') }"></ng-template> </span> </ng-container> <ng-container *ngIf="!unmasked"> <svg data-p-icon="eye" *ngIf="!showIconTemplate && !_showIconTemplate" [class]="cx('unmaskIcon')" (click)="onMaskToggle()" [attr.data-pc-section]="'showIcon'" /> <span *ngIf="showIconTemplate || _showIconTemplate" (click)="onMaskToggle()"> <ng-template *ngTemplateOutlet="showIconTemplate || _showIconTemplate; context: { class: cx('unmaskIcon') }"></ng-template> </span> </ng-container> </ng-container> <div #overlay *ngIf="overlayVisible" [class]="cx('overlay')" [style]="sx('overlay')" (click)="onOverlayClick($event)" [@overlayAnimation]="{ value: 'visible', params: { showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions } }" (@overlayAnimation.start)="onAnimationStart($event)" (@overlayAnimation.done)="onAnimationEnd($event)" [attr.data-pc-section]="'panel'" > <ng-container *ngTemplateOutlet="headerTemplate || _headerTemplate"></ng-container> <ng-container *ngIf="contentTemplate || _contentTemplate; else content"> <ng-container *ngTemplateOutlet="contentTemplate || _contentTemplate"></ng-container> </ng-container> <ng-template #content> <div [class]="cx('content')"> <div [class]="cx('meter')" [attr.data-pc-section]="'meter'"> <div [class]="cx('meterLabel')" [ngStyle]="{ width: meter ? meter.width : '' }" [attr.data-pc-section]="'meterLabel'"></div> </div> <div [class]="cx('meterText')" [attr.data-pc-section]="'info'">{{ infoText }}</div> </div> </ng-template> <ng-container *ngTemplateOutlet="footerTemplate || _footerTemplate"></ng-container> </div> `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: InputText, selector: "[pInputText]", inputs: ["pSize", "variant", "fluid", "invalid"] }, { kind: "directive", type: AutoFocus, selector: "[pAutoFocus]", inputs: ["pAutoFocus"] }, { kind: "component", type: TimesIcon, selector: "[data-p-icon=\"times\"]" }, { kind: "component", type: EyeSlashIcon, selector: "[data-p-icon=\"eyeslash\"]" }, { kind: "component", type: EyeIcon, selector: "[data-p-icon=\"eye\"]" }, { kind: "ngmodule", type: SharedModule }], animations: [trigger('overlayAnimation', [transition(':enter', [style$1({ opacity: 0, transform: 'scaleY(0.8)' }), animate('{{showTransitionParams}}')]), transition(':leave', [animate('{{hideTransitionParams}}', style$1({ opacity: 0 }))])])], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: Password, decorators: [{ type: Component, args: [{ selector: 'p-password', standalone: true, imports: [CommonModule, InputText, AutoFocus, TimesIcon, EyeSlashIcon, EyeIcon, SharedModule], template: ` <input #input [attr.label]="label" [attr.aria-label]="ariaLabel" [attr.aria-labelledBy]="ariaLabelledBy" [attr.id]="inputId" [attr.tabindex]="tabindex" pInputText [pSize]="size()" [ngStyle]="inputStyle" [class]="cn(cx('pcInputText'), inputStyleClass)" [attr.type]="unmasked ? 'text' : 'password'" [attr.placeholder]="placeholder" [attr.autocomplete]="autocomplete" [value]="value" [variant]="$variant()" [attr.name]="name()" [attr.maxlength]="maxlength() || maxLength" [attr.minlength]="minlength()" [attr.required]="required() ? '' : undefined" [attr.disabled]="$disabled() ? '' : undefined" [invalid]="invalid()" (input)="onInput($event)" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" (keyup)="onKeyUp($event)" [attr.data-pc-section]="'input'" [pAutoFocus]="autofocus" /> <ng-container *ngIf="showClear && value != null"> <svg data-p-icon="times" *ngIf="!clearIconTemplate && !_clearIconTemplate" [class]="cx('clearIcon')" (click)="clear()" [attr.data-pc-section]="'clearIcon'" /> <span (click)="clear()" [class]="cx('clearIcon')" [attr.data-pc-section]="'clearIcon'"> <ng-template *ngTemplateOutlet="clearIconTemplate || _clearIconTemplate"></ng-template> </span> </ng-container> <ng-container *ngIf="toggleMask"> <ng-container *ngIf="unmasked"> <svg data-p-icon="eyeslash" [class]="cx('maskIcon')" *ngIf="!hideIconTemplate && !_hideIconTemplate" (click)="onMaskToggle()" [attr.data-pc-section]="'hideIcon'" /> <span *ngIf="hideIconTemplate || _hideIconTemplate" (click)="onMaskToggle()"> <ng-template *ngTemplateOutlet="hideIconTemplate || _hideIconTemplate; context: { class: cx('maskIcon') }"></ng-template> </span> </ng-container> <ng-container *ngIf="!unmasked"> <svg data-p-icon="eye" *ngIf="!showIconTemplate && !_showIconTemplate" [class]="cx('unmaskIcon')" (click)="onMaskToggle()" [attr.data-pc-section]="'showIcon'" /> <span *ngIf="showIconTemplate || _showIconTemplate" (click)="onMaskToggle()"> <ng-template *ngTemplateOutlet="showIconTemplate || _showIconTemplate; context: { class: cx('unmaskIcon') }"></ng-template> </span> </ng-container> </ng-container> <div #overlay *ngIf="overlayVisible" [class]="cx('overlay')" [style]="sx('overlay')" (click)="onOverlayClick($event)" [@overlayAnimation]="{ value: 'visible', params: { showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions } }" (@overlayAnimation.start)="onAnimationStart($event)" (@overlayAnimation.done)="onAnimationEnd($event)" [attr.data-pc-section]="'panel'" > <ng-container *ngTemplateOutlet="headerTemplate || _headerTemplate"></ng-container> <ng-container *ngIf="contentTemplate || _contentTemplate; else content"> <ng-container *ngTemplateOutlet="contentTemplate || _contentTemplate"></ng-container> </ng-container> <ng-template #content> <div [class]="cx('content')"> <div [class]="cx('meter')" [attr.data-pc-section]="'meter'"> <div [class]="cx('meterLabel')" [ngStyle]="{ width: meter ? meter.width : '' }" [attr.data-pc-section]="'meterLabel'"></div> </div> <div [class]="cx('meterText')" [attr.data-pc-section]="'info'">{{ infoText }}</div> </div> </ng-template> <ng-container *ngTemplateOutlet="footerTemplate || _footerTemplate"></ng-container> </div> `, animations: [trigger('overlayAnimation', [transition(':enter', [style$1({ opacity: 0, transform: 'scaleY(0.8)' }), animate('{{showTransitionParams}}')]), transition(':leave', [animate('{{hideTransitionParams}}', style$1({ opacity: 0 }))])])], providers: [Password_VALUE_ACCESSOR, PasswordStyle], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { '[class]': "cn(cx('root'), styleClass)", '[style]': "sx('root')", 'data-pc-name': 'password', 'data-pc-section': 'root' } }] }], propDecorators: { ariaLabel: [{ type: Input }], ariaLabelledBy: [{ type: Input }], label: [{ type: Input }], promptLabel: [{ type: Input }], mediumRegex: [{ type: Input }], strongRegex: [{ type: Input }], weakLabel: [{ type: Input }], mediumLabel: [{ type: Input }], maxLength: [{ type: Input, args: [{ transform: numberAttribute }] }], strongLabel: [{ type: Input }], inputId: [{ type: Input }], feedback: [{ type: Input, args: [{ transform: booleanAttribute }] }], toggleMask: [{ type: Input, args: [{ transform: booleanAttribute }] }], inputStyleClass: [{ type: Input }], styleClass: [{ type: Input }], inputStyle: [{ type: Input }], showTransitionOptions: [{ type: Input }], hideTransitionOptions: [{ type: Input }], autocomplete: [{ type: Input }], placeholder: [{ type: Input }], showClear: [{ type: Input, args: [{ transform: booleanAttribute }] }], autofocus: [{ type: Input, args: [{ transform: booleanAttribute }] }], tabindex: [{ type: Input, args: [{ transform: numberAttribute }] }], onFocus: [{ type: Output }], onBlur: [{ type: Output }], onClear: [{ type: Output }], input: [{ type: ViewChild, args: ['input'] }], contentTemplate: [{ type: ContentChild, args: ['content', { descendants: false }] }], footerTemplate: [{ type: ContentChild, args: ['footer', { descendants: false }] }], headerTemplate: [{ type: ContentChild, args: ['header', { descendants: false }] }], clearIconTemplate: [{ type: ContentChild, args: ['clearicon', { descendants: false }] }], hideIconTemplate: [{ type: ContentChild, args: ['hideicon', { descendants: false }] }], showIconTemplate: [{ type: ContentChild, args: ['showicon', { descendants: false }] }], templates: [{ type: ContentChildren, args: [PrimeTemplate] }] } }); class PasswordModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PasswordModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.3", ngImport: i0, type: PasswordModule, imports: [Password, PasswordDirective, SharedModule], exports: [PasswordDirective, Password, SharedModule] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PasswordModule, imports: [Password, SharedModule, SharedModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PasswordModule, decorators: [{ type: NgModule, args: [{