ai-design-system 0.1.108 → 0.1.110

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.
@@ -0,0 +1,42 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { fn } from "@storybook/test";
3
+ import { AccountDialog } from "./AccountDialog";
4
+
5
+ const meta = {
6
+ title: "Composites/AccountDialog",
7
+ component: AccountDialog,
8
+ tags: ["autodocs"],
9
+ parameters: {
10
+ layout: "centered",
11
+ },
12
+ args: {
13
+ onUpgrade: fn(),
14
+ onSignOut: fn(),
15
+ },
16
+ } satisfies Meta<typeof AccountDialog>;
17
+
18
+ export default meta;
19
+ type Story = StoryObj<typeof meta>;
20
+
21
+ export const Default: Story = {
22
+ args: {
23
+ user: {
24
+ name: "Rajalakshmi",
25
+ email: "rajalakshmi2655@gmail.com",
26
+ plan: "Google AI Pro",
27
+ planDescription: "You can upgrade to a Google AI Ultra plan to receive higher rate limits.",
28
+ },
29
+ },
30
+ };
31
+
32
+ export const OpenModal: Story = {
33
+ args: {
34
+ open: true,
35
+ user: {
36
+ name: "Rajalakshmi",
37
+ email: "rajalakshmi2655@gmail.com",
38
+ plan: "Google AI Pro",
39
+ planDescription: "You can upgrade to a Google AI Ultra plan to receive higher rate limits.",
40
+ },
41
+ },
42
+ };
@@ -0,0 +1,188 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { Button } from "@/components/primitives/Button";
5
+ import { Icon } from "@/components/primitives/Icon";
6
+ import {
7
+ Dialog,
8
+ DialogContent,
9
+ DialogDescription,
10
+ DialogHeader,
11
+ DialogTitle,
12
+ DialogTrigger,
13
+ } from "@/components/primitives/Dialog";
14
+ import { cn } from "@/lib/utils";
15
+
16
+ export interface AccountUser {
17
+ name?: string;
18
+ email?: string;
19
+ initial?: string;
20
+ avatarColor?: string;
21
+ plan?: string;
22
+ planDescription?: string;
23
+ [key: string]: unknown;
24
+ }
25
+
26
+ export interface AccountDialogProps extends React.ComponentPropsWithoutRef<typeof Dialog> {
27
+ user?: AccountUser;
28
+ trigger?: React.ReactNode;
29
+ showTrigger?: boolean;
30
+ onUpgrade?: () => void;
31
+ onSignOut?: () => void;
32
+ termsUrl?: string;
33
+ onTermsClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
34
+ className?: string;
35
+ }
36
+
37
+ export interface AccountButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
38
+ initial?: string;
39
+ avatarColor?: string;
40
+ }
41
+
42
+ export const AccountButton = React.forwardRef<HTMLButtonElement, AccountButtonProps>(
43
+ ({ initial = "R", avatarColor, className, ...props }, ref) => {
44
+ return (
45
+ <button
46
+ ref={ref}
47
+ type="button"
48
+ aria-label="Account details"
49
+ className={cn(
50
+ "flex items-center gap-1.5 p-1 rounded-full hover:bg-muted/50 transition-colors cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
51
+ className
52
+ )}
53
+ {...props}
54
+ >
55
+ <div
56
+ className={cn(
57
+ "w-6 h-6 rounded-full flex items-center justify-center text-xs font-semibold select-none text-white",
58
+ avatarColor ? "" : "bg-emerald-700"
59
+ )}
60
+ style={avatarColor ? { backgroundColor: avatarColor } : undefined}
61
+ >
62
+ {initial}
63
+ </div>
64
+ <Icon name="chevron-down" className="w-3.5 h-3.5 text-muted-foreground" />
65
+ </button>
66
+ );
67
+ }
68
+ );
69
+
70
+ AccountButton.displayName = "AccountButton";
71
+
72
+ export const AccountDialog = React.forwardRef<HTMLDivElement, AccountDialogProps>(
73
+ (
74
+ {
75
+ user,
76
+ trigger,
77
+ showTrigger = true,
78
+ onUpgrade,
79
+ onSignOut,
80
+ termsUrl = "/terms",
81
+ onTermsClick,
82
+ className,
83
+ children,
84
+ ...dialogProps
85
+ },
86
+ _ref
87
+ ) => {
88
+ const email = user?.email || "rajalakshmi2655@gmail.com";
89
+ const initial =
90
+ user?.initial ||
91
+ (user?.name ? user.name[0].toUpperCase() : email[0].toUpperCase());
92
+ const plan = user?.plan || "Google AI Pro";
93
+ const planDescription =
94
+ user?.planDescription ||
95
+ "You can upgrade to a Google AI Ultra plan to receive higher rate limits.";
96
+
97
+ const defaultTrigger = (
98
+ <AccountButton initial={initial} avatarColor={user?.avatarColor} />
99
+ );
100
+
101
+ return (
102
+ <Dialog {...dialogProps}>
103
+ {showTrigger && (
104
+ <DialogTrigger asChild>
105
+ {trigger ?? defaultTrigger}
106
+ </DialogTrigger>
107
+ )}
108
+ <DialogContent
109
+ className={cn(
110
+ "sm:max-w-md p-6 bg-card text-card-foreground border-border rounded-2xl shadow-2xl",
111
+ className
112
+ )}
113
+ >
114
+ <DialogHeader className="gap-1 text-left">
115
+ <DialogTitle className="text-xl font-bold tracking-tight text-foreground">
116
+ Account
117
+ </DialogTitle>
118
+ <DialogDescription className="text-xs text-muted-foreground">
119
+ Manage your plan, credentials, and general preferences.
120
+ </DialogDescription>
121
+ </DialogHeader>
122
+
123
+ <div className="mt-4">
124
+ <div className="text-xs font-semibold text-foreground/90 mb-2.5">
125
+ Account
126
+ </div>
127
+
128
+ <div className="rounded-xl border border-border bg-muted/30 divide-y divide-border overflow-hidden">
129
+ {/* Row 1: Plan Details */}
130
+ <div className="flex items-center justify-between p-4 gap-3">
131
+ <div className="min-w-0 pr-1">
132
+ <div className="text-sm font-semibold text-foreground">
133
+ Your Plan: {plan}
134
+ </div>
135
+ <p className="text-xs text-muted-foreground mt-0.5 leading-snug">
136
+ {planDescription}
137
+ </p>
138
+ </div>
139
+ <Button
140
+ size="sm"
141
+ onClick={onUpgrade}
142
+ className="shrink-0 bg-blue-600 hover:bg-blue-500 text-white font-medium text-xs px-4 py-2 rounded-lg cursor-pointer"
143
+ >
144
+ Upgrade
145
+ </Button>
146
+ </div>
147
+
148
+ {/* Row 2: Email & Sign Out */}
149
+ <div className="flex items-center justify-between p-4 gap-3">
150
+ <div className="min-w-0 pr-1">
151
+ <div className="text-sm font-semibold text-foreground">
152
+ Email
153
+ </div>
154
+ <div className="text-xs text-muted-foreground mt-0.5 font-normal truncate">
155
+ {email}
156
+ </div>
157
+ </div>
158
+ <Button
159
+ variant="outline"
160
+ size="sm"
161
+ onClick={onSignOut}
162
+ className="shrink-0 text-xs font-medium px-3.5 py-2 rounded-lg cursor-pointer"
163
+ >
164
+ Sign Out
165
+ </Button>
166
+ </div>
167
+ </div>
168
+
169
+ {/* Footer Note */}
170
+ <div className="text-xs text-muted-foreground mt-6 text-left">
171
+ By using this app, you agree to its{" "}
172
+ <a
173
+ href={termsUrl}
174
+ onClick={onTermsClick ?? ((e) => e.preventDefault())}
175
+ className="text-blue-500 hover:underline cursor-pointer"
176
+ >
177
+ Terms of Service
178
+ </a>
179
+ </div>
180
+ </div>
181
+ {children}
182
+ </DialogContent>
183
+ </Dialog>
184
+ );
185
+ }
186
+ );
187
+
188
+ AccountDialog.displayName = "AccountDialog";
@@ -0,0 +1,6 @@
1
+ export { AccountDialog, AccountButton } from "./AccountDialog";
2
+ export type {
3
+ AccountDialogProps,
4
+ AccountButtonProps,
5
+ AccountUser,
6
+ } from "./AccountDialog";
@@ -3,6 +3,5 @@ export type {
3
3
  StoryPlayerProps,
4
4
  ScenePlayerProps,
5
5
  StorySegment,
6
- StoryItem,
7
6
  SceneItem,
8
7
  } from "@/components/composites/StoryPlayer";
