shadcn-ui-react 0.5.2 → 0.5.3

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.cjs CHANGED
@@ -8391,7 +8391,7 @@ function Breadcrumbs({ items, className, classNameList }) {
8391
8391
  }
8392
8392
 
8393
8393
  // src/shared/data-table.tsx
8394
- var import_react36 = __toESM(require("react"), 1);
8394
+ var import_react36 = require("react");
8395
8395
  var import_framer_motion2 = require("framer-motion");
8396
8396
  var import_react_icons18 = require("@radix-ui/react-icons");
8397
8397
  var import_react_table = require("@tanstack/react-table");
@@ -8425,46 +8425,40 @@ function DataTable({
8425
8425
  heightClassName = "h-[clamp(22rem,80vh,44rem)] supports-[height:100dvh]:h-[clamp(22rem,80dvh,44rem)]"
8426
8426
  }) {
8427
8427
  const safePageCount = Math.max(pageCount != null ? pageCount : 1, 1);
8428
- const [pagination, setPagination] = import_react36.default.useState({
8429
- pageIndex: Math.max(page - 1, 0),
8430
- pageSize: perPage
8431
- });
8432
- (0, import_react36.useEffect)(() => {
8433
- setPagination((prev) => {
8434
- const nextIndex = Math.max(page - 1, 0);
8435
- const nextSize = perPage;
8436
- if (prev.pageIndex === nextIndex && prev.pageSize === nextSize) return prev;
8437
- return { pageIndex: nextIndex, pageSize: nextSize };
8438
- });
8439
- }, [page, perPage]);
8440
- (0, import_react36.useEffect)(() => {
8441
- setPagination((prev) => {
8442
- const maxIndex = Math.max(safePageCount - 1, 0);
8443
- const clamped = Math.min(prev.pageIndex, maxIndex);
8444
- if (clamped === prev.pageIndex) return prev;
8445
- return __spreadProps(__spreadValues({}, prev), { pageIndex: clamped });
8446
- });
8447
- }, [safePageCount]);
8428
+ const pageIndex = Math.min(Math.max(page - 1, 0), safePageCount - 1);
8429
+ const pageSize = Math.max(perPage, 1);
8430
+ const paginationState = (0, import_react36.useMemo)(
8431
+ () => ({ pageIndex, pageSize }),
8432
+ [pageIndex, pageSize]
8433
+ );
8448
8434
  const table = (0, import_react_table.useReactTable)({
8449
8435
  data,
8450
8436
  columns,
8451
8437
  pageCount: safePageCount,
8438
+ state: { pagination: paginationState },
8452
8439
  getCoreRowModel: (0, import_react_table.getCoreRowModel)(),
8453
8440
  getFilteredRowModel: (0, import_react_table.getFilteredRowModel)(),
8454
- state: { pagination },
8455
- onPaginationChange: setPagination,
8456
- getPaginationRowModel: (0, import_react_table.getPaginationRowModel)(),
8457
8441
  manualPagination: true,
8458
- manualFiltering: true
8442
+ manualFiltering: true,
8443
+ autoResetAll: false,
8444
+ autoResetPageIndex: false
8459
8445
  });
8460
8446
  const clickable = !!onClick;
8461
- (0, import_react36.useEffect)(() => {
8462
- onPageChange == null ? void 0 : onPageChange(pagination.pageIndex + 1);
8463
- }, [pagination.pageIndex, onPageChange]);
8464
8447
  const pageKey = (0, import_react36.useMemo)(
8465
- () => `${pagination.pageIndex}-${pagination.pageSize}-${data.length}`,
8466
- [pagination.pageIndex, pagination.pageSize, data.length]
8448
+ () => `${pageIndex}-${pageSize}-${data.length}`,
8449
+ [pageIndex, pageSize, data.length]
8467
8450
  );
8451
+ const goToPage = (nextPageIndex) => {
8452
+ const clamped = Math.min(Math.max(nextPageIndex, 0), safePageCount - 1);
8453
+ if (clamped === pageIndex) return;
8454
+ onPageChange == null ? void 0 : onPageChange(clamped + 1);
8455
+ };
8456
+ const changePageSize = (newSize) => {
8457
+ const size = Math.max(Number(newSize) || 1, 1);
8458
+ if (size === pageSize) return;
8459
+ onPageSizeChange == null ? void 0 : onPageSizeChange(size);
8460
+ onPageChange == null ? void 0 : onPageChange(1);
8461
+ };
8468
8462
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
8469
8463
  "div",
8470
8464
  {
@@ -8486,10 +8480,27 @@ function DataTable({
8486
8480
  TableHeader,
8487
8481
  {
8488
8482
  className: cn(
8489
- headerClassName,
8490
- stickyHeader ? "sticky top-0 z-10 bg-background/80 backdrop-blur border-b" : ""
8483
+ stickyHeader ? "sticky top-0 z-10 bg-background/80 backdrop-blur border-b" : "",
8484
+ headerClassName
8491
8485
  ),
8492
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { className: cn("hover:bg-transparent", rowClassName), children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableHead, { className: cn("whitespace-nowrap", headerClassName), children: header.isPlaceholder ? null : (0, import_react_table.flexRender)(header.column.columnDef.header, header.getContext()) }, header.id)) }, headerGroup.id))
8486
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8487
+ TableRow,
8488
+ {
8489
+ className: cn("hover:bg-transparent", rowClassName),
8490
+ children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8491
+ TableHead,
8492
+ {
8493
+ className: cn("whitespace-nowrap", headerClassName),
8494
+ children: header.isPlaceholder ? null : (0, import_react_table.flexRender)(
8495
+ header.column.columnDef.header,
8496
+ header.getContext()
8497
+ )
8498
+ },
8499
+ header.id
8500
+ ))
8501
+ },
8502
+ headerGroup.id
8503
+ ))
8493
8504
  }
