@sparkstudio/storage-ui 1.0.12 → 1.0.13
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/index.cjs +404 -172
- package/dist/index.d.cts +75 -16
- package/dist/index.d.ts +75 -16
- package/dist/index.js +402 -172
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -92,34 +92,93 @@ declare class SparkStudioStorageSDK {
|
|
|
92
92
|
constructor(baseUrl: string);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
interface ContainerUploadPanelProps {
|
|
96
|
+
/** Base URL for the Container API (the SDK you pasted). */
|
|
97
|
+
containerApiBaseUrl: string;
|
|
98
|
+
/** Base URL for your storage / presign endpoint (used by getPresignedUrl). */
|
|
99
|
+
storageApiBaseUrl: string;
|
|
100
|
+
/** Optional parent container – if set, we query children instead of roots. */
|
|
101
|
+
parentContainerId?: string;
|
|
102
|
+
title?: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
}
|
|
105
|
+
declare const ContainerUploadPanel: React.FC<ContainerUploadPanelProps>;
|
|
106
|
+
|
|
95
107
|
interface UploadContainerProps {
|
|
96
108
|
title?: string;
|
|
97
109
|
description?: string;
|
|
98
110
|
multiple?: boolean;
|
|
99
111
|
accept?: string;
|
|
100
112
|
onFilesSelected?: (files: FileList) => void;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* using getPresignedUrl for each file.
|
|
104
|
-
*/
|
|
113
|
+
existingFiles?: ContainerDTO[];
|
|
114
|
+
onExistingFileClick?: (file: ContainerDTO) => void;
|
|
105
115
|
autoUpload?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Your function that returns a pre-signed URL for a given file.
|
|
108
|
-
* Typically calls your backend: /api/uploads/presign
|
|
109
|
-
*/
|
|
110
116
|
getPresignedUrl?: (file: File) => Promise<AWSPresignedUrlDTO>;
|
|
111
|
-
/**
|
|
112
|
-
* Called when a file has successfully finished uploading.
|
|
113
|
-
* s3Url is usually the final S3 object URL or key (depends on your backend).
|
|
114
|
-
*/
|
|
115
117
|
onUploadComplete?: (file: File, s3Url: string) => void;
|
|
116
|
-
/**
|
|
117
|
-
* Called when a file upload fails.
|
|
118
|
-
*/
|
|
119
118
|
onUploadError?: (file: File, error: Error) => void;
|
|
120
119
|
}
|
|
121
120
|
declare const UploadContainer: React.FC<UploadContainerProps>;
|
|
122
121
|
|
|
122
|
+
interface UploadDropzoneProps {
|
|
123
|
+
isDragging: boolean;
|
|
124
|
+
onDragOver: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
125
|
+
onDragLeave: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
126
|
+
onDrop: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
127
|
+
}
|
|
128
|
+
declare const UploadDropzone: React.FC<UploadDropzoneProps>;
|
|
129
|
+
|
|
130
|
+
interface UploadFilePickerProps {
|
|
131
|
+
multiple: boolean;
|
|
132
|
+
accept?: string;
|
|
133
|
+
fileNames: string[];
|
|
134
|
+
onFileChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
135
|
+
}
|
|
136
|
+
declare const UploadFilePicker: React.FC<UploadFilePickerProps>;
|
|
137
|
+
|
|
138
|
+
type UploadStatus = "pending" | "uploading" | "success" | "error";
|
|
139
|
+
interface UploadState {
|
|
140
|
+
id: string;
|
|
141
|
+
file: File;
|
|
142
|
+
progress: number;
|
|
143
|
+
status: UploadStatus;
|
|
144
|
+
error?: string;
|
|
145
|
+
s3Url?: string;
|
|
146
|
+
publicUrl?: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface UploadProgressListProps {
|
|
150
|
+
uploads: UploadState[];
|
|
151
|
+
}
|
|
152
|
+
declare const UploadProgressList: React.FC<UploadProgressListProps>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Helper: upload a file to a pre-signed S3 URL with progress events.
|
|
156
|
+
*/
|
|
157
|
+
declare function UploadFileToS3(file: File, presignedUrl: string, onProgress: (progress: number) => void): Promise<void>;
|
|
158
|
+
|
|
159
|
+
interface UseContainersOptions {
|
|
160
|
+
apiBaseUrl: string;
|
|
161
|
+
parentId?: string;
|
|
162
|
+
}
|
|
163
|
+
declare function UseContainers({ apiBaseUrl, parentId }: UseContainersOptions): {
|
|
164
|
+
containers: ContainerDTO[];
|
|
165
|
+
loading: boolean;
|
|
166
|
+
error: Error | null;
|
|
167
|
+
reload: () => Promise<void>;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
interface UseUploadManagerOptions {
|
|
171
|
+
autoUpload?: boolean;
|
|
172
|
+
getPresignedUrl?: (file: File) => Promise<AWSPresignedUrlDTO>;
|
|
173
|
+
onUploadComplete?: (file: File, s3Url: string) => void;
|
|
174
|
+
onUploadError?: (file: File, error: Error) => void;
|
|
175
|
+
}
|
|
176
|
+
declare function UseUploadManager({ autoUpload, getPresignedUrl, onUploadComplete, onUploadError, }: UseUploadManagerOptions): {
|
|
177
|
+
uploads: UploadState[];
|
|
178
|
+
startUploadsIfNeeded: (files: FileList) => void;
|
|
179
|
+
resetUploads: () => void;
|
|
180
|
+
};
|
|
181
|
+
|
|
123
182
|
declare function HomeView(): react_jsx_runtime.JSX.Element;
|
|
124
183
|
|
|
125
|
-
export { AWSPresignedUrlDTO, Container, ContainerDTO, ContainerType, Home, HomeView, type IAWSPresignedUrlDTO, type IContainerDTO, S3, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps };
|
|
184
|
+
export { AWSPresignedUrlDTO, Container, ContainerDTO, ContainerType, ContainerUploadPanel, Home, HomeView, type IAWSPresignedUrlDTO, type IContainerDTO, S3, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps, UploadDropzone, UploadFilePicker, UploadFileToS3, UploadProgressList, type UploadState, type UploadStatus, UseContainers, UseUploadManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -92,34 +92,93 @@ declare class SparkStudioStorageSDK {
|
|
|
92
92
|
constructor(baseUrl: string);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
interface ContainerUploadPanelProps {
|
|
96
|
+
/** Base URL for the Container API (the SDK you pasted). */
|
|
97
|
+
containerApiBaseUrl: string;
|
|
98
|
+
/** Base URL for your storage / presign endpoint (used by getPresignedUrl). */
|
|
99
|
+
storageApiBaseUrl: string;
|
|
100
|
+
/** Optional parent container – if set, we query children instead of roots. */
|
|
101
|
+
parentContainerId?: string;
|
|
102
|
+
title?: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
}
|
|
105
|
+
declare const ContainerUploadPanel: React.FC<ContainerUploadPanelProps>;
|
|
106
|
+
|
|
95
107
|
interface UploadContainerProps {
|
|
96
108
|
title?: string;
|
|
97
109
|
description?: string;
|
|
98
110
|
multiple?: boolean;
|
|
99
111
|
accept?: string;
|
|
100
112
|
onFilesSelected?: (files: FileList) => void;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* using getPresignedUrl for each file.
|
|
104
|
-
*/
|
|
113
|
+
existingFiles?: ContainerDTO[];
|
|
114
|
+
onExistingFileClick?: (file: ContainerDTO) => void;
|
|
105
115
|
autoUpload?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Your function that returns a pre-signed URL for a given file.
|
|
108
|
-
* Typically calls your backend: /api/uploads/presign
|
|
109
|
-
*/
|
|
110
116
|
getPresignedUrl?: (file: File) => Promise<AWSPresignedUrlDTO>;
|
|
111
|
-
/**
|
|
112
|
-
* Called when a file has successfully finished uploading.
|
|
113
|
-
* s3Url is usually the final S3 object URL or key (depends on your backend).
|
|
114
|
-
*/
|
|
115
117
|
onUploadComplete?: (file: File, s3Url: string) => void;
|
|
116
|
-
/**
|
|
117
|
-
* Called when a file upload fails.
|
|
118
|
-
*/
|
|
119
118
|
onUploadError?: (file: File, error: Error) => void;
|
|
120
119
|
}
|
|
121
120
|
declare const UploadContainer: React.FC<UploadContainerProps>;
|
|
122
121
|
|
|
122
|
+
interface UploadDropzoneProps {
|
|
123
|
+
isDragging: boolean;
|
|
124
|
+
onDragOver: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
125
|
+
onDragLeave: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
126
|
+
onDrop: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
127
|
+
}
|
|
128
|
+
declare const UploadDropzone: React.FC<UploadDropzoneProps>;
|
|
129
|
+
|
|
130
|
+
interface UploadFilePickerProps {
|
|
131
|
+
multiple: boolean;
|
|
132
|
+
accept?: string;
|
|
133
|
+
fileNames: string[];
|
|
134
|
+
onFileChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
135
|
+
}
|
|
136
|
+
declare const UploadFilePicker: React.FC<UploadFilePickerProps>;
|
|
137
|
+
|
|
138
|
+
type UploadStatus = "pending" | "uploading" | "success" | "error";
|
|
139
|
+
interface UploadState {
|
|
140
|
+
id: string;
|
|
141
|
+
file: File;
|
|
142
|
+
progress: number;
|
|
143
|
+
status: UploadStatus;
|
|
144
|
+
error?: string;
|
|
145
|
+
s3Url?: string;
|
|
146
|
+
publicUrl?: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface UploadProgressListProps {
|
|
150
|
+
uploads: UploadState[];
|
|
151
|
+
}
|
|
152
|
+
declare const UploadProgressList: React.FC<UploadProgressListProps>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Helper: upload a file to a pre-signed S3 URL with progress events.
|
|
156
|
+
*/
|
|
157
|
+
declare function UploadFileToS3(file: File, presignedUrl: string, onProgress: (progress: number) => void): Promise<void>;
|
|
158
|
+
|
|
159
|
+
interface UseContainersOptions {
|
|
160
|
+
apiBaseUrl: string;
|
|
161
|
+
parentId?: string;
|
|
162
|
+
}
|
|
163
|
+
declare function UseContainers({ apiBaseUrl, parentId }: UseContainersOptions): {
|
|
164
|
+
containers: ContainerDTO[];
|
|
165
|
+
loading: boolean;
|
|
166
|
+
error: Error | null;
|
|
167
|
+
reload: () => Promise<void>;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
interface UseUploadManagerOptions {
|
|
171
|
+
autoUpload?: boolean;
|
|
172
|
+
getPresignedUrl?: (file: File) => Promise<AWSPresignedUrlDTO>;
|
|
173
|
+
onUploadComplete?: (file: File, s3Url: string) => void;
|
|
174
|
+
onUploadError?: (file: File, error: Error) => void;
|
|
175
|
+
}
|
|
176
|
+
declare function UseUploadManager({ autoUpload, getPresignedUrl, onUploadComplete, onUploadError, }: UseUploadManagerOptions): {
|
|
177
|
+
uploads: UploadState[];
|
|
178
|
+
startUploadsIfNeeded: (files: FileList) => void;
|
|
179
|
+
resetUploads: () => void;
|
|
180
|
+
};
|
|
181
|
+
|
|
123
182
|
declare function HomeView(): react_jsx_runtime.JSX.Element;
|
|
124
183
|
|
|
125
|
-
export { AWSPresignedUrlDTO, Container, ContainerDTO, ContainerType, Home, HomeView, type IAWSPresignedUrlDTO, type IContainerDTO, S3, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps };
|
|
184
|
+
export { AWSPresignedUrlDTO, Container, ContainerDTO, ContainerType, ContainerUploadPanel, Home, HomeView, type IAWSPresignedUrlDTO, type IContainerDTO, S3, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps, UploadDropzone, UploadFilePicker, UploadFileToS3, UploadProgressList, type UploadState, type UploadStatus, UseContainers, UseUploadManager };
|