@tulip-systems/core 0.5.9 → 0.5.11
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/components/common/icons.d.mts +52 -52
- package/dist/components/common/icons.d.mts.map +1 -1
- package/dist/components/common/status.d.mts +3 -3
- package/dist/components/common/status.d.mts.map +1 -1
- package/dist/components/editor/components/content.client.d.mts +2 -2
- package/dist/components/editor/components/editor.client.d.mts +4 -4
- package/dist/components/editor/components/menu.client.d.mts +3 -3
- package/dist/components/editor/lib/helpers.d.mts.map +1 -1
- package/dist/components/header/back-button.client.d.mts +2 -2
- package/dist/components/header/bottom-bar.client.d.mts +3 -3
- package/dist/components/header/breadcrumbs.client.d.mts +7 -7
- package/dist/components/header/header.client.d.mts +2 -2
- package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
- package/dist/components/header/top-bar.client.d.mts +4 -4
- package/dist/components/layouts/admin-content.client.d.mts +2 -2
- package/dist/components/layouts/admin-error-pages.d.mts +4 -4
- package/dist/components/layouts/admin-error-pages.d.mts.map +1 -1
- package/dist/components/layouts/admin-layout.d.mts +2 -2
- package/dist/components/layouts/admin-layout.d.mts.map +1 -1
- package/dist/components/layouts/admin-loading.d.mts +2 -2
- package/dist/components/layouts/admin-loading.d.mts.map +1 -1
- package/dist/components/layouts/empty-page.d.mts +4 -4
- package/dist/components/layouts/empty-page.d.mts.map +1 -1
- package/dist/components/layouts/error-page.d.mts +9 -9
- package/dist/components/layouts/error-page.d.mts.map +1 -1
- package/dist/components/layouts/error-sections.d.mts +5 -5
- package/dist/components/layouts/list-layout.d.mts +2 -2
- package/dist/components/layouts/providers.client.d.mts +2 -2
- package/dist/components/layouts/root-error-pages.d.mts +2 -2
- package/dist/components/layouts/root-layout.server.d.mts +2 -2
- package/dist/components/layouts/root-layout.server.d.mts.map +1 -1
- package/dist/components/layouts/root-loading.d.mts +2 -2
- package/dist/components/layouts/tab-layout.d.mts +2 -2
- package/dist/components/lists/data-list.d.mts +5 -5
- package/dist/components/lists/data-stack.d.mts +8 -8
- package/dist/components/lists/data-stack.d.mts.map +1 -1
- package/dist/components/navigation/admin-sidebar-paths.client.d.mts +10 -10
- package/dist/components/ui/accordion.d.mts +5 -5
- package/dist/components/ui/alert-dialog.d.mts +12 -12
- package/dist/components/ui/alert.d.mts +4 -4
- package/dist/components/ui/aspect-ratio.d.mts +2 -2
- package/dist/components/ui/avatar.client.d.mts +4 -4
- package/dist/components/ui/badge.d.mts +5 -5
- package/dist/components/ui/breadcrumb.d.mts +8 -8
- package/dist/components/ui/button.d.mts +5 -5
- package/dist/components/ui/button.d.mts.map +1 -1
- package/dist/components/ui/calendar.d.mts +3 -3
- package/dist/components/ui/calendar.d.mts.map +1 -1
- package/dist/components/ui/card.d.mts +7 -7
- package/dist/components/ui/card.d.mts.map +1 -1
- package/dist/components/ui/carousel.d.mts +6 -6
- package/dist/components/ui/carousel.d.mts.map +1 -1
- package/dist/components/ui/chart.client.d.mts +5 -5
- package/dist/components/ui/checkbox.d.mts +2 -2
- package/dist/components/ui/checkbox.d.mts.map +1 -1
- package/dist/components/ui/collapsible.client.d.mts +4 -4
- package/dist/components/ui/color-picker.client.d.mts +2 -2
- package/dist/components/ui/combobox-dropdown.client.d.mts +2 -2
- package/dist/components/ui/combobox.client.d.mts +2 -2
- package/dist/components/ui/command.d.mts +10 -10
- package/dist/components/ui/command.d.mts.map +1 -1
- package/dist/components/ui/context-menu.d.mts +16 -16
- package/dist/components/ui/context-menu.d.mts.map +1 -1
- package/dist/components/ui/date-picker.client.d.mts +2 -2
- package/dist/components/ui/dialog.client.d.mts +11 -11
- package/dist/components/ui/drawer.client.d.mts +11 -11
- package/dist/components/ui/dropdown-menu.d.mts +16 -16
- package/dist/components/ui/dropdown-menu.d.mts.map +1 -1
- package/dist/components/ui/form.client.d.mts +7 -7
- package/dist/components/ui/hover-card.client.d.mts +4 -4
- package/dist/components/ui/input.d.mts +2 -2
- package/dist/components/ui/label.d.mts +2 -2
- package/dist/components/ui/navigation-menu.d.mts +11 -11
- package/dist/components/ui/pagination.d.mts +8 -8
- package/dist/components/ui/popover.d.mts +5 -5
- package/dist/components/ui/progress.client.d.mts +2 -2
- package/dist/components/ui/radio-group.d.mts +3 -3
- package/dist/components/ui/resizable.client.d.mts +4 -4
- package/dist/components/ui/scroll-area.d.mts +3 -3
- package/dist/components/ui/select.client.d.mts +11 -11
- package/dist/components/ui/separator.d.mts +2 -2
- package/dist/components/ui/sheet.client.d.mts +9 -9
- package/dist/components/ui/sidebar.client.d.mts +24 -24
- package/dist/components/ui/skeleton.d.mts +2 -2
- package/dist/components/ui/slider.d.mts +2 -2
- package/dist/components/ui/sonner.client.d.mts +2 -2
- package/dist/components/ui/switch.d.mts +2 -2
- package/dist/components/ui/tabs.d.mts +5 -5
- package/dist/components/ui/textarea.d.mts +2 -2
- package/dist/components/ui/time-input.client.d.mts +2 -2
- package/dist/components/ui/toggle-group.client.d.mts +3 -3
- package/dist/components/ui/toggle.d.mts +4 -4
- package/dist/components/ui/toggle.d.mts.map +1 -1
- package/dist/components/ui/tooltip.client.d.mts +5 -5
- package/dist/lib/hooks/use-indicator.d.mts +2 -2
- package/dist/lib/hooks/use-indicator.d.mts.map +1 -1
- package/dist/modules/auth/components/allowed.client.d.mts +2 -2
- package/dist/modules/auth/components/allowed.client.d.mts.map +1 -1
- package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
- package/dist/modules/auth/components/auth-layout.server.d.mts.map +1 -1
- package/dist/modules/auth/components/auth-loading.d.mts +2 -2
- package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
- package/dist/modules/auth/components/create-first-user-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/forget-password-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
- package/dist/modules/auth/components/guard-first-user.server.d.mts.map +1 -1
- package/dist/modules/auth/components/guard.server.d.mts +2 -2
- package/dist/modules/auth/components/guard.server.d.mts.map +1 -1
- package/dist/modules/auth/components/login-page.client.d.mts +2 -2
- package/dist/modules/auth/components/login-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/reset-password-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/update-password-command.d.mts +2 -2
- package/dist/modules/auth/components/update-password-command.d.mts.map +1 -1
- package/dist/modules/auth/db/schema.d.mts +73 -73
- package/dist/modules/auth/handler/client.client.d.mts +16 -16
- package/dist/modules/auth/lib/validators.d.mts +2 -2
- package/dist/modules/auth/lib/validators.d.mts.map +1 -1
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts +10 -10
- package/dist/modules/commands/components/click-command.client.d.mts +2 -2
- package/dist/modules/commands/components/command-trigger.client.d.mts +6 -6
- package/dist/modules/commands/components/dialog-command.client.d.mts +8 -8
- package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
- package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
- package/dist/modules/commands/components/form-dialog-command.client.d.mts +11 -11
- package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
- package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
- package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
- package/dist/modules/commands/utils/delete-command.client.d.mts +3 -3
- package/dist/modules/config/db/helpers.d.mts +5 -5
- package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
- package/dist/modules/data-tables/components/cell/common.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/column-header.d.mts +2 -2
- package/dist/modules/data-tables/components/column-header.d.mts.map +1 -1
- package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/slider.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/header.d.mts +4 -4
- package/dist/modules/data-tables/components/header.d.mts.map +1 -1
- package/dist/modules/data-tables/components/layout.d.mts +2 -2
- package/dist/modules/data-tables/components/layout.d.mts.map +1 -1
- package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
- package/dist/modules/data-tables/components/search-input.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/skeleton.d.mts +2 -2
- package/dist/modules/data-tables/components/skeleton.d.mts.map +1 -1
- package/dist/modules/data-tables/components/table.d.mts +7 -7
- package/dist/modules/data-tables/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/components/toolbar.d.mts +3 -3
- package/dist/modules/data-tables/components/toolbar.d.mts.map +1 -1
- package/dist/modules/data-tables/hooks/use-context.client.d.mts +2 -2
- package/dist/modules/data-tables/hooks/use-context.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/data-table/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/read-only.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/read-only.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/combobox.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/date-input.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/date-picker.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/editor.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/input-recipient.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/input-toggle.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/input.client.d.mts +4 -4
- package/dist/modules/inline-edit/components/select.client.d.mts +6 -6
- package/dist/modules/inline-edit/components/switch.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/toggle.client.d.mts +2 -2
- package/dist/modules/inline-edit/hooks/context.client.d.mts +2 -2
- package/dist/modules/inline-edit/lib/variants.d.mts +1 -1
- package/dist/modules/router/lib/query-client.server.d.mts +2 -2
- package/dist/modules/storage/components/dropzone-context.client.d.mts +2 -2
- package/dist/modules/storage/components/dropzone-context.client.d.mts.map +1 -1
- package/dist/modules/storage/components/dropzone.client.d.mts +5 -5
- package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/image-grid.client.d.mts +10 -3
- package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -1
- package/dist/modules/storage/components/image-grid.client.mjs +8 -9
- package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
- package/dist/modules/storage/components/upload-zone-context.client.d.mts +7 -2
- package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.d.mts +6 -9
- package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.mjs +38 -58
- package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
- package/dist/modules/storage/lib/router.server.d.mts +12 -12
- package/dist/modules/storage/lib/schema.d.mts +92 -92
- package/dist/modules/storage/lib/service.server.d.mts +21 -21
- package/dist/modules/storage/lib/validators.d.mts +87 -87
- package/package.json +1 -1
- package/src/modules/storage/components/image-grid.client.tsx +10 -8
- package/src/modules/storage/components/upload-zone-context.client.tsx +9 -2
- package/src/modules/storage/components/upload-zone.client.tsx +49 -77
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime363 from "react/jsx-runtime";
|
|
2
|
+
import * as react106 from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { DropEvent, DropzoneOptions, FileRejection } from "react-dropzone";
|
|
5
5
|
|
|
@@ -25,7 +25,7 @@ declare function Dropzone({
|
|
|
25
25
|
className,
|
|
26
26
|
children,
|
|
27
27
|
...props
|
|
28
|
-
}: DropzoneProps):
|
|
28
|
+
}: DropzoneProps): react_jsx_runtime363.JSX.Element;
|
|
29
29
|
/**
|
|
30
30
|
* DropzoneContent
|
|
31
31
|
*/
|
|
@@ -36,7 +36,7 @@ type DropzoneContentProps = {
|
|
|
36
36
|
declare function DropzoneContent({
|
|
37
37
|
children,
|
|
38
38
|
className
|
|
39
|
-
}: DropzoneContentProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean |
|
|
39
|
+
}: DropzoneContentProps): string | number | bigint | true | react_jsx_runtime363.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react106.ReactPortal | react106.ReactElement<unknown, string | react106.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
|
|
40
40
|
/**
|
|
41
41
|
* DropzoneEmptyState
|
|
42
42
|
*/
|
|
@@ -47,7 +47,7 @@ type DropzoneEmptyStateProps = {
|
|
|
47
47
|
declare function DropzoneEmptyState({
|
|
48
48
|
children,
|
|
49
49
|
className
|
|
50
|
-
}: DropzoneEmptyStateProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean |
|
|
50
|
+
}: DropzoneEmptyStateProps): string | number | bigint | true | react_jsx_runtime363.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react106.ReactPortal | react106.ReactElement<unknown, string | react106.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
|
|
51
51
|
//#endregion
|
|
52
52
|
export { Dropzone, DropzoneContent, DropzoneContentProps, DropzoneEmptyState, DropzoneEmptyStateProps, DropzoneProps };
|
|
53
53
|
//# sourceMappingURL=dropzone.client.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropzone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/dropzone.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;KAcY,aAAA,GAAgB,KAAK;EAArB,GAAA,CAAA,EACJ,IADI,EAAA;EAAqB,SAAA,CAAA,EAAA,MAAA;EAAL,MAAA,CAAA,EAAA,CAAA,aAAA,EAGD,IAHC,EAAA,EAAA,cAAA,EAGuB,aAHvB,EAAA,EAAA,KAAA,EAG+C,SAH/C,EAAA,GAAA,IAAA;EACpB,QAAA,CAAA,EAGK,SAHL;CAEmB;AAAwB,iBAInC,QAAA,CAJmC;EAAA,MAAA;EAAA,QAAA;EAAA,OAAA;EAAA,OAAA;EAAA,MAAA;EAAA,OAAA;EAAA,QAAA;EAAA,GAAA;EAAA,SAAA;EAAA,QAAA;EAAA,GAAA;AAAA,CAAA,EAgBhD,aAhBgD,CAAA,EAgBnC,
|
|
1
|
+
{"version":3,"file":"dropzone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/dropzone.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;KAcY,aAAA,GAAgB,KAAK;EAArB,GAAA,CAAA,EACJ,IADI,EAAA;EAAqB,SAAA,CAAA,EAAA,MAAA;EAAL,MAAA,CAAA,EAAA,CAAA,aAAA,EAGD,IAHC,EAAA,EAAA,cAAA,EAGuB,aAHvB,EAAA,EAAA,KAAA,EAG+C,SAH/C,EAAA,GAAA,IAAA;EACpB,QAAA,CAAA,EAGK,SAHL;CAEmB;AAAwB,iBAInC,QAAA,CAJmC;EAAA,MAAA;EAAA,QAAA;EAAA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CAAA,GAAA,CAAA,CAAA,GAoFmE,QApFnE,CAoFmE,SApFnE,CAAA,GAAA,IAAA,GAAA,SAAA,CAAA,GAAA,IAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileNode } from "../lib/validators.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime366 from "react/jsx-runtime";
|
|
3
3
|
import { ComponentProps } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/modules/storage/components/image-grid.client.d.ts
|
|
@@ -13,14 +13,21 @@ type ImageGridProps = ComponentProps<"div"> & {
|
|
|
13
13
|
fromIndex: number;
|
|
14
14
|
toIndex: number;
|
|
15
15
|
}) => Promise<void>;
|
|
16
|
+
optimistic?: {
|
|
17
|
+
move?: (params: {
|
|
18
|
+
fromIndex: number;
|
|
19
|
+
toIndex: number;
|
|
20
|
+
}) => Promise<void> | void;
|
|
21
|
+
};
|
|
16
22
|
};
|
|
17
23
|
declare function ImageGrid({
|
|
18
24
|
nodes,
|
|
19
25
|
moveAction,
|
|
26
|
+
optimistic,
|
|
20
27
|
disabled,
|
|
21
28
|
...props
|
|
22
|
-
}: ImageGridProps):
|
|
23
|
-
declare function ImageGridSkeleton(props: ComponentProps<"div">):
|
|
29
|
+
}: ImageGridProps): react_jsx_runtime366.JSX.Element;
|
|
30
|
+
declare function ImageGridSkeleton(props: ComponentProps<"div">): react_jsx_runtime366.JSX.Element;
|
|
24
31
|
//#endregion
|
|
25
32
|
export { ImageGrid, ImageGridSkeleton };
|
|
26
33
|
//# sourceMappingURL=image-grid.client.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-grid.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"image-grid.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAsC6C,KAMxC,cAAA,GAAiB,cAAH,CAAA,KAAA,CAAA,GAAA;EAAG,KAAA,EACb,QADa,EAAA;EACb,QAAA,CAAA,EAAA,OAAA;EAEyD,UAAA,EAAA,CAAA,MAAA,EAAA;IAEH,SAAA,EAAA,MAAA;IAAO,OAAA,EAAA,MAAA;EAItD,CAAA,EAAA,GANkD,OAMzC,CAAA,IAAA,CAAA;EAAG,UAAA,CAAA,EAAA;IAAO,IAAA,CAAA,EAAA,CAAA,MAAA,EAAA;MAAY,SAAA,EAAA,MAAA;MAAY,OAAA,EAAA,MAAA;IAAsB,CAAA,EAAA,GAJlB,OAIkB,CAAA,IAAA,CAAA,GAAA,IAAA;EAAc,CAAA;CAAA;AAkK/E,iBAlKA,SAAA,CAkKiB;EAAA,KAAQ;EAAA,UAAqB;EAAA,UAAA;EAAA,QAAA;EAAA,GAAA;AAAA,CAAA,EAlKmB,cAkKnB,CAAA,EAlKiC,oBAAA,CAAA,GAAA,CAAA,OAkKjC;iBAA9C,iBAAA,QAAyB,wBAAqB,oBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { Icons } from "../../../components/common/icons.mjs";
|
|
4
4
|
import { cn } from "../../../lib/utils/cn.mjs";
|
|
5
5
|
import { Button } from "../../../components/ui/button.mjs";
|
|
6
|
-
import { arrayMove } from "../../../lib/utils/array-move.mjs";
|
|
7
6
|
import { getFileUrl, imageLoader } from "../lib/helpers.mjs";
|
|
8
7
|
import { Skeleton } from "../../../components/ui/skeleton.mjs";
|
|
9
8
|
import { Input } from "../../../components/ui/input.mjs";
|
|
@@ -21,8 +20,8 @@ import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useDroppable,
|
|
|
21
20
|
import { CSS } from "@dnd-kit/utilities";
|
|
22
21
|
|
|
23
22
|
//#region src/modules/storage/components/image-grid.client.tsx
|
|
24
|
-
function ImageGrid({ nodes, moveAction, disabled, ...props }) {
|
|
25
|
-
const
|
|
23
|
+
function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }) {
|
|
24
|
+
const uploadZone = useUploadZone();
|
|
26
25
|
const images = nodes.flatMap((node) => ({
|
|
27
26
|
...node,
|
|
28
27
|
url: getFileUrl(node.id)
|
|
@@ -38,10 +37,10 @@ function ImageGrid({ nodes, moveAction, disabled, ...props }) {
|
|
|
38
37
|
if (!activeId || !overId || activeId === overId) return Promise.resolve();
|
|
39
38
|
const fromIndex = images.findIndex((image) => image.id === activeId);
|
|
40
39
|
const toIndex = images.findIndex((image) => image.id === overId);
|
|
41
|
-
await
|
|
40
|
+
await optimistic?.move?.({
|
|
42
41
|
fromIndex,
|
|
43
42
|
toIndex
|
|
44
|
-
})
|
|
43
|
+
});
|
|
45
44
|
await moveAction({
|
|
46
45
|
fromIndex,
|
|
47
46
|
toIndex
|
|
@@ -49,7 +48,7 @@ function ImageGrid({ nodes, moveAction, disabled, ...props }) {
|
|
|
49
48
|
},
|
|
50
49
|
onSuccess: async () => {
|
|
51
50
|
setCurrent(0);
|
|
52
|
-
await
|
|
51
|
+
await uploadZone.optimistic?.invalidate?.();
|
|
53
52
|
},
|
|
54
53
|
onError: (error) => {
|
|
55
54
|
console.error("Error moving image:", error);
|
|
@@ -80,7 +79,7 @@ function ImageGrid({ nodes, moveAction, disabled, ...props }) {
|
|
|
80
79
|
multiple: true,
|
|
81
80
|
onChange: (e) => {
|
|
82
81
|
if (!e.target.files) return;
|
|
83
|
-
return Array.from(e.target.files).map(onUpload);
|
|
82
|
+
return Array.from(e.target.files).map(uploadZone.onUpload);
|
|
84
83
|
}
|
|
85
84
|
})]
|
|
86
85
|
})]
|
|
@@ -114,7 +113,7 @@ function ImageGrid({ nodes, moveAction, disabled, ...props }) {
|
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
function ImageGridItem({ node, index, setCurrent }) {
|
|
117
|
-
const
|
|
116
|
+
const uploadZone = useUploadZone();
|
|
118
117
|
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: node.id });
|
|
119
118
|
return /* @__PURE__ */ jsx(Card, {
|
|
120
119
|
id: node.id,
|
|
@@ -149,7 +148,7 @@ function ImageGridItem({ node, index, setCurrent }) {
|
|
|
149
148
|
type: "button",
|
|
150
149
|
variant: "destructive",
|
|
151
150
|
size: "icon",
|
|
152
|
-
onClick: () =>
|
|
151
|
+
onClick: () => uploadZone.onRemove([node.id]),
|
|
153
152
|
className: "absolute left-2 top-2 hidden p-1 group-hover:flex",
|
|
154
153
|
children: /* @__PURE__ */ jsx(Icons.trash, { className: "size-4" })
|
|
155
154
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-grid.client.mjs","names":["Image"],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { Icons } from \"@/components/common/icons\";\nimport { Button } from \"@/components/ui/button\";\nimport { Card } from \"@/components/ui/card\";\nimport {\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n} from \"@/components/ui/carousel\";\nimport { Dialog, DialogContent, DialogTrigger } from \"@/components/ui/dialog.client\";\nimport { Input } from \"@/components/ui/input\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport { useAction } from \"@/lib/entry.client\";\nimport { arrayMove } from \"@/lib/utils/array-move\";\nimport { cn } from \"@/lib/utils/cn\";\nimport {\n closestCenter,\n DndContext,\n DragEndEvent,\n KeyboardSensor,\n PointerSensor,\n useDroppable,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport {\n rectSortingStrategy,\n SortableContext,\n sortableKeyboardCoordinates,\n useSortable,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { GripIcon, UploadIcon } from \"lucide-react\";\nimport Image from \"next/image\";\nimport React, { ComponentProps } from \"react\";\nimport { getFileUrl, imageLoader } from \"../lib/helpers\";\nimport { FileNode } from \"../lib/validators\";\nimport { useUploadZone } from \"./upload-zone-context.client\";\n\n/**\n * Image Grid\n */\ntype ImageGridProps = ComponentProps<\"div\"> & {\n nodes: FileNode[];\n disabled?: boolean;\n moveAction: (params: { fromIndex: number; toIndex: number }) => Promise<void>;\n};\n\nexport function ImageGrid({ nodes, moveAction, disabled, ...props }: ImageGridProps) {\n const { onUpload, updateData, invalidateQuery } = useUploadZone();\n\n const images = nodes.flatMap((node) => ({ ...node, url: getFileUrl(node.id) }));\n\n const [current, setCurrent] = React.useState<number>(0);\n\n const { setNodeRef } = useDroppable({ id: \"image-grid\" });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const moveMuration = useAction({\n mutationFn: async ({ active, over }: DragEndEvent) => {\n if (!moveAction) return Promise.resolve();\n\n const activeId = active.id;\n const overId = over?.id;\n if (!activeId || !overId || activeId === overId) return Promise.resolve();\n\n const fromIndex = images.findIndex((image) => image.id === activeId);\n const toIndex = images.findIndex((image) => image.id === overId);\n\n await updateData((prev) => arrayMove(prev, { fromIndex, toIndex }));\n await moveAction({ fromIndex, toIndex });\n },\n onSuccess: async () => {\n setCurrent(0);\n await invalidateQuery();\n },\n onError: (error) => {\n console.error(\"Error moving image:\", error);\n },\n });\n\n return (\n <Dialog {...props}>\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={moveMuration.mutate}\n >\n <div\n ref={setNodeRef}\n className=\"grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5\"\n >\n <SortableContext items={images.map((image) => image.id)} strategy={rectSortingStrategy}>\n {images.map((node, index) => (\n <ImageGridItem key={node.id} node={node} index={index} setCurrent={setCurrent} />\n ))}\n\n {!disabled && (\n <label className=\"border-muted-foreground bg-muted hover:border-primary relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center rounded-lg border border-dashed\">\n <UploadIcon className=\"h-8 w-8\" />\n <Input\n type=\"file\"\n accept=\"image/jpeg, image/png, image/webp, image/gif\"\n className=\"absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0\"\n multiple\n onChange={(e) => {\n if (!e.target.files) return;\n return Array.from(e.target.files).map(onUpload);\n }}\n />\n </label>\n )}\n </SortableContext>\n </div>\n </DndContext>\n\n <Carousel className=\"w-full\" opts={{ startIndex: current }}>\n <DialogContent className=\"border-none bg-transparent p-0 shadow-none md:max-w-[80vw] xl:max-w-[60vw]\">\n <CarouselContent className=\"md:max-h-[80vh]\">\n {images.map(({ id, url }) => (\n <CarouselItem key={id} className=\"overflow-hidden rounded-xl\">\n <Image\n src={url}\n alt=\"Image Preview\"\n width={1920}\n height={1080}\n className=\"h-full w-full rounded-xl object-contain\"\n loader={imageLoader}\n />\n </CarouselItem>\n ))}\n </CarouselContent>\n <CarouselPrevious />\n <CarouselNext />\n </DialogContent>\n </Carousel>\n </Dialog>\n );\n}\n\n/**\n * Image Grid Item\n */\ntype ImageGridItemProps = {\n node: FileNode & { url: string };\n index: number;\n setCurrent: React.Dispatch<React.SetStateAction<number>>;\n};\n\nfunction ImageGridItem({ node, index, setCurrent }: ImageGridItemProps) {\n const { uploadClient } = useUploadZone();\n\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: node.id });\n\n return (\n <Card\n id={node.id}\n ref={setNodeRef}\n style={{\n transform: CSS.Transform.toString(transform),\n transition,\n }}\n className={cn(\"group relative aspect-square w-full\", node.isPending && \"opacity-30\")}\n >\n {!node.isPending ? (\n <>\n <DialogTrigger onClick={() => setCurrent(index)}>\n <Image\n src={node.url}\n alt=\"Image Preview\"\n width={100}\n height={100}\n className=\"bg-muted absolute inset-0 h-full w-full cursor-pointer rounded-lg object-contain\"\n loader={imageLoader}\n />\n </DialogTrigger>\n\n <Button\n {...attributes}\n {...listeners}\n type=\"button\"\n variant=\"secondary\"\n size=\"icon\"\n className=\"absolute right-2 top-2 hidden p-1 group-hover:flex\"\n >\n <GripIcon className=\"size-4\" />\n </Button>\n\n <Button\n type=\"button\"\n variant=\"destructive\"\n size=\"icon\"\n onClick={() => uploadClient.deleteFiles([node.id])}\n className=\"absolute left-2 top-2 hidden p-1 group-hover:flex\"\n >\n <Icons.trash className=\"size-4\" />\n </Button>\n </>\n ) : (\n <Skeleton className=\"absolute inset-0 h-full w-full rounded-lg\" />\n )}\n </Card>\n );\n}\n\nexport function ImageGridSkeleton(props: ComponentProps<\"div\">) {\n return (\n <div\n {...props}\n className={cn(\"grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5\", props.className)}\n >\n {Array.from({ length: 12 }).map((_, index) => (\n <Skeleton key={index} className=\"aspect-square w-full rounded-lg\" />\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,GAAG,SAAyB;CACnF,MAAM,EAAE,UAAU,YAAY,oBAAoB,eAAe;CAEjE,MAAM,SAAS,MAAM,SAAS,UAAU;EAAE,GAAG;EAAM,KAAK,WAAW,KAAK,GAAG;EAAE,EAAE;CAE/E,MAAM,CAAC,SAAS,cAAc,MAAM,SAAiB,EAAE;CAEvD,MAAM,EAAE,eAAe,aAAa,EAAE,IAAI,cAAc,CAAC;CACzD,MAAM,UAAU,WACd,UAAU,cAAc,EACxB,UAAU,gBAAgB,EACxB,kBAAkB,6BACnB,CAAC,CACH;CAED,MAAM,eAAe,UAAU;EAC7B,YAAY,OAAO,EAAE,QAAQ,WAAyB;AACpD,OAAI,CAAC,WAAY,QAAO,QAAQ,SAAS;GAEzC,MAAM,WAAW,OAAO;GACxB,MAAM,SAAS,MAAM;AACrB,OAAI,CAAC,YAAY,CAAC,UAAU,aAAa,OAAQ,QAAO,QAAQ,SAAS;GAEzE,MAAM,YAAY,OAAO,WAAW,UAAU,MAAM,OAAO,SAAS;GACpE,MAAM,UAAU,OAAO,WAAW,UAAU,MAAM,OAAO,OAAO;AAEhE,SAAM,YAAY,SAAS,UAAU,MAAM;IAAE;IAAW;IAAS,CAAC,CAAC;AACnE,SAAM,WAAW;IAAE;IAAW;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UAAU,SAAS,UAAU;GAC5C;GACD;EACD,WAAW,GAAG,uCAAuC,KAAK,aAAa,aAAa;YAEnF,CAAC,KAAK,YACL;GACE,oBAAC;IAAc,eAAe,WAAW,MAAM;cAC7C,oBAACA;KACC,KAAK,KAAK;KACV,KAAI;KACJ,OAAO;KACP,QAAQ;KACR,WAAU;KACV,QAAQ;MACR;KACY;GAEhB,oBAAC;IACC,GAAI;IACJ,GAAI;IACJ,MAAK;IACL,SAAQ;IACR,MAAK;IACL,WAAU;cAEV,oBAAC,YAAS,WAAU,WAAW;KACxB;GAET,oBAAC;IACC,MAAK;IACL,SAAQ;IACR,MAAK;IACL,eAAe,aAAa,YAAY,CAAC,KAAK,GAAG,CAAC;IAClD,WAAU;cAEV,oBAAC,MAAM,SAAM,WAAU,WAAW;KAC3B;MACR,GAEH,oBAAC,YAAS,WAAU,8CAA8C;GAE/D;;AAIX,SAAgB,kBAAkB,OAA8B;AAC9D,QACE,oBAAC;EACC,GAAI;EACJ,WAAW,GAAG,8DAA8D,MAAM,UAAU;YAE3F,MAAM,KAAK,EAAE,QAAQ,IAAI,CAAC,CAAC,KAAK,GAAG,UAClC,oBAAC,YAAqB,WAAU,qCAAjB,MAAqD,CACpE;GACE"}
|
|
1
|
+
{"version":3,"file":"image-grid.client.mjs","names":["Image"],"sources":["../../../../src/modules/storage/components/image-grid.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { Icons } from \"@/components/common/icons\";\nimport { Button } from \"@/components/ui/button\";\nimport { Card } from \"@/components/ui/card\";\nimport {\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n} from \"@/components/ui/carousel\";\nimport { Dialog, DialogContent, DialogTrigger } from \"@/components/ui/dialog.client\";\nimport { Input } from \"@/components/ui/input\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport { useAction } from \"@/lib/entry.client\";\nimport { cn } from \"@/lib/utils/cn\";\nimport {\n closestCenter,\n DndContext,\n DragEndEvent,\n KeyboardSensor,\n PointerSensor,\n useDroppable,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport {\n rectSortingStrategy,\n SortableContext,\n sortableKeyboardCoordinates,\n useSortable,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { GripIcon, UploadIcon } from \"lucide-react\";\nimport Image from \"next/image\";\nimport React, { ComponentProps } from \"react\";\nimport { getFileUrl, imageLoader } from \"../lib/helpers\";\nimport { FileNode } from \"../lib/validators\";\nimport { useUploadZone } from \"./upload-zone-context.client\";\n\n/**\n * Image Grid\n */\ntype ImageGridProps = ComponentProps<\"div\"> & {\n nodes: FileNode[];\n disabled?: boolean;\n moveAction: (params: { fromIndex: number; toIndex: number }) => Promise<void>;\n optimistic?: {\n move?: (params: { fromIndex: number; toIndex: number }) => Promise<void> | void;\n };\n};\n\nexport function ImageGrid({ nodes, moveAction, optimistic, disabled, ...props }: ImageGridProps) {\n const uploadZone = useUploadZone();\n\n const images = nodes.flatMap((node) => ({ ...node, url: getFileUrl(node.id) }));\n\n const [current, setCurrent] = React.useState<number>(0);\n\n const { setNodeRef } = useDroppable({ id: \"image-grid\" });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const moveMuration = useAction({\n mutationFn: async ({ active, over }: DragEndEvent) => {\n if (!moveAction) return Promise.resolve();\n\n const activeId = active.id;\n const overId = over?.id;\n if (!activeId || !overId || activeId === overId) return Promise.resolve();\n\n const fromIndex = images.findIndex((image) => image.id === activeId);\n const toIndex = images.findIndex((image) => image.id === overId);\n\n await optimistic?.move?.({ fromIndex, toIndex });\n await moveAction({ fromIndex, toIndex });\n },\n onSuccess: async () => {\n setCurrent(0);\n await uploadZone.optimistic?.invalidate?.();\n },\n onError: (error) => {\n console.error(\"Error moving image:\", error);\n },\n });\n\n return (\n <Dialog {...props}>\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={moveMuration.mutate}\n >\n <div\n ref={setNodeRef}\n className=\"grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5\"\n >\n <SortableContext items={images.map((image) => image.id)} strategy={rectSortingStrategy}>\n {images.map((node, index) => (\n <ImageGridItem key={node.id} node={node} index={index} setCurrent={setCurrent} />\n ))}\n\n {!disabled && (\n <label className=\"border-muted-foreground bg-muted hover:border-primary relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center rounded-lg border border-dashed\">\n <UploadIcon className=\"h-8 w-8\" />\n <Input\n type=\"file\"\n accept=\"image/jpeg, image/png, image/webp, image/gif\"\n className=\"absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0\"\n multiple\n onChange={(e) => {\n if (!e.target.files) return;\n return Array.from(e.target.files).map(uploadZone.onUpload);\n }}\n />\n </label>\n )}\n </SortableContext>\n </div>\n </DndContext>\n\n <Carousel className=\"w-full\" opts={{ startIndex: current }}>\n <DialogContent className=\"border-none bg-transparent p-0 shadow-none md:max-w-[80vw] xl:max-w-[60vw]\">\n <CarouselContent className=\"md:max-h-[80vh]\">\n {images.map(({ id, url }) => (\n <CarouselItem key={id} className=\"overflow-hidden rounded-xl\">\n <Image\n src={url}\n alt=\"Image Preview\"\n width={1920}\n height={1080}\n className=\"h-full w-full rounded-xl object-contain\"\n loader={imageLoader}\n />\n </CarouselItem>\n ))}\n </CarouselContent>\n <CarouselPrevious />\n <CarouselNext />\n </DialogContent>\n </Carousel>\n </Dialog>\n );\n}\n\n/**\n * Image Grid Item\n */\ntype ImageGridItemProps = {\n node: FileNode & { url: string };\n index: number;\n setCurrent: React.Dispatch<React.SetStateAction<number>>;\n};\n\nfunction ImageGridItem({ node, index, setCurrent }: ImageGridItemProps) {\n const uploadZone = useUploadZone();\n\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: node.id });\n\n return (\n <Card\n id={node.id}\n ref={setNodeRef}\n style={{\n transform: CSS.Transform.toString(transform),\n transition,\n }}\n className={cn(\"group relative aspect-square w-full\", node.isPending && \"opacity-30\")}\n >\n {!node.isPending ? (\n <>\n <DialogTrigger onClick={() => setCurrent(index)}>\n <Image\n src={node.url}\n alt=\"Image Preview\"\n width={100}\n height={100}\n className=\"bg-muted absolute inset-0 h-full w-full cursor-pointer rounded-lg object-contain\"\n loader={imageLoader}\n />\n </DialogTrigger>\n\n <Button\n {...attributes}\n {...listeners}\n type=\"button\"\n variant=\"secondary\"\n size=\"icon\"\n className=\"absolute right-2 top-2 hidden p-1 group-hover:flex\"\n >\n <GripIcon className=\"size-4\" />\n </Button>\n\n <Button\n type=\"button\"\n variant=\"destructive\"\n size=\"icon\"\n onClick={() => uploadZone.onRemove([node.id])}\n className=\"absolute left-2 top-2 hidden p-1 group-hover:flex\"\n >\n <Icons.trash className=\"size-4\" />\n </Button>\n </>\n ) : (\n <Skeleton className=\"absolute inset-0 h-full w-full rounded-lg\" />\n )}\n </Card>\n );\n}\n\nexport function ImageGridSkeleton(props: ComponentProps<\"div\">) {\n return (\n <div\n {...props}\n className={cn(\"grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-5\", props.className)}\n >\n {Array.from({ length: 12 }).map((_, index) => (\n <Skeleton key={index} className=\"aspect-square w-full rounded-lg\" />\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,UAAU,EAAE,OAAO,YAAY,YAAY,UAAU,GAAG,SAAyB;CAC/F,MAAM,aAAa,eAAe;CAElC,MAAM,SAAS,MAAM,SAAS,UAAU;EAAE,GAAG;EAAM,KAAK,WAAW,KAAK,GAAG;EAAE,EAAE;CAE/E,MAAM,CAAC,SAAS,cAAc,MAAM,SAAiB,EAAE;CAEvD,MAAM,EAAE,eAAe,aAAa,EAAE,IAAI,cAAc,CAAC;CACzD,MAAM,UAAU,WACd,UAAU,cAAc,EACxB,UAAU,gBAAgB,EACxB,kBAAkB,6BACnB,CAAC,CACH;CAED,MAAM,eAAe,UAAU;EAC7B,YA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|
|
11
11
|
uploadClient: UploadClient;
|
|
12
|
-
updateData: (newValue: FileNode[] | ((oldValue: FileNode[]) => FileNode[])) => Promise<void>;
|
|
13
|
-
invalidateQuery: () => Promise<void> | void;
|
|
14
12
|
onUpload: (file: File) => Promise<Node>;
|
|
13
|
+
onRemove: (ids: string[]) => Promise<void>;
|
|
14
|
+
optimistic?: {
|
|
15
|
+
add?: (newValue: FileNode) => Promise<void> | void;
|
|
16
|
+
remove?: (ids: string[]) => Promise<void> | void;
|
|
17
|
+
invalidate?: () => Promise<void> | void;
|
|
18
|
+
cancel?: () => Promise<void> | void;
|
|
19
|
+
};
|
|
15
20
|
};
|
|
16
21
|
/**
|
|
17
22
|
* Upload Zone Context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone-context.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AACgB,KADJ,sBAAA,GACI;
|
|
1
|
+
{"version":3,"file":"upload-zone-context.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AACgB,KADJ,sBAAA,GACI;EACG,YAAA,EADH,YACG;EAAiB,QAAA,EAAA,CAAA,IAAA,EAAjB,IAAiB,EAAA,GAAR,OAAQ,CAAA,IAAA,CAAA;EAAR,QAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,EAAA,GACG,OADH,CAAA,IAAA,CAAA;EACG,UAAA,CAAA,EAAA;IAEV,GAAA,CAAA,EAAA,CAAA,QAAA,EAAA,QAAA,EAAA,GAAa,OAAb,CAAA,IAAA,CAAA,GAAA,IAAA;IAAa,MAAA,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,EAAA,GACF,OADE,CAAA,IAAA,CAAA,GAAA,IAAA;IACF,UAAA,CAAA,EAAA,GAAA,GACT,OADS,CAAA,IAAA,CAAA,GAAA,IAAA;IACT,MAAA,CAAA,EAAA,GAAA,GACJ,OADI,CAAA,IAAA,CAAA,GAAA,IAAA;EACJ,CAAA;CAAO;AAS1B;AAKA;;cALa,mBAAiB,KAAA,CAAA,QAAA;;;;iBAKd,aAAA,CAAA,GAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone-context.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { UploadClient } from \"../lib/create-upload.client\";\nimport { FileNode, Node } from \"../lib/validators\";\n\n/**\n * Upload Zone Context Value\n */\nexport type UploadZoneContextValue = {\n uploadClient: UploadClient;\n
|
|
1
|
+
{"version":3,"file":"upload-zone-context.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/upload-zone-context.client.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { UploadClient } from \"../lib/create-upload.client\";\nimport { FileNode, Node } from \"../lib/validators\";\n\n/**\n * Upload Zone Context Value\n */\nexport type UploadZoneContextValue = {\n uploadClient: UploadClient;\n onUpload: (file: File) => Promise<Node>;\n onRemove: (ids: string[]) => Promise<void>;\n optimistic?: {\n add?: (newValue: FileNode) => Promise<void> | void;\n remove?: (ids: string[]) => Promise<void> | void;\n invalidate?: () => Promise<void> | void;\n cancel?: () => Promise<void> | void;\n };\n // updateData: (newValue: FileNode[] | ((oldValue: FileNode[]) => FileNode[])) => Promise<void>;\n // invalidateQuery: () => Promise<void> | void;\n};\n\n/**\n * Upload Zone Context\n */\nexport const UploadZoneContext = React.createContext({} as UploadZoneContextValue);\n\n/**\n * Upload Zone Hook\n */\nexport function useUploadZone() {\n const context = React.useContext(UploadZoneContext);\n if (!context) {\n throw new Error(\"useUploadZone must be used within an UploadZoneProvider\");\n }\n return context;\n}\n"],"mappings":";;;;;;;;AA0BA,MAAa,oBAAoB,MAAM,cAAc,EAAE,CAA2B;;;;AAKlF,SAAgB,gBAAgB;CAC9B,MAAM,UAAU,MAAM,WAAW,kBAAkB;AACnD,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,0DAA0D;AAE5E,QAAO"}
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { Node, UploadFileSchema } from "../lib/validators.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { UploadHooks } from "../lib/create-upload.client.mjs";
|
|
3
|
+
import { UploadZoneContextValue } from "./upload-zone-context.client.mjs";
|
|
4
|
+
import * as react_jsx_runtime368 from "react/jsx-runtime";
|
|
4
5
|
import { ComponentProps } from "react";
|
|
5
6
|
|
|
6
7
|
//#region src/modules/storage/components/upload-zone.client.d.ts
|
|
7
|
-
type UploadZoneProps = ComponentProps<"div"> & {
|
|
8
|
-
queryKey: readonly unknown[];
|
|
8
|
+
type UploadZoneProps = ComponentProps<"div"> & Pick<UploadZoneContextValue, "optimistic" | "uploadClient"> & {
|
|
9
9
|
variables: Pick<UploadFileSchema, "namespace" | "parentId" | "mode" | "hidden" | "readonly">;
|
|
10
|
-
uploadClient: UploadClient;
|
|
11
10
|
uploadHooks?: UploadHooks;
|
|
12
11
|
onUploadCompleted?: (node: Node) => Promise<void> | void;
|
|
13
12
|
onUploadFailed?: (error: unknown) => Promise<void> | void;
|
|
14
13
|
};
|
|
15
14
|
declare function UploadZone({
|
|
16
15
|
variables,
|
|
17
|
-
|
|
16
|
+
optimistic,
|
|
18
17
|
uploadClient,
|
|
19
18
|
uploadHooks,
|
|
20
19
|
onUploadCompleted,
|
|
21
20
|
onUploadFailed,
|
|
22
21
|
children,
|
|
23
22
|
className,
|
|
24
|
-
onDragOver,
|
|
25
|
-
onDragLeave,
|
|
26
23
|
...props
|
|
27
|
-
}: UploadZoneProps):
|
|
24
|
+
}: UploadZoneProps): react_jsx_runtime368.JSX.Element;
|
|
28
25
|
//#endregion
|
|
29
26
|
export { UploadZone, UploadZoneProps };
|
|
30
27
|
//# sourceMappingURL=upload-zone.client.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload-zone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;KAWY,eAAA,GAAkB,wBAC5B,KAAK;aACQ,KAAK;gBACF;EAHN,iBAAA,CAAe,EAAA,CAAA,IAAA,EAKI,IALJ,EAAA,GAKa,OALb,CAAA,IAAA,CAAA,GAAA,IAAA;EAAG,cAAA,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAMW,OANX,CAAA,IAAA,CAAA,GAAA,IAAA;CACvB;AAAL,iBAQc,UAAA,CARd;EAAA,SAAA;EAAA,UAAA;EAAA,YAAA;EAAA,WAAA;EAAA,iBAAA;EAAA,cAAA;EAAA,QAAA;EAAA,SAAA;EAAA,GAAA;AAAA,CAAA,EAkBC,eAlBD,CAAA,EAkBgB,oBAAA,CAAA,GAAA,CAAA,OAlBhB"}
|
|
@@ -1,45 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../../lib/utils/cn.mjs";
|
|
4
|
-
import { Input } from "../../../components/ui/input.mjs";
|
|
5
4
|
import { useAction } from "../../../lib/hooks/use-action.mjs";
|
|
6
5
|
import { toast } from "../../../components/ui/sonner.client.mjs";
|
|
7
6
|
import { UploadZoneContext } from "./upload-zone-context.client.mjs";
|
|
8
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { useCallback
|
|
10
|
-
import {
|
|
8
|
+
import { useCallback } from "react";
|
|
9
|
+
import { useDropzone } from "react-dropzone";
|
|
11
10
|
|
|
12
11
|
//#region src/modules/storage/components/upload-zone.client.tsx
|
|
13
|
-
function UploadZone({ variables,
|
|
14
|
-
const queryClient = useQueryClient();
|
|
15
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
16
|
-
/**
|
|
17
|
-
* Optimisticly update the data
|
|
18
|
-
*/
|
|
19
|
-
const updateData = useCallback(async (newValue) => {
|
|
20
|
-
await queryClient.cancelQueries({ queryKey });
|
|
21
|
-
await queryClient.setQueryData(queryKey, newValue);
|
|
22
|
-
}, [queryClient, queryKey]);
|
|
23
|
-
/**
|
|
24
|
-
* Invalidate the query
|
|
25
|
-
*/
|
|
26
|
-
const invalidateQuery = useCallback(async () => {
|
|
27
|
-
await queryClient.invalidateQueries({ queryKey });
|
|
28
|
-
}, [queryClient, queryKey]);
|
|
12
|
+
function UploadZone({ variables, optimistic, uploadClient, uploadHooks, onUploadCompleted, onUploadFailed, children, className, ...props }) {
|
|
29
13
|
/**
|
|
30
14
|
* Delete mutation
|
|
31
15
|
*/
|
|
32
16
|
const deleteMutation = useAction({
|
|
33
|
-
mutationFn: async (
|
|
34
|
-
onMutate: async (
|
|
35
|
-
await
|
|
36
|
-
|
|
37
|
-
onSuccess: async () => {
|
|
38
|
-
await invalidateQuery();
|
|
17
|
+
mutationFn: async (ids) => uploadClient.deleteFiles(ids),
|
|
18
|
+
onMutate: async (ids) => {
|
|
19
|
+
await optimistic?.cancel?.();
|
|
20
|
+
await optimistic?.remove?.(ids);
|
|
39
21
|
},
|
|
40
22
|
onError: async (error) => {
|
|
41
|
-
await onUploadFailed?.(error);
|
|
42
23
|
console.error("Delete failed upload error: ", error);
|
|
24
|
+
await onUploadFailed?.(error);
|
|
25
|
+
},
|
|
26
|
+
onSettled: () => {
|
|
27
|
+
optimistic?.invalidate?.();
|
|
43
28
|
}
|
|
44
29
|
});
|
|
45
30
|
/**
|
|
@@ -53,7 +38,8 @@ function UploadZone({ variables, queryKey, uploadClient, uploadHooks, onUploadCo
|
|
|
53
38
|
type: "file",
|
|
54
39
|
isPending: true
|
|
55
40
|
};
|
|
56
|
-
await
|
|
41
|
+
await optimistic?.cancel?.();
|
|
42
|
+
await optimistic?.add?.(newNode);
|
|
57
43
|
},
|
|
58
44
|
onSuccess: async (data) => {
|
|
59
45
|
await onUploadCompleted?.(data);
|
|
@@ -64,16 +50,17 @@ function UploadZone({ variables, queryKey, uploadClient, uploadHooks, onUploadCo
|
|
|
64
50
|
console.error("Upload error: ", error);
|
|
65
51
|
toast.error("Bestand uploaden mislukt", { description: error instanceof Error ? error.message : void 0 });
|
|
66
52
|
console.info("Deleting failed upload");
|
|
67
|
-
await deleteMutation.mutateAsync(
|
|
53
|
+
await deleteMutation.mutateAsync([variables$1.id]);
|
|
68
54
|
},
|
|
69
55
|
onSettled: () => {
|
|
70
|
-
|
|
56
|
+
optimistic?.invalidate?.();
|
|
71
57
|
}
|
|
72
58
|
});
|
|
73
59
|
/**
|
|
74
60
|
* Upload file handler
|
|
75
61
|
*/
|
|
76
62
|
const onUpload = useCallback(async (file) => {
|
|
63
|
+
console.info("Uploading file", file);
|
|
77
64
|
const req = uploadClient.prepareUpload({
|
|
78
65
|
...variables,
|
|
79
66
|
file
|
|
@@ -84,38 +71,31 @@ function UploadZone({ variables, queryKey, uploadClient, uploadHooks, onUploadCo
|
|
|
84
71
|
variables,
|
|
85
72
|
uploadMutation
|
|
86
73
|
]);
|
|
74
|
+
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
75
|
+
onDrop: useCallback(async (acceptedFiles) => {
|
|
76
|
+
if (acceptedFiles.length === 0) return;
|
|
77
|
+
await Promise.allSettled(acceptedFiles.map(onUpload));
|
|
78
|
+
}, [onUpload]),
|
|
79
|
+
noClick: true
|
|
80
|
+
});
|
|
81
|
+
console.log("isDragActive", isDragActive);
|
|
87
82
|
return /* @__PURE__ */ jsxs("div", {
|
|
88
83
|
...props,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
type: "file",
|
|
103
|
-
className: "h-full w-full opacity-0",
|
|
104
|
-
onChange: async (e) => {
|
|
105
|
-
setIsDragging(false);
|
|
106
|
-
if (!e.target.files) return;
|
|
107
|
-
await Promise.allSettled(Array.from(e.target.files).map(onUpload));
|
|
108
|
-
}
|
|
84
|
+
...getRootProps(),
|
|
85
|
+
className: cn("relative z-0", className),
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsx("input", { ...getInputProps() }),
|
|
88
|
+
isDragActive && /* @__PURE__ */ jsx("div", { className: "bg-primary/20 border-primary absolute inset-0 z-10 rounded-md border opacity-70 backdrop-blur-3xl" }),
|
|
89
|
+
/* @__PURE__ */ jsx(UploadZoneContext, {
|
|
90
|
+
value: {
|
|
91
|
+
uploadClient,
|
|
92
|
+
onUpload,
|
|
93
|
+
onRemove: deleteMutation.mutateAsync,
|
|
94
|
+
optimistic
|
|
95
|
+
},
|
|
96
|
+
children
|
|
109
97
|
})
|
|
110
|
-
|
|
111
|
-
value: {
|
|
112
|
-
uploadClient,
|
|
113
|
-
onUpload,
|
|
114
|
-
updateData,
|
|
115
|
-
invalidateQuery
|
|
116
|
-
},
|
|
117
|
-
children
|
|
118
|
-
})]
|
|
98
|
+
]
|
|
119
99
|
});
|
|
120
100
|
}
|
|
121
101
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone.client.mjs","names":["variables"],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"sourcesContent":["\"use client\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"upload-zone.client.mjs","names":["variables"],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { toast } from \"@/components/ui/sonner.client\";\nimport { useAction } from \"@/lib/hooks/use-action\";\nimport { cn } from \"@/lib/utils/cn\";\nimport { ComponentProps, useCallback } from \"react\";\nimport { useDropzone } from \"react-dropzone\";\nimport { UploadFileRequest, UploadHooks } from \"../lib/create-upload.client\";\nimport { FileNode, Node, UploadFileSchema } from \"../lib/validators\";\nimport { UploadZoneContext, UploadZoneContextValue } from \"./upload-zone-context.client\";\n\nexport type UploadZoneProps = ComponentProps<\"div\"> &\n Pick<UploadZoneContextValue, \"optimistic\" | \"uploadClient\"> & {\n variables: Pick<UploadFileSchema, \"namespace\" | \"parentId\" | \"mode\" | \"hidden\" | \"readonly\">;\n uploadHooks?: UploadHooks;\n\n onUploadCompleted?: (node: Node) => Promise<void> | void;\n onUploadFailed?: (error: unknown) => Promise<void> | void;\n };\n\nexport function UploadZone({\n variables,\n optimistic,\n uploadClient,\n uploadHooks,\n onUploadCompleted,\n onUploadFailed,\n children,\n className,\n ...props\n}: UploadZoneProps) {\n /**\n * Delete mutation\n */\n const deleteMutation = useAction({\n mutationFn: async (ids: string[]) => uploadClient.deleteFiles(ids),\n onMutate: async (ids) => {\n await optimistic?.cancel?.();\n await optimistic?.remove?.(ids);\n },\n onError: async (error) => {\n console.error(\"Delete failed upload error: \", error);\n await onUploadFailed?.(error);\n },\n onSettled: () => {\n optimistic?.invalidate?.();\n },\n });\n\n /**\n * Upload mutation\n */\n const uploadMutation = useAction({\n mutationFn: async (params: UploadFileRequest) => uploadClient.upload(params, uploadHooks),\n onMutate: async (variables) => {\n // Generate a new node\n const newNode = {\n ...variables,\n type: \"file\",\n isPending: true,\n } as FileNode;\n\n await optimistic?.cancel?.();\n await optimistic?.add?.(newNode);\n },\n onSuccess: async (data) => {\n await onUploadCompleted?.(data);\n toast.success(`Succesvol geupload: ${data.name}`);\n },\n onError: async (error, variables) => {\n await onUploadFailed?.(error);\n\n console.error(\"Upload error: \", error);\n toast.error(\"Bestand uploaden mislukt\", {\n description: error instanceof Error ? error.message : undefined,\n });\n\n console.info(\"Deleting failed upload\");\n await deleteMutation.mutateAsync([variables.id]);\n },\n onSettled: () => {\n optimistic?.invalidate?.();\n },\n });\n\n /**\n * Upload file handler\n */\n const onUpload = useCallback(\n async (file: File) => {\n console.info(\"Uploading file\", file);\n const req = uploadClient.prepareUpload({ ...variables, file });\n return await uploadMutation.mutateAsync(req);\n },\n [uploadClient, variables, uploadMutation],\n );\n\n /**\n * Drop handler\n */\n const onDrop = useCallback(\n async (acceptedFiles: File[]) => {\n if (acceptedFiles.length === 0) return;\n await Promise.allSettled(acceptedFiles.map(onUpload));\n },\n [onUpload],\n );\n\n const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, noClick: true });\n\n console.log(\"isDragActive\", isDragActive);\n\n return (\n <div {...props} {...getRootProps()} className={cn(\"relative z-0\", className)}>\n <input {...getInputProps()} />\n\n {/* Show drag overlay when drag is active */}\n {isDragActive && (\n <div className=\"bg-primary/20 border-primary absolute inset-0 z-10 rounded-md border opacity-70 backdrop-blur-3xl\" />\n )}\n\n <UploadZoneContext\n value={{\n uploadClient,\n onUpload,\n onRemove: deleteMutation.mutateAsync,\n optimistic,\n }}\n >\n {children}\n </UploadZoneContext>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAoBA,SAAgB,WAAW,EACzB,WACA,YACA,cACA,aACA,mBACA,gBACA,UACA,WACA,GAAG,SACe;;;;CAIlB,MAAM,iBAAiB,UAAU;EAC/B,YAAY,OAAO,QAAkB,aAAa,YAAY,IAAI;EAClE,UAAU,OAAO,QAAQ;AACvB,SAAM,YAAY,UAAU;AAC5B,SAAM,YAAY,SAAS,IAAI;;EAEjC,SAAS,OAAO,UAAU;AACxB,WAAQ,MAAM,gCAAgC,MAAM;AACpD,SAAM,iBAAiB,MAAM;;EAE/B,iBAAiB;AACf,eAAY,cAAc;;EAE7B,CAAC;;;;CAKF,MAAM,iBAAiB,UAAU;EAC/B,YAAY,OAAO,WAA8B,aAAa,OAAO,QAAQ,YAAY;EACzF,UAAU,OAAO,gBAAc;GAE7B,MAAM,UAAU;IACd,GAAGA;IACH,MAAM;IACN,WAAW;IACZ;AAED,SAAM,YAAY,UAAU;AAC5B,SAAM,YAAY,MAAM,QAAQ;;EAElC,WAAW,OAAO,SAAS;AACzB,SAAM,oBAAoB,KAAK;AAC/B,SAAM,QAAQ,uBAAuB,KAAK,OAAO;;EAEnD,SAAS,OAAO,OAAO,gBAAc;AACnC,SAAM,iBAAiB,MAAM;AAE7B,WAAQ,MAAM,kBAAkB,MAAM;AACtC,SAAM,MAAM,4BAA4B,EACtC,aAAa,iBAAiB,QAAQ,MAAM,UAAU,QACvD,CAAC;AAEF,WAAQ,KAAK,yBAAyB;AACtC,SAAM,eAAe,YAAY,CAACA,YAAU,GAAG,CAAC;;EAElD,iBAAiB;AACf,eAAY,cAAc;;EAE7B,CAAC;;;;CAKF,MAAM,WAAW,YACf,OAAO,SAAe;AACpB,UAAQ,KAAK,kBAAkB,KAAK;EACpC,MAAM,MAAM,aAAa,cAAc;GAAE,GAAG;GAAW;GAAM,CAAC;AAC9D,SAAO,MAAM,eAAe,YAAY,IAAI;IAE9C;EAAC;EAAc;EAAW;EAAe,CAC1C;CAaD,MAAM,EAAE,cAAc,eAAe,iBAAiB,YAAY;EAAE,QARrD,YACb,OAAO,kBAA0B;AAC/B,OAAI,cAAc,WAAW,EAAG;AAChC,SAAM,QAAQ,WAAW,cAAc,IAAI,SAAS,CAAC;KAEvD,CAAC,SAAS,CACX;EAE2E,SAAS;EAAM,CAAC;AAE5F,SAAQ,IAAI,gBAAgB,aAAa;AAEzC,QACE,qBAAC;EAAI,GAAI;EAAO,GAAI,cAAc;EAAE,WAAW,GAAG,gBAAgB,UAAU;;GAC1E,oBAAC,WAAM,GAAI,eAAe,GAAI;GAG7B,gBACC,oBAAC,SAAI,WAAU,sGAAsG;GAGvH,oBAAC;IACC,OAAO;KACL;KACA;KACA,UAAU,eAAe;KACzB;KACD;IAEA;KACiB;;GAChB"}
|
|
@@ -6151,12 +6151,12 @@ declare function createDriveBaseProcedures(): {
|
|
|
6151
6151
|
node: drizzle_orm0.One<"nodes", true>;
|
|
6152
6152
|
}>;
|
|
6153
6153
|
}>>, z$1.ZodObject<{
|
|
6154
|
-
sort: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
6155
6154
|
search: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
6156
6155
|
order: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
|
|
6157
6156
|
asc: "asc";
|
|
6158
6157
|
desc: "desc";
|
|
6159
6158
|
}>>>;
|
|
6159
|
+
sort: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
6160
6160
|
filters: z$1.ZodPipe<z$1.ZodObject<{
|
|
6161
6161
|
types: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodArray<z$1.ZodEnum<{
|
|
6162
6162
|
file: "file";
|
|
@@ -15214,16 +15214,13 @@ declare function createDriveBaseProcedures(): {
|
|
|
15214
15214
|
node: drizzle_orm0.One<"nodes", true>;
|
|
15215
15215
|
}>;
|
|
15216
15216
|
}>>, z$1.ZodObject<{
|
|
15217
|
-
readonly: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodBoolean>>;
|
|
15218
|
-
size: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodInt>>;
|
|
15219
|
-
isPending: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
15220
|
-
createdAt: z$1.ZodOptional<z$1.ZodDate>;
|
|
15221
|
-
updatedAt: z$1.ZodOptional<z$1.ZodDate>;
|
|
15222
15217
|
name: z$1.ZodString;
|
|
15223
15218
|
mode: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
|
|
15224
15219
|
private: "private";
|
|
15225
15220
|
public: "public";
|
|
15226
15221
|
}>>>;
|
|
15222
|
+
size: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodInt>>;
|
|
15223
|
+
hidden: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodBoolean>>;
|
|
15227
15224
|
namespace: z$1.ZodString;
|
|
15228
15225
|
subtype: z$1.ZodOptional<z$1.ZodEnum<{
|
|
15229
15226
|
image: "image";
|
|
@@ -15235,8 +15232,11 @@ declare function createDriveBaseProcedures(): {
|
|
|
15235
15232
|
other: "other";
|
|
15236
15233
|
}>>;
|
|
15237
15234
|
contentType: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
15238
|
-
|
|
15235
|
+
readonly: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodBoolean>>;
|
|
15236
|
+
createdAt: z$1.ZodOptional<z$1.ZodDate>;
|
|
15237
|
+
updatedAt: z$1.ZodOptional<z$1.ZodDate>;
|
|
15239
15238
|
createdBy: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUUID>>;
|
|
15239
|
+
isPending: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
15240
15240
|
isDeleted: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
15241
15241
|
orphanedAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
15242
15242
|
parentId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUUID>>;
|
|
@@ -21351,18 +21351,18 @@ declare function createDriveBaseProcedures(): {
|
|
|
21351
21351
|
}>;
|
|
21352
21352
|
}>>, z$1.ZodObject<{
|
|
21353
21353
|
id: z$1.ZodOptional<z$1.ZodUUID>;
|
|
21354
|
-
readonly: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodBoolean>>;
|
|
21355
|
-
isPending: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
21356
|
-
createdAt: z$1.ZodOptional<z$1.ZodDate>;
|
|
21357
|
-
updatedAt: z$1.ZodOptional<z$1.ZodDate>;
|
|
21358
21354
|
name: z$1.ZodString;
|
|
21359
21355
|
mode: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodEnum<{
|
|
21360
21356
|
private: "private";
|
|
21361
21357
|
public: "public";
|
|
21362
21358
|
}>>>;
|
|
21363
|
-
namespace: z$1.ZodString;
|
|
21364
21359
|
hidden: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodBoolean>>;
|
|
21360
|
+
namespace: z$1.ZodString;
|
|
21361
|
+
readonly: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodBoolean>>;
|
|
21362
|
+
createdAt: z$1.ZodOptional<z$1.ZodDate>;
|
|
21363
|
+
updatedAt: z$1.ZodOptional<z$1.ZodDate>;
|
|
21365
21364
|
createdBy: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUUID>>;
|
|
21365
|
+
isPending: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
21366
21366
|
isDeleted: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
21367
21367
|
orphanedAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
21368
21368
|
parentId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUUID>>;
|