baaz-custom-components 3.1.21 → 3.1.22

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
@@ -668,11 +668,7 @@ var capitalize = (text) => {
668
668
  return text[0].toUpperCase() + text.substring(1).toLowerCase();
669
669
  };
670
670
 
671
- // src/components/custom/navbar/customMenu.tsx
672
- var import_jsx_runtime9 = require("react/jsx-runtime");
673
- function isLeaf(value) {
674
- return typeof value === "string";
675
- }
671
+ // src/utils/navbarHelper.ts
676
672
  function normalizePath(path) {
677
673
  return path.startsWith("/") ? path : `/${path}`;
678
674
  }
@@ -691,7 +687,7 @@ function treeContainsPath({
691
687
  pathname
692
688
  }) {
693
689
  for (const [, value] of Object.entries(data)) {
694
- if (isLeaf(value)) {
690
+ if (typeof value === "string") {
695
691
  const full = base + normalizePath(value);
696
692
  const onlyPath = extractPathname(full);
697
693
  if (onlyPath === pathname) return true;
@@ -703,6 +699,12 @@ function treeContainsPath({
703
699
  }
704
700
  return false;
705
701
  }
702
+
703
+ // src/components/custom/navbar/customMenu.tsx
704
+ var import_jsx_runtime9 = require("react/jsx-runtime");
705
+ function isLeaf(value) {
706
+ return typeof value === "string";
707
+ }
706
708
  function MenuItems({
707
709
  data,
708
710
  base,
@@ -1471,29 +1473,50 @@ function CollapsibleContent2(_a) {
1471
1473
 
1472
1474
  // src/components/custom/navbar/nav-main.tsx
1473
1475
  var import_jsx_runtime16 = require("react/jsx-runtime");
1474
- function NavMain({ items, router }) {
1475
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SidebarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SidebarMenu, { children: items.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1476
- Collapsible,
1477
- {
1478
- asChild: true,
1479
- defaultOpen: false,
1480
- className: "group/collapsible group-data-[state=open]:bg-sidebar-accent group-data-[state=open]:text-sidebar-accent-foreground",
1481
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(SidebarMenuItem, { children: [
1482
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(SidebarMenuButton, { tooltip: entry.name, children: [
1483
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "font-medium text-lg", children: entry.name }),
1484
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react9.ChevronRight, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
1485
- ] }) }),
1486
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CollapsibleContent2, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SidebarMenuSub, { children: renderMenu(entry.routes, entry.url, router) }) })
1487
- ] })
1488
- },
1489
- entry.name
1490
- )) }) });
1476
+ function NavMain({
1477
+ items,
1478
+ router
1479
+ }) {
1480
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SidebarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SidebarMenu, { children: items.map((entry) => {
1481
+ const isGroupActive = treeContainsPath({
1482
+ data: entry.routes,
1483
+ base: entry.url,
1484
+ pathname: router.pathname
1485
+ });
1486
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1487
+ Collapsible,
1488
+ {
1489
+ asChild: true,
1490
+ defaultOpen: isGroupActive,
1491
+ className: "group/collapsible group-data-[state=open]:bg-sidebar-accent group-data-[state=open]:text-sidebar-accent-foreground",
1492
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(SidebarMenuItem, { children: [
1493
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1494
+ SidebarMenuButton,
1495
+ {
1496
+ tooltip: entry.name,
1497
+ className: isGroupActive ? "bg-sidebar-accent text-sidebar-accent-foreground" : void 0,
1498
+ children: [
1499
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "font-medium text-lg", children: entry.name }),
1500
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react9.ChevronRight, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
1501
+ ]
1502
+ }
1503
+ ) }),
1504
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CollapsibleContent2, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SidebarMenuSub, { children: renderMenu(
1505
+ entry.routes,
1506
+ entry.url,
1507
+ router
1508
+ ) }) })
1509
+ ] })
1510
+ },
1511
+ entry.name
1512
+ );
1513
+ }) }) });
1491
1514
  }
