@@ -30,21 +30,17 @@ export const isPixelUnit = (trackSize: TrackSize): trackSize is CSSTrackSize =>
3030
3131const NO_SPLITTERS : ISplitter [ ] = [ ] ;
3232
33+ //TODO shouldn't id be here ?
3334export interface GridLayoutChildItemDescriptor {
34- /**
35- * componentId is only required when a GridLayout is declared using JSX
36- * and child components are directly nested within GridLayout without GridItem
37- * wrappers.
38- * Each child component must have a unique id. The componentId here is used
39- * to match the with the associated component. If GridItem wrappers are included
40- * explicitly in the JSX, componentId is not required in the
41- * GridLayoutChildItemDescriptor.
42- */
43- componentId ?: string ;
35+ contentVisible ?: boolean ;
4436 dropTarget ?: boolean | string ;
4537 gridArea : string ;
4638 header ?: boolean ;
4739 resizeable ?: GridModelItemResizeable ;
40+ /**
41+ * For GridLayoutItems that are 'stacked' (e.g. displayed in tabbed container)
42+ * this is the id of the associated StackedLayoutItem.
43+ */
4844 stackId ?: string ;
4945 title ?: string ;
5046}
@@ -81,21 +77,13 @@ export interface GridLayoutModelCoordinates {
8177 row : GridLayoutModelPosition ;
8278}
8379
84- export interface GridModelChildItemProps {
80+ export interface GridModelChildItemProps
81+ extends Omit < GridLayoutChildItemDescriptor , "gridArea" > {
8582 contentVisible ?: boolean ;
86- dropTarget ?: boolean | string ;
8783 fixed ?: boolean ;
88- header ?: boolean ;
8984 height ?: number ;
9085 id : string ;
91- /**
92- * For GridLayoutItems that are 'stacked' (e.g. displayed in tabbed container)
93- * this is the id of the associated StackedLayoutItem.
94- */
95- stackId ?: string ;
96- resizeable ?: GridModelItemResizeable ;
9786 style : GridChildItemStyle ;
98- title ?: string ;
9987 type ?: GridModelItemType ;
10088 width ?: number ;
10189}
@@ -952,7 +940,11 @@ export class GridModel extends EventEmitter<GridModelEvents> {
952940 }
953941 } ;
954942
955- setTabState ( stackId : string , childItems : GridModelChildItem [ ] ) {
943+ setTabState (
944+ stackId : string ,
945+ childItems : GridModelChildItem [ ] ,
946+ activeItem = 0 ,
947+ ) {
956948 console . log ( `[GridModel] setTabState ${ stackId } ` ) ;
957949 let tabState = this . #tabState. get ( stackId ) ;
958950 if ( tabState ) {
@@ -962,15 +954,15 @@ export class GridModel extends EventEmitter<GridModelEvents> {
962954 id,
963955 label : title ?? `Label-${ index + 1 } ` ,
964956 } ) ) ;
965- tabState = new TabState ( stackId , 0 , tabs ) ;
957+ tabState = new TabState ( stackId , activeItem , tabs ) ;
966958
967959 tabState . on ( "active-change" , this . handleTabSelectionChange ) ;
968960 tabState . on ( "tab-added" , this . handleTabAdded ) ;
969961 tabState . on ( "tab-detached" , this . handleTabDetached ) ;
970962 tabState . on ( "tabs-change" , this . handleTabsChange ) ;
971963 tabState . on ( "tabs-removed" , this . handleTabsRemoved ) ;
972964
973- this . activateStackedChildItem ( stackId , tabs [ 0 ] ) ;
965+ this . activateStackedChildItem ( stackId , tabs [ activeItem ] ) ;
974966
975967 this . #tabState. set ( stackId , tabState ) ;
976968 return tabState ;
@@ -1034,16 +1026,37 @@ export class GridModel extends EventEmitter<GridModelEvents> {
10341026 gridLayoutItems : this . #childItems. reduce < GridLayoutChildItemDescriptors > (
10351027 (
10361028 result ,
1037- { id, column, dropTarget, header, resizeable, row, stackId, title } ,
1038- ) => {
1039- result [ id . replace ( / ^ g r i d - / , "" ) ] = {
1029+ {
1030+ id,
1031+ column,
1032+ contentVisible,
10401033 dropTarget,
1041- gridArea : `${ row . start } /${ column . start } /${ row . end } /${ column . end } ` ,
10421034 header,
10431035 resizeable,
1036+ row,
10441037 stackId,
10451038 title,
1046- } ;
1039+ type,
1040+ } ,
1041+ ) => {
1042+ console . log ( `[GridModel] toGridLayoutDescriptor ${ id } = ${ type } ` ) ;
1043+ if ( stackId ) {
1044+ console . log (
1045+ `[GridModel] is a stacked item, active item ? ${ contentVisible === true } ` ,
1046+ ) ;
1047+ }
1048+ // The stacked-content gridItems are a runtime construct, no need to serialize
1049+ if ( type !== "stacked-content" ) {
1050+ result [ id ] = {
1051+ contentVisible,
1052+ dropTarget,
1053+ gridArea : `${ row . start } /${ column . start } /${ row . end } /${ column . end } ` ,
1054+ header,
1055+ resizeable,
1056+ stackId,
1057+ title,
1058+ } ;
1059+ }
10471060 return result ;
10481061 } ,
10491062 { } ,
@@ -1148,12 +1161,20 @@ export class GridModel extends EventEmitter<GridModelEvents> {
11481161 private addChildItems ( childItems : GridLayoutChildItemDescriptors ) {
11491162 for ( const [
11501163 id ,
1151- { dropTarget, header, resizeable, stackId, title, ...item } ,
1164+ {
1165+ contentVisible,
1166+ dropTarget,
1167+ header,
1168+ resizeable,
1169+ stackId,
1170+ title,
1171+ ...item
1172+ } ,
11521173 ] of Object . entries ( childItems ) ) {
11531174 const { column, row } = getGridPosition ( item . gridArea ) ;
11541175 this . addChildItem (
11551176 new GridModelChildItem ( {
1156- // id: `grid-${id}` ,
1177+ contentVisible ,
11571178 id,
11581179 column,
11591180 dropTarget,
0 commit comments