@eqtylab/equality 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -566,12 +566,13 @@ interface PaginationProps {
566
566
  onItemsPerPageChange?: (itemsPerPage: number) => void;
567
567
  itemsPerPageOptions?: number[];
568
568
  showInfo?: boolean;
569
+ showFirstLast?: boolean;
569
570
  maxVisiblePages?: number;
570
571
  className?: string;
571
572
  type?: string;
572
573
  scrollTargetRef?: React$1.RefObject<HTMLElement | null> | string;
573
574
  }
574
- declare const Pagination: ({ currentPage, totalItems, filteredItems, itemsPerPage, onPageChange, onItemsPerPageChange, itemsPerPageOptions, showInfo, maxVisiblePages, className, type, scrollTargetRef, }: PaginationProps) => react_jsx_runtime.JSX.Element | null;
575
+ declare const Pagination: ({ currentPage, totalItems, filteredItems, itemsPerPage, onPageChange, onItemsPerPageChange, itemsPerPageOptions, showInfo, showFirstLast, maxVisiblePages, className, type, scrollTargetRef, }: PaginationProps) => react_jsx_runtime.JSX.Element | null;
575
576
 
576
577
  interface PanelLabelProps {
577
578
  className?: string;
package/dist/index.d.ts CHANGED
@@ -566,12 +566,13 @@ interface PaginationProps {
566
566
  onItemsPerPageChange?: (itemsPerPage: number) => void;
567
567
  itemsPerPageOptions?: number[];
568
568
  showInfo?: boolean;
569
+ showFirstLast?: boolean;
569
570
  maxVisiblePages?: number;
570
571
  className?: string;
571
572
  type?: string;
572
573
  scrollTargetRef?: React$1.RefObject<HTMLElement | null> | string;
573
574
  }
574
- declare const Pagination: ({ currentPage, totalItems, filteredItems, itemsPerPage, onPageChange, onItemsPerPageChange, itemsPerPageOptions, showInfo, maxVisiblePages, className, type, scrollTargetRef, }: PaginationProps) => react_jsx_runtime.JSX.Element | null;
575
+ declare const Pagination: ({ currentPage, totalItems, filteredItems, itemsPerPage, onPageChange, onItemsPerPageChange, itemsPerPageOptions, showInfo, showFirstLast, maxVisiblePages, className, type, scrollTargetRef, }: PaginationProps) => react_jsx_runtime.JSX.Element | null;
575
576
 
576
577
  interface PanelLabelProps {
577
578
  className?: string;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { forwardRef, useRef, useMemo, useEffect, useSyncExternalStore, useState,
3
3
  import { cva } from 'class-variance-authority';
4
4
  import styles2 from './alert.module.module.css.module.css';
5
5
  import * as LucideIcons from 'lucide-react';
6
- import { Check, ChevronRight, Search, Circle, ChevronDown, ChevronUp, X, SearchIcon, CalendarDays, ChevronLeft, Grid3X3, List, AlertOctagon, Home, ArrowUp, ArrowDown, ArrowUpDown, TriangleAlert } from 'lucide-react';
6
+ import { Check, ChevronRight, Search, Circle, ChevronDown, ChevronUp, X, SearchIcon, CalendarDays, ChevronLeft, Grid3X3, List, AlertOctagon, Home, ChevronsLeft, ChevronsRight, ArrowUp, ArrowDown, ArrowUpDown, TriangleAlert } from 'lucide-react';
7
7
  import styles from './icon.module.module.css.module.css';
8
8
  import { clsx } from 'clsx';
9
9
  import { twMerge } from 'tailwind-merge';
@@ -2696,6 +2696,8 @@ var SelectSeparator = React15.forwardRef(({ className, ...props }, ref) => /* @_
2696
2696
  SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
2697
2697
  var ChevronLeftIcon2 = ChevronLeft;
2698
2698
  var ChevronRightIcon3 = ChevronRight;
2699
+ var ChevronsLeftIcon = ChevronsLeft;
2700
+ var ChevronsRightIcon = ChevronsRight;
2699
2701
  var Pagination = ({
2700
2702
  currentPage,
2701
2703
  totalItems,
@@ -2705,6 +2707,7 @@ var Pagination = ({
2705
2707
  onItemsPerPageChange,
2706
2708
  itemsPerPageOptions = [10, 25, 50, 100],
2707
2709
  showInfo = true,
2710
+ showFirstLast = true,
2708
2711
  maxVisiblePages = 5,
2709
2712
  className = "",
2710
2713
  type = "",
@@ -2714,8 +2717,9 @@ var Pagination = ({
2714
2717
  const startItem = Math.min(filteredItems, 1 + (currentPage - 1) * itemsPerPage);
2715
2718
  const endItem = Math.min(currentPage * itemsPerPage, filteredItems);
2716
2719
  const hasFilteredItems = filteredItems > 0;
2717
- const isFirstPage = currentPage === 1;
2718
- const isLastPage = currentPage === totalPages;
2720
+ const isFirstPage = currentPage <= 1;
2721
+ const isLastPage = currentPage >= totalPages;
2722
+ const showFirstLastButtons = showFirstLast && totalPages > maxVisiblePages;
2719
2723
  if (totalItems <= itemsPerPageOptions[0]) {
2720
2724
  return null;
2721
2725
  }
@@ -2743,12 +2747,18 @@ var Pagination = ({
2743
2747
  onItemsPerPageChange?.(newItemsPerPage);
2744
2748
  onPageChange(1);
2745
2749
  };
2750
+ const handleFirstPage = () => {
2751
+ handlePageChange(1);
2752
+ };
2746
2753
  const handlePreviousPage = () => {
2747
2754
  handlePageChange(Math.max(1, currentPage - 1));
2748
2755
  };
2749
2756
  const handleNextPage = () => {
2750
2757
  handlePageChange(Math.min(totalPages, currentPage + 1));
2751
2758
  };
2759
+ const handleLastPage = () => {
2760
+ handlePageChange(totalPages);
2761
+ };
2752
2762
  const getVisiblePages = () => {
2753
2763
  const pageButtons = [];
2754
2764
  let startPage = 1;
@@ -2761,7 +2771,7 @@ var Pagination = ({
2761
2771
  startPage = totalPages - maxVisiblePages + 1;
2762
2772
  } else {
2763
2773
  startPage = currentPage - halfVisible;
2764
- endPage = currentPage + halfVisible;
2774
+ endPage = startPage + maxVisiblePages - 1;
2765
2775
  }
2766
2776
  }
2767
2777
  for (let i = startPage; i <= endPage; i++) {
@@ -2772,6 +2782,8 @@ var Pagination = ({
2772
2782
  variant: currentPage === i ? "primary" : "tertiary",
2773
2783
  size: "sm",
2774
2784
  onClick: () => handlePageChange(i),
2785
+ "aria-label": `Page ${i} of ${totalPages}`,
2786
+ "aria-current": currentPage === i ? "page" : void 0,
2775
2787
  children: i
2776
2788
  },
2777
2789
  i
@@ -2788,7 +2800,14 @@ var Pagination = ({
2788
2800
  " to"
2789
2801
  ] }),
2790
2802
  onItemsPerPageChange ? /* @__PURE__ */ jsxs(Select, { value: itemsPerPage.toString(), onValueChange: handleItemsPerPageChange, children: [
2791
- /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2803
+ /* @__PURE__ */ jsx(
2804
+ SelectTrigger,
2805
+ {
2806
+ className: styles36["items-per-page-trigger"],
2807
+ "aria-label": "Items per page",
2808
+ children: /* @__PURE__ */ jsx(SelectValue, {})
2809
+ }
2810
+ ),
2792
2811
  /* @__PURE__ */ jsx(SelectContent, { children: itemsPerPageOptions.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.toString(), children: option }, option)) })
2793
2812
  ] }) : /* @__PURE__ */ jsx("span", { children: endItem }),
2794
2813
  /* @__PURE__ */ jsxs("span", { children: [
@@ -2798,7 +2817,18 @@ var Pagination = ({
2798
2817
  type
2799
2818
  ] })
2800
2819
  ] }) }),
