@blocklet/pages-kit 0.6.52 → 0.6.55
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.
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useUploaderContext } from '@blocklet/uploader/react';
|
|
3
3
|
import UploadIcon from '@mui/icons-material/Upload';
|
|
4
|
-
import { IconButton } from '@mui/material';
|
|
4
|
+
import { IconButton, Skeleton } from '@mui/material';
|
|
5
|
+
import { lazy, Suspense } from 'react';
|
|
6
|
+
const UploaderProviderLib = lazy(() =>
|
|
7
|
+
// eslint-disable-next-line import/no-unresolved
|
|
8
|
+
import('@blocklet/uploader').then((res) => ({ default: res.UploaderProvider })));
|
|
5
9
|
export const useUploader = useUploaderContext;
|
|
6
10
|
export function UploaderButton({ onChange }) {
|
|
7
11
|
const uploaderRef = useUploader();
|
|
@@ -19,25 +23,25 @@ export function UploaderButton({ onChange }) {
|
|
|
19
23
|
return (_jsx(IconButton, { onClick: handleOpen, size: "small", children: _jsx(UploadIcon, {}) }, "uploader-trigger"));
|
|
20
24
|
}
|
|
21
25
|
export function UploaderProvider({ children }) {
|
|
22
|
-
return (_jsx(UploaderProviderLib, { popup: true,
|
|
26
|
+
return (_jsx(Suspense, { fallback: _jsx(Skeleton, { variant: "rectangular", width: "100%", height: "100%" }), children: _jsx(UploaderProviderLib, { popup: true,
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
coreProps: {
|
|
29
|
+
restrictions: {
|
|
30
|
+
allowedFileTypes: [
|
|
31
|
+
'image/png',
|
|
32
|
+
'image/jpeg',
|
|
33
|
+
'image/gif',
|
|
34
|
+
'image/webp',
|
|
35
|
+
'image/svg+xml',
|
|
36
|
+
'video/mp4',
|
|
37
|
+
'video/webm',
|
|
38
|
+
'audio/mpeg',
|
|
39
|
+
],
|
|
40
|
+
maxNumberOfFiles: 1,
|
|
41
|
+
},
|
|
42
|
+
}, children: children }, "uploader"
|
|
23
43
|
// @ts-ignore
|
|
24
|
-
|
|
25
|
-
restrictions: {
|
|
26
|
-
allowedFileTypes: [
|
|
27
|
-
'image/png',
|
|
28
|
-
'image/jpeg',
|
|
29
|
-
'image/gif',
|
|
30
|
-
'image/webp',
|
|
31
|
-
'image/svg+xml',
|
|
32
|
-
'video/mp4',
|
|
33
|
-
'video/webm',
|
|
34
|
-
'audio/mpeg',
|
|
35
|
-
],
|
|
36
|
-
maxNumberOfFiles: 1,
|
|
37
|
-
},
|
|
38
|
-
}, children: children }, "uploader"
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
));
|
|
44
|
+
) }));
|
|
41
45
|
}
|
|
42
46
|
export default UploaderProvider;
|
|
43
47
|
export function getVideoSize(url) {
|