@@ -19,6 +19,10 @@ import { TranslateWithId } from '../../types/common';
1919import { breakpoints } from '@carbon/layout' ;
2020import { useMatchMedia } from '../../internal/useMatchMedia' ;
2121import { clamp } from '../../internal/clamp' ;
22+ import { PopoverAlignment } from '../Popover' ;
23+
24+ type TooltipAlignment = 'start' | 'center' | 'end' ;
25+ type TooltipPosition = 'top' | 'right' | 'bottom' | 'left' ;
2226
2327const translationIds = {
2428 'carbon.pagination-nav.next' : 'Next' ,
@@ -55,10 +59,7 @@ function calculateCuts(
5559 splitPoint : number | null = null
5660) {
5761 if ( itemsDisplayedOnPage >= totalItems ) {
58- return {
59- front : 0 ,
60- back : 0 ,
61- } ;
62+ return { front : 0 , back : 0 } ;
6263 }
6364
6465 const split = splitPoint || Math . ceil ( itemsDisplayedOnPage / 2 ) - 1 ;
@@ -76,10 +77,7 @@ function calculateCuts(
7677 backHidden = 0 ;
7778 }
7879
79- return {
80- front : frontHidden ,
81- back : backHidden ,
82- } ;
80+ return { front : frontHidden , back : backHidden } ;
8381}
8482
8583export interface DirectionButtonProps {
@@ -102,20 +100,37 @@ export interface DirectionButtonProps {
102100 * The callback function called when the button is clicked.
103101 */
104102 onClick ?: React . MouseEventHandler ;
103+
104+ /**
105+ * Specify the alignment of the tooltip for the icon-only next/prev buttons.
106+ */
107+ tooltipAlignment ?: TooltipAlignment ;
108+
109+ /**
110+ * Specify the position of the tooltip for the icon-only next/prev buttons.
111+ */
112+ tooltipPosition ?: TooltipPosition ;
105113}
106114
107115function DirectionButton ( {
108116 direction,
109117 label,
110118 disabled,
111119 onClick,
120+ tooltipAlignment = 'center' ,
121+ tooltipPosition = 'bottom' ,
112122} : DirectionButtonProps ) {
113123 const prefix = usePrefix ( ) ;
114124
125+ const align : PopoverAlignment =
126+ tooltipAlignment === 'center'
127+ ? ( tooltipPosition as PopoverAlignment )
128+ : ( `${ tooltipPosition } -${ tooltipAlignment } ` as PopoverAlignment ) ;
129+
115130 return (
116131 < li className = { `${ prefix } --pagination-nav__list-item` } >
117132 < IconButton
118- align = "bottom"
133+ align = { align }
119134 disabled = { disabled }
120135 kind = "ghost"
121136 label = { label }
@@ -319,6 +334,18 @@ export interface PaginationNavProps
319334 */
320335 size ?: 'sm' | 'md' | 'lg' ;
321336
337+ /**
338+ * Specify the alignment of the tooltip for the icon-only next/prev buttons.
339+ * Can be one of: start, center, or end.
340+ */
341+ tooltipAlignment ?: TooltipAlignment ;
342+
343+ /**
344+ * Specify the position of the tooltip for the icon-only next/prev buttons.
345+ * Can be one of: top, right, bottom, or left.
346+ */
347+ tooltipPosition ?: TooltipPosition ;
348+
322349 /**
323350 * The total number of items.
324351 */
@@ -336,6 +363,8 @@ const PaginationNav = React.forwardRef<HTMLElement, PaginationNavProps>(
336363 page = 0 ,
337364 loop = false ,
338365 size = 'lg' ,
366+ tooltipAlignment,
367+ tooltipPosition,
339368 translateWithId : t = translateWithId ,
340369 ...rest
341370 } ,
@@ -479,6 +508,8 @@ const PaginationNav = React.forwardRef<HTMLElement, PaginationNavProps>(
479508 label = { t ( 'carbon.pagination-nav.previous' ) }
480509 disabled = { backwardButtonDisabled }
481510 onClick = { jumpToPrevious }
511+ tooltipAlignment = { tooltipAlignment }
512+ tooltipPosition = { tooltipPosition }
482513 />
483514
484515 {
@@ -551,6 +582,8 @@ const PaginationNav = React.forwardRef<HTMLElement, PaginationNavProps>(
551582 label = { t ( 'carbon.pagination-nav.next' ) }
552583 disabled = { forwardButtonDisabled }
553584 onClick = { jumpToNext }
585+ tooltipAlignment = { tooltipAlignment }
586+ tooltipPosition = { tooltipPosition }
554587 />
555588 </ ul >
556589 < div
@@ -586,6 +619,18 @@ DirectionButton.propTypes = {
586619 * The callback function called when the button is clicked.
587620 */
588621 onClick : PropTypes . func ,
622+
623+ /**
624+ * Specify how the tooltip should align with the navigation button.
625+ * Can be one of: start, center, or end.
626+ */
627+ tooltipAlignment : PropTypes . oneOf ( [ 'start' , 'center' , 'end' ] ) ,
628+
629+ /**
630+ * Specify the position of the tooltip relative to the navigation button.
631+ * Can be one of: top, right, bottom, or left.
632+ */
633+ tooltipPosition : PropTypes . oneOf ( [ 'top' , 'right' , 'bottom' , 'left' ] ) ,
589634} ;
590635
591636PaginationItem . propTypes = {
@@ -672,6 +717,18 @@ PaginationNav.propTypes = {
672717 */
673718 size : PropTypes . oneOf ( [ 'sm' , 'md' , 'lg' ] ) ,
674719
720+ /**
721+ * Specify the alignment of the tooltip for the icon-only prev/next buttons.
722+ * Can be one of: start, center, or end.
723+ */
724+ tooltipAlignment : PropTypes . oneOf ( [ 'start' , 'center' , 'end' ] ) ,
725+
726+ /**
727+ * Specify the position of the tooltip for the icon-only prev/next buttons.
728+ * Can be one of: top, right, bottom, or left.
729+ */
730+ tooltipPosition : PropTypes . oneOf ( [ 'top' , 'right' , 'bottom' , 'left' ] ) ,
731+
675732 /**
676733 * The total number of items.
677734 */
0 commit comments