@algorithm-shift/design-system 1.2.65 → 1.2.67

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
@@ -243,6 +243,11 @@ function TabGroupComponent({
243
243
  activeTab,
244
244
  onTabChange
245
245
  }) {
246
+ (0, import_react3.useEffect)(() => {
247
+ if (list && list.length > 0 && !activeTab && onTabChange) {
248
+ onTabChange(list[0]?.tabId);
249
+ }
250
+ }, [list, activeTab, onTabChange]);
246
251
  const formatedList = (0, import_react3.useMemo)(
247
252
  () => Array.isArray(list) ? [...list].sort((a, b) => (a.orderNumber ?? 0) - (b.orderNumber ?? 0)) : [],
248
253
  [list]
@@ -27819,7 +27824,7 @@ var PhoneInput = ({ className, style, ...props }) => {
27819
27824
  name: props.name,
27820
27825
  value: props.value || "",
27821
27826
  className: cn(
27822
- "rounded-md",
27827
+ "rounded-md border-1",
27823
27828
  className,
27824
27829
  props.errorMessage ? "border-red-500" : ""
27825
27830
  ),
@@ -28434,16 +28439,20 @@ function DataTable({
28434
28439
  onPageChange,
28435
28440
  pageSize = 10,
28436
28441
  paginationMode = "client",
28437
- totalRecords = 0
28442
+ totalRecords = 0,
28443
+ onSortChange,
28444
+ onFilterChange,
28445
+ onGlobalSearch,
28446
+ globalSearch
28438
28447
  }) {
28439
- const [sorting, setSorting] = React6.useState([]);
28440
28448
  const [columnFilters, setColumnFilters] = React6.useState([]);
28441
28449
  const [columnVisibility, setColumnVisibility] = React6.useState({});
28450
+ const [manualSort, setManualSort] = React6.useState(null);
28451
+ const [searchTerm, setSearchTerm] = React6.useState("");
28442
28452
  const table = (0, import_react_table.useReactTable)({
28443
28453
  data,
28444
28454
  columns,
28445
28455
  state: {
28446
- sorting,
28447
28456
  columnFilters,
28448
28457
  columnVisibility,
28449
28458
  pagination: {
@@ -28451,11 +28460,9 @@ function DataTable({
28451
28460
  pageSize
28452
28461
  }
28453
28462
  },
28454
- onSortingChange: setSorting,
28455
28463
  onColumnFiltersChange: setColumnFilters,
28456
28464
  onColumnVisibilityChange: setColumnVisibility,
28457
28465
  getCoreRowModel: (0, import_react_table.getCoreRowModel)(),
28458
- getSortedRowModel: (0, import_react_table.getSortedRowModel)(),
28459
28466
  getFilteredRowModel: (0, import_react_table.getFilteredRowModel)(),
28460
28467
  getPaginationRowModel: pagination && paginationMode === "client" ? (0, import_react_table.getPaginationRowModel)() : void 0,
28461
28468
  manualPagination: paginationMode === "server",
@@ -28485,68 +28492,105 @@ function DataTable({
28485
28492
  }
28486
28493
  return [];
28487
28494
  };
28488
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "overflow-hidden rounded-md border w-full", children: [
28489
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "flex justify-end p-2", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(Popover, { children: [
28490
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
28491
- Button,
28492
- {
28493
- variant: "outline",
28494
- size: "sm",
28495
- className: "px-3 py-1 text-xs cursor-pointer",
28496
- children: "Manage Columns"
28497
- }
28498
- ) }),
28499
- /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(PopoverContent, { align: "end", className: "w-48 p-3 space-y-2", children: [
28500
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "text-sm font-medium mb-2", children: "Show / Hide Columns" }),
28501
- /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 text-sm font-semibold border-b pb-2 mb-2", children: [
28495
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
28496
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: `flex ${globalSearch ? "justify-between" : "justify-end"} p-2 bg-gray-50`, children: [
28497
+ globalSearch && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
28498
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "relative w-full", children: [
28502
28499
  /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
28503
28500
  "input",
28504
28501
  {
28505
- type: "checkbox",
28506
- checked: table.getAllLeafColumns().every((col) => col.getIsVisible()),
28507
- ref: (input) => {
28508
- if (input) {
28509
- input.indeterminate = table.getAllLeafColumns().some((col) => col.getIsVisible()) && !table.getAllLeafColumns().every((col) => col.getIsVisible());
28502
+ type: "text",
28503
+ placeholder: "Search...",
28504
+ value: searchTerm,
28505
+ onChange: (e) => setSearchTerm(e.target.value),
28506
+ onKeyDown: (e) => {
28507
+ if (e.key === "Enter" && onGlobalSearch) {
28508
+ onGlobalSearch(searchTerm.trim());
28510
28509
  }
28511
28510
  },
28512
- onChange: (e) => {
28513
- table.getAllLeafColumns().forEach(
28514
- (col) => col.toggleVisibility(e.target.checked)
28515
- );
28516
- }
28511
+ 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]"
28517
28512
  }
28518
28513
  ),
28519
- "Toggle All"
28514
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
28520
28515
  ] }),
28521
- table.getAllLeafColumns().map((column) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 text-sm", children: [
28522
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
28523
- "input",
28524
- {
28525
- type: "checkbox",
28526
- checked: column.getIsVisible(),
28527
- onChange: (e) => column.toggleVisibility(e.target.checked)
28528
- }
28529
- ),
28530
- column.columnDef.header?.toString() ?? column.id
28531
- ] }, column.id))
28516
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
28517
+ Button,
28518
+ {
28519
+ size: "sm",
28520
+ className: "bg-[#12715B] text-white text-xs h-auto py-2 px-3",
28521
+ onClick: () => onGlobalSearch?.(searchTerm.trim()),
28522
+ children: "Search"
28523
+ }
28524
+ )
28525
+ ] }),
28526
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(Popover, { children: [
28527
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
28528
+ Button,
28529
+ {
28530
+ variant: "outline",
28531
+ size: "sm",
28532
+ className: "px-3 py-1 text-xs cursor-pointer border-gray-300",
28533
+ children: "Manage Columns"
28534
+ }
28535
+ ) }),
28536
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(PopoverContent, { align: "end", className: "w-48 p-3 space-y-2", children: [
28537
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "text-sm font-medium mb-2", children: "Show / Hide Columns" }),
28538
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 text-sm font-semibold border-b pb-2 mb-2", children: [
28539
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
28540
+ "input",
28541
+ {
28542
+ type: "checkbox",
28543
+ checked: table.getAllLeafColumns().every((col) => col.getIsVisible()),
28544
+ ref: (input) => {
28545
+ if (input) {
28546
+ input.indeterminate = table.getAllLeafColumns().some((col) => col.getIsVisible()) && !table.getAllLeafColumns().every((col) => col.getIsVisible());
28547
+ }
28548
+ },
28549
+ onChange: (e) => {
28550
+ table.getAllLeafColumns().forEach(
28551
+ (col) => col.toggleVisibility(e.target.checked)
28552
+ );
28553
+ }
28554
+ }
28555
+ ),
28556
+ "Toggle All"
28557
+ ] }),
28558
+ table.getAllLeafColumns().map((column) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 text-sm", children: [
28559
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
28560
+ "input",
28561
+ {
28562
+ type: "checkbox",
28563
+ checked: column.getIsVisible(),
28564
+ onChange: (e) => column.toggleVisibility(e.target.checked)
28565
+ }
28566
+ ),
28567
+ column.columnDef.header?.toString() ?? column.id
28568
+ ] }, column.id))
28569
+ ] })
28532
28570
  ] })
