@marcoschwartz/lite-ui 0.25.0 → 0.25.2

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.d.mts CHANGED
@@ -73,15 +73,28 @@ interface SidebarNavProps {
73
73
  className?: string;
74
74
  }
75
75
  interface SidebarNavItemProps {
76
+ /** Icon element (alias: leftSection) */
76
77
  icon?: React.ReactNode;
78
+ /** Icon element (Mantine-compatible alias for icon) */
79
+ leftSection?: React.ReactNode;
80
+ /** Item label text */
77
81
  label: string;
82
+ /** Link URL (renders as anchor) */
78
83
  href?: string;
84
+ /** Click handler (renders as button) */
79
85
  onClick?: () => void;
86
+ /** Active/selected state */
80
87
  active?: boolean;
88
+ /** Disabled state */
81
89
  disabled?: boolean;
90
+ /** Additional CSS classes */
82
91
  className?: string;
83
92
  /** Custom component to render (e.g., Next.js Link) */
84
93
  component?: React.ElementType;
94
+ /** Nested children (for sub-navigation) */
95
+ children?: React.ReactNode;
96
+ /** Whether children are open by default */
97
+ defaultOpened?: boolean;
85
98
  }
86
99
  interface SidebarNavGroupProps {
87
100
  icon?: React.ReactNode;
package/dist/index.d.ts CHANGED
@@ -73,15 +73,28 @@ interface SidebarNavProps {
73
73
  className?: string;
74
74
  }
75
75
  interface SidebarNavItemProps {
76
+ /** Icon element (alias: leftSection) */
76
77
  icon?: React.ReactNode;
78
+ /** Icon element (Mantine-compatible alias for icon) */
79
+ leftSection?: React.ReactNode;
80
+ /** Item label text */
77
81
  label: string;
82
+ /** Link URL (renders as anchor) */
78
83
  href?: string;
84
+ /** Click handler (renders as button) */
79
85
  onClick?: () => void;
86
+ /** Active/selected state */
80
87
  active?: boolean;
88
+ /** Disabled state */
81
89
  disabled?: boolean;
90
+ /** Additional CSS classes */
82
91
  className?: string;
83
92
  /** Custom component to render (e.g., Next.js Link) */
84
93
  component?: React.ElementType;
94
+ /** Nested children (for sub-navigation) */
95
+ children?: React.ReactNode;
96
+ /** Whether children are open by default */
97
+ defaultOpened?: boolean;
85
98
  }
86
99
  interface SidebarNavGroupProps {
87
100
  icon?: React.ReactNode;
package/dist/index.js CHANGED
@@ -838,16 +838,22 @@ var SidebarNavSection = ({
838
838
  };
839
839
  var SidebarNavItem = ({
840
840
  icon,
841
+ leftSection,
841
842
  label,
842
843
  href,
843
844
  onClick,
844
845
  active = false,
845
846
  disabled = false,
846
847
  className = "",
847
- component
848
+ component,
849
+ children,
850
+ defaultOpened = false
848
851
  }) => {
849
852
  const context = useSidebarNavOptional();
850
853
  const collapsed = context?.collapsed ?? false;
854
+ const [childrenOpen, setChildrenOpen] = (0, import_react4.useState)(defaultOpened);
855
+ const iconElement = leftSection || icon;
856
+ const hasChildren = import_react4.default.Children.count(children) > 0;
851
857
  const Component = component || (href ? "a" : "button");
852
858
  const baseClasses = `
853
859
  flex items-center gap-3 w-full px-3 py-2.5 rounded-lg
@@ -858,15 +864,40 @@ var SidebarNavItem = ({
858
864
  ${collapsed ? "justify-center px-0" : ""}
859
865
  ${className}
860
866
  `;
867
+ const handleClick = () => {
868
+ if (disabled) return;
869
+ if (hasChildren) {
870
+ setChildrenOpen(!childrenOpen);
871
+ }
872
+ onClick?.();
873
+ };
861
874
  const content = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
862
- icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: `flex-shrink-0 ${collapsed ? "" : "w-5 h-5"} flex items-center justify-center`, children: icon }),
863
- !collapsed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "truncate", children: label })
875
+ iconElement && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: `flex-shrink-0 ${collapsed ? "" : "w-5 h-5"} flex items-center justify-center`, children: iconElement }),
876
+ !collapsed && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
877
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "flex-1 truncate text-left", children: label }),
878
+ hasChildren && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: `flex-shrink-0 transition-transform duration-200 ${childrenOpen ? "rotate-90" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronRightIcon, {}) })
879
+ ] })
864
880
  ] });
881
+ if (hasChildren && !collapsed) {
882
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
883
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
884
+ "button",
885
+ {
886
+ onClick: handleClick,
887
+ className: baseClasses,
888
+ "aria-disabled": disabled,
889
+ "aria-expanded": childrenOpen,
890
+ children: content
891
+ }
892
+ ),
893
+ childrenOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "ml-4 pl-3 border-l border-[hsl(var(--border))] mt-1 space-y-1", children })
894
+ ] });
895
+ }
865
896
  const element = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
866
897
  Component,
867
898
  {
868
899
  href,
869
- onClick: disabled ? void 0 : onClick,
900
+ onClick: handleClick,
870
901
  className: baseClasses,
871
902
  "aria-disabled": disabled,
872
903
  "aria-current": active ? "page" : void 0,