|
12 | 12 | // See the License for the specific language governing permissions and
|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
15 |
| -import { Component, AfterViewInit, Input, ContentChild, ViewEncapsulation } from '@angular/core'; |
| 15 | +import { Component, ViewEncapsulation, input, contentChild, effect } from '@angular/core'; |
16 | 16 | import { IonInput } from '@ionic/angular';
|
17 | 17 | import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
18 | 18 |
|
@@ -51,43 +51,42 @@ import { CoreBaseModule } from '@/core/base.module';
|
51 | 51 | encapsulation: ViewEncapsulation.None,
|
52 | 52 | imports: [CoreBaseModule],
|
53 | 53 | })
|
54 |
| -export class CoreShowPasswordComponent implements AfterViewInit { |
| 54 | +export class CoreShowPasswordComponent { |
55 | 55 |
|
56 | 56 | /**
|
57 | 57 | * @deprecated since 4.5. Not used anymore.
|
58 | 58 | */
|
59 |
| - @Input() initialShown = ''; |
| 59 | + readonly initialShown = input(''); |
60 | 60 |
|
61 | 61 | /**
|
62 | 62 | * @deprecated since 4.4. Not used anymore.
|
63 | 63 | */
|
64 |
| - @Input() name = ''; |
| 64 | + readonly name = input(''); |
65 | 65 |
|
66 | 66 | /**
|
67 | 67 | * @deprecated since 4.4. Use slotted solution instead.
|
68 | 68 | */
|
69 |
| - @ContentChild(IonInput) ionInput?: IonInput | HTMLIonInputElement; |
| 69 | + readonly ionInput = contentChild<IonInput | HTMLIonInputElement>(IonInput); |
70 | 70 |
|
71 |
| - /** |
72 |
| - * @inheritdoc |
73 |
| - */ |
74 |
| - async ngAfterViewInit(): Promise<void> { |
| 71 | + constructor() { |
75 | 72 | CoreLogger.getInstance('CoreShowPasswordComponent')
|
76 | 73 | .warn('Deprecated component, use <ion-input-password-toggle /> instead.');
|
77 | 74 |
|
78 |
| - // eslint-disable-next-line @typescript-eslint/no-deprecated |
79 |
| - if (!this.ionInput) { |
80 |
| - return; |
81 |
| - } |
| 75 | + effect(async () => { |
| 76 | + // eslint-disable-next-line @typescript-eslint/no-deprecated |
| 77 | + const ionInput = this.ionInput(); |
| 78 | + if (!ionInput) { |
| 79 | + return; |
| 80 | + } |
82 | 81 |
|
83 |
| - // eslint-disable-next-line @typescript-eslint/no-deprecated |
84 |
| - const input = await CorePromiseUtils.ignoreErrors(this.ionInput.getInputElement()); |
85 |
| - if (!input) { |
86 |
| - return; |
87 |
| - } |
| 82 | + const input = await CorePromiseUtils.ignoreErrors(ionInput.getInputElement()); |
| 83 | + if (!input) { |
| 84 | + return; |
| 85 | + } |
88 | 86 |
|
89 |
| - const toggle = convertTextToHTMLElement('<ion-input-password-toggle slot="end" />'); |
90 |
| - input.parentElement?.appendChild(toggle.children[0]); |
| 87 | + const toggle = convertTextToHTMLElement('<ion-input-password-toggle slot="end" />'); |
| 88 | + input.parentElement?.appendChild(toggle.children[0]); |
| 89 | + }); |
91 | 90 | }
|
92 | 91 |
|
93 | 92 | }
|
0 commit comments