28533
- ] }) }),
28571
+ ] }),
28534
28572
  /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(Table3, { children: [
28535
28573
  /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TableHeader, { children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TableRow, { children: hg.headers.map((header) => {
28536
28574
  const canSort = header.column.getCanSort();
28537
28575
  const canFilter = header.column.getCanFilter();
28576
+ const sortDir = manualSort?.key === header.column.id ? manualSort.dir : null;
28538
28577
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TableHead, { className: "relative select-none", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
28539
28578
  /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
28540
28579
  "span",
28541
28580
  {
28542
28581
  className: `flex items-center gap-1 ${canSort ? "cursor-pointer" : ""}`,
28543
- onClick: canSort ? header.column.getToggleSortingHandler() : void 0,
28582
+ onClick: () => {
28583
+ if (!canSort) return;
28584
+ const newDir = manualSort?.key === header.column.id && manualSort.dir === "asc" ? "desc" : "asc";
28585
+ setManualSort({ key: header.column.id, dir: newDir });
28586
+ onSortChange?.(header.column.id, newDir);
28587
+ },
28544
28588
  children: [
28545
28589
  (0, import_react_table.flexRender)(header.column.columnDef.header, header.getContext()),
28546
28590
  canSort && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
28547
- header.column.getIsSorted() === "asc" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ArrowUp, { size: 14, className: "text-gray-500" }),
28548
- header.column.getIsSorted() === "desc" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ArrowDown, { size: 14, className: "text-gray-500" }),
28549
- !header.column.getIsSorted() && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ArrowUpDown, { size: 14, className: "text-gray-400" })
28591
+ sortDir === "asc" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ArrowUp, { size: 14, className: "text-gray-500" }),
28592
+ sortDir === "desc" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ArrowDown, { size: 14, className: "text-gray-500" }),
28593
+ !sortDir && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ArrowUpDown, { size: 14, className: "text-gray-400" })
28550
28594
  ] })
28551
28595
  ]
