@algorithm-shift/design-system 1.2.47 → 1.2.48

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.mjs CHANGED
@@ -2130,7 +2130,8 @@ var CustomPagination = ({
2130
2130
  totalPages,
2131
2131
  currentPage,
2132
2132
  onPageChange,
2133
- maxVisiblePages = 5
2133
+ maxVisiblePages = 5,
2134
+ perPage
2134
2135
  }) => {
2135
2136
  const getPageNumbers = () => {
2136
2137
  const pages = [];
@@ -2163,35 +2164,61 @@ var CustomPagination = ({
2163
2164
  };
2164
2165
  const handlePageChange = (page) => {
2165
2166
  if (page >= 1 && page <= totalPages && page !== currentPage) {
2166
- onPageChange(page);
2167
+ onPageChange({
2168
+ page,
2169
+ itemsPerPage: perPage
2170
+ });
2167
2171
  }
2168
2172
  };
2169
2173
  const pageNumbers = getPageNumbers();
2170
- return /* @__PURE__ */ jsx43(Pagination, { children: /* @__PURE__ */ jsxs26(PaginationContent, { children: [
2171
- /* @__PURE__ */ jsx43(PaginationItem, { children: /* @__PURE__ */ jsx43(
2172
- PaginationPrevious,
2173
- {
2174
- onClick: () => handlePageChange(currentPage - 1),
2175
- className: currentPage === 1 ? "pointer-events-none opacity-50" : "cursor-pointer"
2176
- }
2177
- ) }),
2178
- pageNumbers.map((pageNumber, index) => /* @__PURE__ */ jsx43(PaginationItem, { children: pageNumber === "..." ? /* @__PURE__ */ jsx43(PaginationEllipsis, {}) : /* @__PURE__ */ jsx43(
2179
- PaginationLink,
2180
- {
2181
- onClick: () => handlePageChange(pageNumber),
2182
- isActive: currentPage === pageNumber,
2183
- className: "cursor-pointer",
2184
- children: pageNumber
2185
- }
2186
- ) }, index)),
2187
- /* @__PURE__ */ jsx43(PaginationItem, { children: /* @__PURE__ */ jsx43(
2188
- PaginationNext,
2189
- {
2190
- onClick: () => handlePageChange(currentPage + 1),
2191
- className: currentPage === totalPages ? "pointer-events-none opacity-50" : "cursor-pointer"
2192
- }
2193
- ) })
2194
- ] }) });
2174
+ return /* @__PURE__ */ jsxs26("div", { className: "flex flex-col gap-4 items-center", children: [
2175
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-2", children: [
2176
+ /* @__PURE__ */ jsx43("span", { className: "text-sm text-muted-foreground", children: "Items per page:" }),
2177
+ /* @__PURE__ */ jsxs26(
2178
+ Select,
2179
+ {
2180
+ value: String(perPage),
2181
+ onValueChange: (value) => {
2182
+ onPageChange({ page: 1, itemsPerPage: Number(value) });
2183
+ },
2184
+ children: [
2185
+ /* @__PURE__ */ jsx43(SelectTrigger, { className: "w-[100px]", children: /* @__PURE__ */ jsx43(SelectValue, { placeholder: "Select" }) }),
2186
+ /* @__PURE__ */ jsxs26(SelectContent, { children: [
2187
+ /* @__PURE__ */ jsx43(SelectItem, { value: "5", children: "5" }),
2188
+ /* @__PURE__ */ jsx43(SelectItem, { value: "10", children: "10" }),
2189
+ /* @__PURE__ */ jsx43(SelectItem, { value: "20", children: "20" }),
2190
+ /* @__PURE__ */ jsx43(SelectItem, { value: "50", children: "50" })
2191
+ ] })
2192
+ ]
2193
+ }
2194
+ )
2195
+ ] }),
2196
+ /* @__PURE__ */ jsx43(Pagination, { children: /* @__PURE__ */ jsxs26(PaginationContent, { children: [
2197
+ /* @__PURE__ */ jsx43(PaginationItem, { children: /* @__PURE__ */ jsx43(
2198
+ PaginationPrevious,
2199
+ {
2200
+ onClick: () => handlePageChange(currentPage - 1),
2201
+ className: currentPage === 1 ? "pointer-events-none opacity-50" : "cursor-pointer"
2202
+ }
2203
+ ) }),
2204
+ pageNumbers.map((pageNumber, index) => /* @__PURE__ */ jsx43(PaginationItem, { children: pageNumber === "..." ? /* @__PURE__ */ jsx43(PaginationEllipsis, {}) : /* @__PURE__ */ jsx43(
2205
+ PaginationLink,
2206
+ {
2207
+ onClick: () => handlePageChange(pageNumber),
2208
+ isActive: currentPage === pageNumber,
2209
+ className: "cursor-pointer",
2210
+ children: pageNumber
2211
+ }
2212
+ ) }, index)),
2213
+ /* @__PURE__ */ jsx43(PaginationItem, { children: /* @__PURE__ */ jsx43(
2214
+ PaginationNext,
2215
+ {
2216
+ onClick: () => handlePageChange(currentPage + 1),
2217
+ className: currentPage === totalPages ? "pointer-events-none opacity-50" : "cursor-pointer"
2218
+ }
2219
+ ) })
2220
+ ] }) })
2221
+ ] });
2195
2222
  };