1492
1515
  function renderMenu(data, base, router) {
1493
1516
  return Object.entries(data).map(([title, value]) => {
1494
1517
  if (typeof value === "string") {
1495
1518
  const fullPath = `${base}${value.startsWith("/") ? value : `/${value}`}`;
1496
- const active = fullPath === router.pathname;
1519
+ const active = extractPathname(fullPath) === router.pathname;
1497
1520
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SidebarMenuSubItem, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1498
1521
  SidebarMenuSubButton,
1499
1522
  {
package/dist/index.mjs CHANGED
@@ -634,11 +634,7 @@ var capitalize = (text) => {
634
634
  return text[0].toUpperCase() + text.substring(1).toLowerCase();
635
635
  };
636
636
 
637
- // src/components/custom/navbar/customMenu.tsx
638
- import { Fragment, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
639
- function isLeaf(value) {
640
- return typeof value === "string";
641
- }
637
+ // src/utils/navbarHelper.ts
642
638
  function normalizePath(path) {
643
639
  return path.startsWith("/") ? path : `/${path}`;
644
640
  }
@@ -657,7 +653,7 @@ function treeContainsPath({
657
653
  pathname
658
654
  }) {
659
655
  for (const [, value] of Object.entries(data)) {
660
- if (isLeaf(value)) {
656
+ if (typeof value === "string") {
661
657
  const full = base + normalizePath(value);
662
658
  const onlyPath = extractPathname(full);
663
659
  if (onlyPath === pathname) return true;
@@ -669,6 +665,12 @@ function treeContainsPath({
669
665
  }
670
666
  return false;
671
667
  }
668
+
669
+ // src/components/custom/navbar/customMenu.tsx
670
+ import { Fragment, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
671
+ function isLeaf(value) {
672
+ return typeof value === "string";
673
+ }
672
674
  function MenuItems({
673
675
  data,
674
676
  base,
@@ -1437,29 +1439,50 @@ function CollapsibleContent2(_a) {
1437
1439
 
1438
1440
  // src/components/custom/navbar/nav-main.tsx
1439
1441
  import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
1440
- function NavMain({ items, router }) {
1441
- return /* @__PURE__ */ jsx16(SidebarGroup, { children: /* @__PURE__ */ jsx16(SidebarMenu, { children: items.map((entry) => /* @__PURE__ */ jsx16(
1442
- Collapsible,
1443
- {
1444
- asChild: true,
1445
- defaultOpen: false,
1446
- className: "group/collapsible group-data-[state=open]:bg-sidebar-accent group-data-[state=open]:text-sidebar-accent-foreground",
1447
- children: /* @__PURE__ */ jsxs13(SidebarMenuItem, { children: [
1448
- /* @__PURE__ */ jsx16(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs13(SidebarMenuButton, { tooltip: entry.name, children: [
1449
- /* @__PURE__ */ jsx16("span", { className: "font-medium text-lg", children: entry.name }),
1450
- /* @__PURE__ */ jsx16(ChevronRight, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
1451
- ] }) }),
1452
- /* @__PURE__ */ jsx16(CollapsibleContent2, { children: /* @__PURE__ */ jsx16(SidebarMenuSub, { children: renderMenu(entry.routes, entry.url, router) }) })
1453
- ] })
1454
- },
1455
- entry.name
1456
- )) }) });
1442
+ function NavMain({
1443
+ items,
1444
+ router
1445
+ }) {
1446
+ return /* @__PURE__ */ jsx16(SidebarGroup, { children: /* @__PURE__ */ jsx16(SidebarMenu, { children: items.map((entry) => {
1447
+ const isGroupActive = treeContainsPath({
1448
+ data: entry.routes,
1449
+ base: entry.url,
1450
+ pathname: router.pathname
1451
+ });
1452
+ return /* @__PURE__ */ jsx16(
1453
+ Collapsible,
1454
+ {
1455
+ asChild: true,
1456
+ defaultOpen: isGroupActive,
1457
+ className: "group/collapsible group-data-[state=open]:bg-sidebar-accent group-data-[state=open]:text-sidebar-accent-foreground",
1458
+ children: /* @__PURE__ */ jsxs13(SidebarMenuItem, { children: [
1459
+ /* @__PURE__ */ jsx16(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs13(
1460
+ SidebarMenuButton,
1461
+ {
1462
+ tooltip: entry.name,
1463
+ className: isGroupActive ? "bg-sidebar-accent text-sidebar-accent-foreground" : void 0,
1464
+ children: [
1465
+ /* @__PURE__ */ jsx16("span", { className: "font-medium text-lg", children: entry.name }),
1466
+ /* @__PURE__ */ jsx16(ChevronRight, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
1467
+ ]
1468
+ }
1469
+ ) }),
1470
+ /* @__PURE__ */ jsx16(CollapsibleContent2, { children: /* @__PURE__ */ jsx16(SidebarMenuSub, { children: renderMenu(
1471
+ entry.routes,
1472
+ entry.url,
1473
+ router
1474
+ ) }) })
1475
+ ] })
1476
+ },
1477
+ entry.name
1478
+ );
1479
+ }) }) });
1457
1480
  }
1458
1481
  function renderMenu(data, base, router) {
1459
1482
  return Object.entries(data).map(([title, value]) => {
1460
1483
  if (typeof value === "string") {
1461
1484
  const fullPath = `${base}${value.startsWith("/") ? value : `/${value}`}`;
1462
- const active = fullPath === router.pathname;
1485
+ const active = extractPathname(fullPath) === router.pathname;
1463
1486
  return /* @__PURE__ */ jsx16(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxs13(
1464
1487
  SidebarMenuSubButton,
1465
1488
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baaz-custom-components",
3
- "version": "3.1.21",
3
+ "version": "3.1.22",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "main": "dist/index.js",