28552
28596
  }
@@ -28564,8 +28608,8 @@ function DataTable({
28564
28608
  /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
28565
28609
  PopoverContent,
28566
28610
  {
28567
- align: "start",
28568
- sideOffset: 4,
28611
+ align: "center",
28612
+ sideOffset: 14,
28569
28613
  className: "w-50 p-3 z-[200] border-gray-300",
28570
28614
  avoidCollisions: true,
28571
28615
  children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
@@ -28574,8 +28618,10 @@ function DataTable({
28574
28618
  onSubmit: (e) => {
28575
28619
  e.preventDefault();
28576
28620
  const formData = new FormData(e.currentTarget);
28577
- const value = formData.get("filter");
28578
- header.column.setFilterValue(value || void 0);
28621
+ const value = formData.get("filter") || "";
28622
+ if (onFilterChange && value) {
28623
+ onFilterChange({ columnKey: header.column.id, columnTerm: value });
28624
+ }
28579
28625
  },
28580
28626
  className: "space-y-2",
28581
28627
  children: [
@@ -28665,9 +28711,13 @@ var Table4 = ({
28665
28711
  paginationMode = "client",
28666
28712
  itemsPerPage = 10,
28667
28713
  onPageChange,
28714
+ onSortChange,
28715
+ onFilterChange,
28716
+ onGlobalSearch,
28668
28717
  page,
28669
28718
  loading = false,
28670
28719
  totalRecords = 0,
28720
+ globalSearch = false,
28671
28721
  ...props
28672
28722
  }) => {
28673
28723
  const rawColumns = Array.isArray(columns) ? columns : [];
@@ -28688,7 +28738,11 @@ var Table4 = ({
28688
28738
  onPageChange?.({ page: pageIndex + 1, itemsPerPage: pageSize });
28689
28739
  },
28690
28740
  paginationMode,
28691
- totalRecords
28741
+ totalRecords,
28742
+ onSortChange: (col, dir) => onSortChange?.({ sort_by: col, sort_order: dir }),
28743
+ onFilterChange: (filters) => onFilterChange?.({ columnKey: filters.columnKey, columnTerm: filters.columnTerm }),
28744
+ onGlobalSearch: (term) => onGlobalSearch?.({ searchTerm: term }),
28745
+ globalSearch
28692
28746
  }
28693
28747
  ) });
28694
28748
  };
@@ -29085,20 +29139,20 @@ function Navbar({
29085
29139
  userName = "Guest User"
29086
29140
  }) {
29087
29141
  const isMobileView = canvasMode === "mobile" || canvasMode === "tablet";
29088
- return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("nav", { className: "w-full border-b bg-white shadow-sm", style, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "mx-auto flex max-w-7xl items-center justify-between px-4 py-4", children: [
29142
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("nav", { className: "w-full border-b border-b-white dark:border-b-gray-800 dark:bg-gray-800 bg-white shadow-sm", style, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "mx-auto flex max-w-[90%] items-center justify-between px-4 py-4", children: [
29089
29143
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_link6.default, { href: "/", className: "flex items-center space-x-2", children: imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_image3.default, { src: imageUrl, alt: altText, width: 200, height: 200 }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "font-semibold text-blue-700", children: "Logo" }) }),
29090
29144
  !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex items-center space-x-6 sm:hidden md:flex", children: list.map((item) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
29091
29145
  import_link6.default,
29092
29146
  {
29093
29147
  href: item.url || "#",
29094
- className: "text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors",
29148
+ className: "text-sm font-medium dark:text-white text-gray-600 hover:text-gray-900 transition-colors",
29095
29149
  children: item.header
29096
29150
  },
29097
29151
  item.id
29098
29152
  )) }),
29099
29153
  /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center space-x-3", children: [
29100
29154
  !isMobileView ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex-1 px-6", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "relative w-full max-w-md border border-gray-300 rounded-md", children: [
29101
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" }),
29155
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 dark:text-white text-gray-400" }),
29102
29156
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Input, { placeholder: "Search", className: "pl-9 text-gray-400" })
29103
29157
  ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
29104
29158
  Button,
@@ -29109,13 +29163,13 @@ function Navbar({
29109
29163
  children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Search, { className: "h-5 w-5 text-gray-400" })
29110
29164
  }
29111
29165
  ),
29112
- /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "relative bg-[#E9E9E9] rounded-md", children: [
29113
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Bell, { className: "h-5 w-5 text-[#1C1B1F]" }) }),
29166
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "relative bg-[#E9E9E9] dark:bg-gray-700 rounded-md", children: [
29167
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Bell, { className: "h-5 w-5 text-[#1C1B1F] dark:text-gray-400" }) }),
29114
29168
  badgeType === "number" && !(hideBadgeWhenZero && badgeCount === 0) && Number(badgeCount) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full bg-red-500 text-[10px] text-white leading-8", children: badgeCount }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "absolute -top-1 -right-1 flex h-2 w-2 items-center justify-center rounded-full bg-red-500" })
