@ceed/cds 1.16.0 → 1.17.1-next.1

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.
@@ -21,6 +21,7 @@ interface PaginationProps extends React.ComponentProps<typeof PaginationRoot> {
21
21
  rowCount: number;
22
22
  onPageChange: (newPage: number) => void;
23
23
  size?: 'sm' | 'md' | 'lg';
24
+ variant?: 'standard' | 'compact';
24
25
  }
25
26
  declare function Pagination(props: PaginationProps): React.JSX.Element;
26
27
  declare namespace Pagination {
@@ -2,8 +2,8 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- ```text
6
- // Unable to derive source for Default
5
+ ```
6
+ <Canvas of={Pagination.Default} />
7
7
  ```
8
8
 
9
9
  | Field | Description | Default |
package/dist/index.cjs CHANGED
@@ -3528,8 +3528,10 @@ TableBody.displayName = "TableBody";
3528
3528
 
3529
3529
  // src/components/Pagination/Pagination.tsx
3530
3530
  var import_react27 = __toESM(require("react"));
3531
- var import_ChevronLeft2 = __toESM(require("@mui/icons-material/ChevronLeft"));
3532
- var import_ChevronRight2 = __toESM(require("@mui/icons-material/ChevronRight"));
3531
+ var import_ChevronLeftRounded = __toESM(require("@mui/icons-material/ChevronLeftRounded"));
3532
+ var import_ChevronRightRounded = __toESM(require("@mui/icons-material/ChevronRightRounded"));
3533
+ var import_FirstPageRounded = __toESM(require("@mui/icons-material/FirstPageRounded"));
3534
+ var import_LastPageRounded = __toESM(require("@mui/icons-material/LastPageRounded"));
3533
3535
  var import_joy35 = require("@mui/joy");
3534
3536
  var PaginationButton = (0, import_joy35.styled)(Button_default, {
3535
3537
  name: "Pagination",
@@ -3588,6 +3590,7 @@ function Pagination(props) {
3588
3590
  onPageChange,
3589
3591
  rowCount,
3590
3592
  size = "md",
3593
+ variant = "standard",
3591
3594
  ...innerProps
3592
3595
  } = props;
3593
3596
  const [paginationModel, setPaginationModel] = useControlledState(
@@ -3614,6 +3617,87 @@ function Pagination(props) {
3614
3617
  setPaginationModel({ ...paginationModel, page: lastPage });
3615
3618
  }
3616
3619
  }, [rowCount, paginationModel, lastPage, setPaginationModel]);
3620
+ const pageOptions = Array.from({ length: lastPage }, (_, i) => ({
3621
+ label: `${i + 1}`,
3622
+ value: `${i + 1}`
3623
+ }));
3624
+ if (variant === "compact") {
3625
+ return /* @__PURE__ */ import_react27.default.createElement(PaginationRoot, { ...innerProps }, /* @__PURE__ */ import_react27.default.createElement(PaginationContainer, { direction: "row", size, alignItems: "center" }, /* @__PURE__ */ import_react27.default.createElement(Stack_default, { direction: "row" }, /* @__PURE__ */ import_react27.default.createElement(
3626
+ PaginationIconButton,
3627
+ {
3628
+ size,
3629
+ variant: "plain",
3630
+ color: "neutral",
3631
+ onClick: () => handlePageChange(firstPage),
3632
+ disabled: paginationModel.page === firstPage,
3633
+ "aria-label": "First page"
3634
+ },
3635
+ /* @__PURE__ */ import_react27.default.createElement(import_FirstPageRounded.default, null)
3636
+ ), /* @__PURE__ */ import_react27.default.createElement(
3637
+ PaginationIconButton,
3638
+ {
3639
+ size,
3640
+ variant: "plain",
3641
+ color: "neutral",
3642
+ onClick: () => handlePageChange(paginationModel.page - 1),
3643
+ disabled: paginationModel.page === firstPage,
3644
+ "aria-label": "Previous page"
3645
+ },
3646
+ /* @__PURE__ */ import_react27.default.createElement(import_ChevronLeftRounded.default, null)
3647
+ )), /* @__PURE__ */ import_react27.default.createElement(
3648
+ Autocomplete_default,
3649
+ {
3650
+ size,
3651
+ value: `${paginationModel.page}`,
3652
+ onChange: (event) => {
3653
+ if (event.target.value) {
3654
+ handlePageChange(parseInt(event.target.value, 10));
3655
+ }
3656
+ },
3657
+ options: pageOptions,
3658
+ sx: {
3659
+ width: {
3660
+ sm: "80px",
3661
+ md: "100px",
3662
+ lg: "120px"
3663
+ }[size]
3664
+ }
3665
+ }
3666
+ ), /* @__PURE__ */ import_react27.default.createElement(
3667
+ Typography_default,
3668
+ {
3669
+ level: `body-${size}`,
3670
+ sx: (theme) => ({
3671
+ color: theme.palette.text.secondary,
3672
+ fontWeight: 500
3673
+ })
3674
+ },
3675
+ "/ ",
3676
+ lastPage
3677
+ ), /* @__PURE__ */ import_react27.default.createElement(Stack_default, { direction: "row" }, /* @__PURE__ */ import_react27.default.createElement(
3678
+ PaginationIconButton,
3679
+ {
3680
+ size,
3681
+ variant: "plain",
3682
+ color: "neutral",
3683
+ onClick: () => handlePageChange(paginationModel.page + 1),
3684
+ disabled: paginationModel.page === lastPage,
3685
+ "aria-label": "Next page"
3686
+ },
3687
+ /* @__PURE__ */ import_react27.default.createElement(import_ChevronRightRounded.default, null)
3688
+ ), /* @__PURE__ */ import_react27.default.createElement(
3689
+ PaginationIconButton,
3690
+ {
3691
+ size,
3692
+ variant: "plain",
3693
+ color: "neutral",
3694
+ onClick: () => handlePageChange(lastPage),
3695
+ disabled: paginationModel.page === lastPage,
3696
+ "aria-label": "Last page"
3697
+ },
3698
+ /* @__PURE__ */ import_react27.default.createElement(import_LastPageRounded.default, null)
3699
+ ))));
3700
+ }
3617
3701
  return /* @__PURE__ */ import_react27.default.createElement(PaginationRoot, { ...innerProps }, /* @__PURE__ */ import_react27.default.createElement(PaginationContainer, { direction: "row", size, alignItems: "center" }, /* @__PURE__ */ import_react27.default.createElement(
3618
3702
  PaginationIconButton,
3619
3703
  {
@@ -3624,7 +3708,7 @@ function Pagination(props) {
3624
3708
  disabled: paginationModel.page === firstPage,
3625
3709
  "aria-label": "Previous page"
3626
3710
  },
3627
- /* @__PURE__ */ import_react27.default.createElement(import_ChevronLeft2.default, null)
3711
+ /* @__PURE__ */ import_react27.default.createElement(import_ChevronLeftRounded.default, null)
3628
3712
  ), paginationModel.page !== firstPage && /* @__PURE__ */ import_react27.default.createElement(PaginationButton, { size, variant: "plain", color: "neutral", onClick: () => handlePageChange(firstPage) }, firstPage), isMoreBeforePages && /* @__PURE__ */ import_react27.default.createElement(
3629
3713
  PaginationButton,
3630
3714
  {
@@ -3655,7 +3739,7 @@ function Pagination(props) {
3655
3739
  disabled: paginationModel.page === lastPage,
3656
3740
  "aria-label": "Next page"
3657
3741
  },
3658
- /* @__PURE__ */ import_react27.default.createElement(import_ChevronRight2.default, null)
3742
+ /* @__PURE__ */ import_react27.default.createElement(import_ChevronRightRounded.default, null)
3659
3743
  )));
3660
3744
  }
3661
3745
  Pagination.displayName = "Pagination";
package/dist/index.js CHANGED
@@ -3466,8 +3466,10 @@ TableBody.displayName = "TableBody";
3466
3466
 
3467
3467
  // src/components/Pagination/Pagination.tsx
3468
3468
  import React24, { useCallback as useCallback10, useEffect as useEffect6 } from "react";
3469
- import PreviousIcon from "@mui/icons-material/ChevronLeft";
3470
- import NextIcon from "@mui/icons-material/ChevronRight";
3469
+ import PreviousIcon from "@mui/icons-material/ChevronLeftRounded";
3470
+ import NextIcon from "@mui/icons-material/ChevronRightRounded";
3471
+ import FirstPageIcon from "@mui/icons-material/FirstPageRounded";
3472
+ import LastPageIcon from "@mui/icons-material/LastPageRounded";
3471
3473
  import { styled as styled13 } from "@mui/joy";
3472
3474
  var PaginationButton = styled13(Button_default, {
3473
3475
  name: "Pagination",
@@ -3526,6 +3528,7 @@ function Pagination(props) {
3526
3528
  onPageChange,
3527
3529
  rowCount,
3528
3530
  size = "md",
3531
+ variant = "standard",
3529
3532
  ...innerProps
3530
3533
  } = props;
3531
3534
  const [paginationModel, setPaginationModel] = useControlledState(
@@ -3552,6 +3555,87 @@ function Pagination(props) {
3552
3555
  setPaginationModel({ ...paginationModel, page: lastPage });
3553
3556
  }
3554
3557
  }, [rowCount, paginationModel, lastPage, setPaginationModel]);
3558
+ const pageOptions = Array.from({ length: lastPage }, (_, i) => ({
3559
+ label: `${i + 1}`,
3560
+ value: `${i + 1}`
3561
+ }));
3562
+ if (variant === "compact") {
3563
+ return /* @__PURE__ */ React24.createElement(PaginationRoot, { ...innerProps }, /* @__PURE__ */ React24.createElement(PaginationContainer, { direction: "row", size, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Stack_default, { direction: "row" }, /* @__PURE__ */ React24.createElement(
3564
+ PaginationIconButton,
3565
+ {
3566
+ size,
3567
+ variant: "plain",
3568
+ color: "neutral",
3569
+ onClick: () => handlePageChange(firstPage),
3570
+ disabled: paginationModel.page === firstPage,
3571
+ "aria-label": "First page"
3572
+ },
3573
+ /* @__PURE__ */ React24.createElement(FirstPageIcon, null)
3574
+ ), /* @__PURE__ */ React24.createElement(
3575
+ PaginationIconButton,
3576
+ {
3577
+ size,
3578
+ variant: "plain",
3579
+ color: "neutral",
3580
+ onClick: () => handlePageChange(paginationModel.page - 1),
3581
+ disabled: paginationModel.page === firstPage,
3582
+ "aria-label": "Previous page"
3583
+ },
3584
+ /* @__PURE__ */ React24.createElement(PreviousIcon, null)
3585
+ )), /* @__PURE__ */ React24.createElement(
3586
+ Autocomplete_default,
3587
+ {
3588
+ size,
3589
+ value: `${paginationModel.page}`,
3590
+ onChange: (event) => {
3591
+ if (event.target.value) {
3592
+ handlePageChange(parseInt(event.target.value, 10));
3593
+ }
3594
+ },
3595
+ options: pageOptions,
3596
+ sx: {
3597
+ width: {
3598
+ sm: "80px",
3599
+ md: "100px",
3600
+ lg: "120px"
3601
+ }[size]
3602
+ }
3603
+ }
3604
+ ), /* @__PURE__ */ React24.createElement(
3605
+ Typography_default,
3606
+ {
3607
+ level: `body-${size}`,
3608
+ sx: (theme) => ({
3609
+ color: theme.palette.text.secondary,
3610
+ fontWeight: 500
3611
+ })
3612
+ },
3613
+ "/ ",
3614
+ lastPage
3615
+ ), /* @__PURE__ */ React24.createElement(Stack_default, { direction: "row" }, /* @__PURE__ */ React24.createElement(
3616
+ PaginationIconButton,
3617
+ {
3618
+ size,
3619
+ variant: "plain",
3620
+ color: "neutral",
3621
+ onClick: () => handlePageChange(paginationModel.page + 1),
3622
+ disabled: paginationModel.page === lastPage,
3623
+ "aria-label": "Next page"
3624
+ },
3625
+ /* @__PURE__ */ React24.createElement(NextIcon, null)
3626
+ ), /* @__PURE__ */ React24.createElement(
3627
+ PaginationIconButton,
3628
+ {
3629
+ size,
3630
+ variant: "plain",
3631
+ color: "neutral",
3632
+ onClick: () => handlePageChange(lastPage),
3633
+ disabled: paginationModel.page === lastPage,
3634
+ "aria-label": "Last page"
3635
+ },
3636
+ /* @__PURE__ */ React24.createElement(LastPageIcon, null)
3637
+ ))));
3638
+ }
3555
3639
  return /* @__PURE__ */ React24.createElement(PaginationRoot, { ...innerProps }, /* @__PURE__ */ React24.createElement(PaginationContainer, { direction: "row", size, alignItems: "center" }, /* @__PURE__ */ React24.createElement(
3556
3640
  PaginationIconButton,
3557
3641
  {