@@ -469,8 +469,8 @@ export class GridStack {
469
469
this . _updateContainerHeight ( ) ;
470
470
471
471
// see if there is a sub-grid to create
472
- if ( node . subGrid ) {
473
- this . makeSubGrid ( node . el , undefined , undefined , false ) ; //node.subGrid will be used as option in method, no need to pass
472
+ if ( node . subGridOpts ) {
473
+ this . makeSubGrid ( node . el , node . subGridOpts , undefined , false ) ; // node.subGrid will be used as option in method, no need to pass
474
474
}
475
475
476
476
// if we're adding an item into 1 column (_prevColumn is set only when going to 1) make sure
@@ -498,18 +498,18 @@ export class GridStack {
498
498
if ( ! node ) {
499
499
node = this . makeWidget ( el ) . gridstackNode ;
500
500
}
501
- if ( ( node . subGrid as GridStack ) ?. el ) return node . subGrid as GridStack ; // already done
501
+ if ( node . subGrid ?. el ) return node . subGrid ; // already done
502
502
503
503
// find the template subGrid stored on a parent as fallback...
504
504
let subGridTemplate : GridStackOptions ; // eslint-disable-next-line @typescript-eslint/no-this-alias
505
505
let grid : GridStack = this ;
506
506
while ( grid && ! subGridTemplate ) {
507
- subGridTemplate = grid . opts ?. subGrid ;
507
+ subGridTemplate = grid . opts ?. subGridOpts ;
508
508
grid = grid . parentGridItem ?. grid ;
509
509
}
510
510
//... and set the create options
511
- ops = Utils . cloneDeep ( { ...( subGridTemplate || { } ) , children : undefined , ...( ops || node . subGrid as GridStackOptions ) } ) ;
512
- node . subGrid = ops ;
511
+ ops = Utils . cloneDeep ( { ...( subGridTemplate || { } ) , children : undefined , ...( ops || node . subGridOpts ) } ) ;
512
+ node . subGridOpts = ops ;
513
513
514
514
// if column special case it set, remember that flag and set default
515
515
let autoColumn : boolean ;
@@ -527,7 +527,7 @@ export class GridStack {
527
527
this . _removeDD ( node . el ) ; // remove D&D since it's set on content div
528
528
newItemOpt = { ...node , x :0 , y :0 } ;
529
529
Utils . removeInternalForSave ( newItemOpt ) ;
530
- delete newItemOpt . subGrid ;
530
+ delete newItemOpt . subGridOpts ;
531
531
if ( node . content ) {
532
532
newItemOpt . content = node . content ;
533
533
delete node . content ;
@@ -625,9 +625,10 @@ export class GridStack {
625
625
} else {
626
626
if ( ! saveContent && ! saveCB ) { delete n . content ; }
627
627
// check for nested grid
628
- if ( ( n . subGrid as GridStack ) ?. el ) {
629
- const listOrOpt = ( n . subGrid as GridStack ) . save ( saveContent , saveGridOpt , saveCB ) ;
630
- n . subGrid = ( saveGridOpt ? listOrOpt : { children : listOrOpt } ) as GridStackOptions ;
628
+ if ( n . subGrid ?. el ) {
629
+ const listOrOpt = n . subGrid . save ( saveContent , saveGridOpt , saveCB ) ;
630
+ n . subGridOpts = ( saveGridOpt ? listOrOpt : { children : listOrOpt } ) as GridStackOptions ;
631
+ delete n . subGrid ;
631
632
}
632
633
}
633
634
delete n . el ;
@@ -711,10 +712,10 @@ export class GridStack {
711
712
let item = ( w . id || w . id === 0 ) ? this . engine . nodes . find ( n => n . id === w . id ) : undefined ;
712
713
if ( item ) {
713
714
this . update ( item . el , w ) ;
714
- if ( w . subGrid && ( w . subGrid as GridStackOptions ) . children ) { // update any sub grid as well
715
+ if ( w . subGridOpts ? .children ) { // update any sub grid as well
715
716
let sub = item . el . querySelector ( '.grid-stack' ) as GridHTMLElement ;
716
717
if ( sub && sub . gridstack ) {
717
- sub . gridstack . load ( ( w . subGrid as GridStackOptions ) . children ) ; // TODO: support updating grid options ?
718
+ sub . gridstack . load ( w . subGridOpts . children ) ; // TODO: support updating grid options ?
718
719
this . _insertNotAppend = true ; // got reset by above call
719
720
}
720
721
}
@@ -1138,7 +1139,7 @@ export class GridStack {
1138
1139
this . _setupAcceptWidget ( ) ;
1139
1140
this . engine . nodes . forEach ( n => {
1140
1141
this . _prepareDragDropByNode ( n ) ; // either delete or init Drag&drop
1141
- if ( n . subGrid && recurse ) ( n . subGrid as GridStack ) . setStatic ( val , updateClass , recurse ) ;
1142
+ if ( n . subGrid && recurse ) n . subGrid . setStatic ( val , updateClass , recurse ) ;
1142
1143
} ) ;
1143
1144
if ( updateClass ) { this . _setStaticClass ( ) ; }
1144
1145
return this ;
@@ -1553,7 +1554,7 @@ export class GridStack {
1553
1554
1554
1555
// finally update any nested grids
1555
1556
this . engine . nodes . forEach ( n => {
1556
- if ( n . subGrid ) { ( n . subGrid as GridStack ) . onParentResize ( ) }
1557
+ if ( n . subGrid ) n . subGrid . onParentResize ( )
1557
1558
} ) ;
1558
1559
1559
1560
return this ;
@@ -1757,7 +1758,7 @@ export class GridStack {
1757
1758
this . opts . disableDrag = ! doEnable ; // FIRST before we update children as grid overrides #1658
1758
1759
this . engine . nodes . forEach ( n => {
1759
1760
this . movable ( n . el , doEnable ) ;
1760
- if ( n . subGrid && recurse ) ( n . subGrid as GridStack ) . enableMove ( doEnable , recurse ) ;
1761
+ if ( n . subGrid && recurse ) n . subGrid . enableMove ( doEnable , recurse ) ;
1761
1762
} ) ;
1762
1763
return this ;
1763
1764
}
@@ -1771,7 +1772,7 @@ export class GridStack {
1771
1772
this . opts . disableResize = ! doEnable ; // FIRST before we update children as grid overrides #1658
1772
1773
this . engine . nodes . forEach ( n => {
1773
1774
this . resizable ( n . el , doEnable ) ;
1774
- if ( n . subGrid && recurse ) ( n . subGrid as GridStack ) . enableResize ( doEnable , recurse ) ;
1775
+ if ( n . subGrid && recurse ) n . subGrid . enableResize ( doEnable , recurse ) ;
1775
1776
} ) ;
1776
1777
return this ;
1777
1778
}
@@ -1987,7 +1988,7 @@ export class GridStack {
1987
1988
if ( ! wasAdded ) return false ;
1988
1989
el . gridstackNode = node ;
1989
1990
node . el = el ;
1990
- let subGrid = ( node . subGrid as GridStack ) ?. el ?. gridstack ; // set when actual sub-grid present
1991
+ let subGrid = node . subGrid ?. el ?. gridstack ; // set when actual sub-grid present
1991
1992
// @ts -ignore
1992
1993
Utils . copyPos ( node , this . _readAttr ( this . placeholder ) ) ; // placeholder values as moving VERY fast can throw things off #1578
1993
1994
Utils . removePositioningStyles ( el ) ; // @ts -ignore
@@ -2263,7 +2264,7 @@ export class GridStack {
2263
2264
node . _lastUiPosition = ui . position ;
2264
2265
this . engine . cacheRects ( cellWidth , cellHeight , mTop , mRight , mBottom , mLeft ) ;
2265
2266
delete node . _skipDown ;
2266
- if ( resizing && node . subGrid ) { ( node . subGrid as GridStack ) . onParentResize ( ) ; } // @ts -ignore
2267
+ if ( resizing && node . subGrid ) node . subGrid . onParentResize ( ) ;
2267
2268
this . _extraDragRow = 0 ; // @ts -ignore
2268
2269
this . _updateContainerHeight ( ) ;
2269
2270
0 commit comments