29115
29169
  ] }),
29116
29170
  /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(DropdownMenu, { children: [
29117
29171
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center space-x-2", children: [
29118
- !isMobileView && showName && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h4", { className: "text-[#000000] text-[13px] font-[500] mb-0", children: userName }),
29172
+ !isMobileView && showName && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h4", { className: "text-[#000000] dark:text-gray-300 text-[13px] font-[500] mb-0", children: userName }),
29119
29173
  !isMobileView ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
29120
29174
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Avatar, { className: "cursor-pointer h-8 w-8 text-gray-900", children: profileType === "avatar" ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
29121
29175
  AvatarImage,
@@ -29129,7 +29183,7 @@ function Navbar({
29129
29183
  {
29130
29184
  variant: "ghost",
29131
29185
  size: "icon",
29132
- className: "text-gray-900 md:hidden",
29186
+ className: "text-gray-900 md:hidden dark:invert",
29133
29187
  children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Menu, { className: "h-6 w-6" })
29134
29188
  }
29135
29189
  )
@@ -29138,16 +29192,16 @@ function Navbar({
29138
29192
  {
29139
29193
  variant: "ghost",
29140
29194
  size: "icon",
29141
- className: "text-gray-900",
29195
+ className: "text-gray-900 dark:invert",
29142
29196
  children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Menu, { className: "h-6 w-6" })
29143
29197
  }
29144
29198
  )
29145
29199
  ] }) }),
29146
- /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(DropdownMenuContent, { align: "end", className: "bg-white", children: [
29147
- profileMenu && profileMenu.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, { children: profileMenu.map((item) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(DropdownMenuItem, { className: "text-black", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_link6.default, { href: item.url || "#", children: item.header }) }, item.id)) }),
29200
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(DropdownMenuContent, { align: "end", className: "bg-white dark:bg-gray-800", children: [
29201
+ profileMenu && profileMenu.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, { children: profileMenu.map((item) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(DropdownMenuItem, { className: "text-black dark:invert", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_link6.default, { href: item.url || "#", children: item.header }) }, item.id)) }),
29148
29202
  /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "md:hidden", children: [
29149
29203
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_react_dropdown_menu.DropdownMenuSeparator, {}),
29150
- list && list.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, { children: list.map((item) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(DropdownMenuItem, { className: "text-black", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_link6.default, { href: item.url || "#", children: item.header }) }, item.id)) })
29204
+ list && list.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, { children: list.map((item) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(DropdownMenuItem, { className: "text-black dark:invert", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_link6.default, { href: item.url || "#", children: item.header }) }, item.id)) })
29151
29205
  ] })
