@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.mjs CHANGED
@@ -28979,9 +28979,12 @@ var valueFormatter = (value, format2, customFormatters = {}) => {
28979
28979
  switch (type) {
28980
28980
  case "date":
28981
28981
  return dayjs_setup_default(value).format(arg || "YYYY-MM-DD");
28982
- case "datetime":
28982
+ case "datetimenumber":
28983
28983
  const parsed = dayjs_setup_default(value).isValid() ? dayjs_setup_default(value).utc() : dayjs_setup_default(value);
28984
28984
  return parsed.format("YYYY-MM-DD hh:mm");
28985
+ case "datetime":
28986
+ const formated = dayjs_setup_default(value).isValid() ? dayjs_setup_default(value).utc() : dayjs_setup_default(value);
28987
+ return formated.format("DD MMM YYYY hh:mm A");
28985
28988
  case "days":
28986
28989
  return `${dayjs_setup_default().diff(dayjs_setup_default(value), "day")} days`;
28987
28990
  case "months":
@@ -29267,6 +29270,7 @@ function DataTable({
29267
29270
  const [searchTerm, setSearchTerm] = React9.useState("");
29268
29271
  const tableData = Array.isArray(data) ? data : [];
29269
29272
  const dynamicCols = useDynamicColumns({ columns });
29273
+ const [localPageSize, setLocalPageSize] = React9.useState(pageSize);
29270
29274
  const table = useReactTable({
29271
29275
  data: tableData,
29272
29276
  columns: dynamicCols,
@@ -29315,36 +29319,48 @@ function DataTable({
29315
29319
  return [];
29316
29320
  };
29317
29321
  const pageCount = table.getPageCount() === 0 ? 1 : table.getPageCount();
29322
+ const handlePageSizeChange = (e) => {
29323
+ const newSize = Number(e.target.value);
29324
+ const currentPageIndex = table.getState().pagination.pageIndex;
29325
+ onPageChange?.(currentPageIndex, newSize);
29326
+ setLocalPageSize(newSize);
29327
+ };
29318
29328
  return /* @__PURE__ */ jsxs29("div", { className: "overflow-hidden rounded-md w-full", children: [
29319
- /* @__PURE__ */ jsxs29("div", { className: `flex ${globalSearch ? "justify-between" : "justify-end"} p-2 bg-gray-50`, children: [
29320
- globalSearch && /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
29321
- /* @__PURE__ */ jsxs29("div", { className: "relative w-full", children: [
29329
+ !loading && /* @__PURE__ */ jsxs29("div", { className: "flex justify-between p-2 bg-gray-50", children: [
29330
+ /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-4 w-full", children: [
29331
+ /* @__PURE__ */ jsxs29("p", { className: "text-sm font-medium", children: [
29332
+ "Total Records : ",
29333
+ totalRecords.toLocaleString("en-IN") || 0
29334
+ ] }),
29335
+ globalSearch && /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
29336
+ /* @__PURE__ */ jsxs29("div", { className: "relative w-full", children: [
29337
+ /* @__PURE__ */ jsx51(
29338
+ "input",
29339
+ {
29340
+ type: "text",
29341
+ placeholder: "Search...",
29342
+ value: searchTerm,
29343
+ onChange: (e) => setSearchTerm(e.target.value),
29344
+ onKeyDown: (e) => {
29345
+ if (e.key === "Enter" && onGlobalSearch) {
29346
+ onGlobalSearch(searchTerm.trim());
29347
+ }
29348
+ },
29349
+ 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]"
29350
+ }
29351
+ ),
29352
+ /* @__PURE__ */ jsx51(Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
29353
+ ] }),
29322
29354
  /* @__PURE__ */ jsx51(
29323
- "input",
29355
+ Button,
29324
29356
  {
29325
- type: "text",
29326
- placeholder: "Search...",
29327
- value: searchTerm,
29328
- onChange: (e) => setSearchTerm(e.target.value),
29329
- onKeyDown: (e) => {
29330
- if (e.key === "Enter" && onGlobalSearch) {
29331
- onGlobalSearch(searchTerm.trim());
29332
- }
29333
- },
29334
- 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]"
29357
+ size: "sm",
29358
+ className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3",
29359
+ onClick: () => onGlobalSearch?.(searchTerm.trim()),
29360
+ children: "Search"
29335
29361
  }
29336
- ),
29337
- /* @__PURE__ */ jsx51(Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
29338
- ] }),
29339
- /* @__PURE__ */ jsx51(
29340
- Button,
29341
- {
29342
- size: "sm",
29343
- className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3",
29344
- onClick: () => onGlobalSearch?.(searchTerm.trim()),
29345
- children: "Search"
29346
- }
29347
- )
29362
+ )
29363
+ ] })
29348
29364
  ] }),
29349
29365
  /* @__PURE__ */ jsxs29(Popover, { children: [
29350
29366
  /* @__PURE__ */ jsx51(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx51(
@@ -29534,12 +29550,26 @@ function DataTable({
29534
29550
  );
29535
29551
  }) }, row.id)) : /* @__PURE__ */ jsx51(TableRow, { children: /* @__PURE__ */ jsx51(TableCell, { colSpan: dynamicCols.length, className: "h-24 text-center", children: /* @__PURE__ */ jsx51("span", { className: "flex items-center justify-center py-10 w-full min-w-full text-gray-600 bg-gray-100", children: "No results." }) }) }) })
29536
29552
  ] }),
29537
- pagination && /* @__PURE__ */ jsxs29("div", { className: "flex items-center justify-between py-3 px-2 text-sm w-full", children: [
29538
- /* @__PURE__ */ jsxs29("div", { children: [
29539
- "Page ",
29540
- table.getState().pagination.pageIndex + 1,
29541
- " of ",
29542
- pageCount
29553
+ pagination && /* @__PURE__ */ jsxs29("div", { className: "flex items-center justify-between py-3 text-sm w-full", children: [
29554
+ !loading && /* @__PURE__ */ jsxs29("div", { className: "flex gap-2 items-center", children: [
29555
+ /* @__PURE__ */ jsx51(
29556
+ "select",
29557
+ {
29558
+ value: localPageSize,
29559
+ onChange: handlePageSizeChange,
29560
+ className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
29561
+ children: [10, 20, 50, 100].map((size) => /* @__PURE__ */ jsxs29("option", { value: size, children: [
29562
+ size,
29563
+ " / page"
29564
+ ] }, size))
29565
+ }
29566
+ ),
29567
+ /* @__PURE__ */ jsxs29("div", { children: [
29568
+ "Page ",
29569
+ table.getState().pagination.pageIndex + 1,
29570
+ " of ",
29571
+ pageCount
29572
+ ] })
29543
29573
  ] }),
29544
29574
  /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-2", children: [
29545
29575
  /* @__PURE__ */ jsx51(