@wordrhyme/auto-crud 1.22.1 → 1.23.0

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
@@ -3418,9 +3418,11 @@ function DataTablePagination({ table, pageSizeOptions = [
3418
3418
  const [hasSpace, setHasSpace] = (0, react.useState)(false);
3419
3419
  const hideExtras = responsive && !hasSpace;
3420
3420
  const hiddenClass = hideExtras ? "absolute invisible pointer-events-none left-0 top-0" : void 0;
3421
- const pageIndex = table.getState().pagination.pageIndex;
3421
+ const { pageIndex, pageSize } = table.getState().pagination;
3422
3422
  const pageCount = table.getPageCount();
3423
+ const knownPageCount = pageCount >= 0;
3423
3424
  const canJump = Number.isFinite(pageCount) && pageCount > 0;
3425
+ const canGoNext = table.getCanNextPage() && (knownPageCount || table.options.data.length >= pageSize);
3424
3426
  const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
3425
3427
  (0, react.useEffect)(() => {
3426
3428
  if (!responsive || !container.current || !summary.current || !controls.current || !navigation.current) return;
@@ -3490,16 +3492,16 @@ function DataTablePagination({ table, pageSizeOptions = [
3490
3492
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.SelectValue, { placeholder: table.getState().pagination.pageSize })
3491
3493
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.SelectContent, {
3492
3494
  side: "top",
3493
- children: pageSizeOptions.map((pageSize) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.SelectItem, {
3494
- value: `${pageSize}`,
3495
- children: pageSize
3496
- }, pageSize))
3495
+ children: pageSizeOptions.map((pageSize$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.SelectItem, {
3496
+ value: `${pageSize$1}`,
3497
+ children: pageSize$1
3498
+ }, pageSize$1))
3497
3499
  })]
3498
3500
  })]
3499
3501
  }),
3500
3502
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3501
3503
  className: "flex items-center justify-center font-medium text-sm",
3502
- children: locale.page(pageIndex + 1, pageCount)
3504
+ children: knownPageCount ? locale.page(pageIndex + 1, pageCount) : pageIndex + 1
3503
3505
  }),
3504
3506
  showPageJump && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3505
3507
  ref: pageJump,
@@ -3564,7 +3566,7 @@ function DataTablePagination({ table, pageSizeOptions = [
3564
3566
  size: "icon",
3565
3567
  className: "size-8",
3566
3568
  onClick: () => table.nextPage(),
3567
- disabled: !table.getCanNextPage(),
3569
+ disabled: !canGoNext,
3568
3570
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, {})
3569
3571
  }),
3570
3572
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
@@ -3573,7 +3575,7 @@ function DataTablePagination({ table, pageSizeOptions = [
3573
3575
  size: "icon",
3574
3576
  className: cn("size-8", alwaysShowFirstLast ? "flex" : "hidden lg:flex", hiddenClass),
3575
3577
  onClick: () => table.setPageIndex(table.getPageCount() - 1),
3576
- disabled: !table.getCanNextPage() || alwaysShowFirstLast && !canJump,
3578
+ disabled: !canJump || !canGoNext,
3577
3579
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronsRight, {})
3578
3580
  })
3579
3581
  ]
@@ -7910,7 +7912,7 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
7910
7912
  getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
7911
7913
  autoResetExpanded: defaultExpanded ? false : void 0,
7912
7914
  pageCount,
7913
- ...total !== void 0 ? { rowCount: total } : {},
7915
+ rowCount: total,
7914
7916
  enableAdvancedFilter,
7915
7917
  initialState: stableInitialState,
7916
7918
  shallow: false,
