@@ -3396,6 +3396,122 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
33963396 this . stateManager . select . selecting = false ;
33973397 }
33983398
3399+ changeHeaderPosition ( args : {
3400+ source : CellAddress ;
3401+ target : CellAddress ;
3402+ movingColumnOrRow ?: 'column' | 'row' ;
3403+ } ) : boolean {
3404+ if (
3405+ ! ( 'canMoveHeaderPosition' in this . internalProps . layoutMap ) ||
3406+ this . options . customConfig ?. notUpdateInColumnRowMove === true
3407+ ) {
3408+ return false ;
3409+ }
3410+ const prevMoving = this . stateManager . columnMove . movingColumnOrRow ;
3411+ this . stateManager . columnMove . movingColumnOrRow = args . movingColumnOrRow ;
3412+ try {
3413+ if ( this . internalProps . layoutMap . canMoveHeaderPosition ?.( args . source , args . target ) === false ) {
3414+ return false ;
3415+ }
3416+ const oldSourceMergeInfo = this . getCellRange ( args . source . col , args . source . row ) ;
3417+ const oldTargetMergeInfo = this . getCellRange ( args . target . col , args . target . row ) ;
3418+ const moveContext = this . _moveHeaderPosition ( args . source , args . target ) ;
3419+ if ( ! moveContext || moveContext . targetIndex === moveContext . sourceIndex ) {
3420+ return false ;
3421+ }
3422+ this . internalProps . useOneRowHeightFillAll = false ;
3423+ this . internalProps . layoutMap . clearCellRangeMap ( ) ;
3424+ const sourceMergeInfo = this . getCellRange ( args . source . col , args . source . row ) ;
3425+ const targetMergeInfo = this . getCellRange ( args . target . col , args . target . row ) ;
3426+
3427+ const colMin = Math . min (
3428+ sourceMergeInfo . start . col ,
3429+ targetMergeInfo . start . col ,
3430+ oldSourceMergeInfo . start . col ,
3431+ oldTargetMergeInfo . start . col
3432+ ) ;
3433+ const colMax = Math . max (
3434+ sourceMergeInfo . end . col ,
3435+ targetMergeInfo . end . col ,
3436+ oldSourceMergeInfo . end . col ,
3437+ oldTargetMergeInfo . end . col
3438+ ) ;
3439+ const rowMin = Math . min (
3440+ sourceMergeInfo . start . row ,
3441+ targetMergeInfo . start . row ,
3442+ oldSourceMergeInfo . start . row ,
3443+ oldTargetMergeInfo . start . row
3444+ ) ;
3445+ let rowMax = Math . max (
3446+ sourceMergeInfo . end . row ,
3447+ targetMergeInfo . end . row ,
3448+ oldSourceMergeInfo . end . row ,
3449+ oldTargetMergeInfo . end . row
3450+ ) ;
3451+ if (
3452+ moveContext . moveType === 'row' &&
3453+ ( this . internalProps . layoutMap as PivotHeaderLayoutMap ) . rowHierarchyType === 'tree'
3454+ ) {
3455+ if ( moveContext . targetIndex > moveContext . sourceIndex ) {
3456+ rowMax = rowMax + moveContext . targetSize - 1 ;
3457+ } else {
3458+ rowMax = rowMax + moveContext . sourceSize - 1 ;
3459+ }
3460+ }
3461+
3462+ if (
3463+ ! ( this as any ) . transpose &&
3464+ ( this . isSeriesNumberInBody ( args . source . col , args . source . row ) || args . movingColumnOrRow === 'row' )
3465+ ) {
3466+ this . changeRecordOrder ( moveContext . sourceIndex , moveContext . targetIndex ) ;
3467+ this . stateManager . changeCheckboxAndRadioOrder ( moveContext . sourceIndex , moveContext . targetIndex ) ;
3468+ }
3469+
3470+ if ( moveContext . moveType === 'column' ) {
3471+ for ( let col = colMin ; col <= colMax ; col ++ ) {
3472+ this . _clearColRangeWidthsMap ( col ) ;
3473+ }
3474+ } else {
3475+ for ( let row = rowMin ; row <= rowMax ; row ++ ) {
3476+ this . _clearRowRangeHeightsMap ( row ) ;
3477+ }
3478+ }
3479+
3480+ this . clearCellStyleCache ( ) ;
3481+ if ( this . isSeriesNumberInBody ( args . source . col , args . source . row ) || args . movingColumnOrRow === 'row' ) {
3482+ this . scenegraph . updateHeaderPosition (
3483+ this . scenegraph . proxy . colStart ,
3484+ this . scenegraph . proxy . colEnd ,
3485+ this . scenegraph . proxy . rowStart ,
3486+ this . scenegraph . proxy . rowEnd ,
3487+ moveContext . moveType
3488+ ) ;
3489+ } else if ( moveContext . moveType === 'column' ) {
3490+ this . scenegraph . updateHeaderPosition ( colMin , colMax , 0 , - 1 , moveContext . moveType ) ;
3491+ } else {
3492+ this . scenegraph . updateHeaderPosition ( 0 , - 1 , rowMin , rowMax , moveContext . moveType ) ;
3493+ }
3494+
3495+ if ( this . internalProps . frozenColDragHeaderMode === 'adjustFrozenCount' && this . isListTable ( ) ) {
3496+ if ( this . isLeftFrozenColumn ( args . target . col ) && ! this . isLeftFrozenColumn ( args . source . col ) ) {
3497+ this . frozenColCount += sourceMergeInfo . end . col - sourceMergeInfo . start . col + 1 ;
3498+ } else if ( this . isLeftFrozenColumn ( args . source . col ) && ! this . isLeftFrozenColumn ( args . target . col ) ) {
3499+ this . frozenColCount -= sourceMergeInfo . end . col - sourceMergeInfo . start . col + 1 ;
3500+ }
3501+ if ( this . isRightFrozenColumn ( args . target . col ) && ! this . isRightFrozenColumn ( args . source . col ) ) {
3502+ this . rightFrozenColCount += sourceMergeInfo . end . col - sourceMergeInfo . start . col + 1 ;
3503+ } else if ( this . isRightFrozenColumn ( args . source . col ) && ! this . isRightFrozenColumn ( args . target . col ) ) {
3504+ this . rightFrozenColCount -= sourceMergeInfo . end . col - sourceMergeInfo . start . col + 1 ;
3505+ }
3506+ }
3507+
3508+ this . scenegraph . updateNextFrame ?.( ) ;
3509+ return true ;
3510+ } finally {
3511+ this . stateManager . columnMove . movingColumnOrRow = prevMoving ;
3512+ }
3513+ }
3514+
33993515 abstract isListTable ( ) : boolean ;
34003516 abstract isPivotTable ( ) : boolean ;
34013517 abstract isPivotChart ( ) : boolean ;
0 commit comments