forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist-item-sections.ts
109 lines (98 loc) · 3.59 KB
/
list-item-sections.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Directive, ElementRef, inject} from '@angular/core';
import {LIST_OPTION, ListOption} from './list-option-types';
/**
* Directive capturing the title of a list item. A list item usually consists of a
* title and optional secondary or tertiary lines.
*
* Text content for the title never wraps. There can only be a single title per list item.
*/
@Directive({
selector: '[matListItemTitle]',
host: {'class': 'mat-mdc-list-item-title mdc-list-item__primary-text'},
})
export class MatListItemTitle {
_elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
constructor(...args: unknown[]);
constructor() {}
}
/**
* Directive capturing a line in a list item. A list item usually consists of a
* title and optional secondary or tertiary lines.
*
* Text content inside a line never wraps. There can be at maximum two lines per list item.
*/
@Directive({
selector: '[matListItemLine]',
host: {'class': 'mat-mdc-list-item-line mdc-list-item__secondary-text'},
})
export class MatListItemLine {
_elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
constructor(...args: unknown[]);
constructor() {}
}
/**
* Directive matching an optional meta section for list items.
*
* List items can reserve space at the end of an item to display a control,
* button or additional text content.
*/
@Directive({
selector: '[matListItemMeta]',
host: {'class': 'mat-mdc-list-item-meta mdc-list-item__end'},
})
export class MatListItemMeta {}
/**
* @docs-private
*
* MDC uses the very intuitively named classes `.mdc-list-item__start` and `.mat-list-item__end` to
* position content such as icons or checkboxes/radios that comes either before or after the text
* content respectively. This directive detects the placement of the checkbox/radio and applies the
* correct MDC class to position the icon/avatar on the opposite side.
*/
@Directive({
host: {
// MDC uses intuitively named classes `.mdc-list-item__start` and `.mat-list-item__end` to
// position content such as icons or checkboxes/radios that comes either before or after the
// text content respectively. This directive detects the placement of the checkbox/radio and
// applies the correct MDC class to position the icon/avatar on the opposite side.
'[class.mdc-list-item__start]': '_isAlignedAtStart()',
'[class.mdc-list-item__end]': '!_isAlignedAtStart()',
},
})
export class _MatListItemGraphicBase {
_listOption = inject<ListOption>(LIST_OPTION, {optional: true});
constructor(...args: unknown[]);
constructor() {}
_isAlignedAtStart() {
// By default, in all list items the graphic is aligned at start. In list options,
// the graphic is only aligned at start if the checkbox/radio is at the end.
return !this._listOption || this._listOption?._getTogglePosition() === 'after';
}
}
/**
* Directive matching an optional avatar within a list item.
*
* List items can reserve space at the beginning of an item to display an avatar.
*/
@Directive({
selector: '[matListItemAvatar]',
host: {'class': 'mat-mdc-list-item-avatar'},
})
export class MatListItemAvatar extends _MatListItemGraphicBase {}
/**
* Directive matching an optional icon within a list item.
*
* List items can reserve space at the beginning of an item to display an icon.
*/
@Directive({
selector: '[matListItemIcon]',
host: {'class': 'mat-mdc-list-item-icon'},
})
export class MatListItemIcon extends _MatListItemGraphicBase {}