@blocklet/pages-kit-inner-components 0.0.16 → 0.0.18
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/lib/cjs/uploader.js +1 -1
- package/lib/es/uploader.js +53 -68
- package/package.json +8 -8
package/lib/cjs/uploader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),d=require("@blocklet/uploader/react"),s=require("@mui/icons-material/Upload"),c=require("@mui/material"),p=o=>o&&o.__esModule?o:{default:o},g=p(s),u=d.useUploaderContext;function m({onChange:o}){const r=u(),n=()=>{var t;const e=(t=r==null?void 0:r.current)==null?void 0:t.getUploader();e==null||e.open(),o&&e.onceUploadSuccess((...i)=>{o(...i)})};return a.jsx(c.IconButton,{size:"small",onClick:n,children:a.jsx(g.default,{})},"uploader-trigger")}function l({children:o}){return a.jsx(d.UploaderProvider,{popup:!0,coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","video/mp4","video/webm","audio/mpeg"],maxNumberOfFiles:1}},children:o},"uploader")}function f(o){return new Promise((r,n)=>{const e=document.createElement("video");e.src=o,e.onloadedmetadata=()=>{const{videoWidth:t,videoHeight:i}=e;r({naturalWidth:t,naturalHeight:i})},e.onerror=t=>n(t)})}function v(o){return new Promise((r,n)=>{const e=new Image;e.src=o,e.onload=()=>{const{naturalWidth:t,naturalHeight:i}=e;r({naturalWidth:t,naturalHeight:i})},e.onerror=t=>n(t)})}exports.UploaderButton=m;exports.UploaderProvider=l;exports.default=l;exports.getImageSize=v;exports.getVideoSize=f;exports.useUploader=u;
|
package/lib/es/uploader.js
CHANGED
|
@@ -1,81 +1,66 @@
|
|
|
1
|
-
import { jsx as a
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const r = U();
|
|
14
|
-
return /* @__PURE__ */ a(u, { size: "small", onClick: () => {
|
|
15
|
-
var n;
|
|
16
|
-
const e = (n = r == null ? void 0 : r.current) == null ? void 0 : n.getUploader();
|
|
17
|
-
e == null || e.open(), o && e.onceUploadSuccess((...i) => {
|
|
18
|
-
o(...i);
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useUploaderContext as d, UploaderProvider as l } from "@blocklet/uploader/react";
|
|
3
|
+
import m from "@mui/icons-material/Upload";
|
|
4
|
+
import { IconButton as p } from "@mui/material";
|
|
5
|
+
const s = d;
|
|
6
|
+
function v({ onChange: r }) {
|
|
7
|
+
const t = s();
|
|
8
|
+
return /* @__PURE__ */ a(p, { size: "small", onClick: () => {
|
|
9
|
+
var o;
|
|
10
|
+
const e = (o = t == null ? void 0 : t.current) == null ? void 0 : o.getUploader();
|
|
11
|
+
e == null || e.open(), r && e.onceUploadSuccess((...n) => {
|
|
12
|
+
r(...n);
|
|
19
13
|
});
|
|
20
|
-
}, children: /* @__PURE__ */ a(
|
|
14
|
+
}, children: /* @__PURE__ */ a(m, {}) }, "uploader-trigger");
|
|
21
15
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"image/gif",
|
|
41
|
-
"image/webp",
|
|
42
|
-
"image/svg+xml",
|
|
43
|
-
"video/mp4",
|
|
44
|
-
"video/webm",
|
|
45
|
-
"audio/mpeg"
|
|
46
|
-
],
|
|
47
|
-
maxNumberOfFiles: 1
|
|
48
|
-
}
|
|
16
|
+
function U({ children: r }) {
|
|
17
|
+
return /* @__PURE__ */ a(
|
|
18
|
+
l,
|
|
19
|
+
{
|
|
20
|
+
popup: !0,
|
|
21
|
+
coreProps: {
|
|
22
|
+
restrictions: {
|
|
23
|
+
allowedFileTypes: [
|
|
24
|
+
"image/png",
|
|
25
|
+
"image/jpeg",
|
|
26
|
+
"image/gif",
|
|
27
|
+
"image/webp",
|
|
28
|
+
"image/svg+xml",
|
|
29
|
+
"video/mp4",
|
|
30
|
+
"video/webm",
|
|
31
|
+
"audio/mpeg"
|
|
32
|
+
],
|
|
33
|
+
maxNumberOfFiles: 1
|
|
49
34
|
}
|
|
50
35
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
children: r
|
|
37
|
+
},
|
|
38
|
+
"uploader"
|
|
39
|
+
);
|
|
54
40
|
}
|
|
55
|
-
function
|
|
56
|
-
return new Promise((
|
|
41
|
+
function h(r) {
|
|
42
|
+
return new Promise((t, i) => {
|
|
57
43
|
const e = document.createElement("video");
|
|
58
|
-
e.src =
|
|
59
|
-
const { videoWidth:
|
|
60
|
-
|
|
61
|
-
}, e.onerror = (
|
|
44
|
+
e.src = r, e.onloadedmetadata = () => {
|
|
45
|
+
const { videoWidth: o, videoHeight: n } = e;
|
|
46
|
+
t({ naturalWidth: o, naturalHeight: n });
|
|
47
|
+
}, e.onerror = (o) => i(o);
|
|
62
48
|
});
|
|
63
49
|
}
|
|
64
|
-
function
|
|
65
|
-
return new Promise((
|
|
50
|
+
function w(r) {
|
|
51
|
+
return new Promise((t, i) => {
|
|
66
52
|
const e = new Image();
|
|
67
|
-
e.src =
|
|
68
|
-
const { naturalWidth:
|
|
69
|
-
|
|
70
|
-
}, e.onerror = (
|
|
53
|
+
e.src = r, e.onload = () => {
|
|
54
|
+
const { naturalWidth: o, naturalHeight: n } = e;
|
|
55
|
+
t({ naturalWidth: o, naturalHeight: n });
|
|
56
|
+
}, e.onerror = (o) => i(o);
|
|
71
57
|
});
|
|
72
58
|
}
|
|
73
59
|
export {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
U as useUploader
|
|
60
|
+
v as UploaderButton,
|
|
61
|
+
U as UploaderProvider,
|
|
62
|
+
U as default,
|
|
63
|
+
w as getImageSize,
|
|
64
|
+
h as getVideoSize,
|
|
65
|
+
s as useUploader
|
|
81
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/pages-kit-inner-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Pages Kit inner components library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@arcblock/did-auth": "^1.19.9",
|
|
61
61
|
"@arcblock/did-auth-storage-nedb": "^1.7.1",
|
|
62
|
-
"@arcblock/did-connect": "^2.11.
|
|
63
|
-
"@arcblock/react-hooks": "^2.11.
|
|
64
|
-
"@arcblock/ux": "^2.11.
|
|
62
|
+
"@arcblock/did-connect": "^2.11.36",
|
|
63
|
+
"@arcblock/react-hooks": "^2.11.36",
|
|
64
|
+
"@arcblock/ux": "^2.11.36",
|
|
65
65
|
"@blocklet/ai-kit": "^0.1.68",
|
|
66
66
|
"@blocklet/ai-runtime": "^0.4.230",
|
|
67
67
|
"@blocklet/code-editor": "^0.4.230",
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"@blocklet/sdk": "^1.16.38",
|
|
74
74
|
"@blocklet/studio-ui": "^0.4.230",
|
|
75
75
|
"@blocklet/tracker": "^1.16.38",
|
|
76
|
-
"@blocklet/ui-react": "^2.11.
|
|
77
|
-
"@blocklet/uploader": "^0.1.
|
|
78
|
-
"@blocklet/uploader-server": "^0.1.
|
|
76
|
+
"@blocklet/ui-react": "^2.11.36",
|
|
77
|
+
"@blocklet/uploader": "^0.1.68",
|
|
78
|
+
"@blocklet/uploader-server": "^0.1.80",
|
|
79
79
|
"@emotion/cache": "^11.13.1",
|
|
80
80
|
"@emotion/css": "^11.13.0",
|
|
81
81
|
"@emotion/react": "^11.13.0",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
"yjs": "^13.6.18",
|
|
196
196
|
"zustand": "^4.5.5",
|
|
197
197
|
"@blocklet/pages-kit": "^0.4.9",
|
|
198
|
-
"@blocklet/pages-kit-block-studio": "^0.0.
|
|
198
|
+
"@blocklet/pages-kit-block-studio": "^0.0.14"
|
|
199
199
|
},
|
|
200
200
|
"devDependencies": {
|
|
201
201
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|