@fldr/ui 0.3.8 → 0.3.10
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/README.md +67 -448
- package/ai/component-registry.json +27 -14
- package/ai/component-registry.md +3 -3
- package/dist/.build-complete +1 -1
- package/dist/blocks-source/auth-card/auth-card.test.tsx +20 -14
- package/dist/blocks-source/auth-card/auth-card.tsx +73 -55
- package/dist/blocks-source/file-table/file-table.tsx +197 -150
- package/dist/blocks-source/login-page/login-page.tsx +3 -1
- package/dist/blocks-source/share-dialog/share-dialog.test.tsx +9 -3
- package/dist/blocks-source/share-dialog/share-dialog.tsx +50 -35
- package/dist/blocks.d.ts +24 -5
- package/dist/blocks.js +250 -197
- package/dist/brands.d.ts +143 -0
- package/dist/brands.js +92 -0
- package/dist/{button-DzavLWXm.d.ts → button-CS82eT0x.d.ts} +1 -1
- package/dist/chunks/{checkbox-eifiwbw34xwsikvf.js → checkbox-d5epe4dl78bzy4f8.js} +8 -8
- package/dist/chunks/{dropdown-e5zk0ez21busnt0b.js → dropdown-oec4g1w9kbsjsg15.js} +1 -1
- package/dist/chunks/highlighter-kb7huz24pcziin6d.js +57 -0
- package/dist/chunks/{layer-dialog-m8qb0wzfg3k7406a.js → layer-dialog-ioa3r4ayemppsspx.js} +4 -3
- package/dist/chunks/{table-ngl1b5yc8mcur662.js → table-bdye068ekayq3u1n.js} +1 -1
- package/dist/chunks/table-n5yarooiknhc18ln.js +448 -0
- package/dist/chunks/{table-of-contents-gkjv9ck8etbz64ej.js → table-of-contents-d3pmkrk223umdz9h.js} +1 -1
- package/dist/code/server.js +1 -1
- package/dist/code.js +4 -131
- package/dist/components/banner.d.ts +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/dropdown.js +1 -1
- package/dist/components/input-group.d.ts +2 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/layer-dialog.js +1 -1
- package/dist/components/link.d.ts +2 -67
- package/dist/components/sidebar.d.ts +2 -1
- package/dist/components/table-of-contents.js +1 -1
- package/dist/components/table.d.ts +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/toast.d.ts +1 -1
- package/dist/components/toolbar.d.ts +1 -1
- package/dist/form.d.ts +207 -0
- package/dist/form.js +317 -0
- package/dist/hotkeys.d.ts +135 -0
- package/dist/hotkeys.js +203 -0
- package/dist/index-9LwQy84o.d.ts +1 -0
- package/dist/index-B7iG0qDU.d.ts +1 -0
- package/dist/{index-B6JNUfG9.d.ts → index-BMXHK-3k.d.ts} +2 -2
- package/dist/{index-B6Wo_iiN.d.ts → index-B_ug9XY7.d.ts} +1 -1
- package/dist/{index-RP_rt8vB.d.ts → index-Bh9kuAvN.d.ts} +1 -1
- package/dist/{index-DjSGDESy.d.ts → index-CAUjUp2G.d.ts} +1 -1
- package/dist/{index-NnHba-T1.d.ts → index-DK28YxxP.d.ts} +2 -2
- package/dist/{index-aahL-0Zw.d.ts → index-DOVlARA6.d.ts} +2 -2
- package/dist/index-DTj6M6kA.d.ts +1 -0
- package/dist/index.d.ts +14 -12
- package/dist/index.js +5 -6
- package/dist/{input-group-8gEtPiKw.d.ts → input-group-Swzit45o.d.ts} +1 -1
- package/dist/link-CoVXE5W2.d.ts +68 -0
- package/dist/query.d.ts +156 -0
- package/dist/query.js +204 -0
- package/dist/router.d.ts +95 -0
- package/dist/router.js +146 -0
- package/dist/skeleton.d.ts +3 -0
- package/dist/skeleton.js +4 -0
- package/dist/styles/kumo-binding.css +36 -0
- package/dist/styles/kumo-standalone.css +1 -1
- package/dist/styles/theme-fldr.css +18 -18
- package/dist/table.d.ts +245 -0
- package/dist/table.js +3 -0
- package/dist/theming.d.ts +4 -4
- package/dist/theming.js +2 -2
- package/package.json +46 -1
- package/dist/chunks/highlighter-mouttug0tu8xg1i8.js +0 -1364
- package/dist/index-DL1-uSuH.d.ts +0 -1
- /package/dist/{index-BkTAB4wj.d.ts → sidebar-BkTAB4wj.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fireEvent, render, screen } from "@testing-library/react";
|
|
1
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
2
2
|
import { describe, expect, it, vi } from "vite-plus/test";
|
|
3
3
|
import { AuthCard } from "./auth-card";
|
|
4
4
|
|
|
@@ -8,20 +8,22 @@ const fill = (label: string, value: string) =>
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
describe("AuthCard", () => {
|
|
11
|
-
it("submits email and password", () => {
|
|
11
|
+
it("submits email and password", async () => {
|
|
12
12
|
const onSubmit = vi.fn();
|
|
13
13
|
render(<AuthCard onSubmit={onSubmit} />);
|
|
14
14
|
expect(screen.queryByLabelText("Name", { exact: false })).toBeNull();
|
|
15
15
|
fill("Email", "ada@fldr.zip");
|
|
16
16
|
fill("Password", "hunter22");
|
|
17
17
|
fireEvent.click(screen.getByRole("button", { name: "Sign in" }));
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
await waitFor(() =>
|
|
19
|
+
expect(onSubmit).toHaveBeenCalledWith({
|
|
20
|
+
email: "ada@fldr.zip",
|
|
21
|
+
password: "hunter22",
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
22
24
|
});
|
|
23
25
|
|
|
24
|
-
it("shows a name field in sign-up mode", () => {
|
|
26
|
+
it("shows a name field in sign-up mode", async () => {
|
|
25
27
|
const onSubmit = vi.fn();
|
|
26
28
|
render(<AuthCard mode="sign-up" onSubmit={onSubmit} />);
|
|
27
29
|
fill("Name", "Ada");
|
|
@@ -30,14 +32,16 @@ describe("AuthCard", () => {
|
|
|
30
32
|
const input = screen.getByLabelText("Password", { exact: false });
|
|
31
33
|
expect(input.getAttribute("autocomplete")).toBe("new-password");
|
|
32
34
|
fireEvent.click(screen.getByRole("button", { name: "Create account" }));
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
await waitFor(() =>
|
|
36
|
+
expect(onSubmit).toHaveBeenCalledWith({
|
|
37
|
+
email: "ada@fldr.zip",
|
|
38
|
+
password: "hunter22",
|
|
39
|
+
name: "Ada",
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
38
42
|
});
|
|
39
43
|
|
|
40
|
-
it("omits password for magic links and renders providers and errors", () => {
|
|
44
|
+
it("omits password for magic links and renders providers and errors", async () => {
|
|
41
45
|
const onSubmit = vi.fn();
|
|
42
46
|
const onProvider = vi.fn();
|
|
43
47
|
render(
|
|
@@ -59,6 +63,8 @@ describe("AuthCard", () => {
|
|
|
59
63
|
fireEvent.click(
|
|
60
64
|
screen.getByRole("button", { name: "Email me a sign-in link" }),
|
|
61
65
|
);
|
|
62
|
-
|
|
66
|
+
await waitFor(() =>
|
|
67
|
+
expect(onSubmit).toHaveBeenCalledWith({ email: "ada@fldr.zip" }),
|
|
68
|
+
);
|
|
63
69
|
});
|
|
64
70
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import { WarningCircleIcon } from "@phosphor-icons/react";
|
|
3
3
|
import { Banner } from "../../components/banner";
|
|
4
4
|
import { Button } from "../../components/button";
|
|
5
|
-
import {
|
|
5
|
+
import { compose, email, required, useAppForm } from "../../form";
|
|
6
6
|
import { cn } from "../../utils/cn";
|
|
7
7
|
|
|
8
8
|
export type AuthCardMode = "sign-in" | "sign-up";
|
|
@@ -30,6 +30,10 @@ export interface AuthCardLabels {
|
|
|
30
30
|
signUpSubmit: string;
|
|
31
31
|
magicLinkSubmit: string;
|
|
32
32
|
divider: string;
|
|
33
|
+
/** Validation message for empty fields. */
|
|
34
|
+
required: string;
|
|
35
|
+
/** Validation message for malformed emails. */
|
|
36
|
+
invalidEmail: string;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
const DEFAULT_LABELS: AuthCardLabels = {
|
|
@@ -42,6 +46,8 @@ const DEFAULT_LABELS: AuthCardLabels = {
|
|
|
42
46
|
signUpSubmit: "Create account",
|
|
43
47
|
magicLinkSubmit: "Email me a sign-in link",
|
|
44
48
|
divider: "or",
|
|
49
|
+
required: "Required",
|
|
50
|
+
invalidEmail: "Enter a valid email",
|
|
45
51
|
};
|
|
46
52
|
|
|
47
53
|
export interface AuthCardProps {
|
|
@@ -49,7 +55,7 @@ export interface AuthCardProps {
|
|
|
49
55
|
mode?: AuthCardMode;
|
|
50
56
|
/** `"magic-link"` hides the password field. @default "password" */
|
|
51
57
|
method?: AuthCardMethod;
|
|
52
|
-
/** Called with form values on
|
|
58
|
+
/** Called with validated form values on submit. */
|
|
53
59
|
onSubmit: (values: AuthCardValues) => void;
|
|
54
60
|
/** Provider buttons rendered above the "or" divider. */
|
|
55
61
|
providers?: AuthCardProvider[];
|
|
@@ -125,20 +131,18 @@ export function AuthCard({
|
|
|
125
131
|
))
|
|
126
132
|
: null);
|
|
127
133
|
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
141
|
-
};
|
|
134
|
+
const form = useAppForm({
|
|
135
|
+
defaultValues: { email: "", password: "", name: "" },
|
|
136
|
+
onSubmit: ({ value }) => {
|
|
137
|
+
if (loading) return;
|
|
138
|
+
onSubmit({
|
|
139
|
+
email: value.email.trim(),
|
|
140
|
+
...(hasPassword && { password: value.password }),
|
|
141
|
+
...(isSignUp && { name: value.name.trim() }),
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
const isRequired = { onChange: required(labels.required) };
|
|
142
146
|
|
|
143
147
|
const submitLabel = !hasPassword
|
|
144
148
|
? labels.magicLinkSubmit
|
|
@@ -185,44 +189,58 @@ export function AuthCard({
|
|
|
185
189
|
</>
|
|
186
190
|
)}
|
|
187
191
|
|
|
188
|
-
<form
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
192
|
+
<form.AppForm>
|
|
193
|
+
<form.Form className="flex flex-col gap-3">
|
|
194
|
+
{isSignUp && (
|
|
195
|
+
<form.AppField name="name" validators={isRequired}>
|
|
196
|
+
{(field) => (
|
|
197
|
+
<field.TextField
|
|
198
|
+
label={labels.name}
|
|
199
|
+
autoComplete="name"
|
|
200
|
+
disabled={loading}
|
|
201
|
+
/>
|
|
202
|
+
)}
|
|
203
|
+
</form.AppField>
|
|
204
|
+
)}
|
|
205
|
+
<form.AppField
|
|
206
|
+
name="email"
|
|
207
|
+
validators={{
|
|
208
|
+
onChange: compose(
|
|
209
|
+
required(labels.required),
|
|
210
|
+
email(labels.invalidEmail),
|
|
211
|
+
),
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
{(field) => (
|
|
215
|
+
<field.TextField
|
|
216
|
+
label={labels.email}
|
|
217
|
+
type="email"
|
|
218
|
+
autoComplete="email"
|
|
219
|
+
placeholder="you@example.com"
|
|
220
|
+
disabled={loading}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
</form.AppField>
|
|
224
|
+
{hasPassword && (
|
|
225
|
+
<form.AppField name="password" validators={isRequired}>
|
|
226
|
+
{(field) => (
|
|
227
|
+
<field.TextField
|
|
228
|
+
label={labels.password}
|
|
229
|
+
type="password"
|
|
230
|
+
autoComplete={isSignUp ? "new-password" : "current-password"}
|
|
231
|
+
disabled={loading}
|
|
232
|
+
/>
|
|
233
|
+
)}
|
|
234
|
+
</form.AppField>
|
|
235
|
+
)}
|
|
236
|
+
<form.SubmitButton
|
|
237
|
+
loading={loading}
|
|
238
|
+
className="w-full justify-center"
|
|
239
|
+
>
|
|
240
|
+
{submitLabel}
|
|
241
|
+
</form.SubmitButton>
|
|
242
|
+
</form.Form>
|
|
243
|
+
</form.AppForm>
|
|
226
244
|
|
|
227
245
|
{footer && (
|
|
228
246
|
<div className="text-center text-sm text-kumo-subtle">{footer}</div>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { useMemo, type ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
DataTable,
|
|
4
|
+
DataTableToolbar,
|
|
5
|
+
createColumnHelper,
|
|
6
|
+
functionalUpdate,
|
|
7
|
+
selectColumn,
|
|
8
|
+
type RowSelectionState,
|
|
9
|
+
type SortingState,
|
|
10
|
+
} from "../../table";
|
|
6
11
|
import {
|
|
7
12
|
FileKindIcon,
|
|
8
13
|
ItemActionsMenu,
|
|
@@ -41,6 +46,7 @@ export interface FileTableLabels {
|
|
|
41
46
|
selected: (count: number) => string;
|
|
42
47
|
clearSelection: string;
|
|
43
48
|
actions: (name: string) => string;
|
|
49
|
+
search: string;
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
const DEFAULT_LABELS: FileTableLabels = {
|
|
@@ -53,6 +59,7 @@ const DEFAULT_LABELS: FileTableLabels = {
|
|
|
53
59
|
selected: (count) => `${count} selected`,
|
|
54
60
|
clearSelection: "Clear selection",
|
|
55
61
|
actions: (name) => `Actions for ${name}`,
|
|
62
|
+
search: "Search files",
|
|
56
63
|
};
|
|
57
64
|
|
|
58
65
|
export interface FileTableProps<T extends FileItem = FileItem> {
|
|
@@ -78,6 +85,14 @@ export interface FileTableProps<T extends FileItem = FileItem> {
|
|
|
78
85
|
labels?: Partial<FileTableLabels>;
|
|
79
86
|
/** Locale for size and date formatting. Defaults to the runtime locale. */
|
|
80
87
|
locale?: string;
|
|
88
|
+
/** Show a search field that filters by name and owner. */
|
|
89
|
+
searchable?: boolean;
|
|
90
|
+
/** Shows skeleton rows instead of items. */
|
|
91
|
+
loading?: boolean;
|
|
92
|
+
/** Render only visible rows; for folders with thousands of items. */
|
|
93
|
+
virtualize?: boolean;
|
|
94
|
+
/** Scroll container height (sticky header). @default 480 when virtualized */
|
|
95
|
+
height?: number | string;
|
|
81
96
|
className?: string;
|
|
82
97
|
}
|
|
83
98
|
|
|
@@ -91,8 +106,13 @@ function compare(a: FileItem, b: FileItem, key: FileTableSortKey) {
|
|
|
91
106
|
});
|
|
92
107
|
}
|
|
93
108
|
|
|
109
|
+
const getRowId = (item: FileItem) => item.id;
|
|
110
|
+
const dash = "—";
|
|
111
|
+
const subtle = "whitespace-nowrap text-kumo-subtle";
|
|
112
|
+
|
|
94
113
|
/**
|
|
95
|
-
* FileTable — sortable, selectable list of files and folders
|
|
114
|
+
* FileTable — sortable, selectable list of files and folders, built on
|
|
115
|
+
* `DataTable`. Folders always sort above files.
|
|
96
116
|
*
|
|
97
117
|
* @example
|
|
98
118
|
* ```tsx
|
|
@@ -101,6 +121,7 @@ function compare(a: FileItem, b: FileItem, key: FileTableSortKey) {
|
|
|
101
121
|
* onOpen={(item) => navigate(item.id)}
|
|
102
122
|
* actions={[{ label: "Delete", variant: "danger", onSelect: remove }]}
|
|
103
123
|
* bulkActions={(ids) => <Button size="sm" onClick={() => share(ids)}>Share</Button>}
|
|
124
|
+
* searchable
|
|
104
125
|
* />
|
|
105
126
|
* ```
|
|
106
127
|
*/
|
|
@@ -119,6 +140,10 @@ export function FileTable<T extends FileItem = FileItem>({
|
|
|
119
140
|
empty,
|
|
120
141
|
labels: labelsProp,
|
|
121
142
|
locale,
|
|
143
|
+
searchable,
|
|
144
|
+
loading,
|
|
145
|
+
virtualize,
|
|
146
|
+
height,
|
|
122
147
|
className,
|
|
123
148
|
}: FileTableProps<T>) {
|
|
124
149
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
@@ -128,7 +153,6 @@ export function FileTable<T extends FileItem = FileItem>({
|
|
|
128
153
|
defaultSelectedIds,
|
|
129
154
|
onSelectionChange,
|
|
130
155
|
);
|
|
131
|
-
const selectedSet = new Set(selected);
|
|
132
156
|
|
|
133
157
|
const sorted = useMemo(() => {
|
|
134
158
|
const dir = sort.direction === "asc" ? 1 : -1;
|
|
@@ -139,154 +163,177 @@ export function FileTable<T extends FileItem = FileItem>({
|
|
|
139
163
|
);
|
|
140
164
|
}, [items, sort]);
|
|
141
165
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
166
|
+
const columns = useFileColumns<T>({
|
|
167
|
+
labels,
|
|
168
|
+
locale,
|
|
169
|
+
onOpen,
|
|
170
|
+
actions,
|
|
171
|
+
selectable,
|
|
172
|
+
});
|
|
147
173
|
|
|
148
|
-
|
|
149
|
-
const active = sort.key === key;
|
|
150
|
-
const Caret = sort.direction === "asc" ? CaretUpIcon : CaretDownIcon;
|
|
151
|
-
return (
|
|
152
|
-
<Table.Head
|
|
153
|
-
className={cn("font-medium", cls)}
|
|
154
|
-
aria-sort={
|
|
155
|
-
active
|
|
156
|
-
? sort.direction === "asc"
|
|
157
|
-
? "ascending"
|
|
158
|
-
: "descending"
|
|
159
|
-
: undefined
|
|
160
|
-
}
|
|
161
|
-
>
|
|
162
|
-
<button
|
|
163
|
-
type="button"
|
|
164
|
-
className="inline-flex cursor-pointer items-center gap-1 text-kumo-subtle hover:text-kumo-default"
|
|
165
|
-
onClick={() =>
|
|
166
|
-
setSort({
|
|
167
|
-
key,
|
|
168
|
-
direction: active && sort.direction === "asc" ? "desc" : "asc",
|
|
169
|
-
})
|
|
170
|
-
}
|
|
171
|
-
>
|
|
172
|
-
{label}
|
|
173
|
-
{active && <Caret size={12} weight="bold" aria-hidden />}
|
|
174
|
-
</button>
|
|
175
|
-
</Table.Head>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
174
|
+
if (items.length === 0 && empty && !loading) return <>{empty}</>;
|
|
178
175
|
|
|
179
|
-
const
|
|
180
|
-
|
|
176
|
+
const sorting: SortingState = [
|
|
177
|
+
{ id: sort.key, desc: sort.direction === "desc" },
|
|
178
|
+
];
|
|
179
|
+
const rowSelection: RowSelectionState = Object.fromEntries(
|
|
180
|
+
selected.map((id) => [id, true]),
|
|
181
|
+
);
|
|
181
182
|
|
|
182
183
|
return (
|
|
183
|
-
<
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
label={labels.selectAll}
|
|
212
|
-
checked={allSelected}
|
|
213
|
-
indeterminate={selected.length > 0 && !allSelected}
|
|
214
|
-
onCheckedChange={(checked) =>
|
|
215
|
-
setSelected(checked ? items.map((i) => i.id) : [])
|
|
216
|
-
}
|
|
184
|
+
<DataTable
|
|
185
|
+
columns={columns}
|
|
186
|
+
data={sorted}
|
|
187
|
+
getRowId={getRowId}
|
|
188
|
+
manualSorting
|
|
189
|
+
sortDescFirst={false}
|
|
190
|
+
enableSortingRemoval={false}
|
|
191
|
+
enableRowSelection={selectable}
|
|
192
|
+
state={{ sorting, rowSelection }}
|
|
193
|
+
onSortingChange={(updater) => {
|
|
194
|
+
const [next] = functionalUpdate(updater, sorting);
|
|
195
|
+
if (next)
|
|
196
|
+
setSort({
|
|
197
|
+
key: next.id as FileTableSortKey,
|
|
198
|
+
direction: next.desc ? "desc" : "asc",
|
|
199
|
+
});
|
|
200
|
+
}}
|
|
201
|
+
onRowSelectionChange={(updater) => {
|
|
202
|
+
const next = functionalUpdate(updater, rowSelection);
|
|
203
|
+
setSelected(items.filter((i) => next[i.id]).map((i) => i.id));
|
|
204
|
+
}}
|
|
205
|
+
toolbar={
|
|
206
|
+
searchable
|
|
207
|
+
? (table) => (
|
|
208
|
+
<DataTableToolbar
|
|
209
|
+
table={table}
|
|
210
|
+
columnVisibility={false}
|
|
211
|
+
labels={{ search: labels.search }}
|
|
217
212
|
/>
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
"even:bg-kumo-base hover:bg-kumo-tint even:hover:bg-kumo-tint",
|
|
236
|
-
onOpen && "cursor-pointer",
|
|
237
|
-
)}
|
|
238
|
-
onClick={onOpen && (() => onOpen(item))}
|
|
239
|
-
>
|
|
240
|
-
{selectable && (
|
|
241
|
-
<Table.CheckCell
|
|
242
|
-
label={labels.selectRow(item.name)}
|
|
243
|
-
checked={isSelected}
|
|
244
|
-
onCheckedChange={(checked) => toggle(item.id, checked)}
|
|
245
|
-
onClick={(e) => e.stopPropagation()}
|
|
246
|
-
/>
|
|
247
|
-
)}
|
|
248
|
-
<Table.Cell className="max-w-0">
|
|
249
|
-
<span className="flex min-w-0 items-center gap-2">
|
|
250
|
-
<FileKindIcon kind={item.kind} />
|
|
251
|
-
{onOpen ? (
|
|
252
|
-
<button
|
|
253
|
-
type="button"
|
|
254
|
-
className="cursor-pointer truncate text-left"
|
|
255
|
-
>
|
|
256
|
-
{item.name}
|
|
257
|
-
</button>
|
|
258
|
-
) : (
|
|
259
|
-
<span className="truncate">{item.name}</span>
|
|
260
|
-
)}
|
|
261
|
-
</span>
|
|
262
|
-
</Table.Cell>
|
|
263
|
-
<Table.Cell className="text-right whitespace-nowrap text-kumo-subtle tabular-nums">
|
|
264
|
-
{item.size === undefined
|
|
265
|
-
? "—"
|
|
266
|
-
: formatFileSize(item.size, locale)}
|
|
267
|
-
</Table.Cell>
|
|
268
|
-
<Table.Cell className="hidden whitespace-nowrap text-kumo-subtle sm:table-cell">
|
|
269
|
-
{item.modifiedAt === undefined
|
|
270
|
-
? "—"
|
|
271
|
-
: formatFileDate(item.modifiedAt, locale)}
|
|
272
|
-
</Table.Cell>
|
|
273
|
-
<Table.Cell className="hidden whitespace-nowrap text-kumo-subtle md:table-cell">
|
|
274
|
-
{item.owner ?? "—"}
|
|
275
|
-
</Table.Cell>
|
|
276
|
-
{actions && (
|
|
277
|
-
<Table.Cell className="py-0 text-right">
|
|
278
|
-
<ItemActionsMenu
|
|
279
|
-
item={item}
|
|
280
|
-
actions={actions}
|
|
281
|
-
label={labels.actions(item.name)}
|
|
282
|
-
/>
|
|
283
|
-
</Table.Cell>
|
|
284
|
-
)}
|
|
285
|
-
</Table.Row>
|
|
286
|
-
);
|
|
287
|
-
})}
|
|
288
|
-
</Table.Body>
|
|
289
|
-
</Table>
|
|
290
|
-
</div>
|
|
213
|
+
)
|
|
214
|
+
: undefined
|
|
215
|
+
}
|
|
216
|
+
bulkActions={
|
|
217
|
+
typeof bulkActions === "function" ? bulkActions(selected) : bulkActions
|
|
218
|
+
}
|
|
219
|
+
onRowClick={onOpen && ((row) => onOpen(row.original))}
|
|
220
|
+
empty={empty}
|
|
221
|
+
loading={loading}
|
|
222
|
+
virtualize={virtualize}
|
|
223
|
+
height={height}
|
|
224
|
+
labels={{
|
|
225
|
+
selected: labels.selected,
|
|
226
|
+
clearSelection: labels.clearSelection,
|
|
227
|
+
}}
|
|
228
|
+
className={className}
|
|
229
|
+
/>
|
|
291
230
|
);
|
|
292
231
|
}
|
|
232
|
+
|
|
233
|
+
function useFileColumns<T extends FileItem>({
|
|
234
|
+
labels,
|
|
235
|
+
locale,
|
|
236
|
+
onOpen,
|
|
237
|
+
actions,
|
|
238
|
+
selectable,
|
|
239
|
+
}: {
|
|
240
|
+
labels: FileTableLabels;
|
|
241
|
+
locale?: string;
|
|
242
|
+
onOpen?: (item: T) => void;
|
|
243
|
+
actions?: FileActions<T>;
|
|
244
|
+
selectable: boolean;
|
|
245
|
+
}) {
|
|
246
|
+
const { selectAll, selectRow, name, size, modified, owner } = labels;
|
|
247
|
+
const actionsLabel = labels.actions;
|
|
248
|
+
const clickable = !!onOpen;
|
|
249
|
+
return useMemo(() => {
|
|
250
|
+
const col = createColumnHelper<T>();
|
|
251
|
+
return col.columns([
|
|
252
|
+
...(selectable
|
|
253
|
+
? [
|
|
254
|
+
selectColumn<T>({
|
|
255
|
+
allLabel: selectAll,
|
|
256
|
+
rowLabel: (item) => selectRow(item.name),
|
|
257
|
+
}),
|
|
258
|
+
]
|
|
259
|
+
: []),
|
|
260
|
+
col.accessor((item) => item.name, {
|
|
261
|
+
id: "name",
|
|
262
|
+
header: name,
|
|
263
|
+
meta: { headerClassName: "w-full", cellClassName: "max-w-0" },
|
|
264
|
+
cell: ({ row }) => (
|
|
265
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
266
|
+
<FileKindIcon kind={row.original.kind} />
|
|
267
|
+
{clickable ? (
|
|
268
|
+
<button
|
|
269
|
+
type="button"
|
|
270
|
+
className="cursor-pointer truncate text-left"
|
|
271
|
+
>
|
|
272
|
+
{row.original.name}
|
|
273
|
+
</button>
|
|
274
|
+
) : (
|
|
275
|
+
<span className="truncate">{row.original.name}</span>
|
|
276
|
+
)}
|
|
277
|
+
</span>
|
|
278
|
+
),
|
|
279
|
+
}),
|
|
280
|
+
col.accessor((item) => item.size, {
|
|
281
|
+
id: "size",
|
|
282
|
+
header: size,
|
|
283
|
+
enableGlobalFilter: false,
|
|
284
|
+
meta: {
|
|
285
|
+
className: "text-right",
|
|
286
|
+
cellClassName: `${subtle} tabular-nums`,
|
|
287
|
+
},
|
|
288
|
+
cell: ({ getValue }) => {
|
|
289
|
+
const value = getValue();
|
|
290
|
+
return value === undefined ? dash : formatFileSize(value, locale);
|
|
291
|
+
},
|
|
292
|
+
}),
|
|
293
|
+
col.accessor((item) => item.modifiedAt, {
|
|
294
|
+
id: "modifiedAt",
|
|
295
|
+
header: modified,
|
|
296
|
+
enableGlobalFilter: false,
|
|
297
|
+
meta: { className: "hidden sm:table-cell", cellClassName: subtle },
|
|
298
|
+
cell: ({ getValue }) => {
|
|
299
|
+
const value = getValue();
|
|
300
|
+
return value === undefined ? dash : formatFileDate(value, locale);
|
|
301
|
+
},
|
|
302
|
+
}),
|
|
303
|
+
col.accessor((item) => item.owner, {
|
|
304
|
+
id: "owner",
|
|
305
|
+
header: owner,
|
|
306
|
+
meta: { className: "hidden md:table-cell", cellClassName: subtle },
|
|
307
|
+
cell: ({ getValue }) => getValue() ?? dash,
|
|
308
|
+
}),
|
|
309
|
+
...(actions
|
|
310
|
+
? [
|
|
311
|
+
col.display({
|
|
312
|
+
id: "actions",
|
|
313
|
+
enableHiding: false,
|
|
314
|
+
meta: { className: "w-10", cellClassName: "py-0 text-right" },
|
|
315
|
+
cell: ({ row }) => (
|
|
316
|
+
<ItemActionsMenu
|
|
317
|
+
item={row.original}
|
|
318
|
+
actions={actions}
|
|
319
|
+
label={actionsLabel(row.original.name)}
|
|
320
|
+
/>
|
|
321
|
+
),
|
|
322
|
+
}),
|
|
323
|
+
]
|
|
324
|
+
: []),
|
|
325
|
+
]);
|
|
326
|
+
}, [
|
|
327
|
+
selectable,
|
|
328
|
+
selectAll,
|
|
329
|
+
selectRow,
|
|
330
|
+
name,
|
|
331
|
+
size,
|
|
332
|
+
modified,
|
|
333
|
+
owner,
|
|
334
|
+
actionsLabel,
|
|
335
|
+
actions,
|
|
336
|
+
locale,
|
|
337
|
+
clickable,
|
|
338
|
+
]);
|
|
339
|
+
}
|
|
@@ -18,9 +18,11 @@ export interface LoginPageProps extends Omit<
|
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```tsx
|
|
21
|
+
* import { Google } from "@fldr/ui/brands";
|
|
22
|
+
*
|
|
21
23
|
* <LoginPage
|
|
22
24
|
* logo={<FldrMark />}
|
|
23
|
-
* providers={[{ id: "google", label: "Continue with Google", icon: <
|
|
25
|
+
* providers={[{ id: "google", label: "Continue with Google", icon: <Google /> }]}
|
|
24
26
|
* onProvider={startOAuth}
|
|
25
27
|
* onSubmit={({ email, password }) => signIn(email, password)}
|
|
26
28
|
* legal={<>By continuing you agree to the <a href="/terms">Terms</a>.</>}
|