@farmzone/fz-react-ui 1.0.15 → 1.0.16

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.cts CHANGED
@@ -331,7 +331,7 @@ interface PaginationProps {
331
331
  onPageChange?: (page: number) => void;
332
332
  showTotalCount?: boolean;
333
333
  }
334
- declare function Pagination(props: PaginationProps): react.JSX.Element | null;
334
+ declare function Pagination(props: PaginationProps): react.JSX.Element;
335
335
 
336
336
  type BreadCrumbItem = {
337
337
  label: string;
package/dist/index.d.ts CHANGED
@@ -331,7 +331,7 @@ interface PaginationProps {
331
331
  onPageChange?: (page: number) => void;
332
332
  showTotalCount?: boolean;
333
333
  }
334
- declare function Pagination(props: PaginationProps): react.JSX.Element | null;
334
+ declare function Pagination(props: PaginationProps): react.JSX.Element;
335
335
 
336
336
  type BreadCrumbItem = {
337
337
  label: string;
package/dist/index.js CHANGED
@@ -1397,7 +1397,8 @@ function getVisiblePageRange(currentPage, totalPages) {
1397
1397
  return { start, end };
1398
1398
  }
1399
1399
  function Pagination(props) {
1400
- const { page = 0, totalPages = 50, onPageChange } = props;
1400
+ const { page = 0, totalPages: rawTotalPages = 0, onPageChange } = props;
1401
+ const totalPages = Math.max(1, rawTotalPages);
1401
1402
  const [displayPage, setDisplayPage] = useState(page);
1402
1403
  useEffect(() => {
1403
1404
  setDisplayPage(page);
@@ -1409,6 +1410,7 @@ function Pagination(props) {
1409
1410
  },
1410
1411
  [onPageChange]
1411
1412
  );
1413
+ const isEmpty = rawTotalPages === 0;
1412
1414
  const pageButtons = useMemo(() => {
1413
1415
  const { start, end } = getVisiblePageRange(displayPage, totalPages);
1414
1416
  const buttons = [];
@@ -1420,9 +1422,10 @@ function Pagination(props) {
1420
1422
  "button",
1421
1423
  {
1422
1424
  type: "button",
1425
+ disabled: isEmpty,
1423
1426
  className: cn(
1424
- "min-w-7 min-h-7 rounded-[4px] text-[14px] px-[5px] font-medium cursor-pointer",
1425
- isActive ? "bg-[#2675e2] text-white font-bold" : "bg-white text-[#000000] font-normal hover:bg-gray-50"
1427
+ "min-w-7 min-h-7 rounded-[4px] text-[14px] px-[5px] font-medium",
1428
+ isEmpty ? "bg-[#2675e2] text-white font-bold cursor-default" : isActive ? "bg-[#2675e2] text-white font-bold cursor-pointer" : "bg-white text-[#000000] font-normal hover:bg-gray-50 cursor-pointer"
1426
1429
  ),
1427
1430
  onClick: () => handlePageChange(pageIndex),
1428
1431
  children: displayPageNumber
@@ -1432,7 +1435,7 @@ function Pagination(props) {
1432
1435
  );
1433
1436
  }
1434
1437
  return buttons;
1435
- }, [displayPage, totalPages, handlePageChange]);
1438
+ }, [displayPage, totalPages, handlePageChange, isEmpty]);
1436
1439
  const isFirstDisabled = displayPage <= 0;
1437
1440
  const isPreviousDisabled = displayPage <= 0;
1438
1441
  const isNextDisabled = displayPage >= totalPages - 1;
@@ -1452,9 +1455,6 @@ function Pagination(props) {
1452
1455
  children
1453
1456
  }
1454
1457
  );
1455
- if (!totalPages || totalPages === 0) {
1456
- return null;
1457
- }
1458
1458
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-1.5", children: [
1459
1459
  renderNavButton(
1460
1460
  () => handlePageChange(0),
@@ -2794,7 +2794,7 @@ function DatePickerSingle(props) {
2794
2794
  "div",
2795
2795
  {
2796
2796
  role: "button",
2797
- tabIndex: disabled ? -1 : 0,
2797
+ tabIndex: -1,
2798
2798
  "aria-hidden": disabled,
2799
2799
  onClick: () => {
2800
2800
  if (!disabled) toggleCalendar(inputValue);
@@ -5228,7 +5228,7 @@ function Table(props) {
5228
5228
  ] })
5229
5229
  }
5230
5230
  ),
5231
- !showEmpty && !showSkeleton && (paginationInfo || renderFooter?.renderLeft || renderFooter?.renderRight) && /* @__PURE__ */ jsx("div", { ref: footerRef, children: /* @__PURE__ */ jsx(
5231
+ !showSkeleton && (paginationInfo || renderFooter?.renderLeft || renderFooter?.renderRight) && /* @__PURE__ */ jsx("div", { ref: footerRef, children: /* @__PURE__ */ jsx(
5232
5232
  TableFooter,
5233
5233
  {
5234
5234
  paginationInfo,