8494
8505
  ),
8495
8506
  animate ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_framer_motion2.AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
@@ -8509,10 +8520,20 @@ function DataTable({
8509
8520
  rowClassName,
8510
8521
  clickable ? "cursor-pointer hover:bg-muted/60 active:bg-muted/80" : ""
8511
8522
  ),
8512
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { className: cellClassName, children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
8523
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { className: cellClassName, children: (0, import_react_table.flexRender)(
8524
+ cell.column.columnDef.cell,
8525
+ cell.getContext()
8526
+ ) }, cell.id))
8513
8527
  },
8514
8528
  row.id
8515
- )) : emptyData || /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { colSpan: columns.length, className: "h-28 text-center text-muted-foreground", children: "No results." }) })
8529
+ )) : emptyData || /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8530
+ TableCell,
8531
+ {
8532
+ colSpan: columns.length,
8533
+ className: "h-28 text-center text-muted-foreground",
8534
+ children: "No results."
8535
+ }
8536
+ ) })
8516
8537
  },
8517
8538
  pageKey
8518
8539
  ) }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableBody, { className: bodyClassName, children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
@@ -8524,10 +8545,20 @@ function DataTable({
8524
8545
  rowClassName,
8525
8546
  clickable ? "cursor-pointer hover:bg-muted/60 active:bg-muted/80" : ""
8526
8547
  ),
8527
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { className: cn(cellClassName), children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
8548
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { className: cn(cellClassName), children: (0, import_react_table.flexRender)(
8549
+ cell.column.columnDef.cell,
8550
+ cell.getContext()
8551
+ ) }, cell.id))
8528
8552
  },
8529
8553
  row.id
8530
- )) : emptyData || /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { colSpan: columns.length, className: "h-28 text-center text-muted-foreground", children: "No results." }) }) })
8554
+ )) : emptyData || /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8555
+ TableCell,
8556
+ {
8557
+ colSpan: columns.length,
8558
+ className: "h-28 text-center text-muted-foreground",
8559
+ children: "No results."
8560
+ }
8561
+ ) }) })
8531
8562
  ]