29152
29206
  ] })
29153
29207
  ] })
@@ -29156,19 +29210,45 @@ function Navbar({
29156
29210
  }
29157
29211
 
29158
29212
  // src/components/Chart/BarChart.tsx
29213
+ var import_react27 = __toESM(require("react"));
29159
29214
  var import_recharts = require("recharts");
29160
29215
  var import_jsx_runtime59 = require("react/jsx-runtime");
29161
- var ChartComponent = ({ className, style, ...props }) => {
29162
- const data = Array.isArray(props?.data) ? props.data : [];
29216
+ var ChartComponent = ({ className, style, loading, ...props }) => {
29217
+ const data = Array.isArray(props.data) ? props.data : [];
29163
29218
  const chartType = props.chartType || "bar";
29164
29219
  const legendsPosition = props.legendsPosition === "middle" || props.legendsPosition === "bottom" ? props.legendsPosition : "top";
29165
- return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: `${className} h-[400px]`, style, children: data.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: "100%", children: chartType === "bar" ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_recharts.BarChart, { data, children: [
29220
+ if (loading || data.length === 0) {
29221
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
29222
+ "div",
29223
+ {
29224
+ className: `flex items-center justify-center w-full h-[300px] md:h-[400px] bg-gray-50 animate-pulse rounded-lg ${className}`,
29225
+ style,
29226
+ children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "text-gray-400 text-sm md:text-base", children: loading ? "Loading chart report..." : "No data available to display the chart." })
29227
+ }
29228
+ );
29229
+ }
29230
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: `${className} h-[400px]`, style, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: "100%", children: chartType === "bar" ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_recharts.BarChart, { data, title: "Leads", desc: "content", children: [
29166
29231
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
29167
29232
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.XAxis, { dataKey: "name" }),
29168
29233
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.YAxis, {}),
29169
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Tooltip, {}),
29234
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Tooltip, { formatter: (value) => `${value}k` }),
29170
29235
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Legend, { verticalAlign: legendsPosition, align: "center" }),
29171
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Bar, { dataKey: "value", fill: "#00695C" })
29236
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
29237
+ import_recharts.Bar,
29238
+ {
29239
+ dataKey: "value",
29240
+ fill: "#00695C",
29241
+ radius: [6, 6, 0, 0],
29242
+ isAnimationActive: false,
29243
+ children: data.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
29244
+ "rect",
29245
+ {
29246
+ fill: entry.color || "#00695C"
29247
+ },
29248
+ `bar-${index}`
29249
+ ))
29250
+ }
29251
+ )
29172
29252
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_recharts.AreaChart, { data, children: [
29173
29253
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("linearGradient", { id: "colorCount", x1: "0", y1: "0", x2: "0", y2: "1", children: [
29174
29254
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("stop", { offset: "5%", stopColor: "#00695C", stopOpacity: 0.8 }),
@@ -29177,7 +29257,7 @@ var ChartComponent = ({ className, style, ...props }) => {
29177
29257
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
29178
29258
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.XAxis, { dataKey: "name" }),
29179
29259
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.YAxis, {}),
29180
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Tooltip, {}),
29260
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_recharts.Tooltip, { formatter: (value) => `${value}k` }),
29181
29261
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
29182
29262
  import_recharts.Area,
29183
29263
  {
@@ -29185,47 +29265,44 @@ var ChartComponent = ({ className, style, ...props }) => {
29185
29265
  dataKey: "value",
29186
29266
  stroke: "#00695C",
29187
29267
  fillOpacity: 1,
29188
- fill: "url(#colorCount)"
29268
+ fill: "url(#colorCount)",
29269
+ isAnimationActive: false
29189
29270
  }
29190
29271
  )
29191
29272
  ] }) }) });
