@algorithm-shift/design-system 1.2.957 → 1.2.959

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.js CHANGED
@@ -29068,9 +29068,12 @@ var valueFormatter = (value, format2, customFormatters = {}) => {
29068
29068
  switch (type) {
29069
29069
  case "date":
29070
29070
  return dayjs_setup_default(value).format(arg || "YYYY-MM-DD");
29071
- case "datetime":
29071
+ case "datetimenumber":
29072
29072
  const parsed = dayjs_setup_default(value).isValid() ? dayjs_setup_default(value).utc() : dayjs_setup_default(value);
29073
29073
  return parsed.format("YYYY-MM-DD hh:mm");
29074
+ case "datetime":
29075
+ const formated = dayjs_setup_default(value).isValid() ? dayjs_setup_default(value).utc() : dayjs_setup_default(value);
29076
+ return formated.format("DD MMM YYYY hh:mm A");
29074
29077
  case "days":
29075
29078
  return `${dayjs_setup_default().diff(dayjs_setup_default(value), "day")} days`;
29076
29079
  case "months":
@@ -29356,6 +29359,7 @@ function DataTable({
29356
29359
  const [searchTerm, setSearchTerm] = React9.useState("");
29357
29360
  const tableData = Array.isArray(data) ? data : [];
29358
29361
  const dynamicCols = useDynamicColumns({ columns });
29362
+ const [localPageSize, setLocalPageSize] = React9.useState(pageSize);
29359
29363
  const table = (0, import_react_table2.useReactTable)({
29360
29364
  data: tableData,
29361
29365
  columns: dynamicCols,
@@ -29404,36 +29408,48 @@ function DataTable({
29404
29408
  return [];
29405
29409
  };
29406
29410
  const pageCount = table.getPageCount() === 0 ? 1 : table.getPageCount();
29411
+ const handlePageSizeChange = (e) => {
29412
+ const newSize = Number(e.target.value);
29413
+ const currentPageIndex = table.getState().pagination.pageIndex;
29414
+ onPageChange?.(currentPageIndex, newSize);
29415
+ setLocalPageSize(newSize);
29416
+ };
29407
29417
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
29408
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: `flex ${globalSearch ? "justify-between" : "justify-end"} p-2 bg-gray-50`, children: [
29409
- globalSearch && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
29410
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "relative w-full", children: [
29418
+ !loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex justify-between p-2 bg-gray-50", children: [
29419
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-4 w-full", children: [
29420
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("p", { className: "text-sm font-medium", children: [
29421
+ "Total Records : ",
29422
+ totalRecords.toLocaleString("en-IN") || 0
29423
+ ] }),
29424
+ globalSearch && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
29425
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "relative w-full", children: [
29426
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
29427
+ "input",
29428
+ {
29429
+ type: "text",
29430
+ placeholder: "Search...",
29431
+ value: searchTerm,
29432
+ onChange: (e) => setSearchTerm(e.target.value),
29433
+ onKeyDown: (e) => {
29434
+ if (e.key === "Enter" && onGlobalSearch) {
29435
+ onGlobalSearch(searchTerm.trim());
29436
+ }
29437
+ },
29438
+ className: "border border-gray-300 rounded-md text-sm px-3 py-2 pl-8 w-full focus:outline-none focus:ring-1 focus:ring-[#12715B]"
29439
+ }
29440
+ ),
29441
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
29442
+ ] }),
29411
29443
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
29412
- "input",
29444
+ Button,
29413
29445
  {
29414
- type: "text",
29415
- placeholder: "Search...",
29416
- value: searchTerm,
29417
- onChange: (e) => setSearchTerm(e.target.value),
29418
- onKeyDown: (e) => {
29419
- if (e.key === "Enter" && onGlobalSearch) {
29420
- onGlobalSearch(searchTerm.trim());
29421
- }
29422
- },
29423
- className: "border border-gray-300 rounded-md text-sm px-3 py-2 pl-8 w-full focus:outline-none focus:ring-1 focus:ring-[#12715B]"
29446
+ size: "sm",
29447
+ className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3",
29448
+ onClick: () => onGlobalSearch?.(searchTerm.trim()),
29449
+ children: "Search"
29424
29450
  }
29425
- ),
29426
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
29427
- ] }),
29428
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
29429
- Button,
29430
- {
29431
- size: "sm",
29432
- className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3",
29433
- onClick: () => onGlobalSearch?.(searchTerm.trim()),
29434
- children: "Search"
29435
- }
29436
- )
29451
+ )
29452
+ ] })
29437
29453
  ] }),
29438
29454
  /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Popover, { children: [
29439
29455
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
@@ -29623,12 +29639,26 @@ function DataTable({
29623
29639
  );
29624
29640
  }) }, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableCell, { colSpan: dynamicCols.length, className: "h-24 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "flex items-center justify-center py-10 w-full min-w-full text-gray-600 bg-gray-100", children: "No results." }) }) }) })
29625
29641
  ] }),
29626
- pagination && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center justify-between py-3 px-2 text-sm w-full", children: [
29627
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { children: [
29628
- "Page ",
29629
- table.getState().pagination.pageIndex + 1,
29630
- " of ",
29631
- pageCount
29642
+ pagination && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center justify-between py-3 text-sm w-full", children: [
29643
+ !loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex gap-2 items-center", children: [
29644
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
29645
+ "select",
29646
+ {
29647
+ value: localPageSize,
29648
+ onChange: handlePageSizeChange,
29649
+ className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
29650
+ children: [10, 20, 50, 100].map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
29651
+ size,
29652
+ " / page"
29653
+ ] }, size))
29654
+ }
29655
+ ),
29656
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { children: [
29657
+ "Page ",
29658
+ table.getState().pagination.pageIndex + 1,
29659
+ " of ",
29660
+ pageCount
29661
+ ] })
29632
29662
  ] }),
29633
29663
  /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-2", children: [
29634
29664
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(