@snksergio/design-system 0.37.2 → 0.38.0

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.
Files changed (47) hide show
  1. package/dist-lib/chunks/{kpi-delta-0eogwK3C.mjs → kpi-delta-BQ6waavJ.mjs} +2 -2
  2. package/dist-lib/chunks/{kpi-delta-0eogwK3C.mjs.map → kpi-delta-BQ6waavJ.mjs.map} +1 -1
  3. package/dist-lib/chunks/{kpi-delta-Cz6qAe4c.cjs → kpi-delta-NM4hUgz4.cjs} +2 -2
  4. package/dist-lib/chunks/{kpi-delta-Cz6qAe4c.cjs.map → kpi-delta-NM4hUgz4.cjs.map} +1 -1
  5. package/dist-lib/chunks/{panel-NCZKvmDE.mjs → panel-BYgb6UTx.mjs} +2 -2
  6. package/dist-lib/chunks/{panel-NCZKvmDE.mjs.map → panel-BYgb6UTx.mjs.map} +1 -1
  7. package/dist-lib/chunks/{panel-DNobvn1Z.cjs → panel-CmmbJAIs.cjs} +2 -2
  8. package/dist-lib/chunks/{panel-DNobvn1Z.cjs.map → panel-CmmbJAIs.cjs.map} +1 -1
  9. package/dist-lib/chunks/{useTheme-BeD_2lZN.cjs → useTheme-C8eZFGSb.cjs} +175 -33
  10. package/dist-lib/chunks/useTheme-C8eZFGSb.cjs.map +1 -0
  11. package/dist-lib/chunks/{useTheme-CYMBVr3I.mjs → useTheme-Chash1gR.mjs} +178 -36
  12. package/dist-lib/chunks/useTheme-Chash1gR.mjs.map +1 -0
  13. package/dist-lib/index.cjs +7 -3
  14. package/dist-lib/index.cjs.map +1 -1
  15. package/dist-lib/index.mjs +221 -217
  16. package/dist-lib/index.mjs.map +1 -1
  17. package/dist-lib/preview/chat.cjs +1 -1
  18. package/dist-lib/preview/chat.mjs +1 -1
  19. package/dist-lib/preview/clientes.cjs +2 -2
  20. package/dist-lib/preview/clientes.mjs +2 -2
  21. package/dist-lib/preview/dashboard.cjs +2 -2
  22. package/dist-lib/preview/dashboard.mjs +2 -2
  23. package/dist-lib/src/components/ui/AppShell/app-shell.d.ts +1 -1
  24. package/dist-lib/src/components/ui/AppShell/app-shell.d.ts.map +1 -1
  25. package/dist-lib/src/components/ui/AppShell/app-shell.types.d.ts +23 -3
  26. package/dist-lib/src/components/ui/AppShell/app-shell.types.d.ts.map +1 -1
  27. package/dist-lib/src/components/ui/MenuSidebar/index.d.ts +3 -1
  28. package/dist-lib/src/components/ui/MenuSidebar/index.d.ts.map +1 -1
  29. package/dist-lib/src/components/ui/MenuSidebar/menu-sidebar.d.ts +1 -1
  30. package/dist-lib/src/components/ui/MenuSidebar/menu-sidebar.d.ts.map +1 -1
  31. package/dist-lib/src/components/ui/MenuSidebar/nav-link.d.ts +29 -0
  32. package/dist-lib/src/components/ui/MenuSidebar/nav-link.d.ts.map +1 -0
  33. package/dist-lib/src/components/ui/MenuSidebar/sidebar-item.d.ts +16 -1
  34. package/dist-lib/src/components/ui/MenuSidebar/sidebar-item.d.ts.map +1 -1
  35. package/dist-lib/src/components/ui/MenuSidebar/sidebar-panel.d.ts +6 -4
  36. package/dist-lib/src/components/ui/MenuSidebar/sidebar-panel.d.ts.map +1 -1
  37. package/dist-lib/src/components/ui/MenuSidebar/sidebar-rail.d.ts +7 -3
  38. package/dist-lib/src/components/ui/MenuSidebar/sidebar-rail.d.ts.map +1 -1
  39. package/dist-lib/src/components/ui/MenuSidebar/sidebar-section.d.ts +4 -2
  40. package/dist-lib/src/components/ui/MenuSidebar/sidebar-section.d.ts.map +1 -1
  41. package/dist-lib/src/components/ui/MenuSidebar/sidebar-subgroup.d.ts +6 -3
  42. package/dist-lib/src/components/ui/MenuSidebar/sidebar-subgroup.d.ts.map +1 -1
  43. package/dist-lib/src/components/ui/MenuSidebar/sidebar.types.d.ts +56 -2
  44. package/dist-lib/src/components/ui/MenuSidebar/sidebar.types.d.ts.map +1 -1
  45. package/package.json +7 -4
  46. package/dist-lib/chunks/useTheme-BeD_2lZN.cjs.map +0 -1
  47. package/dist-lib/chunks/useTheme-CYMBVr3I.mjs.map +0 -1
