@namespace AntDesign @using AntDesign.Internal @inherits AntDomComponentBase @{ // When hideOnSinglePage is true and there is only 1 page, hide the pager if (HideOnSinglePage == true && Total <= PageSize) { return; } var allPages = CalculatePage(null, _pageSize, Total); var pagerList = new LinkedList(); RenderFragment jumpPrev = null; RenderFragment jumpNext = null; RenderFragment firstPager = null; RenderFragment lastPager = null; RenderFragment gotoButton = null; var goButton = ShowQuickJumper ? GoButton : null; var pageBufferSize = ShowLessItems ? 1 : 2; var prevPage = _current - 1 > 0 ? _current - 1 : 0; var nextPage = _current + 1 < allPages ? _current + 1 : allPages; var dataOrAriaAttributeProps = UnmatchedAttributes? .Where(pair => pair.Key.StartsWith("data-") || pair.Key.StartsWith("aria-") || pair.Key == "role") .ToDictionary(e => e.Key, e => e.Value); if (Simple) { RenderFragment? goButtonRender; if (ShowQuickJumper) { if (goButton == null) { goButtonRender = @; } else { goButtonRender = @ @goButton ; } gotoButton = @
  • @goButtonRender
  • ; } } else { if (allPages <= 3 + pageBufferSize * 2) { if (allPages == 0) { pagerList.AddLast( @ ); } for (var i = 1; i <= allPages; i += 1) { var key = i; pagerList.AddLast( @ ); } } else { var prevItemTitle = ShowLessItems ? Locale.Prev3 : Locale.Prev5; var nextItemTitle = ShowLessItems ? Locale.Next3 : Locale.Next5; if (ShowPrevNextJumpers) { jumpPrev = @
  • @ItemRender(new( GetJumpPrevPage(), PaginationItemType.JumpPrev, GetItemIcon(JumpPrevIcon, "prev page") ))
  • ; jumpNext = @
  • @ItemRender(new( GetJumpNextPage(), PaginationItemType.JumpNext, GetItemIcon(JumpNextIcon, "next page") ))
  • ; } lastPager = @; firstPager = @; var left = Math.Max(1, _current - pageBufferSize); var right = Math.Min(_current + pageBufferSize, allPages); if (_current - 1 <= pageBufferSize) { right = 1 + pageBufferSize * 2; } if (allPages - _current <= pageBufferSize) { left = allPages - pageBufferSize * 2; } var itemAfterJumpPrev = _current - 1 >= pageBufferSize * 2 && _current != 1 + 2; var itemBeforeJumpNext = allPages - _current >= pageBufferSize * 2 && _current != allPages - 2; for (var i = left; i <= right; i += 1) { var key = i; pagerList.AddLast( @ ); } if (itemAfterJumpPrev) { pagerList.First.Value = @; pagerList.AddFirst(jumpPrev); } if (itemBeforeJumpNext) { pagerList.Last.Value = @; pagerList.AddLast(jumpNext); } if (left != 1) { pagerList.AddFirst(firstPager); } if (right != allPages) { pagerList.AddLast(lastPager); } } RenderFragment totalText = null; if (ShowTotal.HasValue) { totalText = @
  • @if (ShowTotal.Value.IsT0) { @ShowTotal.Value.AsT0(new(Total, ( Total == 0 ? 0 : (_current - 1) * _pageSize + 1, _current * _pageSize > Total ? Total : _current * _pageSize ))) } else if (ShowTotal.Value.IsT1) { @ShowTotal.Value.AsT1(new(Total, ( Total == 0 ? 0 : (_current - 1) * _pageSize + 1, _current * _pageSize > Total ? Total : _current * _pageSize ))) }
  • ; } var prevDisabled = !HasPrev() || allPages != 0; var nextDisabled = !HasNext() || allPages != 0;
      @totalText
    • @RenderPrev(prevPage)
    • @foreach (var pager in pagerList) { @pager }
    • @RenderNext(nextPage)
    } } @code { private void SetIcon() { RenderFragment ellipsis = @•••; RenderFragment prevIcon = context => @; RenderFragment nextIcon = context => @; RenderFragment jumpPrevIcon = _ => @ @* You can use transition effects in the container :) *@
    @ellipsis
    ; RenderFragment jumpNextIcon = _ => @ @* You can use transition effects in the container :) *@
    @ellipsis
    ; // change arrows direction in right-to-left direction if (Direction == "rtl") { PrevIcon ??= prevIcon; NextIcon ??= nextIcon; JumpPrevIcon ??= jumpPrevIcon; JumpNextIcon ??= jumpNextIcon; } else { PrevIcon ??= prevIcon; NextIcon ??= nextIcon; JumpPrevIcon ??= jumpPrevIcon; JumpNextIcon ??= jumpNextIcon; } } /// /// computed icon node that need to be rendered. /// /// /// /// private RenderFragment GetItemIcon(RenderFragment? icon, string label) { RenderFragment defaultIconRender = ctx => @