@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.cjs CHANGED
@@ -2801,6 +2801,8 @@ var SelectSeparator = React15__namespace.forwardRef(({ className, ...props }, re
2801
2801
  SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
2802
2802
  var ChevronLeftIcon2 = LucideIcons.ChevronLeft;
2803
2803
  var ChevronRightIcon3 = LucideIcons.ChevronRight;
2804
+ var ChevronsLeftIcon = LucideIcons.ChevronsLeft;
2805
+ var ChevronsRightIcon = LucideIcons.ChevronsRight;
2804
2806
  var Pagination = ({
2805
2807
  currentPage,
2806
2808
  totalItems,
@@ -2810,6 +2812,7 @@ var Pagination = ({
2810
2812
  onItemsPerPageChange,
2811
2813
  itemsPerPageOptions = [10, 25, 50, 100],
2812
2814
  showInfo = true,
2815
+ showFirstLast = true,
2813
2816
  maxVisiblePages = 5,
2814
2817
  className = "",
2815
2818
  type = "",
@@ -2819,8 +2822,9 @@ var Pagination = ({
2819
2822
  const startItem = Math.min(filteredItems, 1 + (currentPage - 1) * itemsPerPage);
2820
2823
  const endItem = Math.min(currentPage * itemsPerPage, filteredItems);
2821
2824
  const hasFilteredItems = filteredItems > 0;
2822
- const isFirstPage = currentPage === 1;
2823
- const isLastPage = currentPage === totalPages;
2825
+ const isFirstPage = currentPage <= 1;
2826
+ const isLastPage = currentPage >= totalPages;
2827
+ const showFirstLastButtons = showFirstLast && totalPages > maxVisiblePages;
2824
2828
  if (totalItems <= itemsPerPageOptions[0]) {
2825
2829
  return null;
2826
2830
  }
@@ -2848,12 +2852,18 @@ var Pagination = ({
2848
2852
  onItemsPerPageChange?.(newItemsPerPage);
2849
2853
  onPageChange(1);
2850
2854
  };
2855
+ const handleFirstPage = () => {
2856
+ handlePageChange(1);
2857
+ };
2851
2858
  const handlePreviousPage = () => {
2852
2859
  handlePageChange(Math.max(1, currentPage - 1));
2853
2860
  };
2854
2861
  const handleNextPage = () => {
2855
2862
  handlePageChange(Math.min(totalPages, currentPage + 1));
2856
2863
  };
2864
+ const handleLastPage = () => {
2865
+ handlePageChange(totalPages);
2866
+ };
2857
2867
  const getVisiblePages = () => {
2858
2868
  const pageButtons = [];
2859
2869
  let startPage = 1;
@@ -2866,7 +2876,7 @@ var Pagination = ({
2866
2876
  startPage = totalPages - maxVisiblePages + 1;
2867
2877
  } else {
2868
2878
  startPage = currentPage - halfVisible;
2869
- endPage = currentPage + halfVisible;
2879
+ endPage = startPage + maxVisiblePages - 1;
2870
2880
  }
2871
2881
  }
2872
2882
  for (let i = startPage; i <= endPage; i++) {
@@ -2877,6 +2887,8 @@ var Pagination = ({
2877
2887
  variant: currentPage === i ? "primary" : "tertiary",
2878
2888
  size: "sm",
2879
2889
  onClick: () => handlePageChange(i),
2890
+ "aria-label": `Page ${i} of ${totalPages}`,
2891
+ "aria-current": currentPage === i ? "page" : void 0,
2880
2892
  children: i
2881
2893
  },
2882
2894
  i
@@ -2893,7 +2905,14 @@ var Pagination = ({
2893
2905
  " to"
2894
2906
  ] }),
2895
2907
  onItemsPerPageChange ? /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: itemsPerPage.toString(), onValueChange: handleItemsPerPageChange, children: [
2896
- /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
2908
+ /* @__PURE__ */ jsxRuntime.jsx(
2909
+ SelectTrigger,
2910
+ {
2911
+ className: styles36__default.default["items-per-page-trigger"],
2912
+ "aria-label": "Items per page",
2913
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {})
2914
+ }
2915
+ ),
2897
2916
  /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: itemsPerPageOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: option.toString(), children: option }, option)) })
2898
2917
  ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: endItem }),
2899
2918
  /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
@@ -2903,7 +2922,18 @@ var Pagination = ({
2903
2922
  type
2904
2923
  ] })
2905
2924
  ] }) }),
2906
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles36__default.default["page-navigation-container"], children: [
2925
+ /* @__PURE__ */ jsxRuntime.jsxs("nav", { className: styles36__default.default["page-navigation-container"], "aria-label": "Pagination", children: [
2926
+ showFirstLastButtons && /* @__PURE__ */ jsxRuntime.jsx(
2927
+ Button,
2928
+ {
2929
+ variant: "tertiary",
2930
+ size: "sm",
2931
+ onClick: handleFirstPage,
2932
+ disabled: isFirstPage,
2933
+ "aria-label": "First page",
2934
+ children: /* @__PURE__ */ jsxRuntime.jsx(ChevronsLeftIcon, {})
2935
+ }
2936
+ ),
2907
2937
  /* @__PURE__ */ jsxRuntime.jsx(
2908
2938
  Button,
2909
2939
  {
@@ -2926,6 +2956,17 @@ var Pagination = ({
2926
2956
  "aria-label": "Next page",
2927
2957
  children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon3, {})
2928
2958
  }
2959
+ ),
2960
+ showFirstLastButtons && /* @__PURE__ */ jsxRuntime.jsx(
2961
+ Button,
2962
+ {
2963
+ variant: "tertiary",
2964
+ size: "sm",
2965
+ onClick: handleLastPage,
2966
+ disabled: isLastPage,
2967
+ "aria-label": `Last page (${totalPages})`,
2968
+ children: /* @__PURE__ */ jsxRuntime.jsx(ChevronsRightIcon, {})
2969
+ }
2929
2970
  )
2930
2971
  ] })
2931
2972
  ] });