2196
2223
  var Pagination_default = CustomPagination;
2197
2224
 
@@ -2212,6 +2239,7 @@ var Table2 = ({
2212
2239
  totalRecords = 0,
2213
2240
  ...props
2214
2241
  }) => {
2242
+ const [perPage, setPerPage] = useState3(itemsPerPage);
2215
2243
  const rawColumns = Array.isArray(columns) ? columns : [];
2216
2244
  const rawData = Array.isArray(data) ? data : [];
2217
2245
  const rawRowActions = Array.isArray(rowActions) ? rowActions : [];
@@ -2222,19 +2250,19 @@ var Table2 = ({
2222
2250
  if (isControlled) return;
2223
2251
  if (currentPage > 1 && !pagination) setInternalPage(1);
2224
2252
  }, [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);
2253
+ const enablePagination = pagination && (paginationMode === "server" ? totalRecords > perPage : rawData.length > perPage);
2254
+ const handlePageChange = ({ page: page2, itemsPerPage: itemsPerPage2 }) => {
2255
+ if (!isControlled) setInternalPage(page2);
2256
+ onPageChange?.({ page: page2, itemsPerPage: itemsPerPage2 });
2229
2257
  };
2230
2258
  const paginatedData = !enablePagination ? rawData : paginationMode === "server" ? rawData : rawData.slice(
2231
- (currentPage - 1) * itemsPerPage,
2232
- currentPage * itemsPerPage
2259
+ (currentPage - 1) * perPage,
2260
+ currentPage * perPage
2233
2261
  );
2234
2262
  const totalPages = enablePagination ? Math.max(
2235
2263
  1,
2236
2264
  Math.ceil(
2237
- (paginationMode === "server" ? totalRecords : rawData.length) / itemsPerPage
2265
+ (paginationMode === "server" ? totalRecords : rawData.length) / perPage
2238
2266
  )
2239
2267
  ) : 1;
2240
2268
  return /* @__PURE__ */ jsxs27("div", { className: `${className || ""} space-y-3`, style, children: [
@@ -2251,6 +2279,7 @@ var Table2 = ({
2251
2279
  enablePagination && /* @__PURE__ */ jsx44(
2252
2280
  Pagination_default,
2253
2281
  {
2282
+ perPage,
2254
2283
  totalPages,
2255
2284
  currentPage,
2256
2285
  onPageChange: handlePageChange