@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.mjs
CHANGED
|
@@ -1855,6 +1855,9 @@ var TextInputGroup = ({ className, style, prepend, append, ...props }) => {
|
|
|
1855
1855
|
};
|
|
1856
1856
|
var TextInputGroup_default = TextInputGroup;
|
|
1857
1857
|
|
|
1858
|
+
// src/components/DataDisplay/Table/Table.tsx
|
|
1859
|
+
import { useState as useState3, useEffect as useEffect2 } from "react";
|
|
1860
|
+
|
|
1858
1861
|
// src/components/ui/data-table.tsx
|
|
1859
1862
|
import {
|
|
1860
1863
|
flexRender,
|
|
@@ -2193,7 +2196,6 @@ var CustomPagination = ({
|
|
|
2193
2196
|
var Pagination_default = CustomPagination;
|
|
2194
2197
|
|
|
2195
2198
|
// src/components/DataDisplay/Table/Table.tsx
|
|
2196
|
-
import { useState as useState3 } from "react";
|
|
2197
2199
|
import { jsx as jsx44, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
2198
2200
|
var Table2 = ({
|
|
2199
2201
|
columns,
|
|
@@ -2202,22 +2204,40 @@ var Table2 = ({
|
|
|
2202
2204
|
className,
|
|
2203
2205
|
style,
|
|
2204
2206
|
pagination = false,
|
|
2207
|
+
paginationMode = "client",
|
|
2205
2208
|
itemsPerPage = 10,
|
|
2206
2209
|
onPageChange,
|
|
2210
|
+
page,
|
|
2207
2211
|
loading = false,
|
|
2212
|
+
totalRecords = 0,
|
|
2208
2213
|
...props
|
|
2209
2214
|
}) => {
|
|
2210
2215
|
const rawColumns = Array.isArray(columns) ? columns : [];
|
|
2211
2216
|
const rawData = Array.isArray(data) ? data : [];
|
|
2212
2217
|
const rawRowActions = Array.isArray(rowActions) ? rowActions : [];
|
|
2213
|
-
const
|
|
2214
|
-
const
|
|
2215
|
-
const
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
+
const isControlled = typeof page === "number";
|
|
2219
|
+
const [internalPage, setInternalPage] = useState3(1);
|
|
2220
|
+
const currentPage = isControlled ? page : internalPage;
|
|
2221
|
+
useEffect2(() => {
|
|
2222
|
+
if (isControlled) return;
|
|
2223
|
+
if (currentPage > 1 && !pagination) setInternalPage(1);
|
|
2224
|
+
}, [pagination, isControlled]);
|
|
2225
|
+
const enablePagination = pagination && (paginationMode === "server" ? totalRecords > itemsPerPage : rawData.length > itemsPerPage);
|
|
2226
|
+
const handlePageChange = (next) => {
|
|
2227
|
+
if (!isControlled) setInternalPage(next);
|
|
2228
|
+
onPageChange?.(next);
|
|
2218
2229
|
};
|
|
2219
|
-
const paginatedData = enablePagination ? rawData
|
|
2220
|
-
|
|
2230
|
+
const paginatedData = !enablePagination ? rawData : paginationMode === "server" ? rawData : rawData.slice(
|
|
2231
|
+
(currentPage - 1) * itemsPerPage,
|
|
2232
|
+
currentPage * itemsPerPage
|
|
2233
|
+
);
|
|
2234
|
+
const totalPages = enablePagination ? Math.max(
|
|
2235
|
+
1,
|
|
2236
|
+
Math.ceil(
|
|
2237
|
+
(paginationMode === "server" ? totalRecords : rawData.length) / itemsPerPage
|
|
2238
|
+
)
|
|
2239
|
+
) : 1;
|
|
2240
|
+
return /* @__PURE__ */ jsxs27("div", { className: `${className || ""} space-y-3`, style, children: [
|
|
2221
2241
|
/* @__PURE__ */ jsx44(
|
|
2222
2242
|
DataTable,
|
|
2223
2243
|
{
|
|
@@ -2231,7 +2251,7 @@ var Table2 = ({
|
|
|
2231
2251
|
enablePagination && /* @__PURE__ */ jsx44(
|
|
2232
2252
|
Pagination_default,
|
|
2233
2253
|
{
|
|
2234
|
-
totalPages
|
|
2254
|
+
totalPages,
|
|
2235
2255
|
currentPage,
|
|
2236
2256
|
onPageChange: handlePageChange
|
|
2237
2257
|
}
|