@axzydev/axzy_ui_system 1.5.3 → 1.6.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.
package/dist/index.cjs CHANGED
@@ -8216,6 +8216,19 @@ function flattenSubItems(entries) {
8216
8216
  (entry) => isSubItemGroup(entry) ? entry.items : [entry]
8217
8217
  );
8218
8218
  }
8219
+ var RAIL_BADGE_MAX_CHARS = 3;
8220
+ function RailBadge({ value }) {
8221
+ const text = String(value);
8222
+ if (text.length <= RAIL_BADGE_MAX_CHARS) return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, { children: text });
8223
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
8224
+ "span",
8225
+ {
8226
+ "aria-hidden": "true",
8227
+ className: "block w-1.5 h-1.5 rounded-full",
8228
+ style: { backgroundColor: "currentColor" }
8229
+ }
8230
+ );
8231
+ }
8219
8232
  function ITSidebar({
8220
8233
  navigationItems = [],
8221
8234
  isCollapsed = false,
@@ -8286,7 +8299,9 @@ function ITSidebar({
8286
8299
  }
8287
8300
  }, [navigationItems]);
8288
8301
  const isSidebarCollapsed = visibleOnMobile ? false : isCollapsed && !(expandOnHover && isHovering);
8289
- const sidebarWidth = isSidebarCollapsed ? flat ? "w-[72px]" : "w-[88px]" : flat ? "w-[248px]" : "w-[280px]";
8302
+ const collapsedWidth = flat ? "w-[72px]" : "w-[88px]";
8303
+ const expandedWidth = flat ? "w-[248px]" : "w-[280px]";
8304
+ const sidebarWidth = isSidebarCollapsed ? collapsedWidth : expandedWidth;
8290
8305
  const fixedRail = isSidebarCollapsed && !expandOnHover;
8291
8306
  const toggleExpanded = (itemId) => {
8292
8307
  const newExpanded = new Set(expandedItems);
@@ -8398,7 +8413,7 @@ function ITSidebar({
8398
8413
  size: "sm",
8399
8414
  ...badgeRest,
8400
8415
  className: (0, import_clsx40.default)("shadow-md", badgeClassName),
8401
- children: String(count)
8416
+ children: isSidebarCollapsed ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(RailBadge, { value: count }) : String(count)
8402
8417
  }
8403
8418
  );
8404
8419
  if (isSidebarCollapsed) {
@@ -8409,7 +8424,7 @@ function ITSidebar({
8409
8424
  "aria-label": label,
8410
8425
  title: label,
8411
8426
  onClick,
8412
- className: "relative flex items-center justify-center w-full p-2 mb-1 rounded-xl transition-all duration-300",
8427
+ className: `relative flex items-center w-full h-10 mb-1 rounded-xl transition-all duration-300 ${flat ? "px-3" : "px-5"}`,
8413
8428
  style: { color: "var(--it-sidebar-icon-color, var(--color-secondary-500))" },
8414
8429
  onMouseEnter: (e) => {
8415
8430
  e.currentTarget.style.backgroundColor = "var(--it-sidebar-hover-bg, var(--color-secondary-100))";
@@ -8419,7 +8434,7 @@ function ITSidebar({
8419
8434
  },
8420
8435
  children: [
8421
8436
  icon && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "flex items-center justify-center text-[1.05rem]", children: icon }),
8422
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "absolute top-0.5 right-0.5 pointer-events-none", children: badge })
8437
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "absolute top-0.5 right-0.5 max-w-[2.1rem] overflow-hidden pointer-events-none", children: badge })
8423
8438
  ]
8424
8439
  }
8425
8440
  );
