@plugable-io/react 0.0.1 → 0.0.2
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.d.mts +123 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.js +684 -0
- package/dist/index.mjs +640 -0
- package/package.json +8 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { BucketClient, FileObject } from '@plugable-io/js';
|
|
4
|
+
export { FileObject, SearchOptions, UpdateOptions } from '@plugable-io/js';
|
|
5
|
+
|
|
6
|
+
type AuthProvider = 'clerk' | 'supabase' | 'firebase';
|
|
7
|
+
interface PlugableProviderProps {
|
|
8
|
+
bucketId: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
getToken?: () => Promise<string> | string;
|
|
11
|
+
authProvider?: AuthProvider;
|
|
12
|
+
clerkJWTTemplate?: string;
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
type PlugableEventType = 'file.uploaded' | 'file.deleted';
|
|
16
|
+
type EventHandler = (data?: any) => void;
|
|
17
|
+
interface PlugableContextValue {
|
|
18
|
+
client: BucketClient;
|
|
19
|
+
bucketId: string;
|
|
20
|
+
on: (event: PlugableEventType, handler: EventHandler) => () => void;
|
|
21
|
+
emit: (event: PlugableEventType, data?: any) => void;
|
|
22
|
+
getToken: () => Promise<string> | string;
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
declare function PlugableProvider({ bucketId, children, getToken, authProvider, clerkJWTTemplate, baseUrl, }: PlugableProviderProps): react_jsx_runtime.JSX.Element;
|
|
26
|
+
declare function usePlugable(): PlugableContextValue;
|
|
27
|
+
|
|
28
|
+
interface DropzoneProps {
|
|
29
|
+
bucketId?: string;
|
|
30
|
+
metadata?: Record<string, any>;
|
|
31
|
+
onUploadComplete?: (files: FileObject[]) => void;
|
|
32
|
+
onUploadError?: (error: Error) => void;
|
|
33
|
+
onProgressUpdate?: (fileName: string, progress: number) => void;
|
|
34
|
+
accept?: string;
|
|
35
|
+
maxFiles?: number;
|
|
36
|
+
children?: (props: DropzoneRenderProps) => ReactNode;
|
|
37
|
+
className?: string;
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
}
|
|
40
|
+
interface DropzoneRenderProps {
|
|
41
|
+
isDragActive: boolean;
|
|
42
|
+
isUploading: boolean;
|
|
43
|
+
uploadProgress: Record<string, number>;
|
|
44
|
+
openFileDialog: () => void;
|
|
45
|
+
uploadedFiles: FileObject[];
|
|
46
|
+
}
|
|
47
|
+
declare function Dropzone({ bucketId: _bucketId, metadata, onUploadComplete, onUploadError, onProgressUpdate, accept, maxFiles, children, className, style, }: DropzoneProps): react_jsx_runtime.JSX.Element;
|
|
48
|
+
|
|
49
|
+
interface FileListProps {
|
|
50
|
+
metadata?: Record<string, any>;
|
|
51
|
+
mediaType?: string;
|
|
52
|
+
perPage?: number;
|
|
53
|
+
autoLoad?: boolean;
|
|
54
|
+
startPage?: number;
|
|
55
|
+
children: (props: FileListRenderProps) => ReactNode;
|
|
56
|
+
}
|
|
57
|
+
interface FileListRenderProps {
|
|
58
|
+
files: FileObject[];
|
|
59
|
+
isLoading: boolean;
|
|
60
|
+
hasMore: boolean;
|
|
61
|
+
loadMore: () => void;
|
|
62
|
+
refresh: () => Promise<void>;
|
|
63
|
+
error: Error | null;
|
|
64
|
+
pagination: {
|
|
65
|
+
current: number;
|
|
66
|
+
hasNext: boolean;
|
|
67
|
+
hasPrevious: boolean;
|
|
68
|
+
loadNextPage: () => void;
|
|
69
|
+
loadPreviousPage: () => void;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
declare function FileList({ metadata, mediaType, perPage, autoLoad, startPage, children, }: FileListProps): react_jsx_runtime.JSX.Element;
|
|
73
|
+
|
|
74
|
+
interface FileImageProps {
|
|
75
|
+
file: FileObject;
|
|
76
|
+
width?: number | string;
|
|
77
|
+
height?: number | string;
|
|
78
|
+
objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
79
|
+
borderRadius?: number | string;
|
|
80
|
+
alt?: string;
|
|
81
|
+
className?: string;
|
|
82
|
+
style?: CSSProperties;
|
|
83
|
+
onLoad?: () => void;
|
|
84
|
+
onError?: (error: Error) => void;
|
|
85
|
+
}
|
|
86
|
+
declare function FileImage({ file, width, height, objectFit, borderRadius, alt, className, style, onLoad, onError, }: FileImageProps): react_jsx_runtime.JSX.Element;
|
|
87
|
+
declare function clearImageCache(): void;
|
|
88
|
+
|
|
89
|
+
interface FilePreviewProps {
|
|
90
|
+
file: FileObject;
|
|
91
|
+
width?: number | string;
|
|
92
|
+
height?: number | string;
|
|
93
|
+
className?: string;
|
|
94
|
+
style?: CSSProperties;
|
|
95
|
+
objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
96
|
+
showExtension?: boolean;
|
|
97
|
+
renderNonImage?: (file: FileObject) => React.ReactNode;
|
|
98
|
+
}
|
|
99
|
+
declare function FilePreview({ file, width, height, className, style, objectFit, showExtension, renderNonImage, }: FilePreviewProps): react_jsx_runtime.JSX.Element;
|
|
100
|
+
|
|
101
|
+
interface UseFilesOptions {
|
|
102
|
+
metadata?: Record<string, any>;
|
|
103
|
+
startPage?: number;
|
|
104
|
+
perPage?: number;
|
|
105
|
+
mediaType?: string;
|
|
106
|
+
autoLoad?: boolean;
|
|
107
|
+
}
|
|
108
|
+
interface UseFilesResult {
|
|
109
|
+
files: FileObject[];
|
|
110
|
+
isLoading: boolean;
|
|
111
|
+
pagination: {
|
|
112
|
+
current: number;
|
|
113
|
+
hasNext: boolean;
|
|
114
|
+
hasPrevious: boolean;
|
|
115
|
+
loadNextPage: () => void;
|
|
116
|
+
loadPreviousPage: () => void;
|
|
117
|
+
};
|
|
118
|
+
setPage: (page: number) => void;
|
|
119
|
+
refresh: () => Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
declare function useFiles({ metadata, startPage, perPage, mediaType, autoLoad, }?: UseFilesOptions): UseFilesResult;
|
|
122
|
+
|
|
123
|
+
export { type AuthProvider, Dropzone, type DropzoneProps, type DropzoneRenderProps, FileImage, type FileImageProps, FileList, type FileListProps, type FileListRenderProps, FilePreview, type FilePreviewProps, PlugableProvider, type PlugableProviderProps, type UseFilesOptions, type UseFilesResult, clearImageCache, useFiles, usePlugable };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { BucketClient, FileObject } from '@plugable-io/js';
|
|
4
|
+
export { FileObject, SearchOptions, UpdateOptions } from '@plugable-io/js';
|
|
5
|
+
|
|
6
|
+
type AuthProvider = 'clerk' | 'supabase' | 'firebase';
|
|
7
|
+
interface PlugableProviderProps {
|
|
8
|
+
bucketId: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
getToken?: () => Promise<string> | string;
|
|
11
|
+
authProvider?: AuthProvider;
|
|
12
|
+
clerkJWTTemplate?: string;
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
type PlugableEventType = 'file.uploaded' | 'file.deleted';
|
|
16
|
+
type EventHandler = (data?: any) => void;
|
|
17
|
+
interface PlugableContextValue {
|
|
18
|
+
client: BucketClient;
|
|
19
|
+
bucketId: string;
|
|
20
|
+
on: (event: PlugableEventType, handler: EventHandler) => () => void;
|
|
21
|
+
emit: (event: PlugableEventType, data?: any) => void;
|
|
22
|
+
getToken: () => Promise<string> | string;
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
declare function PlugableProvider({ bucketId, children, getToken, authProvider, clerkJWTTemplate, baseUrl, }: PlugableProviderProps): react_jsx_runtime.JSX.Element;
|
|
26
|
+
declare function usePlugable(): PlugableContextValue;
|
|
27
|
+
|
|
28
|
+
interface DropzoneProps {
|
|
29
|
+
bucketId?: string;
|
|
30
|
+
metadata?: Record<string, any>;
|
|
31
|
+
onUploadComplete?: (files: FileObject[]) => void;
|
|
32
|
+
onUploadError?: (error: Error) => void;
|
|
33
|
+
onProgressUpdate?: (fileName: string, progress: number) => void;
|
|
34
|
+
accept?: string;
|
|
35
|
+
maxFiles?: number;
|
|
36
|
+
children?: (props: DropzoneRenderProps) => ReactNode;
|
|
37
|
+
className?: string;
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
}
|
|
40
|
+
interface DropzoneRenderProps {
|
|
41
|
+
isDragActive: boolean;
|
|
42
|
+
isUploading: boolean;
|
|
43
|
+
uploadProgress: Record<string, number>;
|
|
44
|
+
openFileDialog: () => void;
|
|
45
|
+
uploadedFiles: FileObject[];
|
|
46
|
+
}
|
|
47
|
+
declare function Dropzone({ bucketId: _bucketId, metadata, onUploadComplete, onUploadError, onProgressUpdate, accept, maxFiles, children, className, style, }: DropzoneProps): react_jsx_runtime.JSX.Element;
|
|
48
|
+
|
|
49
|
+
interface FileListProps {
|
|
50
|
+
metadata?: Record<string, any>;
|
|
51
|
+
mediaType?: string;
|
|
52
|
+
perPage?: number;
|
|
53
|
+
autoLoad?: boolean;
|
|
54
|
+
startPage?: number;
|
|
55
|
+
children: (props: FileListRenderProps) => ReactNode;
|
|
56
|
+
}
|
|
57
|
+
interface FileListRenderProps {
|
|
58
|
+
files: FileObject[];
|
|
59
|
+
isLoading: boolean;
|
|
60
|
+
hasMore: boolean;
|
|
61
|
+
loadMore: () => void;
|
|
62
|
+
refresh: () => Promise<void>;
|
|
63
|
+
error: Error | null;
|
|
64
|
+
pagination: {
|
|
65
|
+
current: number;
|
|
66
|
+
hasNext: boolean;
|
|
67
|
+
hasPrevious: boolean;
|
|
68
|
+
loadNextPage: () => void;
|
|
69
|
+
loadPreviousPage: () => void;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
declare function FileList({ metadata, mediaType, perPage, autoLoad, startPage, children, }: FileListProps): react_jsx_runtime.JSX.Element;
|
|
73
|
+
|
|
74
|
+
interface FileImageProps {
|
|
75
|
+
file: FileObject;
|
|
76
|
+
width?: number | string;
|
|
77
|
+
height?: number | string;
|
|
78
|
+
objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
79
|
+
borderRadius?: number | string;
|
|
80
|
+
alt?: string;
|
|
81
|
+
className?: string;
|
|
82
|
+
style?: CSSProperties;
|
|
83
|
+
onLoad?: () => void;
|
|
84
|
+
onError?: (error: Error) => void;
|
|
85
|
+
}
|
|
86
|
+
declare function FileImage({ file, width, height, objectFit, borderRadius, alt, className, style, onLoad, onError, }: FileImageProps): react_jsx_runtime.JSX.Element;
|
|
87
|
+
declare function clearImageCache(): void;
|
|
88
|
+
|
|
89
|
+
interface FilePreviewProps {
|
|
90
|
+
file: FileObject;
|
|
91
|
+
width?: number | string;
|
|
92
|
+
height?: number | string;
|
|
93
|
+
className?: string;
|
|
94
|
+
style?: CSSProperties;
|
|
95
|
+
objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
96
|
+
showExtension?: boolean;
|
|
97
|
+
renderNonImage?: (file: FileObject) => React.ReactNode;
|
|
98
|
+
}
|
|
99
|
+
declare function FilePreview({ file, width, height, className, style, objectFit, showExtension, renderNonImage, }: FilePreviewProps): react_jsx_runtime.JSX.Element;
|
|
100
|
+
|
|
101
|
+
interface UseFilesOptions {
|
|
102
|
+
metadata?: Record<string, any>;
|
|
103
|
+
startPage?: number;
|
|
104
|
+
perPage?: number;
|
|
105
|
+
mediaType?: string;
|
|
106
|
+
autoLoad?: boolean;
|
|
107
|
+
}
|
|
108
|
+
interface UseFilesResult {
|
|
109
|
+
files: FileObject[];
|
|
110
|
+
isLoading: boolean;
|
|
111
|
+
pagination: {
|
|
112
|
+
current: number;
|
|
113
|
+
hasNext: boolean;
|
|
114
|
+
hasPrevious: boolean;
|
|
115
|
+
loadNextPage: () => void;
|
|
116
|
+
loadPreviousPage: () => void;
|
|
117
|
+
};
|
|
118
|
+
setPage: (page: number) => void;
|
|
119
|
+
refresh: () => Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
declare function useFiles({ metadata, startPage, perPage, mediaType, autoLoad, }?: UseFilesOptions): UseFilesResult;
|
|
122
|
+
|
|
123
|
+
export { type AuthProvider, Dropzone, type DropzoneProps, type DropzoneRenderProps, FileImage, type FileImageProps, FileList, type FileListProps, type FileListRenderProps, FilePreview, type FilePreviewProps, PlugableProvider, type PlugableProviderProps, type UseFilesOptions, type UseFilesResult, clearImageCache, useFiles, usePlugable };
|