1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Directive, InjectionToken, Input } from '@angular/core';
|
---|
9 | let nextUniqueId = 0;
|
---|
10 | /**
|
---|
11 | * Injection token that can be used to reference instances of `MatHint`. It serves as
|
---|
12 | * alternative token to the actual `MatHint` class which could cause unnecessary
|
---|
13 | * retention of the class and its directive metadata.
|
---|
14 | *
|
---|
15 | * *Note*: This is not part of the public API as the MDC-based form-field will not
|
---|
16 | * need a lightweight token for `MatHint` and we want to reduce breaking changes.
|
---|
17 | */
|
---|
18 | export const _MAT_HINT = new InjectionToken('MatHint');
|
---|
19 | /** Hint text to be shown underneath the form field control. */
|
---|
20 | export class MatHint {
|
---|
21 | constructor() {
|
---|
22 | /** Whether to align the hint label at the start or end of the line. */
|
---|
23 | this.align = 'start';
|
---|
24 | /** Unique ID for the hint. Used for the aria-describedby on the form field control. */
|
---|
25 | this.id = `mat-hint-${nextUniqueId++}`;
|
---|
26 | }
|
---|
27 | }
|
---|
28 | MatHint.decorators = [
|
---|
29 | { type: Directive, args: [{
|
---|
30 | selector: 'mat-hint',
|
---|
31 | host: {
|
---|
32 | 'class': 'mat-hint',
|
---|
33 | '[class.mat-form-field-hint-end]': 'align === "end"',
|
---|
34 | '[attr.id]': 'id',
|
---|
35 | // Remove align attribute to prevent it from interfering with layout.
|
---|
36 | '[attr.align]': 'null',
|
---|
37 | },
|
---|
38 | providers: [{ provide: _MAT_HINT, useExisting: MatHint }],
|
---|
39 | },] }
|
---|
40 | ];
|
---|
41 | MatHint.propDecorators = {
|
---|
42 | align: [{ type: Input }],
|
---|
43 | id: [{ type: Input }]
|
---|
44 | };
|
---|
45 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGludC5qcyIsInNvdXJjZVJvb3QiO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