@axzydev/axzy_ui_system 1.4.3 → 1.4.4

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.cjs CHANGED
@@ -7695,7 +7695,9 @@ function ITSidebar({
7695
7695
  subitemConnector = "dot",
7696
7696
  header,
7697
7697
  notification,
7698
- brand
7698
+ brand,
7699
+ onToggleCollapse,
7700
+ expandOnHover = true
7699
7701
  }) {
7700
7702
  const flat = useITFlatAppearance();
7701
7703
  const [expandedItems, setExpandedItems] = (0, import_react35.useState)(/* @__PURE__ */ new Set());
@@ -7751,6 +7753,9 @@ function ITSidebar({
7751
7753
  });
7752
7754
  }
7753
7755
  }, [navigationItems]);
7756
+ const isSidebarCollapsed = visibleOnMobile ? false : isCollapsed && !(expandOnHover && isHovering);
7757
+ const sidebarWidth = isSidebarCollapsed ? flat ? "w-[72px]" : "w-[88px]" : flat ? "w-[248px]" : "w-[280px]";
7758
+ const fixedRail = isSidebarCollapsed && !expandOnHover;
7754
7759
  const toggleExpanded = (itemId) => {
7755
7760
  const newExpanded = new Set(expandedItems);
7756
7761
  if (newExpanded.has(itemId)) newExpanded.delete(itemId);
@@ -7759,14 +7764,17 @@ function ITSidebar({
7759
7764
  };
7760
7765
  const handleItemClick = (item) => {
7761
7766
  if (item.subitems && item.subitems.length > 0) {
7762
- toggleExpanded(item.id);
7767
+ if (isSidebarCollapsed && !expandOnHover) {
7768
+ setExpandedItems((prev) => new Set(prev).add(item.id));
7769
+ onToggleCollapse?.();
7770
+ } else {
7771
+ toggleExpanded(item.id);
7772
+ }
7763
7773
  } else {
7764
7774
  if (item.action) item.action();
7765
7775
  if (onItemClick) onItemClick(item);
7766
7776
  }
7767
7777
  };
7768
- const isSidebarCollapsed = visibleOnMobile ? false : !isHovering && isCollapsed;
7769
- const sidebarWidth = isSidebarCollapsed ? "w-[88px]" : flat ? "w-[248px]" : "w-[280px]";
7770
7778
  const renderSubItem = (subitem) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("li", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
7771
7779
  "button",
7772
7780
  {
@@ -7779,7 +7787,7 @@ function ITSidebar({
7779
7787
  style: {
7780
7788
  color: subitem.isActive ? "var(--it-sidebar-active-color, var(--color-secondary-900))" : "var(--it-sidebar-label-color, var(--color-secondary-600))",
7781
7789
  backgroundColor: subitem.isActive ? "var(--it-sidebar-active-bg, var(--color-secondary-50))" : "transparent",
7782
- fontSize: "0.78rem",
7790
+ fontSize: flat ? "0.84rem" : "0.78rem",
7783
7791
  fontWeight: subitem.isActive ? 600 : 500,
7784
7792
  letterSpacing: "0.01em",
7785
7793
  marginLeft: subitemConnector === "|" ? "-1px" : "0"
@@ -7797,7 +7805,7 @@ function ITSidebar({
7797
7805
  }
7798
7806
  },
7799
7807
  children: [
7800
- subitem.isActive && subitemConnector === "|" && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7808
+ subitem.isActive && subitemConnector === "|" && !flat && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7801
7809
  "div",
7802
7810
  {
7803
7811
  className: "absolute left-0 top-1/3 bottom-1/3 w-[2.5px] rounded-r-full transition-all",
@@ -7961,10 +7969,11 @@ function ITSidebar({
7961
7969
  ),
7962
7970
  header && !isSidebarCollapsed && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "px-4 pt-4 pb-1 flex-shrink-0", children: header }),
7963
7971
  notification && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "px-4 pt-3 flex-shrink-0", children: renderNotification() }),
7964
- /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("nav", { "aria-label": "Componentes de la librer\xEDa", className: "flex-1 py-4 overflow-y-auto overflow-x-hidden custom-scrollbar px-4", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { className: "space-y-1", children: navigationItems.map((item) => {
7972
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("nav", { "aria-label": "Componentes de la librer\xEDa", className: `flex-1 py-4 custom-scrollbar ${fixedRail ? "overflow-visible" : "overflow-y-auto overflow-x-hidden"} ${flat && isSidebarCollapsed ? "px-3" : "px-4"}`, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { className: "space-y-1", children: navigationItems.map((item) => {
7965
7973
  const hasSubmenu = !!item.subitems && item.subitems.length > 0;
7966
7974
  const submenuId = `it-sidebar-submenu-${item.id}`;
7967
7975
  const { className: badgeClassName, ...badgeRest } = item.badgeProps ?? {};
7976
+ const active = !!item.isActive && !(flat && hasSubmenu && !isSidebarCollapsed);
7968
7977
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("li", { className: "relative group/navitem", children: [
7969
7978
  /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
7970
7979
  "div",
@@ -7977,18 +7986,18 @@ function ITSidebar({
7977
7986
  className: `flex items-center cursor-pointer
7978
7987
  transition-all duration-300 ease-[cubic-bezier(0.2,0,0,1)]
7979
7988
  rounded-xl relative overflow-visible
7980
- ${isSidebarCollapsed ? "justify-center p-2 mb-1" : "justify-between px-3 py-2 mb-0.5"}
7989
+ ${isSidebarCollapsed ? flat ? "justify-center h-10 mb-1" : "justify-center p-2 mb-1" : "justify-between px-3 py-2 mb-0.5"}
7981
7990
  `,
7982
7991
  style: {
7983
- backgroundColor: item.isActive ? "var(--it-sidebar-active-bg, var(--color-secondary-50))" : "transparent",
7984
- boxShadow: item.isActive && !flat ? "var(--shadow-xs)" : "none",
7985
- border: item.isActive && !flat ? "1px solid var(--it-sidebar-border, var(--color-secondary-200))" : "1px solid transparent"
7992
+ backgroundColor: active ? "var(--it-sidebar-active-bg, var(--color-secondary-50))" : "transparent",
7993
+ boxShadow: active && !flat ? "var(--shadow-xs)" : "none",
7994
+ border: active && !flat ? "1px solid var(--it-sidebar-border, var(--color-secondary-200))" : "1px solid transparent"
7986
7995
  },
7987
7996
  onMouseEnter: (e) => {
7988
- if (!item.isActive) e.currentTarget.style.backgroundColor = "var(--it-sidebar-hover-bg, var(--color-secondary-100))";
7997
+ if (!active) e.currentTarget.style.backgroundColor = "var(--it-sidebar-hover-bg, var(--color-secondary-100))";
7989
7998
  },
7990
7999
  onMouseLeave: (e) => {
7991
- if (!item.isActive) e.currentTarget.style.backgroundColor = "transparent";
8000
+ if (!active) e.currentTarget.style.backgroundColor = "transparent";
7992
8001
  },
7993
8002
  onClick: () => handleItemClick(item),
7994
8003
  onKeyDown: (e) => {
@@ -7998,7 +8007,7 @@ function ITSidebar({
7998
8007
  }
7999
8008
  },
8000
8009
  children: [
8001
- item.isActive && !isSidebarCollapsed && !flat && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
8010
+ active && !isSidebarCollapsed && !flat && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
8002
8011
  "div",
8003
8012
  {
8004
8013
  className: "absolute left-0 top-1/4 bottom-1/4 w-[3px] rounded-r-full transition-all",
@@ -8011,10 +8020,10 @@ function ITSidebar({
8011
8020
  {
8012
8021
  className: `transition-all duration-300 flex-shrink-0 flex items-center justify-center`,
8013
8022
  style: {
8014
- color: item.isActive ? "var(--it-sidebar-active-icon, var(--color-primary-500))" : "var(--it-sidebar-icon-color, #9ca3af)",
8015
- opacity: item.isActive ? 1 : 0.8,
8016
- fontSize: flat ? "1rem" : item.isActive ? "1.12rem" : "1.05rem",
8017
- filter: item.isActive && !flat ? "drop-shadow(0 0 8px rgba(255,255,255,0.2))" : "none"
8023
+ color: active ? "var(--it-sidebar-active-icon, var(--color-primary-500))" : "var(--it-sidebar-icon-color, #9ca3af)",
8024
+ opacity: active ? 1 : 0.8,
8025
+ fontSize: flat ? "1rem" : active ? "1.12rem" : "1.05rem",
8026
+ filter: active && !flat ? "drop-shadow(0 0 8px rgba(255,255,255,0.2))" : "none"
8018
8027
  },
8019
8028
  children: item.icon
8020
8029
  }
@@ -8025,9 +8034,9 @@ function ITSidebar({
8025
8034
  as: "span",
8026
8035
  className: `transition-all duration-300 truncate tracking-wide`,
8027
8036
  style: {
8028
- color: item.isActive ? "var(--it-sidebar-active-color, #ffffff)" : "var(--it-sidebar-label-color, var(--color-secondary-300))",
8037
+ color: active ? "var(--it-sidebar-active-color, #ffffff)" : "var(--it-sidebar-label-color, var(--color-secondary-300))",
8029
8038
  fontSize: flat ? "0.875rem" : "0.8rem",
8030
- fontWeight: item.isActive ? "600" : "500"
8039
+ fontWeight: active ? "600" : "500"
8031
8040
  },
8032
8041
  children: item.label
8033
8042
  }
@@ -8037,7 +8046,7 @@ function ITSidebar({
8037
8046
  "div",
8038
8047
  {
8039
8048
  className: `flex-shrink-0 transition-transform duration-300 ease-[cubic-bezier(0.2,0,0,1)] ${expandedItems.has(item.id) ? "rotate-180" : ""}`,
8040
- style: { color: item.isActive ? "var(--it-sidebar-active-color, var(--color-secondary-900))" : "var(--it-sidebar-icon-color, var(--color-secondary-500))", opacity: 0.7 },
8049
+ style: { color: active ? "var(--it-sidebar-active-color, var(--color-secondary-900))" : "var(--it-sidebar-icon-color, var(--color-secondary-500))", opacity: 0.7 },
8041
8050
  children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_fa26.FaChevronDown, { className: "w-3 h-3" })
8042
8051
  }
8043
8052
  ),
@@ -8058,7 +8067,21 @@ function ITSidebar({
8058
8067
  ]
8059
8068
  }
8060
8069
  ),
8061
- isSidebarCollapsed && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
8070
+ isSidebarCollapsed && flat && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
8071
+ "div",
8072
+ {
8073
+ role: "tooltip",
8074
+ className: "absolute left-full top-1/2 -translate-y-1/2 ml-3 px-2.5 py-1.5 rounded-lg whitespace-nowrap opacity-0 invisible group-hover/navitem:opacity-100 group-hover/navitem:visible transition-opacity duration-150 pointer-events-none z-[70]",
8075
+ style: {
8076
+ backgroundColor: "var(--it-sidebar-tooltip-bg, var(--color-secondary-900))",
8077
+ color: "var(--it-sidebar-tooltip-color, #ffffff)",
8078
+ fontSize: "0.78rem",
8079
+ fontWeight: 500
8080
+ },
8081
+ children: item.label
8082
+ }
8083
+ ),
8084
+ isSidebarCollapsed && !flat && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
8062
8085
  "div",
8063
8086
  {
8064
8087
  className: "absolute left-full top-0 ml-4 rounded-2xl opacity-0 invisible group-hover/navitem:opacity-100 group-hover/navitem:visible transition-all duration-300 pointer-events-none z-[70] min-w-[220px] overflow-hidden -translate-x-2 group-hover/navitem:translate-x-0 shadow-[0_10px_40px_-10px_rgba(0,0,0,0.15)]",
@@ -8100,7 +8123,7 @@ function ITSidebar({
8100
8123
  !isSidebarCollapsed && item.subitems && item.subitems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { id: submenuId, role: "group", "aria-label": item.label, className: `overflow-hidden transition-all duration-400 ease-[cubic-bezier(0.2,0,0,1)] ${expandedItems.has(item.id) ? "max-h-[1000px] opacity-100 mt-1" : "max-h-0 opacity-0"}`, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
8101
8124
  "ul",
8102
8125
  {
8103
- className: "ml-4 flex flex-col gap-0 py-0.5",
8126
+ className: `${flat && subitemConnector === "|" ? "ml-[21px] pl-2" : "ml-4"} flex flex-col gap-0 py-0.5`,
8104
8127
  style: {
8105
8128
  borderLeft: subitemConnector === "|" ? "1px solid var(--it-sidebar-border, var(--color-secondary-200))" : "none"
8106
8129
  },
@@ -10095,7 +10118,8 @@ function ITTopBar({
10095
10118
  onToggleMobileMenu,
10096
10119
  navItems,
10097
10120
  onNavItemClick,
10098
- hideBrandOnDesktop = false
10121
+ hideBrandOnDesktop = false,
10122
+ showDesktopMenuButton = false
10099
10123
  }) {
10100
10124
  const flat = useITFlatAppearance();
10101
10125
  const initials = (userMenu?.userName ?? "").trim().split(/\s+/).slice(0, 2).map((word) => word.charAt(0).toUpperCase()).join("");
@@ -10116,7 +10140,9 @@ function ITTopBar({
10116
10140
  showMobileMenuButton && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
10117
10141
  "button",
10118
10142
  {
10119
- className: "lg:hidden p-2.5 rounded-xl transition-colors duration-200",
10143
+ type: "button",
10144
+ "aria-label": "Men\xFA",
10145
+ className: `${showDesktopMenuButton ? "" : "lg:hidden"} p-2.5 -ml-2.5 rounded-xl transition-colors duration-200`,
10120
10146
  style: {
10121
10147
  color: "var(--it-topbar-icon, #64748b)"
10122
10148
  },
@@ -10294,7 +10320,12 @@ function ITLayout({
10294
10320
  const handleToggleCollapse = isControlled ? sidebar.onToggleCollapse ?? (() => {
10295
10321
  }) : () => setInternalCollapsed((v) => !v);
10296
10322
  const layoutTokens = theme.layout;
10297
- const reservedWidth = desktopCollapsed ? "w-[88px]" : flat ? "w-[248px]" : "w-[280px]";
10323
+ const reservedWidth = desktopCollapsed ? flat ? "w-[72px]" : "w-[88px]" : flat ? "w-[248px]" : "w-[280px]";
10324
+ const toggleByButton = sidebar.expandOnHover === false;
10325
+ const handleMenuButton = () => {
10326
+ if (toggleByButton && window.matchMedia("(min-width: 1024px)").matches) handleToggleCollapse();
10327
+ else setMobileSidebarOpen((v) => !v);
10328
+ };
10298
10329
  const brand = sidebarFullHeight ? sidebar.brand ?? { logo: topBar.logo, text: topBar.logoText } : sidebar.brand;
10299
10330
  const topBarNode = /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
10300
10331
  ITTopBar,
@@ -10302,7 +10333,8 @@ function ITLayout({
10302
10333
  ...topBar,
10303
10334
  hideBrandOnDesktop: sidebarFullHeight || topBar.hideBrandOnDesktop,
10304
10335
  showMobileMenuButton: true,
10305
- onToggleMobileMenu: () => setMobileSidebarOpen((v) => !v)
10336
+ showDesktopMenuButton: toggleByButton || topBar.showDesktopMenuButton,
10337
+ onToggleMobileMenu: handleMenuButton
10306
10338
  }
10307
10339
  );
10308
10340
  const desktopSidebar = (