@validationcloud/fractal-ui 1.82.0 → 1.83.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,42 +1,64 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
1
|
import { DropdownMenu } from '../dropdown-menu/dropdown-menu';
|
|
3
|
-
|
|
2
|
+
import { IconID } from '../icon/icon';
|
|
3
|
+
export type UserDropdownUser = {
|
|
4
4
|
email: string;
|
|
5
5
|
};
|
|
6
|
-
type
|
|
7
|
-
user: UserDropdownUser
|
|
8
|
-
|
|
9
|
-
signupUrl: string;
|
|
10
|
-
logoutUrl: string;
|
|
11
|
-
accountUrl?: string;
|
|
12
|
-
/** Extra menu items rendered between account and logout. */
|
|
13
|
-
menuItems?: React.ReactNode;
|
|
14
|
-
/** Display name shown on the trigger card. Falls back to email prefix when omitted. */
|
|
6
|
+
type UserDropdownRootProps = {
|
|
7
|
+
user: UserDropdownUser;
|
|
8
|
+
/** Display name shown on the trigger. Falls back to the email prefix when omitted. */
|
|
15
9
|
displayName?: string;
|
|
16
|
-
|
|
10
|
+
trigger: React.ReactNode;
|
|
11
|
+
/** When true, the dropdown content width matches the trigger width. */
|
|
12
|
+
matchTriggerWidth?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
} & Omit<React.ComponentProps<typeof DropdownMenu>, 'trigger' | 'contentClassName' | 'contentStyle'>;
|
|
16
|
+
declare function UserDropdownRoot({ user, displayName, trigger, matchTriggerWidth, className, children, ...props }: UserDropdownRootProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
type UserDropdownTriggerProps = {
|
|
18
|
+
/** Plan tier label (e.g. "Free", "PRO \u00b7 Monthly") shown below the name. */
|
|
17
19
|
planLabel?: string;
|
|
18
|
-
/**
|
|
19
|
-
upgradeUrl?: string;
|
|
20
|
-
/** When true, renders a compact avatar-only trigger (e.g. when the sidebar is collapsed). */
|
|
21
|
-
collapsed?: boolean;
|
|
22
|
-
/** When true, renders the trigger with a card-like background (use in sidebar context). */
|
|
20
|
+
/** Render a card-like background (use in sidebar context). */
|
|
23
21
|
card?: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
/** Custom trailing content. Defaults to a chevron icon. */
|
|
23
|
+
trailing?: React.ReactNode;
|
|
24
|
+
} & React.ComponentPropsWithoutRef<'button'>;
|
|
25
|
+
declare function UserDropdownTrigger({ planLabel, card, trailing, className, ...props }: UserDropdownTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
type UserDropdownAvatarTriggerProps = React.ComponentPropsWithoutRef<'button'>;
|
|
27
|
+
declare function UserDropdownAvatarTrigger({ className, ...props }: UserDropdownAvatarTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
declare function UserDropdownUpgradeBadge(): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
declare function UserDropdownEmail(): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
type UserDropdownItemProps = {
|
|
31
|
+
href: string;
|
|
32
|
+
icon: IconID;
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
};
|
|
35
|
+
declare function UserDropdownItem({ href, icon, children }: UserDropdownItemProps): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
declare function UserDropdownUpgrade({ href }: {
|
|
37
|
+
href: string;
|
|
38
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
declare function UserDropdownAccount({ href }: {
|
|
40
|
+
href: string;
|
|
41
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
declare function UserDropdownLogout({ href }: {
|
|
43
|
+
href: string;
|
|
44
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
type UserDropdownLoggedOutProps = {
|
|
46
|
+
loginUrl: string;
|
|
47
|
+
signupUrl: string;
|
|
48
|
+
className?: string;
|
|
49
|
+
/** Extra menu items rendered inside the mobile dropdown. */
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
};
|
|
52
|
+
declare function UserDropdownLoggedOut({ loginUrl, signupUrl, className, children }: UserDropdownLoggedOutProps): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export declare const UserDropdown: typeof UserDropdownRoot & {
|
|
54
|
+
Trigger: typeof UserDropdownTrigger;
|
|
55
|
+
AvatarTrigger: typeof UserDropdownAvatarTrigger;
|
|
56
|
+
UpgradeBadge: typeof UserDropdownUpgradeBadge;
|
|
57
|
+
Email: typeof UserDropdownEmail;
|
|
58
|
+
Item: typeof UserDropdownItem;
|
|
59
|
+
Upgrade: typeof UserDropdownUpgrade;
|
|
60
|
+
Account: typeof UserDropdownAccount;
|
|
61
|
+
Logout: typeof UserDropdownLogout;
|
|
62
|
+
LoggedOut: typeof UserDropdownLoggedOut;
|
|
63
|
+
};
|
|
42
64
|
export {};
|
|
@@ -1,118 +1,152 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
2
|
+
import { jsx as e, jsxs as a, Fragment as w } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as v, use as N } from "react";
|
|
4
|
+
import U from "../../assets/default-avatar.svg.js";
|
|
5
|
+
import { Button as g } from "../button/button.js";
|
|
6
|
+
import { DropdownMenu as h, DropdownMenuItem as u } from "../dropdown-menu/dropdown-menu.js";
|
|
7
|
+
import { Icon as p } from "../icon/icon.js";
|
|
8
|
+
import { InitialsAvatar as f } from "./initials-avatar.js";
|
|
9
|
+
import { twMerge as s } from "../../lib/tailwind-merge.js";
|
|
10
|
+
const x = v(null);
|
|
11
|
+
function m() {
|
|
12
|
+
const r = N(x);
|
|
13
|
+
if (!r)
|
|
14
|
+
throw new Error("UserDropdown compound components must be rendered inside <UserDropdown>.");
|
|
15
|
+
return r;
|
|
16
|
+
}
|
|
17
|
+
function D({
|
|
10
18
|
user: r,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
planLabel: h,
|
|
18
|
-
upgradeUrl: l,
|
|
19
|
-
collapsed: g,
|
|
20
|
-
card: p,
|
|
21
|
-
className: s,
|
|
22
|
-
...f
|
|
19
|
+
displayName: n,
|
|
20
|
+
trigger: t,
|
|
21
|
+
matchTriggerWidth: o,
|
|
22
|
+
className: c,
|
|
23
|
+
children: d,
|
|
24
|
+
...i
|
|
23
25
|
}) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/* @__PURE__ */ e(x, { variant: "secondary", size: "medium", asChild: !0, children: /* @__PURE__ */ e("a", { href: c, children: "Log in" }) }),
|
|
28
|
-
/* @__PURE__ */ e(x, { variant: "primary", size: "medium", asChild: !0, children: /* @__PURE__ */ e("a", { href: d, children: "Sign up" }) })
|
|
29
|
-
] }),
|
|
30
|
-
/* @__PURE__ */ t(
|
|
31
|
-
b,
|
|
32
|
-
{
|
|
33
|
-
trigger: /* @__PURE__ */ e("img", { className: "size-7 cursor-pointer sm:hidden", src: z, alt: "User avatar" }),
|
|
34
|
-
className: o(
|
|
35
|
-
"hover:bg-neutral-60 focus-visible:ring-neutral-60 data-[state=open]:bg-neutral-60 rounded-full outline-none focus-visible:ring-2 sm:hidden",
|
|
36
|
-
s
|
|
37
|
-
),
|
|
38
|
-
...f,
|
|
39
|
-
children: [
|
|
40
|
-
/* @__PURE__ */ e(n, { asChild: !0, children: /* @__PURE__ */ e("a", { href: c, className: "tg-body", children: "Log in" }) }),
|
|
41
|
-
/* @__PURE__ */ e(n, { asChild: !0, children: /* @__PURE__ */ e("a", { href: d, className: "tg-body", children: "Sign up" }) }),
|
|
42
|
-
m
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
] });
|
|
47
|
-
const w = i ?? r.email.split("@")[0] ?? r.email;
|
|
48
|
-
return /* @__PURE__ */ t(
|
|
49
|
-
b,
|
|
26
|
+
const b = n ?? r.email.split("@")[0] ?? r.email;
|
|
27
|
+
return /* @__PURE__ */ e(x, { value: { user: r, displayName: b }, children: /* @__PURE__ */ e(
|
|
28
|
+
h,
|
|
50
29
|
{
|
|
51
|
-
trigger:
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
type: "button",
|
|
55
|
-
"aria-label": "User menu",
|
|
56
|
-
className: "group focus-visible:ring-neutral-40 flex h-14 w-16 cursor-pointer items-center justify-center rounded-xl focus:outline-none focus-visible:ring-2",
|
|
57
|
-
children: /* @__PURE__ */ e(
|
|
58
|
-
N,
|
|
59
|
-
{
|
|
60
|
-
email: r.email,
|
|
61
|
-
displayName: i,
|
|
62
|
-
className: "group-hover:brightness-125 group-data-[state=open]:brightness-125"
|
|
63
|
-
}
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
) : /* @__PURE__ */ t(
|
|
67
|
-
"button",
|
|
68
|
-
{
|
|
69
|
-
type: "button",
|
|
70
|
-
className: o(
|
|
71
|
-
"group focus-visible:ring-neutral-40 flex h-14 w-full cursor-pointer items-center gap-4 rounded-xl pr-3.5 pl-4 focus:outline-none focus-visible:ring-2",
|
|
72
|
-
p && "bg-neutral-65 hover:bg-neutral-60 shadow-[0_-6px_12px_-4px_rgba(0,0,0,0.25)]"
|
|
73
|
-
),
|
|
74
|
-
children: [
|
|
75
|
-
/* @__PURE__ */ e(N, { email: r.email, displayName: i, className: "shrink-0" }),
|
|
76
|
-
/* @__PURE__ */ t("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
77
|
-
/* @__PURE__ */ e("span", { className: "tg-body-bold text-neutral-10 truncate text-left", children: w }),
|
|
78
|
-
h && /* @__PURE__ */ e("span", { className: "tg-caption text-neutral-40 group-data-[state=open]:text-neutral-10 truncate text-left", children: h })
|
|
79
|
-
] }),
|
|
80
|
-
l ? /* @__PURE__ */ e("span", { className: "tg-caption-bold text-neutral-20 shrink-0 rounded-full border border-neutral-50 px-2.5 py-0.5", children: "Upgrade" }) : /* @__PURE__ */ e(
|
|
81
|
-
a,
|
|
82
|
-
{
|
|
83
|
-
icon: "chevron-vertical",
|
|
84
|
-
className: "text-neutral-40 group-data-[state=open]:text-neutral-10 size-3.5 shrink-0"
|
|
85
|
-
}
|
|
86
|
-
)
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
className: s,
|
|
30
|
+
trigger: t,
|
|
31
|
+
className: c,
|
|
91
32
|
contentClassName: "bg-neutral-60",
|
|
92
|
-
contentStyle:
|
|
93
|
-
...
|
|
33
|
+
contentStyle: o ? { width: "var(--radix-dropdown-menu-trigger-width)" } : void 0,
|
|
34
|
+
...i,
|
|
35
|
+
children: d
|
|
36
|
+
}
|
|
37
|
+
) });
|
|
38
|
+
}
|
|
39
|
+
function y({ planLabel: r, card: n, trailing: t, className: o, ...c }) {
|
|
40
|
+
const { user: d, displayName: i } = m();
|
|
41
|
+
return /* @__PURE__ */ a(
|
|
42
|
+
"button",
|
|
43
|
+
{
|
|
44
|
+
type: "button",
|
|
45
|
+
className: s(
|
|
46
|
+
"group focus-visible:ring-neutral-40 flex h-14 w-full cursor-pointer items-center gap-4 rounded-xl pr-3.5 pl-4 focus:outline-none focus-visible:ring-2",
|
|
47
|
+
n && "bg-neutral-65 hover:bg-neutral-60 shadow-[0_-6px_12px_-4px_rgba(0,0,0,0.25)]",
|
|
48
|
+
o
|
|
49
|
+
),
|
|
50
|
+
...c,
|
|
94
51
|
children: [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/* @__PURE__ */ e("
|
|
98
|
-
|
|
99
|
-
/* @__PURE__ */ t("div", { className: "tg-button-small text-neutral-40 flex items-center gap-3 overflow-hidden px-4 py-2.5 select-text", children: [
|
|
100
|
-
/* @__PURE__ */ e(a, { icon: "user", className: "size-4 flex-none" }),
|
|
101
|
-
/* @__PURE__ */ e("p", { className: "tg-body min-w-0 truncate", children: r.email })
|
|
52
|
+
/* @__PURE__ */ e(f, { email: d.email, displayName: i, className: "shrink-0" }),
|
|
53
|
+
/* @__PURE__ */ a("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
54
|
+
/* @__PURE__ */ e("span", { className: "tg-body-bold text-neutral-10 truncate text-left", children: i }),
|
|
55
|
+
r && /* @__PURE__ */ e("span", { className: "tg-caption text-neutral-40 group-data-[state=open]:text-neutral-10 truncate text-left", children: r })
|
|
102
56
|
] }),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/* @__PURE__ */ e("p", { className: "tg-body", children: "Log out" })
|
|
111
|
-
] }) })
|
|
57
|
+
t ?? /* @__PURE__ */ e(
|
|
58
|
+
p,
|
|
59
|
+
{
|
|
60
|
+
icon: "chevron-vertical",
|
|
61
|
+
className: "text-neutral-40 group-data-[state=open]:text-neutral-10 size-3.5 shrink-0"
|
|
62
|
+
}
|
|
63
|
+
)
|
|
112
64
|
]
|
|
113
65
|
}
|
|
114
66
|
);
|
|
115
67
|
}
|
|
68
|
+
function C({ className: r, ...n }) {
|
|
69
|
+
const { user: t, displayName: o } = m();
|
|
70
|
+
return /* @__PURE__ */ e(
|
|
71
|
+
"button",
|
|
72
|
+
{
|
|
73
|
+
type: "button",
|
|
74
|
+
"aria-label": "User menu",
|
|
75
|
+
className: s(
|
|
76
|
+
"group focus-visible:ring-neutral-40 flex h-14 w-16 cursor-pointer items-center justify-center rounded-xl focus:outline-none focus-visible:ring-2",
|
|
77
|
+
r
|
|
78
|
+
),
|
|
79
|
+
...n,
|
|
80
|
+
children: /* @__PURE__ */ e(
|
|
81
|
+
f,
|
|
82
|
+
{
|
|
83
|
+
email: t.email,
|
|
84
|
+
displayName: o,
|
|
85
|
+
className: "group-hover:brightness-125 group-data-[state=open]:brightness-125"
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
function A() {
|
|
92
|
+
return /* @__PURE__ */ e("span", { className: "tg-caption-bold text-neutral-20 shrink-0 rounded-full border border-neutral-50 px-2.5 py-0.5", children: "Upgrade" });
|
|
93
|
+
}
|
|
94
|
+
function z() {
|
|
95
|
+
const { user: r } = m();
|
|
96
|
+
return /* @__PURE__ */ a("div", { className: "tg-button-small text-neutral-40 flex items-center gap-3 overflow-hidden px-4 py-2.5 select-text", children: [
|
|
97
|
+
/* @__PURE__ */ e(p, { icon: "user", className: "size-4 flex-none" }),
|
|
98
|
+
/* @__PURE__ */ e("p", { className: "tg-body min-w-0 truncate", children: r.email })
|
|
99
|
+
] });
|
|
100
|
+
}
|
|
101
|
+
function l({ href: r, icon: n, children: t }) {
|
|
102
|
+
return /* @__PURE__ */ e(u, { asChild: !0, children: /* @__PURE__ */ a("a", { href: r, className: "flex items-center gap-3", children: [
|
|
103
|
+
/* @__PURE__ */ e(p, { icon: n, className: "size-4 flex-none text-white" }),
|
|
104
|
+
/* @__PURE__ */ e("p", { className: "tg-body", children: t })
|
|
105
|
+
] }) });
|
|
106
|
+
}
|
|
107
|
+
function L({ href: r }) {
|
|
108
|
+
return /* @__PURE__ */ e(l, { href: r, icon: "sparkles", children: "Upgrade plan" });
|
|
109
|
+
}
|
|
110
|
+
function I({ href: r }) {
|
|
111
|
+
return /* @__PURE__ */ e(l, { href: r, icon: "cog", children: "Account" });
|
|
112
|
+
}
|
|
113
|
+
function j({ href: r }) {
|
|
114
|
+
return /* @__PURE__ */ e(l, { href: r, icon: "logout", children: "Log out" });
|
|
115
|
+
}
|
|
116
|
+
function k({ loginUrl: r, signupUrl: n, className: t, children: o }) {
|
|
117
|
+
return /* @__PURE__ */ a(w, { children: [
|
|
118
|
+
/* @__PURE__ */ a("div", { className: s("hidden gap-3 sm:flex", t), children: [
|
|
119
|
+
/* @__PURE__ */ e(g, { variant: "secondary", size: "medium", asChild: !0, children: /* @__PURE__ */ e("a", { href: r, children: "Log in" }) }),
|
|
120
|
+
/* @__PURE__ */ e(g, { variant: "primary", size: "medium", asChild: !0, children: /* @__PURE__ */ e("a", { href: n, children: "Sign up" }) })
|
|
121
|
+
] }),
|
|
122
|
+
/* @__PURE__ */ a(
|
|
123
|
+
h,
|
|
124
|
+
{
|
|
125
|
+
trigger: /* @__PURE__ */ e("img", { className: "size-7 cursor-pointer sm:hidden", src: U, alt: "User avatar" }),
|
|
126
|
+
className: s(
|
|
127
|
+
"hover:bg-neutral-60 focus-visible:ring-neutral-60 data-[state=open]:bg-neutral-60 rounded-full outline-none focus-visible:ring-2 sm:hidden",
|
|
128
|
+
t
|
|
129
|
+
),
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ e(u, { asChild: !0, children: /* @__PURE__ */ e("a", { href: r, className: "tg-body", children: "Log in" }) }),
|
|
132
|
+
/* @__PURE__ */ e(u, { asChild: !0, children: /* @__PURE__ */ e("a", { href: n, className: "tg-body", children: "Sign up" }) }),
|
|
133
|
+
o
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
] });
|
|
138
|
+
}
|
|
139
|
+
const R = Object.assign(D, {
|
|
140
|
+
Trigger: y,
|
|
141
|
+
AvatarTrigger: C,
|
|
142
|
+
UpgradeBadge: A,
|
|
143
|
+
Email: z,
|
|
144
|
+
Item: l,
|
|
145
|
+
Upgrade: L,
|
|
146
|
+
Account: I,
|
|
147
|
+
Logout: j,
|
|
148
|
+
LoggedOut: k
|
|
149
|
+
});
|
|
116
150
|
export {
|
|
117
|
-
|
|
151
|
+
R as UserDropdown
|
|
118
152
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -25,5 +25,5 @@ export { Tooltip } from './components/tooltip/tooltip';
|
|
|
25
25
|
export { TooltipProvider } from './components/tooltip-provider/tooltip-provider';
|
|
26
26
|
export { TouchTarget } from './components/touch-target/touch-target';
|
|
27
27
|
export { twMerge } from './lib/tailwind-merge';
|
|
28
|
-
export { UserDropdown } from './components/user-dropdown/user-dropdown';
|
|
28
|
+
export { UserDropdown, type UserDropdownUser } from './components/user-dropdown/user-dropdown';
|
|
29
29
|
export { useScrollToBottom } from './hooks/use-scroll-to-bottom';
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@validationcloud/fractal-ui",
|
|
3
3
|
"description": "Validation Cloud's shared React component library with design tokens, Tailwind CSS utilities, and CLI tools",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.83.0",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|