@@ -28,7 +28,6 @@ export interface StorySegment {
28
28
  [key: string]: unknown;
29
29
  }
30
30
 
31
- export type StoryItem = StorySegment;
32
31
  export type SceneItem = StorySegment;
33
32
 
34
33
  export interface StoryPlayerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSubmit"> {
@@ -3,6 +3,5 @@ export type {
3
3
  StoryPlayerProps,
4
4
  ScenePlayerProps,
5
5
  StorySegment,
6
- StoryItem,
7
6
  SceneItem,
8
7
  } from "./StoryPlayer";
@@ -290,3 +290,8 @@ export type { StoriesBarProps, StoryItem } from './StoriesBar'
290
290
  export { StoryPlayer, ScenePlayer } from './StoryPlayer'
291
291
  export type { StoryPlayerProps, ScenePlayerProps, StorySegment, SceneItem } from './StoryPlayer'
292
292
 
293
+ // AccountDialog Composite
294
+ export { AccountDialog, AccountButton } from './AccountDialog'
295
+ export type { AccountDialogProps, AccountButtonProps, AccountUser } from './AccountDialog'
296
+
297
+
@@ -36,8 +36,13 @@ export {
36
36
  StoriesBar,
37
37
  StoryPlayer,
38
38
  ScenePlayer,
39
+ AccountDialog,
40
+ AccountButton,
39
41
  } from './composites';
