diff --git a/npm/ng-packs/apps/dev-app/src/app/app.module.ts b/npm/ng-packs/apps/dev-app/src/app/app.module.ts index ac56d2736e..7e903dff0d 100644 --- a/npm/ng-packs/apps/dev-app/src/app/app.module.ts +++ b/npm/ng-packs/apps/dev-app/src/app/app.module.ts @@ -12,7 +12,7 @@ import { SettingManagementConfigModule } from '@abp/ng.setting-management/config import { TenantManagementConfigModule } from '@abp/ng.tenant-management/config'; import { FeatureManagementModule } from '@abp/ng.feature-management'; import { AccountConfigModule } from '@abp/ng.account/config'; -import { AccountLayoutModule } from '@abp/ng.theme.lepton-x/account/account-layout'; +import { AccountLayoutModule } from '@abp/ng.theme.lepton-x/account'; import { environment } from '../environments/environment'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; diff --git a/npm/ng-packs/packages/core/src/lib/directives/caps-lock.directive.ts b/npm/ng-packs/packages/core/src/lib/directives/caps-lock.directive.ts new file mode 100644 index 0000000000..0194bb9d3e --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/directives/caps-lock.directive.ts @@ -0,0 +1,30 @@ +import { Directive, EventEmitter, HostListener, Output } from '@angular/core'; + +@Directive({ + standalone: true, + selector: '[abpCapsLock]', +}) +export class TrackCapsLockDirective { + @Output('abpCapsLock') capsLock = new EventEmitter(); + + @HostListener('window:keydown', ['$event']) + onKeyDown(event: KeyboardEvent): void { + this.capsLock.emit(this.isCapsLockOpen(event)); + } + @HostListener('window:keyup', ['$event']) + onKeyUp(event: KeyboardEvent): void { + this.capsLock.emit(this.isCapsLockOpen(event)); + } + + isCapsLockOpen(e): boolean { + var s = String.fromCharCode(e.which); + if ( + (s.toUpperCase() === s && s.toLowerCase() !== s && e.shiftKey) || + (s.toUpperCase() !== s && s.toLowerCase() === s && e.shiftKey) || + e.getModifierState('CapsLock') + ) { + return true; + } + return false; + } +} diff --git a/npm/ng-packs/packages/core/src/lib/directives/index.ts b/npm/ng-packs/packages/core/src/lib/directives/index.ts index 8f05e2daae..d5d6e22c31 100644 --- a/npm/ng-packs/packages/core/src/lib/directives/index.ts +++ b/npm/ng-packs/packages/core/src/lib/directives/index.ts @@ -6,3 +6,5 @@ export * from './init.directive'; export * from './permission.directive'; export * from './replaceable-template.directive'; export * from './stop-propagation.directive'; +export * from './show-password.directive'; +export * from './caps-lock.directive'; diff --git a/npm/ng-packs/packages/core/src/lib/directives/show-password.directive.ts b/npm/ng-packs/packages/core/src/lib/directives/show-password.directive.ts new file mode 100644 index 0000000000..03dc44f6a5 --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/directives/show-password.directive.ts @@ -0,0 +1,16 @@ +import { Directive, ElementRef, Input, inject } from '@angular/core'; + +@Directive({ + standalone: true, + selector: '[abpShowPassword]', +}) +export class ShowPasswordDirective { + protected readonly elementRef = inject(ElementRef); + + @Input() set abpShowPassword(visible: boolean) { + const element = this.elementRef.nativeElement as HTMLInputElement; + if (!element) return; + + element.type = visible ? 'text' : 'password'; + } +}