@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.
- package/api-reference.json +1 -1
- package/dist/index.cjs +67 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +66 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
@@ -22053,10 +22053,20 @@ function DataTablePagination({
|
|
|
22053
22053
|
setCurPageSize,
|
|
22054
22054
|
size,
|
|
22055
22055
|
align,
|
|
22056
|
-
paginationRange
|
|
22056
|
+
paginationRange,
|
|
22057
|
+
borderMode,
|
|
22058
|
+
variant = "default"
|
|
22057
22059
|
}) {
|
|
22058
22060
|
const totalPages = Math.ceil(totalItems / curPageSize);
|
|
22061
|
+
const isClassic = variant === "classic";
|
|
22062
|
+
const classicBlockSize = 10;
|
|
22059
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
|
+
}
|
|
22060
22070
|
const edgeCount = Math.max(1, Math.floor(paginationRange ?? (totalPages < 14 ? 3 : 5)));
|
|
22061
22071
|
if (totalPages <= edgeCount * 2 + 3) return Array.from({ length: totalPages }, (_, index) => index + 1);
|
|
22062
22072
|
const pageNumbers = /* @__PURE__ */ new Set();
|
|
@@ -22064,14 +22074,17 @@ function DataTablePagination({
|
|
|
22064
22074
|
for (let page = totalPages - edgeCount + 1; page <= totalPages; page += 1) pageNumbers.add(page);
|
|
22065
22075
|
for (let page = Math.max(1, curPage - 1); page <= Math.min(totalPages, curPage + 1); page += 1) pageNumbers.add(page);
|
|
22066
22076
|
return Array.from(pageNumbers).sort((a, b) => a - b).flatMap((page, index, sortedPages) => index > 0 && page - sortedPages[index - 1] > 1 ? ["...", page] : [page]);
|
|
22067
|
-
}, [curPage, paginationRange, totalPages]);
|
|
22077
|
+
}, [curPage, paginationRange, totalPages, isClassic]);
|
|
22068
22078
|
if (totalItems === 0) return null;
|
|
22069
22079
|
const controlButtonSize = size === "lg" ? "md" : "sm";
|
|
22070
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";
|
|
22071
22081
|
const navIconClass = size === "sm" ? "h-3.5 w-3.5" : size === "lg" ? "h-5 w-5" : "h-4 w-4";
|
|
22072
|
-
const
|
|
22082
|
+
const pageBtnRadiusClass = getBorderRadiusClass(borderMode);
|
|
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";
|
|
22073
22084
|
const containerTextClass = size === "sm" ? "text-[11px]" : size === "lg" ? "text-sm" : "text-xs";
|
|
22074
22085
|
const pageSizeClass = size === "sm" ? "w-16" : size === "lg" ? "w-24" : "w-20";
|
|
22086
|
+
const showClassicNav = isClassic && totalPages > classicBlockSize;
|
|
22087
|
+
const showArrowNav = !isClassic || showClassicNav;
|
|
22075
22088
|
return /* @__PURE__ */ jsxs51("div", { className: cn("relative flex items-center gap-2 px-1 pt-3 text-muted-foreground", containerTextClass), children: [
|
|
22076
22089
|
/* @__PURE__ */ jsxs51("div", { className: "flex items-center gap-2", children: [
|
|
22077
22090
|
/* @__PURE__ */ jsxs51("div", { className: "tabular-nums", children: [
|
|
@@ -22081,7 +22094,7 @@ function DataTablePagination({
|
|
|
22081
22094
|
"/",
|
|
22082
22095
|
totalItems
|
|
22083
22096
|
] }),
|
|
22084
|
-
pageSizeOptions && /* @__PURE__ */ jsx59(
|
|
22097
|
+
pageSizeOptions && pageSizeOptions.length > 0 && /* @__PURE__ */ jsx59(
|
|
22085
22098
|
Combobox,
|
|
22086
22099
|
{
|
|
22087
22100
|
options: pageSizeOptions.map(String),
|
|
@@ -22099,42 +22112,78 @@ function DataTablePagination({
|
|
|
22099
22112
|
"div",
|
|
22100
22113
|
{
|
|
22101
22114
|
className: cn(
|
|
22102
|
-
"flex items-center gap-
|
|
22115
|
+
"flex items-center gap-3",
|
|
22103
22116
|
align === "center" && "absolute left-1/2 -translate-x-1/2",
|
|
22104
22117
|
align === "right" && "ml-auto"
|
|
22105
22118
|
),
|
|
22106
22119
|
children: [
|
|
22107
|
-
/* @__PURE__ */ jsx59(
|
|
22120
|
+
showClassicNav && /* @__PURE__ */ jsx59(
|
|
22108
22121
|
Button_default,
|
|
22109
22122
|
{
|
|
22110
22123
|
variant: "ghost",
|
|
22111
22124
|
size: controlButtonSize,
|
|
22112
22125
|
className: navBtnClass,
|
|
22113
|
-
onClick: () => setCurPage(
|
|
22126
|
+
onClick: () => setCurPage(1),
|
|
22114
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,
|
|
22115
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" }) })
|
|
22116
22147
|
}
|
|
22117
22148
|
),
|
|
22118
|
-
pages.map(
|
|
22149
|
+
/* @__PURE__ */ jsx59("div", { className: "flex items-center gap-2", children: pages.map(
|
|
22119
22150
|
(p, i) => p === "..." ? /* @__PURE__ */ jsx59("span", { className: "px-1 text-muted-foreground/60", children: "\u2026" }, `dots-${i}`) : /* @__PURE__ */ jsx59(
|
|
22120
22151
|
"button",
|
|
22121
22152
|
{
|
|
22122
22153
|
onClick: () => setCurPage(p),
|
|
22123
|
-
className: cn(pageBtnClass, curPage === p ? "bg-primary text-primary-foreground" : "hover:bg-accent hover:text-accent-foreground"),
|
|
22154
|
+
className: cn(pageBtnClass, pageBtnRadiusClass, curPage === p ? "bg-primary text-primary-foreground" : "hover:bg-accent hover:text-accent-foreground"),
|
|
22124
22155
|
children: p
|
|
22125
22156
|
},
|
|
22126
22157
|
p
|
|
22127
22158
|
)
|
|
22159
|
+
) }),
|
|
22160
|
+
showArrowNav && /* @__PURE__ */ jsx59(
|
|
22161
|
+
Button_default,
|
|
22162
|
+
{
|
|
22163
|
+
variant: "ghost",
|
|
22164
|
+
size: controlButtonSize,
|
|
22165
|
+
className: navBtnClass,
|
|
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,
|
|
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" }) })
|
|
22176
|
+
}
|
|
22128
22177
|
),
|
|
22129
|
-
/* @__PURE__ */ jsx59(
|
|
22178
|
+
showClassicNav && /* @__PURE__ */ jsx59(
|
|
22130
22179
|
Button_default,
|
|
22131
22180
|
{
|
|
22132
22181
|
variant: "ghost",
|
|
22133
22182
|
size: controlButtonSize,
|
|
22134
22183
|
className: navBtnClass,
|
|
22135
|
-
onClick: () => setCurPage(
|
|
22184
|
+
onClick: () => setCurPage(totalPages),
|
|
22136
22185
|
disabled: curPage === totalPages,
|
|
22137
|
-
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: "
|
|
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" }) })
|
|
22138
22187
|
}
|
|
22139
22188
|
)
|
|
22140
22189
|
]
|
|
@@ -22852,7 +22901,8 @@ function DataTable({
|
|
|
22852
22901
|
enableHeaderAutoFit = true,
|
|
22853
22902
|
labels,
|
|
22854
22903
|
columnColorGroups,
|
|
22855
|
-
borderMode
|
|
22904
|
+
borderMode,
|
|
22905
|
+
paginationVariant = "default"
|
|
22856
22906
|
}) {
|
|
22857
22907
|
const t = useSmartTranslations("Common");
|
|
22858
22908
|
const globalConfig = useUnderverseUIConfig();
|
|
@@ -23102,7 +23152,9 @@ function DataTable({
|
|
|
23102
23152
|
setCurPageSize,
|
|
23103
23153
|
size,
|
|
23104
23154
|
align: paginationAlign,
|
|
23105
|
-
paginationRange
|
|
23155
|
+
paginationRange,
|
|
23156
|
+
borderMode: resolvedBorderMode,
|
|
23157
|
+
variant: paginationVariant
|
|
23106
23158
|
}
|
|
23107
23159
|
)
|
|
23108
23160
|
] });
|