8532
8563
  }
8533
8564
  ),
@@ -8556,15 +8587,10 @@ function DataTable({
8556
8587
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
8557
8588
  Select2,
8558
8589
  {
8559
- value: `${pagination.pageSize}`,
8560
- onValueChange: (value) => {
8561
- const newSize = Number(value);
8562
- setPagination((p) => __spreadProps(__spreadValues({}, p), { pageSize: newSize, pageIndex: 0 }));
8563
- onPageSizeChange == null ? void 0 : onPageSizeChange(newSize);
8564
- onPageChange == null ? void 0 : onPageChange(1);
8565
- },
8590
+ value: `${pageSize}`,
8591
+ onValueChange: (value) => changePageSize(Number(value)),
8566
8592
  children: [
8567
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectTrigger, { className: "h-8 w-21", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectValue, { placeholder: pagination.pageSize }) }),
8593
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectTrigger, { className: "h-8 w-21", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectValue, { placeholder: pageSize }) }),
8568
8594
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectContent, { side: "top", children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectItem, { value: `${size}`, children: size }, size)) })
8569
8595
  ]
8570
8596
  }
@@ -8574,7 +8600,7 @@ function DataTable({
8574
8600
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "hidden sm:flex min-w-35 items-center justify-center text-sm font-medium", children: [
8575
8601
  pageLabel,
8576
8602
  " ",
8577
- pagination.pageIndex + 1,
8603
+ pageIndex + 1,
8578
8604
  " ",
8579
8605
  ofLabel,
8580
8606
  " ",
@@ -8586,8 +8612,8 @@ function DataTable({
8586
8612
  "aria-label": "Go to first page",
8587
8613
  variant: "outline",
8588
8614
  className: "hidden h-8 w-8 p-0 lg:flex",
8589
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: 0 })),
8590
- disabled: pagination.pageIndex === 0,
8615
+ onClick: () => goToPage(0),
8616
+ disabled: pageIndex === 0,
8591
8617
  children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_icons18.DoubleArrowLeftIcon, { className: "h-4 w-4" })
8592
8618
  }
8593
8619
  ),
@@ -8597,8 +8623,8 @@ function DataTable({
8597
8623
  "aria-label": "Go to previous page",
8598
8624
  variant: "outline",
8599
8625
  className: "h-8 w-8 p-0",
8600
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: Math.max(p.pageIndex - 1, 0) })),
8601
- disabled: pagination.pageIndex === 0,
8626
+ onClick: () => goToPage(pageIndex - 1),
8627
+ disabled: pageIndex === 0,
8602
8628
  children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react6.ChevronLeftIcon, { className: "h-4 w-4" })
8603
8629
  }
8604
8630
  ),
@@ -8608,10 +8634,8 @@ function DataTable({
8608
8634
  "aria-label": "Go to next page",
8609
8635
  variant: "outline",
8610
8636
  className: "h-8 w-8 p-0",
8611
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), {
8612
- pageIndex: Math.min(p.pageIndex + 1, safePageCount - 1)
8613
- })),
8614
- disabled: pagination.pageIndex + 1 >= safePageCount,
8637
+ onClick: () => goToPage(pageIndex + 1),
8638
+ disabled: pageIndex + 1 >= safePageCount,
8615
8639
  children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react6.ChevronRightIcon, { className: "h-4 w-4" })
8616
8640
  }
8617
8641
  ),
@@ -8621,8 +8645,8 @@ function DataTable({
8621
8645
  "aria-label": "Go to last page",
8622
8646
  variant: "outline",
8623
8647
  className: "hidden h-8 w-8 p-0 lg:flex",
8624
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: safePageCount - 1 })),
8625
- disabled: pagination.pageIndex + 1 >= safePageCount,
8648
+ onClick: () => goToPage(safePageCount - 1),
8649
+ disabled: pageIndex + 1 >= safePageCount,
8626
8650
  children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_icons18.DoubleArrowRightIcon, { className: "h-4 w-4" })
