beez-ui 0.9.1 → 0.11.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.
@@ -1,71 +1,195 @@
1
+ /**
2
+ * Animated application sidebar adapted from beui.dev/components/motion/animated-sidebar: the rail
3
+ * morphs its width with a spring, labels fade out of the icon rail, a shared pill follows the
4
+ * hovered and active items, submenus unfold with a stagger, and small screens get a focus-trapped
5
+ * sheet. Links route through the `BeezUIProvider` adapter and the open state keeps the
6
+ * `sidebar_state` cookie contract read by server entrypoints.
7
+ */
1
8
  import * as React from "react";
2
- import { type VariantProps } from "class-variance-authority";
3
- import { Button } from "./button.js";
4
- import { Input } from "./input.js";
5
- import { Separator } from "./separator.js";
6
- import { TooltipContent } from "./tooltip.js";
7
- type SidebarContextProps = {
8
- state: "expanded" | "collapsed";
9
+ import { type HTMLMotionProps } from "motion/react";
10
+ import { type SidebarPanelState } from "./sidebar-panel-context.js";
11
+ type SidebarState = "expanded" | "collapsed";
12
+ type SidebarSide = "left" | "right";
13
+ type SidebarVariant = "sidebar" | "floating" | "inset";
14
+ type SidebarCollapsible = "offcanvas" | "icon" | "none";
15
+ type SidebarLinkTarget = "_blank" | "_self" | "_parent" | "_top";
16
+ type SidebarContextValue = {
17
+ isMobile: boolean;
18
+ layoutId: string;
19
+ /** Sheet width; the sheet is portaled outside the wrapper that declares the CSS variables. */
20
+ mobileWidth: string;
9
21
  open: boolean;
10
- setOpen: (open: boolean) => void;
11
22
  openMobile: boolean;
23
+ reduce: boolean;
24
+ setOpen: (open: boolean) => void;
12
25
  setOpenMobile: (open: boolean) => void;
13
- isMobile: boolean;
26
+ state: SidebarState;
14
27
  toggleSidebar: () => void;
28
+ triggerRef: React.RefObject<HTMLButtonElement | null>;
15
29
  };
16
- declare function useSidebar(): SidebarContextProps;
17
- declare function SidebarProvider({ defaultOpen, storageKey, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }: React.ComponentProps<"div"> & {
30
+ /**
31
+ * Reads the sidebar state shared by `SidebarProvider`.
32
+ * @returns Open state for desktop and mobile, viewport and motion flags, and state setters.
33
+ */
34
+ declare function useSidebar(): SidebarContextValue;
35
+ /**
36
+ * Reads the state of the enclosing `Sidebar` panel, so product content can adapt to the icon rail
37
+ * without depending on its DOM attributes.
38
+ * @returns Whether the panel is collapsed to its icon rail (always false in the mobile sheet), its
39
+ * collapse mode and its side.
40
+ */
41
+ declare function useSidebarPanel(): SidebarPanelState;
42
+ type SidebarProviderStyle = React.CSSProperties & {
43
+ "--sidebar-width"?: string;
44
+ "--sidebar-width-icon"?: string;
45
+ "--sidebar-width-mobile"?: string;
46
+ };
47
+ export type SidebarProviderProps = React.ComponentProps<"div"> & {
48
+ /** Controlled desktop state. */
49
+ open?: boolean;
50
+ /** Desktop state before any interaction; server entrypoints pass the `sidebar_state` cookie here. */
18
51
  defaultOpen?: boolean;
52
+ onOpenChange?: (open: boolean) => void;
53
+ /** Controlled state of the small-screen sheet. */
54
+ openMobile?: boolean;
55
+ defaultOpenMobile?: boolean;
56
+ onOpenMobileChange?: (open: boolean) => void;
19
57
  /** Opts into local persistence without changing the shared SSR cookie contract. */
20
58
  storageKey?: string;
21
- open?: boolean;
22
- onOpenChange?: (open: boolean) => void;
23
- }): React.JSX.Element;
24
- declare function Sidebar({ side, variant, collapsible, className, children, dir, ...props }: React.ComponentProps<"div"> & {
25
- side?: "left" | "right";
26
- variant?: "sidebar" | "floating" | "inset";
27
- collapsible?: "offcanvas" | "icon" | "none";
28
- }): React.JSX.Element;
29
- declare function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
30
- declare function SidebarRail({ className, ...props }: React.ComponentProps<"button">): React.JSX.Element;
31
- declare function SidebarInset({ className, ...props }: React.ComponentProps<"main">): React.JSX.Element;
32
- declare function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>): React.JSX.Element;
59
+ /** Cookie that keeps the desktop state for server entrypoints; defaults to `sidebar_state`. */
60
+ cookieName?: string;
61
+ /** Lifetime of that cookie in seconds; defaults to seven days. */
62
+ cookieMaxAge?: number;
63
+ style?: SidebarProviderStyle;
64
+ };
65
+ /**
66
+ * Owns the open state of the sidebar, the ⌘B / Ctrl+B shortcut and the layout wrapper.
67
+ * @param props - Controlled or default state for both viewports, persistence options and wrapper attributes.
68
+ * @returns The wrapper that lays out the sidebar next to its inset.
69
+ */
70
+ declare function SidebarProvider({ children, open: openProp, defaultOpen, onOpenChange, openMobile: openMobileProp, defaultOpenMobile, onOpenMobileChange, storageKey, cookieName, cookieMaxAge, className, style, ...props }: SidebarProviderProps): React.JSX.Element;
71
+ export type SidebarProps = Omit<HTMLMotionProps<"aside">, "children"> & {
72
+ children?: React.ReactNode;
73
+ side?: SidebarSide;
74
+ variant?: SidebarVariant;
75
+ /** `icon` shrinks to an icon rail, `offcanvas` slides away, `none` stays expanded on every viewport. */
76
+ collapsible?: SidebarCollapsible;
77
+ ariaLabel?: string;
78
+ /** Classes of the inner panel that paints the sidebar surface. */
79
+ panelClassName?: string;
80
+ };
81
+ /**
82
+ * Renders the sidebar: a width-morphing rail on desktop and a sheet on small screens.
83
+ * @param props - Side, variant, collapse mode, accessible name and panel classes.
84
+ * @returns The desktop rail, the mobile sheet portal, or an always-expanded panel.
85
+ */
86
+ declare function Sidebar({ side, variant, collapsible, ariaLabel, children, className, panelClassName, style, ...props }: SidebarProps): React.JSX.Element;
87
+ /**
88
+ * Button that toggles the desktop rail or the mobile sheet; shows a panel icon unless given children.
89
+ * @param props - Native button attributes.
90
+ * @returns The toggle button.
91
+ */
92
+ declare function SidebarTrigger({ children, className, onClick, ref, type, ...props }: React.ComponentProps<"button">): React.JSX.Element;
93
+ /**
94
+ * Button that closes the sidebar on the current viewport.
95
+ * @param props - Native button attributes; the content is the consumer's icon or text.
96
+ * @returns The close button.
97
+ */
98
+ declare function SidebarClose({ className, onClick, type, ...props }: React.ComponentProps<"button">): React.JSX.Element;
99
+ /**
100
+ * Thin hit area on the sidebar edge that toggles it with the pointer.
101
+ * @param props - Native button attributes.
102
+ * @returns The rail button, outside the tab order.
103
+ */
104
+ declare function SidebarRail({ className, onClick, type, ...props }: React.ComponentProps<"button">): React.JSX.Element;
105
+ /**
106
+ * Main content area laid out next to the sidebar.
107
+ * @param props - Motion-enabled `main` attributes.
108
+ * @returns The content landmark.
109
+ */
110
+ declare function SidebarInset({ className, ...props }: HTMLMotionProps<"main">): React.JSX.Element;
33
111
  declare function SidebarHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
