@chayns-components/gallery 5.0.0-beta.441 → 5.0.0-beta.443
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/components/Gallery.js +36 -46
- package/lib/components/Gallery.js.map +1 -1
- package/lib/components/Gallery.styles.js +15 -23
- package/lib/components/Gallery.styles.js.map +1 -1
- package/lib/components/add-file/AddFile.js +9 -17
- package/lib/components/add-file/AddFile.js.map +1 -1
- package/lib/components/add-file/AddFile.styles.js +3 -10
- package/lib/components/add-file/AddFile.styles.js.map +1 -1
- package/lib/components/gallery-item/GalleryItem.js +13 -22
- package/lib/components/gallery-item/GalleryItem.js.map +1 -1
- package/lib/components/gallery-item/GalleryItem.styles.js +4 -11
- package/lib/components/gallery-item/GalleryItem.styles.js.map +1 -1
- package/lib/components/gallery-item/media-item/MediaItem.js +11 -18
- package/lib/components/gallery-item/media-item/MediaItem.js.map +1 -1
- package/lib/components/gallery-item/media-item/MediaItem.styles.js +8 -15
- package/lib/components/gallery-item/media-item/MediaItem.styles.js.map +1 -1
- package/lib/components/gallery-item/preview-item/PreviewItem.js +8 -15
- package/lib/components/gallery-item/preview-item/PreviewItem.js.map +1 -1
- package/lib/components/gallery-item/preview-item/PreviewItem.styles.js +6 -13
- package/lib/components/gallery-item/preview-item/PreviewItem.styles.js.map +1 -1
- package/lib/index.js +3 -19
- package/lib/index.js.map +1 -1
- package/lib/types/gallery.js +1 -7
- package/lib/types/gallery.js.map +1 -1
- package/lib/utils/file.js +3 -12
- package/lib/utils/file.js.map +1 -1
- package/package.json +10 -10
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _core = require("@chayns-components/core");
|
|
8
|
-
var _chaynsApi = require("chayns-api");
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _uuid = require("uuid");
|
|
11
|
-
var _gallery = require("../types/gallery");
|
|
12
|
-
var _file = require("../utils/file");
|
|
13
|
-
var _AddFile = _interopRequireDefault(require("./add-file/AddFile"));
|
|
14
|
-
var _GalleryItem = _interopRequireDefault(require("./gallery-item/GalleryItem"));
|
|
15
|
-
var _Gallery = require("./Gallery.styles");
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
import { uploadFile } from '@chayns-components/core';
|
|
19
2
|
// TODO: Check why absolute import is needed
|
|
20
|
-
|
|
3
|
+
import { MediaType, openMedia } from 'chayns-api';
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
import { GalleryViewMode } from '../types/gallery';
|
|
7
|
+
import { filterDuplicateFile, generatePreviewUrl, generateVideoThumbnail } from '../utils/file';
|
|
8
|
+
import AddFile from './add-file/AddFile';
|
|
9
|
+
import GalleryItem from './gallery-item/GalleryItem';
|
|
10
|
+
import { StyledGallery, StyledGalleryEditModeWrapper, StyledGalleryItemWrapper } from './Gallery.styles';
|
|
21
11
|
const Gallery = _ref => {
|
|
22
12
|
let {
|
|
23
13
|
accessToken,
|
|
@@ -29,9 +19,9 @@ const Gallery = _ref => {
|
|
|
29
19
|
onFileCountChange,
|
|
30
20
|
onRemove,
|
|
31
21
|
personId,
|
|
32
|
-
viewMode =
|
|
22
|
+
viewMode = GalleryViewMode.GRID
|
|
33
23
|
} = _ref;
|
|
34
|
-
const [fileItems, setFileItems] =
|
|
24
|
+
const [fileItems, setFileItems] = useState([]);
|
|
35
25
|
|
|
36
26
|
/**
|
|
37
27
|
* This function adds a previewUrl to fileItems
|
|
@@ -51,7 +41,7 @@ const Gallery = _ref => {
|
|
|
51
41
|
/**
|
|
52
42
|
* This function adds uploaded files to fileItems
|
|
53
43
|
*/
|
|
54
|
-
const handleUploadFileCallback =
|
|
44
|
+
const handleUploadFileCallback = useCallback((file, UploadedFile) => {
|
|
55
45
|
setFileItems(prevState => prevState.map(prevFile => {
|
|
56
46
|
if (prevFile.id === file.id) {
|
|
57
47
|
if (typeof onAdd === 'function') {
|
|
@@ -74,7 +64,7 @@ const Gallery = _ref => {
|
|
|
74
64
|
/**
|
|
75
65
|
* Returns the current count to check if all files are uploaded
|
|
76
66
|
*/
|
|
77
|
-
|
|
67
|
+
useEffect(() => {
|
|
78
68
|
if (typeof onFileCountChange === 'function') {
|
|
79
69
|
onFileCountChange(fileItems.length);
|
|
80
70
|
}
|
|
@@ -83,7 +73,7 @@ const Gallery = _ref => {
|
|
|
83
73
|
/**
|
|
84
74
|
* Prepares files for previewUrl and upload
|
|
85
75
|
*/
|
|
86
|
-
|
|
76
|
+
useEffect(() => {
|
|
87
77
|
const filesToGeneratePreview = fileItems.filter(file => file.file && !file.previewUrl && (file.state === 'none' || !file.state));
|
|
88
78
|
const filesToUpload = fileItems.filter(file => !file.uploadedFile && file.state !== 'uploading');
|
|
89
79
|
filesToGeneratePreview.forEach(file => {
|
|
@@ -91,13 +81,13 @@ const Gallery = _ref => {
|
|
|
91
81
|
return;
|
|
92
82
|
}
|
|
93
83
|
if (file.file.type.includes('video/')) {
|
|
94
|
-
|
|
84
|
+
generateVideoThumbnail({
|
|
95
85
|
file: file.file,
|
|
96
86
|
callback: previewUrl => handlePreviewUrlCallback(previewUrl, file)
|
|
97
87
|
});
|
|
98
88
|
return;
|
|
99
89
|
}
|
|
100
|
-
|
|
90
|
+
generatePreviewUrl({
|
|
101
91
|
file: file.file,
|
|
102
92
|
callback: previewUrl => handlePreviewUrlCallback(previewUrl, file)
|
|
103
93
|
});
|
|
@@ -112,7 +102,7 @@ const Gallery = _ref => {
|
|
|
112
102
|
}
|
|
113
103
|
return prevFile;
|
|
114
104
|
}));
|
|
115
|
-
void
|
|
105
|
+
void uploadFile({
|
|
116
106
|
fileToUpload: file,
|
|
117
107
|
personId,
|
|
118
108
|
accessToken,
|
|
@@ -124,15 +114,15 @@ const Gallery = _ref => {
|
|
|
124
114
|
/**
|
|
125
115
|
* This function formats and adds files to fileItems
|
|
126
116
|
*/
|
|
127
|
-
const handleAddFiles =
|
|
117
|
+
const handleAddFiles = useCallback(filesToAdd => {
|
|
128
118
|
const newFileItems = [];
|
|
129
119
|
filesToAdd.forEach(file => {
|
|
130
|
-
if (file && !
|
|
120
|
+
if (file && !filterDuplicateFile({
|
|
131
121
|
files: fileItems,
|
|
132
122
|
newFile: file
|
|
133
123
|
})) {
|
|
134
124
|
newFileItems.push({
|
|
135
|
-
id: (
|
|
125
|
+
id: uuidv4(),
|
|
136
126
|
file,
|
|
137
127
|
state: 'none'
|
|
138
128
|
});
|
|
@@ -144,12 +134,12 @@ const Gallery = _ref => {
|
|
|
144
134
|
/**
|
|
145
135
|
* This function adds external files to fileItems
|
|
146
136
|
*/
|
|
147
|
-
|
|
137
|
+
useEffect(() => {
|
|
148
138
|
if (files) {
|
|
149
139
|
const newFileItems = [];
|
|
150
140
|
files.forEach(file => {
|
|
151
141
|
newFileItems.push({
|
|
152
|
-
id: (
|
|
142
|
+
id: uuidv4(),
|
|
153
143
|
uploadedFile: file.uploadedFile,
|
|
154
144
|
file: file.file,
|
|
155
145
|
state: file.uploadedFile ? 'uploaded' : 'none',
|
|
@@ -163,7 +153,7 @@ const Gallery = _ref => {
|
|
|
163
153
|
/**
|
|
164
154
|
* This function deletes a selected file from the file list
|
|
165
155
|
*/
|
|
166
|
-
const handleDeleteFile =
|
|
156
|
+
const handleDeleteFile = useCallback(id => {
|
|
167
157
|
let fileToDelete;
|
|
168
158
|
const filteredFiles = fileItems.filter(file => {
|
|
169
159
|
const fileId = file.id;
|
|
@@ -182,7 +172,7 @@ const Gallery = _ref => {
|
|
|
182
172
|
/**
|
|
183
173
|
* This function handles the drag and drop
|
|
184
174
|
*/
|
|
185
|
-
const handleDrop =
|
|
175
|
+
const handleDrop = useCallback(e => {
|
|
186
176
|
if (!allowDragAndDrop) {
|
|
187
177
|
return;
|
|
188
178
|
}
|
|
@@ -194,16 +184,16 @@ const Gallery = _ref => {
|
|
|
194
184
|
/**
|
|
195
185
|
* Opens the files in a slideShow
|
|
196
186
|
*/
|
|
197
|
-
const openFiles =
|
|
187
|
+
const openFiles = useCallback(file => {
|
|
198
188
|
const startIndex = fileItems.findIndex(item => item.id === file.id);
|
|
199
189
|
const items = fileItems.map(item => ({
|
|
200
190
|
url: item.uploadedFile?.url.replace('_0.mp4', '.mp4') ?? '',
|
|
201
|
-
mediaType: item.uploadedFile && 'thumbnailUrl' in item.uploadedFile ?
|
|
191
|
+
mediaType: item.uploadedFile && 'thumbnailUrl' in item.uploadedFile ? MediaType.VIDEO : MediaType.IMAGE
|
|
202
192
|
}));
|
|
203
193
|
|
|
204
194
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
205
195
|
// @ts-ignore
|
|
206
|
-
void
|
|
196
|
+
void openMedia({
|
|
207
197
|
items,
|
|
208
198
|
startIndex
|
|
209
199
|
});
|
|
@@ -212,7 +202,7 @@ const Gallery = _ref => {
|
|
|
212
202
|
/**
|
|
213
203
|
* Returns the ratio of the single file
|
|
214
204
|
*/
|
|
215
|
-
const ratio =
|
|
205
|
+
const ratio = useMemo(() => {
|
|
216
206
|
switch (fileItems.length) {
|
|
217
207
|
case 0:
|
|
218
208
|
return 0;
|
|
@@ -226,17 +216,17 @@ const Gallery = _ref => {
|
|
|
226
216
|
return 1;
|
|
227
217
|
}
|
|
228
218
|
}, [fileItems]);
|
|
229
|
-
const galleryContent =
|
|
219
|
+
const galleryContent = useMemo(() => {
|
|
230
220
|
const combinedFilesLength = fileItems.length;
|
|
231
221
|
if (isEditMode) {
|
|
232
|
-
const items = fileItems.map(file => /*#__PURE__*/
|
|
222
|
+
const items = fileItems.map(file => /*#__PURE__*/React.createElement(GalleryItem, {
|
|
233
223
|
key: file.id,
|
|
234
224
|
fileItem: file,
|
|
235
225
|
isEditMode: true,
|
|
236
226
|
onClick: openFiles,
|
|
237
227
|
handleDeleteFile: handleDeleteFile
|
|
238
228
|
}));
|
|
239
|
-
items.push( /*#__PURE__*/
|
|
229
|
+
items.push( /*#__PURE__*/React.createElement(AddFile, {
|
|
240
230
|
key: "add_file",
|
|
241
231
|
onAdd: handleAddFiles
|
|
242
232
|
}));
|
|
@@ -245,14 +235,14 @@ const Gallery = _ref => {
|
|
|
245
235
|
const shortedFiles = fileItems.slice(0, 4);
|
|
246
236
|
return shortedFiles.map((file, index) => {
|
|
247
237
|
let imageRatio = 1;
|
|
248
|
-
if (viewMode ===
|
|
238
|
+
if (viewMode === GalleryViewMode.GRID) {
|
|
249
239
|
if (combinedFilesLength === 2 && (index === 0 || index === 1)) {
|
|
250
240
|
imageRatio = 0.5;
|
|
251
241
|
} else if (index === 0 && combinedFilesLength > 2 || combinedFilesLength === 3 && (index === 1 || index === 2)) {
|
|
252
242
|
imageRatio = 1.5;
|
|
253
243
|
}
|
|
254
244
|
}
|
|
255
|
-
return /*#__PURE__*/
|
|
245
|
+
return /*#__PURE__*/React.createElement(GalleryItem, {
|
|
256
246
|
key: file.id,
|
|
257
247
|
fileItem: file,
|
|
258
248
|
isEditMode: false,
|
|
@@ -263,16 +253,16 @@ const Gallery = _ref => {
|
|
|
263
253
|
});
|
|
264
254
|
});
|
|
265
255
|
}, [fileItems, isEditMode, handleAddFiles, openFiles, handleDeleteFile, viewMode]);
|
|
266
|
-
return
|
|
256
|
+
return useMemo(() => /*#__PURE__*/React.createElement(StyledGallery, null, isEditMode ? /*#__PURE__*/React.createElement(StyledGalleryEditModeWrapper, {
|
|
267
257
|
fileMinWidth: fileMinWidth,
|
|
268
258
|
onDragOver: e => e.preventDefault(),
|
|
269
259
|
onDrop: e => void handleDrop(e)
|
|
270
|
-
}, galleryContent) : /*#__PURE__*/
|
|
260
|
+
}, galleryContent) : /*#__PURE__*/React.createElement(StyledGalleryItemWrapper, {
|
|
271
261
|
ratio: ratio,
|
|
272
262
|
uploadedFileLength: fileItems.length,
|
|
273
263
|
viewMode: viewMode
|
|
274
264
|
}, galleryContent)), [isEditMode, fileMinWidth, galleryContent, ratio, fileItems.length, viewMode, handleDrop]);
|
|
275
265
|
};
|
|
276
266
|
Gallery.displayName = 'Gallery';
|
|
277
|
-
|
|
267
|
+
export default Gallery;
|
|
278
268
|
//# sourceMappingURL=Gallery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gallery.js","names":["_core","require","_chaynsApi","_react","_interopRequireWildcard","_uuid","_gallery","_file","_AddFile","_interopRequireDefault","_GalleryItem","_Gallery","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Gallery","_ref","accessToken","allowDragAndDrop","isEditMode","fileMinWidth","files","onAdd","onFileCountChange","onRemove","personId","viewMode","GalleryViewMode","GRID","fileItems","setFileItems","useState","handlePreviewUrlCallback","previewUrl","file","prevState","map","prevFile","id","handleUploadFileCallback","useCallback","UploadedFile","uploadedFile","state","useEffect","length","filesToGeneratePreview","filter","filesToUpload","forEach","type","includes","generateVideoThumbnail","callback","generatePreviewUrl","uploadFile","fileToUpload","handleAddFiles","filesToAdd","newFileItems","filterDuplicateFile","newFile","push","uuidv4","url","undefined","handleDeleteFile","fileToDelete","filteredFiles","fileId","handleDrop","preventDefault","draggedFiles","Array","from","dataTransfer","openFiles","startIndex","findIndex","item","items","replace","mediaType","MediaType","VIDEO","IMAGE","openMedia","ratio","useMemo","Math","max","galleryContent","combinedFilesLength","createElement","key","fileItem","onClick","shortedFiles","slice","index","imageRatio","remainingItemsLength","StyledGallery","StyledGalleryEditModeWrapper","onDragOver","onDrop","StyledGalleryItemWrapper","uploadedFileLength","displayName","_default","exports"],"sources":["../../src/components/Gallery.tsx"],"sourcesContent":["import { uploadFile } from '@chayns-components/core';\nimport type { FileItem, Image, Video } from '@chayns-components/core/lib/types/file'; // TODO: Check why absolute import is needed\nimport { MediaType, openMedia, OpenMediaItem } from 'chayns-api';\nimport React, { DragEvent, FC, useCallback, useEffect, useMemo, useState } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport { GalleryViewMode } from '../types/gallery';\nimport { filterDuplicateFile, generatePreviewUrl, generateVideoThumbnail } from '../utils/file';\nimport AddFile from './add-file/AddFile';\nimport GalleryItem from './gallery-item/GalleryItem';\nimport {\n StyledGallery,\n StyledGalleryEditModeWrapper,\n StyledGalleryItemWrapper,\n} from './Gallery.styles';\n\nexport type GalleryProps = {\n /**\n * AccessToken of the user\n */\n accessToken: string;\n /**\n * Whether drag and drop is allowed or not\n */\n allowDragAndDrop?: boolean;\n /**\n * Whether images and videos can be edited\n */\n isEditMode?: boolean;\n /**\n * The minimum width of a file in the edit mode\n */\n fileMinWidth?: number;\n /**\n * Images and videos which should be displayed\n */\n files?: FileItem[];\n /**\n * Function to be executed when files are added and uploaded\n */\n onAdd?: (file: FileItem) => void;\n /**\n * Function to be executed when the count of files are changed. Needed to check if all files are uploaded\n */\n onFileCountChange?: (fileCount: number) => void;\n /**\n * Function to be executed when a file is removed\n */\n onRemove?: (file: FileItem) => void;\n /**\n * PersonId of the user\n */\n personId: string;\n /**\n * The mode how the images should be displayed.\n */\n viewMode?: GalleryViewMode;\n};\n\nconst Gallery: FC<GalleryProps> = ({\n accessToken,\n allowDragAndDrop = false,\n isEditMode = false,\n fileMinWidth = 100,\n files,\n onAdd,\n onFileCountChange,\n onRemove,\n personId,\n viewMode = GalleryViewMode.GRID,\n}) => {\n const [fileItems, setFileItems] = useState<FileItem[]>([]);\n\n /**\n * This function adds a previewUrl to fileItems\n */\n const handlePreviewUrlCallback = (previewUrl: string, file: FileItem) => {\n setFileItems((prevState) =>\n prevState.map((prevFile) => {\n if (prevFile.id === file.id) {\n return { ...prevFile, previewUrl };\n }\n return prevFile;\n }),\n );\n };\n\n /**\n * This function adds uploaded files to fileItems\n */\n const handleUploadFileCallback = useCallback(\n (file: FileItem, UploadedFile: Video | Image) => {\n setFileItems((prevState) =>\n prevState.map((prevFile) => {\n if (prevFile.id === file.id) {\n if (typeof onAdd === 'function') {\n onAdd({\n ...prevFile,\n uploadedFile: UploadedFile,\n state: 'uploaded',\n });\n }\n\n return {\n ...prevFile,\n uploadedFile: UploadedFile,\n state: 'uploaded',\n };\n }\n return prevFile;\n }),\n );\n },\n [onAdd],\n );\n\n /**\n * Returns the current count to check if all files are uploaded\n */\n useEffect(() => {\n if (typeof onFileCountChange === 'function') {\n onFileCountChange(fileItems.length);\n }\n }, [fileItems.length, onFileCountChange]);\n\n /**\n * Prepares files for previewUrl and upload\n */\n useEffect(() => {\n const filesToGeneratePreview = fileItems.filter(\n (file) => file.file && !file.previewUrl && (file.state === 'none' || !file.state),\n );\n\n const filesToUpload = fileItems.filter(\n (file) => !file.uploadedFile && file.state !== 'uploading',\n );\n\n filesToGeneratePreview.forEach((file) => {\n if (!file.file) {\n return;\n }\n\n if (file.file.type.includes('video/')) {\n generateVideoThumbnail({\n file: file.file,\n callback: (previewUrl) => handlePreviewUrlCallback(previewUrl, file),\n });\n\n return;\n }\n\n generatePreviewUrl({\n file: file.file,\n callback: (previewUrl) => handlePreviewUrlCallback(previewUrl, file),\n });\n });\n\n filesToUpload.forEach((file) => {\n setFileItems((prevState) =>\n prevState.map((prevFile) => {\n if (prevFile.id === file.id) {\n return { ...prevFile, state: 'uploading' };\n }\n return prevFile;\n }),\n );\n\n void uploadFile({\n fileToUpload: file,\n personId,\n accessToken,\n callback: (UploadedFile) => handleUploadFileCallback(file, UploadedFile),\n });\n });\n }, [accessToken, fileItems, handleUploadFileCallback, personId]);\n\n /**\n * This function formats and adds files to fileItems\n */\n const handleAddFiles = useCallback(\n (filesToAdd: File[]) => {\n const newFileItems: FileItem[] = [];\n\n filesToAdd.forEach((file) => {\n if (file && !filterDuplicateFile({ files: fileItems, newFile: file })) {\n newFileItems.push({\n id: uuidv4(),\n file,\n state: 'none',\n });\n }\n });\n\n setFileItems((prevState) => [...prevState, ...newFileItems]);\n },\n [fileItems],\n );\n\n /**\n * This function adds external files to fileItems\n */\n useEffect(() => {\n if (files) {\n const newFileItems: FileItem[] = [];\n\n files.forEach((file) => {\n newFileItems.push({\n id: uuidv4(),\n uploadedFile: file.uploadedFile,\n file: file.file,\n state: file.uploadedFile ? 'uploaded' : 'none',\n previewUrl: file.uploadedFile ? file.uploadedFile.url : undefined,\n });\n });\n\n setFileItems((prevState) => [...prevState, ...newFileItems]);\n }\n }, [files]);\n\n /**\n * This function deletes a selected file from the file list\n */\n const handleDeleteFile = useCallback(\n (id?: string) => {\n let fileToDelete: FileItem | undefined;\n\n const filteredFiles = fileItems.filter((file) => {\n const fileId = file.id;\n\n if (fileId === id) {\n fileToDelete = file;\n }\n\n return fileId !== id;\n });\n\n setFileItems(filteredFiles);\n\n if (!fileToDelete || typeof onRemove !== 'function') {\n return;\n }\n\n onRemove(fileToDelete);\n },\n [fileItems, onRemove],\n );\n\n /**\n * This function handles the drag and drop\n */\n const handleDrop = useCallback(\n (e: DragEvent<HTMLDivElement>) => {\n if (!allowDragAndDrop) {\n return;\n }\n\n e.preventDefault();\n const draggedFiles = Array.from(e.dataTransfer.files);\n\n handleAddFiles(draggedFiles);\n },\n [allowDragAndDrop, handleAddFiles],\n );\n\n /**\n * Opens the files in a slideShow\n */\n const openFiles = useCallback(\n (file: FileItem) => {\n const startIndex = fileItems.findIndex((item) => item.id === file.id);\n\n const items: OpenMediaItem[] = fileItems.map((item) => ({\n url: item.uploadedFile?.url.replace('_0.mp4', '.mp4') ?? '',\n mediaType:\n item.uploadedFile && 'thumbnailUrl' in item.uploadedFile\n ? MediaType.VIDEO\n : MediaType.IMAGE,\n }));\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n void openMedia({ items, startIndex });\n },\n [fileItems],\n );\n\n /**\n * Returns the ratio of the single file\n */\n const ratio = useMemo(() => {\n switch (fileItems.length) {\n case 0:\n return 0;\n case 1:\n return Math.max(fileItems[0]?.uploadedFile?.ratio ?? 1, 1);\n case 2:\n return 2;\n case 3:\n return 3;\n default:\n return 1;\n }\n }, [fileItems]);\n\n const galleryContent = useMemo(() => {\n const combinedFilesLength = fileItems.length;\n\n if (isEditMode) {\n const items = fileItems.map((file) => (\n <GalleryItem\n key={file.id}\n fileItem={file}\n isEditMode\n onClick={openFiles}\n handleDeleteFile={handleDeleteFile}\n />\n ));\n\n items.push(<AddFile key=\"add_file\" onAdd={handleAddFiles} />);\n\n return items;\n }\n\n const shortedFiles = fileItems.slice(0, 4);\n\n return shortedFiles.map((file, index) => {\n let imageRatio = 1;\n\n if (viewMode === GalleryViewMode.GRID) {\n if (combinedFilesLength === 2 && (index === 0 || index === 1)) {\n imageRatio = 0.5;\n } else if (\n (index === 0 && combinedFilesLength > 2) ||\n (combinedFilesLength === 3 && (index === 1 || index === 2))\n ) {\n imageRatio = 1.5;\n }\n }\n\n return (\n <GalleryItem\n key={file.id}\n fileItem={file}\n isEditMode={false}\n handleDeleteFile={handleDeleteFile}\n onClick={openFiles}\n ratio={imageRatio}\n remainingItemsLength={\n combinedFilesLength > 4 && index === 3 ? combinedFilesLength : undefined\n }\n />\n );\n });\n }, [fileItems, isEditMode, handleAddFiles, openFiles, handleDeleteFile, viewMode]);\n\n return useMemo(\n () => (\n <StyledGallery>\n {isEditMode ? (\n <StyledGalleryEditModeWrapper\n fileMinWidth={fileMinWidth}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => void handleDrop(e)}\n >\n {galleryContent}\n </StyledGalleryEditModeWrapper>\n ) : (\n <StyledGalleryItemWrapper\n ratio={ratio}\n uploadedFileLength={fileItems.length}\n viewMode={viewMode}\n >\n {galleryContent}\n </StyledGalleryItemWrapper>\n )}\n </StyledGallery>\n ),\n [isEditMode, fileMinWidth, galleryContent, ratio, fileItems.length, viewMode, handleDrop],\n );\n};\n\nGallery.displayName = 'Gallery';\n\nexport default Gallery;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,YAAA,GAAAD,sBAAA,CAAAR,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAI0B,SAAAQ,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wB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MAAA,CAAAW,OAAA,CAAAkG,aAAA,CAACrG,QAAA,CAAA+G,4BAA4B;IACzBnF,YAAY,EAAEA,YAAa;IAC3BoF,UAAU,EAAG3G,CAAC,IAAKA,CAAC,CAAC0E,cAAc,CAAC,CAAE;IACtCkC,MAAM,EAAG5G,CAAC,IAAK,KAAKyE,UAAU,CAACzE,CAAC;EAAE,GAEjC8F,cACyB,CAAC,gBAE/B3G,MAAA,CAAAW,OAAA,CAAAkG,aAAA,CAACrG,QAAA,CAAAkH,wBAAwB;IACrBnB,KAAK,EAAEA,KAAM;IACboB,kBAAkB,EAAE9E,SAAS,CAACgB,MAAO;IACrCnB,QAAQ,EAAEA;EAAS,GAElBiE,cACqB,CAEnB,CAClB,EACD,CAACxE,UAAU,EAAEC,YAAY,EAAEuE,cAAc,EAAEJ,KAAK,EAAE1D,SAAS,CAACgB,MAAM,EAAEnB,QAAQ,EAAE4C,UAAU,CAC5F,CAAC;AACL,CAAC;AAEDvD,OAAO,CAAC6F,WAAW,GAAG,SAAS;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnH,OAAA,GAEjBoB,OAAO"}
|
|
1
|
+
{"version":3,"file":"Gallery.js","names":["uploadFile","MediaType","openMedia","React","useCallback","useEffect","useMemo","useState","v4","uuidv4","GalleryViewMode","filterDuplicateFile","generatePreviewUrl","generateVideoThumbnail","AddFile","GalleryItem","StyledGallery","StyledGalleryEditModeWrapper","StyledGalleryItemWrapper","Gallery","_ref","accessToken","allowDragAndDrop","isEditMode","fileMinWidth","files","onAdd","onFileCountChange","onRemove","personId","viewMode","GRID","fileItems","setFileItems","handlePreviewUrlCallback","previewUrl","file","prevState","map","prevFile","id","handleUploadFileCallback","UploadedFile","uploadedFile","state","length","filesToGeneratePreview","filter","filesToUpload","forEach","type","includes","callback","fileToUpload","handleAddFiles","filesToAdd","newFileItems","newFile","push","url","undefined","handleDeleteFile","fileToDelete","filteredFiles","fileId","handleDrop","e","preventDefault","draggedFiles","Array","from","dataTransfer","openFiles","startIndex","findIndex","item","items","replace","mediaType","VIDEO","IMAGE","ratio","Math","max","galleryContent","combinedFilesLength","createElement","key","fileItem","onClick","shortedFiles","slice","index","imageRatio","remainingItemsLength","onDragOver","onDrop","uploadedFileLength","displayName"],"sources":["../../src/components/Gallery.tsx"],"sourcesContent":["import { uploadFile } from '@chayns-components/core';\nimport type { FileItem, Image, Video } from '@chayns-components/core/lib/types/file'; // TODO: Check why absolute import is needed\nimport { MediaType, openMedia, OpenMediaItem } from 'chayns-api';\nimport React, { DragEvent, FC, useCallback, useEffect, useMemo, useState } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport { GalleryViewMode } from '../types/gallery';\nimport { filterDuplicateFile, generatePreviewUrl, generateVideoThumbnail } from '../utils/file';\nimport AddFile from './add-file/AddFile';\nimport GalleryItem from './gallery-item/GalleryItem';\nimport {\n StyledGallery,\n StyledGalleryEditModeWrapper,\n StyledGalleryItemWrapper,\n} from './Gallery.styles';\n\nexport type GalleryProps = {\n /**\n * AccessToken of the user\n */\n accessToken: string;\n /**\n * Whether drag and drop is allowed or not\n */\n allowDragAndDrop?: boolean;\n /**\n * Whether images and videos can be edited\n */\n isEditMode?: boolean;\n /**\n * The minimum width of a file in the edit mode\n */\n fileMinWidth?: number;\n /**\n * Images and videos which should be displayed\n */\n files?: FileItem[];\n /**\n * Function to be executed when files are added and uploaded\n */\n onAdd?: (file: FileItem) => void;\n /**\n * Function to be executed when the count of files are changed. Needed to check if all files are uploaded\n */\n onFileCountChange?: (fileCount: number) => void;\n /**\n * Function to be executed when a file is removed\n */\n onRemove?: (file: FileItem) => void;\n /**\n * PersonId of the user\n */\n personId: string;\n /**\n * The mode how the images should be displayed.\n */\n viewMode?: GalleryViewMode;\n};\n\nconst Gallery: FC<GalleryProps> = ({\n accessToken,\n allowDragAndDrop = false,\n isEditMode = false,\n fileMinWidth = 100,\n files,\n onAdd,\n onFileCountChange,\n onRemove,\n personId,\n viewMode = GalleryViewMode.GRID,\n}) => {\n const [fileItems, setFileItems] = useState<FileItem[]>([]);\n\n /**\n * This function adds a previewUrl to fileItems\n */\n const handlePreviewUrlCallback = (previewUrl: string, file: FileItem) => {\n setFileItems((prevState) =>\n prevState.map((prevFile) => {\n if (prevFile.id === file.id) {\n return { ...prevFile, previewUrl };\n }\n return prevFile;\n }),\n );\n };\n\n /**\n * This function adds uploaded files to fileItems\n */\n const handleUploadFileCallback = useCallback(\n (file: FileItem, UploadedFile: Video | Image) => {\n setFileItems((prevState) =>\n prevState.map((prevFile) => {\n if (prevFile.id === file.id) {\n if (typeof onAdd === 'function') {\n onAdd({\n ...prevFile,\n uploadedFile: UploadedFile,\n state: 'uploaded',\n });\n }\n\n return {\n ...prevFile,\n uploadedFile: UploadedFile,\n state: 'uploaded',\n };\n }\n return prevFile;\n }),\n );\n },\n [onAdd],\n );\n\n /**\n * Returns the current count to check if all files are uploaded\n */\n useEffect(() => {\n if (typeof onFileCountChange === 'function') {\n onFileCountChange(fileItems.length);\n }\n }, [fileItems.length, onFileCountChange]);\n\n /**\n * Prepares files for previewUrl and upload\n */\n useEffect(() => {\n const filesToGeneratePreview = fileItems.filter(\n (file) => file.file && !file.previewUrl && (file.state === 'none' || !file.state),\n );\n\n const filesToUpload = fileItems.filter(\n (file) => !file.uploadedFile && file.state !== 'uploading',\n );\n\n filesToGeneratePreview.forEach((file) => {\n if (!file.file) {\n return;\n }\n\n if (file.file.type.includes('video/')) {\n generateVideoThumbnail({\n file: file.file,\n callback: (previewUrl) => handlePreviewUrlCallback(previewUrl, file),\n });\n\n return;\n }\n\n generatePreviewUrl({\n file: file.file,\n callback: (previewUrl) => handlePreviewUrlCallback(previewUrl, file),\n });\n });\n\n filesToUpload.forEach((file) => {\n setFileItems((prevState) =>\n prevState.map((prevFile) => {\n if (prevFile.id === file.id) {\n return { ...prevFile, state: 'uploading' };\n }\n return prevFile;\n }),\n );\n\n void uploadFile({\n fileToUpload: file,\n personId,\n accessToken,\n callback: (UploadedFile) => handleUploadFileCallback(file, UploadedFile),\n });\n });\n }, [accessToken, fileItems, handleUploadFileCallback, personId]);\n\n /**\n * This function formats and adds files to fileItems\n */\n const handleAddFiles = useCallback(\n (filesToAdd: File[]) => {\n const newFileItems: FileItem[] = [];\n\n filesToAdd.forEach((file) => {\n if (file && !filterDuplicateFile({ files: fileItems, newFile: file })) {\n newFileItems.push({\n id: uuidv4(),\n file,\n state: 'none',\n });\n }\n });\n\n setFileItems((prevState) => [...prevState, ...newFileItems]);\n },\n [fileItems],\n );\n\n /**\n * This function adds external files to fileItems\n */\n useEffect(() => {\n if (files) {\n const newFileItems: FileItem[] = [];\n\n files.forEach((file) => {\n newFileItems.push({\n id: uuidv4(),\n uploadedFile: file.uploadedFile,\n file: file.file,\n state: file.uploadedFile ? 'uploaded' : 'none',\n previewUrl: file.uploadedFile ? file.uploadedFile.url : undefined,\n });\n });\n\n setFileItems((prevState) => [...prevState, ...newFileItems]);\n }\n }, [files]);\n\n /**\n * This function deletes a selected file from the file list\n */\n const handleDeleteFile = useCallback(\n (id?: string) => {\n let fileToDelete: FileItem | undefined;\n\n const filteredFiles = fileItems.filter((file) => {\n const fileId = file.id;\n\n if (fileId === id) {\n fileToDelete = file;\n }\n\n return fileId !== id;\n });\n\n setFileItems(filteredFiles);\n\n if (!fileToDelete || typeof onRemove !== 'function') {\n return;\n }\n\n onRemove(fileToDelete);\n },\n [fileItems, onRemove],\n );\n\n /**\n * This function handles the drag and drop\n */\n const handleDrop = useCallback(\n (e: DragEvent<HTMLDivElement>) => {\n if (!allowDragAndDrop) {\n return;\n }\n\n e.preventDefault();\n const draggedFiles = Array.from(e.dataTransfer.files);\n\n handleAddFiles(draggedFiles);\n },\n [allowDragAndDrop, handleAddFiles],\n );\n\n /**\n * Opens the files in a slideShow\n */\n const openFiles = useCallback(\n (file: FileItem) => {\n const startIndex = fileItems.findIndex((item) => item.id === file.id);\n\n const items: OpenMediaItem[] = fileItems.map((item) => ({\n url: item.uploadedFile?.url.replace('_0.mp4', '.mp4') ?? '',\n mediaType:\n item.uploadedFile && 'thumbnailUrl' in item.uploadedFile\n ? MediaType.VIDEO\n : MediaType.IMAGE,\n }));\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n void openMedia({ items, startIndex });\n },\n [fileItems],\n );\n\n /**\n * Returns the ratio of the single file\n */\n const ratio = useMemo(() => {\n switch (fileItems.length) {\n case 0:\n return 0;\n case 1:\n return Math.max(fileItems[0]?.uploadedFile?.ratio ?? 1, 1);\n case 2:\n return 2;\n case 3:\n return 3;\n default:\n return 1;\n }\n }, [fileItems]);\n\n const galleryContent = useMemo(() => {\n const combinedFilesLength = fileItems.length;\n\n if (isEditMode) {\n const items = fileItems.map((file) => (\n <GalleryItem\n key={file.id}\n fileItem={file}\n isEditMode\n onClick={openFiles}\n handleDeleteFile={handleDeleteFile}\n />\n ));\n\n items.push(<AddFile key=\"add_file\" onAdd={handleAddFiles} />);\n\n return items;\n }\n\n const shortedFiles = fileItems.slice(0, 4);\n\n return shortedFiles.map((file, index) => {\n let imageRatio = 1;\n\n if (viewMode === GalleryViewMode.GRID) {\n if (combinedFilesLength === 2 && (index === 0 || index === 1)) {\n imageRatio = 0.5;\n } else if (\n (index === 0 && combinedFilesLength > 2) ||\n (combinedFilesLength === 3 && (index === 1 || index === 2))\n ) {\n imageRatio = 1.5;\n }\n }\n\n return (\n <GalleryItem\n key={file.id}\n fileItem={file}\n isEditMode={false}\n handleDeleteFile={handleDeleteFile}\n onClick={openFiles}\n ratio={imageRatio}\n remainingItemsLength={\n combinedFilesLength > 4 && index === 3 ? combinedFilesLength : undefined\n }\n />\n );\n });\n }, [fileItems, isEditMode, handleAddFiles, openFiles, handleDeleteFile, viewMode]);\n\n return useMemo(\n () => (\n <StyledGallery>\n {isEditMode ? (\n <StyledGalleryEditModeWrapper\n fileMinWidth={fileMinWidth}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => void handleDrop(e)}\n >\n {galleryContent}\n </StyledGalleryEditModeWrapper>\n ) : (\n <StyledGalleryItemWrapper\n ratio={ratio}\n uploadedFileLength={fileItems.length}\n viewMode={viewMode}\n >\n {galleryContent}\n </StyledGalleryItemWrapper>\n )}\n </StyledGallery>\n ),\n [isEditMode, fileMinWidth, galleryContent, ratio, fileItems.length, viewMode, handleDrop],\n );\n};\n\nGallery.displayName = 'Gallery';\n\nexport default Gallery;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,yBAAyB;AACkC;AACtF,SAASC,SAAS,EAAEC,SAAS,QAAuB,YAAY;AAChE,OAAOC,KAAK,IAAmBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACvF,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,mBAAmB,EAAEC,kBAAkB,EAAEC,sBAAsB,QAAQ,eAAe;AAC/F,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,WAAW,MAAM,4BAA4B;AACpD,SACIC,aAAa,EACbC,4BAA4B,EAC5BC,wBAAwB,QACrB,kBAAkB;AA6CzB,MAAMC,OAAyB,GAAGC,IAAA,IAW5B;EAAA,IAX6B;IAC/BC,WAAW;IACXC,gBAAgB,GAAG,KAAK;IACxBC,UAAU,GAAG,KAAK;IAClBC,YAAY,GAAG,GAAG;IAClBC,KAAK;IACLC,KAAK;IACLC,iBAAiB;IACjBC,QAAQ;IACRC,QAAQ;IACRC,QAAQ,GAAGpB,eAAe,CAACqB;EAC/B,CAAC,GAAAX,IAAA;EACG,MAAM,CAACY,SAAS,EAAEC,YAAY,CAAC,GAAG1B,QAAQ,CAAa,EAAE,CAAC;;EAE1D;AACJ;AACA;EACI,MAAM2B,wBAAwB,GAAGA,CAACC,UAAkB,EAAEC,IAAc,KAAK;IACrEH,YAAY,CAAEI,SAAS,IACnBA,SAAS,CAACC,GAAG,CAAEC,QAAQ,IAAK;MACxB,IAAIA,QAAQ,CAACC,EAAE,KAAKJ,I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+D,KAAK,EAAEA,KAAM;IACbgB,kBAAkB,EAAEjE,SAAS,CAACa,MAAO;IACrCf,QAAQ,EAAEA;EAAS,GAElBsD,cACqB,CAEnB,CAClB,EACD,CAAC7D,UAAU,EAAEC,YAAY,EAAE4D,cAAc,EAAEH,KAAK,EAAEjD,SAAS,CAACa,MAAM,EAAEf,QAAQ,EAAEmC,UAAU,CAC5F,CAAC;AACL,CAAC;AAED9C,OAAO,CAAC+E,WAAW,GAAG,SAAS;AAE/B,eAAe/E,OAAO"}
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.StyledGalleryItemWrapper = exports.StyledGalleryEditModeWrapper = exports.StyledGallery = void 0;
|
|
7
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
-
var _gallery = require("../types/gallery");
|
|
9
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
-
const StyledGallery = exports.StyledGallery = _styledComponents.default.div``;
|
|
12
|
-
const StyledGalleryItemWrapper = exports.StyledGalleryItemWrapper = _styledComponents.default.div`
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { GalleryViewMode } from '../types/gallery';
|
|
3
|
+
export const StyledGallery = styled.div``;
|
|
4
|
+
export const StyledGalleryItemWrapper = styled.div`
|
|
13
5
|
display: grid;
|
|
14
6
|
gap: 5px;
|
|
15
7
|
|
|
@@ -18,8 +10,8 @@ const StyledGalleryItemWrapper = exports.StyledGalleryItemWrapper = _styledCompo
|
|
|
18
10
|
viewMode,
|
|
19
11
|
uploadedFileLength
|
|
20
12
|
} = _ref;
|
|
21
|
-
if (viewMode ===
|
|
22
|
-
return
|
|
13
|
+
if (viewMode === GalleryViewMode.GRID) {
|
|
14
|
+
return css`
|
|
23
15
|
> div:first-child {
|
|
24
16
|
grid-column: 1 / -1;
|
|
25
17
|
}
|
|
@@ -27,25 +19,25 @@ const StyledGalleryItemWrapper = exports.StyledGalleryItemWrapper = _styledCompo
|
|
|
27
19
|
${() => {
|
|
28
20
|
switch (uploadedFileLength) {
|
|
29
21
|
case 1:
|
|
30
|
-
return
|
|
22
|
+
return css`
|
|
31
23
|
grid-template-columns: 1fr;
|
|
32
24
|
`;
|
|
33
25
|
case 2:
|
|
34
|
-
return
|
|
26
|
+
return css`
|
|
35
27
|
grid-template-columns: repeat(2, 1fr);
|
|
36
28
|
> div:first-child {
|
|
37
29
|
grid-column: span 1;
|
|
38
30
|
}
|
|
39
31
|
`;
|
|
40
32
|
case 3:
|
|
41
|
-
return
|
|
33
|
+
return css`
|
|
42
34
|
grid-template-columns: repeat(2, 1fr);
|
|
43
35
|
> div:first-child {
|
|
44
36
|
grid-column: span 2;
|
|
45
37
|
}
|
|
46
38
|
`;
|
|
47
39
|
default:
|
|
48
|
-
return
|
|
40
|
+
return css`
|
|
49
41
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
50
42
|
> div:not(:first-child) {
|
|
51
43
|
grid-column: span 1;
|
|
@@ -57,19 +49,19 @@ const StyledGalleryItemWrapper = exports.StyledGalleryItemWrapper = _styledCompo
|
|
|
57
49
|
}
|
|
58
50
|
switch (uploadedFileLength) {
|
|
59
51
|
case 1:
|
|
60
|
-
return
|
|
52
|
+
return css`
|
|
61
53
|
grid-template-columns: 1fr;
|
|
62
54
|
`;
|
|
63
55
|
case 2:
|
|
64
|
-
return
|
|
56
|
+
return css`
|
|
65
57
|
grid-template-columns: repeat(2, 1fr);
|
|
66
58
|
`;
|
|
67
59
|
case 3:
|
|
68
|
-
return
|
|
60
|
+
return css`
|
|
69
61
|
grid-template-columns: repeat(3, 1fr);
|
|
70
62
|
`;
|
|
71
63
|
default:
|
|
72
|
-
return
|
|
64
|
+
return css`
|
|
73
65
|
grid-template-columns: repeat(2, 1fr);
|
|
74
66
|
> div:nth-child(-n + 2) {
|
|
75
67
|
grid-row: 1;
|
|
@@ -85,7 +77,7 @@ const StyledGalleryItemWrapper = exports.StyledGalleryItemWrapper = _styledCompo
|
|
|
85
77
|
return ratio;
|
|
86
78
|
}};
|
|
87
79
|
`;
|
|
88
|
-
const StyledGalleryEditModeWrapper =
|
|
80
|
+
export const StyledGalleryEditModeWrapper = styled.div`
|
|
89
81
|
display: grid;
|
|
90
82
|
grid-template-columns: ${_ref3 => {
|
|
91
83
|
let {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gallery.styles.js","names":["
|
|
1
|
+
{"version":3,"file":"Gallery.styles.js","names":["styled","css","GalleryViewMode","StyledGallery","div","StyledGalleryItemWrapper","_ref","viewMode","uploadedFileLength","GRID","_ref2","ratio","StyledGalleryEditModeWrapper","_ref3","fileMinWidth"],"sources":["../../src/components/Gallery.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { GalleryViewMode } from '../types/gallery';\n\nexport const StyledGallery = styled.div``;\n\nexport const StyledGalleryItemWrapper = styled.div<{\n uploadedFileLength: number;\n ratio: number;\n viewMode: GalleryViewMode;\n}>`\n display: grid;\n gap: 5px;\n\n ${({ viewMode, uploadedFileLength }) => {\n if (viewMode === GalleryViewMode.GRID) {\n return css`\n > div:first-child {\n grid-column: 1 / -1;\n }\n\n ${() => {\n switch (uploadedFileLength) {\n case 1:\n return css`\n grid-template-columns: 1fr;\n `;\n case 2:\n return css`\n grid-template-columns: repeat(2, 1fr);\n > div:first-child {\n grid-column: span 1;\n }\n `;\n case 3:\n return css`\n grid-template-columns: repeat(2, 1fr);\n > div:first-child {\n grid-column: span 2;\n }\n `;\n default:\n return css`\n grid-template-columns: repeat(3, minmax(0, 1fr));\n > div:not(:first-child) {\n grid-column: span 1;\n }\n `;\n }\n }}\n `;\n }\n\n switch (uploadedFileLength) {\n case 1:\n return css`\n grid-template-columns: 1fr;\n `;\n case 2:\n return css`\n grid-template-columns: repeat(2, 1fr);\n `;\n case 3:\n return css`\n grid-template-columns: repeat(3, 1fr);\n `;\n default:\n return css`\n grid-template-columns: repeat(2, 1fr);\n > div:nth-child(-n + 2) {\n grid-row: 1;\n }\n `;\n }\n }}\n\n aspect-ratio: ${({ ratio }) => ratio};\n`;\n\nexport const StyledGalleryEditModeWrapper = styled.div<{\n fileMinWidth: number;\n}>`\n display: grid;\n grid-template-columns: ${({ fileMinWidth }) =>\n `repeat(auto-fill, minmax(${fileMinWidth}px, 1fr))`};\n grid-auto-rows: 1fr;\n gap: 6px;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAC/C,SAASC,eAAe,QAAQ,kBAAkB;AAElD,OAAO,MAAMC,aAAa,GAAGH,MAAM,CAACI,GAAI,EAAC;AAEzC,OAAO,MAAMC,wBAAwB,GAAGL,MAAM,CAACI,GAI5C;AACH;AACA;AACA;AACA,MAAME,IAAA,IAAsC;EAAA,IAArC;IAAEC,QAAQ;IAAEC;EAAmB,CAAC,GAAAF,IAAA;EAC/B,IAAIC,QAAQ,KAAKL,eAAe,CAACO,IAAI,EAAE;IACnC,OAAOR,GAAI;AACvB;AACA;AACA;AACA;AACA,kBAAkB,MAAM;MACJ,QAAQO,kBAAkB;QACtB,KAAK,CAAC;UACF,OAAOP,GAAI;AACvC;AACA,6BAA6B;QACL,KAAK,CAAC;UACF,OAAOA,GAAI;AACvC;AACA;AACA;AACA;AACA,6BAA6B;QACL,KAAK,CAAC;UACF,OAAOA,GAAI;AACvC;AACA;AACA;AACA;AACA,6BAA6B;QACL;UACI,OAAOA,GAAI;AACvC;AACA;AACA;AACA;AACA,6BAA6B;MACT;IACJ,CAAE;AAClB,aAAa;EACL;EAEA,QAAQO,kBAAkB;IACtB,KAAK,CAAC;MACF,OAAOP,GAAI;AAC3B;AACA,iBAAiB;IACL,KAAK,CAAC;MACF,OAAOA,GAAI;AAC3B;AACA,iBAAiB;IACL,KAAK,CAAC;MACF,OAAOA,GAAI;AAC3B;AACA,iBAAiB;IACL;MACI,OAAOA,GAAI;AAC3B;AACA;AACA;AACA;AACA,iBAAiB;EACT;AACJ,CAAE;AACN;AACA,oBAAoBS,KAAA;EAAA,IAAC;IAAEC;EAAM,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK;AAAA,CAAC;AACzC,CAAC;AAED,OAAO,MAAMC,4BAA4B,GAAGZ,MAAM,CAACI,GAEhD;AACH;AACA,6BAA6BS,KAAA;EAAA,IAAC;IAAEC;EAAa,CAAC,GAAAD,KAAA;EAAA,OACrC,4BAA2BC,YAAa,WAAU;AAAA,CAAC;AAC5D;AACA;AACA,CAAC"}
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _core = require("@chayns-components/core");
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _AddFile = require("./AddFile.styles");
|
|
10
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
import { Icon, selectFiles } from '@chayns-components/core';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { StyledAddFile, StyledAddFIleIconWrapper } from './AddFile.styles';
|
|
12
4
|
const AddFile = _ref => {
|
|
13
5
|
let {
|
|
14
6
|
onAdd
|
|
15
7
|
} = _ref;
|
|
16
|
-
const openSelectDialog =
|
|
17
|
-
const files = await
|
|
8
|
+
const openSelectDialog = useCallback(async () => {
|
|
9
|
+
const files = await selectFiles({
|
|
18
10
|
multiple: true,
|
|
19
11
|
type: 'image/*, video/*'
|
|
20
12
|
});
|
|
21
13
|
onAdd(files);
|
|
22
14
|
}, [onAdd]);
|
|
23
|
-
return /*#__PURE__*/
|
|
15
|
+
return /*#__PURE__*/React.createElement(StyledAddFile, {
|
|
24
16
|
key: "addButton"
|
|
25
|
-
}, /*#__PURE__*/
|
|
17
|
+
}, /*#__PURE__*/React.createElement(StyledAddFIleIconWrapper, {
|
|
26
18
|
onClick: () => void openSelectDialog()
|
|
27
|
-
}, /*#__PURE__*/
|
|
19
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
28
20
|
size: 40,
|
|
29
21
|
icons: ['fa fa-plus']
|
|
30
22
|
})));
|
|
31
23
|
};
|
|
32
24
|
AddFile.displayName = 'AddFile';
|
|
33
|
-
|
|
25
|
+
export default AddFile;
|
|
34
26
|
//# sourceMappingURL=AddFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddFile.js","names":["
|
|
1
|
+
{"version":3,"file":"AddFile.js","names":["Icon","selectFiles","React","useCallback","StyledAddFile","StyledAddFIleIconWrapper","AddFile","_ref","onAdd","openSelectDialog","files","multiple","type","createElement","key","onClick","size","icons","displayName"],"sources":["../../../src/components/add-file/AddFile.tsx"],"sourcesContent":["import { Icon, selectFiles } from '@chayns-components/core';\nimport React, { FC, useCallback } from 'react';\nimport { StyledAddFile, StyledAddFIleIconWrapper } from './AddFile.styles';\n\nexport type AddFileProps = {\n /**\n * Function to be executed when files are added\n */\n onAdd: (files: File[]) => void;\n};\n\nconst AddFile: FC<AddFileProps> = ({ onAdd }) => {\n const openSelectDialog = useCallback(async () => {\n const files = await selectFiles({\n multiple: true,\n type: 'image/*, video/*',\n });\n\n onAdd(files);\n }, [onAdd]);\n\n return (\n <StyledAddFile key=\"addButton\">\n <StyledAddFIleIconWrapper onClick={() => void openSelectDialog()}>\n <Icon size={40} icons={['fa fa-plus']} />\n </StyledAddFIleIconWrapper>\n </StyledAddFile>\n );\n};\n\nAddFile.displayName = 'AddFile';\n\nexport default AddFile;\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,WAAW,QAAQ,yBAAyB;AAC3D,OAAOC,KAAK,IAAQC,WAAW,QAAQ,OAAO;AAC9C,SAASC,aAAa,EAAEC,wBAAwB,QAAQ,kBAAkB;AAS1E,MAAMC,OAAyB,GAAGC,IAAA,IAAe;EAAA,IAAd;IAAEC;EAAM,CAAC,GAAAD,IAAA;EACxC,MAAME,gBAAgB,GAAGN,WAAW,CAAC,YAAY;IAC7C,MAAMO,KAAK,GAAG,MAAMT,WAAW,CAAC;MAC5BU,QAAQ,EAAE,IAAI;MACdC,IAAI,EAAE;IACV,CAAC,CAAC;IAEFJ,KAAK,CAACE,KAAK,CAAC;EAChB,CAAC,EAAE,CAACF,KAAK,CAAC,CAAC;EAEX,oBACIN,KAAA,CAAAW,aAAA,CAACT,aAAa;IAACU,GAAG,EAAC;EAAW,gBAC1BZ,KAAA,CAAAW,aAAA,CAACR,wBAAwB;IAACU,OAAO,EAAEA,CAAA,KAAM,KAAKN,gBAAgB,CAAC;EAAE,gBAC7DP,KAAA,CAAAW,aAAA,CAACb,IAAI;IAACgB,IAAI,EAAE,EAAG;IAACC,KAAK,EAAE,CAAC,YAAY;EAAE,CAAE,CAClB,CACf,CAAC;AAExB,CAAC;AAEDX,OAAO,CAACY,WAAW,GAAG,SAAS;AAE/B,eAAeZ,OAAO"}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StyledAddFile = exports.StyledAddFIleIconWrapper = void 0;
|
|
7
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
const StyledAddFile = exports.StyledAddFile = _styledComponents.default.div`
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const StyledAddFile = styled.div`
|
|
10
3
|
position: relative;
|
|
11
4
|
`;
|
|
12
|
-
const StyledAddFIleIconWrapper =
|
|
5
|
+
export const StyledAddFIleIconWrapper = styled.button`
|
|
13
6
|
background-color: ${_ref => {
|
|
14
7
|
let {
|
|
15
8
|
theme
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddFile.styles.js","names":["
|
|
1
|
+
{"version":3,"file":"AddFile.styles.js","names":["styled","StyledAddFile","div","StyledAddFIleIconWrapper","button","_ref","theme","_ref2"],"sources":["../../../src/components/add-file/AddFile.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\nexport const StyledAddFile = styled.div`\n position: relative;\n`;\n\ntype StyledAddFIleIconWrapperProps = WithTheme<unknown>;\n\nexport const StyledAddFIleIconWrapper = styled.button<StyledAddFIleIconWrapperProps>`\n background-color: ${({ theme }: StyledAddFIleIconWrapperProps) => theme['101']};\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledAddFIleIconWrapperProps) => theme['009-rgb']}, 0.08) inset;\n width: 100%;\n aspect-ratio: 1 / 1;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,aAAa,GAAGD,MAAM,CAACE,GAAI;AACxC;AACA,CAAC;AAID,OAAO,MAAMC,wBAAwB,GAAGH,MAAM,CAACI,MAAsC;AACrF,wBAAwBC,IAAA;EAAA,IAAC;IAAEC;EAAqC,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AACnF;AACA,eAAeC,KAAA;EAAA,IAAC;IAAED;EAAqC,CAAC,GAAAC,KAAA;EAAA,OAAKD,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AAC9E;AACA;AACA,CAAC"}
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _core = require("@chayns-components/core");
|
|
8
|
-
var _framerMotion = require("framer-motion");
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _GalleryItem = require("./GalleryItem.styles");
|
|
11
|
-
var _MediaItem = _interopRequireDefault(require("./media-item/MediaItem"));
|
|
12
|
-
var _PreviewItem = _interopRequireDefault(require("./preview-item/PreviewItem"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
import { Icon } from '@chayns-components/core';
|
|
2
|
+
import { AnimatePresence } from 'framer-motion';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { StyledGalleryItem, StyledGalleryItemDeleteButton, StyledGalleryItemMoreItemsIndicator } from './GalleryItem.styles';
|
|
5
|
+
import MediaItem from './media-item/MediaItem';
|
|
6
|
+
import PreviewItem from './preview-item/PreviewItem';
|
|
16
7
|
const GalleryItem = _ref => {
|
|
17
8
|
let {
|
|
18
9
|
fileItem,
|
|
@@ -22,25 +13,25 @@ const GalleryItem = _ref => {
|
|
|
22
13
|
remainingItemsLength,
|
|
23
14
|
onClick
|
|
24
15
|
} = _ref;
|
|
25
|
-
return
|
|
16
|
+
return useMemo(() => /*#__PURE__*/React.createElement(StyledGalleryItem, null, isEditMode && /*#__PURE__*/React.createElement(StyledGalleryItemDeleteButton, {
|
|
26
17
|
onClick: () => handleDeleteFile(fileItem.id)
|
|
27
|
-
}, /*#__PURE__*/
|
|
18
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
28
19
|
size: 20,
|
|
29
20
|
icons: ['ts-wrong']
|
|
30
|
-
})), !fileItem.state || fileItem.state === 'none' || !fileItem.previewUrl && !fileItem.uploadedFile ? null : /*#__PURE__*/
|
|
21
|
+
})), !fileItem.state || fileItem.state === 'none' || !fileItem.previewUrl && !fileItem.uploadedFile ? null : /*#__PURE__*/React.createElement(AnimatePresence, {
|
|
31
22
|
initial: false
|
|
32
|
-
}, fileItem.state === 'uploading' ? /*#__PURE__*/
|
|
23
|
+
}, fileItem.state === 'uploading' ? /*#__PURE__*/React.createElement(PreviewItem, {
|
|
33
24
|
ratio: ratio,
|
|
34
25
|
key: `uploading_${fileItem.id ?? ''}`,
|
|
35
26
|
fileItem: fileItem
|
|
36
|
-
}) : /*#__PURE__*/
|
|
27
|
+
}) : /*#__PURE__*/React.createElement(MediaItem, {
|
|
37
28
|
key: `uploaded_${fileItem.id ?? ''}`,
|
|
38
29
|
fileItem: fileItem,
|
|
39
30
|
isEditMode: isEditMode,
|
|
40
31
|
ratio: ratio,
|
|
41
32
|
openSelectedFile: onClick
|
|
42
|
-
})), remainingItemsLength && /*#__PURE__*/
|
|
33
|
+
})), remainingItemsLength && /*#__PURE__*/React.createElement(StyledGalleryItemMoreItemsIndicator, null, /*#__PURE__*/React.createElement("p", null, `+ ${remainingItemsLength - 3}`))), [fileItem, handleDeleteFile, isEditMode, onClick, ratio, remainingItemsLength]);
|
|
43
34
|
};
|
|
44
35
|
GalleryItem.displayName = 'GalleryItem';
|
|
45
|
-
|
|
36
|
+
export default GalleryItem;
|
|
46
37
|
//# sourceMappingURL=GalleryItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryItem.js","names":["
|
|
1
|
+
{"version":3,"file":"GalleryItem.js","names":["Icon","AnimatePresence","React","useMemo","StyledGalleryItem","StyledGalleryItemDeleteButton","StyledGalleryItemMoreItemsIndicator","MediaItem","PreviewItem","GalleryItem","_ref","fileItem","handleDeleteFile","isEditMode","ratio","remainingItemsLength","onClick","createElement","id","size","icons","state","previewUrl","uploadedFile","initial","key","openSelectedFile","displayName"],"sources":["../../../src/components/gallery-item/GalleryItem.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\nimport type { FileItem } from '@chayns-components/core/lib/types/file';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, useMemo } from 'react';\nimport {\n StyledGalleryItem,\n StyledGalleryItemDeleteButton,\n StyledGalleryItemMoreItemsIndicator,\n} from './GalleryItem.styles';\nimport MediaItem from './media-item/MediaItem';\nimport PreviewItem from './preview-item/PreviewItem';\n\nexport type GalleryItemProps = {\n /**\n * Images and videos which should be displayed\n */\n fileItem: FileItem;\n /**\n * Whether images and videos can be edited\n */\n isEditMode: boolean;\n /**\n * Function to be executed when a file is deleted\n */\n handleDeleteFile: (id?: string) => void;\n /**\n * The ratio of the image\n */\n ratio?: number;\n /**\n * Length of the uploaded files\n */\n remainingItemsLength?: number;\n /**\n * Function to be executed if a file should be opened\n */\n onClick: (file: FileItem) => void;\n};\n\nconst GalleryItem: FC<GalleryItemProps> = ({\n fileItem,\n handleDeleteFile,\n isEditMode,\n ratio = 1,\n remainingItemsLength,\n onClick,\n}) =>\n useMemo(\n () => (\n <StyledGalleryItem>\n {isEditMode && (\n <StyledGalleryItemDeleteButton onClick={() => handleDeleteFile(fileItem.id)}>\n <Icon size={20} icons={['ts-wrong']} />\n </StyledGalleryItemDeleteButton>\n )}\n {!fileItem.state ||\n fileItem.state === 'none' ||\n (!fileItem.previewUrl && !fileItem.uploadedFile) ? null : (\n <AnimatePresence initial={false}>\n {fileItem.state === 'uploading' ? (\n <PreviewItem\n ratio={ratio}\n key={`uploading_${fileItem.id ?? ''}`}\n fileItem={fileItem}\n />\n ) : (\n <MediaItem\n key={`uploaded_${fileItem.id ?? ''}`}\n fileItem={fileItem}\n isEditMode={isEditMode}\n ratio={ratio}\n openSelectedFile={onClick}\n />\n )}\n </AnimatePresence>\n )}\n {remainingItemsLength && (\n <StyledGalleryItemMoreItemsIndicator>\n <p>{`+ ${remainingItemsLength - 3}`}</p>\n </StyledGalleryItemMoreItemsIndicator>\n )}\n </StyledGalleryItem>\n ),\n [fileItem, handleDeleteFile, isEditMode, onClick, ratio, remainingItemsLength],\n );\n\nGalleryItem.displayName = 'GalleryItem';\n\nexport default GalleryItem;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,yBAAyB;AAE9C,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAAQC,OAAO,QAAQ,OAAO;AAC1C,SACIC,iBAAiB,EACjBC,6BAA6B,EAC7BC,mCAAmC,QAChC,sBAAsB;AAC7B,OAAOC,SAAS,MAAM,wBAAwB;AAC9C,OAAOC,WAAW,MAAM,4BAA4B;AA6BpD,MAAMC,WAAiC,GAAGC,IAAA;EAAA,IAA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J,QAAQ,EAAEC,gBAAgB,EAAEC,UAAU,EAAEG,OAAO,EAAEF,KAAK,EAAEC,oBAAoB,CACjF,CAAC;AAAA;AAELN,WAAW,CAACkB,WAAW,GAAG,aAAa;AAEvC,eAAelB,WAAW"}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StyledGalleryItemMoreItemsIndicator = exports.StyledGalleryItemDeleteButton = exports.StyledGalleryItem = void 0;
|
|
7
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
const StyledGalleryItem = exports.StyledGalleryItem = _styledComponents.default.div`
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const StyledGalleryItem = styled.div`
|
|
10
3
|
display: flex;
|
|
11
4
|
position: relative;
|
|
12
5
|
height: 100%;
|
|
13
6
|
width: 100%;
|
|
14
7
|
`;
|
|
15
|
-
const StyledGalleryItemDeleteButton =
|
|
8
|
+
export const StyledGalleryItemDeleteButton = styled.button`
|
|
16
9
|
background-color: rgba(
|
|
17
10
|
${_ref => {
|
|
18
11
|
let {
|
|
@@ -39,7 +32,7 @@ const StyledGalleryItemDeleteButton = exports.StyledGalleryItemDeleteButton = _s
|
|
|
39
32
|
justify-content: center;
|
|
40
33
|
align-items: center;
|
|
41
34
|
`;
|
|
42
|
-
const StyledGalleryItemMoreItemsIndicator =
|
|
35
|
+
export const StyledGalleryItemMoreItemsIndicator = styled.div`
|
|
43
36
|
position: absolute;
|
|
44
37
|
z-index: 2;
|
|
45
38
|
height: 100%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryItem.styles.js","names":["
|
|
1
|
+
{"version":3,"file":"GalleryItem.styles.js","names":["styled","StyledGalleryItem","div","StyledGalleryItemDeleteButton","button","_ref","theme","_ref2","StyledGalleryItemMoreItemsIndicator"],"sources":["../../../src/components/gallery-item/GalleryItem.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\nexport const StyledGalleryItem = styled.div`\n display: flex;\n position: relative;\n height: 100%;\n width: 100%;\n`;\n\ntype StyledGalleryItemDeleteButtonProps = WithTheme<unknown>;\n\nexport const StyledGalleryItemDeleteButton = styled.button<StyledGalleryItemDeleteButtonProps>`\n background-color: rgba(\n ${({ theme }: StyledGalleryItemDeleteButtonProps) => theme['000-rgb']},\n 0.75\n );\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledGalleryItemDeleteButtonProps) => theme['009-rgb']}, 0.08) inset;\n position: absolute;\n top: 0;\n right: 0;\n z-index: 2;\n height: 30px;\n width: 30px;\n display: flex;\n justify-content: center;\n align-items: center;\n`;\n\nexport const StyledGalleryItemMoreItemsIndicator = styled.div`\n position: absolute;\n z-index: 2;\n height: 100%;\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n backdrop-filter: brightness(40%);\n\n p {\n font-size: 40px;\n color: white;\n }\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,iBAAiB,GAAGD,MAAM,CAACE,GAAI;AAC5C;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,6BAA6B,GAAGH,MAAM,CAACI,MAA2C;AAC/F;AACA,UAAUC,IAAA;EAAA,IAAC;IAAEC;EAA0C,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AAC9E;AACA;AACA;AACA,eAAeC,KAAA;EAAA,IAAC;IAAED;EAA0C,CAAC,GAAAC,KAAA;EAAA,OAAKD,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AACnF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,mCAAmC,GAAGR,MAAM,CAACE,GAAI;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _core = require("@chayns-components/core");
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _MediaItem = require("./MediaItem.styles");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import { Icon } from '@chayns-components/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StyledMediaItemImage, StyledMediaItemImageWrapper, StyledMediaItemPlayIcon, StyledMediaItemVideo, StyledMediaItemVideoWrapper, StyledMotionMediaItem } from './MediaItem.styles';
|
|
11
4
|
const MediaItem = _ref => {
|
|
12
5
|
let {
|
|
13
6
|
fileItem,
|
|
@@ -15,7 +8,7 @@ const MediaItem = _ref => {
|
|
|
15
8
|
openSelectedFile,
|
|
16
9
|
ratio
|
|
17
10
|
} = _ref;
|
|
18
|
-
return /*#__PURE__*/
|
|
11
|
+
return /*#__PURE__*/React.createElement(StyledMotionMediaItem, {
|
|
19
12
|
animate: {
|
|
20
13
|
opacity: 1
|
|
21
14
|
},
|
|
@@ -28,25 +21,25 @@ const MediaItem = _ref => {
|
|
|
28
21
|
transition: {
|
|
29
22
|
duration: 3.2
|
|
30
23
|
}
|
|
31
|
-
}, fileItem.uploadedFile && 'thumbnailUrl' in fileItem.uploadedFile ? /*#__PURE__*/
|
|
24
|
+
}, fileItem.uploadedFile && 'thumbnailUrl' in fileItem.uploadedFile ? /*#__PURE__*/React.createElement(StyledMediaItemVideoWrapper, {
|
|
32
25
|
onClick: () => openSelectedFile(fileItem),
|
|
33
26
|
ratio: ratio
|
|
34
|
-
}, /*#__PURE__*/
|
|
27
|
+
}, /*#__PURE__*/React.createElement(StyledMediaItemPlayIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
35
28
|
size: isEditMode ? 30 : 50,
|
|
36
29
|
icons: ['fa fa-play']
|
|
37
|
-
})), /*#__PURE__*/
|
|
30
|
+
})), /*#__PURE__*/React.createElement(StyledMediaItemVideo, {
|
|
38
31
|
poster: fileItem.uploadedFile.thumbnailUrl
|
|
39
|
-
}, /*#__PURE__*/
|
|
32
|
+
}, /*#__PURE__*/React.createElement("source", {
|
|
40
33
|
src: fileItem.uploadedFile.url,
|
|
41
34
|
type: "video/mp4"
|
|
42
|
-
}))) : /*#__PURE__*/
|
|
35
|
+
}))) : /*#__PURE__*/React.createElement(StyledMediaItemImageWrapper, {
|
|
43
36
|
onClick: () => openSelectedFile(fileItem),
|
|
44
37
|
ratio: ratio
|
|
45
|
-
}, /*#__PURE__*/
|
|
38
|
+
}, /*#__PURE__*/React.createElement(StyledMediaItemImage, {
|
|
46
39
|
draggable: false,
|
|
47
40
|
src: fileItem.uploadedFile?.url
|
|
48
41
|
})));
|
|
49
42
|
};
|
|
50
43
|
MediaItem.displayName = 'MediaItem';
|
|
51
|
-
|
|
44
|
+
export default MediaItem;
|
|
52
45
|
//# sourceMappingURL=MediaItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaItem.js","names":["
|
|
1
|
+
{"version":3,"file":"MediaItem.js","names":["Icon","React","StyledMediaItemImage","StyledMediaItemImageWrapper","StyledMediaItemPlayIcon","StyledMediaItemVideo","StyledMediaItemVideoWrapper","StyledMotionMediaItem","MediaItem","_ref","fileItem","isEditMode","openSelectedFile","ratio","createElement","animate","opacity","initial","exit","transition","duration","uploadedFile","onClick","size","icons","poster","thumbnailUrl","src","url","type","draggable","displayName"],"sources":["../../../../src/components/gallery-item/media-item/MediaItem.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\nimport type { FileItem } from '@chayns-components/core/lib/types/file';\nimport React, { FC } from 'react';\nimport {\n StyledMediaItemImage,\n StyledMediaItemImageWrapper,\n StyledMediaItemPlayIcon,\n StyledMediaItemVideo,\n StyledMediaItemVideoWrapper,\n StyledMotionMediaItem,\n} from './MediaItem.styles';\n\nexport type MediaItemProps = {\n /**\n * Images and videos which should be displayed\n */\n fileItem: FileItem;\n /**\n * Whether images and videos can be edited\n */\n isEditMode: boolean;\n /**\n * Function to be executed when a file is selected\n */\n openSelectedFile: (file: FileItem) => void;\n /**\n * The ratio of the image\n */\n ratio: number;\n};\n\nconst MediaItem: FC<MediaItemProps> = ({ fileItem, isEditMode, openSelectedFile, ratio }) => (\n <StyledMotionMediaItem\n animate={{ opacity: 1 }}\n initial={{ opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 3.2 }}\n >\n {fileItem.uploadedFile && 'thumbnailUrl' in fileItem.uploadedFile ? (\n <StyledMediaItemVideoWrapper onClick={() => openSelectedFile(fileItem)} ratio={ratio}>\n <StyledMediaItemPlayIcon>\n <Icon size={isEditMode ? 30 : 50} icons={['fa fa-play']} />\n </StyledMediaItemPlayIcon>\n <StyledMediaItemVideo poster={fileItem.uploadedFile.thumbnailUrl}>\n <source src={fileItem.uploadedFile.url} type=\"video/mp4\" />\n </StyledMediaItemVideo>\n </StyledMediaItemVideoWrapper>\n ) : (\n <StyledMediaItemImageWrapper onClick={() => openSelectedFile(fileItem)} ratio={ratio}>\n <StyledMediaItemImage draggable={false} src={fileItem.uploadedFile?.url} />\n </StyledMediaItemImageWrapper>\n )}\n </StyledMotionMediaItem>\n);\n\nMediaItem.displayName = 'MediaItem';\n\nexport default MediaItem;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,yBAAyB;AAE9C,OAAOC,KAAK,MAAc,OAAO;AACjC,SACIC,oBAAoB,EACpBC,2BAA2B,EAC3BC,uBAAuB,EACvBC,oBAAoB,EACpBC,2BAA2B,EAC3BC,qBAAqB,QAClB,oBAAoB;AAqB3B,MAAMC,SAA6B,GAAGC,IAAA;EAAA,IAAC;IAAEC,QAAQ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S,CAACuB,WAAW,GAAG,WAAW;AAEnC,eAAevB,SAAS"}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StyledMotionMediaItem = exports.StyledMediaItemVideoWrapper = exports.StyledMediaItemVideo = exports.StyledMediaItemPlayIcon = exports.StyledMediaItemImageWrapper = exports.StyledMediaItemImage = void 0;
|
|
7
|
-
var _framerMotion = require("framer-motion");
|
|
8
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const StyledMotionMediaItem = exports.StyledMotionMediaItem = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
1
|
+
import { motion } from 'framer-motion';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const StyledMotionMediaItem = styled(motion.div)`
|
|
11
4
|
display: flex;
|
|
12
5
|
width: 100%;
|
|
13
6
|
height: 100%;
|
|
14
7
|
`;
|
|
15
|
-
const StyledMediaItemVideoWrapper =
|
|
8
|
+
export const StyledMediaItemVideoWrapper = styled.div`
|
|
16
9
|
display: flex;
|
|
17
10
|
width: 100%;
|
|
18
11
|
height: 100%;
|
|
@@ -23,7 +16,7 @@ const StyledMediaItemVideoWrapper = exports.StyledMediaItemVideoWrapper = _style
|
|
|
23
16
|
return ratio;
|
|
24
17
|
}};
|
|
25
18
|
`;
|
|
26
|
-
const StyledMediaItemImageWrapper =
|
|
19
|
+
export const StyledMediaItemImageWrapper = styled.div`
|
|
27
20
|
display: flex;
|
|
28
21
|
width: 100%;
|
|
29
22
|
height: 100%;
|
|
@@ -34,7 +27,7 @@ const StyledMediaItemImageWrapper = exports.StyledMediaItemImageWrapper = _style
|
|
|
34
27
|
return ratio;
|
|
35
28
|
}};
|
|
36
29
|
`;
|
|
37
|
-
const StyledMediaItemImage =
|
|
30
|
+
export const StyledMediaItemImage = styled.img`
|
|
38
31
|
background-color: ${_ref3 => {
|
|
39
32
|
let {
|
|
40
33
|
theme
|
|
@@ -53,7 +46,7 @@ const StyledMediaItemImage = exports.StyledMediaItemImage = _styledComponents.de
|
|
|
53
46
|
height: 100%;
|
|
54
47
|
object-fit: cover;
|
|
55
48
|
`;
|
|
56
|
-
const StyledMediaItemVideo =
|
|
49
|
+
export const StyledMediaItemVideo = styled.video`
|
|
57
50
|
background-color: ${_ref5 => {
|
|
58
51
|
let {
|
|
59
52
|
theme
|
|
@@ -70,7 +63,7 @@ const StyledMediaItemVideo = exports.StyledMediaItemVideo = _styledComponents.de
|
|
|
70
63
|
width: 100%;
|
|
71
64
|
object-fit: cover;
|
|
72
65
|
`;
|
|
73
|
-
const StyledMediaItemPlayIcon =
|
|
66
|
+
export const StyledMediaItemPlayIcon = styled.div`
|
|
74
67
|
position: absolute;
|
|
75
68
|
z-index: 2;
|
|
76
69
|
top: 50%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaItem.styles.js","names":["
|
|
1
|
+
{"version":3,"file":"MediaItem.styles.js","names":["motion","styled","StyledMotionMediaItem","div","StyledMediaItemVideoWrapper","_ref","ratio","StyledMediaItemImageWrapper","_ref2","StyledMediaItemImage","img","_ref3","theme","_ref4","StyledMediaItemVideo","video","_ref5","_ref6","StyledMediaItemPlayIcon"],"sources":["../../../../src/components/gallery-item/media-item/MediaItem.styles.ts"],"sourcesContent":["import type { FramerMotionBugFix, WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledMotionMediaItem = styled(motion.div)<FramerMotionBugFix>`\n display: flex;\n width: 100%;\n height: 100%;\n`;\n\nexport const StyledMediaItemVideoWrapper = styled.div<{ ratio: number }>`\n display: flex;\n width: 100%;\n height: 100%;\n aspect-ratio: ${({ ratio }) => ratio};\n`;\n\nexport const StyledMediaItemImageWrapper = styled.div<{ ratio: number }>`\n display: flex;\n width: 100%;\n height: 100%;\n aspect-ratio: ${({ ratio }) => ratio};\n`;\n\ntype StyledMediaItemVideoProps = WithTheme<unknown>;\n\ntype StyledMediaItemImageProps = WithTheme<unknown>;\n\nexport const StyledMediaItemImage = styled.img<StyledMediaItemImageProps>`\n background-color: ${({ theme }: StyledMediaItemImageProps) => theme['101']};\n box-shadow: 0 0 0 1px rgba(${({ theme }: StyledMediaItemImageProps) => theme['009-rgb']}, 0.08)\n inset;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n`;\n\nexport const StyledMediaItemVideo = styled.video<StyledMediaItemVideoProps>`\n background-color: ${({ theme }: StyledMediaItemVideoProps) => theme['101']};\n box-shadow: 0 0 0 1px rgba(${({ theme }: StyledMediaItemVideoProps) => theme['009-rgb']}, 0.08)\n inset;\n width: 100%;\n object-fit: cover;\n`;\n\nexport const StyledMediaItemPlayIcon = styled.div`\n position: absolute;\n z-index: 2;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,qBAAqB,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAsB;AAC5E;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAGH,MAAM,CAACE,GAAuB;AACzE;AACA;AACA;AACA,oBAAoBE,IAAA;EAAA,IAAC;IAAEC;EAAM,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK;AAAA,CAAC;AACzC,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAGN,MAAM,CAACE,GAAuB;AACzE;AACA;AACA;AACA,oBAAoBK,KAAA;EAAA,IAAC;IAAEF;EAAM,CAAC,GAAAE,KAAA;EAAA,OAAKF,KAAK;AAAA,CAAC;AACzC,CAAC;AAMD,OAAO,MAAMG,oBAAoB,GAAGR,MAAM,CAACS,GAA+B;AAC1E,wBAAwBC,KAAA;EAAA,IAAC;IAAEC;EAAiC,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC/E,iCAAiCC,KAAA;EAAA,IAAC;IAAED;EAAiC,CAAC,GAAAC,KAAA;EAAA,OAAKD,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AAC5F;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,oBAAoB,GAAGb,MAAM,CAACc,KAAiC;AAC5E,wBAAwBC,KAAA;EAAA,IAAC;IAAEJ;EAAiC,CAAC,GAAAI,KAAA;EAAA,OAAKJ,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC/E,iCAAiCK,KAAA;EAAA,IAAC;IAAEL;EAAiC,CAAC,GAAAK,KAAA;EAAA,OAAKL,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AAC5F;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMM,uBAAuB,GAAGjB,MAAM,CAACE,GAAI;AAClD;AACA;AACA;AACA;AACA;AACA,CAAC"}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _core = require("@chayns-components/core");
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _PreviewItem = require("./PreviewItem.styles");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import { SmallWaitCursor } from '@chayns-components/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StyledMotionPreviewItem, StyledPreviewItemImage, StyledPreviewItemImageWrapper, StyledPreviewItemLoadingIcon } from './PreviewItem.styles';
|
|
11
4
|
const PreviewItem = _ref => {
|
|
12
5
|
let {
|
|
13
6
|
fileItem,
|
|
14
7
|
ratio
|
|
15
8
|
} = _ref;
|
|
16
|
-
return /*#__PURE__*/
|
|
9
|
+
return /*#__PURE__*/React.createElement(StyledMotionPreviewItem, {
|
|
17
10
|
animate: {
|
|
18
11
|
opacity: 1
|
|
19
12
|
},
|
|
@@ -33,16 +26,16 @@ const PreviewItem = _ref => {
|
|
|
33
26
|
style: {
|
|
34
27
|
position: 'absolute'
|
|
35
28
|
}
|
|
36
|
-
}, /*#__PURE__*/
|
|
29
|
+
}, /*#__PURE__*/React.createElement(StyledPreviewItemImageWrapper, {
|
|
37
30
|
ratio: ratio
|
|
38
|
-
}, /*#__PURE__*/
|
|
31
|
+
}, /*#__PURE__*/React.createElement(StyledPreviewItemLoadingIcon, null, /*#__PURE__*/React.createElement(SmallWaitCursor, {
|
|
39
32
|
shouldHideWaitCursor: false,
|
|
40
33
|
shouldHideBackground: true
|
|
41
|
-
})), /*#__PURE__*/
|
|
34
|
+
})), /*#__PURE__*/React.createElement(StyledPreviewItemImage, {
|
|
42
35
|
draggable: false,
|
|
43
36
|
src: fileItem.previewUrl
|
|
44
37
|
})));
|
|
45
38
|
};
|
|
46
39
|
PreviewItem.displayName = 'PreviewItem';
|
|
47
|
-
|
|
40
|
+
export default PreviewItem;
|
|
48
41
|
//# sourceMappingURL=PreviewItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewItem.js","names":["
|
|
1
|
+
{"version":3,"file":"PreviewItem.js","names":["SmallWaitCursor","React","StyledMotionPreviewItem","StyledPreviewItemImage","StyledPreviewItemImageWrapper","StyledPreviewItemLoadingIcon","PreviewItem","_ref","fileItem","ratio","createElement","animate","opacity","initial","exit","transition","duration","delay","style","position","shouldHideWaitCursor","shouldHideBackground","draggable","src","previewUrl","displayName"],"sources":["../../../../src/components/gallery-item/preview-item/PreviewItem.tsx"],"sourcesContent":["import { SmallWaitCursor } from '@chayns-components/core';\nimport type { FileItem } from '@chayns-components/core/lib/types/file';\nimport React, { FC } from 'react';\nimport {\n StyledMotionPreviewItem,\n StyledPreviewItemImage,\n StyledPreviewItemImageWrapper,\n StyledPreviewItemLoadingIcon,\n} from './PreviewItem.styles';\n\nexport type PreviewItemProps = {\n /**\n * Images and videos which should be displayed\n */\n fileItem: FileItem;\n /**\n * The ratio of the image\n */\n ratio: number;\n};\n\nconst PreviewItem: FC<PreviewItemProps> = ({ fileItem, ratio }) => (\n <StyledMotionPreviewItem\n animate={{ opacity: 1 }}\n initial={{ opacity: 0 }}\n exit={{\n opacity: 0,\n transition: { duration: 3.2, delay: 3.2 },\n }}\n transition={{ duration: 3.2 }}\n style={{ position: 'absolute' }}\n >\n <StyledPreviewItemImageWrapper ratio={ratio}>\n <StyledPreviewItemLoadingIcon>\n <SmallWaitCursor shouldHideWaitCursor={false} shouldHideBackground />\n </StyledPreviewItemLoadingIcon>\n <StyledPreviewItemImage draggable={false} src={fileItem.previewUrl} />\n </StyledPreviewItemImageWrapper>\n </StyledMotionPreviewItem>\n);\n\nPreviewItem.displayName = 'PreviewItem';\n\nexport default PreviewItem;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,yBAAyB;AAEzD,OAAOC,KAAK,MAAc,OAAO;AACjC,SACIC,uBAAuB,EACvBC,sBAAsB,EACtBC,6BAA6B,EAC7BC,4BAA4B,QACzB,sBAAsB;AAa7B,MAAMC,WAAiC,GAAGC,IAAA;EAAA,IAAC;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAAF,IAAA;EAAA,oBAC1DN,KAAA,CAAAS,aAAA,CAACR,uBAAuB;IACpBS,OAAO,EAAE;MAAEC,OAAO,EAAE;IAAE,CAAE;IACxBC,OAAO,EAAE;MAAED,OAAO,EAAE;IAAE,CAAE;IACxBE,IAAI,EAAE;MACFF,OAAO,EAAE,CAAC;MACVG,UAAU,EAAE;QAAEC,QAAQ,EAAE,GAAG;QAAEC,KAAK,EAAE;MAAI;IAC5C,CAAE;IACFF,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI,CAAE;IAC9BE,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAW;EAAE,gBAEhClB,KAAA,CAAAS,aAAA,CAACN,6BAA6B;IAACK,KAAK,EAAEA;EAAM,gBACxCR,KAAA,CAAAS,aAAA,CAACL,4BAA4B,qBACzBJ,KAAA,CAAAS,aAAA,CAACV,eAAe;IAACoB,oBAAoB,EAAE,KAAM;IAACC,oBAAoB;EAAA,CAAE,CAC1C,CAAC,eAC/BpB,KAAA,CAAAS,aAAA,CAACP,sBAAsB;IAACmB,SAAS,EAAE,KAAM;IAACC,GAAG,EAAEf,QAAQ,CAACgB;EAAW,CAAE,CAC1C,CACV,CAAC;AAAA,CAC7B;AAEDlB,WAAW,CAACmB,WAAW,GAAG,aAAa;AAEvC,eAAenB,WAAW"}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StyledPreviewItemLoadingIcon = exports.StyledPreviewItemImageWrapper = exports.StyledPreviewItemImage = exports.StyledMotionPreviewItem = void 0;
|
|
7
|
-
var _framerMotion = require("framer-motion");
|
|
8
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const StyledMotionPreviewItem = exports.StyledMotionPreviewItem = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
1
|
+
import { motion } from 'framer-motion';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const StyledMotionPreviewItem = styled(motion.div)`
|
|
11
4
|
display: flex;
|
|
12
5
|
width: 100%;
|
|
13
6
|
height: 100%;
|
|
14
7
|
`;
|
|
15
|
-
const StyledPreviewItemImageWrapper =
|
|
8
|
+
export const StyledPreviewItemImageWrapper = styled.div`
|
|
16
9
|
display: flex;
|
|
17
10
|
width: 100%;
|
|
18
11
|
height: 100%;
|
|
@@ -23,7 +16,7 @@ const StyledPreviewItemImageWrapper = exports.StyledPreviewItemImageWrapper = _s
|
|
|
23
16
|
return ratio;
|
|
24
17
|
}};
|
|
25
18
|
`;
|
|
26
|
-
const StyledPreviewItemImage =
|
|
19
|
+
export const StyledPreviewItemImage = styled.img`
|
|
27
20
|
background-color: ${_ref2 => {
|
|
28
21
|
let {
|
|
29
22
|
theme
|
|
@@ -42,7 +35,7 @@ const StyledPreviewItemImage = exports.StyledPreviewItemImage = _styledComponent
|
|
|
42
35
|
height: 100%;
|
|
43
36
|
object-fit: cover;
|
|
44
37
|
`;
|
|
45
|
-
const StyledPreviewItemLoadingIcon =
|
|
38
|
+
export const StyledPreviewItemLoadingIcon = styled.div`
|
|
46
39
|
position: absolute;
|
|
47
40
|
z-index: 2;
|
|
48
41
|
top: 50%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewItem.styles.js","names":["
|
|
1
|
+
{"version":3,"file":"PreviewItem.styles.js","names":["motion","styled","StyledMotionPreviewItem","div","StyledPreviewItemImageWrapper","_ref","ratio","StyledPreviewItemImage","img","_ref2","theme","_ref3","StyledPreviewItemLoadingIcon"],"sources":["../../../../src/components/gallery-item/preview-item/PreviewItem.styles.ts"],"sourcesContent":["import type { FramerMotionBugFix, WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledMotionPreviewItem = styled(motion.div)<FramerMotionBugFix>`\n display: flex;\n width: 100%;\n height: 100%;\n`;\n\nexport const StyledPreviewItemImageWrapper = styled.div<{ ratio: number }>`\n display: flex;\n width: 100%;\n height: 100%;\n aspect-ratio: ${({ ratio }) => ratio};\n`;\n\ntype StyledPreviewItemImageProps = WithTheme<unknown>;\n\nexport const StyledPreviewItemImage = styled.img<StyledPreviewItemImageProps>`\n background-color: ${({ theme }: StyledPreviewItemImageProps) => theme['101']};\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledPreviewItemImageProps) => theme['009-rgb']}, 0.08) inset;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n`;\n\nexport const StyledPreviewItemLoadingIcon = styled.div`\n position: absolute;\n z-index: 2;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,uBAAuB,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAsB;AAC9E;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,6BAA6B,GAAGH,MAAM,CAACE,GAAuB;AAC3E;AACA;AACA;AACA,oBAAoBE,IAAA;EAAA,IAAC;IAAEC;EAAM,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK;AAAA,CAAC;AACzC,CAAC;AAID,OAAO,MAAMC,sBAAsB,GAAGN,MAAM,CAACO,GAAiC;AAC9E,wBAAwBC,KAAA;EAAA,IAAC;IAAEC;EAAmC,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AACjF;AACA,eAAeC,KAAA;EAAA,IAAC;IAAED;EAAmC,CAAC,GAAAC,KAAA;EAAA,OAAKD,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AAC5E;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,4BAA4B,GAAGX,MAAM,CAACE,GAAI;AACvD;AACA;AACA;AACA;AACA;AACA,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Gallery", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _Gallery.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "GalleryViewMode", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _gallery.GalleryViewMode;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
var _Gallery = _interopRequireDefault(require("./components/Gallery"));
|
|
19
|
-
var _gallery = require("./types/gallery");
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3
|
+
export { default as Gallery } from './components/Gallery';
|
|
4
|
+
export { GalleryViewMode } from './types/gallery';
|
|
21
5
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","Gallery","GalleryViewMode"],"sources":["../src/index.ts"],"sourcesContent":["// noinspection JSUnusedGlobalSymbols\n\nexport { default as Gallery } from './components/Gallery';\nexport { GalleryViewMode } from './types/gallery';\n"],"mappings":"AAAA;;AAEA,SAASA,OAAO,IAAIC,OAAO,QAAQ,sBAAsB;AACzD,SAASC,eAAe,QAAQ,iBAAiB"}
|
package/lib/types/gallery.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GalleryViewMode = void 0;
|
|
7
|
-
let GalleryViewMode = exports.GalleryViewMode = /*#__PURE__*/function (GalleryViewMode) {
|
|
1
|
+
export let GalleryViewMode = /*#__PURE__*/function (GalleryViewMode) {
|
|
8
2
|
GalleryViewMode[GalleryViewMode["SQUARE"] = 0] = "SQUARE";
|
|
9
3
|
GalleryViewMode[GalleryViewMode["GRID"] = 1] = "GRID";
|
|
10
4
|
return GalleryViewMode;
|
package/lib/types/gallery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.js","names":["GalleryViewMode"
|
|
1
|
+
{"version":3,"file":"gallery.js","names":["GalleryViewMode"],"sources":["../../src/types/gallery.ts"],"sourcesContent":["export enum GalleryViewMode {\n SQUARE,\n GRID,\n}\n"],"mappings":"AAAA,WAAYA,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA"}
|
package/lib/utils/file.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateVideoThumbnail = exports.generatePreviewUrl = exports.filterDuplicateFile = void 0;
|
|
7
1
|
// TODO: Check why absolute import is needed
|
|
8
2
|
|
|
9
|
-
const filterDuplicateFile = _ref => {
|
|
3
|
+
export const filterDuplicateFile = _ref => {
|
|
10
4
|
let {
|
|
11
5
|
newFile,
|
|
12
6
|
files
|
|
@@ -19,8 +13,7 @@ const filterDuplicateFile = _ref => {
|
|
|
19
13
|
});
|
|
20
14
|
return duplicates.length > 0;
|
|
21
15
|
};
|
|
22
|
-
|
|
23
|
-
const generatePreviewUrl = _ref3 => {
|
|
16
|
+
export const generatePreviewUrl = _ref3 => {
|
|
24
17
|
let {
|
|
25
18
|
callback,
|
|
26
19
|
file
|
|
@@ -32,8 +25,7 @@ const generatePreviewUrl = _ref3 => {
|
|
|
32
25
|
};
|
|
33
26
|
reader.readAsDataURL(file);
|
|
34
27
|
};
|
|
35
|
-
|
|
36
|
-
const generateVideoThumbnail = _ref4 => {
|
|
28
|
+
export const generateVideoThumbnail = _ref4 => {
|
|
37
29
|
let {
|
|
38
30
|
file,
|
|
39
31
|
callback
|
|
@@ -54,5 +46,4 @@ const generateVideoThumbnail = _ref4 => {
|
|
|
54
46
|
callback(canvas.toDataURL('image/png'));
|
|
55
47
|
};
|
|
56
48
|
};
|
|
57
|
-
exports.generateVideoThumbnail = generateVideoThumbnail;
|
|
58
49
|
//# sourceMappingURL=file.js.map
|
package/lib/utils/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":["filterDuplicateFile","_ref","newFile","files","duplicates","filter","_ref2","file","name","size","length","
|
|
1
|
+
{"version":3,"file":"file.js","names":["filterDuplicateFile","_ref","newFile","files","duplicates","filter","_ref2","file","name","size","length","generatePreviewUrl","_ref3","callback","reader","FileReader","onload","event","previewUrl","target","result","readAsDataURL","generateVideoThumbnail","_ref4","canvas","document","createElement","video","autoplay","muted","src","URL","createObjectURL","onloadeddata","ctx","getContext","width","videoWidth","height","videoHeight","drawImage","pause","toDataURL"],"sources":["../../src/utils/file.ts"],"sourcesContent":["import type { FileItem } from '@chayns-components/core/lib/types/file'; // TODO: Check why absolute import is needed\n\ninterface FilerDuplicateFileOptions {\n files: FileItem[];\n newFile: File;\n}\n\nexport const filterDuplicateFile = ({ newFile, files }: FilerDuplicateFileOptions) => {\n const duplicates = files.filter(\n ({ file }) => file && file.name === newFile.name && file.size === newFile.size\n );\n\n return duplicates.length > 0;\n};\n\ninterface GeneratePreviewUrlOptions {\n file: File;\n callback: (previewUrl: string) => void;\n}\n\nexport const generatePreviewUrl = ({ callback, file }: GeneratePreviewUrlOptions): void => {\n const reader = new FileReader();\n\n reader.onload = (event) => {\n const previewUrl = event.target?.result as string;\n\n callback(previewUrl);\n };\n\n reader.readAsDataURL(file);\n};\n\ninterface GenerateVideoThumbnailOptions {\n file: File;\n callback: (previewUrl: string) => void;\n}\n\nexport const generateVideoThumbnail = ({ file, callback }: GenerateVideoThumbnailOptions) => {\n const canvas = document.createElement('canvas');\n const video = document.createElement('video');\n\n // this is important\n video.autoplay = true;\n video.muted = true;\n video.src = URL.createObjectURL(file);\n\n video.onloadeddata = () => {\n const ctx = canvas.getContext('2d');\n\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n ctx?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n video.pause();\n\n callback(canvas.toDataURL('image/png'));\n };\n};\n"],"mappings":"AAAwE;;AAOxE,OAAO,MAAMA,mBAAmB,GAAGC,IAAA,IAAmD;EAAA,I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AAK,GAAGT,KAAK,CAACU,UAAU;IAC/Bb,MAAM,CAACc,MAAM,GAAGX,KAAK,CAACY,WAAW;IAEjCL,GAAG,EAAEM,SAAS,CAACb,KAAK,EAAE,CAAC,EAAE,CAAC,EAAEA,KAAK,CAACU,UAAU,EAAEV,KAAK,CAACY,WAAW,CAAC;IAChEZ,KAAK,CAACc,KAAK,CAAC,CAAC;IAEb5B,QAAQ,CAACW,MAAM,CAACkB,SAAS,CAAC,WAAW,CAAC,CAAC;EAC3C,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/gallery",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.443",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chayns",
|
|
@@ -33,24 +33,24 @@
|
|
|
33
33
|
"url": "https://github.com/TobitSoftware/chayns-components/issues"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@babel/cli": "^7.23.
|
|
37
|
-
"@babel/core": "^7.23.
|
|
38
|
-
"@babel/preset-env": "^7.23.
|
|
36
|
+
"@babel/cli": "^7.23.9",
|
|
37
|
+
"@babel/core": "^7.23.9",
|
|
38
|
+
"@babel/preset-env": "^7.23.9",
|
|
39
39
|
"@babel/preset-react": "^7.23.3",
|
|
40
40
|
"@babel/preset-typescript": "^7.23.3",
|
|
41
|
-
"@types/react": "^18.2.
|
|
42
|
-
"@types/react-dom": "^18.2.
|
|
41
|
+
"@types/react": "^18.2.55",
|
|
42
|
+
"@types/react-dom": "^18.2.19",
|
|
43
43
|
"@types/styled-components": "^5.1.34",
|
|
44
|
-
"@types/uuid": "^9.0.
|
|
44
|
+
"@types/uuid": "^9.0.8",
|
|
45
45
|
"babel-loader": "^9.1.3",
|
|
46
|
-
"lerna": "^8.
|
|
46
|
+
"lerna": "^8.1.2",
|
|
47
47
|
"react": "^18.2.0",
|
|
48
48
|
"react-dom": "^18.2.0",
|
|
49
49
|
"styled-components": "^6.1.8",
|
|
50
50
|
"typescript": "^5.3.3"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@chayns-components/core": "^5.0.0-beta.
|
|
53
|
+
"@chayns-components/core": "^5.0.0-beta.443"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"chayns-api": ">=1.0.50",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "3f3e8b424de86b8597fd4670766a496a767ee1ba"
|
|
66
66
|
}
|