40
42
  export type {
43
+ AccountDialogProps,
44
+ AccountButtonProps,
45
+ AccountUser,
41
46
  StoriesBarProps,
42
47
  StoryItem,
43
48
  StoryPlayerProps,
package/dist/index.cjs CHANGED
@@ -2469,6 +2469,10 @@ function Dialog(_a) {
2469
2469
  var props = __objRest(_a, []);
2470
2470
  return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Root, __spreadValues({ "data-slot": "dialog" }, props));
2471
2471
  }
2472
+ function DialogTrigger(_a) {
2473
+ var props = __objRest(_a, []);
2474
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Trigger, __spreadValues({ "data-slot": "dialog-trigger" }, props));
2475
+ }
2472
2476
  function DialogPortal(_a) {
2473
2477
  var props = __objRest(_a, []);
2474
2478
  return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, __spreadValues({ "data-slot": "dialog-portal" }, props));
@@ -15181,6 +15185,141 @@ var StoryPlayer = React3__namespace.forwardRef(
15181
15185
  );
15182
15186
  StoryPlayer.displayName = "StoryPlayer";
15183
15187
  var ScenePlayer = StoryPlayer;
15188
+ var AccountButton = React3__namespace.forwardRef(
15189
+ (_a, ref) => {
15190
+ var _b = _a, { initial = "R", avatarColor, className } = _b, props = __objRest(_b, ["initial", "avatarColor", "className"]);
15191
+ return /* @__PURE__ */ jsxRuntime.jsxs(
15192
+ "button",
15193
+ __spreadProps(__spreadValues({
15194
+ ref,
15195
+ type: "button",
15196
+ "aria-label": "Account details",
15197
+ className: cn(
15198
+ "flex items-center gap-1.5 p-1 rounded-full hover:bg-muted/50 transition-colors cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
15199
+ className
15200
+ )
15201
+ }, props), {
15202
+ children: [
15203
+ /* @__PURE__ */ jsxRuntime.jsx(
15204
+ "div",
15205
+ {
15206
+ className: cn(
15207
+ "w-6 h-6 rounded-full flex items-center justify-center text-xs font-semibold select-none text-white",
15208
+ avatarColor ? "" : "bg-emerald-700"
15209
+ ),
15210
+ style: avatarColor ? { backgroundColor: avatarColor } : void 0,
15211
+ children: initial
15212
+ }
15213
+ ),
15214
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "chevron-down", className: "w-3.5 h-3.5 text-muted-foreground" })
15215
+ ]
15216
+ })
15217
+ );
15218
+ }
15219
+ );
15220
+ AccountButton.displayName = "AccountButton";
15221
+ var AccountDialog = React3__namespace.forwardRef(
15222
+ (_a, _ref) => {
15223
+ var _b = _a, {
15224
+ user,
15225
+ trigger,
15226
+ showTrigger = true,
15227
+ onUpgrade,
15228
+ onSignOut,
15229
+ termsUrl = "/terms",
15230
+ onTermsClick,
15231
+ className,
15232
+ children
15233
+ } = _b, dialogProps = __objRest(_b, [
15234
+ "user",
15235
+ "trigger",
15236
+ "showTrigger",
15237
+ "onUpgrade",
15238
+ "onSignOut",
15239
+ "termsUrl",
15240
+ "onTermsClick",
15241
+ "className",
15242
+ "children"
15243
+ ]);
15244
+ const email = (user == null ? void 0 : user.email) || "rajalakshmi2655@gmail.com";
15245
+ const initial = (user == null ? void 0 : user.initial) || ((user == null ? void 0 : user.name) ? user.name[0].toUpperCase() : email[0].toUpperCase());
15246
+ const plan = (user == null ? void 0 : user.plan) || "Google AI Pro";
15247
+ const planDescription = (user == null ? void 0 : user.planDescription) || "You can upgrade to a Google AI Ultra plan to receive higher rate limits.";
15248
+ const defaultTrigger = /* @__PURE__ */ jsxRuntime.jsx(AccountButton, { initial, avatarColor: user == null ? void 0 : user.avatarColor });
15249
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dialog2, __spreadProps(__spreadValues({}, dialogProps), { children: [
15250
+ showTrigger && /* @__PURE__ */ jsxRuntime.jsx(DialogTrigger, { asChild: true, children: trigger != null ? trigger : defaultTrigger }),
15251
+ /* @__PURE__ */ jsxRuntime.jsxs(
15252
+ DialogContent,
15253
+ {
15254
+ className: cn(
15255
+ "sm:max-w-md p-6 bg-card text-card-foreground border-border rounded-2xl shadow-2xl",
15256
+ className
15257
+ ),
15258
+ children: [
15259
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { className: "gap-1 text-left", children: [
15260
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-xl font-bold tracking-tight text-foreground", children: "Account" }),
15261
+ /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { className: "text-xs text-muted-foreground", children: "Manage your plan, credentials, and general preferences." })
15262
+ ] }),
15263
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-4", children: [
15264
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-semibold text-foreground/90 mb-2.5", children: "Account" }),
15265
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-border bg-muted/30 divide-y divide-border overflow-hidden", children: [
15266
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-4 gap-3", children: [
15267
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 pr-1", children: [
15268
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-semibold text-foreground", children: [
15269
+ "Your Plan: ",
15270
+ plan
15271
+ ] }),
15272
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-0.5 leading-snug", children: planDescription })
15273
+ ] }),
15274
+ /* @__PURE__ */ jsxRuntime.jsx(
15275
+ Button2,
15276
+ {
15277
+ size: "sm",
15278
+ onClick: onUpgrade,
15279
+ className: "shrink-0 bg-blue-600 hover:bg-blue-500 text-white font-medium text-xs px-4 py-2 rounded-lg cursor-pointer",
15280
+ children: "Upgrade"
15281
+ }
15282
+ )
15283
+ ] }),
15284
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-4 gap-3", children: [
15285
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 pr-1", children: [
15286
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold text-foreground", children: "Email" }),
15287
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground mt-0.5 font-normal truncate", children: email })
15288
+ ] }),
15289
+ /* @__PURE__ */ jsxRuntime.jsx(
15290
+ Button2,
15291
+ {
15292
+ variant: "outline",
15293
+ size: "sm",
15294
+ onClick: onSignOut,
15295
+ className: "shrink-0 text-xs font-medium px-3.5 py-2 rounded-lg cursor-pointer",
15296
+ children: "Sign Out"
15297
+ }
15298
+ )
15299
+ ] })
15300
+ ] }),
15301
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-muted-foreground mt-6 text-left", children: [
15302
+ "By using this app, you agree to its",
15303
+ " ",
15304
+ /* @__PURE__ */ jsxRuntime.jsx(
15305
+ "a",
15306
+ {
15307
+ href: termsUrl,
15308
+ onClick: onTermsClick != null ? onTermsClick : ((e) => e.preventDefault()),
15309
+ className: "text-blue-500 hover:underline cursor-pointer",
15310
+ children: "Terms of Service"
15311
+ }
15312
+ )
15313
+ ] })
15314
+ ] }),
15315
+ children
15316
+ ]
15317
+ }
15318
+ )
15319
+ ] }));
15320
+ }
15321
+ );
15322
+ AccountDialog.displayName = "AccountDialog";
15184
15323
  var SpecNavigator = React3__namespace.memo(
15185
15324
  ({ groups, selectedFileId, onFileSelect, className }) => {
15186
15325
  var _a, _b;
@@ -17874,6 +18013,8 @@ Object.defineProperty(exports, "toast", {
17874
18013
  enumerable: true,
17875
18014
  get: function () { return sonner.toast; }
17876
18015
  });
18016
+ exports.AccountButton = AccountButton;
18017
+ exports.AccountDialog = AccountDialog;
17877
18018
  exports.AgentAnnotation = AgentAnnotation;
17878
18019
  exports.AppBreadcrumb = AppBreadcrumb;
17879
18020
  exports.ApprovalCard = ApprovalCard;