@raketa-builder/image-input 1.6.7 → 1.6.8
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.js
CHANGED
|
@@ -3,3 +3,5 @@ export { default as ImagePicker } from './pickers/ImagePicker/ImagePicker';
|
|
|
3
3
|
export { default as ImageInput } from './pickers/ImagePicker/ImageInput';
|
|
4
4
|
export { default as MediaManager } from './MediaManager';
|
|
5
5
|
export { default as MediaManagerContext } from './MediaManagerContext';
|
|
6
|
+
export { default as MediaRenderer } from './lib/MediaRenderer';
|
|
7
|
+
export { isLottieFile } from './lib/mediaUtils';
|
package/dist/lib/Dropbox.js
CHANGED
|
@@ -26,11 +26,25 @@ const Dropbox = ({ buttonLabel = "Select files...", onDrop }) => {
|
|
|
26
26
|
const dropzoneRef = React.createRef();
|
|
27
27
|
const handleOpen = () => dropzoneRef.current.open();
|
|
28
28
|
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
29
|
-
/* @__PURE__ */ jsx(StyledDropzone, { children: /* @__PURE__ */ jsx(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
/* @__PURE__ */ jsx(StyledDropzone, { children: /* @__PURE__ */ jsx(
|
|
30
|
+
Dropzone,
|
|
31
|
+
{
|
|
32
|
+
ref: dropzoneRef,
|
|
33
|
+
onDrop,
|
|
34
|
+
accept: {
|
|
35
|
+
"image/jpeg": [".jpg", ".jpeg"],
|
|
36
|
+
"image/png": [".png"],
|
|
37
|
+
"image/gif": [".gif"],
|
|
38
|
+
"image/svg+xml": [".svg"],
|
|
39
|
+
"application/zip": [".lottie"]
|
|
40
|
+
},
|
|
41
|
+
children: ({ getRootProps, getInputProps }) => /* @__PURE__ */ jsxs(DropzoneLabel, __spreadProps(__spreadValues({}, getRootProps()), { children: [
|
|
42
|
+
/* @__PURE__ */ jsx(H, { size: "large", children: "Select files from your computer" }),
|
|
43
|
+
/* @__PURE__ */ jsx("small", { children: "or drag and drop here" }),
|
|
44
|
+
/* @__PURE__ */ jsx("input", __spreadValues({}, getInputProps()))
|
|
45
|
+
] }))
|
|
46
|
+
}
|
|
47
|
+
) }),
|
|
34
48
|
/* @__PURE__ */ jsx(
|
|
35
49
|
Button,
|
|
36
50
|
{
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __objRest, __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import { Image } from '@raketa-builder/support';
|
|
5
|
+
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
|
|
6
|
+
import { isLottieFile } from './mediaUtils';
|
|
7
|
+
|
|
8
|
+
const MediaRenderer = (_a) => {
|
|
9
|
+
var _b = _a, { src, variant = "thumb", style } = _b, props = __objRest(_b, ["src", "variant", "style"]);
|
|
10
|
+
var _a2;
|
|
11
|
+
if (!src) return null;
|
|
12
|
+
if (isLottieFile(src)) {
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
DotLottieReact,
|
|
15
|
+
{
|
|
16
|
+
src: (_a2 = src.urls) == null ? void 0 : _a2.original,
|
|
17
|
+
loop: true,
|
|
18
|
+
autoplay: true,
|
|
19
|
+
style: style || { width: "100%", height: "100%" }
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
Image,
|
|
25
|
+
__spreadValues({
|
|
26
|
+
src,
|
|
27
|
+
variant
|
|
28
|
+
}, props)
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
var MediaRenderer_default = MediaRenderer;
|
|
32
|
+
|
|
33
|
+
export { MediaRenderer_default as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '../chunk-ORMEWXMH.js';
|
|
2
|
+
|
|
3
|
+
const isLottieFile = (image) => {
|
|
4
|
+
var _a, _b, _c, _d;
|
|
5
|
+
if (!image) return false;
|
|
6
|
+
if (image.mime_type === "application/zip" && ((_a = image.name) == null ? void 0 : _a.endsWith(".lottie"))) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (image.mime_type === "application/json" && ((_b = image.name) == null ? void 0 : _b.endsWith(".json"))) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return ((_c = image.name) == null ? void 0 : _c.endsWith(".lottie")) || ((_d = image.name) == null ? void 0 : _d.endsWith(".json")) || false;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { isLottieFile };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __objRest, __spreadValues, __spreadProps } from '../../chunk-ORMEWXMH.js';
|
|
2
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Stack, Button, cn, H } from '@raketa-builder/ui';
|
|
5
|
-
import { Image } from '@raketa-builder/support';
|
|
6
5
|
import TextInput from '../../forms/TextInput';
|
|
6
|
+
import MediaRenderer from '../../lib/MediaRenderer';
|
|
7
|
+
import { isLottieFile } from '../../lib/mediaUtils';
|
|
7
8
|
|
|
8
9
|
const ImageList = (_a) => {
|
|
9
10
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
@@ -50,7 +51,7 @@ const ImageItem = ({ image, selected, onSelect, onFastSelect }) => /* @__PURE__
|
|
|
50
51
|
onClick: () => onSelect(image),
|
|
51
52
|
onDoubleClick: () => onFastSelect(image),
|
|
52
53
|
children: /* @__PURE__ */ jsx(ImageWrapper, { title: image.name, children: /* @__PURE__ */ jsx(
|
|
53
|
-
|
|
54
|
+
MediaRenderer,
|
|
54
55
|
{
|
|
55
56
|
src: getPreviewImage(image),
|
|
56
57
|
variant: "thumb",
|
|
@@ -88,7 +89,15 @@ const isImageEditable = (image) => {
|
|
|
88
89
|
const ImagePreview = ({ image, onDelete }) => {
|
|
89
90
|
return /* @__PURE__ */ jsxs(ImageInspector, { children: [
|
|
90
91
|
/* @__PURE__ */ jsxs(ImagePreviewWrapper, { children: [
|
|
91
|
-
/* @__PURE__ */ jsx(
|
|
92
|
+
/* @__PURE__ */ jsx(
|
|
93
|
+
MediaRenderer,
|
|
94
|
+
{
|
|
95
|
+
src: image,
|
|
96
|
+
variant: "original",
|
|
97
|
+
style: isLottieFile(image) ? { width: "100%", maxWidth: "400px", margin: "0 auto" } : void 0,
|
|
98
|
+
alt: ""
|
|
99
|
+
}
|
|
100
|
+
),
|
|
92
101
|
isImageEditable(image) && /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
93
102
|
/* @__PURE__ */ jsx(
|
|
94
103
|
H,
|
|
@@ -105,10 +114,13 @@ const ImagePreview = ({ image, onDelete }) => {
|
|
|
105
114
|
),
|
|
106
115
|
/* @__PURE__ */ jsxs("div", { style: { opacity: 0.5 }, children: [
|
|
107
116
|
(image.size / 1024).toFixed(2),
|
|
108
|
-
" KB
|
|
109
|
-
image
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
" KB",
|
|
118
|
+
!isLottieFile(image) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
119
|
+
" / ",
|
|
120
|
+
image.width,
|
|
121
|
+
"\xD7",
|
|
122
|
+
image.height
|
|
123
|
+
] })
|
|
112
124
|
] })
|
|
113
125
|
] })
|
|
114
126
|
] }),
|
|
@@ -2,11 +2,11 @@ import { __spreadProps, __spreadValues, __objRest } from '../../chunk-ORMEWXMH.j
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { FormGroup, Label, Button, Tabs, cn } from '@raketa-builder/ui';
|
|
5
|
-
import { Image } from '@raketa-builder/support';
|
|
6
5
|
import TextInput from '../../forms/TextInput';
|
|
7
6
|
import Dialog from '../../dialogs/Dialog';
|
|
8
7
|
import BrowseTab from './BrowseTab';
|
|
9
8
|
import UploadTab from './UploadTab';
|
|
9
|
+
import MediaRenderer from '../../lib/MediaRenderer';
|
|
10
10
|
import { removeById } from '../../lists';
|
|
11
11
|
import MediaManagerContext from '../../MediaManagerContext';
|
|
12
12
|
|
|
@@ -147,10 +147,7 @@ const ImagePicker = ({
|
|
|
147
147
|
const image = fetchImage(value);
|
|
148
148
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
149
149
|
/* @__PURE__ */ jsxs(ImageControl, { children: [
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
image && /* @__PURE__ */ jsx(Image, { src: image, variant: "thumb", title: image.name, alt: "" }),
|
|
152
|
-
!image && /* @__PURE__ */ jsx(ImagePlaceholder, {})
|
|
153
|
-
] }),
|
|
150
|
+
/* @__PURE__ */ jsx(ImageWrapper, { children: image ? /* @__PURE__ */ jsx(MediaRenderer, { src: image, variant: "thumb", title: image.name, alt: "" }) : /* @__PURE__ */ jsx(ImagePlaceholder, {}) }),
|
|
154
151
|
/* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
155
152
|
/* @__PURE__ */ jsx(Label, { children: label }),
|
|
156
153
|
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "0.5rem" }, children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-builder/image-input",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.8",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"react-dropzone": "14.3.8",
|
|
33
|
-
"@raketa-builder/support": "1.6.
|
|
34
|
-
"@raketa-builder/ui": "1.6.
|
|
33
|
+
"@raketa-builder/support": "1.6.8",
|
|
34
|
+
"@raketa-builder/ui": "1.6.8",
|
|
35
|
+
"@lottiefiles/dotlottie-react": "0.19.2"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@biomejs/biome": "2.1.2",
|