@underverse-ui/underverse 2.0.20 → 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.20",
3
+ "version": "2.0.21",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 260,
6
6
  "exports": [
package/dist/index.cjs CHANGED
@@ -31899,10 +31899,19 @@ function DataTablePagination({
31899
31899
  size,
31900
31900
  align,
31901
31901
  paginationRange,
31902
- borderMode
31902
+ borderMode,
31903
+ variant = "default"
31903
31904
  }) {
31904
31905
  const totalPages = Math.ceil(totalItems / curPageSize);
31906
+ const isClassic = variant === "classic";
31907
+ const classicBlockSize = 10;
31905
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
+ }
31906
31915
  const edgeCount = Math.max(1, Math.floor(paginationRange ?? (totalPages < 14 ? 3 : 5)));
31907
31916
  if (totalPages <= edgeCount * 2 + 3) return Array.from({ length: totalPages }, (_, index) => index + 1);
31908
31917
  const pageNumbers = /* @__PURE__ */ new Set();
@@ -31910,7 +31919,7 @@ function DataTablePagination({
31910
31919
  for (let page = totalPages - edgeCount + 1; page <= totalPages; page += 1) pageNumbers.add(page);
31911
31920
  for (let page = Math.max(1, curPage - 1); page <= Math.min(totalPages, curPage + 1); page += 1) pageNumbers.add(page);
31912
31921
  return Array.from(pageNumbers).sort((a, b) => a - b).flatMap((page, index, sortedPages) => index > 0 && page - sortedPages[index - 1] > 1 ? ["...", page] : [page]);
31913
- }, [curPage, paginationRange, totalPages]);
31922
+ }, [curPage, paginationRange, totalPages, isClassic]);
31914
31923
  if (totalItems === 0) return null;
31915
31924
  const controlButtonSize = size === "lg" ? "md" : "sm";
31916
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";
@@ -31919,6 +31928,8 @@ function DataTablePagination({
31919
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";
31920
31929
  const containerTextClass = size === "sm" ? "text-[11px]" : size === "lg" ? "text-sm" : "text-xs";
31921
31930
  const pageSizeClass = size === "sm" ? "w-16" : size === "lg" ? "w-24" : "w-20";
31931
+ const showClassicNav = isClassic && totalPages > classicBlockSize;
31932
+ const showArrowNav = !isClassic || showClassicNav;
31922
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: [
31923
31934
  /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex items-center gap-2", children: [
31924
31935
  /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "tabular-nums", children: [
@@ -31928,7 +31939,7 @@ function DataTablePagination({
31928
31939
  "/",
31929
31940
  totalItems
31930
31941
  ] }),
31931
- pageSizeOptions && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31942
+ pageSizeOptions && pageSizeOptions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31932
31943
  Combobox,
31933
31944
  {
31934
31945
  options: pageSizeOptions.map(String),
@@ -31951,14 +31962,32 @@ function DataTablePagination({
31951
31962
  align === "right" && "ml-auto"
31952
31963
  ),
31953
31964
  children: [
31954
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31965
+ showClassicNav && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31955
31966
  Button_default,
31956
31967
  {
31957
31968
  variant: "ghost",
31958
31969
  size: controlButtonSize,
31959
31970
  className: navBtnClass,
31960
- onClick: () => setCurPage(Math.max(1, curPage - 1)),
31971
+ onClick: () => setCurPage(1),
31961
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,
31962
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" }) })
31963
31992
  }
31964
31993
  ),
@@ -31973,16 +32002,34 @@ function DataTablePagination({
31973
32002
  p
31974
32003
  )
31975
32004
  ) }),
31976
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32005
+ showArrowNav && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31977
32006
  Button_default,
31978
32007
  {
31979
32008
  variant: "ghost",
31980
32009
  size: controlButtonSize,
31981
32010
  className: navBtnClass,
31982
- onClick: () => setCurPage(Math.min(totalPages, curPage + 1)),
31983
- disabled: curPage === totalPages,
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,
31984
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" }) })
31985
32021
  }
32022
+ ),
32023
+ showClassicNav && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32024
+ Button_default,
32025
+ {
32026
+ variant: "ghost",
32027
+ size: controlButtonSize,
32028
+ className: navBtnClass,
32029
+ onClick: () => setCurPage(totalPages),
32030
+ disabled: curPage === totalPages,
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" }) })
32032
+ }
31986
32033
  )
31987
32034
  ]
31988
32035
  }
@@ -32701,7 +32748,8 @@ function DataTable({
32701
32748
  enableHeaderAutoFit = true,
32702
32749
  labels,
32703
32750
  columnColorGroups,
32704
- borderMode
32751
+ borderMode,
32752
+ paginationVariant = "default"
32705
32753
  }) {
32706
32754
  const t = useSmartTranslations("Common");
32707
32755
  const globalConfig = useUnderverseUIConfig();
@@ -32952,7 +33000,8 @@ function DataTable({
32952
33000
  size,
32953
33001
  align: paginationAlign,
32954
33002
  paginationRange,
32955
- borderMode: resolvedBorderMode
33003
+ borderMode: resolvedBorderMode,
33004
+ variant: paginationVariant
32956
33005
  }
32957
33006
  )
32958
33007
  ] });