@recanica/ui 0.1.0 → 0.2.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.
@@ -10,13 +10,13 @@ function AppPanel({ className, ...props }) {
10
10
  return /* @__PURE__ */ jsx("main", { "data-slot": "app-panel", className: cn("min-h-0 flex-1 overflow-y-auto overscroll-contain rounded-2xl border bg-panel", className), ...props });
11
11
  }
12
12
  function AppSidebar({ className, ...props }) {
13
- return /* @__PURE__ */ jsx("div", { "data-slot": "app-sidebar", className: cn("flex h-full flex-col gap-1 p-3", className), ...props });
13
+ return /* @__PURE__ */ jsx("div", { "data-slot": "app-sidebar", className: cn("flex h-full min-w-0 flex-col gap-1 overflow-x-hidden overflow-y-auto p-3", className), ...props });
14
14
  }
15
15
  function AppSidebarHeader({ className, ...props }) {
16
16
  return /* @__PURE__ */ jsx("div", { "data-slot": "app-sidebar-header", className: cn("mb-4 flex items-center justify-between px-2 py-1", className), ...props });
17
17
  }
18
18
  function AppSidebarSub({ className, ...props }) {
19
- return /* @__PURE__ */ jsx("div", { "data-slot": "app-sidebar-sub", className: cn("my-1 ml-5 flex flex-col border-l pl-3", className), ...props });
19
+ return /* @__PURE__ */ jsx("div", { "data-slot": "app-sidebar-sub", className: cn("my-1 ml-5 flex min-w-0 flex-col border-l pl-3", className), ...props });
20
20
  }
21
21
  export {
22
22
  AppPanel,
@@ -4,6 +4,7 @@ import { type VariantProps } from "class-variance-authority";
4
4
  * NavItem — the one selectable row: sidebar and top-nav items, list/detail rows, inbox rows, option lists.
5
5
  * `active` marks the current item (accent background + aria-current). `variant="tab"` is the icon-over-label bottom tab.
6
6
  * Renders a <button> by default; pass `as={Link}` (or "a") for navigation.
7
+ * Sidebar and sub items wrap a long label onto the next line, like any docs menu: never cut off, never scrolling sideways.
7
8
  */
8
9
  declare const navItemVariants: (props?: ({
9
10
  variant?: "default" | "pill" | "sidebar" | "sub" | "tab" | null | undefined;
@@ -13,5 +14,5 @@ type NavItemProps<T extends React.ElementType> = {
13
14
  active?: boolean;
14
15
  className?: string;
15
16
  } & VariantProps<typeof navItemVariants> & Omit<React.ComponentPropsWithoutRef<T>, "as" | "className">;
16
- declare function NavItem<T extends React.ElementType = "button">({ as, active, variant, className, ...props }: NavItemProps<T>): React.JSX.Element;
17
+ declare function NavItem<T extends React.ElementType = "button">({ as, active, variant, className, children, ...props }: NavItemProps<T>): React.JSX.Element;
17
18
  export { NavItem, navItemVariants };
@@ -1,4 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
2
3
  import { cva } from "class-variance-authority";
3
4
  import { cn } from "@recanica/ui/lib/utils";
4
5
  const navItemVariants = cva(
@@ -7,8 +8,8 @@ const navItemVariants = cva(
7
8
  variants: {
8
9
  variant: {
9
10
  default: "items-start gap-3 rounded-xl px-3 py-2.5 hover:bg-accent data-[active=true]:bg-accent data-[active=true]:text-foreground",
10
- sidebar: "items-center gap-3 rounded-lg px-3 py-2 text-sidebar-foreground hover:text-foreground data-[active=true]:bg-sidebar-accent data-[active=true]:text-foreground",
11
- sub: "items-center py-1.5 text-sidebar-foreground hover:text-foreground data-[active=true]:text-foreground",
11
+ sidebar: "items-start gap-3 rounded-lg px-3 py-2 text-sidebar-foreground [&>svg]:mt-0.5 [&>svg]:shrink-0 hover:text-foreground data-[active=true]:bg-sidebar-accent data-[active=true]:text-foreground",
12
+ sub: "items-start py-1.5 text-sidebar-foreground hover:text-foreground data-[active=true]:text-foreground",
12
13
  pill: "w-auto shrink-0 items-center rounded-full px-3 py-1.5 whitespace-nowrap text-muted-foreground hover:text-foreground data-[active=true]:bg-accent data-[active=true]:text-foreground",
13
14
  tab: "flex-col items-center gap-1 py-2.5 text-xs text-muted-foreground data-[active=true]:text-foreground"
14
15
  }
@@ -16,8 +17,10 @@ const navItemVariants = cva(
16
17
  defaultVariants: { variant: "default" }
17
18
  }
18
19
  );
19
- function NavItem({ as, active, variant, className, ...props }) {
20
+ function NavItem({ as, active, variant, className, children, ...props }) {
20
21
  const Tag = as ?? "button";
22
+ const menu = variant === "sidebar" || variant === "sub";
23
+ const label = menu ? React.Children.map(children, (c) => typeof c === "string" || typeof c === "number" ? /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 [overflow-wrap:anywhere]", children: c }) : c) : children;
21
24
  return /* @__PURE__ */ jsx(
22
25
  Tag,
23
26
  {
@@ -26,7 +29,8 @@ function NavItem({ as, active, variant, className, ...props }) {
26
29
  "aria-current": active ? "page" : void 0,
27
30
  ...Tag === "button" ? { type: "button" } : {},
28
31
  className: cn(navItemVariants({ variant }), className),
29
- ...props
32
+ ...props,
33
+ children: label
30
34
  }
31
35
  );
32
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recanica/ui",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "peerDependencies": {
21
- "@recanica/tokens": "^0.1.0",
21
+ "@recanica/tokens": "^0.2.0",
22
22
  "react": "^19",
23
23
  "react-dom": "^19"
24
24
  },