34
- declare function SidebarFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
35
- declare function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>): React.JSX.Element;
36
112
  declare function SidebarContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
37
- declare function SidebarGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
38
- declare function SidebarGroupLabel({ className, asChild, ...props }: React.ComponentProps<"div"> & {
39
- asChild?: boolean;
40
- }): React.JSX.Element;
41
- declare function SidebarGroupAction({ className, asChild, ...props }: React.ComponentProps<"button"> & {
113
+ declare function SidebarFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
114
+ export type SidebarLabelProps = React.ComponentProps<"span"> & {
115
+ /** Renders the child element instead of a `span`, for example a paragraph. */
42
116
  asChild?: boolean;
43
- }): React.JSX.Element;
117
+ };
118
+ /**
119
+ * Product text that only makes sense in the expanded sidebar, such as a workspace name or an empty
120
+ * state: it leaves the layout while the panel is the icon rail and always shows in the mobile sheet.
121
+ * @param props - Span attributes, or `asChild` to keep the child element.
122
+ * @returns The content, or nothing in the icon rail.
123
+ */
124
+ declare function SidebarLabel({ asChild, ...props }: SidebarLabelProps): React.JSX.Element | null;
125
+ export type SidebarBrandButtonProps = React.ComponentProps<"button"> & {
126
+ /** Square tile such as a logo or initials; it stays visible in the icon rail. */
127
+ icon: React.ReactNode;
128
+ /** Trailing affordance such as a chevron, hidden in the icon rail. */
129
+ trailing?: React.ReactNode;
130
+ };
131
+ /**
132
+ * Header row that identifies the workspace, often the trigger of a workspace switcher. It forwards
133
+ * its props and ref to the `button`, so it works as `DropdownMenuTrigger asChild`, and keeps its tile
134
+ * on the menu icon column while the label and trailing content leave in the icon rail.
135
+ * @param props - Tile, label, trailing content and native button attributes.
136
+ * @returns The brand button.
137
+ */
138
+ declare function SidebarBrandButton({ icon, trailing, children, className, type, ...props }: SidebarBrandButtonProps): React.JSX.Element;
139
+ declare function SidebarGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
140
+ /** Section heading that fades out of the icon rail and is hidden from assistive technology there. */
141
+ declare function SidebarGroupLabel({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
44
142
  declare function SidebarGroupContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
143
+ /** Menu list whose items share a hover pill that glides between them. */
45
144
  declare function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">): React.JSX.Element;
46
- declare function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
47
- declare const sidebarMenuButtonVariants: (props?: ({
48
- variant?: "default" | "outline" | null | undefined;
49
- size?: "default" | "lg" | "sm" | null | undefined;
50
- } & import("class-variance-authority/types").ClassProp) | undefined) => string;
51
- declare function SidebarMenuButton({ asChild, isActive, variant, size, tooltip, className, ...props }: React.ComponentProps<"button"> & {
52
- asChild?: boolean;
53
- isActive?: boolean;
54
- tooltip?: string | React.ComponentProps<typeof TooltipContent>;
55
- } & VariantProps<typeof sidebarMenuButtonVariants>): React.JSX.Element;
56
- declare function SidebarMenuAction({ className, asChild, showOnHover, ...props }: React.ComponentProps<"button"> & {
57
- asChild?: boolean;
58
- showOnHover?: boolean;
59
- }): React.JSX.Element;
60
- declare function SidebarMenuBadge({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
61
- declare function SidebarMenuSkeleton({ className, showIcon, ...props }: React.ComponentProps<"div"> & {
62
- showIcon?: boolean;
63
- }): React.JSX.Element;
64
- declare function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">): React.JSX.Element;
65
- declare function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
66
- declare function SidebarMenuSubButton({ asChild, size, isActive, className, ...props }: React.ComponentProps<"a"> & {
67
- asChild?: boolean;
68
- size?: "sm" | "md";
145
+ declare function SidebarMenuItem({ className, ...props }: HTMLMotionProps<"li">): React.JSX.Element;
146
+ export type SidebarMenuSubProps = Omit<HTMLMotionProps<"ul">, "children"> & {
147
+ /** Whether the submenu is unfolded; it never renders inside the icon rail. */
148
+ open: boolean;
149
+ children?: React.ReactNode;
150
+ };
151
+ /**
152
+ * Nested list that unfolds with a clip and staggered items.
153
+ * @param props - Open state and motion-enabled list attributes.
154
+ * @returns The submenu while open and the sidebar is expanded.
155
+ */
156
+ declare function SidebarMenuSub({ open, children, className, ...props }: SidebarMenuSubProps): React.JSX.Element;
157
+ declare function SidebarMenuSubItem({ className, ...props }: HTMLMotionProps<"li">): React.JSX.Element;
158
+ type SidebarActionProps = {
159
+ children: React.ReactNode;
160
+ icon?: React.ReactNode;
161
+ /** Renders a link through the `BeezUIProvider` routing adapter instead of a button. */
162
+ href?: string;
69
163
  isActive?: boolean;
70
- }): React.JSX.Element;
71
- export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
164
+ disabled?: boolean;
165
+ target?: SidebarLinkTarget;
166
+ rel?: string;
167
+ onSelect?: () => void;
168
+ className?: string;
169
+ };
170
+ export type SidebarMenuSubButtonProps = SidebarActionProps & {
171
+ /** Closes the mobile sheet after selecting; on by default. */
172
+ closeOnSelect?: boolean;
173
+ };
174
+ /**
175
+ * Submenu entry; shows a dot when no icon is given.
176
+ * @param props - Label, icon, link or select handler, active and disabled state.
177
+ * @returns The submenu link or button.
178
+ */
179
+ declare function SidebarMenuSubButton({ children, icon, href, isActive, disabled, closeOnSelect, target, rel, onSelect, className, }: SidebarMenuSubButtonProps): React.JSX.Element;
180
+ export type SidebarMenuButtonProps = SidebarActionProps & {
181
+ /** Trailing content such as a counter, hidden in the icon rail. */
182
+ badge?: React.ReactNode;
183
+ /** Marks the button as a submenu toggle and shows a rotating chevron. */
184
+ ariaExpanded?: boolean;
185
+ /** Closes the mobile sheet after selecting; defaults to on, except for submenu toggles. */
186
+ closeOnSelect?: boolean;
187
+ };
188
+ /**
189
+ * Top-level menu entry: the active one carries a pill that glides between entries, and the label
190
+ * fades out of the icon rail, leaving a string label as accessible name and native tooltip.
191
+ * @param props - Label, icon, badge, link or select handler, submenu and active state.
192
+ * @returns The menu link or button.
193
+ */
194
+ declare function SidebarMenuButton({ children, icon, badge, href, isActive, ariaExpanded, disabled, closeOnSelect, target, rel, onSelect, className, }: SidebarMenuButtonProps): React.JSX.Element;
195
+ export { Sidebar, SidebarBrandButton, SidebarClose, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarTrigger, useSidebar, useSidebarPanel, };