@underverse-ui/underverse 2.0.19 → 2.0.21

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 260,
6
6
  "exports": [
package/dist/index.cjs CHANGED
@@ -31887,6 +31887,7 @@ function DataTableHeader({
31887
31887
  // src/components/DataTable/components/Pagination.tsx
31888
31888
  var import_react35 = __toESM(require("react"), 1);
31889
31889
  init_cn();
31890
+ init_radius();
31890
31891
  var import_jsx_runtime71 = require("react/jsx-runtime");
31891
31892
  function DataTablePagination({
31892
31893
  totalItems,
@@ -31897,10 +31898,20 @@ function DataTablePagination({
31897
31898
  setCurPageSize,
31898
31899
  size,
31899
31900
  align,
31900
- paginationRange
31901
+ paginationRange,
31902
+ borderMode,
31903
+ variant = "default"
31901
31904
  }) {
31902
31905
  const totalPages = Math.ceil(totalItems / curPageSize);
31906
+ const isClassic = variant === "classic";
31907
+ const classicBlockSize = 10;
31903
31908
  const pages = import_react35.default.useMemo(() => {
31909
+ if (isClassic) {
31910
+ const blockIndex = Math.floor((curPage - 1) / classicBlockSize);
31911
+ const startPage = blockIndex * classicBlockSize + 1;
31912
+ const endPage = Math.min(startPage + classicBlockSize - 1, totalPages);
31913
+ return Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);
31914
+ }
31904
31915
  const edgeCount = Math.max(1, Math.floor(paginationRange ?? (totalPages < 14 ? 3 : 5)));
31905
31916
  if (totalPages <= edgeCount * 2 + 3) return Array.from({ length: totalPages }, (_, index) => index + 1);
31906
31917
  const pageNumbers = /* @__PURE__ */ new Set();
@@ -31908,14 +31919,17 @@ function DataTablePagination({
31908
31919
  for (let page = totalPages - edgeCount + 1; page <= totalPages; page += 1) pageNumbers.add(page);
31909
31920
  for (let page = Math.max(1, curPage - 1); page <= Math.min(totalPages, curPage + 1); page += 1) pageNumbers.add(page);
31910
31921
  return Array.from(pageNumbers).sort((a, b) => a - b).flatMap((page, index, sortedPages) => index > 0 && page - sortedPages[index - 1] > 1 ? ["...", page] : [page]);
31911
- }, [curPage, paginationRange, totalPages]);
31922
+ }, [curPage, paginationRange, totalPages, isClassic]);
31912
31923
  if (totalItems === 0) return null;
31913
31924
  const controlButtonSize = size === "lg" ? "md" : "sm";
31914
31925
  const navBtnClass = size === "sm" ? "h-6 w-6 p-0 rounded-full" : size === "lg" ? "h-8 w-8 p-0 rounded-full" : "h-7 w-7 p-0 rounded-full";
31915
31926
  const navIconClass = size === "sm" ? "h-3.5 w-3.5" : size === "lg" ? "h-5 w-5" : "h-4 w-4";
31916
- const pageBtnClass = size === "sm" ? "h-6 min-w-6 px-1.5 rounded-full text-[11px] font-medium transition-colors" : size === "lg" ? "h-8 min-w-8 px-2.5 rounded-full text-sm font-medium transition-colors" : "h-7 min-w-7 px-2 rounded-full text-xs font-medium transition-colors";
31927
+ const pageBtnRadiusClass = getBorderRadiusClass(borderMode);
31928
+ const pageBtnClass = size === "sm" ? "h-6 min-w-6 px-1.5 text-[11px] font-medium transition-colors" : size === "lg" ? "h-8 min-w-8 px-2.5 text-sm font-medium transition-colors" : "h-7 min-w-7 px-2 text-xs font-medium transition-colors";
31917
31929
  const containerTextClass = size === "sm" ? "text-[11px]" : size === "lg" ? "text-sm" : "text-xs";
31918
31930
  const pageSizeClass = size === "sm" ? "w-16" : size === "lg" ? "w-24" : "w-20";
31931
+ const showClassicNav = isClassic && totalPages > classicBlockSize;
31932
+ const showArrowNav = !isClassic || showClassicNav;
31919
31933
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: cn("relative flex items-center gap-2 px-1 pt-3 text-muted-foreground", containerTextClass), children: [
31920
31934
  /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex items-center gap-2", children: [
31921
31935
  /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "tabular-nums", children: [
@@ -31925,7 +31939,7 @@ function DataTablePagination({
31925
31939
  "/",
31926
31940
  totalItems
31927
31941
  ] }),
31928
- pageSizeOptions && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31942
+ pageSizeOptions && pageSizeOptions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31929
31943
  Combobox,
31930
31944
  {
31931
31945
  options: pageSizeOptions.map(String),
@@ -31943,42 +31957,78 @@ function DataTablePagination({
31943
31957
  "div",
31944
31958
  {
31945
31959
  className: cn(
31946
- "flex items-center gap-0.5",
31960
+ "flex items-center gap-3",
31947
31961
  align === "center" && "absolute left-1/2 -translate-x-1/2",
31948
31962
  align === "right" && "ml-auto"
31949
31963
  ),
31950
31964
  children: [
31951
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31965
+ showClassicNav && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31952
31966
  Button_default,
31953
31967
  {
31954
31968
  variant: "ghost",
31955
31969
  size: controlButtonSize,
31956
31970
  className: navBtnClass,
31957
- onClick: () => setCurPage(Math.max(1, curPage - 1)),
31971
+ onClick: () => setCurPage(1),
31958
31972
  disabled: curPage === 1,
31973
+ children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M11 19l-7-7 7-7m8 14l-7-7 7-7" }) })
31974
+ }
31975
+ ),
31976
+ showArrowNav && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31977
+ Button_default,
31978
+ {
31979
+ variant: "ghost",
31980
+ size: controlButtonSize,
31981
+ className: navBtnClass,
31982
+ onClick: () => {
31983
+ if (isClassic) {
31984
+ const startPage = Math.floor((curPage - 1) / classicBlockSize) * classicBlockSize + 1;
31985
+ setCurPage(Math.max(1, startPage - classicBlockSize));
31986
+ } else {
31987
+ setCurPage(Math.max(1, curPage - 1));
31988
+ }
31989
+ },
31990
+ disabled: isClassic ? Math.floor((curPage - 1) / classicBlockSize) === 0 : curPage === 1,
31959
31991
  children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) })
31960
31992
  }
31961
31993
  ),
31962
- pages.map(
31994
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "flex items-center gap-2", children: pages.map(
31963
31995
  (p, i) => p === "..." ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "px-1 text-muted-foreground/60", children: "\u2026" }, `dots-${i}`) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31964
31996
  "button",
31965
31997
  {
31966
31998
  onClick: () => setCurPage(p),
31967
- className: cn(pageBtnClass, curPage === p ? "bg-primary text-primary-foreground" : "hover:bg-accent hover:text-accent-foreground"),
31999
+ className: cn(pageBtnClass, pageBtnRadiusClass, curPage === p ? "bg-primary text-primary-foreground" : "hover:bg-accent hover:text-accent-foreground"),
31968
32000
  children: p
31969
32001
  },
31970
32002
  p
31971
32003
  )
32004
+ ) }),
32005
+ showArrowNav && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32006
+ Button_default,
32007
+ {
32008
+ variant: "ghost",
32009
+ size: controlButtonSize,
32010
+ className: navBtnClass,
32011
+ onClick: () => {
32012
+ if (isClassic) {
32013
+ const startPage = Math.floor((curPage - 1) / classicBlockSize) * classicBlockSize + 1;
32014
+ setCurPage(Math.min(totalPages, startPage + classicBlockSize));
32015
+ } else {
32016
+ setCurPage(Math.min(totalPages, curPage + 1));
32017
+ }
32018
+ },
32019
+ disabled: isClassic ? Math.floor((curPage - 1) / classicBlockSize) === Math.floor((totalPages - 1) / classicBlockSize) : curPage === totalPages,
32020
+ children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
32021
+ }
31972
32022
  ),
31973
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32023
+ showClassicNav && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31974
32024
  Button_default,
31975
32025
  {
31976
32026
  variant: "ghost",
31977
32027
  size: controlButtonSize,
31978
32028
  className: navBtnClass,
31979
- onClick: () => setCurPage(Math.min(totalPages, curPage + 1)),
32029
+ onClick: () => setCurPage(totalPages),
31980
32030
  disabled: curPage === totalPages,
31981
- children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
32031
+ children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 5l7 7-7 7M5 5l7 7-7 7" }) })
31982
32032
  }
31983
32033
  )
31984
32034
  ]
@@ -32698,7 +32748,8 @@ function DataTable({
32698
32748
  enableHeaderAutoFit = true,
32699
32749
  labels,
32700
32750
  columnColorGroups,
32701
- borderMode
32751
+ borderMode,
32752
+ paginationVariant = "default"
32702
32753
  }) {
32703
32754
  const t = useSmartTranslations("Common");
32704
32755
  const globalConfig = useUnderverseUIConfig();
@@ -32948,7 +32999,9 @@ function DataTable({
32948
32999
  setCurPageSize,
32949
33000
  size,
32950
33001
  align: paginationAlign,
32951
- paginationRange
33002
+ paginationRange,
33003
+ borderMode: resolvedBorderMode,
33004
+ variant: paginationVariant
32952
33005
  }
32953
33006
  )
32954
33007
  ] });