@@ -21,11 +21,15 @@ import {
2121 ListSelectionInputs ,
2222 ListSelectionItem ,
2323} from '../behaviors/list-selection/list-selection' ;
24+ import { ExpansionControl , ExpansionPanel } from '../behaviors/expansion/expansion' ;
2425import { SignalLike } from '../behaviors/signal-like/signal-like' ;
2526
2627/** The required inputs to tabs. */
2728export interface TabInputs extends ListNavigationItem , ListSelectionItem < string > , ListFocusItem {
29+ /** The parent tablist that controls the tab. */
2830 tablist : SignalLike < TabListPattern > ;
31+
32+ /** The remote tabpanel controlled by the tab. */
2933 tabpanel : SignalLike < TabPanelPattern | undefined > ;
3034}
3135
@@ -37,55 +41,41 @@ export class TabPattern {
3741 /** A local unique identifier for the tab. */
3842 value : SignalLike < string > ;
3943
40- /** Whether the tab is active . */
41- active = computed ( ( ) => this . tablist ( ) ?. focusManager . activeItem ( ) === this ) ;
44+ /** Whether the tab is disabled . */
45+ disabled : SignalLike < boolean > ;
4246
43- /** Whether the tab is selected . */
44- selected = computed ( ( ) => this . tablist ( ) . selection . inputs . value ( ) . includes ( this . value ( ) ) ) ;
47+ /** The html element that should receive focus . */
48+ element : SignalLike < HTMLElement > ;
4549
46- /** A Tabpanel Id controlled by the tab. */
47- controls = computed ( ( ) => this . tabpanel ( ) ?. id ( ) ) ;
50+ /** Controls the expansion state for the tab. */
51+ expansionControl : ExpansionControl ;
4852
49- /** Whether the tab is disabled . */
50- disabled : SignalLike < boolean > ;
53+ /** Whether the tab is active . */
54+ active = computed ( ( ) => this . inputs . tablist ( ) . focusManager . activeItem ( ) === this ) ;
5155
52- /** A reference to the parent tablist. */
53- tablist : SignalLike < TabListPattern > ;
56+ /** Whether the tab is selected. */
57+ selected = computed (
58+ ( ) => ! ! this . inputs . tablist ( ) . selection . inputs . value ( ) . includes ( this . value ( ) ) ,
59+ ) ;
5460
55- /** A reference to the corresponding tabpanel . */
56- tabpanel : SignalLike < TabPanelPattern | undefined > ;
61+ /** A tabpanel Id controlled by the tab . */
62+ controls = computed ( ( ) => this . expansionControl . controls ( ) ) ;
5763
5864 /** The tabindex of the tab. */
59- tabindex = computed ( ( ) => this . tablist ( ) . focusManager . getItemTabindex ( this ) ) ;
65+ tabindex = computed ( ( ) => this . inputs . tablist ( ) . focusManager . getItemTabindex ( this ) ) ;
6066
61- /** The html element that should receive focus. */
62- element : SignalLike < HTMLElement > ;
63-
64- constructor ( inputs : TabInputs ) {
67+ constructor ( readonly inputs : TabInputs ) {
6568 this . id = inputs . id ;
6669 this . value = inputs . value ;
67- this . tablist = inputs . tablist ;
68- this . tabpanel = inputs . tabpanel ;
69- this . element = inputs . element ;
7070 this . disabled = inputs . disabled ;
71+ this . element = inputs . element ;
72+ this . expansionControl = new ExpansionControl ( {
73+ visible : this . selected ,
74+ expansionPanel : computed ( ( ) => inputs . tabpanel ( ) ?. expansionPanel ) ,
75+ } ) ;
7176 }
7277}
7378
74- /** The selection operations that the tablist can perform. */
75- interface SelectOptions {
76- select ?: boolean ;
77- toggle ?: boolean ;
78- toggleOne ?: boolean ;
79- selectOne ?: boolean ;
80- }
81-
82- /** The required inputs for the tablist. */
83- export type TabListInputs = ListNavigationInputs < TabPattern > &
84- Omit < ListSelectionInputs < TabPattern , string > , 'multi' > &
85- ListFocusInputs < TabPattern > & {
86- disabled : SignalLike < boolean > ;
87- } ;
88-
8979/** The required inputs for the tabpanel. */
9080export interface TabPanelInputs {
9181 id : SignalLike < string > ;
@@ -101,19 +91,37 @@ export class TabPanelPattern {
10191 /** A local unique identifier for the tabpanel. */
10292 value : SignalLike < string > ;
10393
104- /** A reference to the corresponding tab. */
105- tab : SignalLike < TabPattern | undefined > ;
94+ /** Represents the expansion state for the tabpanel. */
95+ expansionPanel : ExpansionPanel ;
10696
10797 /** Whether the tabpanel is hidden. */
108- hidden = computed ( ( ) => ! this . tab ( ) ?. selected ( ) ) ;
98+ hidden = computed ( ( ) => this . expansionPanel . hidden ( ) ) ;
10999
110100 constructor ( inputs : TabPanelInputs ) {
111101 this . id = inputs . id ;
112102 this . value = inputs . value ;
113- this . tab = inputs . tab ;
103+ this . expansionPanel = new ExpansionPanel ( {
104+ id : inputs . id ,
105+ expansionControl : computed ( ( ) => inputs . tab ( ) ?. expansionControl ) ,
106+ } ) ;
114107 }
115108}
116109
110+ /** The selection operations that the tablist can perform. */
111+ interface SelectOptions {
112+ select ?: boolean ;
113+ toggle ?: boolean ;
114+ toggleOne ?: boolean ;
115+ selectOne ?: boolean ;
116+ }
117+
118+ /** The required inputs for the tablist. */
119+ export type TabListInputs = ListNavigationInputs < TabPattern > &
120+ Omit < ListSelectionInputs < TabPattern , string > , 'multi' > &
121+ ListFocusInputs < TabPattern > & {
122+ disabled : SignalLike < boolean > ;
123+ } ;
124+
117125/** Controls the state of a tablist. */
118126export class TabListPattern {
119127 /** Controls navigation for the tablist. */
0 commit comments