@fldr/ui 0.3.6 → 0.3.8
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.
- package/THEMING.md +2 -6
- package/ai/component-registry.json +962 -43
- package/ai/component-registry.md +1 -1
- package/dist/.build-complete +1 -1
- package/dist/ai/schemas.d.ts +18 -18
- package/dist/blocks-source/activity-feed/activity-feed.test.tsx +75 -0
- package/dist/blocks-source/activity-feed/activity-feed.tsx +256 -0
- package/dist/blocks-source/app-shell/app-shell.test.tsx +74 -0
- package/dist/blocks-source/app-shell/app-shell.tsx +123 -0
- package/dist/blocks-source/auth-card/auth-card.test.tsx +64 -0
- package/dist/blocks-source/auth-card/auth-card.tsx +234 -0
- package/dist/blocks-source/dashboard-page/dashboard-page.tsx +167 -0
- package/dist/blocks-source/error-page/error-page.test.tsx +60 -0
- package/dist/blocks-source/error-page/error-page.tsx +97 -0
- package/dist/blocks-source/file-table/file-item.tsx +164 -0
- package/dist/blocks-source/file-table/file-table.test.tsx +82 -0
- package/dist/blocks-source/file-table/file-table.tsx +292 -0
- package/dist/blocks-source/folder-grid/folder-grid.test.tsx +54 -0
- package/dist/blocks-source/folder-grid/folder-grid.tsx +170 -0
- package/dist/blocks-source/login-page/login-page.tsx +47 -0
- package/dist/blocks-source/onboarding-checklist/onboarding-checklist.test.tsx +50 -0
- package/dist/blocks-source/onboarding-checklist/onboarding-checklist.tsx +180 -0
- package/dist/blocks-source/settings-section/settings-section.test.tsx +43 -0
- package/dist/blocks-source/settings-section/settings-section.tsx +165 -0
- package/dist/blocks-source/share-dialog/share-dialog.test.tsx +69 -0
- package/dist/blocks-source/share-dialog/share-dialog.tsx +307 -0
- package/dist/blocks-source/stat-grid/stat-grid.test.tsx +52 -0
- package/dist/blocks-source/stat-grid/stat-grid.tsx +153 -0
- package/dist/blocks-source/upload-dropzone/upload-dropzone.test.tsx +82 -0
- package/dist/blocks-source/upload-dropzone/upload-dropzone.tsx +264 -0
- package/dist/blocks.d.ts +780 -0
- package/dist/blocks.js +1664 -0
- package/dist/chunks/delete-resource-cmlptb61ih8s84r3.js +151 -0
- package/dist/delete-resource-DY-GFy2s.d.ts +48 -0
- package/dist/index.d.ts +4 -50
- package/dist/index.js +1 -146
- package/dist/primitives.d.ts +1 -1
- package/dist/styles/kumo-standalone.css +1 -1
- package/dist/styles/theme-fldr.css +0 -11
- package/dist/theming.d.ts +4 -24
- package/dist/theming.js +4 -15
- package/package.json +5 -1
package/dist/blocks.js
ADDED
|
@@ -0,0 +1,1664 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./chunks/vendor-styling-gs32v7xt5znc8kg0.js";
|
|
3
|
+
import { r as Link } from "./chunks/link-h84bkh8eem39p529.js";
|
|
4
|
+
import { n as LinkButton, t as Button } from "./chunks/button-hzvowfkbathmx8yg.js";
|
|
5
|
+
import { t as Banner } from "./chunks/banner-mo1xl9ww734kgsqh.js";
|
|
6
|
+
import { t as Checkbox } from "./chunks/checkbox-eifiwbw34xwsikvf.js";
|
|
7
|
+
import { t as Input } from "./chunks/input-kfi46426y22ocoo4.js";
|
|
8
|
+
import { t as ClipboardText } from "./chunks/clipboard-text-ejyilhenww9v18l4.js";
|
|
9
|
+
import { t as DropdownMenu } from "./chunks/dropdown-e5zk0ez21busnt0b.js";
|
|
10
|
+
import { n as KUMO_DELETE_RESOURCE_DEFAULT_VARIANTS, r as KUMO_DELETE_RESOURCE_VARIANTS, t as DeleteResource } from "./chunks/delete-resource-cmlptb61ih8s84r3.js";
|
|
11
|
+
import { t as Meter } from "./chunks/meter-poh8jpe0qtq6mvee.js";
|
|
12
|
+
import { t as Select } from "./chunks/select-h2pejw38n5z3l59r.js";
|
|
13
|
+
import { t as Tabs } from "./chunks/tabs-cja62qojznpj99et.js";
|
|
14
|
+
import { r as Table } from "./chunks/table-ngl1b5yc8mcur662.js";
|
|
15
|
+
import { i as Sidebar } from "./chunks/sidebar-mhlgvpawixxoey2k.js";
|
|
16
|
+
import { t as LayerDialog } from "./chunks/layer-dialog-m8qb0wzfg3k7406a.js";
|
|
17
|
+
import { useCallback, useId, useMemo, useRef, useState } from "react";
|
|
18
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { ArrowClockwiseIcon, ArrowDownIcon, ArrowUpIcon, ArrowsLeftRightIcon, CaretDownIcon, CaretUpIcon, ChatCircleIcon, CheckCircleIcon, CircleIcon, DotsThreeIcon, FileIcon, FileImageIcon, FilePdfIcon, FileXlsIcon, FolderSimpleIcon, GlobeIcon, LockIcon, PencilSimpleIcon, ShareNetworkIcon, TrashIcon, UploadSimpleIcon, WarningCircleIcon, XIcon } from "@phosphor-icons/react";
|
|
20
|
+
//#region src/blocks/activity-feed/activity-feed.tsx
|
|
21
|
+
const DEFAULT_LABELS$6 = {
|
|
22
|
+
today: "Today",
|
|
23
|
+
yesterday: "Yesterday",
|
|
24
|
+
loadMore: "Load more"
|
|
25
|
+
};
|
|
26
|
+
const KIND_ICONS$1 = {
|
|
27
|
+
upload: UploadSimpleIcon,
|
|
28
|
+
share: ShareNetworkIcon,
|
|
29
|
+
comment: ChatCircleIcon,
|
|
30
|
+
delete: TrashIcon,
|
|
31
|
+
rename: PencilSimpleIcon,
|
|
32
|
+
move: ArrowsLeftRightIcon
|
|
33
|
+
};
|
|
34
|
+
const UNITS = [
|
|
35
|
+
["year", 31536e3],
|
|
36
|
+
["month", 2592e3],
|
|
37
|
+
["week", 604800],
|
|
38
|
+
["day", 86400],
|
|
39
|
+
["hour", 3600],
|
|
40
|
+
["minute", 60],
|
|
41
|
+
["second", 1]
|
|
42
|
+
];
|
|
43
|
+
/** Formats `date` relative to `now`, e.g. "5 minutes ago". */
|
|
44
|
+
function formatActivityTime(date, now, locale) {
|
|
45
|
+
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
46
|
+
const seconds = Math.round((date.getTime() - now.getTime()) / 1e3);
|
|
47
|
+
for (const [unit, size] of UNITS) if (Math.abs(seconds) >= size || unit === "second") return rtf.format(Math.round(seconds / size), unit);
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
const dayKey = (d) => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
|
|
51
|
+
function dayLabel(d, now, l, locale) {
|
|
52
|
+
const yesterday = new Date(now);
|
|
53
|
+
yesterday.setDate(now.getDate() - 1);
|
|
54
|
+
if (dayKey(d) === dayKey(now)) return l.today;
|
|
55
|
+
if (dayKey(d) === dayKey(yesterday)) return l.yesterday;
|
|
56
|
+
return d.toLocaleDateString(locale, {
|
|
57
|
+
month: "short",
|
|
58
|
+
day: "numeric",
|
|
59
|
+
year: d.getFullYear() === now.getFullYear() ? void 0 : "numeric"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const initials$1 = (name) => name.split(/\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]?.toUpperCase()).join("");
|
|
63
|
+
/**
|
|
64
|
+
* Compact vertical timeline of file and folder activity.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <ActivityFeed
|
|
69
|
+
* groupByDay
|
|
70
|
+
* events={[{ id: "1", actor: { name: "Ada Lovelace" }, action: "uploaded",
|
|
71
|
+
* target: { label: "receipt-0412.pdf", href: "/f/1" }, kind: "upload",
|
|
72
|
+
* timestamp: new Date() }]}
|
|
73
|
+
* onLoadMore={fetchOlder}
|
|
74
|
+
* />
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
function ActivityFeed({ events, groupByDay = false, onLoadMore, loadingMore = false, footer, now = /* @__PURE__ */ new Date(), locale, labels, className }) {
|
|
78
|
+
const l = {
|
|
79
|
+
...DEFAULT_LABELS$6,
|
|
80
|
+
...labels
|
|
81
|
+
};
|
|
82
|
+
const groups = [];
|
|
83
|
+
for (const event of events) {
|
|
84
|
+
const date = new Date(event.timestamp);
|
|
85
|
+
const key = groupByDay ? dayKey(date) : "all";
|
|
86
|
+
const last = groups[groups.length - 1];
|
|
87
|
+
if (last?.key === key) last.items.push(event);
|
|
88
|
+
else groups.push({
|
|
89
|
+
key,
|
|
90
|
+
label: groupByDay ? dayLabel(date, now, l, locale) : void 0,
|
|
91
|
+
items: [event]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
95
|
+
className: cn("flex flex-col gap-4", className),
|
|
96
|
+
children: [groups.map((group) => /* @__PURE__ */ jsxs("section", {
|
|
97
|
+
className: "flex flex-col gap-1",
|
|
98
|
+
children: [group.label && /* @__PURE__ */ jsx("h3", {
|
|
99
|
+
className: "m-0 px-1 text-xs font-medium text-kumo-subtle",
|
|
100
|
+
children: group.label
|
|
101
|
+
}), /* @__PURE__ */ jsx("ol", {
|
|
102
|
+
className: "m-0 flex list-none flex-col p-0",
|
|
103
|
+
children: group.items.map((event) => {
|
|
104
|
+
const date = new Date(event.timestamp);
|
|
105
|
+
const KindIcon = event.kind ? KIND_ICONS$1[event.kind] : null;
|
|
106
|
+
const { target } = event;
|
|
107
|
+
const targetClass = "font-medium text-kumo-link hover:underline cursor-pointer";
|
|
108
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
109
|
+
className: "flex items-center gap-2.5 rounded-md px-1 py-1.5 text-sm",
|
|
110
|
+
children: [
|
|
111
|
+
event.actor.avatarUrl ? /* @__PURE__ */ jsx("img", {
|
|
112
|
+
src: event.actor.avatarUrl,
|
|
113
|
+
alt: "",
|
|
114
|
+
className: "size-6 shrink-0 rounded-full bg-kumo-recessed object-cover"
|
|
115
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
116
|
+
"aria-hidden": true,
|
|
117
|
+
className: "flex size-6 shrink-0 items-center justify-center rounded-full bg-kumo-recessed text-[10px] font-medium text-kumo-subtle",
|
|
118
|
+
children: initials$1(event.actor.name)
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ jsxs("span", {
|
|
121
|
+
className: "min-w-0 grow truncate text-kumo-subtle",
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx("span", {
|
|
124
|
+
className: "font-medium text-kumo-default",
|
|
125
|
+
children: event.actor.name
|
|
126
|
+
}),
|
|
127
|
+
" ",
|
|
128
|
+
event.action,
|
|
129
|
+
target && " ",
|
|
130
|
+
target?.href ? /* @__PURE__ */ jsx("a", {
|
|
131
|
+
href: target.href,
|
|
132
|
+
onClick: target.onClick,
|
|
133
|
+
className: targetClass,
|
|
134
|
+
children: target.label
|
|
135
|
+
}) : target?.onClick ? /* @__PURE__ */ jsx("button", {
|
|
136
|
+
type: "button",
|
|
137
|
+
onClick: target.onClick,
|
|
138
|
+
className: targetClass,
|
|
139
|
+
children: target.label
|
|
140
|
+
}) : target ? /* @__PURE__ */ jsx("span", {
|
|
141
|
+
className: "font-medium text-kumo-default",
|
|
142
|
+
children: target.label
|
|
143
|
+
}) : null
|
|
144
|
+
]
|
|
145
|
+
}),
|
|
146
|
+
KindIcon && /* @__PURE__ */ jsx(KindIcon, {
|
|
147
|
+
size: 14,
|
|
148
|
+
"aria-hidden": true,
|
|
149
|
+
className: "shrink-0 text-kumo-subtle"
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ jsx("time", {
|
|
152
|
+
dateTime: date.toISOString(),
|
|
153
|
+
title: date.toLocaleString(locale),
|
|
154
|
+
className: "shrink-0 text-xs text-kumo-subtle tabular-nums",
|
|
155
|
+
children: formatActivityTime(date, now, locale)
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
}, event.id);
|
|
159
|
+
})
|
|
160
|
+
})]
|
|
161
|
+
}, group.key)), footer ?? (onLoadMore && /* @__PURE__ */ jsx(Button, {
|
|
162
|
+
size: "sm",
|
|
163
|
+
variant: "ghost",
|
|
164
|
+
className: "self-start",
|
|
165
|
+
loading: loadingMore,
|
|
166
|
+
onClick: onLoadMore,
|
|
167
|
+
children: l.loadMore
|
|
168
|
+
}))]
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/blocks/app-shell/app-shell.tsx
|
|
173
|
+
/**
|
|
174
|
+
* Application frame: sidebar navigation, top bar and a scrollable content area.
|
|
175
|
+
* The sidebar collapses to icons on desktop and becomes a drawer on narrow screens.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* <AppShell
|
|
180
|
+
* brand={<span className="font-semibold">fldr</span>}
|
|
181
|
+
* nav={
|
|
182
|
+
* <Sidebar.Group>
|
|
183
|
+
* <Sidebar.Menu>
|
|
184
|
+
* <Sidebar.MenuButton icon={FolderIcon} active>All files</Sidebar.MenuButton>
|
|
185
|
+
* <Sidebar.MenuButton icon={ReceiptIcon}>Receipts</Sidebar.MenuButton>
|
|
186
|
+
* </Sidebar.Menu>
|
|
187
|
+
* </Sidebar.Group>
|
|
188
|
+
* }
|
|
189
|
+
* sidebarFooter={<span>ada@fldr.app</span>}
|
|
190
|
+
* header="All files"
|
|
191
|
+
* actions={<Button variant="primary">Upload</Button>}
|
|
192
|
+
* >
|
|
193
|
+
* <FileList />
|
|
194
|
+
* </AppShell>
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
function AppShell({ brand, nav, sidebarFooter, header, actions, children, defaultOpen = true, open, onOpenChange, collapsible = "icon", mobileBreakpoint, contained = false, toggleLabel, className, contentClassName }) {
|
|
198
|
+
return /* @__PURE__ */ jsxs(Sidebar.Provider, {
|
|
199
|
+
defaultOpen,
|
|
200
|
+
open,
|
|
201
|
+
onOpenChange,
|
|
202
|
+
collapsible,
|
|
203
|
+
mobileBreakpoint,
|
|
204
|
+
contained,
|
|
205
|
+
className: cn("overflow-hidden bg-kumo-base", contained ? "h-full" : "h-svh", className),
|
|
206
|
+
children: [/* @__PURE__ */ jsxs(Sidebar, { children: [
|
|
207
|
+
brand && /* @__PURE__ */ jsx(Sidebar.Header, { children: brand }),
|
|
208
|
+
/* @__PURE__ */ jsx(Sidebar.Content, { children: nav }),
|
|
209
|
+
sidebarFooter && /* @__PURE__ */ jsx(Sidebar.Footer, { children: sidebarFooter })
|
|
210
|
+
] }), /* @__PURE__ */ jsxs("div", {
|
|
211
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
212
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
213
|
+
className: "flex h-[58px] shrink-0 items-center gap-2 border-b border-kumo-line px-3",
|
|
214
|
+
children: [
|
|
215
|
+
collapsible !== "none" && /* @__PURE__ */ jsx(Sidebar.Trigger, { ...toggleLabel ? { "aria-label": toggleLabel } : {} }),
|
|
216
|
+
/* @__PURE__ */ jsx("div", {
|
|
217
|
+
className: "flex min-w-0 flex-1 items-center truncate font-medium text-kumo-default",
|
|
218
|
+
children: header
|
|
219
|
+
}),
|
|
220
|
+
actions && /* @__PURE__ */ jsx("div", {
|
|
221
|
+
className: "flex shrink-0 items-center gap-2",
|
|
222
|
+
children: actions
|
|
223
|
+
})
|
|
224
|
+
]
|
|
225
|
+
}), /* @__PURE__ */ jsx("main", {
|
|
226
|
+
className: cn("min-h-0 flex-1 overflow-y-auto bg-kumo-base", contentClassName),
|
|
227
|
+
children
|
|
228
|
+
})]
|
|
229
|
+
})]
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/blocks/auth-card/auth-card.tsx
|
|
234
|
+
const DEFAULT_LABELS$5 = {
|
|
235
|
+
signInTitle: "Sign in to fldr",
|
|
236
|
+
signUpTitle: "Create your fldr account",
|
|
237
|
+
name: "Name",
|
|
238
|
+
email: "Email",
|
|
239
|
+
password: "Password",
|
|
240
|
+
signInSubmit: "Sign in",
|
|
241
|
+
signUpSubmit: "Create account",
|
|
242
|
+
magicLinkSubmit: "Email me a sign-in link",
|
|
243
|
+
divider: "or"
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Centered sign-in / sign-up card with optional providers and magic-link mode.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```tsx
|
|
250
|
+
* <AuthCard
|
|
251
|
+
* mode="sign-in"
|
|
252
|
+
* providers={[{ id: "google", label: "Continue with Google" }]}
|
|
253
|
+
* onProvider={(id) => startOAuth(id)}
|
|
254
|
+
* onSubmit={({ email, password }) => signIn(email, password)}
|
|
255
|
+
* footer={<>Don't have an account? <a href="/sign-up">Sign up</a></>}
|
|
256
|
+
* />
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
function AuthCard({ mode = "sign-in", method = "password", onSubmit, providers, onProvider, providerSlot, logo, title, description, error, loading = false, footer, labels: labelOverrides, className }) {
|
|
260
|
+
const labels = {
|
|
261
|
+
...DEFAULT_LABELS$5,
|
|
262
|
+
...labelOverrides
|
|
263
|
+
};
|
|
264
|
+
const isSignUp = mode === "sign-up";
|
|
265
|
+
const hasPassword = method === "password";
|
|
266
|
+
const providerContent = providerSlot ?? (providers?.length ? providers.map((p) => /* @__PURE__ */ jsx(Button, {
|
|
267
|
+
type: "button",
|
|
268
|
+
variant: "secondary",
|
|
269
|
+
icon: p.icon,
|
|
270
|
+
disabled: loading,
|
|
271
|
+
onClick: () => onProvider?.(p.id),
|
|
272
|
+
className: "w-full justify-center",
|
|
273
|
+
children: p.label
|
|
274
|
+
}, p.id)) : null);
|
|
275
|
+
const handleSubmit = (event) => {
|
|
276
|
+
event.preventDefault();
|
|
277
|
+
if (loading) return;
|
|
278
|
+
const data = new FormData(event.currentTarget);
|
|
279
|
+
const get = (key) => {
|
|
280
|
+
const value = data.get(key);
|
|
281
|
+
return typeof value === "string" ? value : void 0;
|
|
282
|
+
};
|
|
283
|
+
onSubmit({
|
|
284
|
+
email: get("email") ?? "",
|
|
285
|
+
...hasPassword && { password: get("password") ?? "" },
|
|
286
|
+
...isSignUp && { name: get("name") ?? "" }
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
const submitLabel = !hasPassword ? labels.magicLinkSubmit : isSignUp ? labels.signUpSubmit : labels.signInSubmit;
|
|
290
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
291
|
+
className: cn("mx-auto flex w-full max-w-[360px] flex-col gap-4 rounded-xl bg-kumo-elevated p-5", className),
|
|
292
|
+
children: [
|
|
293
|
+
/* @__PURE__ */ jsxs("div", {
|
|
294
|
+
className: "flex flex-col gap-1",
|
|
295
|
+
children: [
|
|
296
|
+
logo && /* @__PURE__ */ jsx("div", {
|
|
297
|
+
className: "mb-3",
|
|
298
|
+
children: logo
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ jsx("h1", {
|
|
301
|
+
className: "text-lg font-semibold text-kumo-default",
|
|
302
|
+
children: title ?? (isSignUp ? labels.signUpTitle : labels.signInTitle)
|
|
303
|
+
}),
|
|
304
|
+
description && /* @__PURE__ */ jsx("p", {
|
|
305
|
+
className: "text-sm text-kumo-subtle",
|
|
306
|
+
children: description
|
|
307
|
+
})
|
|
308
|
+
]
|
|
309
|
+
}),
|
|
310
|
+
error && /* @__PURE__ */ jsx("div", {
|
|
311
|
+
role: "alert",
|
|
312
|
+
children: /* @__PURE__ */ jsx(Banner, {
|
|
313
|
+
variant: "error",
|
|
314
|
+
size: "sm",
|
|
315
|
+
icon: /* @__PURE__ */ jsx(WarningCircleIcon, {}),
|
|
316
|
+
description: error
|
|
317
|
+
})
|
|
318
|
+
}),
|
|
319
|
+
providerContent && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
320
|
+
className: "flex flex-col gap-2",
|
|
321
|
+
children: providerContent
|
|
322
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
323
|
+
className: "flex items-center gap-3 text-xs text-kumo-subtle",
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-kumo-line" }),
|
|
326
|
+
labels.divider,
|
|
327
|
+
/* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-kumo-line" })
|
|
328
|
+
]
|
|
329
|
+
})] }),
|
|
330
|
+
/* @__PURE__ */ jsxs("form", {
|
|
331
|
+
className: "flex flex-col gap-3",
|
|
332
|
+
onSubmit: handleSubmit,
|
|
333
|
+
children: [
|
|
334
|
+
isSignUp && /* @__PURE__ */ jsx(Input, {
|
|
335
|
+
label: labels.name,
|
|
336
|
+
name: "name",
|
|
337
|
+
autoComplete: "name",
|
|
338
|
+
required: true,
|
|
339
|
+
disabled: loading
|
|
340
|
+
}),
|
|
341
|
+
/* @__PURE__ */ jsx(Input, {
|
|
342
|
+
label: labels.email,
|
|
343
|
+
name: "email",
|
|
344
|
+
type: "email",
|
|
345
|
+
autoComplete: "email",
|
|
346
|
+
placeholder: "you@example.com",
|
|
347
|
+
required: true,
|
|
348
|
+
disabled: loading
|
|
349
|
+
}),
|
|
350
|
+
hasPassword && /* @__PURE__ */ jsx(Input, {
|
|
351
|
+
label: labels.password,
|
|
352
|
+
name: "password",
|
|
353
|
+
type: "password",
|
|
354
|
+
autoComplete: isSignUp ? "new-password" : "current-password",
|
|
355
|
+
required: true,
|
|
356
|
+
disabled: loading
|
|
357
|
+
}),
|
|
358
|
+
/* @__PURE__ */ jsx(Button, {
|
|
359
|
+
type: "submit",
|
|
360
|
+
variant: "primary",
|
|
361
|
+
loading,
|
|
362
|
+
className: "w-full justify-center",
|
|
363
|
+
children: submitLabel
|
|
364
|
+
})
|
|
365
|
+
]
|
|
366
|
+
}),
|
|
367
|
+
footer && /* @__PURE__ */ jsx("div", {
|
|
368
|
+
className: "text-center text-sm text-kumo-subtle",
|
|
369
|
+
children: footer
|
|
370
|
+
})
|
|
371
|
+
]
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
AuthCard.displayName = "AuthCard";
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/blocks/file-table/file-item.tsx
|
|
377
|
+
const KIND_ICONS = {
|
|
378
|
+
folder: FolderSimpleIcon,
|
|
379
|
+
pdf: FilePdfIcon,
|
|
380
|
+
image: FileImageIcon,
|
|
381
|
+
sheet: FileXlsIcon,
|
|
382
|
+
file: FileIcon
|
|
383
|
+
};
|
|
384
|
+
/** Phosphor icon for a file kind. */
|
|
385
|
+
function FileKindIcon({ kind, size = 18, className }) {
|
|
386
|
+
const IconComponent = KIND_ICONS[kind] ?? FileIcon;
|
|
387
|
+
return /* @__PURE__ */ jsx(IconComponent, {
|
|
388
|
+
size,
|
|
389
|
+
weight: kind === "folder" ? "fill" : "regular",
|
|
390
|
+
className: cn("shrink-0 text-kumo-subtle", className),
|
|
391
|
+
"aria-hidden": true
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
function formatFileSize(bytes, locale) {
|
|
395
|
+
const units = [
|
|
396
|
+
"byte",
|
|
397
|
+
"kilobyte",
|
|
398
|
+
"megabyte",
|
|
399
|
+
"gigabyte",
|
|
400
|
+
"terabyte"
|
|
401
|
+
];
|
|
402
|
+
const i = Math.min(units.length - 1, bytes > 0 ? Math.floor(Math.log(bytes) / Math.log(1024)) : 0);
|
|
403
|
+
return new Intl.NumberFormat(locale, {
|
|
404
|
+
style: "unit",
|
|
405
|
+
unit: units[i],
|
|
406
|
+
unitDisplay: "short",
|
|
407
|
+
maximumFractionDigits: i === 0 ? 0 : 1
|
|
408
|
+
}).format(bytes / 1024 ** i);
|
|
409
|
+
}
|
|
410
|
+
function formatFileDate(value, locale) {
|
|
411
|
+
return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(new Date(value));
|
|
412
|
+
}
|
|
413
|
+
function toTime(value) {
|
|
414
|
+
return value === void 0 ? 0 : new Date(value).getTime();
|
|
415
|
+
}
|
|
416
|
+
/** Controlled/uncontrolled state helper. */
|
|
417
|
+
function useControllable(value, defaultValue, onChange) {
|
|
418
|
+
const [inner, setInner] = useState(defaultValue);
|
|
419
|
+
return [value ?? inner, useCallback((next) => {
|
|
420
|
+
if (value === void 0) setInner(next);
|
|
421
|
+
onChange?.(next);
|
|
422
|
+
}, [value, onChange])];
|
|
423
|
+
}
|
|
424
|
+
/** Kebab button that opens an item's actions menu. Clicks don't bubble to the row/card. */
|
|
425
|
+
function ItemActionsMenu({ item, actions, label, className }) {
|
|
426
|
+
return /* @__PURE__ */ jsx("span", {
|
|
427
|
+
className: cn("inline-flex", className),
|
|
428
|
+
onClick: (e) => e.stopPropagation(),
|
|
429
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
430
|
+
children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, { render: /* @__PURE__ */ jsx(Button, {
|
|
431
|
+
variant: "ghost",
|
|
432
|
+
size: "sm",
|
|
433
|
+
shape: "square",
|
|
434
|
+
icon: /* @__PURE__ */ jsx(DotsThreeIcon, { weight: "bold" }),
|
|
435
|
+
"aria-label": label
|
|
436
|
+
}) }), /* @__PURE__ */ jsx(DropdownMenu.Content, {
|
|
437
|
+
align: "end",
|
|
438
|
+
children: typeof actions === "function" ? actions(item) : actions.map((action, i) => /* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
439
|
+
icon: action.icon,
|
|
440
|
+
variant: action.variant,
|
|
441
|
+
onClick: () => action.onSelect(item),
|
|
442
|
+
children: action.label
|
|
443
|
+
}, i))
|
|
444
|
+
})] })
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/blocks/file-table/file-table.tsx
|
|
449
|
+
const DEFAULT_LABELS$4 = {
|
|
450
|
+
name: "Name",
|
|
451
|
+
size: "Size",
|
|
452
|
+
modified: "Modified",
|
|
453
|
+
owner: "Owner",
|
|
454
|
+
selectAll: "Select all",
|
|
455
|
+
selectRow: (name) => `Select ${name}`,
|
|
456
|
+
selected: (count) => `${count} selected`,
|
|
457
|
+
clearSelection: "Clear selection",
|
|
458
|
+
actions: (name) => `Actions for ${name}`
|
|
459
|
+
};
|
|
460
|
+
const DEFAULT_SORT = {
|
|
461
|
+
key: "name",
|
|
462
|
+
direction: "asc"
|
|
463
|
+
};
|
|
464
|
+
function compare(a, b, key) {
|
|
465
|
+
if (key === "size") return (a.size ?? -1) - (b.size ?? -1);
|
|
466
|
+
if (key === "modifiedAt") return toTime(a.modifiedAt) - toTime(b.modifiedAt);
|
|
467
|
+
return (a[key] ?? "").localeCompare(b[key] ?? "", void 0, { numeric: true });
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* FileTable — sortable, selectable list of files and folders.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```tsx
|
|
474
|
+
* <FileTable
|
|
475
|
+
* items={[{ id: "1", name: "Receipts", kind: "folder", itemCount: 48 }]}
|
|
476
|
+
* onOpen={(item) => navigate(item.id)}
|
|
477
|
+
* actions={[{ label: "Delete", variant: "danger", onSelect: remove }]}
|
|
478
|
+
* bulkActions={(ids) => <Button size="sm" onClick={() => share(ids)}>Share</Button>}
|
|
479
|
+
* />
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
function FileTable({ items, sort: sortProp, defaultSort = DEFAULT_SORT, onSortChange, selectable = true, selectedIds, defaultSelectedIds = [], onSelectionChange, bulkActions, actions, onOpen, empty, labels: labelsProp, locale, className }) {
|
|
483
|
+
const labels = {
|
|
484
|
+
...DEFAULT_LABELS$4,
|
|
485
|
+
...labelsProp
|
|
486
|
+
};
|
|
487
|
+
const [sort, setSort] = useControllable(sortProp, defaultSort, onSortChange);
|
|
488
|
+
const [selected, setSelected] = useControllable(selectedIds, defaultSelectedIds, onSelectionChange);
|
|
489
|
+
const selectedSet = new Set(selected);
|
|
490
|
+
const sorted = useMemo(() => {
|
|
491
|
+
const dir = sort.direction === "asc" ? 1 : -1;
|
|
492
|
+
return [...items].sort((a, b) => Number(b.kind === "folder") - Number(a.kind === "folder") || dir * compare(a, b, sort.key));
|
|
493
|
+
}, [items, sort]);
|
|
494
|
+
if (items.length === 0 && empty) return /* @__PURE__ */ jsx(Fragment$1, { children: empty });
|
|
495
|
+
const allSelected = items.length > 0 && selected.length === items.length;
|
|
496
|
+
const toggle = (id, checked) => setSelected(checked ? [...selected, id] : selected.filter((s) => s !== id));
|
|
497
|
+
const head = (key, label, cls) => {
|
|
498
|
+
const active = sort.key === key;
|
|
499
|
+
const Caret = sort.direction === "asc" ? CaretUpIcon : CaretDownIcon;
|
|
500
|
+
return /* @__PURE__ */ jsx(Table.Head, {
|
|
501
|
+
className: cn("font-medium", cls),
|
|
502
|
+
"aria-sort": active ? sort.direction === "asc" ? "ascending" : "descending" : void 0,
|
|
503
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
504
|
+
type: "button",
|
|
505
|
+
className: "inline-flex cursor-pointer items-center gap-1 text-kumo-subtle hover:text-kumo-default",
|
|
506
|
+
onClick: () => setSort({
|
|
507
|
+
key,
|
|
508
|
+
direction: active && sort.direction === "asc" ? "desc" : "asc"
|
|
509
|
+
}),
|
|
510
|
+
children: [label, active && /* @__PURE__ */ jsx(Caret, {
|
|
511
|
+
size: 12,
|
|
512
|
+
weight: "bold",
|
|
513
|
+
"aria-hidden": true
|
|
514
|
+
})]
|
|
515
|
+
})
|
|
516
|
+
});
|
|
517
|
+
};
|
|
518
|
+
const bulk = typeof bulkActions === "function" ? bulkActions(selected) : bulkActions;
|
|
519
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
520
|
+
className: cn("w-full", className),
|
|
521
|
+
children: [selectable && selected.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
522
|
+
role: "toolbar",
|
|
523
|
+
"aria-label": labels.selected(selected.length),
|
|
524
|
+
className: "flex items-center gap-2 bg-kumo-tint px-3 py-1.5",
|
|
525
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
526
|
+
className: "text-sm font-medium text-kumo-default",
|
|
527
|
+
children: labels.selected(selected.length)
|
|
528
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
529
|
+
className: "ml-auto flex items-center gap-1.5",
|
|
530
|
+
children: [bulk, /* @__PURE__ */ jsx(Button, {
|
|
531
|
+
variant: "ghost",
|
|
532
|
+
size: "sm",
|
|
533
|
+
shape: "square",
|
|
534
|
+
icon: /* @__PURE__ */ jsx(XIcon, {}),
|
|
535
|
+
"aria-label": labels.clearSelection,
|
|
536
|
+
onClick: () => setSelected([])
|
|
537
|
+
})]
|
|
538
|
+
})]
|
|
539
|
+
}), /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(Table.Header, {
|
|
540
|
+
variant: "compact",
|
|
541
|
+
children: /* @__PURE__ */ jsxs(Table.Row, { children: [
|
|
542
|
+
selectable && /* @__PURE__ */ jsx(Table.CheckHead, {
|
|
543
|
+
label: labels.selectAll,
|
|
544
|
+
checked: allSelected,
|
|
545
|
+
indeterminate: selected.length > 0 && !allSelected,
|
|
546
|
+
onCheckedChange: (checked) => setSelected(checked ? items.map((i) => i.id) : [])
|
|
547
|
+
}),
|
|
548
|
+
head("name", labels.name, "w-full"),
|
|
549
|
+
head("size", labels.size, "text-right"),
|
|
550
|
+
head("modifiedAt", labels.modified, "hidden sm:table-cell"),
|
|
551
|
+
head("owner", labels.owner, "hidden md:table-cell"),
|
|
552
|
+
actions && /* @__PURE__ */ jsx(Table.Head, { className: "w-10" })
|
|
553
|
+
] })
|
|
554
|
+
}), /* @__PURE__ */ jsx(Table.Body, { children: sorted.map((item) => {
|
|
555
|
+
const isSelected = selectedSet.has(item.id);
|
|
556
|
+
return /* @__PURE__ */ jsxs(Table.Row, {
|
|
557
|
+
variant: isSelected ? "selected" : "default",
|
|
558
|
+
className: cn(!isSelected && "even:bg-kumo-base hover:bg-kumo-tint even:hover:bg-kumo-tint", onOpen && "cursor-pointer"),
|
|
559
|
+
onClick: onOpen && (() => onOpen(item)),
|
|
560
|
+
children: [
|
|
561
|
+
selectable && /* @__PURE__ */ jsx(Table.CheckCell, {
|
|
562
|
+
label: labels.selectRow(item.name),
|
|
563
|
+
checked: isSelected,
|
|
564
|
+
onCheckedChange: (checked) => toggle(item.id, checked),
|
|
565
|
+
onClick: (e) => e.stopPropagation()
|
|
566
|
+
}),
|
|
567
|
+
/* @__PURE__ */ jsx(Table.Cell, {
|
|
568
|
+
className: "max-w-0",
|
|
569
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
570
|
+
className: "flex min-w-0 items-center gap-2",
|
|
571
|
+
children: [/* @__PURE__ */ jsx(FileKindIcon, { kind: item.kind }), onOpen ? /* @__PURE__ */ jsx("button", {
|
|
572
|
+
type: "button",
|
|
573
|
+
className: "cursor-pointer truncate text-left",
|
|
574
|
+
children: item.name
|
|
575
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
576
|
+
className: "truncate",
|
|
577
|
+
children: item.name
|
|
578
|
+
})]
|
|
579
|
+
})
|
|
580
|
+
}),
|
|
581
|
+
/* @__PURE__ */ jsx(Table.Cell, {
|
|
582
|
+
className: "text-right whitespace-nowrap text-kumo-subtle tabular-nums",
|
|
583
|
+
children: item.size === void 0 ? "—" : formatFileSize(item.size, locale)
|
|
584
|
+
}),
|
|
585
|
+
/* @__PURE__ */ jsx(Table.Cell, {
|
|
586
|
+
className: "hidden whitespace-nowrap text-kumo-subtle sm:table-cell",
|
|
587
|
+
children: item.modifiedAt === void 0 ? "—" : formatFileDate(item.modifiedAt, locale)
|
|
588
|
+
}),
|
|
589
|
+
/* @__PURE__ */ jsx(Table.Cell, {
|
|
590
|
+
className: "hidden whitespace-nowrap text-kumo-subtle md:table-cell",
|
|
591
|
+
children: item.owner ?? "—"
|
|
592
|
+
}),
|
|
593
|
+
actions && /* @__PURE__ */ jsx(Table.Cell, {
|
|
594
|
+
className: "py-0 text-right",
|
|
595
|
+
children: /* @__PURE__ */ jsx(ItemActionsMenu, {
|
|
596
|
+
item,
|
|
597
|
+
actions,
|
|
598
|
+
label: labels.actions(item.name)
|
|
599
|
+
})
|
|
600
|
+
})
|
|
601
|
+
]
|
|
602
|
+
}, item.id);
|
|
603
|
+
}) })] })]
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/blocks/onboarding-checklist/onboarding-checklist.tsx
|
|
608
|
+
const DEFAULT_LABELS$3 = {
|
|
609
|
+
title: "Get started with fldr",
|
|
610
|
+
progress: (done, total) => `${done} of ${total} done`,
|
|
611
|
+
progressLabel: "Setup progress",
|
|
612
|
+
dismiss: "Dismiss checklist",
|
|
613
|
+
done: "Done"
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* Getting-started card with progress and a list of steps. The first
|
|
617
|
+
* incomplete step is expanded; others show only their title.
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```tsx
|
|
621
|
+
* <OnboardingChecklist
|
|
622
|
+
* steps={[
|
|
623
|
+
* { id: "folder", title: "Create your first folder", done: true },
|
|
624
|
+
* { id: "forward", title: "Forward an email to inbox@fldr.zip", actionLabel: "Copy address" },
|
|
625
|
+
* ]}
|
|
626
|
+
* onStepAction={(id) => run(id)}
|
|
627
|
+
* onDismiss={() => hide()}
|
|
628
|
+
* />
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
function OnboardingChecklist({ steps, onStepAction, onDismiss, title, description, labels: labelOverrides, className }) {
|
|
632
|
+
const labels = {
|
|
633
|
+
...DEFAULT_LABELS$3,
|
|
634
|
+
...labelOverrides
|
|
635
|
+
};
|
|
636
|
+
const doneCount = steps.filter((s) => s.done).length;
|
|
637
|
+
const total = steps.length;
|
|
638
|
+
const currentId = steps.find((s) => !s.done)?.id;
|
|
639
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
640
|
+
className: cn("flex w-full flex-col gap-3 rounded-xl bg-kumo-elevated p-4", className),
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ jsxs("div", {
|
|
643
|
+
className: "flex items-start justify-between gap-3",
|
|
644
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
645
|
+
className: "flex flex-col gap-1",
|
|
646
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
647
|
+
className: "text-base font-semibold text-kumo-default",
|
|
648
|
+
children: title ?? labels.title
|
|
649
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
650
|
+
className: "text-sm text-kumo-subtle",
|
|
651
|
+
children: description
|
|
652
|
+
})]
|
|
653
|
+
}), onDismiss && /* @__PURE__ */ jsx(Button, {
|
|
654
|
+
variant: "ghost",
|
|
655
|
+
shape: "square",
|
|
656
|
+
size: "sm",
|
|
657
|
+
"aria-label": labels.dismiss,
|
|
658
|
+
icon: XIcon,
|
|
659
|
+
onClick: onDismiss
|
|
660
|
+
})]
|
|
661
|
+
}),
|
|
662
|
+
/* @__PURE__ */ jsx(Meter, {
|
|
663
|
+
label: labels.progressLabel,
|
|
664
|
+
value: total ? doneCount / total * 100 : 0,
|
|
665
|
+
customValue: labels.progress(doneCount, total)
|
|
666
|
+
}),
|
|
667
|
+
/* @__PURE__ */ jsx("ol", {
|
|
668
|
+
className: "-mx-2 flex flex-col",
|
|
669
|
+
children: steps.map((step) => {
|
|
670
|
+
const current = step.id === currentId;
|
|
671
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
672
|
+
"aria-current": current ? "step" : void 0,
|
|
673
|
+
className: cn("flex gap-3 rounded-lg px-2 py-2", current && "bg-kumo-tint"),
|
|
674
|
+
children: [
|
|
675
|
+
step.done ? /* @__PURE__ */ jsx(CheckCircleIcon, {
|
|
676
|
+
size: 18,
|
|
677
|
+
weight: "fill",
|
|
678
|
+
className: "mt-px shrink-0 text-kumo-success",
|
|
679
|
+
"aria-label": labels.done
|
|
680
|
+
}) : /* @__PURE__ */ jsx(CircleIcon, {
|
|
681
|
+
size: 18,
|
|
682
|
+
className: "mt-px shrink-0 text-kumo-subtle",
|
|
683
|
+
"aria-hidden": true
|
|
684
|
+
}),
|
|
685
|
+
/* @__PURE__ */ jsxs("div", {
|
|
686
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
687
|
+
children: [
|
|
688
|
+
/* @__PURE__ */ jsx("span", {
|
|
689
|
+
className: cn("text-sm", step.done ? "text-kumo-subtle line-through" : "text-kumo-default", current && "font-medium"),
|
|
690
|
+
children: step.title
|
|
691
|
+
}),
|
|
692
|
+
current && step.description && /* @__PURE__ */ jsx("p", {
|
|
693
|
+
className: "text-sm text-kumo-subtle",
|
|
694
|
+
children: step.description
|
|
695
|
+
}),
|
|
696
|
+
current && step.actionLabel && /* @__PURE__ */ jsx(Button, {
|
|
697
|
+
variant: "primary",
|
|
698
|
+
size: "sm",
|
|
699
|
+
className: "mt-1 self-start",
|
|
700
|
+
onClick: () => onStepAction?.(step.id),
|
|
701
|
+
children: step.actionLabel
|
|
702
|
+
})
|
|
703
|
+
]
|
|
704
|
+
}),
|
|
705
|
+
!current && !step.done && step.actionLabel && /* @__PURE__ */ jsx(Button, {
|
|
706
|
+
variant: "ghost",
|
|
707
|
+
size: "sm",
|
|
708
|
+
onClick: () => onStepAction?.(step.id),
|
|
709
|
+
children: step.actionLabel
|
|
710
|
+
})
|
|
711
|
+
]
|
|
712
|
+
}, step.id);
|
|
713
|
+
})
|
|
714
|
+
})
|
|
715
|
+
]
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
OnboardingChecklist.displayName = "OnboardingChecklist";
|
|
719
|
+
//#endregion
|
|
720
|
+
//#region src/blocks/stat-grid/stat-grid.tsx
|
|
721
|
+
const TREND_CLASSES = {
|
|
722
|
+
good: "text-kumo-success",
|
|
723
|
+
bad: "text-kumo-danger",
|
|
724
|
+
neutral: "text-kumo-subtle"
|
|
725
|
+
};
|
|
726
|
+
function deltaTone({ trend = "neutral", positiveIsGood = true }) {
|
|
727
|
+
if (trend === "neutral") return TREND_CLASSES.neutral;
|
|
728
|
+
return trend === "up" === positiveIsGood ? TREND_CLASSES.good : TREND_CLASSES.bad;
|
|
729
|
+
}
|
|
730
|
+
/** A single metric card. Usable on its own or inside `StatGrid`. */
|
|
731
|
+
function Stat({ label, value, delta, hint, icon, meter, className }) {
|
|
732
|
+
const TrendIcon = delta?.trend === "up" ? ArrowUpIcon : delta?.trend === "down" ? ArrowDownIcon : null;
|
|
733
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
734
|
+
className: cn("flex min-w-0 flex-col gap-1.5 rounded-lg bg-kumo-elevated px-3 py-2.5", className),
|
|
735
|
+
children: [
|
|
736
|
+
/* @__PURE__ */ jsxs("div", {
|
|
737
|
+
className: "flex items-center gap-1.5 text-sm text-kumo-subtle",
|
|
738
|
+
children: [icon && /* @__PURE__ */ jsx("span", {
|
|
739
|
+
className: "flex shrink-0 [&_svg]:size-4",
|
|
740
|
+
children: icon
|
|
741
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
742
|
+
className: "truncate",
|
|
743
|
+
children: label
|
|
744
|
+
})]
|
|
745
|
+
}),
|
|
746
|
+
/* @__PURE__ */ jsxs("div", {
|
|
747
|
+
className: "flex flex-wrap items-baseline gap-2",
|
|
748
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
749
|
+
className: "text-2xl font-semibold text-kumo-default tabular-nums",
|
|
750
|
+
children: value
|
|
751
|
+
}), delta && /* @__PURE__ */ jsxs("span", {
|
|
752
|
+
"data-trend": delta.trend ?? "neutral",
|
|
753
|
+
className: cn("inline-flex items-center gap-0.5 text-sm font-medium tabular-nums", deltaTone(delta)),
|
|
754
|
+
children: [TrendIcon && /* @__PURE__ */ jsx(TrendIcon, {
|
|
755
|
+
"aria-hidden": true,
|
|
756
|
+
weight: "bold",
|
|
757
|
+
className: "size-3"
|
|
758
|
+
}), delta.value]
|
|
759
|
+
})]
|
|
760
|
+
}),
|
|
761
|
+
meter && /* @__PURE__ */ jsx(Meter, {
|
|
762
|
+
label: meter.label,
|
|
763
|
+
value: meter.value,
|
|
764
|
+
showValue: false
|
|
765
|
+
}),
|
|
766
|
+
hint && /* @__PURE__ */ jsx("p", {
|
|
767
|
+
className: "text-xs text-kumo-subtle",
|
|
768
|
+
children: hint
|
|
769
|
+
})
|
|
770
|
+
]
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
const COLUMN_CLASSES = {
|
|
774
|
+
2: "sm:grid-cols-2",
|
|
775
|
+
3: "sm:grid-cols-2 lg:grid-cols-3",
|
|
776
|
+
4: "sm:grid-cols-2 lg:grid-cols-4"
|
|
777
|
+
};
|
|
778
|
+
/**
|
|
779
|
+
* Responsive grid of metric cards with optional delta, footnote, icon and meter.
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* ```tsx
|
|
783
|
+
* <StatGrid
|
|
784
|
+
* items={[
|
|
785
|
+
* { label: "Files", value: "1,284", delta: { value: "+36", trend: "up" } },
|
|
786
|
+
* { label: "Storage", value: "12.4 GB", hint: "of 50 GB", meter: { value: 25, label: "Storage used" } },
|
|
787
|
+
* { label: "Shared links", value: "18", icon: <LinkIcon /> },
|
|
788
|
+
* ]}
|
|
789
|
+
* />
|
|
790
|
+
* ```
|
|
791
|
+
*/
|
|
792
|
+
function StatGrid({ items, children, columns = 4, className }) {
|
|
793
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
794
|
+
className: cn("grid grid-cols-1 gap-2", COLUMN_CLASSES[columns], className),
|
|
795
|
+
children: [items?.map((item, index) => /* @__PURE__ */ jsx(Stat, { ...item }, index)), children]
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
//#endregion
|
|
799
|
+
//#region src/blocks/dashboard-page/dashboard-page.tsx
|
|
800
|
+
const DEFAULT_LABELS$2 = {
|
|
801
|
+
recent: "Recent files",
|
|
802
|
+
activity: "Activity",
|
|
803
|
+
viewAll: "View all"
|
|
804
|
+
};
|
|
805
|
+
function Panel({ title, action, children }) {
|
|
806
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
807
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
808
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
809
|
+
className: "flex items-center justify-between gap-2",
|
|
810
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
811
|
+
className: "m-0 text-sm font-semibold text-kumo-strong",
|
|
812
|
+
children: title
|
|
813
|
+
}), action]
|
|
814
|
+
}), children]
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* DashboardPage: the first screen after sign-in. A header, stats, recent
|
|
819
|
+
* files, and a side column with onboarding and activity. Render it inside
|
|
820
|
+
* `AppShell`; every section is optional.
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* ```tsx
|
|
824
|
+
* <AppShell nav={nav} header="Home">
|
|
825
|
+
* <DashboardPage
|
|
826
|
+
* title="Good morning, Ada"
|
|
827
|
+
* actions={<Button variant="primary">Upload</Button>}
|
|
828
|
+
* stats={[{ label: "Files", value: "1,284" }]}
|
|
829
|
+
* recentFiles={files}
|
|
830
|
+
* activity={{ events }}
|
|
831
|
+
* />
|
|
832
|
+
* </AppShell>
|
|
833
|
+
* ```
|
|
834
|
+
*/
|
|
835
|
+
function DashboardPage({ title, description, actions, stats, onboarding, recentFiles, onOpenFile, allFilesHref, activity, children, labels: labelsProp, className }) {
|
|
836
|
+
const labels = {
|
|
837
|
+
...DEFAULT_LABELS$2,
|
|
838
|
+
...labelsProp
|
|
839
|
+
};
|
|
840
|
+
const hasSide = Boolean(onboarding || activity);
|
|
841
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
842
|
+
className: cn("@container mx-auto flex w-full max-w-6xl flex-col gap-5 p-4 md:p-6", className),
|
|
843
|
+
children: [
|
|
844
|
+
/* @__PURE__ */ jsxs("header", {
|
|
845
|
+
className: "flex flex-wrap items-end justify-between gap-3",
|
|
846
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
847
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
848
|
+
children: [/* @__PURE__ */ jsx("h1", {
|
|
849
|
+
className: "m-0 text-xl font-semibold text-kumo-strong",
|
|
850
|
+
children: title
|
|
851
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
852
|
+
className: "m-0 text-sm text-kumo-subtle",
|
|
853
|
+
children: description
|
|
854
|
+
})]
|
|
855
|
+
}), actions && /* @__PURE__ */ jsx("div", {
|
|
856
|
+
className: "flex items-center gap-2",
|
|
857
|
+
children: actions
|
|
858
|
+
})]
|
|
859
|
+
}),
|
|
860
|
+
stats && stats.length > 0 && /* @__PURE__ */ jsx(StatGrid, {
|
|
861
|
+
items: stats,
|
|
862
|
+
columns: Math.min(4, Math.max(2, stats.length))
|
|
863
|
+
}),
|
|
864
|
+
/* @__PURE__ */ jsxs("div", {
|
|
865
|
+
className: cn("grid grid-cols-1 gap-5", hasSide && "@4xl:grid-cols-[minmax(0,1fr)_18rem]"),
|
|
866
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
867
|
+
className: "flex min-w-0 flex-col gap-5",
|
|
868
|
+
children: [recentFiles && /* @__PURE__ */ jsx(Panel, {
|
|
869
|
+
title: labels.recent,
|
|
870
|
+
action: allFilesHref && /* @__PURE__ */ jsx(Link, {
|
|
871
|
+
href: allFilesHref,
|
|
872
|
+
className: "text-sm",
|
|
873
|
+
children: labels.viewAll
|
|
874
|
+
}),
|
|
875
|
+
children: /* @__PURE__ */ jsx(FileTable, {
|
|
876
|
+
items: recentFiles,
|
|
877
|
+
selectable: false,
|
|
878
|
+
onOpen: onOpenFile
|
|
879
|
+
})
|
|
880
|
+
}), children]
|
|
881
|
+
}), hasSide && /* @__PURE__ */ jsxs("aside", {
|
|
882
|
+
className: "flex min-w-0 flex-col gap-5",
|
|
883
|
+
children: [onboarding && /* @__PURE__ */ jsx(OnboardingChecklist, { ...onboarding }), activity && /* @__PURE__ */ jsx(Panel, {
|
|
884
|
+
title: labels.activity,
|
|
885
|
+
children: /* @__PURE__ */ jsx(ActivityFeed, { ...activity })
|
|
886
|
+
})]
|
|
887
|
+
})]
|
|
888
|
+
})
|
|
889
|
+
]
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
//#endregion
|
|
893
|
+
//#region src/blocks/error-page/error-page.tsx
|
|
894
|
+
const DEFAULT_COPY = {
|
|
895
|
+
403: {
|
|
896
|
+
title: "You don't have access",
|
|
897
|
+
description: "Ask the owner to share it with you, or switch accounts."
|
|
898
|
+
},
|
|
899
|
+
404: {
|
|
900
|
+
title: "Page not found",
|
|
901
|
+
description: "This page doesn't exist or was moved."
|
|
902
|
+
},
|
|
903
|
+
500: {
|
|
904
|
+
title: "Something went wrong",
|
|
905
|
+
description: "We couldn't load this page. Try again in a moment."
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
/**
|
|
909
|
+
* ErrorPage: a quiet 404 / 403 / 500 page with a way back.
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
* ```tsx
|
|
913
|
+
* <ErrorPage status={404} homeHref="/files" homeLabel="Back to files" />
|
|
914
|
+
* <ErrorPage status={500} details="Request ID 7f3a…" actions={<Button onClick={retry}>Retry</Button>} />
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
function ErrorPage({ status = 404, title, description, homeHref = "/", homeLabel = "Go home", actions, logo, details, fullScreen = true, className }) {
|
|
918
|
+
const copy = DEFAULT_COPY[status] ?? DEFAULT_COPY[500];
|
|
919
|
+
return /* @__PURE__ */ jsx("main", {
|
|
920
|
+
className: cn("flex w-full items-center justify-center bg-kumo-canvas px-4 py-12 text-kumo-default", fullScreen && "min-h-dvh", className),
|
|
921
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
922
|
+
className: "flex w-full max-w-sm flex-col items-start gap-3",
|
|
923
|
+
children: [
|
|
924
|
+
logo,
|
|
925
|
+
/* @__PURE__ */ jsx("span", {
|
|
926
|
+
className: "font-mono text-sm text-kumo-subtle tabular-nums",
|
|
927
|
+
children: status
|
|
928
|
+
}),
|
|
929
|
+
/* @__PURE__ */ jsx("h1", {
|
|
930
|
+
className: "m-0 text-2xl font-semibold text-kumo-strong",
|
|
931
|
+
children: title ?? copy.title
|
|
932
|
+
}),
|
|
933
|
+
/* @__PURE__ */ jsx("p", {
|
|
934
|
+
className: "m-0 text-base text-kumo-subtle",
|
|
935
|
+
children: description ?? copy.description
|
|
936
|
+
}),
|
|
937
|
+
(homeHref !== null || actions) && /* @__PURE__ */ jsxs("div", {
|
|
938
|
+
className: "mt-2 flex flex-wrap items-center gap-2",
|
|
939
|
+
children: [homeHref !== null && /* @__PURE__ */ jsx(LinkButton, {
|
|
940
|
+
href: homeHref,
|
|
941
|
+
variant: "primary",
|
|
942
|
+
children: homeLabel
|
|
943
|
+
}), actions]
|
|
944
|
+
}),
|
|
945
|
+
details && /* @__PURE__ */ jsx("p", {
|
|
946
|
+
className: "m-0 mt-2 text-xs text-kumo-subtle",
|
|
947
|
+
children: details
|
|
948
|
+
})
|
|
949
|
+
]
|
|
950
|
+
})
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
//#endregion
|
|
954
|
+
//#region src/blocks/folder-grid/folder-grid.tsx
|
|
955
|
+
const DEFAULT_LABELS$1 = {
|
|
956
|
+
itemCount: (count) => `${count} ${count === 1 ? "file" : "files"}`,
|
|
957
|
+
selectItem: (name) => `Select ${name}`,
|
|
958
|
+
actions: (name) => `Actions for ${name}`
|
|
959
|
+
};
|
|
960
|
+
/**
|
|
961
|
+
* FolderGrid — responsive grid of folder and file cards.
|
|
962
|
+
*
|
|
963
|
+
* @example
|
|
964
|
+
* ```tsx
|
|
965
|
+
* <FolderGrid
|
|
966
|
+
* items={[{ id: "1", name: "Receipts", kind: "folder", itemCount: 48, size: 12_400_000 }]}
|
|
967
|
+
* onOpen={(folder) => navigate(folder.id)}
|
|
968
|
+
* actions={[{ label: "Share", onSelect: share }]}
|
|
969
|
+
* />
|
|
970
|
+
* ```
|
|
971
|
+
*/
|
|
972
|
+
function FolderGrid({ items, selectable = false, selectedIds, defaultSelectedIds = [], onSelectionChange, onOpen, actions, meta, empty, labels: labelsProp, locale, className }) {
|
|
973
|
+
const labels = {
|
|
974
|
+
...DEFAULT_LABELS$1,
|
|
975
|
+
...labelsProp
|
|
976
|
+
};
|
|
977
|
+
const [selected, setSelected] = useControllable(selectedIds, defaultSelectedIds, onSelectionChange);
|
|
978
|
+
if (items.length === 0 && empty) return /* @__PURE__ */ jsx(Fragment$1, { children: empty });
|
|
979
|
+
const defaultMeta = (item) => [
|
|
980
|
+
item.kind === "folder" && item.itemCount !== void 0 ? labels.itemCount(item.itemCount) : void 0,
|
|
981
|
+
item.size === void 0 ? void 0 : formatFileSize(item.size, locale),
|
|
982
|
+
item.kind !== "folder" && item.modifiedAt !== void 0 ? formatFileDate(item.modifiedAt, locale) : void 0
|
|
983
|
+
].filter(Boolean).join(" · ");
|
|
984
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
985
|
+
className: cn("grid grid-cols-[repeat(auto-fill,minmax(14rem,1fr))] gap-2", className),
|
|
986
|
+
children: items.map((item) => {
|
|
987
|
+
const isSelected = selected.includes(item.id);
|
|
988
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
989
|
+
"data-selected": isSelected || void 0,
|
|
990
|
+
onClick: onOpen && (() => onOpen(item)),
|
|
991
|
+
className: cn("flex flex-col overflow-hidden rounded-lg bg-kumo-elevated hover:bg-kumo-tint", isSelected ? "bg-kumo-tint" : "hover:bg-kumo-tint", onOpen && "cursor-pointer"),
|
|
992
|
+
children: [item.thumbnailUrl && /* @__PURE__ */ jsx("img", {
|
|
993
|
+
src: item.thumbnailUrl,
|
|
994
|
+
alt: "",
|
|
995
|
+
className: "aspect-[4/3] w-full bg-kumo-recessed object-cover"
|
|
996
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
997
|
+
className: "flex items-center gap-2 px-2.5 py-2",
|
|
998
|
+
children: [
|
|
999
|
+
selectable && /* @__PURE__ */ jsx("span", {
|
|
1000
|
+
onClick: (e) => e.stopPropagation(),
|
|
1001
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1002
|
+
"aria-label": labels.selectItem(item.name),
|
|
1003
|
+
checked: isSelected,
|
|
1004
|
+
onCheckedChange: (checked) => setSelected(checked ? [...selected, item.id] : selected.filter((id) => id !== item.id))
|
|
1005
|
+
})
|
|
1006
|
+
}),
|
|
1007
|
+
/* @__PURE__ */ jsx(FileKindIcon, {
|
|
1008
|
+
kind: item.kind,
|
|
1009
|
+
size: 22
|
|
1010
|
+
}),
|
|
1011
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1012
|
+
className: "min-w-0 flex-1",
|
|
1013
|
+
children: [onOpen ? /* @__PURE__ */ jsx("button", {
|
|
1014
|
+
type: "button",
|
|
1015
|
+
className: "block w-full cursor-pointer truncate text-left text-base font-medium text-kumo-default",
|
|
1016
|
+
children: item.name
|
|
1017
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
1018
|
+
className: "truncate text-base font-medium text-kumo-default",
|
|
1019
|
+
children: item.name
|
|
1020
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1021
|
+
className: "truncate text-sm text-kumo-subtle",
|
|
1022
|
+
children: meta ? meta(item) : defaultMeta(item)
|
|
1023
|
+
})]
|
|
1024
|
+
}),
|
|
1025
|
+
actions && /* @__PURE__ */ jsx(ItemActionsMenu, {
|
|
1026
|
+
item,
|
|
1027
|
+
actions,
|
|
1028
|
+
label: labels.actions(item.name),
|
|
1029
|
+
className: "-mr-1"
|
|
1030
|
+
})
|
|
1031
|
+
]
|
|
1032
|
+
})]
|
|
1033
|
+
}, item.id);
|
|
1034
|
+
})
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region src/blocks/login-page/login-page.tsx
|
|
1039
|
+
/**
|
|
1040
|
+
* LoginPage: a full-screen sign-in or sign-up page around `AuthCard`.
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* ```tsx
|
|
1044
|
+
* <LoginPage
|
|
1045
|
+
* logo={<FldrMark />}
|
|
1046
|
+
* providers={[{ id: "google", label: "Continue with Google", icon: <GoogleLogoIcon /> }]}
|
|
1047
|
+
* onProvider={startOAuth}
|
|
1048
|
+
* onSubmit={({ email, password }) => signIn(email, password)}
|
|
1049
|
+
* legal={<>By continuing you agree to the <a href="/terms">Terms</a>.</>}
|
|
1050
|
+
* />
|
|
1051
|
+
* ```
|
|
1052
|
+
*/
|
|
1053
|
+
function LoginPage({ logo, legal, className, ...card }) {
|
|
1054
|
+
return /* @__PURE__ */ jsxs("main", {
|
|
1055
|
+
className: cn("flex min-h-dvh w-full flex-col items-center justify-center gap-6 bg-kumo-canvas px-4 py-12 text-kumo-default", className),
|
|
1056
|
+
children: [
|
|
1057
|
+
logo && /* @__PURE__ */ jsx("div", {
|
|
1058
|
+
className: "flex items-center justify-center",
|
|
1059
|
+
children: logo
|
|
1060
|
+
}),
|
|
1061
|
+
/* @__PURE__ */ jsx(AuthCard, { ...card }),
|
|
1062
|
+
legal && /* @__PURE__ */ jsx("p", {
|
|
1063
|
+
className: "m-0 max-w-[360px] text-center text-xs text-kumo-subtle [&_a]:text-kumo-default [&_a]:underline",
|
|
1064
|
+
children: legal
|
|
1065
|
+
})
|
|
1066
|
+
]
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
//#endregion
|
|
1070
|
+
//#region src/blocks/page-header/page-header.tsx
|
|
1071
|
+
const KUMO_PAGE_HEADER_VARIANTS = { spacing: {
|
|
1072
|
+
compact: {
|
|
1073
|
+
classes: "gap-1",
|
|
1074
|
+
description: "Compact spacing between header elements"
|
|
1075
|
+
},
|
|
1076
|
+
base: {
|
|
1077
|
+
classes: "gap-2",
|
|
1078
|
+
description: "Default spacing between header elements"
|
|
1079
|
+
},
|
|
1080
|
+
relaxed: {
|
|
1081
|
+
classes: "gap-4",
|
|
1082
|
+
description: "Relaxed spacing for more prominent headers"
|
|
1083
|
+
}
|
|
1084
|
+
} };
|
|
1085
|
+
const KUMO_PAGE_HEADER_DEFAULT_VARIANTS = { spacing: "base" };
|
|
1086
|
+
function pageHeaderVariants({ spacing = KUMO_PAGE_HEADER_DEFAULT_VARIANTS.spacing } = {}) {
|
|
1087
|
+
return cn("flex flex-col", KUMO_PAGE_HEADER_VARIANTS.spacing[spacing].classes);
|
|
1088
|
+
}
|
|
1089
|
+
function PageHeader({ breadcrumbs, title, description, tabs, defaultTab, onValueChange, spacing = "base", className, children }) {
|
|
1090
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1091
|
+
className: cn(pageHeaderVariants({ spacing }), className),
|
|
1092
|
+
children: [
|
|
1093
|
+
/* @__PURE__ */ jsx("div", {
|
|
1094
|
+
className: "border-b border-kumo-line",
|
|
1095
|
+
children: breadcrumbs
|
|
1096
|
+
}),
|
|
1097
|
+
(title || description) && /* @__PURE__ */ jsxs("div", {
|
|
1098
|
+
className: "flex flex-col gap-2 py-3 pl-3",
|
|
1099
|
+
children: [title && /* @__PURE__ */ jsx("h1", {
|
|
1100
|
+
className: "font-heading text-3xl font-semibold text-kumo-default",
|
|
1101
|
+
children: title
|
|
1102
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
1103
|
+
className: "max-w-prose text-base text-kumo-subtle",
|
|
1104
|
+
children: description
|
|
1105
|
+
})]
|
|
1106
|
+
}),
|
|
1107
|
+
tabs && /* @__PURE__ */ jsxs("div", {
|
|
1108
|
+
className: "flex w-full items-center justify-between border-b border-kumo-line pt-1 pb-3 pl-3",
|
|
1109
|
+
children: [/* @__PURE__ */ jsx(Tabs, {
|
|
1110
|
+
tabs,
|
|
1111
|
+
selectedValue: defaultTab,
|
|
1112
|
+
onValueChange: (nextValue) => {
|
|
1113
|
+
onValueChange?.(String(nextValue));
|
|
1114
|
+
}
|
|
1115
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1116
|
+
className: "flex items-center gap-2",
|
|
1117
|
+
children
|
|
1118
|
+
})]
|
|
1119
|
+
})
|
|
1120
|
+
]
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
//#endregion
|
|
1124
|
+
//#region src/blocks/resource-list/resource-list.tsx
|
|
1125
|
+
/**
|
|
1126
|
+
* ResourceListPage - A layout component for resource list pages
|
|
1127
|
+
*
|
|
1128
|
+
* Layouts are page-level components that provide consistent structure
|
|
1129
|
+
* for common page patterns like resource lists, dashboards, and settings.
|
|
1130
|
+
*/
|
|
1131
|
+
function ResourceListPage({ title, description, icon, usage, additionalContent, children, className }) {
|
|
1132
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1133
|
+
className: cn("h-full min-h-screen w-full bg-kumo-overlay", className),
|
|
1134
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1135
|
+
className: "mx-auto flex max-w-[1400px] flex-col p-6 md:gap-4 md:p-8 lg:px-10 lg:py-9 xl:gap-6",
|
|
1136
|
+
children: [
|
|
1137
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1138
|
+
className: "flex flex-col",
|
|
1139
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1140
|
+
className: "mb-1.5 flex items-center gap-1.5",
|
|
1141
|
+
children: [icon, /* @__PURE__ */ jsx("h1", {
|
|
1142
|
+
className: "font-heading m-0 p-0 text-3xl font-semibold",
|
|
1143
|
+
children: title
|
|
1144
|
+
})]
|
|
1145
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1146
|
+
className: "hidden p-0 text-lg leading-normal text-pretty text-kumo-subtle md:block",
|
|
1147
|
+
children: description
|
|
1148
|
+
})]
|
|
1149
|
+
}),
|
|
1150
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1151
|
+
className: "flex flex-col-reverse gap-6 xl:flex-row xl:gap-8",
|
|
1152
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1153
|
+
className: "min-w-0 grow",
|
|
1154
|
+
children
|
|
1155
|
+
}), (usage || additionalContent) && /* @__PURE__ */ jsxs("div", {
|
|
1156
|
+
className: `top-22 flex h-fit w-full shrink-0 flex-col gap-4 xl:sticky xl:w-[380px]`,
|
|
1157
|
+
children: [usage, /* @__PURE__ */ jsx("div", {
|
|
1158
|
+
className: cn("hidden xl:block", usage ? "mt-6" : ""),
|
|
1159
|
+
children: additionalContent
|
|
1160
|
+
})]
|
|
1161
|
+
})]
|
|
1162
|
+
}),
|
|
1163
|
+
/* @__PURE__ */ jsx("div", {
|
|
1164
|
+
className: "mt-6 xl:hidden",
|
|
1165
|
+
children: additionalContent
|
|
1166
|
+
})
|
|
1167
|
+
]
|
|
1168
|
+
})
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
//#endregion
|
|
1172
|
+
//#region src/blocks/settings-section/settings-section.tsx
|
|
1173
|
+
/**
|
|
1174
|
+
* A titled group of settings rows.
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* ```tsx
|
|
1178
|
+
* <SettingsSection title="Folder" description="How this folder behaves.">
|
|
1179
|
+
* <SettingsRow label="Auto-file receipts" control={<Switch />} />
|
|
1180
|
+
* </SettingsSection>
|
|
1181
|
+
* <SettingsSection title="Danger zone" variant="danger">
|
|
1182
|
+
* <SettingsRow label="Delete folder" control={<Button variant="destructive">Delete</Button>} />
|
|
1183
|
+
* </SettingsSection>
|
|
1184
|
+
* ```
|
|
1185
|
+
*/
|
|
1186
|
+
function SettingsSection({ title, description, variant = "default", children, className }) {
|
|
1187
|
+
const headingId = useId();
|
|
1188
|
+
const danger = variant === "danger";
|
|
1189
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
1190
|
+
"aria-labelledby": headingId,
|
|
1191
|
+
className: cn("flex flex-col gap-2", className),
|
|
1192
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1193
|
+
className: "flex flex-col gap-0.5",
|
|
1194
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
1195
|
+
id: headingId,
|
|
1196
|
+
className: cn("text-base font-semibold", danger ? "text-kumo-danger" : "text-kumo-default"),
|
|
1197
|
+
children: title
|
|
1198
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
1199
|
+
className: "text-sm text-kumo-subtle",
|
|
1200
|
+
children: description
|
|
1201
|
+
})]
|
|
1202
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1203
|
+
className: cn("divide-y border-y", danger ? "divide-kumo-danger/20 border-kumo-danger/20" : "divide-kumo-hairline border-kumo-hairline"),
|
|
1204
|
+
children
|
|
1205
|
+
})]
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
/** A single setting: label and description on the left, control on the right. */
|
|
1209
|
+
function SettingsRow({ label, description, control, htmlFor, className }) {
|
|
1210
|
+
const Label = htmlFor ? "label" : "div";
|
|
1211
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1212
|
+
className: cn("flex flex-col gap-2 py-2.5 sm:flex-row sm:items-center sm:justify-between sm:gap-6", className),
|
|
1213
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1214
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
1215
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
1216
|
+
htmlFor,
|
|
1217
|
+
className: "text-sm font-medium text-kumo-default",
|
|
1218
|
+
children: label
|
|
1219
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
1220
|
+
className: "text-sm text-kumo-subtle",
|
|
1221
|
+
children: description
|
|
1222
|
+
})]
|
|
1223
|
+
}), control && /* @__PURE__ */ jsx("div", {
|
|
1224
|
+
className: "shrink-0",
|
|
1225
|
+
children: control
|
|
1226
|
+
})]
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
/** Sticky bottom bar shown while a settings form has unsaved changes. */
|
|
1230
|
+
function SettingsSaveBar({ dirty, onSave, onDiscard, saving = false, labels = {}, className }) {
|
|
1231
|
+
if (!dirty) return null;
|
|
1232
|
+
const { message = "Unsaved changes", discard = "Discard", save = "Save" } = labels;
|
|
1233
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1234
|
+
role: "region",
|
|
1235
|
+
"aria-label": message,
|
|
1236
|
+
className: cn("sticky bottom-4 z-10 flex items-center justify-between gap-3 rounded-lg border border-kumo-line bg-kumo-elevated py-2 pr-2 pl-4 shadow-sm", className),
|
|
1237
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1238
|
+
className: "text-sm text-kumo-default",
|
|
1239
|
+
children: message
|
|
1240
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1241
|
+
className: "flex gap-2",
|
|
1242
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1243
|
+
variant: "ghost",
|
|
1244
|
+
onClick: onDiscard,
|
|
1245
|
+
disabled: saving,
|
|
1246
|
+
children: discard
|
|
1247
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1248
|
+
variant: "primary",
|
|
1249
|
+
onClick: onSave,
|
|
1250
|
+
loading: saving,
|
|
1251
|
+
children: save
|
|
1252
|
+
})]
|
|
1253
|
+
})]
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
//#endregion
|
|
1257
|
+
//#region src/blocks/share-dialog/share-dialog.tsx
|
|
1258
|
+
const DEFAULT_ROLES = {
|
|
1259
|
+
viewer: "Viewer",
|
|
1260
|
+
editor: "Editor"
|
|
1261
|
+
};
|
|
1262
|
+
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1263
|
+
function initials(name) {
|
|
1264
|
+
const parts = name.trim().split(/\s+/);
|
|
1265
|
+
return ((parts[0]?.[0] ?? "") + (parts[1]?.[0] ?? "")).toUpperCase();
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Share dialog for a file or folder: invite people, manage their roles,
|
|
1269
|
+
* set general link access and copy the link.
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* ```tsx
|
|
1273
|
+
* <ShareDialog
|
|
1274
|
+
* resourceName="Q4 receipts"
|
|
1275
|
+
* trigger={<Button>Share</Button>}
|
|
1276
|
+
* members={members}
|
|
1277
|
+
* linkAccess={access}
|
|
1278
|
+
* link="https://fldr.app/f/q4-receipts"
|
|
1279
|
+
* onInvite={(email, role) => invite(email, role)}
|
|
1280
|
+
* onRoleChange={setRole}
|
|
1281
|
+
* onRemove={remove}
|
|
1282
|
+
* onLinkAccessChange={setAccess}
|
|
1283
|
+
* />
|
|
1284
|
+
* ```
|
|
1285
|
+
*/
|
|
1286
|
+
function ShareDialog({ resourceName, members, linkAccess, link, onInvite, onRoleChange, onRemove, onLinkAccessChange, roles = DEFAULT_ROLES, open, onOpenChange, trigger, labels = {}, className }) {
|
|
1287
|
+
const roleKeys = Object.keys(roles);
|
|
1288
|
+
const [email, setEmail] = useState("");
|
|
1289
|
+
const [inviteRole, setInviteRole] = useState(roleKeys[0] ?? "");
|
|
1290
|
+
const l = {
|
|
1291
|
+
title: (name) => `Share "${name}"`,
|
|
1292
|
+
emailPlaceholder: "Add people by email",
|
|
1293
|
+
invite: "Invite",
|
|
1294
|
+
people: "People with access",
|
|
1295
|
+
owner: "Owner",
|
|
1296
|
+
remove: (name) => `Remove ${name}`,
|
|
1297
|
+
roleFor: (name) => `Role for ${name}`,
|
|
1298
|
+
generalAccess: "General access",
|
|
1299
|
+
restricted: "Restricted",
|
|
1300
|
+
restrictedHint: "Only people with access can open",
|
|
1301
|
+
anyone: "Anyone with the link",
|
|
1302
|
+
anyoneHint: "Anyone on the internet with the link can open",
|
|
1303
|
+
linkRole: "Link role",
|
|
1304
|
+
copyLink: "Copy link",
|
|
1305
|
+
...labels
|
|
1306
|
+
};
|
|
1307
|
+
const valid = EMAIL_RE.test(email.trim());
|
|
1308
|
+
const submit = (event) => {
|
|
1309
|
+
event.preventDefault();
|
|
1310
|
+
if (!valid) return;
|
|
1311
|
+
onInvite(email.trim(), inviteRole);
|
|
1312
|
+
setEmail("");
|
|
1313
|
+
};
|
|
1314
|
+
const roleOptions = roleKeys.map((key) => /* @__PURE__ */ jsx(Select.Option, {
|
|
1315
|
+
value: key,
|
|
1316
|
+
children: roles[key]
|
|
1317
|
+
}, key));
|
|
1318
|
+
const anyone = linkAccess.scope === "anyone";
|
|
1319
|
+
return /* @__PURE__ */ jsxs(LayerDialog.Root, {
|
|
1320
|
+
open,
|
|
1321
|
+
onOpenChange,
|
|
1322
|
+
children: [trigger && /* @__PURE__ */ jsx(LayerDialog.Trigger, { render: trigger }), /* @__PURE__ */ jsxs(LayerDialog.Content, {
|
|
1323
|
+
size: "base",
|
|
1324
|
+
children: [/* @__PURE__ */ jsx(LayerDialog.Title, { children: l.title(resourceName) }), /* @__PURE__ */ jsx(LayerDialog.Body, { children: /* @__PURE__ */ jsxs("div", {
|
|
1325
|
+
className: cn("flex flex-col gap-4", className),
|
|
1326
|
+
children: [
|
|
1327
|
+
/* @__PURE__ */ jsxs("form", {
|
|
1328
|
+
onSubmit: submit,
|
|
1329
|
+
className: "flex gap-2",
|
|
1330
|
+
children: [
|
|
1331
|
+
/* @__PURE__ */ jsx(Input, {
|
|
1332
|
+
type: "email",
|
|
1333
|
+
"aria-label": l.emailPlaceholder,
|
|
1334
|
+
placeholder: l.emailPlaceholder,
|
|
1335
|
+
value: email,
|
|
1336
|
+
onChange: (event) => setEmail(event.target.value),
|
|
1337
|
+
className: "min-w-0 flex-1"
|
|
1338
|
+
}),
|
|
1339
|
+
/* @__PURE__ */ jsx(Select, {
|
|
1340
|
+
"aria-label": l.roleFor(email || l.invite),
|
|
1341
|
+
value: inviteRole,
|
|
1342
|
+
onValueChange: (value) => setInviteRole(value),
|
|
1343
|
+
renderValue: (value) => roles[value],
|
|
1344
|
+
className: "w-26",
|
|
1345
|
+
children: roleOptions
|
|
1346
|
+
}),
|
|
1347
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1348
|
+
type: "submit",
|
|
1349
|
+
variant: "primary",
|
|
1350
|
+
disabled: !valid,
|
|
1351
|
+
children: l.invite
|
|
1352
|
+
})
|
|
1353
|
+
]
|
|
1354
|
+
}),
|
|
1355
|
+
/* @__PURE__ */ jsxs("section", {
|
|
1356
|
+
className: "flex flex-col gap-1",
|
|
1357
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
1358
|
+
className: "text-sm font-medium text-kumo-subtle",
|
|
1359
|
+
children: l.people
|
|
1360
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
1361
|
+
className: "-mx-2 flex flex-col",
|
|
1362
|
+
children: members.map((member) => /* @__PURE__ */ jsxs("li", {
|
|
1363
|
+
className: "flex items-center gap-3 rounded-lg px-2 py-1.5 hover:bg-kumo-tint",
|
|
1364
|
+
children: [
|
|
1365
|
+
member.avatarUrl ? /* @__PURE__ */ jsx("img", {
|
|
1366
|
+
src: member.avatarUrl,
|
|
1367
|
+
alt: "",
|
|
1368
|
+
className: "size-8 shrink-0 rounded-full object-cover"
|
|
1369
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
1370
|
+
"aria-hidden": true,
|
|
1371
|
+
className: "flex size-8 shrink-0 items-center justify-center rounded-full bg-kumo-fill text-xs font-medium text-kumo-strong",
|
|
1372
|
+
children: initials(member.name)
|
|
1373
|
+
}),
|
|
1374
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1375
|
+
className: "min-w-0 flex-1",
|
|
1376
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1377
|
+
className: "truncate text-sm text-kumo-default",
|
|
1378
|
+
children: member.name
|
|
1379
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1380
|
+
className: "truncate text-xs text-kumo-subtle",
|
|
1381
|
+
children: member.email
|
|
1382
|
+
})]
|
|
1383
|
+
}),
|
|
1384
|
+
member.owner ? /* @__PURE__ */ jsx("span", {
|
|
1385
|
+
className: "pr-2 text-sm text-kumo-subtle",
|
|
1386
|
+
children: l.owner
|
|
1387
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Select, {
|
|
1388
|
+
size: "sm",
|
|
1389
|
+
"aria-label": l.roleFor(member.name),
|
|
1390
|
+
value: member.role,
|
|
1391
|
+
onValueChange: (value) => onRoleChange(member.id, value),
|
|
1392
|
+
renderValue: (value) => roles[value],
|
|
1393
|
+
className: "w-24",
|
|
1394
|
+
children: roleOptions
|
|
1395
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1396
|
+
size: "sm",
|
|
1397
|
+
variant: "ghost",
|
|
1398
|
+
shape: "square",
|
|
1399
|
+
icon: /* @__PURE__ */ jsx(XIcon, {}),
|
|
1400
|
+
"aria-label": l.remove(member.name),
|
|
1401
|
+
onClick: () => onRemove(member.id)
|
|
1402
|
+
})] })
|
|
1403
|
+
]
|
|
1404
|
+
}, member.id))
|
|
1405
|
+
})]
|
|
1406
|
+
}),
|
|
1407
|
+
/* @__PURE__ */ jsxs("section", {
|
|
1408
|
+
className: "flex flex-col gap-2",
|
|
1409
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
1410
|
+
className: "text-sm font-medium text-kumo-subtle",
|
|
1411
|
+
children: l.generalAccess
|
|
1412
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1413
|
+
className: "flex items-center gap-3",
|
|
1414
|
+
children: [
|
|
1415
|
+
/* @__PURE__ */ jsx("span", {
|
|
1416
|
+
className: "flex size-8 shrink-0 items-center justify-center rounded-full bg-kumo-fill text-kumo-subtle",
|
|
1417
|
+
children: anyone ? /* @__PURE__ */ jsx(GlobeIcon, { size: 16 }) : /* @__PURE__ */ jsx(LockIcon, { size: 16 })
|
|
1418
|
+
}),
|
|
1419
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1420
|
+
className: "min-w-0 flex-1",
|
|
1421
|
+
children: [/* @__PURE__ */ jsxs(Select, {
|
|
1422
|
+
size: "sm",
|
|
1423
|
+
"aria-label": l.generalAccess,
|
|
1424
|
+
value: linkAccess.scope,
|
|
1425
|
+
onValueChange: (value) => onLinkAccessChange({
|
|
1426
|
+
...linkAccess,
|
|
1427
|
+
scope: value
|
|
1428
|
+
}),
|
|
1429
|
+
renderValue: (value) => value === "anyone" ? l.anyone : l.restricted,
|
|
1430
|
+
className: "w-auto",
|
|
1431
|
+
children: [/* @__PURE__ */ jsx(Select.Option, {
|
|
1432
|
+
value: "restricted",
|
|
1433
|
+
children: l.restricted
|
|
1434
|
+
}), /* @__PURE__ */ jsx(Select.Option, {
|
|
1435
|
+
value: "anyone",
|
|
1436
|
+
children: l.anyone
|
|
1437
|
+
})]
|
|
1438
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1439
|
+
className: "mt-0.5 truncate text-xs text-kumo-subtle",
|
|
1440
|
+
children: anyone ? l.anyoneHint : l.restrictedHint
|
|
1441
|
+
})]
|
|
1442
|
+
}),
|
|
1443
|
+
anyone && /* @__PURE__ */ jsx(Select, {
|
|
1444
|
+
size: "sm",
|
|
1445
|
+
"aria-label": l.linkRole,
|
|
1446
|
+
value: linkAccess.role,
|
|
1447
|
+
onValueChange: (value) => onLinkAccessChange({
|
|
1448
|
+
...linkAccess,
|
|
1449
|
+
role: value
|
|
1450
|
+
}),
|
|
1451
|
+
renderValue: (value) => roles[value],
|
|
1452
|
+
className: "w-24",
|
|
1453
|
+
children: roleOptions
|
|
1454
|
+
})
|
|
1455
|
+
]
|
|
1456
|
+
})]
|
|
1457
|
+
}),
|
|
1458
|
+
/* @__PURE__ */ jsx(ClipboardText, {
|
|
1459
|
+
text: link,
|
|
1460
|
+
size: "base",
|
|
1461
|
+
labels: { copyAction: l.copyLink }
|
|
1462
|
+
})
|
|
1463
|
+
]
|
|
1464
|
+
}) })]
|
|
1465
|
+
})]
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
//#endregion
|
|
1469
|
+
//#region src/blocks/upload-dropzone/upload-dropzone.tsx
|
|
1470
|
+
const DEFAULT_LABELS = {
|
|
1471
|
+
title: "Drop files here",
|
|
1472
|
+
hint: "Receipts, documents and images",
|
|
1473
|
+
browse: "Browse files",
|
|
1474
|
+
done: "Uploaded",
|
|
1475
|
+
failed: "Upload failed",
|
|
1476
|
+
retry: "Retry",
|
|
1477
|
+
remove: "Remove"
|
|
1478
|
+
};
|
|
1479
|
+
function matchesAccept(file, accept) {
|
|
1480
|
+
if (!accept) return true;
|
|
1481
|
+
const name = file.name.toLowerCase();
|
|
1482
|
+
const type = file.type.toLowerCase();
|
|
1483
|
+
return accept.split(",").some((raw) => {
|
|
1484
|
+
const rule = raw.trim().toLowerCase();
|
|
1485
|
+
if (!rule) return false;
|
|
1486
|
+
if (rule.startsWith(".")) return name.endsWith(rule);
|
|
1487
|
+
if (rule.endsWith("/*")) return type.startsWith(rule.slice(0, -1));
|
|
1488
|
+
return type === rule;
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Drag-and-drop upload area with a file list. Performs no network requests:
|
|
1493
|
+
* the consumer owns upload state and reacts to the callbacks.
|
|
1494
|
+
*
|
|
1495
|
+
* @example
|
|
1496
|
+
* ```tsx
|
|
1497
|
+
* <UploadDropzone
|
|
1498
|
+
* accept=".pdf,image/*"
|
|
1499
|
+
* maxSize={10 * 1024 * 1024}
|
|
1500
|
+
* uploads={uploads}
|
|
1501
|
+
* onFiles={startUploads}
|
|
1502
|
+
* onReject={(r) => toast(`${r.length} file(s) skipped`)}
|
|
1503
|
+
* onRetry={retryUpload}
|
|
1504
|
+
* onRemove={removeUpload}
|
|
1505
|
+
* />
|
|
1506
|
+
* ```
|
|
1507
|
+
*/
|
|
1508
|
+
function UploadDropzone({ uploads = [], onFiles, onReject, onRetry, onRemove, accept, multiple = true, maxSize, disabled = false, labels, className }) {
|
|
1509
|
+
const l = {
|
|
1510
|
+
...DEFAULT_LABELS,
|
|
1511
|
+
...labels
|
|
1512
|
+
};
|
|
1513
|
+
const inputRef = useRef(null);
|
|
1514
|
+
const hintId = useId();
|
|
1515
|
+
const [dragging, setDragging] = useState(false);
|
|
1516
|
+
const handleFiles = (list) => {
|
|
1517
|
+
if (!list || disabled) return;
|
|
1518
|
+
const files = multiple ? Array.from(list) : Array.from(list).slice(0, 1);
|
|
1519
|
+
const accepted = [];
|
|
1520
|
+
const rejected = [];
|
|
1521
|
+
for (const file of files) if (!matchesAccept(file, accept)) rejected.push({
|
|
1522
|
+
file,
|
|
1523
|
+
reason: "type"
|
|
1524
|
+
});
|
|
1525
|
+
else if (maxSize !== void 0 && file.size > maxSize) rejected.push({
|
|
1526
|
+
file,
|
|
1527
|
+
reason: "size"
|
|
1528
|
+
});
|
|
1529
|
+
else accepted.push(file);
|
|
1530
|
+
if (accepted.length) onFiles(accepted);
|
|
1531
|
+
if (rejected.length) onReject?.(rejected);
|
|
1532
|
+
};
|
|
1533
|
+
const onDragOver = (e) => {
|
|
1534
|
+
e.preventDefault();
|
|
1535
|
+
if (!disabled) setDragging(true);
|
|
1536
|
+
};
|
|
1537
|
+
const onDragLeave = (e) => {
|
|
1538
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setDragging(false);
|
|
1539
|
+
};
|
|
1540
|
+
const onDrop = (e) => {
|
|
1541
|
+
e.preventDefault();
|
|
1542
|
+
setDragging(false);
|
|
1543
|
+
handleFiles(e.dataTransfer.files);
|
|
1544
|
+
};
|
|
1545
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1546
|
+
className: cn("flex flex-col gap-2", className),
|
|
1547
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1548
|
+
"data-dragging": dragging || void 0,
|
|
1549
|
+
onDragOver,
|
|
1550
|
+
onDragLeave,
|
|
1551
|
+
onDrop,
|
|
1552
|
+
className: cn("flex flex-col items-center gap-1.5 rounded-lg border border-dashed border-kumo-line bg-kumo-elevated px-4 py-5 text-center", dragging && "border-kumo-brand bg-kumo-tint", disabled && "opacity-50"),
|
|
1553
|
+
children: [
|
|
1554
|
+
/* @__PURE__ */ jsx(UploadSimpleIcon, {
|
|
1555
|
+
size: 24,
|
|
1556
|
+
className: "text-kumo-subtle"
|
|
1557
|
+
}),
|
|
1558
|
+
/* @__PURE__ */ jsx("div", {
|
|
1559
|
+
className: "text-sm font-medium text-kumo-default",
|
|
1560
|
+
children: l.title
|
|
1561
|
+
}),
|
|
1562
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1563
|
+
id: hintId,
|
|
1564
|
+
className: "text-xs text-kumo-subtle",
|
|
1565
|
+
children: [l.hint, maxSize !== void 0 && ` · ${formatFileSize(maxSize)} max`]
|
|
1566
|
+
}),
|
|
1567
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1568
|
+
size: "sm",
|
|
1569
|
+
className: "mt-1",
|
|
1570
|
+
disabled,
|
|
1571
|
+
"aria-describedby": hintId,
|
|
1572
|
+
onClick: () => inputRef.current?.click(),
|
|
1573
|
+
children: l.browse
|
|
1574
|
+
}),
|
|
1575
|
+
/* @__PURE__ */ jsx("input", {
|
|
1576
|
+
ref: inputRef,
|
|
1577
|
+
type: "file",
|
|
1578
|
+
hidden: true,
|
|
1579
|
+
tabIndex: -1,
|
|
1580
|
+
accept,
|
|
1581
|
+
multiple,
|
|
1582
|
+
disabled,
|
|
1583
|
+
"data-testid": "upload-dropzone-input",
|
|
1584
|
+
onChange: (e) => {
|
|
1585
|
+
handleFiles(e.currentTarget.files);
|
|
1586
|
+
e.currentTarget.value = "";
|
|
1587
|
+
}
|
|
1588
|
+
})
|
|
1589
|
+
]
|
|
1590
|
+
}), uploads.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
1591
|
+
className: "m-0 flex list-none flex-col divide-y divide-kumo-hairline p-0",
|
|
1592
|
+
children: uploads.map((u) => /* @__PURE__ */ jsxs("li", {
|
|
1593
|
+
className: "flex items-center gap-3 px-1 py-1.5",
|
|
1594
|
+
children: [
|
|
1595
|
+
/* @__PURE__ */ jsx(FileIcon, {
|
|
1596
|
+
size: 18,
|
|
1597
|
+
className: "shrink-0 text-kumo-subtle"
|
|
1598
|
+
}),
|
|
1599
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1600
|
+
className: "flex min-w-0 grow flex-col gap-1",
|
|
1601
|
+
children: [
|
|
1602
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1603
|
+
className: "flex items-baseline justify-between gap-2 text-sm",
|
|
1604
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1605
|
+
className: "truncate text-kumo-default",
|
|
1606
|
+
children: u.name
|
|
1607
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1608
|
+
className: "shrink-0 text-xs text-kumo-subtle tabular-nums",
|
|
1609
|
+
children: formatFileSize(u.size)
|
|
1610
|
+
})]
|
|
1611
|
+
}),
|
|
1612
|
+
u.status === "uploading" && /* @__PURE__ */ jsx("div", {
|
|
1613
|
+
role: "progressbar",
|
|
1614
|
+
"aria-label": u.name,
|
|
1615
|
+
"aria-valuemin": 0,
|
|
1616
|
+
"aria-valuemax": 100,
|
|
1617
|
+
"aria-valuenow": Math.round(u.progress),
|
|
1618
|
+
className: "h-1 overflow-hidden rounded-full bg-kumo-recessed",
|
|
1619
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1620
|
+
className: "h-full bg-kumo-brand",
|
|
1621
|
+
style: { width: `${Math.min(100, Math.max(0, u.progress))}%` }
|
|
1622
|
+
})
|
|
1623
|
+
}),
|
|
1624
|
+
u.status === "done" && /* @__PURE__ */ jsxs("span", {
|
|
1625
|
+
className: "flex items-center gap-1 text-xs text-kumo-success",
|
|
1626
|
+
children: [
|
|
1627
|
+
/* @__PURE__ */ jsx(CheckCircleIcon, { size: 14 }),
|
|
1628
|
+
" ",
|
|
1629
|
+
l.done
|
|
1630
|
+
]
|
|
1631
|
+
}),
|
|
1632
|
+
u.status === "error" && /* @__PURE__ */ jsxs("span", {
|
|
1633
|
+
className: "flex items-center gap-1 text-xs text-kumo-danger",
|
|
1634
|
+
children: [
|
|
1635
|
+
/* @__PURE__ */ jsx(WarningCircleIcon, { size: 14 }),
|
|
1636
|
+
" ",
|
|
1637
|
+
u.error ?? l.failed
|
|
1638
|
+
]
|
|
1639
|
+
})
|
|
1640
|
+
]
|
|
1641
|
+
}),
|
|
1642
|
+
u.status === "error" && onRetry && /* @__PURE__ */ jsx(Button, {
|
|
1643
|
+
size: "sm",
|
|
1644
|
+
variant: "ghost",
|
|
1645
|
+
shape: "square",
|
|
1646
|
+
icon: ArrowClockwiseIcon,
|
|
1647
|
+
"aria-label": `${l.retry} ${u.name}`,
|
|
1648
|
+
onClick: () => onRetry(u.id)
|
|
1649
|
+
}),
|
|
1650
|
+
onRemove && /* @__PURE__ */ jsx(Button, {
|
|
1651
|
+
size: "sm",
|
|
1652
|
+
variant: "ghost",
|
|
1653
|
+
shape: "square",
|
|
1654
|
+
icon: XIcon,
|
|
1655
|
+
"aria-label": `${l.remove} ${u.name}`,
|
|
1656
|
+
onClick: () => onRemove(u.id)
|
|
1657
|
+
})
|
|
1658
|
+
]
|
|
1659
|
+
}, u.id))
|
|
1660
|
+
})]
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
//#endregion
|
|
1664
|
+
export { ActivityFeed, AppShell, AuthCard, DashboardPage, DeleteResource, ErrorPage, FileKindIcon, FileTable, FolderGrid, KUMO_DELETE_RESOURCE_DEFAULT_VARIANTS, KUMO_DELETE_RESOURCE_VARIANTS, KUMO_PAGE_HEADER_DEFAULT_VARIANTS, KUMO_PAGE_HEADER_VARIANTS, LoginPage, OnboardingChecklist, PageHeader, ResourceListPage, SettingsRow, SettingsSaveBar, SettingsSection, ShareDialog, Stat, StatGrid, UploadDropzone, formatActivityTime, formatFileDate, formatFileSize, pageHeaderVariants };
|