@nearform/quantum 1.7.0 → 1.7.2

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.js CHANGED
@@ -3667,9 +3667,10 @@ var PageNumberStyles = (0, import_class_variance_authority21.cva)([
3667
3667
  "rounded-xs",
3668
3668
  "text-foreground-muted",
3669
3669
  "dark:text-foreground-muted-dark",
3670
+ "hover:bg-button-tertiary-hover",
3671
+ "dark:hover:bg-button-tertiary-hover-dark",
3670
3672
  "active:bg-accent",
3671
3673
  "active:text-primary-10",
3672
- "dark:hover:bg-background-dark",
3673
3674
  "dark:active:bg-primary-30",
3674
3675
  "dark:active:text-grey-900"
3675
3676
  ]);
@@ -3683,6 +3684,54 @@ var PageNumberActiveStyles = (0, import_class_variance_authority21.cva)([
3683
3684
  "dark:hover:bg-primary-30",
3684
3685
  "dark:hover:text-grey-900"
3685
3686
  ]);
3687
+ var StepButtonStyles = (0, import_class_variance_authority21.cva)([
3688
+ "px-4",
3689
+ "rounded-xs",
3690
+ "text-foreground",
3691
+ "dark:text-foreground-dark",
3692
+ "enabled:hover:bg-button-tertiary-hover",
3693
+ "dark:enabled:hover:bg-button-tertiary-hover-dark",
3694
+ "disabled:text-foreground-subtle",
3695
+ "dark:disabled:text-foreground-subtle-dark"
3696
+ ]);
3697
+ var noOfSiblings = 1;
3698
+ var noOfPagesShown = noOfSiblings * 2 + 5;
3699
+ var range = (from, to) => Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i);
3700
+ var pageWindow = (currentPage, totalPages) => {
3701
+ if (totalPages <= noOfPagesShown) {
3702
+ return {
3703
+ pageNumbers: range(1, totalPages),
3704
+ showLeftDots: false,
3705
+ showRightDots: false
3706
+ };
3707
+ }
3708
+ if (currentPage <= noOfPagesShown - 3) {
3709
+ return {
3710
+ pageNumbers: [...range(1, noOfPagesShown - 2), totalPages],
3711
+ showLeftDots: false,
3712
+ showRightDots: true
3713
+ };
3714
+ }
3715
+ if (currentPage < totalPages - 3) {
3716
+ return {
3717
+ pageNumbers: [
3718
+ 1,
3719
+ ...range(
3720
+ Math.max(2, currentPage - noOfSiblings),
3721
+ Math.min(totalPages - 1, currentPage + noOfSiblings)
3722
+ ),
3723
+ totalPages
3724
+ ],
3725
+ showLeftDots: true,
3726
+ showRightDots: true
3727
+ };
3728
+ }
3729
+ return {
3730
+ pageNumbers: [1, ...range(totalPages - noOfPagesShown + 3, totalPages)],
3731
+ showLeftDots: true,
3732
+ showRightDots: false
3733
+ };
3734
+ };
3686
3735
  var Pagination = import_react7.default.forwardRef(
3687
3736
  (_a, ref) => {
3688
3737
  var _b = _a, {
@@ -3712,42 +3761,10 @@ var Pagination = import_react7.default.forwardRef(
3712
3761
  currentRowsLength > 0 ? currentRowsLength / numberOfItemsPerPage : 0
3713
3762
  );
3714
3763
  }, [currentRowsLength, numberOfItemsPerPage]);
3715
- const allPages = [...Array(totalPages + 1).keys()].slice(1);
3716
- const [pageNumbers, setPageNumbers] = (0, import_react7.useState)(allPages);
3717
- const [showLeftDots, setShowLeftDots] = (0, import_react7.useState)(false);
3718
- const [showRightDots, setShowRightDots] = (0, import_react7.useState)(false);
3719
- const noOfSiblings = 1;
3720
- const noOfPagesShown = noOfSiblings * 2 + 5;
3721
- (0, import_react7.useEffect)(() => {
3722
- if (totalPages <= noOfPagesShown) {
3723
- setPageNumbers(allPages);
3724
- setShowRightDots(false);
3725
- setShowLeftDots(false);
3726
- } else if (currentPage <= noOfPagesShown - 3) {
3727
- const pages = allPages.slice(0, noOfPagesShown - 2);
3728
- pages.push(totalPages);
3729
- setPageNumbers(pages);
3730
- setShowRightDots(true);
3731
- setShowLeftDots(false);
3732
- } else if (noOfPagesShown - 3 < currentPage && currentPage < totalPages - 3) {
3733
- const pages = [1];
3734
- const start = Math.max(2, currentPage - noOfSiblings);
3735
- const end = Math.min(totalPages - 1, currentPage + noOfSiblings);
3736
- for (let i = start; i <= end; i++) {
3737
- pages.push(i);
3738
- }
3739
- pages.push(totalPages);
3740
- setPageNumbers(pages);
3741
- setShowRightDots(true);
3742
- setShowLeftDots(true);
3743
- } else if (currentPage >= totalPages - 3) {
3744
- const pages = allPages.slice(-noOfPagesShown + 2);
3745
- pages.unshift(1);
3746
- setPageNumbers(pages);
3747
- setShowRightDots(false);
3748
- setShowLeftDots(true);
3749
- }
3750
- }, [currentPage, totalPages]);
3764
+ const { pageNumbers, showLeftDots, showRightDots } = import_react7.default.useMemo(
3765
+ () => pageWindow(currentPage, totalPages),
3766
+ [currentPage, totalPages]
3767
+ );
3751
3768
  const goToNextPage = () => {
3752
3769
  if (currentPage !== totalPages) setCurrentPage(currentPage + 1);
3753
3770
  };
@@ -3762,18 +3779,19 @@ var Pagination = import_react7.default.forwardRef(
3762
3779
  ref
3763
3780
  }, props), {
3764
3781
  children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("ul", { children: [
3765
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("li", { className: "hover:bg-background px-4 dark:hover:bg-background-dark rounded-xs", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3782
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3766
3783
  "button",
3767
3784
  {
3768
3785
  type: "button",
3769
3786
  "aria-label": previousLabel,
3787
+ className: StepButtonStyles(),
3770
3788
  onClick: goToPrevPage,
3771
3789
  disabled: currentPage === 1 || totalPages === 0,
3772
3790
  children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3773
3791
  assets_exports.BsChevronLeft,
3774
3792
  {
3775
3793
  "aria-hidden": "true",
3776
- className: "w-3 h-9 pt-3 pb-3 -mb-1 text-foreground dark:text-foreground-dark"
3794
+ className: "w-3 h-9 pt-3 pb-3 -mb-1"
3777
3795
  }
3778
3796
  )
3779
3797
  }
@@ -3810,18 +3828,19 @@ var Pagination = import_react7.default.forwardRef(
3810
3828
  }
3811
3829
  ) : null
3812
3830
  ] }, pgNumber)),
3813
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("li", { className: "hover:bg-background px-4 dark:hover:bg-background-dark rounded-xs", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3831
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3814
3832
  "button",
3815
3833
  {
3816
3834
  type: "button",
3817
3835
  "aria-label": nextLabel,
3836
+ className: StepButtonStyles(),
3818
3837
  onClick: goToNextPage,
3819
3838
  disabled: currentPage === totalPages || totalPages === 0,
3820
3839
  children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3821
3840
  assets_exports.BsChevronRight,
3822
3841
  {
3823
3842
  "aria-hidden": "true",
3824
- className: "w-3 h-9 py-3 -mb-1 text-foreground dark:text-foreground-dark"
3843
+ className: "w-3 h-9 py-3 -mb-1"
3825
3844
  }
3826
3845
  )
3827
3846
  }