@tulip-systems/drive 0.9.0 → 0.10.1
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/dist/client.d.mts +2 -1
- package/dist/client.mjs +2 -1
- package/dist/components/grid-card.client.d.mts +2 -2
- package/dist/lib/dto.d.mts +2 -2
- package/dist/lib/validators.d.mts +9 -9
- package/dist/lib/view-config.client.d.mts +57 -0
- package/dist/lib/view-config.client.mjs +46 -0
- package/dist/providers/google/components/view.client.d.mts +2 -2
- package/dist/providers/google/components/view.client.mjs +8 -8
- package/dist/providers/google/config/columns-data.mjs +1 -1
- package/dist/providers/google/config/filters.d.mts +1 -1
- package/dist/providers/google/lib/router.server.d.mts +20 -20
- package/dist/providers/google/lib/search-params.d.mts +1 -1
- package/dist/providers/google/lib/validators.d.mts +12 -12
- package/dist/providers/local/components/view.client.d.mts +2 -2
- package/dist/providers/local/components/view.client.mjs +8 -8
- package/dist/providers/local/config/columns-data.mjs +1 -1
- package/dist/providers/local/config/filters.d.mts +1 -1
- package/dist/providers/local/lib/router.server.d.mts +109 -109
- package/dist/providers/local/lib/schema.d.mts +2 -2
- package/dist/providers/local/lib/search-params.d.mts +1 -1
- package/dist/providers/local/lib/service.server.d.mts +15 -15
- package/dist/providers/local/lib/validators.d.mts +18 -18
- package/package.json +2 -2
- package/src/components/grid-card.client.tsx +2 -2
- package/src/entry.client.ts +5 -0
- package/src/lib/view-config.client.tsx +116 -0
- package/src/providers/google/components/view.client.tsx +15 -19
- package/src/providers/local/components/view.client.tsx +15 -15
|
@@ -49,7 +49,7 @@ declare const nodes: drizzle_orm_pg_core0.PgTableWithColumns<{
|
|
|
49
49
|
tableName: "nodes";
|
|
50
50
|
dataType: "string";
|
|
51
51
|
columnType: "PgEnumColumn";
|
|
52
|
-
data: "
|
|
52
|
+
data: "file" | "folder";
|
|
53
53
|
driverParam: string;
|
|
54
54
|
notNull: false;
|
|
55
55
|
hasDefault: false;
|
|
@@ -604,7 +604,7 @@ declare const driveSchema: {
|
|
|
604
604
|
tableName: "nodes";
|
|
605
605
|
dataType: "string";
|
|
606
606
|
columnType: "PgEnumColumn";
|
|
607
|
-
data: "
|
|
607
|
+
data: "file" | "folder";
|
|
608
608
|
driverParam: string;
|
|
609
609
|
notNull: false;
|
|
610
610
|
hasDefault: false;
|
|
@@ -4,7 +4,7 @@ import * as nuqs_server0 from "nuqs/server";
|
|
|
4
4
|
declare const localDriveTreeFilterSearchParams: {
|
|
5
5
|
readonly subtypes: nuqs_server0.SingleParserBuilder<("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null>;
|
|
6
6
|
readonly hidden: nuqs_server0.SingleParserBuilder<boolean | null>;
|
|
7
|
-
readonly types: nuqs_server0.SingleParserBuilder<("
|
|
7
|
+
readonly types: nuqs_server0.SingleParserBuilder<("file" | "folder")[] | null>;
|
|
8
8
|
readonly contentTypes: nuqs_server0.SingleParserBuilder<string[] | null>;
|
|
9
9
|
readonly nodeIds: nuqs_server0.SingleParserBuilder<string[] | null>;
|
|
10
10
|
readonly isArchived: nuqs_server0.SingleParserBuilder<boolean | null>;
|
|
@@ -104,21 +104,21 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
104
104
|
id: string | null;
|
|
105
105
|
namespace: string;
|
|
106
106
|
}): Promise<(Pick<{
|
|
107
|
-
type: "folder" | "file" | null;
|
|
108
|
-
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
109
|
-
id: string;
|
|
110
|
-
createdAt: Date;
|
|
111
|
-
updatedAt: Date;
|
|
112
107
|
name: string;
|
|
113
108
|
namespace: string;
|
|
114
|
-
|
|
109
|
+
parentId: string | null;
|
|
115
110
|
contentType: string | null;
|
|
111
|
+
size: number | null;
|
|
112
|
+
type: "file" | "folder" | null;
|
|
116
113
|
readonly: boolean | null;
|
|
114
|
+
id: string;
|
|
115
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
116
|
+
createdAt: Date;
|
|
117
|
+
updatedAt: Date;
|
|
117
118
|
hidden: boolean | null;
|
|
118
119
|
archivedAt: Date | null;
|
|
119
|
-
parentId: string | null;
|
|
120
120
|
assetId: string | null;
|
|
121
|
-
}, "
|
|
121
|
+
}, "name" | "parentId" | "id"> & {
|
|
122
122
|
depth: number;
|
|
123
123
|
})[]>;
|
|
124
124
|
/**
|
|
@@ -172,7 +172,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
172
172
|
updatedAt: Date;
|
|
173
173
|
name: string;
|
|
174
174
|
namespace: string;
|
|
175
|
-
type: "
|
|
175
|
+
type: "file" | "folder";
|
|
176
176
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
177
177
|
size: number | null;
|
|
178
178
|
contentType: string | null;
|
|
@@ -211,7 +211,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
211
211
|
updatedAt: Date;
|
|
212
212
|
name: string;
|
|
213
213
|
namespace: string;
|
|
214
|
-
type: "
|
|
214
|
+
type: "file" | "folder";
|
|
215
215
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
216
216
|
size: number | null;
|
|
217
217
|
contentType: string | null;
|
|
@@ -309,7 +309,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
309
309
|
updatedAt: Date;
|
|
310
310
|
name: string;
|
|
311
311
|
namespace: string;
|
|
312
|
-
type: "
|
|
312
|
+
type: "file" | "folder";
|
|
313
313
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
314
314
|
size: number | null;
|
|
315
315
|
contentType: string | null;
|
|
@@ -344,7 +344,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
344
344
|
updatedAt: Date;
|
|
345
345
|
name: string;
|
|
346
346
|
namespace: string;
|
|
347
|
-
type: "
|
|
347
|
+
type: "file" | "folder";
|
|
348
348
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
349
349
|
size: number | null;
|
|
350
350
|
contentType: string | null;
|
|
@@ -378,7 +378,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
378
378
|
updatedAt: Date;
|
|
379
379
|
name: string;
|
|
380
380
|
namespace: string;
|
|
381
|
-
type: "
|
|
381
|
+
type: "file" | "folder";
|
|
382
382
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
383
383
|
size: number | null;
|
|
384
384
|
contentType: string | null;
|
|
@@ -412,7 +412,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
412
412
|
updatedAt: Date;
|
|
413
413
|
name: string;
|
|
414
414
|
namespace: string;
|
|
415
|
-
type: "
|
|
415
|
+
type: "file" | "folder";
|
|
416
416
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
417
417
|
size: number | null;
|
|
418
418
|
contentType: string | null;
|
|
@@ -443,7 +443,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
443
443
|
updatedAt: Date;
|
|
444
444
|
name: string;
|
|
445
445
|
namespace: string;
|
|
446
|
-
type: "
|
|
446
|
+
type: "file" | "folder";
|
|
447
447
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
448
448
|
size: number | null;
|
|
449
449
|
contentType: string | null;
|
|
@@ -15,8 +15,8 @@ declare const localDriveNodeSchema: z.ZodObject<{
|
|
|
15
15
|
name: z.ZodString;
|
|
16
16
|
namespace: z.ZodString;
|
|
17
17
|
type: z.ZodEnum<{
|
|
18
|
-
folder: "folder";
|
|
19
18
|
file: "file";
|
|
19
|
+
folder: "folder";
|
|
20
20
|
}>;
|
|
21
21
|
subtype: z.ZodEnum<{
|
|
22
22
|
image: "image";
|
|
@@ -68,8 +68,8 @@ declare const localDriveNodeWithChildrenSchema: z.ZodObject<{
|
|
|
68
68
|
name: z.ZodString;
|
|
69
69
|
namespace: z.ZodString;
|
|
70
70
|
type: z.ZodEnum<{
|
|
71
|
-
folder: "folder";
|
|
72
71
|
file: "file";
|
|
72
|
+
folder: "folder";
|
|
73
73
|
}>;
|
|
74
74
|
subtype: z.ZodEnum<{
|
|
75
75
|
image: "image";
|
|
@@ -106,8 +106,8 @@ declare const localDriveNodeWithChildrenSchema: z.ZodObject<{
|
|
|
106
106
|
name: z.ZodString;
|
|
107
107
|
namespace: z.ZodString;
|
|
108
108
|
type: z.ZodEnum<{
|
|
109
|
-
folder: "folder";
|
|
110
109
|
file: "file";
|
|
110
|
+
folder: "folder";
|
|
111
111
|
}>;
|
|
112
112
|
subtype: z.ZodEnum<{
|
|
113
113
|
image: "image";
|
|
@@ -227,8 +227,8 @@ declare const localDriveTreeFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
227
227
|
}>>>>;
|
|
228
228
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
229
229
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
230
|
-
folder: "folder";
|
|
231
230
|
file: "file";
|
|
231
|
+
folder: "folder";
|
|
232
232
|
}>>>>;
|
|
233
233
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
234
234
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -241,7 +241,7 @@ declare const localDriveTreeFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
241
241
|
namespace: string;
|
|
242
242
|
parentId: string | null;
|
|
243
243
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
244
|
-
types?: ("
|
|
244
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
245
245
|
contentTypes?: string[] | null | undefined;
|
|
246
246
|
nodeIds?: string[] | null | undefined;
|
|
247
247
|
}, {
|
|
@@ -249,7 +249,7 @@ declare const localDriveTreeFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
249
249
|
parentId: string | null;
|
|
250
250
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
251
251
|
hidden?: boolean | null | undefined;
|
|
252
|
-
types?: ("
|
|
252
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
253
253
|
contentTypes?: string[] | null | undefined;
|
|
254
254
|
nodeIds?: string[] | null | undefined;
|
|
255
255
|
isArchived?: boolean | null | undefined;
|
|
@@ -270,8 +270,8 @@ declare const localDriveFlatFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
270
270
|
}>>>>;
|
|
271
271
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
272
272
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
273
|
-
folder: "folder";
|
|
274
273
|
file: "file";
|
|
274
|
+
folder: "folder";
|
|
275
275
|
}>>>>;
|
|
276
276
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
277
277
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -281,14 +281,14 @@ declare const localDriveFlatFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
281
281
|
hidden: boolean;
|
|
282
282
|
isArchived: boolean;
|
|
283
283
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
284
|
-
types?: ("
|
|
284
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
285
285
|
contentTypes?: string[] | null | undefined;
|
|
286
286
|
nodeIds?: string[] | null | undefined;
|
|
287
287
|
namespace?: string | undefined;
|
|
288
288
|
}, {
|
|
289
289
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
290
290
|
hidden?: boolean | null | undefined;
|
|
291
|
-
types?: ("
|
|
291
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
292
292
|
contentTypes?: string[] | null | undefined;
|
|
293
293
|
nodeIds?: string[] | null | undefined;
|
|
294
294
|
isArchived?: boolean | null | undefined;
|
|
@@ -318,8 +318,8 @@ declare const listLocalDriveTreeInputSchema: z.ZodObject<{
|
|
|
318
318
|
}>>>>;
|
|
319
319
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
320
320
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
321
|
-
folder: "folder";
|
|
322
321
|
file: "file";
|
|
322
|
+
folder: "folder";
|
|
323
323
|
}>>>>;
|
|
324
324
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
325
325
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -332,7 +332,7 @@ declare const listLocalDriveTreeInputSchema: z.ZodObject<{
|
|
|
332
332
|
namespace: string;
|
|
333
333
|
parentId: string | null;
|
|
334
334
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
335
|
-
types?: ("
|
|
335
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
336
336
|
contentTypes?: string[] | null | undefined;
|
|
337
337
|
nodeIds?: string[] | null | undefined;
|
|
338
338
|
}, {
|
|
@@ -340,7 +340,7 @@ declare const listLocalDriveTreeInputSchema: z.ZodObject<{
|
|
|
340
340
|
parentId: string | null;
|
|
341
341
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
342
342
|
hidden?: boolean | null | undefined;
|
|
343
|
-
types?: ("
|
|
343
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
344
344
|
contentTypes?: string[] | null | undefined;
|
|
345
345
|
nodeIds?: string[] | null | undefined;
|
|
346
346
|
isArchived?: boolean | null | undefined;
|
|
@@ -372,8 +372,8 @@ declare const listLocalDriveFlatInputSchema: z.ZodObject<{
|
|
|
372
372
|
}>>>>;
|
|
373
373
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
374
374
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
375
|
-
folder: "folder";
|
|
376
375
|
file: "file";
|
|
376
|
+
folder: "folder";
|
|
377
377
|
}>>>>;
|
|
378
378
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
379
379
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -383,14 +383,14 @@ declare const listLocalDriveFlatInputSchema: z.ZodObject<{
|
|
|
383
383
|
hidden: boolean;
|
|
384
384
|
isArchived: boolean;
|
|
385
385
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
386
|
-
types?: ("
|
|
386
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
387
387
|
contentTypes?: string[] | null | undefined;
|
|
388
388
|
nodeIds?: string[] | null | undefined;
|
|
389
389
|
namespace?: string | undefined;
|
|
390
390
|
}, {
|
|
391
391
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
392
392
|
hidden?: boolean | null | undefined;
|
|
393
|
-
types?: ("
|
|
393
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
394
394
|
contentTypes?: string[] | null | undefined;
|
|
395
395
|
nodeIds?: string[] | null | undefined;
|
|
396
396
|
isArchived?: boolean | null | undefined;
|
|
@@ -420,8 +420,8 @@ declare const getLocalDriveNodesByParentIdInputSchema: z.ZodObject<{
|
|
|
420
420
|
}>>>>;
|
|
421
421
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
422
422
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
423
|
-
folder: "folder";
|
|
424
423
|
file: "file";
|
|
424
|
+
folder: "folder";
|
|
425
425
|
}>>>>;
|
|
426
426
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
427
427
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -434,7 +434,7 @@ declare const getLocalDriveNodesByParentIdInputSchema: z.ZodObject<{
|
|
|
434
434
|
namespace: string;
|
|
435
435
|
parentId: string | null;
|
|
436
436
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
437
|
-
types?: ("
|
|
437
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
438
438
|
contentTypes?: string[] | null | undefined;
|
|
439
439
|
nodeIds?: string[] | null | undefined;
|
|
440
440
|
}, {
|
|
@@ -442,7 +442,7 @@ declare const getLocalDriveNodesByParentIdInputSchema: z.ZodObject<{
|
|
|
442
442
|
parentId: string | null;
|
|
443
443
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
444
444
|
hidden?: boolean | null | undefined;
|
|
445
|
-
types?: ("
|
|
445
|
+
types?: ("file" | "folder")[] | null | undefined;
|
|
446
446
|
contentTypes?: string[] | null | undefined;
|
|
447
447
|
nodeIds?: string[] | null | undefined;
|
|
448
448
|
isArchived?: boolean | null | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tulip-systems/drive",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"uuid": "^14.0.0",
|
|
66
66
|
"vaul": "^1.1.2",
|
|
67
67
|
"zod": "^4.4.3",
|
|
68
|
-
"@tulip-systems/core": "0.
|
|
68
|
+
"@tulip-systems/core": "0.10.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@tailwindcss/typography": "^0.5.19",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useDraggable, useDroppable } from "@dnd-kit/react";
|
|
4
|
-
import type {
|
|
4
|
+
import type { CommandFor } from "@tulip-systems/core/commands";
|
|
5
5
|
import {
|
|
6
6
|
ContextCommandMenu,
|
|
7
7
|
ContextCommandMenuContent,
|
|
@@ -29,7 +29,7 @@ import { useDriveSelectionContext } from "./selection.client";
|
|
|
29
29
|
*/
|
|
30
30
|
type DriveGridCardProps<TData extends DriveNode> = ComponentProps<"div"> & {
|
|
31
31
|
node: TData;
|
|
32
|
-
commands?:
|
|
32
|
+
commands?: CommandFor<TData>[];
|
|
33
33
|
imageLoader?: (props: ImageLoaderProps) => string;
|
|
34
34
|
unoptimized?: boolean;
|
|
35
35
|
};
|
package/src/entry.client.ts
CHANGED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { VisibilityState } from "@tanstack/react-table";
|
|
4
|
+
import type { CommandFor } from "@tulip-systems/core/commands";
|
|
5
|
+
import type {
|
|
6
|
+
Selection,
|
|
7
|
+
TableColumnDef,
|
|
8
|
+
TableFiltersResult,
|
|
9
|
+
TableMetaInput,
|
|
10
|
+
} from "@tulip-systems/core/data-tables";
|
|
11
|
+
import {
|
|
12
|
+
createTableConfig,
|
|
13
|
+
type TableConfigContextValue,
|
|
14
|
+
TableConfigProvider,
|
|
15
|
+
type useInfiniteStrategy,
|
|
16
|
+
useTableConfigContext,
|
|
17
|
+
} from "@tulip-systems/core/data-tables/client";
|
|
18
|
+
import { createContext, type PropsWithChildren, use } from "react";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* DriveViewConfig context
|
|
22
|
+
*/
|
|
23
|
+
export type DriveViewCommands<TData, TMeta = object> = {
|
|
24
|
+
node?: CommandFor<TData, TMeta>[];
|
|
25
|
+
selectedNodes?: CommandFor<TData[], TMeta>[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type DriveViewConfigContextValue<TData, TMeta = object> = {
|
|
29
|
+
commands?: DriveViewCommands<TData, TMeta>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const DriveViewConfigContext = createContext({} as DriveViewConfigContextValue<any, any>);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Drive View configuration
|
|
36
|
+
*/
|
|
37
|
+
export type DriveViewConfig<
|
|
38
|
+
TData,
|
|
39
|
+
TMeta extends TableMetaInput<TData> = TableMetaInput<TData>,
|
|
40
|
+
> = DriveViewConfigContextValue<TData, TMeta> &
|
|
41
|
+
Omit<TableConfigContextValue<TData, TableFiltersResult, TMeta>, "commands">;
|
|
42
|
+
|
|
43
|
+
export type CreateDriveViewConfigInput<
|
|
44
|
+
TData,
|
|
45
|
+
TMeta extends TableMetaInput<TData> = TableMetaInput<TData>,
|
|
46
|
+
> = {
|
|
47
|
+
queryData: TData[];
|
|
48
|
+
columns: TableColumnDef<TData>[];
|
|
49
|
+
strategy: ReturnType<typeof useInfiniteStrategy>;
|
|
50
|
+
commands?: DriveViewCommands<TData, TMeta>;
|
|
51
|
+
meta?: TMeta;
|
|
52
|
+
columnVisibility?: VisibilityState;
|
|
53
|
+
selection?: Selection;
|
|
54
|
+
getRowId?: (row: TData) => string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export function createDriveViewConfig<
|
|
58
|
+
TData,
|
|
59
|
+
TMeta extends TableMetaInput<TData> = TableMetaInput<TData>,
|
|
60
|
+
>({
|
|
61
|
+
queryData,
|
|
62
|
+
columns,
|
|
63
|
+
strategy,
|
|
64
|
+
commands,
|
|
65
|
+
meta,
|
|
66
|
+
columnVisibility,
|
|
67
|
+
selection,
|
|
68
|
+
getRowId = (row) => (row as { id: string }).id,
|
|
69
|
+
}: CreateDriveViewConfigInput<TData, TMeta>) {
|
|
70
|
+
const { commands: _commands, ...table } = createTableConfig<TData, TableFiltersResult, TMeta>({
|
|
71
|
+
queryData,
|
|
72
|
+
columns,
|
|
73
|
+
getRowId,
|
|
74
|
+
strategy,
|
|
75
|
+
meta,
|
|
76
|
+
columnVisibility,
|
|
77
|
+
selection,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return { ...table, commands } as DriveViewConfig<TData, TMeta>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* DriveViewConfigProvider component
|
|
85
|
+
* Wraps the children components with the DriveViewConfigContext provider
|
|
86
|
+
* and provides the configuration for the drive view
|
|
87
|
+
*/
|
|
88
|
+
type DriveViewConfigProviderProps<
|
|
89
|
+
TData,
|
|
90
|
+
TMeta extends TableMetaInput<TData> = TableMetaInput<TData>,
|
|
91
|
+
> = PropsWithChildren<{
|
|
92
|
+
config: ReturnType<typeof createDriveViewConfig<TData, TMeta>>;
|
|
93
|
+
}>;
|
|
94
|
+
|
|
95
|
+
export function DriveViewConfigProvider<
|
|
96
|
+
TData,
|
|
97
|
+
TMeta extends TableMetaInput<TData> = TableMetaInput<TData>,
|
|
98
|
+
>({ config, children }: DriveViewConfigProviderProps<TData, TMeta>) {
|
|
99
|
+
return (
|
|
100
|
+
<DriveViewConfigContext value={config}>
|
|
101
|
+
<TableConfigProvider config={{ ...config, commands: config.commands?.selectedNodes }}>
|
|
102
|
+
{children}
|
|
103
|
+
</TableConfigProvider>
|
|
104
|
+
</DriveViewConfigContext>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function useDriveViewConfig<
|
|
109
|
+
TData,
|
|
110
|
+
TMeta extends TableMetaInput<TData> = TableMetaInput<TData>,
|
|
111
|
+
>() {
|
|
112
|
+
const tableConfig = useTableConfigContext<TData, TableFiltersResult, TMeta>();
|
|
113
|
+
const viewConfig = use(DriveViewConfigContext) as DriveViewConfigContextValue<TData, TMeta>;
|
|
114
|
+
|
|
115
|
+
return { ...tableConfig, ...viewConfig } as DriveViewConfig<TData, TMeta>;
|
|
116
|
+
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import type { VisibilityState } from "@tanstack/react-table";
|
|
4
|
-
import type { CommandDef } from "@tulip-systems/core/commands";
|
|
5
4
|
import { FloatingCommandMenu } from "@tulip-systems/core/commands/client";
|
|
6
5
|
import { type TableColumnDef, TableLayout, TableSkeleton } from "@tulip-systems/core/data-tables";
|
|
7
6
|
import {
|
|
8
|
-
createTableConfig,
|
|
9
7
|
DataTable,
|
|
10
8
|
type InfiniteStrategyMeta,
|
|
11
|
-
TableConfigProvider,
|
|
12
9
|
type useInfiniteStrategy,
|
|
13
|
-
useTableConfigContext,
|
|
14
10
|
} from "@tulip-systems/core/data-tables/client";
|
|
15
11
|
import { type ComponentProps, useMemo } from "react";
|
|
16
12
|
import {
|
|
@@ -22,6 +18,12 @@ import {
|
|
|
22
18
|
import { DriveGridCard, DriveGridCardSkeleton } from "@/components/grid-card.client";
|
|
23
19
|
import { useDriveSelectionContext } from "@/components/selection.client";
|
|
24
20
|
import { useDriveViewContext } from "@/components/view.client";
|
|
21
|
+
import {
|
|
22
|
+
createDriveViewConfig,
|
|
23
|
+
type DriveViewCommands,
|
|
24
|
+
DriveViewConfigProvider,
|
|
25
|
+
useDriveViewConfig,
|
|
26
|
+
} from "@/lib/view-config.client";
|
|
25
27
|
import { googleDriveColumns } from "../config/columns-data";
|
|
26
28
|
import type { GoogleDriveNode } from "../lib/validators";
|
|
27
29
|
import { useGoogleDriveContext } from "./provider.client";
|
|
@@ -34,7 +36,7 @@ type GoogleDriveViewProviderProps<TData extends GoogleDriveNode = GoogleDriveNod
|
|
|
34
36
|
queryData: TData[];
|
|
35
37
|
columns?: TableColumnDef<TData>[];
|
|
36
38
|
strategy: ReturnType<typeof useInfiniteStrategy>;
|
|
37
|
-
commands?:
|
|
39
|
+
commands?: DriveViewCommands<TData>;
|
|
38
40
|
columnVisibility?: VisibilityState;
|
|
39
41
|
};
|
|
40
42
|
|
|
@@ -49,14 +51,9 @@ export function GoogleDriveViewProvider<TData extends GoogleDriveNode = GoogleDr
|
|
|
49
51
|
}: GoogleDriveViewProviderProps<TData>) {
|
|
50
52
|
const { meta } = useGoogleDriveContext();
|
|
51
53
|
const selectionContext = useDriveSelectionContext();
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Table
|
|
55
|
-
*/
|
|
56
|
-
const config = createTableConfig<TData>({
|
|
54
|
+
const config = createDriveViewConfig<TData>({
|
|
57
55
|
queryData,
|
|
58
56
|
columns,
|
|
59
|
-
getRowId: (row) => row.id,
|
|
60
57
|
strategy,
|
|
61
58
|
commands,
|
|
62
59
|
meta,
|
|
@@ -65,9 +62,9 @@ export function GoogleDriveViewProvider<TData extends GoogleDriveNode = GoogleDr
|
|
|
65
62
|
});
|
|
66
63
|
|
|
67
64
|
return (
|
|
68
|
-
<
|
|
65
|
+
<DriveViewConfigProvider config={config}>
|
|
69
66
|
<TableLayout {...props}>{children}</TableLayout>
|
|
70
|
-
</
|
|
67
|
+
</DriveViewConfigProvider>
|
|
71
68
|
);
|
|
72
69
|
}
|
|
73
70
|
|
|
@@ -92,8 +89,7 @@ export function GoogleDriveView() {
|
|
|
92
89
|
* GoogleDriveGrid
|
|
93
90
|
*/
|
|
94
91
|
function GoogleDriveGrid(props: ComponentProps<"div">) {
|
|
95
|
-
const { queryData, strategy, commands, selection, meta } =
|
|
96
|
-
useTableConfigContext<GoogleDriveNode>();
|
|
92
|
+
const { queryData, strategy, commands, selection, meta } = useDriveViewConfig<GoogleDriveNode>();
|
|
97
93
|
const { rowCount, paginationState } = strategy;
|
|
98
94
|
const { isFetching, isFetchingNextPage, fetchNextPage } = strategy.meta as InfiniteStrategyMeta;
|
|
99
95
|
|
|
@@ -108,7 +104,7 @@ function GoogleDriveGrid(props: ComponentProps<"div">) {
|
|
|
108
104
|
<DriveGrid {...props}>
|
|
109
105
|
{queryData.length > 0 ? (
|
|
110
106
|
queryData.map((node) => (
|
|
111
|
-
<DriveGridCard key={node.id} node={node} commands={commands} unoptimized />
|
|
107
|
+
<DriveGridCard key={node.id} node={node} commands={commands?.node} unoptimized />
|
|
112
108
|
))
|
|
113
109
|
) : (
|
|
114
110
|
<DriveGridEmpty title="Geen resultaten gevonden" />
|
|
@@ -126,10 +122,10 @@ function GoogleDriveGrid(props: ComponentProps<"div">) {
|
|
|
126
122
|
isFetchingNextPage={isFetchingNextPage}
|
|
127
123
|
/>
|
|
128
124
|
|
|
129
|
-
{commands && commands.length > 0 && (
|
|
125
|
+
{commands?.selectedNodes && commands.selectedNodes.length > 0 && (
|
|
130
126
|
<FloatingCommandMenu
|
|
131
|
-
data={selectedData
|
|
132
|
-
commands={commands
|
|
127
|
+
data={selectedData}
|
|
128
|
+
commands={commands.selectedNodes}
|
|
133
129
|
meta={meta}
|
|
134
130
|
state={selectedData.length > 0 ? "open" : "closed"}
|
|
135
131
|
onSuccess={() => selection?.setRowSelection?.({})}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import type { VisibilityState } from "@tanstack/react-table";
|
|
4
|
-
import type { CommandDef } from "@tulip-systems/core/commands";
|
|
5
4
|
import { FloatingCommandMenu } from "@tulip-systems/core/commands/client";
|
|
6
5
|
import { type TableColumnDef, TableLayout, TableSkeleton } from "@tulip-systems/core/data-tables";
|
|
7
6
|
import {
|
|
8
|
-
createTableConfig,
|
|
9
7
|
DataTable,
|
|
10
8
|
type InfiniteStrategyMeta,
|
|
11
|
-
TableConfigProvider,
|
|
12
9
|
type useInfiniteStrategy,
|
|
13
|
-
useTableConfigContext,
|
|
14
10
|
} from "@tulip-systems/core/data-tables/client";
|
|
15
11
|
import { type ComponentProps, useMemo } from "react";
|
|
16
12
|
import {
|
|
@@ -22,6 +18,12 @@ import {
|
|
|
22
18
|
import { DriveGridCard, DriveGridCardSkeleton } from "@/components/grid-card.client";
|
|
23
19
|
import { useDriveSelectionContext } from "@/components/selection.client";
|
|
24
20
|
import { useDriveViewContext } from "@/components/view.client";
|
|
21
|
+
import {
|
|
22
|
+
createDriveViewConfig,
|
|
23
|
+
type DriveViewCommands,
|
|
24
|
+
DriveViewConfigProvider,
|
|
25
|
+
useDriveViewConfig,
|
|
26
|
+
} from "@/lib/view-config.client";
|
|
25
27
|
import { localDriveColumns } from "../config/columns-data";
|
|
26
28
|
import { localDriveImageLoader } from "../lib/helpers";
|
|
27
29
|
import type { LocalDriveNodeWithAsset } from "../lib/validators";
|
|
@@ -33,7 +35,7 @@ type LocalDriveViewProviderProps<TData extends LocalDriveNodeWithAsset = LocalDr
|
|
|
33
35
|
queryData: TData[];
|
|
34
36
|
columns?: TableColumnDef<TData>[];
|
|
35
37
|
strategy: ReturnType<typeof useInfiniteStrategy>;
|
|
36
|
-
commands?:
|
|
38
|
+
commands?: DriveViewCommands<TData>;
|
|
37
39
|
columnVisibility?: VisibilityState;
|
|
38
40
|
};
|
|
39
41
|
|
|
@@ -50,11 +52,9 @@ export function LocalDriveViewProvider<
|
|
|
50
52
|
}: LocalDriveViewProviderProps<TData>) {
|
|
51
53
|
const { meta } = useLocalDriveContext();
|
|
52
54
|
const selectionContext = useDriveSelectionContext();
|
|
53
|
-
|
|
54
|
-
const config = createTableConfig<TData>({
|
|
55
|
+
const config = createDriveViewConfig<TData>({
|
|
55
56
|
queryData,
|
|
56
57
|
columns,
|
|
57
|
-
getRowId: (row) => row.id,
|
|
58
58
|
strategy,
|
|
59
59
|
commands,
|
|
60
60
|
meta,
|
|
@@ -63,9 +63,9 @@ export function LocalDriveViewProvider<
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
return (
|
|
66
|
-
<
|
|
66
|
+
<DriveViewConfigProvider config={config}>
|
|
67
67
|
<TableLayout {...props}>{children}</TableLayout>
|
|
68
|
-
</
|
|
68
|
+
</DriveViewConfigProvider>
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -80,7 +80,7 @@ export function LocalDriveView() {
|
|
|
80
80
|
|
|
81
81
|
function LocalDriveGrid(props: ComponentProps<"div">) {
|
|
82
82
|
const { queryData, strategy, commands, selection, meta } =
|
|
83
|
-
|
|
83
|
+
useDriveViewConfig<LocalDriveNodeWithAsset>();
|
|
84
84
|
const { optimistic } = useLocalDriveUploadZone();
|
|
85
85
|
|
|
86
86
|
const { rowCount, paginationState } = strategy;
|
|
@@ -102,7 +102,7 @@ function LocalDriveGrid(props: ComponentProps<"div">) {
|
|
|
102
102
|
<DriveGridCard
|
|
103
103
|
key={node.id}
|
|
104
104
|
node={node}
|
|
105
|
-
commands={commands}
|
|
105
|
+
commands={commands?.node}
|
|
106
106
|
imageLoader={localDriveImageLoader}
|
|
107
107
|
/>
|
|
108
108
|
))
|
|
@@ -122,10 +122,10 @@ function LocalDriveGrid(props: ComponentProps<"div">) {
|
|
|
122
122
|
isFetchingNextPage={isFetchingNextPage}
|
|
123
123
|
/>
|
|
124
124
|
|
|
125
|
-
{commands && commands.length > 0 && (
|
|
125
|
+
{commands?.selectedNodes && commands?.selectedNodes.length > 0 && (
|
|
126
126
|
<FloatingCommandMenu
|
|
127
|
-
data={selectedData
|
|
128
|
-
commands={commands
|
|
127
|
+
data={selectedData}
|
|
128
|
+
commands={commands.selectedNodes}
|
|
129
129
|
meta={meta}
|
|
130
130
|
state={selectedData.length > 0 ? "open" : "closed"}
|
|
131
131
|
onSuccess={() => {
|