@fldr/ui 0.3.5 → 0.3.7

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.
Files changed (43) hide show
  1. package/THEMING.md +1 -1
  2. package/ai/component-registry.json +962 -43
  3. package/ai/component-registry.md +1 -1
  4. package/dist/.build-complete +1 -1
  5. package/dist/blocks-source/activity-feed/activity-feed.test.tsx +75 -0
  6. package/dist/blocks-source/activity-feed/activity-feed.tsx +256 -0
  7. package/dist/blocks-source/app-shell/app-shell.test.tsx +74 -0
  8. package/dist/blocks-source/app-shell/app-shell.tsx +123 -0
  9. package/dist/blocks-source/auth-card/auth-card.test.tsx +64 -0
  10. package/dist/blocks-source/auth-card/auth-card.tsx +234 -0
  11. package/dist/blocks-source/dashboard-page/dashboard-page.tsx +167 -0
  12. package/dist/blocks-source/error-page/error-page.test.tsx +60 -0
  13. package/dist/blocks-source/error-page/error-page.tsx +97 -0
  14. package/dist/blocks-source/file-table/file-item.tsx +164 -0
  15. package/dist/blocks-source/file-table/file-table.test.tsx +82 -0
  16. package/dist/blocks-source/file-table/file-table.tsx +292 -0
  17. package/dist/blocks-source/folder-grid/folder-grid.test.tsx +54 -0
  18. package/dist/blocks-source/folder-grid/folder-grid.tsx +170 -0
  19. package/dist/blocks-source/login-page/login-page.tsx +47 -0
  20. package/dist/blocks-source/onboarding-checklist/onboarding-checklist.test.tsx +50 -0
  21. package/dist/blocks-source/onboarding-checklist/onboarding-checklist.tsx +180 -0
  22. package/dist/blocks-source/settings-section/settings-section.test.tsx +43 -0
  23. package/dist/blocks-source/settings-section/settings-section.tsx +165 -0
  24. package/dist/blocks-source/share-dialog/share-dialog.test.tsx +69 -0
  25. package/dist/blocks-source/share-dialog/share-dialog.tsx +307 -0
  26. package/dist/blocks-source/stat-grid/stat-grid.test.tsx +52 -0
  27. package/dist/blocks-source/stat-grid/stat-grid.tsx +153 -0
  28. package/dist/blocks-source/upload-dropzone/upload-dropzone.test.tsx +82 -0
  29. package/dist/blocks-source/upload-dropzone/upload-dropzone.tsx +264 -0
  30. package/dist/blocks.d.ts +780 -0
  31. package/dist/blocks.js +1664 -0
  32. package/dist/chunks/delete-resource-cmlptb61ih8s84r3.js +151 -0
  33. package/dist/chunks/{tabs-o59bv7348nh2gppm.js → tabs-cja62qojznpj99et.js} +2 -0
  34. package/dist/components/tabs.js +1 -1
  35. package/dist/delete-resource-DY-GFy2s.d.ts +48 -0
  36. package/dist/index.d.ts +4 -50
  37. package/dist/index.js +2 -147
  38. package/dist/primitives.d.ts +1 -1
  39. package/dist/styles/kumo-standalone.css +1 -1
  40. package/dist/styles/theme-fldr.css +12 -0
  41. package/dist/theming.d.ts +29 -2
  42. package/dist/theming.js +19 -4
  43. package/package.json +5 -1
