@algorithm-shift/design-system 1.2.960 → 1.2.962

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
@@ -27677,7 +27677,7 @@ function useLazyDropdown(config) {
27677
27677
  }, [config]);
27678
27678
  function getValueByPath2(obj, path) {
27679
27679
  if (!obj || !path) return void 0;
27680
- const parts = path.split(/\.|__/);
27680
+ const parts = path.split(/\./);
27681
27681
  return parts.reduce((acc, key) => acc?.[key], obj);
27682
27682
  }
27683
27683
  const transformToOptions = useCallback2((data) => {
@@ -27687,7 +27687,7 @@ function useLazyDropdown(config) {
27687
27687
  const value = getValueByPath2(item, cfg.dataKey) ?? item.id ?? "";
27688
27688
  let label = "";
27689
27689
  if (cfg.dataLabel) {
27690
- label = getValueByPath2(item, cfg.dataLabel) ?? item.name ?? item.label ?? "";
27690
+ label = getValueByPath2(item, cfg.dataLabel) ?? item.name ?? item.label ?? item.first_name ?? "";
27691
27691
  }
27692
27692
  return {
27693
27693
  value,
@@ -29337,10 +29337,17 @@ function DataTable({
29337
29337
  onPageChange?.(currentPageIndex, newSize);
29338
29338
  setLocalPageSize(newSize);
29339
29339
  };
29340
+ const pageSizeOptions = React9.useMemo(() => {
29341
+ const options = [10, 20, 50, 100].filter((size) => size < totalRecords);
29342
+ if (options.length === 0) {
29343
+ options.push(10);
29344
+ }
29345
+ return options;
29346
+ }, [totalRecords]);
29340
29347
  return /* @__PURE__ */ jsxs29("div", { className: "overflow-hidden rounded-md w-full", children: [
29341
29348
  !loading && /* @__PURE__ */ jsxs29("div", { className: "flex justify-between p-2 bg-gray-50", children: [
29342
29349
  /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-4 w-full", children: [
29343
- /* @__PURE__ */ jsxs29("p", { className: "text-sm font-medium", children: [
29350
+ !!totalRecords && /* @__PURE__ */ jsxs29("p", { className: "text-sm font-medium", children: [
29344
29351
  "Total Records : ",
29345
29352
  totalRecords.toLocaleString("en-IN") || 0
29346
29353
  ] }),
@@ -29570,7 +29577,7 @@ function DataTable({
29570
29577
  value: localPageSize,
29571
29578
  onChange: handlePageSizeChange,
29572
29579
  className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
29573
- children: [10, 20, 50, 100].map((size) => /* @__PURE__ */ jsxs29("option", { value: size, children: [
29580
+ children: pageSizeOptions.map((size) => /* @__PURE__ */ jsxs29("option", { value: size, children: [
29574
29581
  size,
29575
29582
  " / page"
29576
29583
  ] }, size))
@@ -29885,7 +29892,7 @@ var CustomPagination = ({
29885
29892
  var Pagination_default = CustomPagination;
29886
29893
 
29887
29894
  // src/components/Navigation/Tabs/Tabs.tsx
29888
- import { useCallback as useCallback3, useMemo as useMemo5, useState as useState8 } from "react";
29895
+ import { useCallback as useCallback3, useMemo as useMemo6, useState as useState8 } from "react";
29889
29896
  import Link5 from "next/link";
29890
29897
  import { useRouter } from "next/navigation";
29891
29898
 
@@ -30003,9 +30010,46 @@ function DialogDescription({
30003
30010
  );
30004
30011
  }
30005
30012
 
30013
+ // src/components/ui/sonner-toast.tsx
30014
+ import { toast } from "sonner";
30015
+ function showSonnerToast({
30016
+ title,
30017
+ description,
30018
+ variant = "default",
30019
+ duration = 3e3,
30020
+ actionLabel,
30021
+ onAction
30022
+ }) {
30023
+ const options = {
30024
+ description,
30025
+ duration,
30026
+ action: actionLabel ? {
30027
+ label: actionLabel,
30028
+ onClick: onAction || (() => {
30029
+ })
30030
+ } : void 0
30031
+ };
30032
+ switch (variant) {
30033
+ case "success":
30034
+ toast.success(title, options);
30035
+ break;
30036
+ case "error":
30037
+ toast.error(title, options);
30038
+ break;
30039
+ case "info":
30040
+ toast.info(title, options);
30041
+ break;
30042
+ case "warning":
30043
+ toast.warning(title, options);
30044
+ break;
30045
+ default:
30046
+ toast(title, options);
30047
+ }
30048
+ }
30049
+
30006
30050
  // src/components/Navigation/Tabs/Tabs.tsx
30007
30051
  import { Fragment as Fragment22, jsx as jsx56, jsxs as jsxs33 } from "react/jsx-runtime";
30008
- var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder = false, source, parentKey, menuNameKey, menuUrlKey, loading }) => {
30052
+ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder = false, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }) => {
30009
30053
  const [openIndex, setOpenIndex] = useState8(null);
30010
30054
  function groupMenus(menus = []) {
30011
30055
  const menuMap = /* @__PURE__ */ new Map();
@@ -30039,17 +30083,29 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30039
30083
  });
30040
30084
  return sortMenus(rootMenus);
30041
30085
  }
30042
- const rawTabs = useMemo5(() => {
30086
+ const rawTabs = useMemo6(() => {
30043
30087
  if (!Array.isArray(tabs)) return [];
30044
30088
  if (source === "manual") return Array.isArray(tabs) ? tabs : [];
30045
30089
  return groupMenus(tabs);
30046
30090
  }, [tabs, source, parentKey, menuNameKey, menuUrlKey]);
30047
30091
  const baseClasses = "text-foreground p-2 text-center rounded-md transition-colors";
30048
- const activeClasses = "bg-white/10 text-white";
30049
- const hoverClasses = "hover:bg-white/5";
30092
+ const activeClasses = `${bgActiveColor ?? "bg-white/10"} ${textActiveColor ?? "text-white"}`;
30093
+ const hoverClasses = `${bgActiveColor ? bgActiveColor.replace("bg-", "hover:bg-") : "hover:bg-white/5"} ${textActiveColor ? textActiveColor.replace("text-", "hover:text-") : "hover:text-white"}`;
30050
30094
  const isActive = (path) => {
30051
30095
  if (!path) return false;
30052
- return pathname === path || path !== "/" && pathname?.startsWith(path);
30096
+ const clean = (p) => p.replace(/\/+$/, "");
30097
+ const current = clean(pathname || "");
30098
+ const target = clean(path);
30099
+ if (!current || !target) return false;
30100
+ if (current === target) return true;
30101
+ if (current.startsWith(target) || target.startsWith(current)) return true;
30102
+ const currentLast = current.split("/").pop();
30103
+ const targetLast = target.split("/").pop();
30104
+ return !!currentLast && !!targetLast && currentLast === targetLast;
30105
+ };
30106
+ const isParentActive = (tab) => {
30107
+ if (!Array.isArray(tab.children)) return false;
30108
+ return tab.children.some((child) => isActive(child.url));
30053
30109
  };
30054
30110
  const router = useRouter();
30055
30111
  const [showExitDialog, setShowExitDialog] = useState8(false);
@@ -30059,7 +30115,11 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30059
30115
  if (isBuilder) {
30060
30116
  e.preventDefault();
30061
30117
  setPendingUrl(url);
30062
- setShowExitDialog(true);
30118
+ showSonnerToast({
30119
+ variant: "success",
30120
+ title: "Navigation Alert",
30121
+ description: `You will be redirected to ${url} in the built application.`
30122
+ });
30063
30123
  }
30064
30124
  },
30065
30125
  [isBuilder]
@@ -30072,7 +30132,8 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30072
30132
  };
30073
30133
  let timeout;
30074
30134
  const renderDesktopTab = (tab, index) => {
30075
- const finalClasses = [baseClasses, isActive(tab.url) ? activeClasses : hoverClasses, tab.className || ""].join(" ");
30135
+ const active = isActive(tab.url) || isParentActive(tab);
30136
+ const finalClasses = [baseClasses, active ? activeClasses : hoverClasses, tab.className || ""].join(" ");
30076
30137
  if (Array.isArray(tab.children) && tab.children.length > 0 && tab.isDropDown) {
30077
30138
  return /* @__PURE__ */ jsxs33(
30078
30139
  DropdownMenu,
@@ -30334,7 +30395,7 @@ import Link6 from "next/link";
30334
30395
  import Image4 from "next/image";
30335
30396
  import { useRouter as useRouter2 } from "next/navigation";
30336
30397
  import { DropdownMenuSeparator } from "@radix-ui/react-dropdown-menu";
30337
- import { useCallback as useCallback4, useMemo as useMemo6, useState as useState10 } from "react";
30398
+ import { useCallback as useCallback4, useMemo as useMemo7, useState as useState10 } from "react";
30338
30399
  import { Fragment as Fragment23, jsx as jsx63, jsxs as jsxs37 } from "react/jsx-runtime";
30339
30400
  function Navbar({
30340
30401
  style,
@@ -30373,7 +30434,7 @@ function Navbar({
30373
30434
  router.push(pendingUrl);
30374
30435
  }
30375
30436
  };
30376
- const formatedMenu = useMemo6(() => {
30437
+ const formatedMenu = useMemo7(() => {
30377
30438
  if (source === "state" && navList && navList.length) {
30378
30439
  return navList.map((i) => ({ ...i, header: i.name || "Menu" }));
30379
30440
  }
@@ -30551,7 +30612,7 @@ var ChartComponent = ({ className, style, loading, ...props }) => {
30551
30612
  var BarChart_default = React12.memo(ChartComponent);
30552
30613
 
30553
30614
  // src/components/Chart/PieChart.tsx
30554
- import React13, { useEffect as useEffect25, useMemo as useMemo7, useState as useState11 } from "react";
30615
+ import React13, { useEffect as useEffect25, useMemo as useMemo8, useState as useState11 } from "react";
30555
30616
  import {
30556
30617
  PieChart,
30557
30618
  Pie,
@@ -30580,18 +30641,18 @@ var DonutChart = ({ className, style, loading, ...props }) => {
30580
30641
  const showLegends = props.showLegends ?? true;
30581
30642
  const labelType = props.labelType || "inside";
30582
30643
  const canvasMode = props.canvasMode;
30583
- const data = useMemo7(() => {
30644
+ const data = useMemo8(() => {
30584
30645
  if (!Array.isArray(props.data)) return [];
30585
30646
  return props.data.map((item) => ({ ...item, color: getRandomColor() }));
30586
30647
  }, [props.data]);
30587
- const total = useMemo7(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
30648
+ const total = useMemo8(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
30588
30649
  const forceMobile = canvasMode === "mobile" || canvasMode === "tablet";
30589
30650
  const [mounted, setMounted] = useState11(false);
30590
30651
  useEffect25(() => {
30591
30652
  const timeout = setTimeout(() => setMounted(true), 100);
30592
30653
  return () => clearTimeout(timeout);
30593
30654
  }, []);
30594
- const renderLegends = useMemo7(() => {
30655
+ const renderLegends = useMemo8(() => {
30595
30656
  if (!showLegends) return null;
30596
30657
  return /* @__PURE__ */ jsx65(Fragment24, { children: data.map((d) => /* @__PURE__ */ jsxs39(
30597
30658
  "div",
@@ -30762,43 +30823,6 @@ function EmailComposer({ className, style, to, setTo, showCc, setShowCc, showBcc
30762
30823
  ] }) });
30763
30824
  }
30764
30825
 
30765
- // src/components/ui/sonner-toast.tsx
30766
- import { toast } from "sonner";
30767
- function showSonnerToast({
30768
- title,
30769
- description,
30770
- variant = "default",
30771
- duration = 3e3,
30772
- actionLabel,
30773
- onAction
30774
- }) {
30775
- const options = {
30776
- description,
30777
- duration,
30778
- action: actionLabel ? {
30779
- label: actionLabel,
30780
- onClick: onAction || (() => {
30781
- })
30782
- } : void 0
30783
- };
30784
- switch (variant) {
30785
- case "success":
30786
- toast.success(title, options);
30787
- break;
30788
- case "error":
30789
- toast.error(title, options);
30790
- break;
30791
- case "info":
30792
- toast.info(title, options);
30793
- break;
30794
- case "warning":
30795
- toast.warning(title, options);
30796
- break;
30797
- default:
30798
- toast(title, options);
30799
- }
30800
- }
30801
-
30802
30826
  // src/components/ui/sonner.tsx
30803
30827
  import { useTheme } from "next-themes";
30804
30828
  import { Toaster as Sonner } from "sonner";