@@ -278,6 +278,11 @@ export interface IrisGridContextMenuData {
278
278
modelColumn : GridRangeIndex ;
279
279
}
280
280
281
+ export type MouseHandlersProp = readonly (
282
+ | GridMouseHandler
283
+ | ( ( irisGrid : IrisGrid ) => GridMouseHandler )
284
+ ) [ ] ;
285
+
281
286
export interface IrisGridProps {
282
287
children : React . ReactNode ;
283
288
advancedFilters : ReadonlyAdvancedFilterMap ;
@@ -361,7 +366,7 @@ export interface IrisGridProps {
361
366
362
367
// Optional key and mouse handlers
363
368
keyHandlers : readonly KeyHandler [ ] ;
364
- mouseHandlers : readonly GridMouseHandler [ ] ;
369
+ mouseHandlers : MouseHandlersProp ;
365
370
366
371
// Pass in a custom renderer to the grid for advanced use cases
367
372
renderer ?: IrisGridRenderer ;
@@ -751,13 +756,15 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
751
756
columnHeaderGroups,
752
757
} = props ;
753
758
759
+ const { mouseHandlers : mouseHandlersProp } = props ;
760
+
754
761
const { dh } = model ;
755
762
const keyHandlers : KeyHandler [ ] = [
756
763
new CopyCellKeyHandler ( this ) ,
757
764
new ReverseKeyHandler ( this ) ,
758
765
new ClearFilterKeyHandler ( this ) ,
759
766
] ;
760
- const mouseHandlers : GridMouseHandler [ ] = [
767
+ const mouseHandlers : MouseHandlersProp = [
761
768
new IrisGridCellOverflowMouseHandler ( this ) ,
762
769
new IrisGridRowTreeMouseHandler ( this ) ,
763
770
new IrisGridTokenMouseHandler ( this ) ,
@@ -769,10 +776,11 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
769
776
new IrisGridDataSelectMouseHandler ( this ) ,
770
777
new PendingMouseHandler ( this ) ,
771
778
new IrisGridPartitionedTableMouseHandler ( this ) ,
779
+ ...mouseHandlersProp ,
780
+ ...( canCopy ? [ new IrisGridCopyCellMouseHandler ( this ) ] : [ ] ) ,
772
781
] ;
773
782
if ( canCopy ) {
774
783
keyHandlers . push ( new CopyKeyHandler ( this ) ) ;
775
- mouseHandlers . push ( new IrisGridCopyCellMouseHandler ( this ) ) ;
776
784
}
777
785
const movedColumns =
778
786
movedColumnsProp . length > 0
@@ -1095,7 +1103,7 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
1095
1103
1096
1104
keyHandlers : readonly KeyHandler [ ] ;
1097
1105
1098
- mouseHandlers : readonly GridMouseHandler [ ] ;
1106
+ mouseHandlers : MouseHandlersProp ;
1099
1107
1100
1108
get gridWrapper ( ) : HTMLDivElement | null {
1101
1109
return this . grid ?. canvasWrapper . current ?? null ;
@@ -1538,9 +1546,10 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
1538
1546
}
1539
1547
1540
1548
getCachedMouseHandlers = memoize (
1541
- (
1542
- mouseHandlers : readonly GridMouseHandler [ ]
1543
- ) : readonly GridMouseHandler [ ] => [ ...mouseHandlers , ...this . mouseHandlers ] ,
1549
+ ( mouseHandlers : MouseHandlersProp ) : readonly GridMouseHandler [ ] =>
1550
+ [ ...mouseHandlers , ...this . mouseHandlers ] . map ( handler =>
1551
+ typeof handler === 'function' ? handler ( this ) : handler
1552
+ ) ,
1544
1553
{ max : 1 }
1545
1554
) ;
1546
1555
@@ -2586,11 +2595,18 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
2586
2595
} ) ;
2587
2596
}
2588
2597
2589
- toggleExpandColumn ( modelIndex : ModelIndex ) : void {
2598
+ toggleExpandColumn (
2599
+ modelIndex : ModelIndex ,
2600
+ expandDescendants ?: boolean
2601
+ ) : void {
2590
2602
log . debug2 ( 'Toggle expand column' , modelIndex ) ;
2591
2603
const { model } = this . props ;
2592
2604
if ( isExpandableColumnGridModel ( model ) && model . hasExpandableColumns ) {
2593
- model . setColumnExpanded ( modelIndex , ! model . isColumnExpanded ( modelIndex ) ) ;
2605
+ model . setColumnExpanded (
2606
+ modelIndex ,
2607
+ ! model . isColumnExpanded ( modelIndex ) ,
2608
+ expandDescendants
2609
+ ) ;
2594
2610
}
2595
2611
}
2596
2612
0 commit comments