@@ -403,99 +403,106 @@ const paneWidths = {
403
403
large : [ '100%' , null , '256px' , '320px' , '336px' ]
404
404
}
405
405
406
- const Pane : React . FC < React . PropsWithChildren < PageLayoutPaneProps > > = ( {
407
- position : responsivePosition = 'end' ,
408
- positionWhenNarrow = 'inherit' ,
409
- width = 'medium' ,
410
- padding = 'none' ,
411
- divider : responsiveDivider = 'none' ,
412
- dividerWhenNarrow = 'inherit' ,
413
- sticky = false ,
414
- offsetHeader = 0 ,
415
- hidden : responsiveHidden = false ,
416
- children,
417
- sx = { }
418
- } ) => {
419
- // Combine position and positionWhenNarrow for backwards compatibility
420
- const positionProp =
421
- ! isResponsiveValue ( responsivePosition ) && positionWhenNarrow !== 'inherit'
422
- ? { regular : responsivePosition , narrow : positionWhenNarrow }
423
- : responsivePosition
424
-
425
- const position = useResponsiveValue ( positionProp , 'end' )
426
-
427
- // Combine divider and dividerWhenNarrow for backwards compatibility
428
- const dividerProp =
429
- ! isResponsiveValue ( responsiveDivider ) && dividerWhenNarrow !== 'inherit'
430
- ? { regular : responsiveDivider , narrow : dividerWhenNarrow }
431
- : responsiveDivider
432
-
433
- const dividerVariant = useResponsiveValue ( dividerProp , 'none' )
434
-
435
- const isHidden = useResponsiveValue ( responsiveHidden , false )
436
-
437
- const { rowGap, columnGap, enableStickyPane, disableStickyPane} = React . useContext ( PageLayoutContext )
438
-
439
- React . useEffect ( ( ) => {
440
- if ( sticky ) {
441
- enableStickyPane ?.( offsetHeader )
442
- } else {
443
- disableStickyPane ?.( )
444
- }
445
- } , [ sticky , enableStickyPane , disableStickyPane , offsetHeader ] )
406
+ const Pane = React . forwardRef < HTMLDivElement , React . PropsWithChildren < PageLayoutPaneProps > > (
407
+ (
408
+ {
409
+ position : responsivePosition = 'end' ,
410
+ positionWhenNarrow = 'inherit' ,
411
+ width = 'medium' ,
412
+ padding = 'none' ,
413
+ divider : responsiveDivider = 'none' ,
414
+ dividerWhenNarrow = 'inherit' ,
415
+ sticky = false ,
416
+ offsetHeader = 0 ,
417
+ hidden : responsiveHidden = false ,
418
+ children,
419
+ sx = { }
420
+ } ,
421
+ forwardRef
422
+ ) => {
423
+ // Combine position and positionWhenNarrow for backwards compatibility
424
+ const positionProp =
425
+ ! isResponsiveValue ( responsivePosition ) && positionWhenNarrow !== 'inherit'
426
+ ? { regular : responsivePosition , narrow : positionWhenNarrow }
427
+ : responsivePosition
428
+
429
+ const position = useResponsiveValue ( positionProp , 'end' )
430
+
431
+ // Combine divider and dividerWhenNarrow for backwards compatibility
432
+ const dividerProp =
433
+ ! isResponsiveValue ( responsiveDivider ) && dividerWhenNarrow !== 'inherit'
434
+ ? { regular : responsiveDivider , narrow : dividerWhenNarrow }
435
+ : responsiveDivider
436
+
437
+ const dividerVariant = useResponsiveValue ( dividerProp , 'none' )
438
+
439
+ const isHidden = useResponsiveValue ( responsiveHidden , false )
440
+
441
+ const { rowGap, columnGap, enableStickyPane, disableStickyPane} = React . useContext ( PageLayoutContext )
442
+
443
+ React . useEffect ( ( ) => {
444
+ if ( sticky ) {
445
+ enableStickyPane ?.( offsetHeader )
446
+ } else {
447
+ disableStickyPane ?.( )
448
+ }
449
+ } , [ sticky , enableStickyPane , disableStickyPane , offsetHeader ] )
446
450
447
- return (
448
- < Box
449
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
450
- sx = { ( theme : any ) =>
451
- merge < BetterSystemStyleObject > (
452
- {
453
- // Narrow viewports
454
- display : isHidden ? 'none' : 'flex' ,
455
- order : panePositions [ position ] ,
456
- width : '100%' ,
457
- marginX : 0 ,
458
- ...( position === 'end'
459
- ? { flexDirection : 'column' , marginTop : SPACING_MAP [ rowGap ] }
460
- : { flexDirection : 'column-reverse' , marginBottom : SPACING_MAP [ rowGap ] } ) ,
461
-
462
- // Regular and wide viewports
463
- [ `@media screen and (min-width: ${ theme . breakpoints [ 1 ] } )` ] : {
464
- width : 'auto' ,
465
- marginY : '0 !important' ,
466
- ...( sticky
467
- ? {
468
- position : 'sticky' ,
469
- // If offsetHeader has value, it will stick the pane to the position where the sticky top ends
470
- // else top will be 0 as the default value of offsetHeader
471
- top : typeof offsetHeader === 'number' ? `${ offsetHeader } px` : offsetHeader ,
472
- overflow : 'hidden' ,
473
- maxHeight : 'var(--sticky-pane-height)'
474
- }
475
- : { } ) ,
451
+ return (
452
+ < Box
453
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
454
+ sx = { ( theme : any ) =>
455
+ merge < BetterSystemStyleObject > (
456
+ {
457
+ // Narrow viewports
458
+ display : isHidden ? 'none' : 'flex' ,
459
+ order : panePositions [ position ] ,
460
+ width : '100%' ,
461
+ marginX : 0 ,
476
462
...( position === 'end'
477
- ? { flexDirection : 'row' , marginLeft : SPACING_MAP [ columnGap ] }
478
- : { flexDirection : 'row-reverse' , marginRight : SPACING_MAP [ columnGap ] } )
479
- }
480
- } ,
481
- sx
482
- )
483
- }
484
- >
485
- { /* Show a horizontal divider when viewport is narrow. Otherwise, show a vertical divider. */ }
486
- < HorizontalDivider
487
- variant = { { narrow : dividerVariant , regular : 'none' } }
488
- sx = { { [ position === 'end' ? 'marginBottom' : 'marginTop' ] : SPACING_MAP [ rowGap ] } }
489
- />
490
- < VerticalDivider
491
- variant = { { narrow : 'none' , regular : dividerVariant } }
492
- sx = { { [ position === 'end' ? 'marginRight' : 'marginLeft' ] : SPACING_MAP [ columnGap ] } }
493
- />
494
-
495
- < Box sx = { { width : paneWidths [ width ] , padding : SPACING_MAP [ padding ] , overflow : 'auto' } } > { children } </ Box >
496
- </ Box >
497
- )
498
- }
463
+ ? { flexDirection : 'column' , marginTop : SPACING_MAP [ rowGap ] }
464
+ : { flexDirection : 'column-reverse' , marginBottom : SPACING_MAP [ rowGap ] } ) ,
465
+
466
+ // Regular and wide viewports
467
+ [ `@media screen and (min-width: ${ theme . breakpoints [ 1 ] } )` ] : {
468
+ width : 'auto' ,
469
+ marginY : '0 !important' ,
470
+ ...( sticky
471
+ ? {
472
+ position : 'sticky' ,
473
+ // If offsetHeader has value, it will stick the pane to the position where the sticky top ends
474
+ // else top will be 0 as the default value of offsetHeader
475
+ top : typeof offsetHeader === 'number' ? `${ offsetHeader } px` : offsetHeader ,
476
+ overflow : 'hidden' ,
477
+ maxHeight : 'var(--sticky-pane-height)'
478
+ }
479
+ : { } ) ,
480
+ ...( position === 'end'
481
+ ? { flexDirection : 'row' , marginLeft : SPACING_MAP [ columnGap ] }
482
+ : { flexDirection : 'row-reverse' , marginRight : SPACING_MAP [ columnGap ] } )
483
+ }
484
+ } ,
485
+ sx
486
+ )
487
+ }
488
+ >
489
+ { /* Show a horizontal divider when viewport is narrow. Otherwise, show a vertical divider. */ }
490
+ < HorizontalDivider
491
+ variant = { { narrow : dividerVariant , regular : 'none' } }
492
+ sx = { { [ position === 'end' ? 'marginBottom' : 'marginTop' ] : SPACING_MAP [ rowGap ] } }
493
+ />
494
+ < VerticalDivider
495
+ variant = { { narrow : 'none' , regular : dividerVariant } }
496
+ sx = { { [ position === 'end' ? 'marginRight' : 'marginLeft' ] : SPACING_MAP [ columnGap ] } }
497
+ />
498
+
499
+ < Box ref = { forwardRef } sx = { { width : paneWidths [ width ] , padding : SPACING_MAP [ padding ] , overflow : 'auto' } } >
500
+ { children }
501
+ </ Box >
502
+ </ Box >
503
+ )
504
+ }
505
+ )
499
506
500
507
Pane . displayName = 'PageLayout.Pane'
501
508
0 commit comments