8627
8651
  }
8628
8652
  )
@@ -8630,7 +8654,7 @@ function DataTable({
8630
8654
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "sm:hidden w-full text-center text-xs text-muted-foreground", children: [
8631
8655
  pageLabel,
8632
8656
  " ",
8633
- pagination.pageIndex + 1,
8657
+ pageIndex + 1,
8634
8658
  " ",
8635
8659
  ofLabel,
8636
8660
  " ",
package/dist/index.js CHANGED
@@ -8182,14 +8182,13 @@ function Breadcrumbs({ items, className, classNameList }) {
8182
8182
  }
8183
8183
 
8184
8184
  // src/shared/data-table.tsx
8185
- import React67, { useEffect as useEffect4, useMemo as useMemo3 } from "react";
8185
+ import { useMemo as useMemo3 } from "react";
8186
8186
  import { AnimatePresence, motion as motion2 } from "framer-motion";
8187
8187
  import { DoubleArrowLeftIcon, DoubleArrowRightIcon } from "@radix-ui/react-icons";
8188
8188
  import {
8189
8189
  flexRender,
8190
8190
  getCoreRowModel,
8191
8191
  getFilteredRowModel,
8192
- getPaginationRowModel,
8193
8192
  useReactTable
8194
8193
  } from "@tanstack/react-table";
8195
8194
  import { ChevronLeftIcon as ChevronLeftIcon2, ChevronRightIcon as ChevronRightIcon6 } from "lucide-react";
@@ -8222,46 +8221,40 @@ function DataTable({
8222
8221
  heightClassName = "h-[clamp(22rem,80vh,44rem)] supports-[height:100dvh]:h-[clamp(22rem,80dvh,44rem)]"
8223
8222
  }) {
8224
8223
  const safePageCount = Math.max(pageCount != null ? pageCount : 1, 1);
8225
- const [pagination, setPagination] = React67.useState({
8226
- pageIndex: Math.max(page - 1, 0),
8227
- pageSize: perPage
8228
- });
8229
- useEffect4(() => {
8230
- setPagination((prev) => {
8231
- const nextIndex = Math.max(page - 1, 0);
8232
- const nextSize = perPage;
8233
- if (prev.pageIndex === nextIndex && prev.pageSize === nextSize) return prev;
8234
- return { pageIndex: nextIndex, pageSize: nextSize };
8235
- });
8236
- }, [page, perPage]);
8237
- useEffect4(() => {
8238
- setPagination((prev) => {
8239
- const maxIndex = Math.max(safePageCount - 1, 0);
8240
- const clamped = Math.min(prev.pageIndex, maxIndex);
8241
- if (clamped === prev.pageIndex) return prev;
8242
- return __spreadProps(__spreadValues({}, prev), { pageIndex: clamped });
8243
- });
8244
- }, [safePageCount]);
8224
+ const pageIndex = Math.min(Math.max(page - 1, 0), safePageCount - 1);
8225
+ const pageSize = Math.max(perPage, 1);
8226
+ const paginationState = useMemo3(
8227
+ () => ({ pageIndex, pageSize }),
8228
+ [pageIndex, pageSize]
8229
+ );
8245
8230
  const table = useReactTable({
8246
8231
  data,
8247
8232
  columns,
8248
8233
  pageCount: safePageCount,
8234
+ state: { pagination: paginationState },
8249
8235
  getCoreRowModel: getCoreRowModel(),
8250
8236
  getFilteredRowModel: getFilteredRowModel(),
8251
- state: { pagination },
8252
- onPaginationChange: setPagination,
8253
- getPaginationRowModel: getPaginationRowModel(),
8254
8237
  manualPagination: true,
8255
- manualFiltering: true
8238
+ manualFiltering: true,
8239
+ autoResetAll: false,
8240
+ autoResetPageIndex: false
8256
8241
  });
8257
8242
  const clickable = !!onClick;
8258
- useEffect4(() => {
8259
- onPageChange == null ? void 0 : onPageChange(pagination.pageIndex + 1);
8260
- }, [pagination.pageIndex, onPageChange]);
8261
8243
  const pageKey = useMemo3(
8262
- () => `${pagination.pageIndex}-${pagination.pageSize}-${data.length}`,
8263
- [pagination.pageIndex, pagination.pageSize, data.length]
8244
+ () => `${pageIndex}-${pageSize}-${data.length}`,
8245
+ [pageIndex, pageSize, data.length]
8264
8246
  );
8247
+ const goToPage = (nextPageIndex) => {
8248
+ const clamped = Math.min(Math.max(nextPageIndex, 0), safePageCount - 1);
8249
+ if (clamped === pageIndex) return;
8250
+ onPageChange == null ? void 0 : onPageChange(clamped + 1);
8251
+ };
8252
+ const changePageSize = (newSize) => {
8253
+ const size = Math.max(Number(newSize) || 1, 1);
8254
+ if (size === pageSize) return;
8255
+ onPageSizeChange == null ? void 0 : onPageSizeChange(size);
8256
+ onPageChange == null ? void 0 : onPageChange(1);
8257
+ };
8265
8258
  return /* @__PURE__ */ jsxs23(
8266
8259
  "div",
8267
8260
  {
@@ -8283,10 +8276,27 @@ function DataTable({
8283
8276
  TableHeader,
8284
8277
  {
8285
8278
  className: cn(
8286
- headerClassName,
8287
- stickyHeader ? "sticky top-0 z-10 bg-background/80 backdrop-blur border-b" : ""
8279
+ stickyHeader ? "sticky top-0 z-10 bg-background/80 backdrop-blur border-b" : "",
8280
+ headerClassName
8288
8281
  ),
8289
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx48(TableRow, { className: cn("hover:bg-transparent", rowClassName), children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx48(TableHead, { className: cn("whitespace-nowrap", headerClassName), children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }, headerGroup.id))
8282
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx48(
8283
+ TableRow,
8284
+ {
8285
+ className: cn("hover:bg-transparent", rowClassName),
8286
+ children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx48(
8287
+ TableHead,
8288
+ {
8289
+ className: cn("whitespace-nowrap", headerClassName),
8290
+ children: header.isPlaceholder ? null : flexRender(
8291
+ header.column.columnDef.header,
8292
+ header.getContext()
8293
+ )
8294
+ },
8295
+ header.id
8296
+ ))
8297
+ },
8298
+ headerGroup.id
8299
+ ))
8290
8300
  }
8291
8301
  ),
8292
8302
  animate ? /* @__PURE__ */ jsx48(AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ jsx48(
@@ -8306,10 +8316,20 @@ function DataTable({
8306
8316
  rowClassName,
8307
8317
  clickable ? "cursor-pointer hover:bg-muted/60 active:bg-muted/80" : ""
8308
8318
  ),
8309
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx48(TableCell, { className: cellClassName, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
8319
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx48(TableCell, { className: cellClassName, children: flexRender(
8320
+ cell.column.columnDef.cell,
8321
+ cell.getContext()
8322
+ ) }, cell.id))
8310
8323
  },
8311
8324
  row.id
8312
- )) : emptyData || /* @__PURE__ */ jsx48(TableRow, { children: /* @__PURE__ */ jsx48(TableCell, { colSpan: columns.length, className: "h-28 text-center text-muted-foreground", children: "No results." }) })
8325
+ )) : emptyData || /* @__PURE__ */ jsx48(TableRow, { children: /* @__PURE__ */ jsx48(
8326
+ TableCell,
8327
+ {
8328
+ colSpan: columns.length,
8329
+ className: "h-28 text-center text-muted-foreground",
8330
+ children: "No results."
8331
+ }
8332
+ ) })
8313
8333
  },
8314
8334
  pageKey
8315
8335
  ) }) : /* @__PURE__ */ jsx48(TableBody, { className: bodyClassName, children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx48(
@@ -8321,10 +8341,20 @@ function DataTable({
8321
8341
  rowClassName,
8322
8342
  clickable ? "cursor-pointer hover:bg-muted/60 active:bg-muted/80" : ""
8323
8343
  ),
8324
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx48(TableCell, { className: cn(cellClassName), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
8344
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx48(TableCell, { className: cn(cellClassName), children: flexRender(
8345
+ cell.column.columnDef.cell,
8346
+ cell.getContext()
8347
+ ) }, cell.id))
8325
8348
  },
8326
8349
  row.id
8327
- )) : emptyData || /* @__PURE__ */ jsx48(TableRow, { children: /* @__PURE__ */ jsx48(TableCell, { colSpan: columns.length, className: "h-28 text-center text-muted-foreground", children: "No results." }) }) })
8350
+ )) : emptyData || /* @__PURE__ */ jsx48(TableRow, { children: /* @__PURE__ */ jsx48(
8351
+ TableCell,
8352
+ {
8353
+ colSpan: columns.length,
8354
+ className: "h-28 text-center text-muted-foreground",
8355
+ children: "No results."
8356
+ }
8357
+ ) }) })
8328
8358
  ]
