File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
src/cdk-experimental/ui-patterns Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ function getExpansion(inputs: TestInputs = {}): {
6868 skipDisabled : focusManager . inputs . skipDisabled ,
6969 focusMode : focusManager . inputs . focusMode ,
7070 multiExpandable : inputs . multiExpandable ?? signal ( false ) ,
71+ expandedIds : signal ( [ ] ) ,
7172 focusManager,
7273 } ) ;
7374
Original file line number Diff line number Diff line change @@ -22,17 +22,22 @@ export interface ExpansionItem extends ListFocusItem {
2222export interface ExpansionInputs < T extends ExpansionItem > extends ListFocusInputs < T > {
2323 /** Whether multiple items can be expanded at once. */
2424 multiExpandable : SignalLike < boolean > ;
25+
26+ /** An array of ids of the currently expanded items. */
27+ expandedIds : WritableSignalLike < string [ ] > ;
2528}
2629
2730/** Manages the expansion state of a list of items. */
2831export class Expansion < T extends ExpansionItem > {
2932 /** A signal holding an array of ids of the currently expanded items. */
30- expandedIds : WritableSignalLike < string [ ] > = signal ( [ ] ) ;
33+ expandedIds : WritableSignalLike < string [ ] > ;
3134
3235 /** The currently active (focused) item in the list. */
3336 activeItem = computed ( ( ) => this . inputs . focusManager . activeItem ( ) ) ;
3437
35- constructor ( readonly inputs : ExpansionInputs < T > & { focusManager : ListFocus < T > } ) { }
38+ constructor ( readonly inputs : ExpansionInputs < T > & { focusManager : ListFocus < T > } ) {
39+ this . expandedIds = inputs . expandedIds ?? signal ( [ ] ) ;
40+ }
3641
3742 /** Opens the specified item, or the currently active item if none is specified. */
3843 open ( item : T = this . activeItem ( ) ) {
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export class TabPattern {
7878 this . value = inputs . value ;
7979 this . disabled = inputs . disabled ;
8080 this . element = inputs . element ;
81- this . expansionId = inputs . id ;
81+ this . expansionId = inputs . value ;
8282 }
8383}
8484
@@ -115,7 +115,7 @@ interface SelectOptions {
115115export type TabListInputs = ListNavigationInputs < TabPattern > &
116116 Omit < ListSelectionInputs < TabPattern , string > , 'multi' > &
117117 ListFocusInputs < TabPattern > &
118- Omit < ExpansionInputs < TabPattern > , 'multiExpandable' > & {
118+ Omit < ExpansionInputs < TabPattern > , 'multiExpandable' | 'expandedIds' > & {
119119 disabled : SignalLike < boolean > ;
120120 } ;
121121
@@ -196,6 +196,7 @@ export class TabListPattern {
196196 this . expansionBehavior = new Expansion ( {
197197 ...inputs ,
198198 multiExpandable : ( ) => false ,
199+ expandedIds : this . inputs . value ,
199200 focusManager : this . focusManager ,
200201 } ) ;
201202 }
You can’t perform that action at this time.
0 commit comments