@algorithm-shift/design-system 1.2.45 → 1.2.47
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.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +29 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -102,6 +102,7 @@ interface TableProps extends ElementProps {
|
|
|
102
102
|
cellClickEnabled?: (cellData: Record<string, any>, columnId: string) => boolean;
|
|
103
103
|
onCellClick?: (cellData: Record<string, any>, columnId: string) => void;
|
|
104
104
|
getRowSelection?: (rowSelection: Record<string, boolean>) => void;
|
|
105
|
+
totalRecords?: number;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
interface TabsProps extends ElementProps {
|
|
@@ -246,7 +247,14 @@ declare const DateRange: ({ className, style, ...props }: DateRangeInputProps) =
|
|
|
246
247
|
|
|
247
248
|
declare const TextInputGroup: ({ className, style, prepend, append, ...props }: TextInputGroupProps) => react_jsx_runtime.JSX.Element;
|
|
248
249
|
|
|
249
|
-
|
|
250
|
+
type PaginationMode = 'client' | 'server';
|
|
251
|
+
interface ExtendedTableProps extends TableProps {
|
|
252
|
+
paginationMode?: PaginationMode;
|
|
253
|
+
page?: number;
|
|
254
|
+
itemsPerPage?: number;
|
|
255
|
+
onPageChange?: (page: number) => void;
|
|
256
|
+
}
|
|
257
|
+
declare const Table: ({ columns, data, rowActions, className, style, pagination, paginationMode, itemsPerPage, onPageChange, page, loading, totalRecords, ...props }: ExtendedTableProps) => react_jsx_runtime.JSX.Element;
|
|
250
258
|
|
|
251
259
|
interface CustomPaginationProps {
|
|
252
260
|
totalPages: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ interface TableProps extends ElementProps {
|
|
|
102
102
|
cellClickEnabled?: (cellData: Record<string, any>, columnId: string) => boolean;
|
|
103
103
|
onCellClick?: (cellData: Record<string, any>, columnId: string) => void;
|
|
104
104
|
getRowSelection?: (rowSelection: Record<string, boolean>) => void;
|
|
105
|
+
totalRecords?: number;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
interface TabsProps extends ElementProps {
|
|
@@ -246,7 +247,14 @@ declare const DateRange: ({ className, style, ...props }: DateRangeInputProps) =
|
|
|
246
247
|
|
|
247
248
|
declare const TextInputGroup: ({ className, style, prepend, append, ...props }: TextInputGroupProps) => react_jsx_runtime.JSX.Element;
|
|
248
249
|
|
|
249
|
-
|
|
250
|
+
type PaginationMode = 'client' | 'server';
|
|
251
|
+
interface ExtendedTableProps extends TableProps {
|
|
252
|
+
paginationMode?: PaginationMode;
|
|
253
|
+
page?: number;
|
|
254
|
+
itemsPerPage?: number;
|
|
255
|
+
onPageChange?: (page: number) => void;
|
|
256
|
+
}
|
|
257
|
+
declare const Table: ({ columns, data, rowActions, className, style, pagination, paginationMode, itemsPerPage, onPageChange, page, loading, totalRecords, ...props }: ExtendedTableProps) => react_jsx_runtime.JSX.Element;
|
|
250
258
|
|
|
251
259
|
interface CustomPaginationProps {
|
|
252
260
|
totalPages: number;
|
package/dist/index.js
CHANGED
|
@@ -1944,6 +1944,9 @@ var TextInputGroup = ({ className, style, prepend, append, ...props }) => {
|
|
|
1944
1944
|
};
|
|
1945
1945
|
var TextInputGroup_default = TextInputGroup;
|
|
1946
1946
|
|
|
1947
|
+
// src/components/DataDisplay/Table/Table.tsx
|
|
1948
|
+
var import_react6 = require("react");
|
|
1949
|
+
|
|
1947
1950
|
// src/components/ui/data-table.tsx
|
|
1948
1951
|
var import_react_table = require("@tanstack/react-table");
|
|
1949
1952
|
|
|
@@ -2278,7 +2281,6 @@ var CustomPagination = ({
|
|
|
2278
2281
|
var Pagination_default = CustomPagination;
|
|
2279
2282
|
|
|
2280
2283
|
// src/components/DataDisplay/Table/Table.tsx
|
|
2281
|
-
var import_react6 = require("react");
|
|
2282
2284
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
2283
2285
|
var Table2 = ({
|
|
2284
2286
|
columns,
|
|
@@ -2287,22 +2289,40 @@ var Table2 = ({
|
|
|
2287
2289
|
className,
|
|
2288
2290
|
style,
|
|
2289
2291
|
pagination = false,
|
|
2292
|
+
paginationMode = "client",
|
|
2290
2293
|
itemsPerPage = 10,
|
|
2291
2294
|
onPageChange,
|
|
2295
|
+
page,
|
|
2292
2296
|
loading = false,
|
|
2297
|
+
totalRecords = 0,
|
|
2293
2298
|
...props
|
|
2294
2299
|
}) => {
|
|
2295
2300
|
const rawColumns = Array.isArray(columns) ? columns : [];
|
|
2296
2301
|
const rawData = Array.isArray(data) ? data : [];
|
|
2297
2302
|
const rawRowActions = Array.isArray(rowActions) ? rowActions : [];
|
|
2298
|
-
const
|
|
2299
|
-
const
|
|
2300
|
-
const
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
+
const isControlled = typeof page === "number";
|
|
2304
|
+
const [internalPage, setInternalPage] = (0, import_react6.useState)(1);
|
|
2305
|
+
const currentPage = isControlled ? page : internalPage;
|
|
2306
|
+
(0, import_react6.useEffect)(() => {
|
|
2307
|
+
if (isControlled) return;
|
|
2308
|
+
if (currentPage > 1 && !pagination) setInternalPage(1);
|
|
2309
|
+
}, [pagination, isControlled]);
|
|
2310
|
+
const enablePagination = pagination && (paginationMode === "server" ? totalRecords > itemsPerPage : rawData.length > itemsPerPage);
|
|
2311
|
+
const handlePageChange = (next) => {
|
|
2312
|
+
if (!isControlled) setInternalPage(next);
|
|
2313
|
+
onPageChange?.(next);
|
|
2303
2314
|
};
|
|
2304
|
-
const paginatedData = enablePagination ? rawData
|
|
2305
|
-
|
|
2315
|
+
const paginatedData = !enablePagination ? rawData : paginationMode === "server" ? rawData : rawData.slice(
|
|
2316
|
+
(currentPage - 1) * itemsPerPage,
|
|
2317
|
+
currentPage * itemsPerPage
|
|
2318
|
+
);
|
|
2319
|
+
const totalPages = enablePagination ? Math.max(
|
|
2320
|
+
1,
|
|
2321
|
+
Math.ceil(
|
|
2322
|
+
(paginationMode === "server" ? totalRecords : rawData.length) / itemsPerPage
|
|
2323
|
+
)
|
|
2324
|
+
) : 1;
|
|
2325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: `${className || ""} space-y-3`, style, children: [
|
|
2306
2326
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2307
2327
|
DataTable,
|
|
2308
2328
|
{
|
|
@@ -2316,7 +2336,7 @@ var Table2 = ({
|
|
|
2316
2336
|
enablePagination && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2317
2337
|
Pagination_default,
|
|
2318
2338
|
{
|
|
2319
|
-
totalPages
|
|
2339
|
+
totalPages,
|
|
2320
2340
|
currentPage,
|
|
2321
2341
|
onPageChange: handlePageChange
|
|
2322
2342
|
}
|