@@ -21,28 +21,28 @@ import {
21
21
import { Directionality } from '@angular/cdk/bidi' ;
22
22
import { DeferredContent , DeferredContentAware } from '@angular/cdk-experimental/deferred-content' ;
23
23
import { TabPattern } from '@angular/cdk-experimental/ui-patterns/tabs/tab' ;
24
- import { TablistPattern } from '@angular/cdk-experimental/ui-patterns/tabs/tablist' ;
25
- import { TabpanelPattern } from '@angular/cdk-experimental/ui-patterns/tabs/tabpanel' ;
24
+ import { TabListPattern } from '@angular/cdk-experimental/ui-patterns/tabs/tablist' ;
25
+ import { TabPanelPattern } from '@angular/cdk-experimental/ui-patterns/tabs/tabpanel' ;
26
26
import { toSignal } from '@angular/core/rxjs-interop' ;
27
27
import { _IdGenerator } from '@angular/cdk/a11y' ;
28
28
29
29
/**
30
30
* A Tabs container.
31
31
*
32
32
* Represents a set of layered sections of content. The CdkTabs is a container meant to be used with
33
- * CdkTablist , CdkTab, and CdkTabpanel as follows:
33
+ * CdkTabList , CdkTab, and CdkTabPanel as follows:
34
34
*
35
35
* ```html
36
36
* <div cdkTabs>
37
- * <ul cdkTablist >
37
+ * <ul cdkTabList >
38
38
* <li cdkTab>Tab 1</li>
39
39
* <li cdkTab>Tab 2</li>
40
40
* <li cdkTab>Tab 3</li>
41
41
* </ul>
42
42
*
43
- * <div cdkTabpanel >Tab content 1</div>
44
- * <div cdkTabpanel >Tab content 2</div>
45
- * <div cdkTabpanel >Tab content 3</div>
43
+ * <div cdkTabPanel >Tab content 1</div>
44
+ * <div cdkTabPanel >Tab content 2</div>
45
+ * <div cdkTabPanel >Tab content 3</div>
46
46
* </div>
47
47
* ```
48
48
*/
@@ -57,24 +57,24 @@ export class CdkTabs {
57
57
/** The CdkTabs nested inside of the container. */
58
58
private readonly _cdkTabs = contentChildren ( CdkTab , { descendants : true } ) ;
59
59
60
- /** The CdkTabpanels nested inside of the container. */
61
- private readonly _cdkTabpanels = contentChildren ( CdkTabpanel , { descendants : true } ) ;
60
+ /** The CdkTabPanels nested inside of the container. */
61
+ private readonly _cdkTabPanels = contentChildren ( CdkTabPanel , { descendants : true } ) ;
62
62
63
63
/** The Tab UIPattern of the child Tabs. */
64
64
tabs = computed ( ( ) => this . _cdkTabs ( ) . map ( tab => tab . pattern ) ) ;
65
65
66
- /** The Tabpanel UIPattern of the child Tabpanels . */
67
- tabpanels = computed ( ( ) => this . _cdkTabpanels ( ) . map ( tabpanel => tabpanel . pattern ) ) ;
66
+ /** The TabPanel UIPattern of the child TabPanels . */
67
+ tabpanels = computed ( ( ) => this . _cdkTabPanels ( ) . map ( tabpanel => tabpanel . pattern ) ) ;
68
68
}
69
69
70
70
/**
71
- * A Tablist container.
71
+ * A TabList container.
72
72
*
73
73
* Controls a list of CdkTab(s).
74
74
*/
75
75
@Directive ( {
76
- selector : '[cdkTablist ]' ,
77
- exportAs : 'cdkTablist ' ,
76
+ selector : '[cdkTabList ]' ,
77
+ exportAs : 'cdkTabList ' ,
78
78
host : {
79
79
'role' : 'tablist' ,
80
80
'class' : 'cdk-tablist' ,
@@ -86,11 +86,11 @@ export class CdkTabs {
86
86
'(pointerdown)' : 'pattern.onPointerdown($event)' ,
87
87
} ,
88
88
} )
89
- export class CdkTablist {
89
+ export class CdkTabList {
90
90
/** The directionality (LTR / RTL) context for the application (or a subtree of it). */
91
91
private readonly _directionality = inject ( Directionality ) ;
92
92
93
- /** The CdkTabs nested inside of the CdkTablist . */
93
+ /** The CdkTabs nested inside of the CdkTabList . */
94
94
private readonly _cdkTabs = contentChildren ( CdkTab ) ;
95
95
96
96
/** A signal wrapper for directionality. */
@@ -122,16 +122,16 @@ export class CdkTablist {
122
122
/** The current index that has been navigated to. */
123
123
activeIndex = model < number > ( 0 ) ;
124
124
125
- /** The Tablist UIPattern. */
126
- pattern : TablistPattern = new TablistPattern ( {
125
+ /** The TabList UIPattern. */
126
+ pattern : TabListPattern = new TabListPattern ( {
127
127
...this ,
128
128
items : this . tabs ,
129
129
textDirection : this . textDirection ,
130
130
value : signal < string [ ] > ( [ ] ) ,
131
131
} ) ;
132
132
}
133
133
134
- /** A selectable tab in a tablist . */
134
+ /** A selectable tab in a TabList . */
135
135
@Directive ( {
136
136
selector : '[cdkTab]' ,
137
137
exportAs : 'cdkTab' ,
@@ -152,46 +152,48 @@ export class CdkTab {
152
152
/** The parent CdkTabs. */
153
153
private readonly _cdkTabs = inject ( CdkTabs ) ;
154
154
155
- /** The parent CdkTablist . */
156
- private readonly _cdkTablist = inject ( CdkTablist ) ;
155
+ /** The parent CdkTabList . */
156
+ private readonly _cdkTabList = inject ( CdkTabList ) ;
157
157
158
- /** A unique identifier for the tab. */
158
+ /** A global unique identifier for the tab. */
159
159
private readonly _id = inject ( _IdGenerator ) . getId ( 'cdk-tab-' ) ;
160
160
161
- /** The position of the tab in the list . */
162
- protected index = computed ( ( ) => this . _cdkTabs . tabs ( ) . findIndex ( tab => tab . id ( ) === this . _id ) ) ;
161
+ /** The parent TabList UIPattern . */
162
+ protected tablist = computed ( ( ) => this . _cdkTabList . pattern ) ;
163
163
164
- /** The parent Tablist UIPattern. */
165
- protected tablist = computed ( ( ) => this . _cdkTablist . pattern ) ;
166
-
167
- /** The Tabpanel UIPattern associated with the tab */
168
- protected tabpanel = computed ( ( ) => this . _cdkTabs . tabpanels ( ) [ this . index ( ) ] ) ;
164
+ /** The TabPanel UIPattern associated with the tab */
165
+ protected tabpanel = computed ( ( ) =>
166
+ this . _cdkTabs . tabpanels ( ) . find ( tabpanel => tabpanel . value ( ) === this . value ( ) ) ,
167
+ ) ;
169
168
170
169
/** Whether a tab is disabled. */
171
170
disabled = input ( false , { transform : booleanAttribute } ) ;
172
171
172
+ /** A local unique identifier for the tab. */
173
+ value = input . required < string > ( ) ;
174
+
173
175
/** The Tab UIPattern. */
174
176
pattern : TabPattern = new TabPattern ( {
175
177
...this ,
176
178
id : ( ) => this . _id ,
177
- value : ( ) => this . _id ,
178
179
element : ( ) => this . _elementRef . nativeElement ,
179
180
tablist : this . tablist ,
180
181
tabpanel : this . tabpanel ,
182
+ value : this . value ,
181
183
} ) ;
182
184
}
183
185
184
186
/**
185
- * A Tabpanel container for the resources of layered content associated with a tab.
187
+ * A TabPanel container for the resources of layered content associated with a tab.
186
188
*
187
189
* If a tabpanel is hidden due to its corresponding tab is not activated, the `inert` attribute
188
190
* will be applied to the tabpanel element to remove it from the accessibility tree and stop
189
191
* all the keyboard and pointer interactions. Note that this does not visually hide the tabpenl
190
192
* and a proper styling is required.
191
193
*/
192
194
@Directive ( {
193
- selector : '[cdkTabpanel ]' ,
194
- exportAs : 'cdkTabpanel ' ,
195
+ selector : '[cdkTabPanel ]' ,
196
+ exportAs : 'cdkTabPanel ' ,
195
197
host : {
196
198
'role' : 'tabpanel' ,
197
199
'tabindex' : '0' ,
@@ -206,26 +208,24 @@ export class CdkTab {
206
208
} ,
207
209
] ,
208
210
} )
209
- export class CdkTabpanel {
211
+ export class CdkTabPanel {
210
212
/** The DeferredContentAware host directive. */
211
213
private readonly _deferredContentAware = inject ( DeferredContentAware ) ;
212
214
213
215
/** The parent CdkTabs. */
214
216
private readonly _cdkTabs = inject ( CdkTabs ) ;
215
217
216
- /** A unique identifier for the tab. */
218
+ /** A global unique identifier for the tab. */
217
219
private readonly _id = inject ( _IdGenerator ) . getId ( 'cdk-tabpanel-' ) ;
218
220
219
- /** The position of the tabpanel in the tabs. */
220
- protected index = computed ( ( ) =>
221
- this . _cdkTabs . tabpanels ( ) . findIndex ( tabpanel => tabpanel . id ( ) === this . _id ) ,
222
- ) ;
223
-
224
221
/** The Tab UIPattern associated with the tabpanel */
225
- protected tab = computed ( ( ) => this . _cdkTabs . tabs ( ) [ this . index ( ) ] ) ;
222
+ protected tab = computed ( ( ) => this . _cdkTabs . tabs ( ) . find ( tab => tab . value ( ) === this . value ( ) ) ) ;
223
+
224
+ /** A local unique identifier for the tabpanel. */
225
+ value = input . required < string > ( ) ;
226
226
227
- /** The Tabpanel UIPattern. */
228
- pattern : TabpanelPattern = new TabpanelPattern ( {
227
+ /** The TabPanel UIPattern. */
228
+ pattern : TabPanelPattern = new TabPanelPattern ( {
229
229
...this ,
230
230
id : ( ) => this . _id ,
231
231
tab : this . tab ,
@@ -237,11 +237,11 @@ export class CdkTabpanel {
237
237
}
238
238
239
239
/**
240
- * A Tabcontent container for the lazy-loaded content.
240
+ * A TabContent container for the lazy-loaded content.
241
241
*/
242
242
@Directive ( {
243
- selector : 'ng-template[cdkTabcontent ]' ,
244
- exportAs : 'cdTabcontent ' ,
243
+ selector : 'ng-template[cdkTabContent ]' ,
244
+ exportAs : 'cdTabContent ' ,
245
245
hostDirectives : [ DeferredContent ] ,
246
246
} )
247
- export class CdkTabcontent { }
247
+ export class CdkTabContent { }
0 commit comments