@@ -0,0 +1,234 @@
1
+ import { type FormEvent, type ReactNode } from "react";
2
+ import { WarningCircleIcon } from "@phosphor-icons/react";
3
+ import { Banner } from "../../components/banner";
4
+ import { Button } from "../../components/button";
5
+ import { Input } from "../../components/input";
6
+ import { cn } from "../../utils/cn";
7
+
8
+ export type AuthCardMode = "sign-in" | "sign-up";
9
+ export type AuthCardMethod = "password" | "magic-link";
10
+
11
+ export interface AuthCardProvider {
12
+ id: string;
13
+ label: string;
14
+ icon?: ReactNode;
15
+ }
16
+
17
+ export interface AuthCardValues {
18
+ email: string;
19
+ password?: string;
20
+ name?: string;
21
+ }
22
+
23
+ export interface AuthCardLabels {
24
+ signInTitle: string;
25
+ signUpTitle: string;
26
+ name: string;
27
+ email: string;
28
+ password: string;
29
+ signInSubmit: string;
30
+ signUpSubmit: string;
31
+ magicLinkSubmit: string;
32
+ divider: string;
33
+ }
34
+
35
+ const DEFAULT_LABELS: AuthCardLabels = {
36
+ signInTitle: "Sign in to fldr",
37
+ signUpTitle: "Create your fldr account",
38
+ name: "Name",
39
+ email: "Email",
40
+ password: "Password",
41
+ signInSubmit: "Sign in",
42
+ signUpSubmit: "Create account",
43
+ magicLinkSubmit: "Email me a sign-in link",
44
+ divider: "or",
45
+ };
46
+
47
+ export interface AuthCardProps {
48
+ /** @default "sign-in" */
49
+ mode?: AuthCardMode;
50
+ /** `"magic-link"` hides the password field. @default "password" */
51
+ method?: AuthCardMethod;
52
+ /** Called with form values on native form submission. */
53
+ onSubmit: (values: AuthCardValues) => void;
54
+ /** Provider buttons rendered above the "or" divider. */
55
+ providers?: AuthCardProvider[];
56
+ /** Called when a provider button is clicked. */
57
+ onProvider?: (id: string) => void;
58
+ /** Custom provider slot; replaces `providers` when set. */
59
+ providerSlot?: ReactNode;
60
+ /** Logo rendered above the title. */
61
+ logo?: ReactNode;
62
+ /** Overrides the mode's default title. */
63
+ title?: ReactNode;
64
+ /** Secondary text below the title. */
65
+ description?: ReactNode;
66
+ /** Error message shown in a banner above the form. */
67
+ error?: ReactNode;
68
+ /** Disables inputs and shows a spinner on submit. */
69
+ loading?: boolean;
70
+ /** Footer slot, e.g. "Don't have an account? Sign up". */
71
+ footer?: ReactNode;
72
+ /** Overridable strings for i18n. */
73
+ labels?: Partial<AuthCardLabels>;
74
+ className?: string;
75
+ }
76
+
77
+ /**
78
+ * Centered sign-in / sign-up card with optional providers and magic-link mode.
79
+ *
80
+ * @example
81
+ * ```tsx
82
+ * <AuthCard
83
+ * mode="sign-in"
84
+ * providers={[{ id: "google", label: "Continue with Google" }]}
85
+ * onProvider={(id) => startOAuth(id)}
86
+ * onSubmit={({ email, password }) => signIn(email, password)}
87
+ * footer={<>Don't have an account? <a href="/sign-up">Sign up</a></>}
88
+ * />
89
+ * ```
90
+ */
91
+ export function AuthCard({
92
+ mode = "sign-in",
93
+ method = "password",
94
+ onSubmit,
95
+ providers,
96
+ onProvider,
97
+ providerSlot,
98
+ logo,
99
+ title,
100
+ description,
101
+ error,
102
+ loading = false,
103
+ footer,
104
+ labels: labelOverrides,
105
+ className,
106
+ }: AuthCardProps) {
107
+ const labels = { ...DEFAULT_LABELS, ...labelOverrides };
108
+ const isSignUp = mode === "sign-up";
109
+ const hasPassword = method === "password";
110
+ const providerContent =
111
+ providerSlot ??
112
+ (providers?.length
113
+ ? providers.map((p) => (
114
+ <Button
115
+ key={p.id}
116
+ type="button"
117
+ variant="secondary"
118
+ icon={p.icon}
119
+ disabled={loading}
120
+ onClick={() => onProvider?.(p.id)}
121
+ className="w-full justify-center"
122
+ >
123
+ {p.label}
124
+ </Button>
125
+ ))
126
+ : null);
127
+
128
+ const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
129
+ event.preventDefault();
130
+ if (loading) return;
131
+ const data = new FormData(event.currentTarget);
132
+ const get = (key: string) => {
133
+ const value = data.get(key);
134
+ return typeof value === "string" ? value : undefined;
135
+ };
136
+ onSubmit({
137
+ email: get("email") ?? "",
138
+ ...(hasPassword && { password: get("password") ?? "" }),
139
+ ...(isSignUp && { name: get("name") ?? "" }),
140
+ });
141
+ };
142
+
143
+ const submitLabel = !hasPassword
144
+ ? labels.magicLinkSubmit
145
+ : isSignUp
146
+ ? labels.signUpSubmit
147
+ : labels.signInSubmit;
148
+
149
+ return (
150
+ <div
151
+ className={cn(
152
+ "mx-auto flex w-full max-w-[360px] flex-col gap-4 rounded-xl bg-kumo-elevated p-5",
153
+ className,
154
+ )}
155
+ >
156
+ <div className="flex flex-col gap-1">
157
+ {logo && <div className="mb-3">{logo}</div>}
158
+ <h1 className="text-lg font-semibold text-kumo-default">
159
+ {title ?? (isSignUp ? labels.signUpTitle : labels.signInTitle)}
160
+ </h1>
161
+ {description && (
162
+ <p className="text-sm text-kumo-subtle">{description}</p>
163
+ )}
164
+ </div>
165
+
166
+ {error && (
167
+ <div role="alert">
168
+ <Banner
169
+ variant="error"
170
+ size="sm"
171
+ icon={<WarningCircleIcon />}
172
+ description={error}
173
+ />
174
+ </div>
175
+ )}
176
+
177
+ {providerContent && (
178
+ <>
179
+ <div className="flex flex-col gap-2">{providerContent}</div>
180
+ <div className="flex items-center gap-3 text-xs text-kumo-subtle">
181
+ <span className="h-px flex-1 bg-kumo-line" />
182
+ {labels.divider}
183
+ <span className="h-px flex-1 bg-kumo-line" />
184
+ </div>
185
+ </>
186
+ )}
187
+
188
+ <form className="flex flex-col gap-3" onSubmit={handleSubmit}>
189
+ {isSignUp && (
190
+ <Input
191
+ label={labels.name}
192
+ name="name"
193
+ autoComplete="name"
194
+ required
195
+ disabled={loading}
196
+ />
197
+ )}
198
+ <Input
199
+ label={labels.email}
200
+ name="email"
201
+ type="email"
202
+ autoComplete="email"
203
+ placeholder="you@example.com"
204
+ required
205
+ disabled={loading}
206
+ />
207
+ {hasPassword && (
208
+ <Input
209
+ label={labels.password}
210
+ name="password"
211
+ type="password"
212
+ autoComplete={isSignUp ? "new-password" : "current-password"}
213
+ required
214
+ disabled={loading}
215
+ />
216
+ )}
217
+ <Button
218
+ type="submit"
219
+ variant="primary"
220
+ loading={loading}
221
+ className="w-full justify-center"
222
+ >
223
+ {submitLabel}
224
+ </Button>
225
+ </form>
226
+
227
+ {footer && (
228
+ <div className="text-center text-sm text-kumo-subtle">{footer}</div>
229
+ )}
230
+ </div>
231
+ );
232
+ }
233
+
234
+ AuthCard.displayName = "AuthCard";
@@ -0,0 +1,167 @@
1
+ import type { ReactNode } from "react";
2
+ import { Link } from "../../components/link";
3
+ import { cn } from "../../utils/cn";
4
+ import { ActivityFeed, type ActivityFeedProps } from "../activity-feed";
5
+ import { FileTable, type FileItem } from "../file-table";
6
+ import {
7
+ OnboardingChecklist,
8
+ type OnboardingChecklistProps,
9
+ } from "../onboarding-checklist";
10
+ import { StatGrid, type StatProps } from "../stat-grid";
11
+
12
+ export interface DashboardPageLabels {
13
+ recent: string;
14
+ activity: string;
15
+ viewAll: string;
16
+ }
17
+
18
+ const DEFAULT_LABELS: DashboardPageLabels = {
19
+ recent: "Recent files",
20
+ activity: "Activity",
21
+ viewAll: "View all",
22
+ };
23
+
24
+ export interface DashboardPageProps {
25
+ /** e.g. "Good morning, Ada". */
26
+ title: ReactNode;
27
+ description?: ReactNode;
28
+ /** Header buttons, e.g. Upload and New folder. */
29
+ actions?: ReactNode;
30
+ stats?: StatProps[];
31
+ /** Shown above the activity feed until the user dismisses it. */
32
+ onboarding?: OnboardingChecklistProps;
33
+ recentFiles?: FileItem[];
34
+ onOpenFile?: (item: FileItem) => void;
35
+ /** "View all" link next to Recent files. */
36
+ allFilesHref?: string;
37
+ activity?: Omit<ActivityFeedProps, "className">;
38
+ /** Extra content under Recent files. */
39
+ children?: ReactNode;
40
+ labels?: Partial<DashboardPageLabels>;
41
+ className?: string;
42
+ }
43
+
44
+ function Panel({
45
+ title,
46
+ action,
47
+ children,
48
+ }: {
49
+ title: string;
50
+ action?: ReactNode;
51
+ children: ReactNode;
52
+ }) {
53
+ return (
54
+ <section className="flex min-w-0 flex-col gap-2">
55
+ <header className="flex items-center justify-between gap-2">
56
+ <h2 className="m-0 text-sm font-semibold text-kumo-strong">{title}</h2>
57
+ {action}
58
+ </header>
59
+ {children}
60
+ </section>
61
+ );
62
+ }
63
+
64
+ /**
65
+ * DashboardPage: the first screen after sign-in. A header, stats, recent
66
+ * files, and a side column with onboarding and activity. Render it inside
67
+ * `AppShell`; every section is optional.
68
+ *
69
+ * @example
70
+ * ```tsx
71
+ * <AppShell nav={nav} header="Home">
72
+ * <DashboardPage
73
+ * title="Good morning, Ada"
74
+ * actions={<Button variant="primary">Upload</Button>}
75
+ * stats={[{ label: "Files", value: "1,284" }]}
76
+ * recentFiles={files}
77
+ * activity={{ events }}
78
+ * />
79
+ * </AppShell>
80
+ * ```
81
+ */
82
+ export function DashboardPage({
83
+ title,
84
+ description,
85
+ actions,
86
+ stats,
87
+ onboarding,
88
+ recentFiles,
89
+ onOpenFile,
90
+ allFilesHref,
91
+ activity,
92
+ children,
93
+ labels: labelsProp,
94
+ className,
95
+ }: DashboardPageProps) {
96
+ const labels = { ...DEFAULT_LABELS, ...labelsProp };
97
+ const hasSide = Boolean(onboarding || activity);
98
+
99
+ return (
100
+ <div
101
+ className={cn(
102
+ "@container mx-auto flex w-full max-w-6xl flex-col gap-5 p-4 md:p-6",
103
+ className,
104
+ )}
105
+ >
106
+ <header className="flex flex-wrap items-end justify-between gap-3">
107
+ <div className="flex min-w-0 flex-col gap-0.5">
108
+ <h1 className="m-0 text-xl font-semibold text-kumo-strong">
109
+ {title}
110
+ </h1>
111
+ {description && (
112
+ <p className="m-0 text-sm text-kumo-subtle">{description}</p>
113
+ )}
114
+ </div>
115
+ {actions && <div className="flex items-center gap-2">{actions}</div>}
116
+ </header>
117
+
118
+ {stats && stats.length > 0 && (
119
+ <StatGrid
120
+ items={stats}
121
+ columns={Math.min(4, Math.max(2, stats.length)) as 2 | 3 | 4}
122
+ />
123
+ )}
124
+
125
+ <div
126
+ className={cn(
127
+ "grid grid-cols-1 gap-5",
128
+ // Container query: the side column only appears when the page itself is wide,
129
+ // not just the viewport (it usually sits inside AppShell).
130
+ hasSide && "@4xl:grid-cols-[minmax(0,1fr)_18rem]",
131
+ )}
132
+ >
133
+ <div className="flex min-w-0 flex-col gap-5">
134
+ {recentFiles && (
135
+ <Panel
136
+ title={labels.recent}
137
+ action={
138
+ allFilesHref && (
139
+ <Link href={allFilesHref} className="text-sm">
140
+ {labels.viewAll}
141
+ </Link>
142
+ )
143
+ }
144
+ >
145
+ <FileTable
146
+ items={recentFiles}
147
+ selectable={false}
148
+ onOpen={onOpenFile}
149
+ />
150
+ </Panel>
151
+ )}
152
+ {children}
153
+ </div>
154
+ {hasSide && (
155
+ <aside className="flex min-w-0 flex-col gap-5">
156
+ {onboarding && <OnboardingChecklist {...onboarding} />}
157
+ {activity && (
158
+ <Panel title={labels.activity}>
159
+ <ActivityFeed {...activity} />
160
+ </Panel>
161
+ )}
162
+ </aside>
163
+ )}
164
+ </div>
165
+ </div>
166
+ );
167
+ }
@@ -0,0 +1,60 @@
1
+ import { describe, expect, it } from "vite-plus/test";
2
+ import { render, screen } from "@testing-library/react";
3
+ import { DashboardPage } from "../dashboard-page";
4
+ import { LoginPage } from "../login-page";
5
+ import { ErrorPage } from "./error-page";
6
+
7
+ describe("ErrorPage", () => {
8
+ it("uses default copy for the status and links home", () => {
9
+ render(
10
+ <ErrorPage status={404} homeHref="/files" homeLabel="Back to files" />,
11
+ );
12
+ expect(
13
+ screen.getByRole("heading", { name: "Page not found" }),
14
+ ).toBeTruthy();
15
+ expect(
16
+ screen.getByRole("link", { name: "Back to files" }).getAttribute("href"),
17
+ ).toBe("/files");
18
+ });
19
+
20
+ it("falls back to the 500 copy for unknown statuses and can hide the home link", () => {
21
+ render(<ErrorPage status={502} homeHref={null} />);
22
+ expect(
23
+ screen.getByRole("heading", { name: "Something went wrong" }),
24
+ ).toBeTruthy();
25
+ expect(screen.queryByRole("link")).toBeNull();
26
+ });
27
+ });
28
+
29
+ describe("LoginPage", () => {
30
+ it("wraps AuthCard with logo and legal text", () => {
31
+ render(
32
+ <LoginPage
33
+ logo={<span>fldr</span>}
34
+ legal="By continuing you agree."
35
+ onSubmit={() => {}}
36
+ />,
37
+ );
38
+ expect(screen.getByText("fldr")).toBeTruthy();
39
+ expect(screen.getByText("By continuing you agree.")).toBeTruthy();
40
+ expect(screen.getByLabelText(/email/i)).toBeTruthy();
41
+ });
42
+ });
43
+
44
+ describe("DashboardPage", () => {
45
+ it("renders only the sections it is given", () => {
46
+ render(
47
+ <DashboardPage
48
+ title="Good morning, Ada"
49
+ stats={[{ label: "Files", value: "1,284" }]}
50
+ recentFiles={[{ id: "1", name: "w2.pdf", kind: "pdf" }]}
51
+ />,
52
+ );
53
+ expect(
54
+ screen.getByRole("heading", { name: "Good morning, Ada" }),
55
+ ).toBeTruthy();
56
+ expect(screen.getByText("1,284")).toBeTruthy();
57
+ expect(screen.getByText("w2.pdf")).toBeTruthy();
58
+ expect(screen.queryByText("Activity")).toBeNull();
59
+ });
60
+ });
@@ -0,0 +1,97 @@
1
+ import type { ReactNode } from "react";
2
+ import { LinkButton } from "../../components/button";
3
+ import { cn } from "../../utils/cn";
4
+
5
+ const DEFAULT_COPY: Record<number, { title: string; description: string }> = {
6
+ 403: {
7
+ title: "You don't have access",
8
+ description: "Ask the owner to share it with you, or switch accounts.",
9
+ },
10
+ 404: {
11
+ title: "Page not found",
12
+ description: "This page doesn't exist or was moved.",
13
+ },
14
+ 500: {
15
+ title: "Something went wrong",
16
+ description: "We couldn't load this page. Try again in a moment.",
17
+ },
18
+ };
19
+
20
+ export interface ErrorPageProps {
21
+ /** HTTP-style status. 403, 404 and 500 come with default copy. @default 404 */
22
+ status?: number;
23
+ title?: string;
24
+ description?: ReactNode;
25
+ /** Where the primary button goes. Pass `null` to hide it. @default "/" */
26
+ homeHref?: string | null;
27
+ /** @default "Go home" */
28
+ homeLabel?: string;
29
+ /** Extra actions after the home button, e.g. "Contact support". */
30
+ actions?: ReactNode;
31
+ /** Shown above the status, e.g. the product mark. */
32
+ logo?: ReactNode;
33
+ /** Small print under the actions, e.g. a request ID. */
34
+ details?: ReactNode;
35
+ /** Fill the viewport. Set false to render inside a layout. @default true */
36
+ fullScreen?: boolean;
37
+ className?: string;
38
+ }
39
+
40
+ /**
41
+ * ErrorPage: a quiet 404 / 403 / 500 page with a way back.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * <ErrorPage status={404} homeHref="/files" homeLabel="Back to files" />
46
+ * <ErrorPage status={500} details="Request ID 7f3a…" actions={<Button onClick={retry}>Retry</Button>} />
47
+ * ```
48
+ */
49
+ export function ErrorPage({
50
+ status = 404,
51
+ title,
52
+ description,
53
+ homeHref = "/",
54
+ homeLabel = "Go home",
55
+ actions,
56
+ logo,
57
+ details,
58
+ fullScreen = true,
59
+ className,
60
+ }: ErrorPageProps) {
61
+ const copy = DEFAULT_COPY[status] ?? DEFAULT_COPY[500];
62
+ return (
63
+ <main
64
+ className={cn(
65
+ "flex w-full items-center justify-center bg-kumo-canvas px-4 py-12 text-kumo-default",
66
+ fullScreen && "min-h-dvh",
67
+ className,
68
+ )}
69
+ >
70
+ <div className="flex w-full max-w-sm flex-col items-start gap-3">
71
+ {logo}
72
+ <span className="font-mono text-sm text-kumo-subtle tabular-nums">
73
+ {status}
74
+ </span>
75
+ <h1 className="m-0 text-2xl font-semibold text-kumo-strong">
76
+ {title ?? copy.title}
77
+ </h1>
78
+ <p className="m-0 text-base text-kumo-subtle">
79
+ {description ?? copy.description}
80
+ </p>
81
+ {(homeHref !== null || actions) && (
82
+ <div className="mt-2 flex flex-wrap items-center gap-2">
83
+ {homeHref !== null && (
84
+ <LinkButton href={homeHref} variant="primary">
85
+ {homeLabel}
86
+ </LinkButton>
87
+ )}
88
+ {actions}
89
+ </div>
90
+ )}
91
+ {details && (
92
+ <p className="m-0 mt-2 text-xs text-kumo-subtle">{details}</p>
93
+ )}
94
+ </div>
95
+ </main>
96
+ );
97
+ }