@algorithm-shift/design-system 1.2.47 → 1.2.49
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.css +3 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +22 -14
- package/dist/index.d.ts +22 -14
- package/dist/index.js +63 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -97,7 +97,6 @@ interface TableProps extends ElementProps {
|
|
|
97
97
|
data?: Record<string, any>;
|
|
98
98
|
pagination?: boolean;
|
|
99
99
|
itemsPerPage?: number;
|
|
100
|
-
onPageChange?: (page: number) => void;
|
|
101
100
|
loading?: boolean;
|
|
102
101
|
cellClickEnabled?: (cellData: Record<string, any>, columnId: string) => boolean;
|
|
103
102
|
onCellClick?: (cellData: Record<string, any>, columnId: string) => void;
|
|
@@ -247,22 +246,31 @@ declare const DateRange: ({ className, style, ...props }: DateRangeInputProps) =
|
|
|
247
246
|
|
|
248
247
|
declare const TextInputGroup: ({ className, style, prepend, append, ...props }: TextInputGroupProps) => react_jsx_runtime.JSX.Element;
|
|
249
248
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
249
|
+
interface PageChangeProps {
|
|
250
|
+
page: number;
|
|
251
|
+
itemsPerPage: number;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
interface CustomPaginationProps {
|
|
255
|
+
totalPages: number;
|
|
256
|
+
currentPage: number;
|
|
257
|
+
onPageChange: (props: PageChangeProps) => void;
|
|
258
|
+
maxVisiblePages?: number;
|
|
259
|
+
perPage: number;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
type PaginationMode = 'client' | 'server';
|
|
263
|
+
|
|
264
|
+
interface ExtendedTableProps extends TableProps {
|
|
265
|
+
paginationMode?: PaginationMode;
|
|
266
|
+
page?: number;
|
|
267
|
+
itemsPerPage?: number;
|
|
268
|
+
onPageChange?: (props: PageChangeProps) => void;
|
|
256
269
|
}
|
|
270
|
+
|
|
257
271
|
declare const Table: ({ columns, data, rowActions, className, style, pagination, paginationMode, itemsPerPage, onPageChange, page, loading, totalRecords, ...props }: ExtendedTableProps) => react_jsx_runtime.JSX.Element;
|
|
258
272
|
|
|
259
|
-
|
|
260
|
-
totalPages: number;
|
|
261
|
-
currentPage: number;
|
|
262
|
-
onPageChange: (page: number) => void;
|
|
263
|
-
maxVisiblePages?: number;
|
|
264
|
-
}
|
|
265
|
-
declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVisiblePages, }: CustomPaginationProps) => react_jsx_runtime.JSX.Element;
|
|
273
|
+
declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVisiblePages, perPage, }: CustomPaginationProps) => react_jsx_runtime.JSX.Element;
|
|
266
274
|
|
|
267
275
|
declare const Tabs: ({ className, style, tabs, verticalMenu, LinkComponent, pathname, canvasMode }: TabsProps) => react_jsx_runtime.JSX.Element;
|
|
268
276
|
|
package/dist/index.js
CHANGED
|
@@ -2215,7 +2215,8 @@ var CustomPagination = ({
|
|
|
2215
2215
|
totalPages,
|
|
2216
2216
|
currentPage,
|
|
2217
2217
|
onPageChange,
|
|
2218
|
-
maxVisiblePages = 5
|
|
2218
|
+
maxVisiblePages = 5,
|
|
2219
|
+
perPage
|
|
2219
2220
|
}) => {
|
|
2220
2221
|
const getPageNumbers = () => {
|
|
2221
2222
|
const pages = [];
|
|
@@ -2248,35 +2249,61 @@ var CustomPagination = ({
|
|
|
2248
2249
|
};
|
|
2249
2250
|
const handlePageChange = (page) => {
|
|
2250
2251
|
if (page >= 1 && page <= totalPages && page !== currentPage) {
|
|
2251
|
-
onPageChange(
|
|
2252
|
+
onPageChange({
|
|
2253
|
+
page,
|
|
2254
|
+
itemsPerPage: perPage
|
|
2255
|
+
});
|
|
2252
2256
|
}
|
|
2253
2257
|
};
|
|
2254
2258
|
const pageNumbers = getPageNumbers();
|
|
2255
|
-
return /* @__PURE__ */ (0, import_jsx_runtime43.
|
|
2256
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex flex-row gap-1 w-full items-center justify-between", children: [
|
|
2260
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2261
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "text-sm text-muted-foreground whitespace-nowrap", children: "Items per page:" }),
|
|
2262
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
2263
|
+
Select,
|
|
2264
|
+
{
|
|
2265
|
+
defaultValue: String(perPage),
|
|
2266
|
+
onValueChange: (value) => {
|
|
2267
|
+
onPageChange({ page: 1, itemsPerPage: Number(value) });
|
|
2268
|
+
},
|
|
2269
|
+
children: [
|
|
2270
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectTrigger, { className: "w-[100px]", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectValue, { placeholder: "Select" }) }),
|
|
2271
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(SelectContent, { children: [
|
|
2272
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectItem, { value: "5", children: "5" }),
|
|
2273
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectItem, { value: "10", children: "10" }),
|
|
2274
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectItem, { value: "20", children: "20" }),
|
|
2275
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SelectItem, { value: "50", children: "50" })
|
|
2276
|
+
] })
|
|
2277
|
+
]
|
|
2278
|
+
}
|
|
2279
|
+
)
|
|
2280
|
+
] }),
|
|
2281
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Pagination, { className: "flex-end", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(PaginationContent, { children: [
|
|
2282
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PaginationItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2283
|
+
PaginationPrevious,
|
|
2284
|
+
{
|
|
2285
|
+
onClick: () => handlePageChange(currentPage - 1),
|
|
2286
|
+
className: currentPage === 1 ? "pointer-events-none opacity-50" : "cursor-pointer"
|
|
2287
|
+
}
|
|
2288
|
+
) }),
|
|
2289
|
+
pageNumbers.map((pageNumber, index) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PaginationItem, { children: pageNumber === "..." ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PaginationEllipsis, {}) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2290
|
+
PaginationLink,
|
|
2291
|
+
{
|
|
2292
|
+
onClick: () => handlePageChange(pageNumber),
|
|
2293
|
+
isActive: currentPage === pageNumber,
|
|
2294
|
+
className: "cursor-pointer",
|
|
2295
|
+
children: pageNumber
|
|
2296
|
+
}
|
|
2297
|
+
) }, index)),
|
|
2298
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PaginationItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2299
|
+
PaginationNext,
|
|
2300
|
+
{
|
|
2301
|
+
onClick: () => handlePageChange(currentPage + 1),
|
|
2302
|
+
className: currentPage === totalPages ? "pointer-events-none opacity-50" : "cursor-pointer"
|
|
2303
|
+
}
|
|
2304
|
+
) })
|
|
2305
|
+
] }) })
|
|
2306
|
+
] });
|
|
2280
2307
|
};
|
|
2281
2308
|
var Pagination_default = CustomPagination;
|
|
2282
2309
|
|
|
@@ -2297,6 +2324,7 @@ var Table2 = ({
|
|
|
2297
2324
|
totalRecords = 0,
|
|
2298
2325
|
...props
|
|
2299
2326
|
}) => {
|
|
2327
|
+
const [perPage, setPerPage] = (0, import_react6.useState)(itemsPerPage);
|
|
2300
2328
|
const rawColumns = Array.isArray(columns) ? columns : [];
|
|
2301
2329
|
const rawData = Array.isArray(data) ? data : [];
|
|
2302
2330
|
const rawRowActions = Array.isArray(rowActions) ? rowActions : [];
|
|
@@ -2307,19 +2335,19 @@ var Table2 = ({
|
|
|
2307
2335
|
if (isControlled) return;
|
|
2308
2336
|
if (currentPage > 1 && !pagination) setInternalPage(1);
|
|
2309
2337
|
}, [pagination, isControlled]);
|
|
2310
|
-
const enablePagination = pagination && (paginationMode === "server" ? totalRecords >
|
|
2311
|
-
const handlePageChange = (
|
|
2312
|
-
if (!isControlled) setInternalPage(
|
|
2313
|
-
onPageChange?.(
|
|
2338
|
+
const enablePagination = pagination && (paginationMode === "server" ? totalRecords > perPage : rawData.length > perPage);
|
|
2339
|
+
const handlePageChange = ({ page: page2, itemsPerPage: itemsPerPage2 }) => {
|
|
2340
|
+
if (!isControlled) setInternalPage(page2);
|
|
2341
|
+
onPageChange?.({ page: page2, itemsPerPage: itemsPerPage2 });
|
|
2314
2342
|
};
|
|
2315
2343
|
const paginatedData = !enablePagination ? rawData : paginationMode === "server" ? rawData : rawData.slice(
|
|
2316
|
-
(currentPage - 1) *
|
|
2317
|
-
currentPage *
|
|
2344
|
+
(currentPage - 1) * perPage,
|
|
2345
|
+
currentPage * perPage
|
|
2318
2346
|
);
|
|
2319
2347
|
const totalPages = enablePagination ? Math.max(
|
|
2320
2348
|
1,
|
|
2321
2349
|
Math.ceil(
|
|
2322
|
-
(paginationMode === "server" ? totalRecords : rawData.length) /
|
|
2350
|
+
(paginationMode === "server" ? totalRecords : rawData.length) / perPage
|
|
2323
2351
|
)
|
|
2324
2352
|
) : 1;
|
|
2325
2353
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: `${className || ""} space-y-3`, style, children: [
|
|
@@ -2336,6 +2364,7 @@ var Table2 = ({
|
|
|
2336
2364
|
enablePagination && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2337
2365
|
Pagination_default,
|
|
2338
2366
|
{
|
|
2367
|
+
perPage,
|
|
2339
2368
|
totalPages,
|
|
2340
2369
|
currentPage,
|
|
2341
2370
|
onPageChange: handlePageChange
|