@algorithm-shift/design-system 1.2.46 → 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 +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -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,8 +2204,10 @@ 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,
|
|
2208
2212
|
totalRecords = 0,
|
|
2209
2213
|
...props
|
|
@@ -2211,14 +2215,29 @@ var Table2 = ({
|
|
|
2211
2215
|
const rawColumns = Array.isArray(columns) ? columns : [];
|
|
2212
2216
|
const rawData = Array.isArray(data) ? data : [];
|
|
2213
2217
|
const rawRowActions = Array.isArray(rowActions) ? rowActions : [];
|
|
2214
|
-
const
|
|
2215
|
-
const
|
|
2216
|
-
const
|
|
2217
|
-
|
|
2218
|
-
|
|
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);
|
|
2219
2229
|
};
|
|
2220
|
-
const paginatedData = enablePagination ? rawData
|
|
2221
|
-
|
|
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: [
|
|
2222
2241
|
/* @__PURE__ */ jsx44(
|
|
2223
2242
|
DataTable,
|
|
2224
2243
|
{
|
|
@@ -2232,7 +2251,7 @@ var Table2 = ({
|
|
|
2232
2251
|
enablePagination && /* @__PURE__ */ jsx44(
|
|
2233
2252
|
Pagination_default,
|
|
2234
2253
|
{
|
|
2235
|
-
totalPages
|
|
2254
|
+
totalPages,
|
|
2236
2255
|
currentPage,
|
|
2237
2256
|
onPageChange: handlePageChange
|
|
2238
2257
|
}
|