@@ -8431,7 +8446,7 @@ function ITSidebar({
8431
8446
  "aria-label": label,
8432
8447
  title: label,
8433
8448
  onClick,
8434
- className: "flex items-center gap-2.5 w-full text-left px-3 py-2 mb-1 rounded-xl transition-all duration-300",
8449
+ className: `flex items-center gap-2.5 w-full text-left h-10 mb-1 rounded-xl transition-all duration-300 ${flat ? "px-3" : "px-5"}`,
8435
8450
  style: { color: "var(--it-sidebar-label-color, var(--color-secondary-600))" },
8436
8451
  onMouseEnter: (e) => {
8437
8452
  e.currentTarget.style.backgroundColor = "var(--it-sidebar-hover-bg, var(--color-secondary-100))";
@@ -8499,9 +8514,9 @@ function ITSidebar({
8499
8514
  ]
8500
8515
  }
8501
8516
  ),
8502
- header && !isSidebarCollapsed && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "px-4 pt-4 pb-1 flex-shrink-0", children: header }),
8517
+ header && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: `px-4 pt-4 pb-1 flex-shrink-0 ${isSidebarCollapsed ? "overflow-hidden" : ""}`, children: isSidebarCollapsed ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: `${expandedWidth} invisible`, "aria-hidden": "true", children: header }) : header }),
8503
8518
  notification && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "px-4 pt-3 flex-shrink-0", children: renderNotification() }),
8504
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("nav", { "aria-label": t("sidebar.navAria"), 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_runtime58.jsx)("ul", { className: "space-y-1", children: navigationItems.map((item) => {
8519
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("nav", { "aria-label": t("sidebar.navAria"), className: `flex-1 py-4 px-4 custom-scrollbar ${fixedRail ? "overflow-visible" : "overflow-y-auto overflow-x-hidden"}`, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("ul", { className: "space-y-1", children: navigationItems.map((item) => {
8505
8520
  const hasSubmenu = !!item.subitems && item.subitems.length > 0;
8506
8521
  const submenuId = `it-sidebar-submenu-${item.id}`;
8507
8522
  const hasRenderedSubmenu = hasSubmenu && !isSidebarCollapsed;
@@ -8519,7 +8534,9 @@ function ITSidebar({
8519
8534
  className: `flex items-center cursor-pointer
8520
8535
  transition-all duration-300 ease-[cubic-bezier(0.2,0,0,1)]
8521
8536
  rounded-xl relative overflow-visible
8522
- ${isSidebarCollapsed ? flat ? "justify-center h-10 mb-1" : "justify-center p-2 mb-1" : "justify-between px-3 py-2 mb-0.5"}
8537
+ h-10
8538
+ ${flat ? "px-3" : "px-5"}
8539
+ ${isSidebarCollapsed ? "justify-start" : "justify-between"}
8523
8540
  `,
8524
8541
  style: {
8525
8542
  backgroundColor: active ? "var(--it-sidebar-active-bg, var(--color-secondary-50))" : "transparent",
@@ -8547,7 +8564,7 @@ function ITSidebar({
8547
8564
  style: { backgroundColor: "var(--it-sidebar-active-icon, var(--color-primary-500))", boxShadow: "0 0 10px var(--it-sidebar-active-icon, var(--color-primary-500))" }
8548
8565
  }
8549
8566
  ),
8550
- /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: `flex items-center ${!isSidebarCollapsed ? "gap-2.5" : "justify-center"} relative z-10 w-full`, children: [
8567
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center gap-2.5 relative z-10 w-full", children: [
8551
8568
  item.icon && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
8552
8569
  "div",
8553
8570
  {
@@ -8591,10 +8608,12 @@ function ITSidebar({
8591
8608
  ...badgeRest,
8592
8609
  className: (0, import_clsx40.default)(
8593
8610
  "absolute shadow-md",
8594
- isSidebarCollapsed ? "top-0.5 right-0.5" : "right-3 top-1/2 -translate-y-1/2",
8611
+ // En el riel no hay ancho para una etiqueta larga: el badge se
8612
+ // ancla a la esquina y se recorta, así nunca desborda ni tapa el icono.
8613
+ isSidebarCollapsed ? "top-0.5 right-0.5 max-w-[2.1rem] overflow-hidden" : "right-3 top-1/2 -translate-y-1/2",
8595
8614
  badgeClassName
8596
8615
  ),
8597
- children: String(item.badge)
8616
+ children: isSidebarCollapsed ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(RailBadge, { value: item.badge }) : String(item.badge)
8598
8617
  }
8599
8618
  )
8600
8619
  ]