29192
29273
  };
29193
- var BarChart_default = ChartComponent;
29274
+ var BarChart_default = import_react27.default.memo(ChartComponent);
29194
29275
 
29195
29276
  // src/components/Chart/PieChart.tsx
29277
+ var import_react28 = __toESM(require("react"));
29196
29278
  var import_recharts2 = require("recharts");
29197
29279
  var import_jsx_runtime60 = require("react/jsx-runtime");
29198
- var DonutChart = ({ className, style, ...props }) => {
29199
- const data = Array.isArray(props?.data) ? props.data : [];
29200
- const total = data.reduce((sum, d) => sum + d.value, 0);
29201
- const showPercentage = props.showPercentage ?? true;
29280
+ var getRandomColor = () => {
29281
+ const palette = [
29282
+ "#2563eb",
29283
+ "#10b981",
29284
+ "#f59e0b",
29285
+ "#ef4444",
29286
+ "#8b5cf6",
29287
+ "#14b8a6",
29288
+ "#ec4899",
29289
+ "#e11d48",
29290
+ "#22c55e",
29291
+ "#3b82f6"
29292
+ ];
29293
+ return palette[Math.floor(Math.random() * palette.length)];
29294
+ };
29295
+ var DonutChart = ({ className, style, loading, ...props }) => {
29202
29296
  const showLegends = props.showLegends ?? true;
29203
29297
  const labelType = props.labelType || "inside";
29204
29298
  const canvasMode = props.canvasMode;
29205
- const renderLabel = ({ value, x, y }) => {
29206
- if (value == null) return null;
29207
- const percentage = (Number(value) / total * 100).toFixed(0);
29208
- return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29209
- "text",
29210
- {
29211
- x,
29212
- y,
29213
- textAnchor: "middle",
29214
- dominantBaseline: "central",
29215
- className: "text-[10px] font-semibold",
29216
- fill: labelType === "inside" ? "#fff" : "#000",
29217
- children: [
29218
- value,
29219
- "k ",
29220
- showPercentage ? `(${percentage}%)` : ""
29221
- ]
29222
- }
29223
- );
29224
- };
29299
+ const data = (0, import_react28.useMemo)(() => {
29300
+ if (!Array.isArray(props.data)) return [];
29301
+ return props.data.map((item) => ({ ...item, color: getRandomColor() }));
29302
+ }, [props.data]);
29303
+ const total = (0, import_react28.useMemo)(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
29225
29304
  const forceMobile = canvasMode === "mobile" || canvasMode === "tablet";
29226
- const forceDesktop = canvasMode === "desktop";
29227
- const wrapperClass = canvasMode ? forceDesktop ? "flex-row" : "flex-col" : "flex-col md:flex-row";
29228
- const renderLegends = () => {
29305
+ const renderLegends = (0, import_react28.useMemo)(() => {
29229
29306
  if (!showLegends) return null;
29230
29307
  return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_jsx_runtime60.Fragment, { children: data.map((d) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29231
29308
  "div",
@@ -29244,23 +29321,33 @@ var DonutChart = ({ className, style, ...props }) => {
29244
29321
  },
29245
29322
  d.name
29246
29323
  )) });
29247
- };
29324
+ }, [data, showLegends]);
29325
+ if (loading || data.length === 0) {
29326
+ return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
29327
+ "div",
29328
+ {
29329
+ className: `flex items-center justify-center w-full h-[300px] md:h-[400px] bg-gray-50 animate-pulse rounded-lg ${className}`,
29330
+ style,
29331
+ children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "text-gray-400 text-sm md:text-base", children: loading ? "Loading chart report..." : "No data available to display the chart." })
29332
+ }
29333
+ );
29334
+ }
29248
29335
  return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29249