@@ -1540,6 +1540,33 @@ function SidebarBrandIcon({ size = 18 }) {
1540
1540
  }
1541
1541
  );
1542
1542
  }
1543
+ const EXTERNO = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1544
+ function isExternalHref(href) {
1545
+ if (!href) return false;
1546
+ if (href.startsWith("#")) return false;
1547
+ return EXTERNO.test(href);
1548
+ }
1549
+ function isHashHref(href) {
1550
+ return !!href && href.startsWith("#");
1551
+ }
1552
+ function isModifiedClick(e) {
1553
+ return (e.button ?? 0) !== 0 || !!e.metaKey || !!e.ctrlKey || !!e.shiftKey || !!e.altKey;
1554
+ }
1555
+ function shouldPreventNavigation({
1556
+ href,
1557
+ hasHandler,
1558
+ target,
1559
+ event
1560
+ }) {
1561
+ if (!href) return false;
1562
+ if (!hasHandler) return false;
1563
+ if (event.defaultPrevented) return false;
1564
+ if (target && target !== "_self") return false;
1565
+ if (isHashHref(href)) return false;
1566
+ if (isExternalHref(href)) return false;
1567
+ if (isModifiedClick(event)) return false;
1568
+ return true;
1569
+ }
1543
1570
  function SidebarRail({
1544
1571
  contexts,
1545
1572
  activeContextId,
@@ -1548,10 +1575,21 @@ function SidebarRail({
1548
1575
  user,
1549
1576
  showAdd = false,
1550
1577
  onAddClick,
1578
+ brandHref = "/",
1579
+ onBrandClick,
1580
+ renderLink,
1551
1581
  className
1552
1582
  }) {
1553
1583
  return /* @__PURE__ */ jsxs("aside", { className: cn(sidebarRail(), className), children: [
1554
- /* @__PURE__ */ jsx("a", { href: "/", className: sidebarRailBrand(), "aria-label": "Home", children: brand ?? /* @__PURE__ */ jsx(SidebarBrandIcon, {}) }),
1584
+ /* @__PURE__ */ jsx(
1585
+ SidebarBrandLink,
1586
+ {
1587
+ href: brandHref,
1588
+ onClick: onBrandClick,
1589
+ renderLink,
1590
+ children: brand ?? /* @__PURE__ */ jsx(SidebarBrandIcon, {})
1591
+ }
1592
+ ),
1555
1593
  /* @__PURE__ */ jsxs("div", { className: sidebarRailList(), children: [
1556
1594
  contexts.map((ctx) => {
1557
1595
  const Icon = ctx.icon;
@@ -1587,8 +1625,52 @@ function SidebarRail({
1587
1625
  user !== null && /* @__PURE__ */ jsx("div", { className: sidebarRailUser(), children: user ?? /* @__PURE__ */ jsx("div", { className: sidebarRailUserDefault(), children: "SV" }) })
1588
1626
  ] });
1589
1627
  }
1628
+ function SidebarBrandLink({
1629
+ href,
1630
+ onClick,
1631
+ renderLink,
1632
+ children
1633
+ }) {
1634
+ if (!href) {
1635
+ return /* @__PURE__ */ jsx(
1636
+ "button",
1637
+ {
1638
+ type: "button",
1639
+ className: sidebarRailBrand(),
1640
+ onClick,
1641
+ "aria-label": "Home",
1642
+ children
1643
+ }
1644
+ );
1645
+ }
1646
+ const handleClick = (e) => {
1647
+ if (!renderLink) {
1648
+ const prevent = shouldPreventNavigation({ href, hasHandler: !!onClick, event: e });
1649
+ if (prevent) e.preventDefault();
1650
+ }
1651
+ onClick?.(e);
1652
+ };
1653
+ const linkProps = {
1654
+ href,
1655
+ className: sidebarRailBrand(),
1656
+ onClick: handleClick,
1657
+ "aria-label": "Home",
1658
+ children
1659
+ };
1660
+ if (renderLink) return /* @__PURE__ */ jsx(Fragment, { children: renderLink(linkProps) });
1661
+ return /* @__PURE__ */ jsx("a", { ...linkProps });
1662
+ }
1590
1663
  const SidebarItem = forwardRef(
1591
- ({ item, active, subitem, iconBrand, onClick, className }, ref) => {
1664
+ ({
1665
+ item,
1666
+ active,
1667
+ subitem,
1668
+ iconBrand,
1669
+ onClick,
1670
+ renderLink,
1671
+ interceptNavigation,
1672
+ className
1673
+ }, ref) => {
1592
1674
  const Icon = item.icon;
1593
1675
  const classes = cn(sidebarItem({ active, subitem }), className);
1594
1676
  const content = /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1604,21 +1686,30 @@ const SidebarItem = forwardRef(
1604
1686
  item.badge && /* @__PURE__ */ jsx(SidebarPill, { kind: item.badgeKind, active, children: item.badge })
1605
1687
  ] });
1606
1688
  const handleClick = (e) => {
1689
+ if (!renderLink) {
1690
+ const prevent = shouldPreventNavigation({
1691
+ href: item.href,
1692
+ hasHandler: interceptNavigation ?? !!(item.onClick || onClick),
1693
+ target: item.target,
1694
+ event: e
1695
+ });
1696
+ if (prevent) e.preventDefault();
1697
+ }
1607
1698
  if (item.onClick) item.onClick(e);
1608
1699
  onClick?.(e);
1609
1700
  };
1610
1701
  if (item.href) {
1611
- return /* @__PURE__ */ jsx(
1612
- "a",
1613
- {
1614
- ref,
1615
- href: item.href,
1616
- className: classes,
1617
- onClick: handleClick,
1618
- "aria-current": active ? "page" : void 0,
1619
- children: content
1620
- }
1621
- );
1702
+ const linkProps = {
1703
+ href: item.href,
1704
+ className: classes,
1705
+ onClick: handleClick,
1706
+ target: item.target,
1707
+ "aria-current": active ? "page" : void 0,
1708
+ ref,
1709
+ children: content
1710
+ };
1711
+ if (renderLink) return /* @__PURE__ */ jsx(Fragment, { children: renderLink(linkProps) });
1712
+ return /* @__PURE__ */ jsx("a", { ...linkProps });
1622
1713
  }
1623
1714
  return /* @__PURE__ */ jsx(
1624
1715
  "button",
@@ -1646,6 +1737,8 @@ function SidebarSubgroup({
1646
1737
  item,
1647
1738
  activeItemHref,
1648
1739
  onItemClick,
1740
+ renderLink,
1741
+ interceptNavigation,
1649
1742
  open,
1650
1743
  defaultOpen,
1651
1744
  onOpenChange,
@@ -1700,7 +1793,9 @@ function SidebarSubgroup({
1700
1793
  item: sub,
1701
1794
  subitem: true,
1702
1795
  active: sub.href !== void 0 && sub.href === activeItemHref,
1703
- onClick: () => onItemClick?.(sub)
1796
+ onClick: (e) => onItemClick?.(sub, e),
1797
+ renderLink,
1798
+ interceptNavigation
1704
1799
  },
1705
1800
  sub.href ?? sub.name
1706
1801
  )) })
@@ -1710,6 +1805,7 @@ function SidebarSection({
1710
1805
  section,
1711
1806
  open,
1712
1807
  onOpenChange,
1808
+ renderLink,
1713
1809
  className
1714
1810
  }) {
1715
1811
  const [internalOpen, setInternalOpen] = useState(section.defaultOpen ?? true);
@@ -1774,6 +1870,7 @@ function SidebarSection({
1774
1870
  {
1775
1871
  href: item.href,
1776
1872
  onClick: item.onClick,
1873
+ renderLink,
1777
1874
  title: item.name,
1778
1875
  children: [
1779
1876
  Icon ? /* @__PURE__ */ jsx(
@@ -1803,6 +1900,7 @@ function SidebarSection({
1803
1900
  {
1804
1901
  href: item.href,
1805
1902
  onClick: item.onClick,
1903
+ renderLink,
1806
1904
  title: `Conversar com ${item.name}`,
1807
1905
  children: [
1808
1906
  /* @__PURE__ */ jsx(
@@ -1834,22 +1932,34 @@ function SidebarSectionLink({
1834
1932
  href,
1835
1933
  onClick,
1836
1934
  title,
1935
+ renderLink,
1837
1936
  children
1838
1937
  }) {
1839
1938
  const handleClick = (e) => {
1840
- if (!href || href === "#") e.preventDefault();
1939
+ if (!href || href === "#") {
1940
+ e.preventDefault();
1941
+ onClick?.(e);
1942
+ return;
1943
+ }
1944
+ if (!renderLink) {
1945
+ const prevent = shouldPreventNavigation({
1946
+ href,
1947
+ hasHandler: !!onClick,
1948
+ event: e
1949
+ });
1950
+ if (prevent) e.preventDefault();
1951
+ }
1841
1952
  onClick?.(e);
1842
1953
  };
1843
- return /* @__PURE__ */ jsx(
1844
- "a",
1845
- {
1846
- href: href ?? "#",
1847
- className: sidebarSectionItem(),
1848
- onClick: handleClick,
1849
- title,
1850
- children
1851
- }
1852
- );
1954
+ const linkProps = {
1955
+ href: href ?? "#",
1956
+ className: sidebarSectionItem(),
1957
+ onClick: handleClick,
1958
+ title,
1959
+ children
1960
+ };
1961
+ if (renderLink && href && href !== "#") return /* @__PURE__ */ jsx(Fragment, { children: renderLink(linkProps) });
1962
+ return /* @__PURE__ */ jsx("a", { ...linkProps });
1853
1963
  }
1854
1964
  function SidebarPanel({
1855
1965
  context,
@@ -1858,6 +1968,8 @@ function SidebarPanel({
1858
1968
  mobile,
1859
1969
  activeItemHref,
1860
1970
  onItemClick,
1971
+ renderLink,
1972
+ interceptNavigation,
1861
1973
  contexts,
1862
1974
  onContextChange,
1863
1975
  onTitleClick,
@@ -1918,7 +2030,9 @@ function SidebarPanel({
1918
2030
  {
1919
2031
  item,
1920
2032
  activeItemHref,
1921
- onItemClick
2033
+ onItemClick,
2034
+ renderLink,
2035
+ interceptNavigation
1922
2036
  },
1923
2037
  item.name
1924
2038
  );
@@ -1928,12 +2042,21 @@ function SidebarPanel({
1928
2042
  {
1929
2043
  item,
1930
2044
  active: item.href !== void 0 && item.href === activeItemHref,
1931
- onClick: () => onItemClick?.(item)
2045
+ onClick: (e) => onItemClick?.(item, e),
2046
+ renderLink,
2047
+ interceptNavigation
1932
2048
  },
1933
2049
  item.href ?? item.name
1934
2050
  );
1935
2051
  }) }),
1936
- context.sections?.map((section) => /* @__PURE__ */ jsx(SidebarSection, { section }, section.id))
2052
+ context.sections?.map((section) => /* @__PURE__ */ jsx(
2053
+ SidebarSection,
2054
+ {
2055
+ section,
2056
+ renderLink
2057
+ },
2058
+ section.id
2059
+ ))
1937
2060
  ] }) })
1938
2061
  ]
1939
2062
  }
@@ -1988,6 +2111,9 @@ function MenuSidebar({
1988
2111
  defaultMobileOpen,
1989
2112
  onMobileOpenChange,
1990
2113
  mobileBreakpoint = "(max-width: 767px)",
2114
+ renderLink,
2115
+ brandHref,
2116
+ onBrandClick,
1991
2117
  className
1992
2118
  }) {
1993
2119
  const isMobile = useMediaQuery(mobileBreakpoint);
@@ -2022,11 +2148,12 @@ function MenuSidebar({
2022
2148
  }, []);
2023
2149
  const shouldFloat = !isMobile && !!expandOnHover && collapsed && (hoverExpanded || hoverExiting);
2024
2150
  const activeContext = contexts.find((c) => c.id === ctxId) ?? contexts[0];
2025
- const handleItemClick = (item) => {
2151
+ const interceptNavigation = !renderLink && !!onItemClick;
2152
+ const handleItemClick = (item, event) => {
2026
2153
  if (item.href && activeItemHref === void 0) {
2027
2154
  setItemHref(item.href);
2028
2155
  }
2029
- onItemClick?.(item);
2156
+ onItemClick?.(item, event);
2030
2157
  if (isMobile && item.href) setOpenMobile(false);
2031
2158
  };
2032
2159
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -2076,7 +2203,10 @@ function MenuSidebar({
2076
2203
  brand,
2077
2204
  user,
2078
2205
  showAdd: showRailAdd,
2079
- onAddClick: onRailAddClick
2206
+ onAddClick: onRailAddClick,
2207
+ brandHref,
2208
+ onBrandClick,
2209
+ renderLink
2080
2210
  }
2081
2211
  ),
2082
2212
  activeContext && /* @__PURE__ */ jsx(
@@ -2090,7 +2220,9 @@ function MenuSidebar({
2090
2220
  onItemClick: handleItemClick,
2091
2221
  contexts,
2092
2222
  onContextChange: setCtxId,
2093
- onTitleClick: onPanelTitleClick
2223
+ onTitleClick: onPanelTitleClick,
2224
+ renderLink,
2225
+ interceptNavigation
2094
2226
  }
2095
2227
  ),
2096
2228
  isMobile && openMobile && /* @__PURE__ */ jsx(
@@ -2296,6 +2428,9 @@ function AppShell({
2296
2428
  defaultActiveItemHref,
2297
2429
  activeItemHref,
2298
2430
  onItemClick,
2431
+ renderLink,
2432
+ brandHref,
2433
+ onBrandClick,
2299
2434
  // Header
2300
2435
  breadcrumb,
2301
2436
  commandGroups,
@@ -2367,6 +2502,9 @@ function AppShell({
2367
2502
  activeItemHref,
2368
2503
  defaultActiveItemHref,
2369
2504
  onItemClick,
2505
+ renderLink,
2506
+ brandHref,
2507
+ onBrandClick,
2370
2508
  user: userNode,
2371
2509
  panelCollapsed: menuCollapsed,
2372
2510
  onPanelCollapseChange: (next) => {
@@ -2493,8 +2631,12 @@ export {
2493
2631
  SidebarSubgroup as m,
2494
2632
  chipCount as n,
2495
2633
  chipVariants as o,
2496
- useControllable as p,
2497
- useMediaQuery as q,
2498
- useTheme as u
2634
+ isExternalHref as p,
2635
+ isHashHref as q,
2636
+ isModifiedClick as r,
2637
+ shouldPreventNavigation as s,
2638
+ useControllable as t,
2639
+ useTheme as u,
2640
+ useMediaQuery as v
2499
2641
  };
2500
- //# sourceMappingURL=useTheme-CYMBVr3I.mjs.map
2642
+ //# sourceMappingURL=useTheme-Chash1gR.mjs.map