@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.
package/dist/index.d.cts CHANGED
@@ -2976,9 +2976,11 @@ interface DataTableProps<T> {
2976
2976
  enableHeaderAutoFit?: boolean;
2977
2977
  labels?: DataTableLabels;
2978
2978
  borderMode?: BorderMode;
2979
+ /** Pagination variant: "default" (ellipsis) or "classic" (blocks of 10 with fast forward/backward) */
2980
+ paginationVariant?: "default" | "classic";
2979
2981
  }
2980
2982
 
2981
- declare function DataTable<T extends Record<string, any>>({ columns, data, rowKey, loading, total, page, pageSize, pageSizeOptions, onQueryChange, caption, toolbar, showToolbar, size, enableColumnVisibilityToggle, enableDensityToggle, enableHeaderAlignToggle, uppercaseHeader, striped, columnDividers, className, storageKey, stickyHeader, maxHeight, horizontalMode, overflowHidden, useOverlayScrollbar, virtualizedRows, estimatedRowHeight, overscan, paginationAlign, paginationRange, enableHeaderAutoFit, labels, columnColorGroups, borderMode, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
2983
+ declare function DataTable<T extends Record<string, any>>({ columns, data, rowKey, loading, total, page, pageSize, pageSizeOptions, onQueryChange, caption, toolbar, showToolbar, size, enableColumnVisibilityToggle, enableDensityToggle, enableHeaderAlignToggle, uppercaseHeader, striped, columnDividers, className, storageKey, stickyHeader, maxHeight, horizontalMode, overflowHidden, useOverlayScrollbar, virtualizedRows, estimatedRowHeight, overscan, paginationAlign, paginationRange, enableHeaderAutoFit, labels, columnColorGroups, borderMode, paginationVariant, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
2982
2984
 
2983
2985
  /** Public props for the `Table` component. */
2984
2986
  interface TableProps extends React__default.HTMLAttributes<HTMLTableElement> {
package/dist/index.d.ts CHANGED
@@ -2976,9 +2976,11 @@ interface DataTableProps<T> {
2976
2976
  enableHeaderAutoFit?: boolean;
2977
2977
  labels?: DataTableLabels;
2978
2978
  borderMode?: BorderMode;
2979
+ /** Pagination variant: "default" (ellipsis) or "classic" (blocks of 10 with fast forward/backward) */
2980
+ paginationVariant?: "default" | "classic";
2979
2981
  }
2980
2982
 
2981
- declare function DataTable<T extends Record<string, any>>({ columns, data, rowKey, loading, total, page, pageSize, pageSizeOptions, onQueryChange, caption, toolbar, showToolbar, size, enableColumnVisibilityToggle, enableDensityToggle, enableHeaderAlignToggle, uppercaseHeader, striped, columnDividers, className, storageKey, stickyHeader, maxHeight, horizontalMode, overflowHidden, useOverlayScrollbar, virtualizedRows, estimatedRowHeight, overscan, paginationAlign, paginationRange, enableHeaderAutoFit, labels, columnColorGroups, borderMode, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
2983
+ declare function DataTable<T extends Record<string, any>>({ columns, data, rowKey, loading, total, page, pageSize, pageSizeOptions, onQueryChange, caption, toolbar, showToolbar, size, enableColumnVisibilityToggle, enableDensityToggle, enableHeaderAlignToggle, uppercaseHeader, striped, columnDividers, className, storageKey, stickyHeader, maxHeight, horizontalMode, overflowHidden, useOverlayScrollbar, virtualizedRows, estimatedRowHeight, overscan, paginationAlign, paginationRange, enableHeaderAutoFit, labels, columnColorGroups, borderMode, paginationVariant, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
2982
2984
 
2983
2985
  /** Public props for the `Table` component. */
2984
2986
  interface TableProps extends React__default.HTMLAttributes<HTMLTableElement> {
package/dist/index.js CHANGED
@@ -22054,10 +22054,19 @@ function DataTablePagination({
22054
22054
  size,
22055
22055
  align,
22056
22056
  paginationRange,
22057
- borderMode
22057
+ borderMode,
22058
+ variant = "default"
22058
22059
  }) {
22059
22060
  const totalPages = Math.ceil(totalItems / curPageSize);
22061
+ const isClassic = variant === "classic";
22062
+ const classicBlockSize = 10;
22060
22063
  const pages = React51.useMemo(() => {
22064
+ if (isClassic) {
22065
+ const blockIndex = Math.floor((curPage - 1) / classicBlockSize);
22066
+ const startPage = blockIndex * classicBlockSize + 1;
22067
+ const endPage = Math.min(startPage + classicBlockSize - 1, totalPages);
22068
+ return Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);
22069
+ }
22061
22070
  const edgeCount = Math.max(1, Math.floor(paginationRange ?? (totalPages < 14 ? 3 : 5)));
22062
22071
  if (totalPages <= edgeCount * 2 + 3) return Array.from({ length: totalPages }, (_, index) => index + 1);
22063
22072
  const pageNumbers = /* @__PURE__ */ new Set();
@@ -22065,7 +22074,7 @@ function DataTablePagination({
22065
22074
  for (let page = totalPages - edgeCount + 1; page <= totalPages; page += 1) pageNumbers.add(page);
22066
22075
  for (let page = Math.max(1, curPage - 1); page <= Math.min(totalPages, curPage + 1); page += 1) pageNumbers.add(page);
22067
22076
  return Array.from(pageNumbers).sort((a, b) => a - b).flatMap((page, index, sortedPages) => index > 0 && page - sortedPages[index - 1] > 1 ? ["...", page] : [page]);
22068
- }, [curPage, paginationRange, totalPages]);
22077
+ }, [curPage, paginationRange, totalPages, isClassic]);
22069
22078
  if (totalItems === 0) return null;
22070
22079
  const controlButtonSize = size === "lg" ? "md" : "sm";
22071
22080
  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";
@@ -22074,6 +22083,8 @@ function DataTablePagination({
22074
22083
  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";
22075
22084
  const containerTextClass = size === "sm" ? "text-[11px]" : size === "lg" ? "text-sm" : "text-xs";
22076
22085
  const pageSizeClass = size === "sm" ? "w-16" : size === "lg" ? "w-24" : "w-20";
22086
+ const showClassicNav = isClassic && totalPages > classicBlockSize;
22087
+ const showArrowNav = !isClassic || showClassicNav;
22077
22088
  return /* @__PURE__ */ jsxs51("div", { className: cn("relative flex items-center gap-2 px-1 pt-3 text-muted-foreground", containerTextClass), children: [
22078
22089
  /* @__PURE__ */ jsxs51("div", { className: "flex items-center gap-2", children: [
22079
22090
  /* @__PURE__ */ jsxs51("div", { className: "tabular-nums", children: [
@@ -22083,7 +22094,7 @@ function DataTablePagination({
22083
22094
  "/",
22084
22095
  totalItems
22085
22096
  ] }),
22086
- pageSizeOptions && /* @__PURE__ */ jsx59(
22097
+ pageSizeOptions && pageSizeOptions.length > 0 && /* @__PURE__ */ jsx59(
22087
22098
  Combobox,
22088
22099
  {
22089
22100
  options: pageSizeOptions.map(String),
@@ -22106,14 +22117,32 @@ function DataTablePagination({
22106
22117
  align === "right" && "ml-auto"
22107
22118
  ),
22108
22119
  children: [
22109
- /* @__PURE__ */ jsx59(
22120
+ showClassicNav && /* @__PURE__ */ jsx59(
22110
22121
  Button_default,
22111
22122
  {
22112
22123
  variant: "ghost",
22113
22124
  size: controlButtonSize,
22114
22125
  className: navBtnClass,
22115
- onClick: () => setCurPage(Math.max(1, curPage - 1)),
22126
+ onClick: () => setCurPage(1),
22116
22127
  disabled: curPage === 1,
22128
+ children: /* @__PURE__ */ jsx59("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx59("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M11 19l-7-7 7-7m8 14l-7-7 7-7" }) })
22129
+ }
22130
+ ),
22131
+ showArrowNav && /* @__PURE__ */ jsx59(
22132
+ Button_default,
22133
+ {
22134
+ variant: "ghost",
22135
+ size: controlButtonSize,
22136
+ className: navBtnClass,
22137
+ onClick: () => {
22138
+ if (isClassic) {
22139
+ const startPage = Math.floor((curPage - 1) / classicBlockSize) * classicBlockSize + 1;
22140
+ setCurPage(Math.max(1, startPage - classicBlockSize));
22141
+ } else {
22142
+ setCurPage(Math.max(1, curPage - 1));
22143
+ }
22144
+ },
22145
+ disabled: isClassic ? Math.floor((curPage - 1) / classicBlockSize) === 0 : curPage === 1,
22117
22146
  children: /* @__PURE__ */ jsx59("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx59("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) })
22118
22147
  }
22119
22148
  ),
@@ -22128,16 +22157,34 @@ function DataTablePagination({
22128
22157
  p
22129
22158
  )
22130
22159
  ) }),
22131
- /* @__PURE__ */ jsx59(
22160
+ showArrowNav && /* @__PURE__ */ jsx59(
22132
22161
  Button_default,
22133
22162
  {
22134
22163
  variant: "ghost",
22135
22164
  size: controlButtonSize,
22136
22165
  className: navBtnClass,
22137
- onClick: () => setCurPage(Math.min(totalPages, curPage + 1)),
22138
- disabled: curPage === totalPages,
22166
+ onClick: () => {
22167
+ if (isClassic) {
22168
+ const startPage = Math.floor((curPage - 1) / classicBlockSize) * classicBlockSize + 1;
22169
+ setCurPage(Math.min(totalPages, startPage + classicBlockSize));
22170
+ } else {
22171
+ setCurPage(Math.min(totalPages, curPage + 1));
22172
+ }
22173
+ },
22174
+ disabled: isClassic ? Math.floor((curPage - 1) / classicBlockSize) === Math.floor((totalPages - 1) / classicBlockSize) : curPage === totalPages,
22139
22175
  children: /* @__PURE__ */ jsx59("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx59("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
22140
22176
  }
22177
+ ),
22178
+ showClassicNav && /* @__PURE__ */ jsx59(
22179
+ Button_default,
22180
+ {
22181
+ variant: "ghost",
22182
+ size: controlButtonSize,
22183
+ className: navBtnClass,
22184
+ onClick: () => setCurPage(totalPages),
22185
+ disabled: curPage === totalPages,
22186
+ children: /* @__PURE__ */ jsx59("svg", { className: navIconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx59("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 5l7 7-7 7M5 5l7 7-7 7" }) })
22187
+ }
22141
22188
  )
22142
22189
  ]
22143
22190
  }
@@ -22854,7 +22901,8 @@ function DataTable({
22854
22901
  enableHeaderAutoFit = true,
22855
22902
  labels,
22856
22903
  columnColorGroups,
22857
- borderMode
22904
+ borderMode,
22905
+ paginationVariant = "default"
22858
22906
  }) {
22859
22907
  const t = useSmartTranslations("Common");
22860
22908
  const globalConfig = useUnderverseUIConfig();
@@ -23105,7 +23153,8 @@ function DataTable({
23105
23153
  size,
23106
23154
  align: paginationAlign,
23107
23155
  paginationRange,
23108
- borderMode: resolvedBorderMode
23156
+ borderMode: resolvedBorderMode,
23157
+ variant: paginationVariant
23109
23158
  }
23110
23159
  )
23111
23160
  ] });