29336
  "div",
29250
29337
  {
29251
- className: `relative flex items-center ${wrapperClass} ${className}`,
29338
+ className: `relative flex flex-col items-center ${className}`,
29252
29339
  style,
29253
29340
  children: [
29254
29341
  /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "relative w-full md:w-[70%] h-[300px] md:h-[400px] flex items-center justify-center", children: [
29255
- data.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_recharts2.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_recharts2.PieChart, { children: [
29342
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_recharts2.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_recharts2.PieChart, { children: [
29256
29343
  /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29257
29344
  import_recharts2.Pie,
29258
29345
  {
29259
29346
  data,
29260
29347
  cx: "50%",
29261
29348
  cy: "50%",
29262
- innerRadius: 70,
29263
- outerRadius: 120,
29349
+ innerRadius: forceMobile ? 60 : 80,
29350
+ outerRadius: forceMobile ? 100 : 140,
29264
29351
  dataKey: "value",
29265
29352
  labelLine: false,
29266
29353
  isAnimationActive: false,
@@ -29271,26 +29358,38 @@ var DonutChart = ({ className, style, ...props }) => {
29271
29358
  {
29272
29359
  dataKey: "value",
29273
29360
  position: labelType === "inside" ? "inside" : "outside",
29274
- content: renderLabel
29361
+ fill: labelType === "inside" ? "#fff" : "#000",
29362
+ fontSize: forceMobile ? 10 : 13,
29363
+ fontWeight: 600
29275
29364
  }
29276
29365
  )
29277
29366
  ]
29278
29367
  }
29279
29368
  ),
29280
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_recharts2.Tooltip, { formatter: (value, name) => [`${value}k`, name] })
29369
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
29370
+ import_recharts2.Tooltip,
29371
+ {
29372
+ formatter: (value, name) => [`${value}k`, name]
29373
+ }
29374
+ )
29281
29375
  ] }) }),
29282
- /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-2xl md:text-4xl font-bold text-[#000]", children: [
29283
- total,
29284
- "k"
29285
- ] })
29376
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
29377
+ "div",
29378
+ {
29379
+ className: `absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 ${forceMobile ? "text-2xl" : "text-4xl"} font-bold text-[#000]`,
29380
+ children: [
29381
+ total,
29382
+ "k"
29383
+ ]
29384
+ }
29385
+ )
29286
29386
  ] }),
29287
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: `flex ${forceDesktop ? "flex-col ml-auto space-y-3" : "flex-wrap justify-center gap-2 mt-4"}
29288
- w-full md:w-auto`, children: renderLegends() })
29387
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "flex flex-wrap justify-center gap-2 mt-6 w-full md:w-auto", children: renderLegends })
29289
29388
  ]
29290
29389
  }
29291
29390
  );
29292
29391
  };
29293
- var PieChart_default = DonutChart;
29392
+ var PieChart_default = import_react28.default.memo(DonutChart);
29294
29393
 
29295
29394
  // src/components/Blocks/EmailComposer.tsx
29296
29395
  var import_jsx_runtime61 = require("react/jsx-runtime");