8329
8359
  }
8330
8360
  ),
@@ -8353,15 +8383,10 @@ function DataTable({
8353
8383
  /* @__PURE__ */ jsxs23(
8354
8384
  Select2,
8355
8385
  {
8356
- value: `${pagination.pageSize}`,
8357
- onValueChange: (value) => {
8358
- const newSize = Number(value);
8359
- setPagination((p) => __spreadProps(__spreadValues({}, p), { pageSize: newSize, pageIndex: 0 }));
8360
- onPageSizeChange == null ? void 0 : onPageSizeChange(newSize);
8361
- onPageChange == null ? void 0 : onPageChange(1);
8362
- },
8386
+ value: `${pageSize}`,
8387
+ onValueChange: (value) => changePageSize(Number(value)),
8363
8388
  children: [
8364
- /* @__PURE__ */ jsx48(SelectTrigger, { className: "h-8 w-21", children: /* @__PURE__ */ jsx48(SelectValue, { placeholder: pagination.pageSize }) }),
8389
+ /* @__PURE__ */ jsx48(SelectTrigger, { className: "h-8 w-21", children: /* @__PURE__ */ jsx48(SelectValue, { placeholder: pageSize }) }),
8365
8390
  /* @__PURE__ */ jsx48(SelectContent, { side: "top", children: pageSizeOptions.map((size) => /* @__PURE__ */ jsx48(SelectItem, { value: `${size}`, children: size }, size)) })
8366
8391
  ]
8367
8392
  }
@@ -8371,7 +8396,7 @@ function DataTable({
8371
8396
  /* @__PURE__ */ jsxs23("div", { className: "hidden sm:flex min-w-35 items-center justify-center text-sm font-medium", children: [
8372
8397
  pageLabel,
8373
8398
  " ",
8374
- pagination.pageIndex + 1,
8399
+ pageIndex + 1,
8375
8400
  " ",
8376
8401
  ofLabel,
8377
8402
  " ",
@@ -8383,8 +8408,8 @@ function DataTable({
8383
8408
  "aria-label": "Go to first page",
8384
8409
  variant: "outline",
8385
8410
  className: "hidden h-8 w-8 p-0 lg:flex",
8386
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: 0 })),
8387
- disabled: pagination.pageIndex === 0,
8411
+ onClick: () => goToPage(0),
8412
+ disabled: pageIndex === 0,
8388
8413
  children: /* @__PURE__ */ jsx48(DoubleArrowLeftIcon, { className: "h-4 w-4" })
8389
8414
  }
8390
8415
  ),
@@ -8394,8 +8419,8 @@ function DataTable({
8394
8419
  "aria-label": "Go to previous page",
8395
8420
  variant: "outline",
8396
8421
  className: "h-8 w-8 p-0",
8397
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: Math.max(p.pageIndex - 1, 0) })),
8398
- disabled: pagination.pageIndex === 0,
8422
+ onClick: () => goToPage(pageIndex - 1),
8423
+ disabled: pageIndex === 0,
8399
8424
  children: /* @__PURE__ */ jsx48(ChevronLeftIcon2, { className: "h-4 w-4" })
8400
8425
  }
8401
8426
  ),
@@ -8405,10 +8430,8 @@ function DataTable({
8405
8430
  "aria-label": "Go to next page",
8406
8431
  variant: "outline",
8407
8432
  className: "h-8 w-8 p-0",
8408
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), {
8409
- pageIndex: Math.min(p.pageIndex + 1, safePageCount - 1)
8410
- })),
8411
- disabled: pagination.pageIndex + 1 >= safePageCount,
8433
+ onClick: () => goToPage(pageIndex + 1),
8434
+ disabled: pageIndex + 1 >= safePageCount,
8412
8435
  children: /* @__PURE__ */ jsx48(ChevronRightIcon6, { className: "h-4 w-4" })
8413
8436
  }
