1 line
4.1 KiB
Plaintext
1 line
4.1 KiB
Plaintext
{"version":3,"file":"primeng-autofocus.mjs","sources":["../../src/app/components/autofocus/autofocus.ts","../../src/app/components/autofocus/primeng-autofocus.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Directive, ElementRef, Input, NgModule, booleanAttribute } from '@angular/core';\nimport { DomHandler } from 'primeng/dom';\n/**\n * AutoFocus manages focus on focusable element on load.\n * @group Components\n */\n@Directive({\n selector: '[pAutoFocus]',\n host: {\n class: 'p-element'\n }\n})\nexport class AutoFocus {\n constructor(private host: ElementRef) {}\n /**\n * When present, it specifies that the component should automatically get focus on load.\n * @group Props\n */\n @Input({ transform: booleanAttribute }) autofocus: boolean = false;\n\n focused: boolean = false;\n\n ngAfterContentChecked() {\n // This sets the `attr.autofocus` which is different than the Input `autofocus` attribute.\n if (this.autofocus === false) {\n this.host.nativeElement.removeAttribute('autofocus');\n } else {\n this.host.nativeElement.setAttribute('autofocus', true);\n }\n\n if (!this.focused) {\n if (this.autofocus) {\n setTimeout(() => {\n const focusableElements = DomHandler.getFocusableElements(this.host.nativeElement);\n\n if (focusableElements.length === 0) {\n this.host.nativeElement.focus();\n }\n if (focusableElements.length > 0) {\n focusableElements[0].focus();\n }\n\n this.focused = true;\n });\n }\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [AutoFocus],\n declarations: [AutoFocus]\n})\nexport class AutoFocusModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;AAGA;;;AAGG;MAOU,SAAS,CAAA;AACE,IAAA,IAAA,CAAA;AAApB,IAAA,WAAA,CAAoB,IAAgB,EAAA;QAAhB,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;KAAI;AACxC;;;AAGG;IACqC,SAAS,GAAY,KAAK,CAAC;IAEnE,OAAO,GAAY,KAAK,CAAC;IAEzB,qBAAqB,GAAA;;AAEjB,QAAA,IAAI,IAAI,CAAC,SAAS,K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