package/dist/index.js CHANGED
@@ -3402,9 +3402,11 @@ function DataTablePagination({ table, pageSizeOptions = [
3402
3402
  const [hasSpace, setHasSpace] = useState(false);
3403
3403
  const hideExtras = responsive && !hasSpace;
3404
3404
  const hiddenClass = hideExtras ? "absolute invisible pointer-events-none left-0 top-0" : void 0;
3405
- const pageIndex = table.getState().pagination.pageIndex;
3405
+ const { pageIndex, pageSize } = table.getState().pagination;
3406
3406
  const pageCount = table.getPageCount();
3407
+ const knownPageCount = pageCount >= 0;
3407
3408
  const canJump = Number.isFinite(pageCount) && pageCount > 0;
3409
+ const canGoNext = table.getCanNextPage() && (knownPageCount || table.options.data.length >= pageSize);
3408
3410
  const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
3409
3411
  useEffect(() => {
3410
3412
  if (!responsive || !container.current || !summary.current || !controls.current || !navigation.current) return;
@@ -3474,16 +3476,16 @@ function DataTablePagination({ table, pageSizeOptions = [
3474
3476
  children: /* @__PURE__ */ jsx(SelectValue, { placeholder: table.getState().pagination.pageSize })
3475
3477
  }), /* @__PURE__ */ jsx(SelectContent, {
3476
3478
  side: "top",
3477
- children: pageSizeOptions.map((pageSize) => /* @__PURE__ */ jsx(SelectItem, {
3478
- value: `${pageSize}`,
3479
- children: pageSize
3480
- }, pageSize))
3479
+ children: pageSizeOptions.map((pageSize$1) => /* @__PURE__ */ jsx(SelectItem, {
3480
+ value: `${pageSize$1}`,
3481
+ children: pageSize$1
3482
+ }, pageSize$1))
3481
3483
  })]
3482
3484
  })]
3483
3485
  }),
3484
3486
  /* @__PURE__ */ jsx("div", {
3485
3487
  className: "flex items-center justify-center font-medium text-sm",
3486
- children: locale.page(pageIndex + 1, pageCount)
3488
+ children: knownPageCount ? locale.page(pageIndex + 1, pageCount) : pageIndex + 1
3487
3489
  }),
3488
3490
  showPageJump && /* @__PURE__ */ jsx("div", {
3489
3491
  ref: pageJump,
@@ -3548,7 +3550,7 @@ function DataTablePagination({ table, pageSizeOptions = [
3548
3550
  size: "icon",
3549
3551
  className: "size-8",
3550
3552
  onClick: () => table.nextPage(),
3551
- disabled: !table.getCanNextPage(),
3553
+ disabled: !canGoNext,
3552
3554
  children: /* @__PURE__ */ jsx(ChevronRight, {})
3553
3555
  }),
3554
3556
  /* @__PURE__ */ jsx(Button, {
@@ -3557,7 +3559,7 @@ function DataTablePagination({ table, pageSizeOptions = [
3557
3559
  size: "icon",
3558
3560
  className: cn("size-8", alwaysShowFirstLast ? "flex" : "hidden lg:flex", hiddenClass),
3559
3561
  onClick: () => table.setPageIndex(table.getPageCount() - 1),
3560
- disabled: !table.getCanNextPage() || alwaysShowFirstLast && !canJump,
3562
+ disabled: !canJump || !canGoNext,
3561
3563
  children: /* @__PURE__ */ jsx(ChevronsRight, {})
3562
3564
  })
3563
3565
  ]
@@ -7894,7 +7896,7 @@ function AutoTable({ resourceId, views, schema, data, getRowId, expandedRow, row
7894
7896
  getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
7895
7897
  autoResetExpanded: defaultExpanded ? false : void 0,
7896
7898
  pageCount,
7897
- ...total !== void 0 ? { rowCount: total } : {},
7899
+ rowCount: total,
7898
7900
  enableAdvancedFilter,
7899
7901
  initialState: stableInitialState,
7900
7902
  shallow: false,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wordrhyme/auto-crud",
3
3
  "type": "module",
4
- "version": "1.22.1",
4
+ "version": "1.23.0",
5
5
  "description": "Schema-first CRUD components with auto-generated tables and forms",
6
6
  "author": "wordrhyme",
7
7
  "license": "MIT",
@@ -71,9 +71,9 @@
71
71
  "nanoid": "^5.1.6",
72
72
  "tailwind-merge": "^3.5.0",
73
73
  "vaul": "^1.1.2",
74
- "@wordrhyme/formily-shadcn": "2.1.4",
75
74
  "@wordrhyme/shadcn": "2.0.3",
76
- "@wordrhyme/shadcn-ui": "2.1.4"
75
+ "@wordrhyme/shadcn-ui": "2.1.4",
76
+ "@wordrhyme/formily-shadcn": "2.1.4"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@storybook/react": "^8.6.18",