8414
8437
  ),
@@ -8418,8 +8441,8 @@ function DataTable({
8418
8441
  "aria-label": "Go to last page",
8419
8442
  variant: "outline",
8420
8443
  className: "hidden h-8 w-8 p-0 lg:flex",
8421
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: safePageCount - 1 })),
8422
- disabled: pagination.pageIndex + 1 >= safePageCount,
8444
+ onClick: () => goToPage(safePageCount - 1),
8445
+ disabled: pageIndex + 1 >= safePageCount,
8423
8446
  children: /* @__PURE__ */ jsx48(DoubleArrowRightIcon, { className: "h-4 w-4" })
8424
8447
  }
8425
8448
  )
@@ -8427,7 +8450,7 @@ function DataTable({
8427
8450
  /* @__PURE__ */ jsxs23("div", { className: "sm:hidden w-full text-center text-xs text-muted-foreground", children: [
8428
8451
  pageLabel,
8429
8452
  " ",
8430
- pagination.pageIndex + 1,
8453
+ pageIndex + 1,
8431
8454
  " ",
8432
8455
  ofLabel,
8433
8456
  " ",
@@ -8483,7 +8506,7 @@ function DataTableSkeleton({
8483
8506
  // src/shared/fileupload.tsx
8484
8507
  import { AvatarIcon } from "@radix-ui/react-icons";
8485
8508
  import { CameraIcon } from "lucide-react";
8486
- import { useEffect as useEffect5, useState as useState5 } from "react";
8509
+ import { useEffect as useEffect4, useState as useState5 } from "react";
8487
8510
  import { useDropzone } from "react-dropzone";
8488
8511
  import { jsx as jsx50, jsxs as jsxs25 } from "react/jsx-runtime";
8489
8512
  function FileUpload({
@@ -8522,7 +8545,7 @@ function FileUpload({
8522
8545
  }
8523
8546
  function ImagePreview({ file }) {
8524
8547
  const [objectUrl, setObjectUrl] = useState5(null);
8525
- useEffect5(() => {
8548
+ useEffect4(() => {
8526
8549
  const url = URL.createObjectURL(file);
8527
8550
  setObjectUrl(url);
8528
8551
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadcn-ui-react",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "private": false,
5
5
  "author": "Bleker Cordova <bleker@gliyen.com>",
6
6
  "description": "A collection of components for building beautiful and accessible user interfaces with React and Tailwind CSS.",