2801
- /* @__PURE__ */ jsxs("div", { className: styles36["page-navigation-container"], children: [
2820
+ /* @__PURE__ */ jsxs("nav", { className: styles36["page-navigation-container"], "aria-label": "Pagination", children: [
2821
+ showFirstLastButtons && /* @__PURE__ */ jsx(
2822
+ Button,
2823
+ {
2824
+ variant: "tertiary",
2825
+ size: "sm",
2826
+ onClick: handleFirstPage,
2827
+ disabled: isFirstPage,
2828
+ "aria-label": "First page",
2829
+ children: /* @__PURE__ */ jsx(ChevronsLeftIcon, {})
2830
+ }
2831
+ ),
2802
2832
  /* @__PURE__ */ jsx(
2803
2833
  Button,
2804
2834
  {
@@ -2821,6 +2851,17 @@ var Pagination = ({
2821
2851
  "aria-label": "Next page",
2822
2852
  children: /* @__PURE__ */ jsx(ChevronRightIcon3, {})
2823
2853
  }
2854
+ ),
2855
+ showFirstLastButtons && /* @__PURE__ */ jsx(
2856
+ Button,
2857
+ {
2858
+ variant: "tertiary",
2859
+ size: "sm",
2860
+ onClick: handleLastPage,
2861
+ disabled: isLastPage,
2862
+ "aria-label": `Last page (${totalPages})`,
2863
+ children: /* @__PURE__ */ jsx(ChevronsRightIcon, {})
2864
+ }
2824
2865
  )
2825
2866
  ] })
2826
2867
  ] });