@chayns-components/gallery 5.2.4-alpha.0 → 5.2.5
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/AGENTS.md +132 -13
- package/lib/cjs/components/Gallery.js +4 -1
- package/lib/cjs/components/Gallery.js.map +1 -1
- package/lib/cjs/components/Gallery.types.js.map +1 -1
- package/lib/cjs/components/gallery-editor/GalleryEditor.constants.js +12 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.constants.js.map +1 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.js +40 -178
- package/lib/cjs/components/gallery-editor/GalleryEditor.js.map +1 -1
- package/lib/cjs/components/gallery-editor/GalleryEditor.styles.js +3 -1
- package/lib/cjs/components/gallery-editor/GalleryEditor.styles.js.map +1 -1
- package/lib/cjs/components/gallery-editor/GalleryEditor.types.js.map +1 -1
- package/lib/cjs/components/gallery-editor/GalleryEditor.utils.js +27 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.utils.js.map +1 -0
- package/lib/cjs/components/gallery-editor/add-file/AddFile.js +1 -1
- package/lib/cjs/components/gallery-editor/add-file/AddFile.js.map +1 -1
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.js +48 -19
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.js.map +1 -1
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.js +10 -3
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.js.map +1 -1
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.types.js.map +1 -1
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.js +10 -4
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.js.map +1 -1
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.types.js.map +1 -1
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.js +7 -10
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.js.map +1 -1
- package/lib/cjs/components/gallery-editor/useGalleryEditorState.js +161 -0
- package/lib/cjs/components/gallery-editor/useGalleryEditorState.js.map +1 -0
- package/lib/cjs/components/gallery-viewer/GalleryViewer.constants.js +8 -0
- package/lib/cjs/components/gallery-viewer/GalleryViewer.constants.js.map +1 -0
- package/lib/cjs/components/gallery-viewer/GalleryViewer.js +8 -4
- package/lib/cjs/components/gallery-viewer/GalleryViewer.js.map +1 -1
- package/lib/cjs/components/gallery-viewer/GalleryViewer.types.js.map +1 -1
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.js +6 -3
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.js.map +1 -1
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.js.map +1 -1
- package/lib/cjs/components/media-content/MediaContent.constants.js +12 -0
- package/lib/cjs/components/media-content/MediaContent.constants.js.map +1 -0
- package/lib/cjs/components/media-content/MediaContent.js +95 -20
- package/lib/cjs/components/media-content/MediaContent.js.map +1 -1
- package/lib/cjs/components/media-content/MediaContent.styles.js +35 -5
- package/lib/cjs/components/media-content/MediaContent.styles.js.map +1 -1
- package/lib/cjs/components/media-content/MediaContent.types.js.map +1 -1
- package/lib/cjs/components/media-content/MediaContent.utils.js +84 -0
- package/lib/cjs/components/media-content/MediaContent.utils.js.map +1 -0
- package/lib/cjs/components/media-content/useMediaContentSize.js +68 -0
- package/lib/cjs/components/media-content/useMediaContentSize.js.map +1 -0
- package/lib/cjs/utils/gallery.js +2 -2
- package/lib/cjs/utils/gallery.js.map +1 -1
- package/lib/esm/components/Gallery.js +4 -1
- package/lib/esm/components/Gallery.js.map +1 -1
- package/lib/esm/components/Gallery.types.js.map +1 -1
- package/lib/esm/components/gallery-editor/GalleryEditor.constants.js +6 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.constants.js.map +1 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.js +37 -174
- package/lib/esm/components/gallery-editor/GalleryEditor.js.map +1 -1
- package/lib/esm/components/gallery-editor/GalleryEditor.styles.js +3 -1
- package/lib/esm/components/gallery-editor/GalleryEditor.styles.js.map +1 -1
- package/lib/esm/components/gallery-editor/GalleryEditor.types.js.map +1 -1
- package/lib/esm/components/gallery-editor/GalleryEditor.utils.js +17 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.utils.js.map +1 -0
- package/lib/esm/components/gallery-editor/add-file/AddFile.js +2 -2
- package/lib/esm/components/gallery-editor/add-file/AddFile.js.map +1 -1
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.js +47 -19
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.js.map +1 -1
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.js +9 -2
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.js.map +1 -1
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.types.js.map +1 -1
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.js +9 -4
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.js.map +1 -1
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.types.js.map +1 -1
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.js +6 -9
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.js.map +1 -1
- package/lib/esm/components/gallery-editor/useGalleryEditorState.js +150 -0
- package/lib/esm/components/gallery-editor/useGalleryEditorState.js.map +1 -0
- package/lib/esm/components/gallery-viewer/GalleryViewer.constants.js +2 -0
- package/lib/esm/components/gallery-viewer/GalleryViewer.constants.js.map +1 -0
- package/lib/esm/components/gallery-viewer/GalleryViewer.js +9 -5
- package/lib/esm/components/gallery-viewer/GalleryViewer.js.map +1 -1
- package/lib/esm/components/gallery-viewer/GalleryViewer.types.js.map +1 -1
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.js +5 -3
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.js.map +1 -1
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.js.map +1 -1
- package/lib/esm/components/media-content/MediaContent.constants.js +6 -0
- package/lib/esm/components/media-content/MediaContent.constants.js.map +1 -0
- package/lib/esm/components/media-content/MediaContent.js +94 -21
- package/lib/esm/components/media-content/MediaContent.js.map +1 -1
- package/lib/esm/components/media-content/MediaContent.styles.js +34 -4
- package/lib/esm/components/media-content/MediaContent.styles.js.map +1 -1
- package/lib/esm/components/media-content/MediaContent.types.js.map +1 -1
- package/lib/esm/components/media-content/MediaContent.utils.js +71 -0
- package/lib/esm/components/media-content/MediaContent.utils.js.map +1 -0
- package/lib/esm/components/media-content/useMediaContentSize.js +62 -0
- package/lib/esm/components/media-content/useMediaContentSize.js.map +1 -0
- package/lib/esm/utils/gallery.js +2 -2
- package/lib/esm/utils/gallery.js.map +1 -1
- package/lib/types/components/Gallery.types.d.ts +12 -0
- package/lib/types/components/gallery-editor/GalleryEditor.constants.d.ts +5 -0
- package/lib/types/components/gallery-editor/GalleryEditor.styles.d.ts +7 -3
- package/lib/types/components/gallery-editor/GalleryEditor.types.d.ts +11 -0
- package/lib/types/components/gallery-editor/GalleryEditor.utils.d.ts +5 -0
- package/lib/types/components/gallery-editor/add-file/AddFile.d.ts +3 -3
- package/lib/types/components/gallery-editor/add-file/AddFile.styles.d.ts +5 -3
- package/lib/types/components/gallery-editor/gallery-editor-item/GalleryEditorItem.d.ts +3 -3
- package/lib/types/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.d.ts +13 -3
- package/lib/types/components/gallery-editor/gallery-editor-item/GalleryEditorItem.types.d.ts +8 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.d.ts +3 -3
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.styles.d.ts +3 -1
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.types.d.ts +15 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.d.ts +3 -3
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.styles.d.ts +12 -6
- package/lib/types/components/gallery-editor/useGalleryEditorState.d.ts +21 -0
- package/lib/types/components/gallery-viewer/GalleryViewer.constants.d.ts +1 -0
- package/lib/types/components/gallery-viewer/GalleryViewer.styles.d.ts +7 -3
- package/lib/types/components/gallery-viewer/GalleryViewer.types.d.ts +11 -0
- package/lib/types/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.d.ts +3 -3
- package/lib/types/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.styles.d.ts +2 -2
- package/lib/types/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.d.ts +8 -0
- package/lib/types/components/media-content/MediaContent.constants.d.ts +5 -0
- package/lib/types/components/media-content/MediaContent.d.ts +3 -3
- package/lib/types/components/media-content/MediaContent.styles.d.ts +50 -9
- package/lib/types/components/media-content/MediaContent.types.d.ts +16 -0
- package/lib/types/components/media-content/MediaContent.utils.d.ts +12 -0
- package/lib/types/components/media-content/useMediaContentSize.d.ts +3 -0
- package/package.json +4 -4
package/AGENTS.md
CHANGED
|
@@ -14,7 +14,10 @@ import { Gallery, GalleryEditor, GalleryViewer } from '@chayns-components/galler
|
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
16
|
<Gallery
|
|
17
|
-
files={galleryStoryFiles}
|
|
17
|
+
files={galleryStoryFiles.slice(0, 3)}
|
|
18
|
+
isEditMode={false}
|
|
19
|
+
shouldLoadImages
|
|
20
|
+
viewMode={GalleryViewMode.GRID}
|
|
18
21
|
/>
|
|
19
22
|
```
|
|
20
23
|
|
|
@@ -26,7 +29,7 @@ import { Gallery, GalleryEditor, GalleryViewer } from '@chayns-components/galler
|
|
|
26
29
|
|
|
27
30
|
## Gallery
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
Die Wrapper-Komponente entscheidet zwischen Viewer und Editor und steuert das optionale verzögerte Laden der finalen Medien. Die Stories zeigen die typischen Einsatzfälle sowie die neue Preview-first-Ladelogik.
|
|
30
33
|
|
|
31
34
|
### Import
|
|
32
35
|
|
|
@@ -38,9 +41,34 @@ import { Gallery } from '@chayns-components/gallery';
|
|
|
38
41
|
|
|
39
42
|
#### General
|
|
40
43
|
|
|
44
|
+
```tsx
|
|
45
|
+
<Gallery
|
|
46
|
+
files={galleryStoryFiles.slice(0, 3)}
|
|
47
|
+
isEditMode={false}
|
|
48
|
+
shouldLoadImages
|
|
49
|
+
viewMode={GalleryViewMode.GRID}
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Read Only Square
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<Gallery
|
|
57
|
+
files={galleryViewerSquareFiles}
|
|
58
|
+
isEditMode={false}
|
|
59
|
+
shouldLoadImages
|
|
60
|
+
viewMode={GalleryViewMode.SQUARE}
|
|
61
|
+
/>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Deferred Load Preview First
|
|
65
|
+
|
|
41
66
|
```tsx
|
|
42
67
|
<Gallery
|
|
43
68
|
files={galleryStoryFiles}
|
|
69
|
+
isEditMode={false}
|
|
70
|
+
shouldLoadImages={false}
|
|
71
|
+
viewMode={GalleryViewMode.GRID}
|
|
44
72
|
/>
|
|
45
73
|
```
|
|
46
74
|
|
|
@@ -48,18 +76,23 @@ import { Gallery } from '@chayns-components/gallery';
|
|
|
48
76
|
|
|
49
77
|
```tsx
|
|
50
78
|
<Gallery
|
|
51
|
-
files={
|
|
79
|
+
files={galleryPreviewFiles.slice(0, 3)}
|
|
52
80
|
isEditMode
|
|
81
|
+
shouldLoadImages
|
|
82
|
+
viewMode={GalleryViewMode.GRID}
|
|
53
83
|
maxFiles={6}
|
|
54
84
|
/>
|
|
55
85
|
```
|
|
56
86
|
|
|
57
|
-
####
|
|
87
|
+
#### Edit Mode Max Files Reached
|
|
58
88
|
|
|
59
89
|
```tsx
|
|
60
90
|
<Gallery
|
|
61
|
-
files={
|
|
62
|
-
|
|
91
|
+
files={galleryPreviewFiles.slice(0, 4)}
|
|
92
|
+
isEditMode
|
|
93
|
+
shouldLoadImages
|
|
94
|
+
viewMode={GalleryViewMode.GRID}
|
|
95
|
+
maxFiles={4}
|
|
63
96
|
/>
|
|
64
97
|
```
|
|
65
98
|
|
|
@@ -67,8 +100,10 @@ import { Gallery } from '@chayns-components/gallery';
|
|
|
67
100
|
|
|
68
101
|
```tsx
|
|
69
102
|
<Gallery
|
|
70
|
-
files={
|
|
103
|
+
files={galleryPreviewFiles.slice(0, 3)}
|
|
71
104
|
isEditMode
|
|
105
|
+
shouldLoadImages
|
|
106
|
+
viewMode={GalleryViewMode.GRID}
|
|
72
107
|
maxFiles={6}
|
|
73
108
|
addFileIcon={'fa fa-image-circle-plus'}
|
|
74
109
|
/>
|
|
@@ -92,7 +127,7 @@ No additional exported types documented.
|
|
|
92
127
|
- Avoid imports from internal paths such as `@chayns-components/gallery/src/...`; always use the public package export.
|
|
93
128
|
## GalleryEditor
|
|
94
129
|
|
|
95
|
-
|
|
130
|
+
Der Editor verwaltet lokale und externe Medien, unterstützt Drag-and-Drop und kann die endgültige Medienladung über `shouldLoadImages` verzögern.
|
|
96
131
|
|
|
97
132
|
### Import
|
|
98
133
|
|
|
@@ -110,17 +145,31 @@ import { GalleryEditor } from '@chayns-components/gallery';
|
|
|
110
145
|
fileMinWidth={100}
|
|
111
146
|
files={galleryStoryFiles.slice(0, 3)}
|
|
112
147
|
maxFiles={6}
|
|
148
|
+
shouldLoadImages
|
|
149
|
+
/>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### Dense Layout
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
<GalleryEditor
|
|
156
|
+
allowDragAndDrop={false}
|
|
157
|
+
fileMinWidth={140}
|
|
158
|
+
files={galleryPreviewFiles.slice(0, 4)}
|
|
159
|
+
maxFiles={6}
|
|
160
|
+
shouldLoadImages
|
|
113
161
|
/>
|
|
114
162
|
```
|
|
115
163
|
|
|
116
|
-
####
|
|
164
|
+
#### Max Files Reached
|
|
117
165
|
|
|
118
166
|
```tsx
|
|
119
167
|
<GalleryEditor
|
|
120
168
|
allowDragAndDrop={false}
|
|
121
169
|
fileMinWidth={100}
|
|
122
|
-
files={
|
|
170
|
+
files={galleryPreviewFiles.slice(0, 4)}
|
|
123
171
|
maxFiles={4}
|
|
172
|
+
shouldLoadImages
|
|
124
173
|
/>
|
|
125
174
|
```
|
|
126
175
|
|
|
@@ -130,12 +179,49 @@ import { GalleryEditor } from '@chayns-components/gallery';
|
|
|
130
179
|
<GalleryEditor
|
|
131
180
|
allowDragAndDrop={false}
|
|
132
181
|
fileMinWidth={100}
|
|
133
|
-
files={
|
|
182
|
+
files={galleryPreviewFiles.slice(0, 3)}
|
|
134
183
|
maxFiles={6}
|
|
184
|
+
shouldLoadImages
|
|
135
185
|
addFileIcon={'fa fa-image-circle-plus'}
|
|
136
186
|
/>
|
|
137
187
|
```
|
|
138
188
|
|
|
189
|
+
#### Drag And Drop Enabled
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
<GalleryEditor
|
|
193
|
+
allowDragAndDrop
|
|
194
|
+
fileMinWidth={100}
|
|
195
|
+
files={galleryPreviewFiles.slice(0, 3)}
|
|
196
|
+
maxFiles={6}
|
|
197
|
+
shouldLoadImages
|
|
198
|
+
/>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### Deferred Load Preview First
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
<GalleryEditor
|
|
205
|
+
allowDragAndDrop={false}
|
|
206
|
+
fileMinWidth={100}
|
|
207
|
+
files={galleryPreviewFiles.slice(0, 4)}
|
|
208
|
+
maxFiles={6}
|
|
209
|
+
shouldLoadImages={false}
|
|
210
|
+
/>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### Video And Images
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
<GalleryEditor
|
|
217
|
+
allowDragAndDrop={false}
|
|
218
|
+
fileMinWidth={100}
|
|
219
|
+
files={[...galleryStoryFiles.slice(0, 3), ...galleryVideoFiles]}
|
|
220
|
+
maxFiles={6}
|
|
221
|
+
shouldLoadImages
|
|
222
|
+
/>
|
|
223
|
+
```
|
|
224
|
+
|
|
139
225
|
### Props
|
|
140
226
|
|
|
141
227
|
No prop documentation available.
|
|
@@ -154,7 +240,7 @@ No additional exported types documented.
|
|
|
154
240
|
- Avoid imports from internal paths such as `@chayns-components/gallery/src/...`; always use the public package export.
|
|
155
241
|
## GalleryViewer
|
|
156
242
|
|
|
157
|
-
|
|
243
|
+
Der read-only Viewer rendert bekannte Medien im Grid- oder Square-Layout und unterstützt das verzögerte Laden finaler Medien über `shouldLoadImages`.
|
|
158
244
|
|
|
159
245
|
### Import
|
|
160
246
|
|
|
@@ -168,7 +254,8 @@ import { GalleryViewer } from '@chayns-components/gallery';
|
|
|
168
254
|
|
|
169
255
|
```tsx
|
|
170
256
|
<GalleryViewer
|
|
171
|
-
files={galleryStoryFiles}
|
|
257
|
+
files={galleryStoryFiles.slice(0, 3)}
|
|
258
|
+
shouldLoadImages
|
|
172
259
|
viewMode={GalleryViewMode.GRID}
|
|
173
260
|
/>
|
|
174
261
|
```
|
|
@@ -178,10 +265,21 @@ import { GalleryViewer } from '@chayns-components/gallery';
|
|
|
178
265
|
```tsx
|
|
179
266
|
<GalleryViewer
|
|
180
267
|
files={galleryViewerSquareFiles}
|
|
268
|
+
shouldLoadImages
|
|
181
269
|
viewMode={GalleryViewMode.SQUARE}
|
|
182
270
|
/>
|
|
183
271
|
```
|
|
184
272
|
|
|
273
|
+
#### Mixed Media
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
<GalleryViewer
|
|
277
|
+
files={galleryStoryFiles}
|
|
278
|
+
shouldLoadImages
|
|
279
|
+
viewMode={GalleryViewMode.GRID}
|
|
280
|
+
/>
|
|
281
|
+
```
|
|
282
|
+
|
|
185
283
|
#### Single Item Fallback Ratio
|
|
186
284
|
|
|
187
285
|
```tsx
|
|
@@ -195,6 +293,27 @@ import { GalleryViewer } from '@chayns-components/gallery';
|
|
|
195
293
|
},
|
|
196
294
|
},
|
|
197
295
|
]}
|
|
296
|
+
shouldLoadImages
|
|
297
|
+
viewMode={GalleryViewMode.GRID}
|
|
298
|
+
/>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### Deferred Load Preview First
|
|
302
|
+
|
|
303
|
+
```tsx
|
|
304
|
+
<GalleryViewer
|
|
305
|
+
files={galleryPreviewFiles}
|
|
306
|
+
shouldLoadImages={false}
|
|
307
|
+
viewMode={GalleryViewMode.GRID}
|
|
308
|
+
/>
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
#### Video Focus
|
|
312
|
+
|
|
313
|
+
```tsx
|
|
314
|
+
<GalleryViewer
|
|
315
|
+
files={galleryVideoFiles}
|
|
316
|
+
shouldLoadImages
|
|
198
317
|
viewMode={GalleryViewMode.GRID}
|
|
199
318
|
/>
|
|
200
319
|
```
|
|
@@ -21,6 +21,7 @@ const Gallery = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
21
21
|
onAdd,
|
|
22
22
|
onFileCountChange,
|
|
23
23
|
onRemove,
|
|
24
|
+
shouldLoadImages = true,
|
|
24
25
|
viewMode = _gallery.GalleryViewMode.GRID
|
|
25
26
|
}, ref) => {
|
|
26
27
|
const editorRef = (0, _react.useRef)(null);
|
|
@@ -45,9 +46,11 @@ const Gallery = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
45
46
|
maxFiles: maxFiles,
|
|
46
47
|
onAdd: onAdd,
|
|
47
48
|
onFileCountChange: onFileCountChange,
|
|
48
|
-
onRemove: onRemove
|
|
49
|
+
onRemove: onRemove,
|
|
50
|
+
shouldLoadImages: shouldLoadImages
|
|
49
51
|
}) : /*#__PURE__*/_react.default.createElement(_GalleryViewer.default, {
|
|
50
52
|
files: files,
|
|
53
|
+
shouldLoadImages: shouldLoadImages,
|
|
51
54
|
viewMode: viewMode
|
|
52
55
|
});
|
|
53
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gallery.js","names":["_react","_interopRequireWildcard","require","_GalleryEditor","_interopRequireDefault","_GalleryViewer","_gallery","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Gallery","forwardRef","allowDragAndDrop","addFileIcon","doubleFileDialogMessage","isEditMode","fileMinWidth","files","maxFiles","onAdd","onFileCountChange","onRemove","viewMode","GalleryViewMode","GRID","ref","editorRef","useRef","handleClear","useCallback","_editorRef$current","console","warn","current","clear","useImperativeHandle","createElement","displayName","_default","exports"],"sources":["../../../src/components/Gallery.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';\nimport GalleryEditor from './gallery-editor/GalleryEditor';\nimport type { GalleryEditorRef } from './gallery-editor/GalleryEditor.types';\nimport GalleryViewer from './gallery-viewer/GalleryViewer';\nimport type { GalleryProps, GalleryRef } from './Gallery.types';\nimport { GalleryViewMode } from '../types/gallery';\n\nconst Gallery = forwardRef<GalleryRef, GalleryProps>(\n (\n {\n allowDragAndDrop = false,\n addFileIcon = 'fa fa-plus',\n doubleFileDialogMessage = 'Diese Datei ist bereits vorhanden',\n isEditMode = false,\n fileMinWidth = 100,\n files,\n maxFiles,\n onAdd,\n onFileCountChange,\n onRemove,\n viewMode = GalleryViewMode.GRID,\n },\n ref,\n ) => {\n const editorRef = useRef<GalleryEditorRef>(null);\n\n const handleClear = useCallback(() => {\n if (!isEditMode) {\n console.warn('Gallery.clear() can only be used in edit mode.');\n return;\n }\n\n editorRef.current?.clear();\n }, [isEditMode]);\n\n useImperativeHandle(\n ref,\n () => ({\n clear: handleClear,\n }),\n [handleClear],\n );\n\n return isEditMode ? (\n <GalleryEditor\n ref={editorRef}\n allowDragAndDrop={allowDragAndDrop}\n addFileIcon={addFileIcon}\n doubleFileDialogMessage={doubleFileDialogMessage}\n fileMinWidth={fileMinWidth}\n files={files}\n maxFiles={maxFiles}\n onAdd={onAdd}\n onFileCountChange={onFileCountChange}\n onRemove={onRemove}\n />\n ) : (\n <GalleryViewer files={files} viewMode={viewMode} />\n );\n },\n);\n\nGallery.displayName = 'Gallery';\n\nexport default Gallery;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAAmD,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAM,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAS,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAG,CAAA,OAAAK,CAAA,CAAAI,GAAA,IAAAJ,CAAA,CAAAK,GAAA,IAAAN,CAAA,CAAAE,CAAA,EAAAN,CAAA,EAAAK,CAAA,IAAAC,CAAA,CAAAN,CAAA,IAAAH,CAAA,CAAAG,CAAA,WAAAM,CAAA,KAAAT,CAAA,EAAAG,CAAA;AAEnD,MAAMgB,OAAO,gBAAG,IAAAC,iBAAU,EACtB,CACI;EACIC,gBAAgB,GAAG,KAAK;EACxBC,WAAW,GAAG,YAAY;EAC1BC,uBAAuB,GAAG,mCAAmC;EAC7DC,UAAU,GAAG,KAAK;EAClBC,YAAY,GAAG,GAAG;EAClBC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,iBAAiB;EACjBC,QAAQ;EACRC,QAAQ,GAAGC,wBAAe,CAACC;AAC/B,CAAC,EACDC,GAAG,KACF;EACD,MAAMC,SAAS,GAAG,IAAAC,aAAM,EAAmB,IAAI,CAAC;EAEhD,MAAMC,WAAW,GAAG,IAAAC,kBAAW,EAAC,MAAM;IAAA,IAAAC,kBAAA;IAClC,IAAI,
|
|
1
|
+
{"version":3,"file":"Gallery.js","names":["_react","_interopRequireWildcard","require","_GalleryEditor","_interopRequireDefault","_GalleryViewer","_gallery","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Gallery","forwardRef","allowDragAndDrop","addFileIcon","doubleFileDialogMessage","isEditMode","fileMinWidth","files","maxFiles","onAdd","onFileCountChange","onRemove","shouldLoadImages","viewMode","GalleryViewMode","GRID","ref","editorRef","useRef","handleClear","useCallback","_editorRef$current","console","warn","current","clear","useImperativeHandle","createElement","displayName","_default","exports"],"sources":["../../../src/components/Gallery.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';\nimport GalleryEditor from './gallery-editor/GalleryEditor';\nimport type { GalleryEditorRef } from './gallery-editor/GalleryEditor.types';\nimport GalleryViewer from './gallery-viewer/GalleryViewer';\nimport type { GalleryProps, GalleryRef } from './Gallery.types';\nimport { GalleryViewMode } from '../types/gallery';\n\nconst Gallery = forwardRef<GalleryRef, GalleryProps>(\n (\n {\n allowDragAndDrop = false,\n addFileIcon = 'fa fa-plus',\n doubleFileDialogMessage = 'Diese Datei ist bereits vorhanden',\n isEditMode = false,\n fileMinWidth = 100,\n files,\n maxFiles,\n onAdd,\n onFileCountChange,\n onRemove,\n shouldLoadImages = true,\n viewMode = GalleryViewMode.GRID,\n },\n ref,\n ) => {\n const editorRef = useRef<GalleryEditorRef>(null);\n\n const handleClear = useCallback(() => {\n if (!isEditMode) {\n console.warn('Gallery.clear() can only be used in edit mode.');\n return;\n }\n\n editorRef.current?.clear();\n }, [isEditMode]);\n\n useImperativeHandle(\n ref,\n () => ({\n clear: handleClear,\n }),\n [handleClear],\n );\n\n return isEditMode ? (\n <GalleryEditor\n ref={editorRef}\n allowDragAndDrop={allowDragAndDrop}\n addFileIcon={addFileIcon}\n doubleFileDialogMessage={doubleFileDialogMessage}\n fileMinWidth={fileMinWidth}\n files={files}\n maxFiles={maxFiles}\n onAdd={onAdd}\n onFileCountChange={onFileCountChange}\n onRemove={onRemove}\n shouldLoadImages={shouldLoadImages}\n />\n ) : (\n <GalleryViewer files={files} shouldLoadImages={shouldLoadImages} viewMode={viewMode} />\n );\n },\n);\n\nGallery.displayName = 'Gallery';\n\nexport default Gallery;\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gallery.types.js","names":[],"sources":["../../../src/components/Gallery.types.ts"],"sourcesContent":["import type { FileItem } from '@chayns-components/core';\nimport type { GalleryViewMode } from '../types/gallery';\n\n/**\n * Props for the public Gallery wrapper component.\n */\nexport type GalleryRef = {\n /**\n * Clears all locally managed gallery items in edit mode.\n * @description\n * When the gallery is rendered in read-only mode, calling this method only emits a console warning.\n */\n clear: () => void;\n};\n\nexport interface GalleryProps {\n /**\n * Enables drag and drop while the component is used in edit mode.\n * @description\n * This prop only affects the editor path. In read-only mode, drag and drop stays disabled regardless of this value.\n * @default false\n * @example\n * <Gallery allowDragAndDrop isEditMode files={files} />\n * @optional\n */\n allowDragAndDrop?: boolean;\n /**\n * Defines the dialog message that is shown when a duplicate upload is detected.\n * @description\n * The message is used by the editor when a locally added file resolves to an already known uploaded file.\n * @default 'Diese Datei ist bereits vorhanden'\n * @example\n * <Gallery doubleFileDialogMessage=\"This file already exists.\" isEditMode files={files} />\n * @optional\n */\n doubleFileDialogMessage?: string;\n /**\n * Defines the minimum width of one tile in edit mode.\n * @description\n * The editor uses this value to build its responsive grid. It has no effect in the read-only viewer.\n * @default 100\n * @example\n * <Gallery fileMinWidth={140} isEditMode files={files} />\n * @optional\n */\n fileMinWidth?: number;\n /**\n * Defines the icon that is shown in the add-file tile in edit mode.\n * @description\n * The icon is forwarded to the editor and replaces the default plus icon on the add-tile.\n * @default 'fa fa-plus'\n * @example\n * <Gallery addFileIcon=\"fa fa-image-circle-plus\" isEditMode files={files} />\n * @optional\n */\n addFileIcon?: string;\n /**\n * Provides already known media items that should be rendered by the gallery.\n * @description\n * In read-only mode, these files are rendered directly from props. In edit mode, they are used as the external baseline\n * for already uploaded media while local uploads are managed internally.\n * @example\n * <Gallery files={files} />\n * @optional\n */\n files?: FileItem[];\n /**\n * Enables the editable upload mode instead of the read-only viewer mode.\n * @description\n * When set to `true`, the public wrapper renders `GalleryEditor`. Otherwise it renders `GalleryViewer`.\n * @default false\n * @example\n * <Gallery isEditMode files={files} />\n * @optional\n */\n isEditMode?: boolean;\n /**\n * Limits how many files can be managed in edit mode.\n * @description\n * Once the limit is reached, the editor hides the add-tile and does not accept more files.\n * This prop has no effect in read-only mode.\n * @example\n * <Gallery isEditMode maxFiles={6} files={files} />\n * @optional\n */\n maxFiles?: number;\n /**\n * Is called after a file has been uploaded successfully in edit mode.\n * @description\n * The callback receives the uploaded file representation that should be merged into the consuming state.\n * It is never called by the read-only viewer.\n * @example\n * <Gallery isEditMode onAdd={(file) => setFiles((prev) => [...prev, file])} />\n * @optional\n */\n onAdd?: (file: FileItem) => void;\n /**\n * Is called whenever the internal item count changes in edit mode.\n * @description\n * This includes already uploaded files and locally pending uploads that are currently managed by the editor.\n * It is useful when surrounding UI needs to know whether uploads are still in progress.\n * @example\n * <Gallery isEditMode onFileCountChange={(count) => console.log(count)} />\n * @optional\n */\n onFileCountChange?: (fileCount: number) => void;\n /**\n * Is called after an uploaded file has been removed in edit mode.\n * @description\n * The callback receives the removed uploaded file so the consuming state can remove it as well.\n * It is never called by the read-only viewer.\n * @example\n * <Gallery isEditMode onRemove={(file) => removeFile(file.id)} />\n * @optional\n */\n onRemove?: (file: FileItem) => void;\n /**\n * Defines how known media items are arranged in read-only mode.\n * @description\n * This prop only affects the viewer path. The editor always uses its dedicated editable grid layout.\n * @default GalleryViewMode.GRID\n * @example\n * <Gallery files={files} viewMode={GalleryViewMode.SQUARE} />\n * @optional\n */\n viewMode?: GalleryViewMode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Gallery.types.js","names":[],"sources":["../../../src/components/Gallery.types.ts"],"sourcesContent":["import type { FileItem } from '@chayns-components/core';\nimport type { GalleryViewMode } from '../types/gallery';\n\n/**\n * Props for the public Gallery wrapper component.\n */\nexport type GalleryRef = {\n /**\n * Clears all locally managed gallery items in edit mode.\n * @description\n * When the gallery is rendered in read-only mode, calling this method only emits a console warning.\n */\n clear: () => void;\n};\n\nexport interface GalleryProps {\n /**\n * Enables drag and drop while the component is used in edit mode.\n * @description\n * This prop only affects the editor path. In read-only mode, drag and drop stays disabled regardless of this value.\n * @default false\n * @example\n * <Gallery allowDragAndDrop isEditMode files={files} />\n * @optional\n */\n allowDragAndDrop?: boolean;\n /**\n * Defines the dialog message that is shown when a duplicate upload is detected.\n * @description\n * The message is used by the editor when a locally added file resolves to an already known uploaded file.\n * @default 'Diese Datei ist bereits vorhanden'\n * @example\n * <Gallery doubleFileDialogMessage=\"This file already exists.\" isEditMode files={files} />\n * @optional\n */\n doubleFileDialogMessage?: string;\n /**\n * Defines the minimum width of one tile in edit mode.\n * @description\n * The editor uses this value to build its responsive grid. It has no effect in the read-only viewer.\n * @default 100\n * @example\n * <Gallery fileMinWidth={140} isEditMode files={files} />\n * @optional\n */\n fileMinWidth?: number;\n /**\n * Defines the icon that is shown in the add-file tile in edit mode.\n * @description\n * The icon is forwarded to the editor and replaces the default plus icon on the add-tile.\n * @default 'fa fa-plus'\n * @example\n * <Gallery addFileIcon=\"fa fa-image-circle-plus\" isEditMode files={files} />\n * @optional\n */\n addFileIcon?: string;\n /**\n * Provides already known media items that should be rendered by the gallery.\n * @description\n * In read-only mode, these files are rendered directly from props. In edit mode, they are used as the external baseline\n * for already uploaded media while local uploads are managed internally.\n * @example\n * <Gallery files={files} />\n * @optional\n */\n files?: FileItem[];\n /**\n * Enables the editable upload mode instead of the read-only viewer mode.\n * @description\n * When set to `true`, the public wrapper renders `GalleryEditor`. Otherwise it renders `GalleryViewer`.\n * @default false\n * @example\n * <Gallery isEditMode files={files} />\n * @optional\n */\n isEditMode?: boolean;\n /**\n * Limits how many files can be managed in edit mode.\n * @description\n * Once the limit is reached, the editor hides the add-tile and does not accept more files.\n * This prop has no effect in read-only mode.\n * @example\n * <Gallery isEditMode maxFiles={6} files={files} />\n * @optional\n */\n maxFiles?: number;\n /**\n * Controls when the gallery is allowed to load the final media assets.\n * @description\n * When set to `true`, the gallery loads the actual images immediately as before.\n * When set to `false`, the gallery keeps rendering previews first and delays the final media load until this flag becomes `true`.\n * This setting applies to the whole gallery wrapper and is intended for external loading control such as virtualized message lists.\n * @default true\n * @example\n * <Gallery files={files} shouldLoadImages={false} />\n * @optional\n */\n shouldLoadImages?: boolean;\n /**\n * Is called after a file has been uploaded successfully in edit mode.\n * @description\n * The callback receives the uploaded file representation that should be merged into the consuming state.\n * It is never called by the read-only viewer.\n * @example\n * <Gallery isEditMode onAdd={(file) => setFiles((prev) => [...prev, file])} />\n * @optional\n */\n onAdd?: (file: FileItem) => void;\n /**\n * Is called whenever the internal item count changes in edit mode.\n * @description\n * This includes already uploaded files and locally pending uploads that are currently managed by the editor.\n * It is useful when surrounding UI needs to know whether uploads are still in progress.\n * @example\n * <Gallery isEditMode onFileCountChange={(count) => console.log(count)} />\n * @optional\n */\n onFileCountChange?: (fileCount: number) => void;\n /**\n * Is called after an uploaded file has been removed in edit mode.\n * @description\n * The callback receives the removed uploaded file so the consuming state can remove it as well.\n * It is never called by the read-only viewer.\n * @example\n * <Gallery isEditMode onRemove={(file) => removeFile(file.id)} />\n * @optional\n */\n onRemove?: (file: FileItem) => void;\n /**\n * Defines how known media items are arranged in read-only mode.\n * @description\n * This prop only affects the viewer path. The editor always uses its dedicated editable grid layout.\n * @default GalleryViewMode.GRID\n * @example\n * <Gallery files={files} viewMode={GalleryViewMode.SQUARE} />\n * @optional\n */\n viewMode?: GalleryViewMode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GALLERY_EDITOR_PREVIEW_FADE_DURATION_S = exports.GALLERY_EDITOR_MEDIA_FADE_DURATION_S = exports.GALLERY_EDITOR_ITEM_FADE_DURATION_S = exports.GALLERY_EDITOR_GRID_GAP_PX = exports.GALLERY_EDITOR_DELETE_BUTTON_Z_INDEX = void 0;
|
|
7
|
+
const GALLERY_EDITOR_GRID_GAP_PX = exports.GALLERY_EDITOR_GRID_GAP_PX = 6;
|
|
8
|
+
const GALLERY_EDITOR_ITEM_FADE_DURATION_S = exports.GALLERY_EDITOR_ITEM_FADE_DURATION_S = 0.18;
|
|
9
|
+
const GALLERY_EDITOR_PREVIEW_FADE_DURATION_S = exports.GALLERY_EDITOR_PREVIEW_FADE_DURATION_S = 0.16;
|
|
10
|
+
const GALLERY_EDITOR_MEDIA_FADE_DURATION_S = exports.GALLERY_EDITOR_MEDIA_FADE_DURATION_S = 0.2;
|
|
11
|
+
const GALLERY_EDITOR_DELETE_BUTTON_Z_INDEX = exports.GALLERY_EDITOR_DELETE_BUTTON_Z_INDEX = 3;
|
|
12
|
+
//# sourceMappingURL=GalleryEditor.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GalleryEditor.constants.js","names":["GALLERY_EDITOR_GRID_GAP_PX","exports","GALLERY_EDITOR_ITEM_FADE_DURATION_S","GALLERY_EDITOR_PREVIEW_FADE_DURATION_S","GALLERY_EDITOR_MEDIA_FADE_DURATION_S","GALLERY_EDITOR_DELETE_BUTTON_Z_INDEX"],"sources":["../../../../src/components/gallery-editor/GalleryEditor.constants.ts"],"sourcesContent":["export const GALLERY_EDITOR_GRID_GAP_PX = 6;\nexport const GALLERY_EDITOR_ITEM_FADE_DURATION_S = 0.18;\nexport const GALLERY_EDITOR_PREVIEW_FADE_DURATION_S = 0.16;\nexport const GALLERY_EDITOR_MEDIA_FADE_DURATION_S = 0.2;\nexport const GALLERY_EDITOR_DELETE_BUTTON_Z_INDEX = 3;\n"],"mappings":";;;;;;AAAO,MAAMA,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,GAAG,CAAC;AACpC,MAAME,mCAAmC,GAAAD,OAAA,CAAAC,mCAAA,GAAG,IAAI;AAChD,MAAMC,sCAAsC,GAAAF,OAAA,CAAAE,sCAAA,GAAG,IAAI;AACnD,MAAMC,oCAAoC,GAAAH,OAAA,CAAAG,oCAAA,GAAG,GAAG;AAChD,MAAMC,oCAAoC,GAAAJ,OAAA,CAAAI,oCAAA,GAAG,CAAC","ignoreList":[]}
|
|
@@ -4,18 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _uuid = require("uuid");
|
|
11
|
-
var _file = require("../../utils/file");
|
|
12
|
-
var _gallery = require("../../utils/gallery");
|
|
7
|
+
var _react = require("motion/react");
|
|
8
|
+
var _react2 = _interopRequireWildcard(require("react"));
|
|
13
9
|
var _AddFile = _interopRequireDefault(require("./add-file/AddFile"));
|
|
14
|
-
var _GalleryEditorItem = _interopRequireDefault(require("./gallery-editor-item/GalleryEditorItem"));
|
|
15
10
|
var _GalleryEditor = require("./GalleryEditor.styles");
|
|
11
|
+
var _GalleryEditorItem = _interopRequireDefault(require("./gallery-editor-item/GalleryEditorItem"));
|
|
12
|
+
var _GalleryEditor2 = require("./GalleryEditor.constants");
|
|
13
|
+
var _useGalleryEditorState = _interopRequireDefault(require("./useGalleryEditorState"));
|
|
16
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
-
const GalleryEditor = /*#__PURE__*/(0,
|
|
16
|
+
const GalleryEditor = /*#__PURE__*/(0, _react2.forwardRef)(({
|
|
19
17
|
allowDragAndDrop = false,
|
|
20
18
|
addFileIcon = 'fa fa-plus',
|
|
21
19
|
doubleFileDialogMessage = 'Diese Datei ist bereits vorhanden',
|
|
@@ -24,182 +22,46 @@ const GalleryEditor = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
24
22
|
maxFiles,
|
|
25
23
|
onAdd,
|
|
26
24
|
onFileCountChange,
|
|
27
|
-
onRemove
|
|
25
|
+
onRemove,
|
|
26
|
+
shouldLoadImages = true
|
|
28
27
|
}, ref) => {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type: _chaynsApi.DialogType.ALERT,
|
|
47
|
-
text: doubleFileDialogMessage
|
|
48
|
-
});
|
|
49
|
-
}, [doubleFileDialogMessage]);
|
|
50
|
-
const handleUploadFileCallback = (0, _react.useCallback)((file, uploadedFile) => {
|
|
51
|
-
setFileItems(prevState => {
|
|
52
|
-
const updatedState = prevState.map(prevFile => {
|
|
53
|
-
var _prevFile$uploadedFil;
|
|
54
|
-
if (((_prevFile$uploadedFil = prevFile.uploadedFile) === null || _prevFile$uploadedFil === void 0 ? void 0 : _prevFile$uploadedFil.url) === uploadedFile.url) {
|
|
55
|
-
callDuplicateFileDialog();
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
if (prevFile.id === file.id) {
|
|
59
|
-
if (typeof onAdd === 'function') {
|
|
60
|
-
const prevElement = prevState.find(({
|
|
61
|
-
uploadedFile: nextUploadedFile
|
|
62
|
-
}) => (nextUploadedFile === null || nextUploadedFile === void 0 ? void 0 : nextUploadedFile.url) === (uploadedFile === null || uploadedFile === void 0 ? void 0 : uploadedFile.url));
|
|
63
|
-
if (!prevElement) {
|
|
64
|
-
onAdd({
|
|
65
|
-
file: uploadedFile,
|
|
66
|
-
id: file.id
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
...prevFile,
|
|
72
|
-
uploadedFile,
|
|
73
|
-
state: 'uploaded'
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return prevFile;
|
|
77
|
-
});
|
|
78
|
-
return updatedState.filter(Boolean);
|
|
79
|
-
});
|
|
80
|
-
}, [callDuplicateFileDialog, onAdd]);
|
|
81
|
-
const handleAddFiles = (0, _react.useCallback)(filesToAdd => {
|
|
82
|
-
const newFileItems = [];
|
|
83
|
-
filesToAdd.forEach(file => {
|
|
84
|
-
if (file && !(0, _file.filterDuplicateFile)({
|
|
85
|
-
files: fileItems,
|
|
86
|
-
newFile: file
|
|
87
|
-
})) {
|
|
88
|
-
newFileItems.push({
|
|
89
|
-
id: (0, _uuid.v4)(),
|
|
90
|
-
file,
|
|
91
|
-
state: 'none'
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
let limitedFileItems = newFileItems;
|
|
96
|
-
if (maxFiles) {
|
|
97
|
-
limitedFileItems = newFileItems.slice(0, Math.max(maxFiles - fileItems.length, 0));
|
|
98
|
-
}
|
|
99
|
-
setFileItems(prevState => [...prevState, ...limitedFileItems]);
|
|
100
|
-
}, [fileItems, maxFiles]);
|
|
101
|
-
const handleDeleteFile = (0, _react.useCallback)(id => {
|
|
102
|
-
let fileToDelete;
|
|
103
|
-
const filteredFiles = fileItems.filter(file => {
|
|
104
|
-
if (file.id === id && file.uploadedFile) {
|
|
105
|
-
fileToDelete = {
|
|
106
|
-
file: file.uploadedFile,
|
|
107
|
-
id
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return file.id !== id;
|
|
111
|
-
});
|
|
112
|
-
setFileItems(filteredFiles);
|
|
113
|
-
if (!fileToDelete || typeof onRemove !== 'function') {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
onRemove(fileToDelete);
|
|
117
|
-
}, [fileItems, onRemove]);
|
|
118
|
-
const handleDrop = (0, _react.useCallback)(event => {
|
|
119
|
-
if (!allowDragAndDrop) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
event.preventDefault();
|
|
123
|
-
handleAddFiles(Array.from(event.dataTransfer.files));
|
|
124
|
-
}, [allowDragAndDrop, handleAddFiles]);
|
|
125
|
-
const handleOpenFiles = (0, _react.useCallback)(file => {
|
|
126
|
-
(0, _gallery.openFiles)(fileItems, file);
|
|
127
|
-
}, [fileItems]);
|
|
128
|
-
(0, _react.useImperativeHandle)(ref, () => ({
|
|
28
|
+
const {
|
|
29
|
+
fileItems,
|
|
30
|
+
handleAddFiles,
|
|
31
|
+
handleClear,
|
|
32
|
+
handleDeleteFile,
|
|
33
|
+
handleDrop,
|
|
34
|
+
handleOpenFiles
|
|
35
|
+
} = (0, _useGalleryEditorState.default)({
|
|
36
|
+
allowDragAndDrop,
|
|
37
|
+
doubleFileDialogMessage,
|
|
38
|
+
files,
|
|
39
|
+
maxFiles,
|
|
40
|
+
onAdd,
|
|
41
|
+
onFileCountChange,
|
|
42
|
+
onRemove
|
|
43
|
+
});
|
|
44
|
+
(0, _react2.useImperativeHandle)(ref, () => ({
|
|
129
45
|
clear: handleClear
|
|
130
46
|
}), [handleClear]);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
onFileCountChange(fileItems.length);
|
|
134
|
-
}
|
|
135
|
-
}, [fileItems.length, onFileCountChange]);
|
|
136
|
-
(0, _react.useEffect)(() => {
|
|
137
|
-
const filesToGeneratePreview = fileItems.filter(file => file.file && !file.previewUrl && (file.state === 'none' || !file.state));
|
|
138
|
-
const filesToUpload = fileItems.filter(file => file.file && !file.uploadedFile && file.state !== 'uploading');
|
|
139
|
-
filesToGeneratePreview.forEach(file => {
|
|
140
|
-
if (!file.file) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (file.file.type.includes('video/')) {
|
|
144
|
-
(0, _file.generateVideoThumbnail)({
|
|
145
|
-
file: file.file,
|
|
146
|
-
callback: previewUrl => handlePreviewUrlCallback(previewUrl, file)
|
|
147
|
-
});
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
(0, _file.generatePreviewUrl)({
|
|
151
|
-
file: file.file,
|
|
152
|
-
callback: previewUrl => handlePreviewUrlCallback(previewUrl, file)
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
filesToUpload.forEach(file => {
|
|
156
|
-
setFileItems(prevState => prevState.map(prevFile => {
|
|
157
|
-
if (prevFile.id === file.id) {
|
|
158
|
-
return {
|
|
159
|
-
...prevFile,
|
|
160
|
-
state: 'uploading'
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return prevFile;
|
|
164
|
-
}));
|
|
165
|
-
void (0, _core.uploadFile)({
|
|
166
|
-
fileToUpload: file,
|
|
167
|
-
callback: uploadedFile => handleUploadFileCallback(file, uploadedFile)
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}, [fileItems, handlePreviewUrlCallback, handleUploadFileCallback]);
|
|
171
|
-
(0, _react.useEffect)(() => {
|
|
172
|
-
const externalFileItems = (0, _gallery.mapFilesToInternalItems)(files);
|
|
173
|
-
setFileItems(prevState => {
|
|
174
|
-
// Keep local-only items such as pending uploads while refreshing known external media.
|
|
175
|
-
const updatedItems = prevState.map(prevItem => {
|
|
176
|
-
const matchingItem = externalFileItems.find(item => item.uploadedFile && item.uploadedFile.url === (prevItem.uploadedFile && prevItem.uploadedFile.url));
|
|
177
|
-
return matchingItem || prevItem;
|
|
178
|
-
});
|
|
179
|
-
return updatedItems.concat(externalFileItems.filter(newItem => !prevState.some(prevItem => prevItem.uploadedFile && newItem.uploadedFile && prevItem.uploadedFile.url === newItem.uploadedFile.url)));
|
|
180
|
-
});
|
|
181
|
-
}, [files]);
|
|
182
|
-
const galleryItems = (0, _react.useMemo)(() => {
|
|
183
|
-
const items = fileItems.map(file => /*#__PURE__*/_react.default.createElement(_GalleryEditorItem.default, {
|
|
184
|
-
key: file.id,
|
|
185
|
-
fileItem: file,
|
|
186
|
-
onClick: handleOpenFiles,
|
|
187
|
-
handleDeleteFile: handleDeleteFile
|
|
188
|
-
}));
|
|
189
|
-
if (maxFiles && maxFiles <= fileItems.length) {
|
|
190
|
-
return items;
|
|
191
|
-
}
|
|
192
|
-
return [...items, /*#__PURE__*/_react.default.createElement(_AddFile.default, {
|
|
193
|
-
key: "add_file",
|
|
194
|
-
addFileIcon: addFileIcon,
|
|
195
|
-
onAdd: handleAddFiles
|
|
196
|
-
})];
|
|
197
|
-
}, [addFileIcon, fileItems, handleAddFiles, handleDeleteFile, handleOpenFiles, maxFiles]);
|
|
198
|
-
return /*#__PURE__*/_react.default.createElement(_GalleryEditor.StyledGalleryEditor, null, /*#__PURE__*/_react.default.createElement(_GalleryEditor.StyledGalleryEditorGrid, {
|
|
47
|
+
const shouldShowAddFileTile = !maxFiles || maxFiles > fileItems.length;
|
|
48
|
+
return /*#__PURE__*/_react2.default.createElement(_GalleryEditor.StyledGalleryEditor, null, /*#__PURE__*/_react2.default.createElement(_GalleryEditor.StyledGalleryEditorGrid, {
|
|
199
49
|
$fileMinWidth: fileMinWidth,
|
|
50
|
+
$gap: _GalleryEditor2.GALLERY_EDITOR_GRID_GAP_PX,
|
|
200
51
|
onDragOver: event => event.preventDefault(),
|
|
201
52
|
onDrop: event => void handleDrop(event)
|
|
202
|
-
},
|
|
53
|
+
}, /*#__PURE__*/_react2.default.createElement(_react.AnimatePresence, {
|
|
54
|
+
initial: false
|
|
55
|
+
}, fileItems.map(file => /*#__PURE__*/_react2.default.createElement(_GalleryEditorItem.default, {
|
|
56
|
+
key: file.id,
|
|
57
|
+
fileItem: file,
|
|
58
|
+
handleDeleteFile: handleDeleteFile,
|
|
59
|
+
onClick: handleOpenFiles,
|
|
60
|
+
shouldLoadImages: shouldLoadImages
|
|
61
|
+
}))), shouldShowAddFileTile && /*#__PURE__*/_react2.default.createElement(_AddFile.default, {
|
|
62
|
+
addFileIcon: addFileIcon,
|
|
63
|
+
onAdd: handleAddFiles
|
|
64
|
+
})));
|
|
203
65
|
});
|
|
204
66
|
GalleryEditor.displayName = 'GalleryEditor';
|
|
205
67
|
var _default = exports.default = GalleryEditor;
|