@ciridae/ui 0.3.2 → 0.3.3
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,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
import { type SidebarAccountThemeMode } from "@ciridae/ui/sidebar-account-menu-theme";
|
|
2
3
|
type SidebarAccountMenuProps = {
|
|
3
4
|
username?: string | null;
|
|
@@ -8,7 +9,8 @@ type SidebarAccountMenuProps = {
|
|
|
8
9
|
themeMode?: SidebarAccountThemeMode;
|
|
9
10
|
onThemeModeChange?: (mode: SidebarAccountThemeMode) => void;
|
|
10
11
|
className?: string;
|
|
12
|
+
children?: ReactNode;
|
|
11
13
|
};
|
|
12
|
-
declare function SidebarAccountMenu({ username, email, imageUrl, onSignOut, isSigningOut, themeMode, onThemeModeChange, className, }: SidebarAccountMenuProps): import("react").JSX.Element;
|
|
14
|
+
declare function SidebarAccountMenu({ username, email, imageUrl, onSignOut, isSigningOut, themeMode, onThemeModeChange, className, children, }: SidebarAccountMenuProps): import("react").JSX.Element;
|
|
13
15
|
export { SidebarAccountMenu };
|
|
14
16
|
export type { SidebarAccountMenuProps, SidebarAccountThemeMode };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronUpIcon, LogOutIcon } from "lucide-react";
|
|
3
3
|
import { Avatar, AvatarFallback, AvatarImage } from "@ciridae/ui/avatar";
|
|
4
4
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@ciridae/ui/dropdown-menu";
|
|
@@ -7,16 +7,16 @@ import { useSidebar } from "@ciridae/ui/sidebar/context";
|
|
|
7
7
|
import { AccountThemeSection, } from "@ciridae/ui/sidebar-account-menu-theme";
|
|
8
8
|
import { Spinner } from "@ciridae/ui/spinner";
|
|
9
9
|
import { cn } from "@ciridae/ui/utils";
|
|
10
|
-
function SidebarAccountMenu({ username, email, imageUrl, onSignOut, isSigningOut = false, themeMode, onThemeModeChange, className, }) {
|
|
10
|
+
function SidebarAccountMenu({ username, email, imageUrl, onSignOut, isSigningOut = false, themeMode, onThemeModeChange, className, children, }) {
|
|
11
11
|
const { isMobile, state } = useSidebar();
|
|
12
12
|
const label = getAccountLabel(username, email);
|
|
13
13
|
const detail = email ?? "Signed in";
|
|
14
14
|
const accountMark = getAccountMark(label);
|
|
15
15
|
const isCollapsed = state === "collapsed" && !isMobile;
|
|
16
|
-
return (_jsx(SidebarMenu, { className: cn("group-data-[collapsible=icon]:-mx-0.5", className), children: _jsx(SidebarMenuItem, { children: _jsx(AccountDropdown, { detail: detail, imageUrl: imageUrl, accountMark: accountMark, isCollapsed: isCollapsed, isSigningOut: isSigningOut, label: label, onSignOut: onSignOut, onThemeModeChange: onThemeModeChange, themeMode: themeMode }) }) }));
|
|
16
|
+
return (_jsx(SidebarMenu, { className: cn("group-data-[collapsible=icon]:-mx-0.5", className), children: _jsx(SidebarMenuItem, { children: _jsx(AccountDropdown, { detail: detail, imageUrl: imageUrl, accountMark: accountMark, isCollapsed: isCollapsed, isSigningOut: isSigningOut, label: label, onSignOut: onSignOut, onThemeModeChange: onThemeModeChange, themeMode: themeMode, children: children }) }) }));
|
|
17
17
|
}
|
|
18
|
-
function AccountDropdown({ accountMark, detail, imageUrl, isCollapsed, isSigningOut, label, onSignOut, onThemeModeChange, themeMode, }) {
|
|
19
|
-
return (_jsxs(DropdownMenu, { children: [_jsx(AccountMenuTrigger, { accountMark: accountMark, detail: detail, imageUrl: imageUrl, label: label }), _jsxs(DropdownMenuContent, { align: isCollapsed ? "end" : "start", className: cn("shadow-sm", isCollapsed ? "w-44" : "w-52"), side: isCollapsed ? "right" : "top", sideOffset: 4, children: [_jsx(AccountMenuLabel, { accountMark: accountMark, detail: detail, imageUrl: imageUrl, label: label }), _jsx(AccountThemeSection, { mode: themeMode, onModeChange: onThemeModeChange }), _jsx(DropdownMenuSeparator, {}), _jsx(AccountSignOutItem, { isSigningOut: isSigningOut, onSignOut: onSignOut })] })] }));
|
|
18
|
+
function AccountDropdown({ accountMark, detail, imageUrl, isCollapsed, isSigningOut, label, onSignOut, onThemeModeChange, themeMode, children, }) {
|
|
19
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(AccountMenuTrigger, { accountMark: accountMark, detail: detail, imageUrl: imageUrl, label: label }), _jsxs(DropdownMenuContent, { align: isCollapsed ? "end" : "start", className: cn("shadow-sm", isCollapsed ? "w-44" : "w-52"), side: isCollapsed ? "right" : "top", sideOffset: 4, children: [_jsx(AccountMenuLabel, { accountMark: accountMark, detail: detail, imageUrl: imageUrl, label: label }), _jsx(AccountThemeSection, { mode: themeMode, onModeChange: onThemeModeChange }), children ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), children] })) : null, _jsx(DropdownMenuSeparator, {}), _jsx(AccountSignOutItem, { isSigningOut: isSigningOut, onSignOut: onSignOut })] })] }));
|
|
20
20
|
}
|
|
21
21
|
function AccountMenuTrigger({ accountMark, detail, imageUrl, label, }) {
|
|
22
22
|
return (_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(SidebarMenuButton, { "aria-label": `Open account menu for ${label}`, className: cn("h-auto min-h-(--control-height) py-1", "text-sidebar-foreground/78 hover:text-sidebar-accent-foreground", "data-[state=open]:bg-sidebar-accent/45 data-[state=open]:text-sidebar-accent-foreground", "group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:p-0!"), tooltip: label, children: [_jsx(AccountAvatar, { accountMark: accountMark, imageUrl: imageUrl }), _jsx(AccountTriggerText, { detail: detail, label: label }), _jsx(ChevronUpIcon, { className: "ml-auto size-3.5 text-sidebar-foreground/42 group-data-[collapsible=icon]:hidden" })] }) }));
|