@chayns-components/gallery 5.0.53 → 5.0.56
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 +135 -72
- package/lib/cjs/components/Gallery.js +16 -329
- package/lib/cjs/components/Gallery.js.map +1 -1
- package/lib/cjs/components/Gallery.types.js +6 -0
- package/lib/cjs/components/Gallery.types.js.map +1 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.js +198 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.js.map +1 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.styles.js +20 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.styles.js.map +1 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.types.js +6 -0
- package/lib/cjs/components/gallery-editor/GalleryEditor.types.js.map +1 -0
- package/lib/cjs/components/gallery-editor/add-file/AddFile.js.map +1 -0
- package/lib/cjs/components/gallery-editor/add-file/AddFile.styles.js.map +1 -0
- package/lib/cjs/components/gallery-editor/add-file/AddFile.types.js +6 -0
- package/lib/cjs/components/gallery-editor/add-file/AddFile.types.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.js +41 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.js +37 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.types.js +6 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/GalleryEditorItem.types.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.js +36 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.styles.js +15 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.styles.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.types.js +6 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.types.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.js +45 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.styles.js +44 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.styles.js.map +1 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.types.js +6 -0
- package/lib/cjs/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.types.js.map +1 -0
- package/lib/cjs/components/gallery-viewer/GalleryViewer.js +42 -0
- package/lib/cjs/components/gallery-viewer/GalleryViewer.js.map +1 -0
- package/lib/cjs/components/{Gallery.styles.js → gallery-viewer/GalleryViewer.styles.js} +13 -18
- package/lib/cjs/components/gallery-viewer/GalleryViewer.styles.js.map +1 -0
- package/lib/cjs/components/gallery-viewer/GalleryViewer.types.js +6 -0
- package/lib/cjs/components/gallery-viewer/GalleryViewer.types.js.map +1 -0
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.js +25 -0
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.js.map +1 -0
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.styles.js +30 -0
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.styles.js.map +1 -0
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.js +6 -0
- package/lib/cjs/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.js.map +1 -0
- package/lib/cjs/components/media-content/MediaContent.js +36 -0
- package/lib/cjs/components/media-content/MediaContent.js.map +1 -0
- package/lib/cjs/components/media-content/MediaContent.styles.js +56 -0
- package/lib/cjs/components/media-content/MediaContent.styles.js.map +1 -0
- package/lib/cjs/components/media-content/MediaContent.types.js +6 -0
- package/lib/cjs/components/media-content/MediaContent.types.js.map +1 -0
- package/lib/cjs/index.js +14 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types/gallery.js +9 -0
- package/lib/cjs/types/gallery.js.map +1 -1
- package/lib/cjs/utils/gallery.js +152 -0
- package/lib/cjs/utils/gallery.js.map +1 -0
- package/lib/esm/components/Gallery.js +16 -319
- package/lib/esm/components/Gallery.js.map +1 -1
- package/lib/esm/components/Gallery.types.js +2 -0
- package/lib/esm/components/Gallery.types.js.map +1 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.js +189 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.js.map +1 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.styles.js +13 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.styles.js.map +1 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.types.js +2 -0
- package/lib/esm/components/gallery-editor/GalleryEditor.types.js.map +1 -0
- package/lib/esm/components/gallery-editor/add-file/AddFile.js.map +1 -0
- package/lib/esm/components/gallery-editor/add-file/AddFile.styles.js.map +1 -0
- package/lib/esm/components/gallery-editor/add-file/AddFile.types.js +2 -0
- package/lib/esm/components/gallery-editor/add-file/AddFile.types.js.map +1 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.js +34 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.js.map +1 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.js +30 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.js.map +1 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.types.js +2 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/GalleryEditorItem.types.js.map +1 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.js +29 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.js.map +1 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.styles.js +8 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.styles.js.map +1 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.types.js +2 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.types.js.map +1 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.js +38 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.js.map +1 -0
- package/lib/esm/components/{gallery-item/preview-item/PreviewItem.styles.js → gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.styles.js} +7 -6
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.styles.js.map +1 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.types.js +2 -0
- package/lib/esm/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.types.js.map +1 -0
- package/lib/esm/components/gallery-viewer/GalleryViewer.js +34 -0
- package/lib/esm/components/gallery-viewer/GalleryViewer.js.map +1 -0
- package/lib/esm/components/{Gallery.styles.js → gallery-viewer/GalleryViewer.styles.js} +12 -17
- package/lib/esm/components/gallery-viewer/GalleryViewer.styles.js.map +1 -0
- package/lib/esm/components/gallery-viewer/GalleryViewer.types.js +2 -0
- package/lib/esm/components/gallery-viewer/GalleryViewer.types.js.map +1 -0
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.js +18 -0
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.js.map +1 -0
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.styles.js +23 -0
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.styles.js.map +1 -0
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.js +2 -0
- package/lib/esm/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.js.map +1 -0
- package/lib/esm/components/media-content/MediaContent.js +29 -0
- package/lib/esm/components/media-content/MediaContent.js.map +1 -0
- package/lib/esm/components/media-content/MediaContent.styles.js +49 -0
- package/lib/esm/components/media-content/MediaContent.styles.js.map +1 -0
- package/lib/esm/components/media-content/MediaContent.types.js +2 -0
- package/lib/esm/components/media-content/MediaContent.types.js.map +1 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types/gallery.js +9 -0
- package/lib/esm/types/gallery.js.map +1 -1
- package/lib/esm/utils/gallery.js +132 -0
- package/lib/esm/utils/gallery.js.map +1 -0
- package/lib/types/components/Gallery.d.ts +1 -44
- package/lib/types/components/Gallery.types.d.ts +107 -0
- package/lib/types/components/gallery-editor/GalleryEditor.d.ts +4 -0
- package/lib/types/components/gallery-editor/GalleryEditor.styles.d.ts +4 -0
- package/lib/types/components/gallery-editor/GalleryEditor.types.d.ts +81 -0
- package/lib/types/components/gallery-editor/add-file/AddFile.d.ts +4 -0
- package/lib/types/components/gallery-editor/add-file/AddFile.types.d.ts +13 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/GalleryEditorItem.d.ts +4 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/GalleryEditorItem.styles.d.ts +4 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/GalleryEditorItem.types.d.ts +40 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.d.ts +4 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.styles.d.ts +3 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-media-item/GalleryEditorMediaItem.types.d.ts +30 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.d.ts +4 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.styles.d.ts +10 -0
- package/lib/types/components/gallery-editor/gallery-editor-item/gallery-editor-preview-item/GalleryEditorPreviewItem.types.d.ts +22 -0
- package/lib/types/components/gallery-viewer/GalleryViewer.d.ts +4 -0
- package/lib/types/components/gallery-viewer/GalleryViewer.styles.d.ts +7 -0
- package/lib/types/components/gallery-viewer/GalleryViewer.types.d.ts +26 -0
- package/lib/types/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.d.ts +4 -0
- package/lib/types/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.styles.d.ts +2 -0
- package/lib/types/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.d.ts +41 -0
- package/lib/types/components/media-content/MediaContent.d.ts +4 -0
- package/lib/types/components/media-content/MediaContent.styles.d.ts +13 -0
- package/lib/types/components/media-content/MediaContent.types.d.ts +40 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/types/gallery.d.ts +9 -0
- package/lib/types/utils/gallery.d.ts +12 -0
- package/package.json +3 -3
- package/lib/cjs/components/Gallery.styles.js.map +0 -1
- package/lib/cjs/components/add-file/AddFile.js.map +0 -1
- package/lib/cjs/components/add-file/AddFile.styles.js.map +0 -1
- package/lib/cjs/components/gallery-item/GalleryItem.js +0 -44
- package/lib/cjs/components/gallery-item/GalleryItem.js.map +0 -1
- package/lib/cjs/components/gallery-item/GalleryItem.styles.js +0 -51
- package/lib/cjs/components/gallery-item/GalleryItem.styles.js.map +0 -1
- package/lib/cjs/components/gallery-item/media-item/MediaItem.js +0 -52
- package/lib/cjs/components/gallery-item/media-item/MediaItem.js.map +0 -1
- package/lib/cjs/components/gallery-item/media-item/MediaItem.styles.js +0 -62
- package/lib/cjs/components/gallery-item/media-item/MediaItem.styles.js.map +0 -1
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.js +0 -45
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.js.map +0 -1
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.styles.js +0 -43
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.styles.js.map +0 -1
- package/lib/esm/components/Gallery.styles.js.map +0 -1
- package/lib/esm/components/add-file/AddFile.js.map +0 -1
- package/lib/esm/components/add-file/AddFile.styles.js.map +0 -1
- package/lib/esm/components/gallery-item/GalleryItem.js +0 -36
- package/lib/esm/components/gallery-item/GalleryItem.js.map +0 -1
- package/lib/esm/components/gallery-item/GalleryItem.styles.js +0 -44
- package/lib/esm/components/gallery-item/GalleryItem.styles.js.map +0 -1
- package/lib/esm/components/gallery-item/media-item/MediaItem.js +0 -42
- package/lib/esm/components/gallery-item/media-item/MediaItem.js.map +0 -1
- package/lib/esm/components/gallery-item/media-item/MediaItem.styles.js +0 -55
- package/lib/esm/components/gallery-item/media-item/MediaItem.styles.js.map +0 -1
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.js +0 -38
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.js.map +0 -1
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.styles.js.map +0 -1
- package/lib/types/components/Gallery.styles.d.ts +0 -10
- package/lib/types/components/add-file/AddFile.d.ts +0 -9
- package/lib/types/components/gallery-item/GalleryItem.d.ts +0 -30
- package/lib/types/components/gallery-item/GalleryItem.styles.d.ts +0 -5
- package/lib/types/components/gallery-item/media-item/MediaItem.d.ts +0 -22
- package/lib/types/components/gallery-item/media-item/MediaItem.styles.d.ts +0 -16
- package/lib/types/components/gallery-item/preview-item/PreviewItem.d.ts +0 -14
- package/lib/types/components/gallery-item/preview-item/PreviewItem.styles.d.ts +0 -10
- /package/lib/cjs/components/{add-file → gallery-editor/add-file}/AddFile.js +0 -0
- /package/lib/cjs/components/{add-file → gallery-editor/add-file}/AddFile.styles.js +0 -0
- /package/lib/esm/components/{add-file → gallery-editor/add-file}/AddFile.js +0 -0
- /package/lib/esm/components/{add-file → gallery-editor/add-file}/AddFile.styles.js +0 -0
- /package/lib/types/components/{add-file → gallery-editor/add-file}/AddFile.styles.d.ts +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
import { GalleryViewMode } from '
|
|
3
|
-
export const
|
|
2
|
+
import { GalleryViewMode } from '../../types/gallery';
|
|
3
|
+
export const StyledGalleryViewer = styled.div`
|
|
4
4
|
width: 100%;
|
|
5
5
|
`;
|
|
6
|
-
export const
|
|
6
|
+
export const StyledGalleryViewerItemWrapper = styled.div`
|
|
7
7
|
display: grid;
|
|
8
8
|
gap: 5px;
|
|
9
9
|
|
|
10
10
|
${({
|
|
11
11
|
$viewMode,
|
|
12
|
-
$
|
|
12
|
+
$itemCount
|
|
13
13
|
}) => {
|
|
14
14
|
if ($viewMode === GalleryViewMode.GRID) {
|
|
15
15
|
return css`
|
|
@@ -18,7 +18,7 @@ export const StyledGalleryItemWrapper = styled.div`
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
${() => {
|
|
21
|
-
switch ($
|
|
21
|
+
switch ($itemCount) {
|
|
22
22
|
case 1:
|
|
23
23
|
return css`
|
|
24
24
|
grid-template-columns: 1fr;
|
|
@@ -48,7 +48,7 @@ export const StyledGalleryItemWrapper = styled.div`
|
|
|
48
48
|
}}
|
|
49
49
|
`;
|
|
50
50
|
}
|
|
51
|
-
switch ($
|
|
51
|
+
switch ($itemCount) {
|
|
52
52
|
case 1:
|
|
53
53
|
return css`
|
|
54
54
|
grid-template-columns: 1fr;
|
|
@@ -71,16 +71,11 @@ export const StyledGalleryItemWrapper = styled.div`
|
|
|
71
71
|
}
|
|
72
72
|
}}
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
${({
|
|
75
|
+
$itemCount,
|
|
75
76
|
$ratio
|
|
76
|
-
}) => $
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
display: grid;
|
|
80
|
-
grid-template-columns: ${({
|
|
81
|
-
$fileMinWidth
|
|
82
|
-
}) => `repeat(auto-fill, minmax(${$fileMinWidth}px, 1fr))`};
|
|
83
|
-
grid-auto-rows: 1fr;
|
|
84
|
-
gap: 6px;
|
|
77
|
+
}) => $itemCount > 0 ? css`
|
|
78
|
+
aspect-ratio: ${$ratio};
|
|
79
|
+
` : ''}
|
|
85
80
|
`;
|
|
86
|
-
//# sourceMappingURL=
|
|
81
|
+
//# sourceMappingURL=GalleryViewer.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GalleryViewer.styles.js","names":["styled","css","GalleryViewMode","StyledGalleryViewer","div","StyledGalleryViewerItemWrapper","$viewMode","$itemCount","GRID","$ratio"],"sources":["../../../../src/components/gallery-viewer/GalleryViewer.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { GalleryViewMode } from '../../types/gallery';\n\nexport const StyledGalleryViewer = styled.div`\n width: 100%;\n`;\n\nexport const StyledGalleryViewerItemWrapper = styled.div<{\n $itemCount: number;\n $ratio: number;\n $viewMode: GalleryViewMode;\n}>`\n display: grid;\n gap: 5px;\n\n ${({ $viewMode, $itemCount }) => {\n if ($viewMode === GalleryViewMode.GRID) {\n return css`\n > div:first-child {\n grid-column: 1 / -1;\n }\n\n ${() => {\n switch ($itemCount) {\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 ($itemCount) {\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 ${({ $itemCount, $ratio }) =>\n $itemCount > 0\n ? css`\n aspect-ratio: ${$ratio};\n `\n : ''}\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAC/C,SAASC,eAAe,QAAQ,qBAAqB;AAErD,OAAO,MAAMC,mBAAmB,GAAGH,MAAM,CAACI,GAAG;AAC7C;AACA,CAAC;AAED,OAAO,MAAMC,8BAA8B,GAAGL,MAAM,CAACI,GAInD;AACF;AACA;AACA;AACA,MAAM,CAAC;EAAEE,SAAS;EAAEC;AAAW,CAAC,KAAK;EAC7B,IAAID,SAAS,KAAKJ,eAAe,CAACM,IAAI,EAAE;IACpC,OAAOP,GAAG;AACtB;AACA;AACA;AACA;AACA,kBAAkB,MAAM;MACJ,QAAQM,UAAU;QACd,KAAK,CAAC;UACF,OAAON,GAAG;AACtC;AACA,6BAA6B;QACL,KAAK,CAAC;UACF,OAAOA,GAAG;AACtC;AACA;AACA;AACA;AACA,6BAA6B;QACL,KAAK,CAAC;UACF,OAAOA,GAAG;AACtC;AACA;AACA;AACA;AACA,6BAA6B;QACL;UACI,OAAOA,GAAG;AACtC;AACA;AACA;AACA;AACA,6BAA6B;MACT;IACJ,CAAC;AACjB,aAAa;EACL;EAEA,QAAQM,UAAU;IACd,KAAK,CAAC;MACF,OAAON,GAAG;AAC1B;AACA,iBAAiB;IACL,KAAK,CAAC;MACF,OAAOA,GAAG;AAC1B;AACA,iBAAiB;IACL,KAAK,CAAC;MACF,OAAOA,GAAG;AAC1B;AACA,iBAAiB;IACL;MACI,OAAOA,GAAG;AAC1B;AACA;AACA;AACA;AACA,iBAAiB;EACT;AACJ,CAAC;AACL;AACA,MAAM,CAAC;EAAEM,UAAU;EAAEE;AAAO,CAAC,KACrBF,UAAU,GAAG,CAAC,GACRN,GAAG;AACjB,kCAAkCQ,MAAM;AACxC,eAAe,GACD,EAAE;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GalleryViewer.types.js","names":[],"sources":["../../../../src/components/gallery-viewer/GalleryViewer.types.ts"],"sourcesContent":["import type { FileItem } from '@chayns-components/core';\nimport type { GalleryViewMode } from '../../types/gallery';\n\n/**\n * Props for the prop-driven read-only gallery viewer.\n */\nexport interface GalleryViewerProps {\n /**\n * Provides the already known media items that should be rendered without local upload state.\n * @description\n * The viewer renders these files directly from props and does not mirror them into local component state.\n * @example\n * <GalleryViewer files={files} />\n * @optional\n */\n files?: FileItem[];\n /**\n * Defines how the media tiles are arranged in read-only mode.\n * @description\n * Use this prop to switch between the supported viewer layouts for known media.\n * @default GalleryViewMode.GRID\n * @example\n * <GalleryViewer files={files} viewMode={GalleryViewMode.SQUARE} />\n * @optional\n */\n viewMode?: GalleryViewMode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import MediaContent from '../../media-content/MediaContent';
|
|
3
|
+
import { StyledGalleryViewerItem, StyledGalleryViewerMoreItemsIndicator } from './GalleryViewerItem.styles';
|
|
4
|
+
const GalleryViewerItem = ({
|
|
5
|
+
fileItem,
|
|
6
|
+
ratio = 1,
|
|
7
|
+
remainingItemsLength,
|
|
8
|
+
onClick
|
|
9
|
+
}) => /*#__PURE__*/React.createElement(StyledGalleryViewerItem, null, /*#__PURE__*/React.createElement(MediaContent, {
|
|
10
|
+
file: fileItem.file,
|
|
11
|
+
onClick: () => onClick(fileItem),
|
|
12
|
+
ratio: ratio
|
|
13
|
+
}), remainingItemsLength && /*#__PURE__*/React.createElement(StyledGalleryViewerMoreItemsIndicator, {
|
|
14
|
+
onClick: () => onClick(fileItem)
|
|
15
|
+
}, /*#__PURE__*/React.createElement("p", null, `+ ${remainingItemsLength - 3}`)));
|
|
16
|
+
GalleryViewerItem.displayName = 'GalleryViewerItem';
|
|
17
|
+
export default GalleryViewerItem;
|
|
18
|
+
//# sourceMappingURL=GalleryViewerItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GalleryViewerItem.js","names":["React","MediaContent","StyledGalleryViewerItem","StyledGalleryViewerMoreItemsIndicator","GalleryViewerItem","fileItem","ratio","remainingItemsLength","onClick","createElement","file","displayName"],"sources":["../../../../../src/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport MediaContent from '../../media-content/MediaContent';\nimport {\n StyledGalleryViewerItem,\n StyledGalleryViewerMoreItemsIndicator,\n} from './GalleryViewerItem.styles';\nimport type { GalleryViewerItemProps } from './GalleryViewerItem.types';\n\nconst GalleryViewerItem: FC<GalleryViewerItemProps> = ({\n fileItem,\n ratio = 1,\n remainingItemsLength,\n onClick,\n}) => (\n <StyledGalleryViewerItem>\n <MediaContent file={fileItem.file} onClick={() => onClick(fileItem)} ratio={ratio} />\n {remainingItemsLength && (\n <StyledGalleryViewerMoreItemsIndicator onClick={() => onClick(fileItem)}>\n <p>{`+ ${remainingItemsLength - 3}`}</p>\n </StyledGalleryViewerMoreItemsIndicator>\n )}\n </StyledGalleryViewerItem>\n);\n\nGalleryViewerItem.displayName = 'GalleryViewerItem';\n\nexport default GalleryViewerItem;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAc,OAAO;AACjC,OAAOC,YAAY,MAAM,kCAAkC;AAC3D,SACIC,uBAAuB,EACvBC,qCAAqC,QAClC,4BAA4B;AAGnC,MAAMC,iBAA6C,GAAGA,CAAC;EACnDC,QAAQ;EACRC,KAAK,GAAG,CAAC;EACTC,oBAAoB;EACpBC;AACJ,CAAC,kBACGR,KAAA,CAAAS,aAAA,CAACP,uBAAuB,qBACpBF,KAAA,CAAAS,aAAA,CAACR,YAAY;EAACS,IAAI,EAAEL,QAAQ,CAACK,IAAK;EAACF,OAAO,EAAEA,CAAA,KAAMA,OAAO,CAACH,QAAQ,CAAE;EAACC,KAAK,EAAEA;AAAM,CAAE,CAAC,EACpFC,oBAAoB,iBACjBP,KAAA,CAAAS,aAAA,CAACN,qCAAqC;EAACK,OAAO,EAAEA,CAAA,KAAMA,OAAO,CAACH,QAAQ;AAAE,gBACpEL,KAAA,CAAAS,aAAA,YAAI,KAAKF,oBAAoB,GAAG,CAAC,EAAM,CACJ,CAEtB,CAC5B;AAEDH,iBAAiB,CAACO,WAAW,GAAG,mBAAmB;AAEnD,eAAeP,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const StyledGalleryViewerItem = styled.div`
|
|
3
|
+
display: flex;
|
|
4
|
+
position: relative;
|
|
5
|
+
height: 100%;
|
|
6
|
+
width: 100%;
|
|
7
|
+
`;
|
|
8
|
+
export const StyledGalleryViewerMoreItemsIndicator = styled.div`
|
|
9
|
+
position: absolute;
|
|
10
|
+
z-index: 2;
|
|
11
|
+
height: 100%;
|
|
12
|
+
width: 100%;
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
backdrop-filter: brightness(40%);
|
|
17
|
+
|
|
18
|
+
p {
|
|
19
|
+
font-size: 40px;
|
|
20
|
+
color: white;
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
//# sourceMappingURL=GalleryViewerItem.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GalleryViewerItem.styles.js","names":["styled","StyledGalleryViewerItem","div","StyledGalleryViewerMoreItemsIndicator"],"sources":["../../../../../src/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledGalleryViewerItem = styled.div`\n display: flex;\n position: relative;\n height: 100%;\n width: 100%;\n`;\n\nexport const StyledGalleryViewerMoreItemsIndicator = 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":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,uBAAuB,GAAGD,MAAM,CAACE,GAAG;AACjD;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,qCAAqC,GAAGH,MAAM,CAACE,GAAG;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GalleryViewerItem.types.js","names":[],"sources":["../../../../../src/components/gallery-viewer/gallery-viewer-item/GalleryViewerItem.types.ts"],"sourcesContent":["import type { FileItem } from '@chayns-components/core';\n\n/**\n * Props for a dedicated read-only gallery tile.\n */\nexport interface GalleryViewerItemProps {\n /**\n * Provides the uploaded media that should be rendered.\n * @description\n * The viewer item renders only already known media and never deals with upload-specific transient state.\n * @example\n * <GalleryViewerItem fileItem={file} onClick={handleOpen} />\n */\n fileItem: FileItem;\n /**\n * Defines the aspect ratio that should be reserved for the tile.\n * @description\n * Use this prop to reserve a deterministic tile height for stable read-only rendering.\n * @default 1\n * @example\n * <GalleryViewerItem fileItem={file} onClick={handleOpen} ratio={1.5} />\n * @optional\n */\n ratio?: number;\n /**\n * Provides the total item count when the last visible tile should show a remaining-items overlay.\n * @description\n * When this prop is set on the last visible viewer tile, the tile displays the `+n` overlay for hidden items.\n * @example\n * <GalleryViewerItem fileItem={file} onClick={handleOpen} remainingItemsLength={5} />\n * @optional\n */\n remainingItemsLength?: number;\n /**\n * Is called when the tile is selected.\n * @description\n * The viewer uses this callback to open the selected file inside the slideshow flow.\n * @example\n * <GalleryViewerItem fileItem={file} onClick={handleOpen} />\n */\n onClick: (file: FileItem) => void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Icon } from '@chayns-components/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StyledMediaContentImage, StyledMediaContentImageWrapper, StyledMediaContentPlayIcon, StyledMediaContentVideo, StyledMediaContentVideoWrapper } from './MediaContent.styles';
|
|
4
|
+
const MediaContent = ({
|
|
5
|
+
file,
|
|
6
|
+
ratio,
|
|
7
|
+
onClick,
|
|
8
|
+
playIconSize = 50
|
|
9
|
+
}) => 'thumbnailUrl' in file ? /*#__PURE__*/React.createElement(StyledMediaContentVideoWrapper, {
|
|
10
|
+
onClick: onClick,
|
|
11
|
+
$ratio: ratio
|
|
12
|
+
}, /*#__PURE__*/React.createElement(StyledMediaContentPlayIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
13
|
+
size: playIconSize,
|
|
14
|
+
icons: ['fa fa-play']
|
|
15
|
+
})), /*#__PURE__*/React.createElement(StyledMediaContentVideo, {
|
|
16
|
+
poster: file.thumbnailUrl
|
|
17
|
+
}, /*#__PURE__*/React.createElement("source", {
|
|
18
|
+
src: file.url,
|
|
19
|
+
type: "video/mp4"
|
|
20
|
+
}))) : /*#__PURE__*/React.createElement(StyledMediaContentImageWrapper, {
|
|
21
|
+
onClick: onClick,
|
|
22
|
+
$ratio: ratio
|
|
23
|
+
}, /*#__PURE__*/React.createElement(StyledMediaContentImage, {
|
|
24
|
+
draggable: false,
|
|
25
|
+
src: file.url
|
|
26
|
+
}));
|
|
27
|
+
MediaContent.displayName = 'MediaContent';
|
|
28
|
+
export default MediaContent;
|
|
29
|
+
//# sourceMappingURL=MediaContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaContent.js","names":["Icon","React","StyledMediaContentImage","StyledMediaContentImageWrapper","StyledMediaContentPlayIcon","StyledMediaContentVideo","StyledMediaContentVideoWrapper","MediaContent","file","ratio","onClick","playIconSize","createElement","$ratio","size","icons","poster","thumbnailUrl","src","url","type","draggable","displayName"],"sources":["../../../../src/components/media-content/MediaContent.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\nimport React, { FC } from 'react';\nimport {\n StyledMediaContentImage,\n StyledMediaContentImageWrapper,\n StyledMediaContentPlayIcon,\n StyledMediaContentVideo,\n StyledMediaContentVideoWrapper,\n} from './MediaContent.styles';\nimport type { MediaContentProps } from './MediaContent.types';\n\nconst MediaContent: FC<MediaContentProps> = ({ file, ratio, onClick, playIconSize = 50 }) =>\n 'thumbnailUrl' in file ? (\n <StyledMediaContentVideoWrapper onClick={onClick} $ratio={ratio}>\n <StyledMediaContentPlayIcon>\n <Icon size={playIconSize} icons={['fa fa-play']} />\n </StyledMediaContentPlayIcon>\n <StyledMediaContentVideo poster={file.thumbnailUrl}>\n <source src={file.url} type=\"video/mp4\" />\n </StyledMediaContentVideo>\n </StyledMediaContentVideoWrapper>\n ) : (\n <StyledMediaContentImageWrapper onClick={onClick} $ratio={ratio}>\n <StyledMediaContentImage draggable={false} src={file.url} />\n </StyledMediaContentImageWrapper>\n );\n\nMediaContent.displayName = 'MediaContent';\n\nexport default MediaContent;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,yBAAyB;AAC9C,OAAOC,KAAK,MAAc,OAAO;AACjC,SACIC,uBAAuB,EACvBC,8BAA8B,EAC9BC,0BAA0B,EAC1BC,uBAAuB,EACvBC,8BAA8B,QAC3B,uBAAuB;AAG9B,MAAMC,YAAmC,GAAGA,CAAC;EAAEC,IAAI;EAAEC,KAAK;EAAEC,OAAO;EAAEC,YAAY,GAAG;AAAG,CAAC,KACpF,cAAc,IAAIH,IAAI,gBAClBP,KAAA,CAAAW,aAAA,CAACN,8BAA8B;EAACI,OAAO,EAAEA,OAAQ;EAACG,MAAM,EAAEJ;AAAM,gBAC5DR,KAAA,CAAAW,aAAA,CAACR,0BAA0B,qBACvBH,KAAA,CAAAW,aAAA,CAACZ,IAAI;EAACc,IAAI,EAAEH,YAAa;EAACI,KAAK,EAAE,CAAC,YAAY;AAAE,CAAE,CAC1B,CAAC,eAC7Bd,KAAA,CAAAW,aAAA,CAACP,uBAAuB;EAACW,MAAM,EAAER,IAAI,CAACS;AAAa,gBAC/ChB,KAAA,CAAAW,aAAA;EAAQM,GAAG,EAAEV,IAAI,CAACW,GAAI;EAACC,IAAI,EAAC;AAAW,CAAE,CACpB,CACG,CAAC,gBAEjCnB,KAAA,CAAAW,aAAA,CAACT,8BAA8B;EAACO,OAAO,EAAEA,OAAQ;EAACG,MAAM,EAAEJ;AAAM,gBAC5DR,KAAA,CAAAW,aAAA,CAACV,uBAAuB;EAACmB,SAAS,EAAE,KAAM;EAACH,GAAG,EAAEV,IAAI,CAACW;AAAI,CAAE,CAC/B,CACnC;AAELZ,YAAY,CAACe,WAAW,GAAG,cAAc;AAEzC,eAAef,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const StyledMediaContentVideoWrapper = styled.div`
|
|
3
|
+
display: flex;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
aspect-ratio: ${({
|
|
7
|
+
$ratio
|
|
8
|
+
}) => $ratio};
|
|
9
|
+
`;
|
|
10
|
+
export const StyledMediaContentImageWrapper = styled.div`
|
|
11
|
+
display: flex;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
aspect-ratio: ${({
|
|
15
|
+
$ratio
|
|
16
|
+
}) => $ratio};
|
|
17
|
+
`;
|
|
18
|
+
export const StyledMediaContentImage = styled.img`
|
|
19
|
+
background-color: ${({
|
|
20
|
+
theme
|
|
21
|
+
}) => theme['101']};
|
|
22
|
+
box-shadow: 0 0 0 1px
|
|
23
|
+
rgba(${({
|
|
24
|
+
theme
|
|
25
|
+
}) => theme['009-rgb']}, 0.08) inset;
|
|
26
|
+
z-index: 1;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
object-fit: cover;
|
|
30
|
+
`;
|
|
31
|
+
export const StyledMediaContentVideo = styled.video`
|
|
32
|
+
background-color: ${({
|
|
33
|
+
theme
|
|
34
|
+
}) => theme['101']};
|
|
35
|
+
box-shadow: 0 0 0 1px
|
|
36
|
+
rgba(${({
|
|
37
|
+
theme
|
|
38
|
+
}) => theme['009-rgb']}, 0.08) inset;
|
|
39
|
+
width: 100%;
|
|
40
|
+
object-fit: cover;
|
|
41
|
+
`;
|
|
42
|
+
export const StyledMediaContentPlayIcon = styled.div`
|
|
43
|
+
position: absolute;
|
|
44
|
+
z-index: 2;
|
|
45
|
+
top: 50%;
|
|
46
|
+
left: 50%;
|
|
47
|
+
transform: translate(-50%, -50%);
|
|
48
|
+
`;
|
|
49
|
+
//# sourceMappingURL=MediaContent.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaContent.styles.js","names":["styled","StyledMediaContentVideoWrapper","div","$ratio","StyledMediaContentImageWrapper","StyledMediaContentImage","img","theme","StyledMediaContentVideo","video","StyledMediaContentPlayIcon"],"sources":["../../../../src/components/media-content/MediaContent.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\nexport const StyledMediaContentVideoWrapper = styled.div<{ $ratio: number }>`\n display: flex;\n width: 100%;\n height: 100%;\n aspect-ratio: ${({ $ratio }) => $ratio};\n`;\n\nexport const StyledMediaContentImageWrapper = styled.div<{ $ratio: number }>`\n display: flex;\n width: 100%;\n height: 100%;\n aspect-ratio: ${({ $ratio }) => $ratio};\n`;\n\ntype StyledMediaContentVideoProps = WithTheme<unknown>;\n\ntype StyledMediaContentImageProps = WithTheme<unknown>;\n\nexport const StyledMediaContentImage = styled.img<StyledMediaContentImageProps>`\n background-color: ${({ theme }: StyledMediaContentImageProps) => theme['101']};\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledMediaContentImageProps) => theme['009-rgb']}, 0.08) inset;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n`;\n\nexport const StyledMediaContentVideo = styled.video<StyledMediaContentVideoProps>`\n background-color: ${({ theme }: StyledMediaContentVideoProps) => theme['101']};\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledMediaContentVideoProps) => theme['009-rgb']}, 0.08) inset;\n width: 100%;\n object-fit: cover;\n`;\n\nexport const StyledMediaContentPlayIcon = styled.div`\n position: absolute;\n z-index: 2;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,8BAA8B,GAAGD,MAAM,CAACE,GAAuB;AAC5E;AACA;AACA;AACA,oBAAoB,CAAC;EAAEC;AAAO,CAAC,KAAKA,MAAM;AAC1C,CAAC;AAED,OAAO,MAAMC,8BAA8B,GAAGJ,MAAM,CAACE,GAAuB;AAC5E;AACA;AACA;AACA,oBAAoB,CAAC;EAAEC;AAAO,CAAC,KAAKA,MAAM;AAC1C,CAAC;AAMD,OAAO,MAAME,uBAAuB,GAAGL,MAAM,CAACM,GAAiC;AAC/E,wBAAwB,CAAC;EAAEC;AAAoC,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACjF;AACA,eAAe,CAAC;EAAEA;AAAoC,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AAC5E;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,uBAAuB,GAAGR,MAAM,CAACS,KAAmC;AACjF,wBAAwB,CAAC;EAAEF;AAAoC,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACjF;AACA,eAAe,CAAC;EAAEA;AAAoC,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AAC5E;AACA;AACA,CAAC;AAED,OAAO,MAAMG,0BAA0B,GAAGV,MAAM,CAACE,GAAG;AACpD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaContent.types.js","names":[],"sources":["../../../../src/components/media-content/MediaContent.types.ts"],"sourcesContent":["import type { FileItem } from '@chayns-components/core';\n\n/**\n * Props for the low-level uploaded media renderer shared by viewer and editor.\n */\nexport interface MediaContentProps {\n /**\n * Provides the uploaded media item that should be rendered.\n * @description\n * This low-level renderer accepts already known image or video data and does not handle upload-specific state.\n * @example\n * <MediaContent file={file.file} onClick={handleOpen} ratio={1} />\n */\n file: FileItem['file'];\n /**\n * Defines the aspect ratio that should be reserved for the media.\n * @description\n * The surrounding tile uses this value to reserve a deterministic media height before the asset finishes loading.\n * @example\n * <MediaContent file={file.file} onClick={handleOpen} ratio={1.5} />\n */\n ratio: number;\n /**\n * Is called when the media tile is selected.\n * @description\n * Use this callback to react to clicks on the rendered image or video tile.\n * @example\n * <MediaContent file={file.file} onClick={() => console.log('open')} ratio={1} />\n */\n onClick: () => void;\n /**\n * Defines the size of the video play icon.\n * @description\n * This prop only affects rendered videos. Image tiles ignore it.\n * @default 50\n * @example\n * <MediaContent file={file.file} onClick={handleOpen} playIconSize={30} ratio={1} />\n * @optional\n */\n playIconSize?: number;\n}\n"],"mappings":"","ignoreList":[]}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// noinspection JSUnusedGlobalSymbols
|
|
2
2
|
|
|
3
3
|
export { default as Gallery } from './components/Gallery';
|
|
4
|
+
export { default as GalleryEditor } from './components/gallery-editor/GalleryEditor';
|
|
5
|
+
export { default as GalleryViewer } from './components/gallery-viewer/GalleryViewer';
|
|
4
6
|
export { GalleryViewMode } from './types/gallery';
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","Gallery","GalleryEditor","GalleryViewer","GalleryViewMode"],"sources":["../../src/index.ts"],"sourcesContent":["// noinspection JSUnusedGlobalSymbols\n\nexport { default as Gallery } from './components/Gallery';\nexport { default as GalleryEditor } from './components/gallery-editor/GalleryEditor';\nexport { default as GalleryViewer } from './components/gallery-viewer/GalleryViewer';\nexport type { GalleryProps } from './components/Gallery.types';\nexport type { GalleryEditorProps } from './components/gallery-editor/GalleryEditor.types';\nexport type { GalleryViewerProps } from './components/gallery-viewer/GalleryViewer.types';\nexport { GalleryViewMode } from './types/gallery';\n"],"mappings":"AAAA;;AAEA,SAASA,OAAO,IAAIC,OAAO,QAAQ,sBAAsB;AACzD,SAASD,OAAO,IAAIE,aAAa,QAAQ,2CAA2C;AACpF,SAASF,OAAO,IAAIG,aAAa,QAAQ,2CAA2C;AAIpF,SAASC,eAAe,QAAQ,iBAAiB","ignoreList":[]}
|
package/lib/esm/types/gallery.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the available gallery layouts for read-only rendering.
|
|
3
|
+
*/
|
|
1
4
|
export let GalleryViewMode = /*#__PURE__*/function (GalleryViewMode) {
|
|
5
|
+
/**
|
|
6
|
+
* Arranges visible items in a square-first layout.
|
|
7
|
+
*/
|
|
2
8
|
GalleryViewMode[GalleryViewMode["SQUARE"] = 0] = "SQUARE";
|
|
9
|
+
/**
|
|
10
|
+
* Arranges visible items in the gallery grid layout.
|
|
11
|
+
*/
|
|
3
12
|
GalleryViewMode[GalleryViewMode["GRID"] = 1] = "GRID";
|
|
4
13
|
return GalleryViewMode;
|
|
5
14
|
}({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.js","names":["GalleryViewMode"],"sources":["../../../src/types/gallery.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"gallery.js","names":["GalleryViewMode"],"sources":["../../../src/types/gallery.ts"],"sourcesContent":["/**\n * Defines the available gallery layouts for read-only rendering.\n */\nexport enum GalleryViewMode {\n /**\n * Arranges visible items in a square-first layout.\n */\n SQUARE,\n /**\n * Arranges visible items in the gallery grid layout.\n */\n GRID,\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,WAAYA,eAAe,0BAAfA,eAAe;EACvB;AACJ;AACA;EAHYA,eAAe,CAAfA,eAAe;EAKvB;AACJ;AACA;EAPYA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { MediaType, openImage, openMedia, openVideo } from 'chayns-api';
|
|
2
|
+
import { GalleryViewMode } from '../types/gallery';
|
|
3
|
+
const DEFAULT_MEDIA_RATIO = 1;
|
|
4
|
+
export const mapFilesToInternalItems = files => (files ?? []).map((file, index) => ({
|
|
5
|
+
id: getGalleryViewerKey(file, index),
|
|
6
|
+
uploadedFile: file.file,
|
|
7
|
+
file: undefined,
|
|
8
|
+
state: 'uploaded',
|
|
9
|
+
previewUrl: undefined
|
|
10
|
+
}));
|
|
11
|
+
export const getGalleryViewerKey = (fileItem, index) => fileItem.id ?? fileItem.file.id ?? fileItem.file.url ?? `gallery-item-${index}`;
|
|
12
|
+
export const getGalleryRatio = fileItems => {
|
|
13
|
+
switch (fileItems.length) {
|
|
14
|
+
case 0:
|
|
15
|
+
return DEFAULT_MEDIA_RATIO;
|
|
16
|
+
case 1:
|
|
17
|
+
return Math.max(fileItems[0]?.file.ratio ?? DEFAULT_MEDIA_RATIO, 1);
|
|
18
|
+
case 2:
|
|
19
|
+
return 2;
|
|
20
|
+
case 3:
|
|
21
|
+
return 3;
|
|
22
|
+
default:
|
|
23
|
+
return DEFAULT_MEDIA_RATIO;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const getReadOnlyItemRatio = ({
|
|
27
|
+
fileItems,
|
|
28
|
+
index,
|
|
29
|
+
viewMode
|
|
30
|
+
}) => {
|
|
31
|
+
const itemCount = fileItems.length;
|
|
32
|
+
if (viewMode !== GalleryViewMode.GRID) {
|
|
33
|
+
return DEFAULT_MEDIA_RATIO;
|
|
34
|
+
}
|
|
35
|
+
if (itemCount === 1) {
|
|
36
|
+
// A square fallback keeps virtualization stable when upstream data does not provide a ratio.
|
|
37
|
+
return Math.max(fileItems[0]?.file.ratio ?? DEFAULT_MEDIA_RATIO, DEFAULT_MEDIA_RATIO);
|
|
38
|
+
}
|
|
39
|
+
if (itemCount === 2 && (index === 0 || index === 1)) {
|
|
40
|
+
return 0.5;
|
|
41
|
+
}
|
|
42
|
+
if (index === 0 && itemCount > 2 || itemCount === 3 && (index === 1 || index === 2)) {
|
|
43
|
+
return 1.5;
|
|
44
|
+
}
|
|
45
|
+
return DEFAULT_MEDIA_RATIO;
|
|
46
|
+
};
|
|
47
|
+
export const openFiles = (fileItems, file) => {
|
|
48
|
+
let startIndex = 0;
|
|
49
|
+
try {
|
|
50
|
+
startIndex = fileItems.findIndex(item => item.id === file.id);
|
|
51
|
+
const items = fileItems.map(item => ({
|
|
52
|
+
url: item.uploadedFile?.url.replace('_0.mp4', '.mp4') ?? '',
|
|
53
|
+
mediaType: item.uploadedFile && 'thumbnailUrl' in item.uploadedFile ? MediaType.VIDEO : MediaType.IMAGE
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
void openMedia({
|
|
59
|
+
items,
|
|
60
|
+
startIndex
|
|
61
|
+
});
|
|
62
|
+
} catch (_) {
|
|
63
|
+
if (file.uploadedFile && 'thumbnailUrl' in file.uploadedFile) {
|
|
64
|
+
void openVideo({
|
|
65
|
+
url: file.uploadedFile.url
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const imageFiles = [];
|
|
70
|
+
fileItems.forEach(({
|
|
71
|
+
uploadedFile
|
|
72
|
+
}) => {
|
|
73
|
+
if (uploadedFile && !('thumbnailUrl' in uploadedFile)) {
|
|
74
|
+
imageFiles.push({
|
|
75
|
+
url: uploadedFile.url
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
startIndex = imageFiles.findIndex(item => item.url === file.uploadedFile?.url);
|
|
80
|
+
const startFile = imageFiles.shift();
|
|
81
|
+
if (!startFile) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
void openImage({
|
|
85
|
+
items: [startFile, ...imageFiles],
|
|
86
|
+
startIndex
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
export const openKnownFiles = (fileItems, file) => {
|
|
91
|
+
const activeFileKey = getGalleryViewerKey(file, fileItems.indexOf(file));
|
|
92
|
+
let startIndex = 0;
|
|
93
|
+
try {
|
|
94
|
+
startIndex = fileItems.findIndex((item, index) => getGalleryViewerKey(item, index) === activeFileKey);
|
|
95
|
+
const items = fileItems.map(item => ({
|
|
96
|
+
url: item.file.url.replace('_0.mp4', '.mp4'),
|
|
97
|
+
mediaType: 'thumbnailUrl' in item.file ? MediaType.VIDEO : MediaType.IMAGE
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
void openMedia({
|
|
103
|
+
items,
|
|
104
|
+
startIndex
|
|
105
|
+
});
|
|
106
|
+
} catch (_) {
|
|
107
|
+
if ('thumbnailUrl' in file.file) {
|
|
108
|
+
void openVideo({
|
|
109
|
+
url: file.file.url
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const imageFiles = [];
|
|
114
|
+
fileItems.forEach(item => {
|
|
115
|
+
if (!('thumbnailUrl' in item.file)) {
|
|
116
|
+
imageFiles.push({
|
|
117
|
+
url: item.file.url
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
startIndex = imageFiles.findIndex(item => item.url === file.file.url);
|
|
122
|
+
const startFile = imageFiles.shift();
|
|
123
|
+
if (!startFile) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
void openImage({
|
|
127
|
+
items: [startFile, ...imageFiles],
|
|
128
|
+
startIndex
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=gallery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gallery.js","names":["MediaType","openImage","openMedia","openVideo","GalleryViewMode","DEFAULT_MEDIA_RATIO","mapFilesToInternalItems","files","map","file","index","id","getGalleryViewerKey","uploadedFile","undefined","state","previewUrl","fileItem","url","getGalleryRatio","fileItems","length","Math","max","ratio","getReadOnlyItemRatio","viewMode","itemCount","GRID","openFiles","startIndex","findIndex","item","items","replace","mediaType","VIDEO","IMAGE","_","imageFiles","forEach","push","startFile","shift","openKnownFiles","activeFileKey","indexOf"],"sources":["../../../src/utils/gallery.ts"],"sourcesContent":["import type { FileItem, InternalFileItem } from '@chayns-components/core';\nimport {\n MediaType,\n openImage,\n openMedia,\n type OpenImageItem,\n type OpenMediaItem,\n openVideo,\n} from 'chayns-api';\nimport { GalleryViewMode } from '../types/gallery';\n\nconst DEFAULT_MEDIA_RATIO = 1;\n\nexport const mapFilesToInternalItems = (files?: FileItem[]): InternalFileItem[] =>\n (files ?? []).map((file, index) => ({\n id: getGalleryViewerKey(file, index),\n uploadedFile: file.file,\n file: undefined,\n state: 'uploaded',\n previewUrl: undefined,\n }));\n\nexport const getGalleryViewerKey = (fileItem: FileItem, index: number): string =>\n fileItem.id ?? fileItem.file.id ?? fileItem.file.url ?? `gallery-item-${index}`;\n\nexport const getGalleryRatio = (fileItems: FileItem[]): number => {\n switch (fileItems.length) {\n case 0:\n return DEFAULT_MEDIA_RATIO;\n case 1:\n return Math.max(fileItems[0]?.file.ratio ?? DEFAULT_MEDIA_RATIO, 1);\n case 2:\n return 2;\n case 3:\n return 3;\n default:\n return DEFAULT_MEDIA_RATIO;\n }\n};\n\nexport const getReadOnlyItemRatio = ({\n fileItems,\n index,\n viewMode,\n}: {\n fileItems: FileItem[];\n index: number;\n viewMode: GalleryViewMode;\n}): number => {\n const itemCount = fileItems.length;\n\n if (viewMode !== GalleryViewMode.GRID) {\n return DEFAULT_MEDIA_RATIO;\n }\n\n if (itemCount === 1) {\n // A square fallback keeps virtualization stable when upstream data does not provide a ratio.\n return Math.max(fileItems[0]?.file.ratio ?? DEFAULT_MEDIA_RATIO, DEFAULT_MEDIA_RATIO);\n }\n\n if (itemCount === 2 && (index === 0 || index === 1)) {\n return 0.5;\n }\n\n if ((index === 0 && itemCount > 2) || (itemCount === 3 && (index === 1 || index === 2))) {\n return 1.5;\n }\n\n return DEFAULT_MEDIA_RATIO;\n};\n\nexport const openFiles = (fileItems: InternalFileItem[], file: InternalFileItem) => {\n let startIndex = 0;\n\n try {\n 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 } catch (_) {\n if (file.uploadedFile && 'thumbnailUrl' in file.uploadedFile) {\n void openVideo({ url: file.uploadedFile.url });\n\n return;\n }\n\n const imageFiles: OpenImageItem[] = [];\n\n fileItems.forEach(({ uploadedFile }) => {\n if (uploadedFile && !('thumbnailUrl' in uploadedFile)) {\n imageFiles.push({ url: uploadedFile.url });\n }\n });\n\n startIndex = imageFiles.findIndex((item) => item.url === file.uploadedFile?.url);\n\n const startFile = imageFiles.shift();\n\n if (!startFile) {\n return;\n }\n\n void openImage({ items: [startFile, ...imageFiles], startIndex });\n }\n};\n\nexport const openKnownFiles = (fileItems: FileItem[], file: FileItem) => {\n const activeFileKey = getGalleryViewerKey(file, fileItems.indexOf(file));\n let startIndex = 0;\n\n try {\n startIndex = fileItems.findIndex(\n (item, index) => getGalleryViewerKey(item, index) === activeFileKey,\n );\n\n const items: OpenMediaItem[] = fileItems.map((item) => ({\n url: item.file.url.replace('_0.mp4', '.mp4'),\n mediaType: 'thumbnailUrl' in item.file ? MediaType.VIDEO : MediaType.IMAGE,\n }));\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n void openMedia({ items, startIndex });\n } catch (_) {\n if ('thumbnailUrl' in file.file) {\n void openVideo({ url: file.file.url });\n\n return;\n }\n\n const imageFiles: OpenImageItem[] = [];\n\n fileItems.forEach((item) => {\n if (!('thumbnailUrl' in item.file)) {\n imageFiles.push({ url: item.file.url });\n }\n });\n\n startIndex = imageFiles.findIndex((item) => item.url === file.file.url);\n\n const startFile = imageFiles.shift();\n\n if (!startFile) {\n return;\n }\n\n void openImage({ items: [startFile, ...imageFiles], startIndex });\n }\n};\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,47 +1,4 @@
|
|
|
1
|
-
import { type FileItem } from '@chayns-components/core';
|
|
2
1
|
import { FC } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export type GalleryProps = {
|
|
5
|
-
/**
|
|
6
|
-
* Whether drag and drop is allowed or not
|
|
7
|
-
*/
|
|
8
|
-
allowDragAndDrop?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* The message that should be displayed if a File is already given.
|
|
11
|
-
*/
|
|
12
|
-
doubleFileDialogMessage?: string;
|
|
13
|
-
/**
|
|
14
|
-
* The minimum width of a file in the edit mode
|
|
15
|
-
*/
|
|
16
|
-
fileMinWidth?: number;
|
|
17
|
-
/**
|
|
18
|
-
* Images and videos which should be displayed
|
|
19
|
-
*/
|
|
20
|
-
files?: FileItem[];
|
|
21
|
-
/**
|
|
22
|
-
* Whether images and videos can be edited
|
|
23
|
-
*/
|
|
24
|
-
isEditMode?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* The maximum amount of images and videos that can be uploaded.
|
|
27
|
-
*/
|
|
28
|
-
maxFiles?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Function to be executed when files are added and uploaded
|
|
31
|
-
*/
|
|
32
|
-
onAdd?: (file: FileItem) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Function to be executed when the count of files are changed. Needed to check if all files are uploaded
|
|
35
|
-
*/
|
|
36
|
-
onFileCountChange?: (fileCount: number) => void;
|
|
37
|
-
/**
|
|
38
|
-
* Function to be executed when a file is removed
|
|
39
|
-
*/
|
|
40
|
-
onRemove?: (file: FileItem) => void;
|
|
41
|
-
/**
|
|
42
|
-
* The mode how the images should be displayed.
|
|
43
|
-
*/
|
|
44
|
-
viewMode?: GalleryViewMode;
|
|
45
|
-
};
|
|
2
|
+
import type { GalleryProps } from './Gallery.types';
|
|
46
3
|
declare const Gallery: FC<GalleryProps>;
|
|
47
4
|
export default Gallery;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { FileItem } from '@chayns-components/core';
|
|
2
|
+
import type { GalleryViewMode } from '../types/gallery';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the public Gallery wrapper component.
|
|
5
|
+
*/
|
|
6
|
+
export interface GalleryProps {
|
|
7
|
+
/**
|
|
8
|
+
* Enables drag and drop while the component is used in edit mode.
|
|
9
|
+
* @description
|
|
10
|
+
* This prop only affects the editor path. In read-only mode, drag and drop stays disabled regardless of this value.
|
|
11
|
+
* @default false
|
|
12
|
+
* @example
|
|
13
|
+
* <Gallery allowDragAndDrop isEditMode files={files} />
|
|
14
|
+
* @optional
|
|
15
|
+
*/
|
|
16
|
+
allowDragAndDrop?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Defines the dialog message that is shown when a duplicate upload is detected.
|
|
19
|
+
* @description
|
|
20
|
+
* The message is used by the editor when a locally added file resolves to an already known uploaded file.
|
|
21
|
+
* @default 'Diese Datei ist bereits vorhanden'
|
|
22
|
+
* @example
|
|
23
|
+
* <Gallery doubleFileDialogMessage="This file already exists." isEditMode files={files} />
|
|
24
|
+
* @optional
|
|
25
|
+
*/
|
|
26
|
+
doubleFileDialogMessage?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Defines the minimum width of one tile in edit mode.
|
|
29
|
+
* @description
|
|
30
|
+
* The editor uses this value to build its responsive grid. It has no effect in the read-only viewer.
|
|
31
|
+
* @default 100
|
|
32
|
+
* @example
|
|
33
|
+
* <Gallery fileMinWidth={140} isEditMode files={files} />
|
|
34
|
+
* @optional
|
|
35
|
+
*/
|
|
36
|
+
fileMinWidth?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Provides already known media items that should be rendered by the gallery.
|
|
39
|
+
* @description
|
|
40
|
+
* In read-only mode, these files are rendered directly from props. In edit mode, they are used as the external baseline
|
|
41
|
+
* for already uploaded media while local uploads are managed internally.
|
|
42
|
+
* @example
|
|
43
|
+
* <Gallery files={files} />
|
|
44
|
+
* @optional
|
|
45
|
+
*/
|
|
46
|
+
files?: FileItem[];
|
|
47
|
+
/**
|
|
48
|
+
* Enables the editable upload mode instead of the read-only viewer mode.
|
|
49
|
+
* @description
|
|
50
|
+
* When set to `true`, the public wrapper renders `GalleryEditor`. Otherwise it renders `GalleryViewer`.
|
|
51
|
+
* @default false
|
|
52
|
+
* @example
|
|
53
|
+
* <Gallery isEditMode files={files} />
|
|
54
|
+
* @optional
|
|
55
|
+
*/
|
|
56
|
+
isEditMode?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Limits how many files can be managed in edit mode.
|
|
59
|
+
* @description
|
|
60
|
+
* Once the limit is reached, the editor hides the add-tile and does not accept more files.
|
|
61
|
+
* This prop has no effect in read-only mode.
|
|
62
|
+
* @example
|
|
63
|
+
* <Gallery isEditMode maxFiles={6} files={files} />
|
|
64
|
+
* @optional
|
|
65
|
+
*/
|
|
66
|
+
maxFiles?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Is called after a file has been uploaded successfully in edit mode.
|
|
69
|
+
* @description
|
|
70
|
+
* The callback receives the uploaded file representation that should be merged into the consuming state.
|
|
71
|
+
* It is never called by the read-only viewer.
|
|
72
|
+
* @example
|
|
73
|
+
* <Gallery isEditMode onAdd={(file) => setFiles((prev) => [...prev, file])} />
|
|
74
|
+
* @optional
|
|
75
|
+
*/
|
|
76
|
+
onAdd?: (file: FileItem) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Is called whenever the internal item count changes in edit mode.
|
|
79
|
+
* @description
|
|
80
|
+
* This includes already uploaded files and locally pending uploads that are currently managed by the editor.
|
|
81
|
+
* It is useful when surrounding UI needs to know whether uploads are still in progress.
|
|
82
|
+
* @example
|
|
83
|
+
* <Gallery isEditMode onFileCountChange={(count) => console.log(count)} />
|
|
84
|
+
* @optional
|
|
85
|
+
*/
|
|
86
|
+
onFileCountChange?: (fileCount: number) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Is called after an uploaded file has been removed in edit mode.
|
|
89
|
+
* @description
|
|
90
|
+
* The callback receives the removed uploaded file so the consuming state can remove it as well.
|
|
91
|
+
* It is never called by the read-only viewer.
|
|
92
|
+
* @example
|
|
93
|
+
* <Gallery isEditMode onRemove={(file) => removeFile(file.id)} />
|
|
94
|
+
* @optional
|
|
95
|
+
*/
|
|
96
|
+
onRemove?: (file: FileItem) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Defines how known media items are arranged in read-only mode.
|
|
99
|
+
* @description
|
|
100
|
+
* This prop only affects the viewer path. The editor always uses its dedicated editable grid layout.
|
|
101
|
+
* @default GalleryViewMode.GRID
|
|
102
|
+
* @example
|
|
103
|
+
* <Gallery files={files} viewMode={GalleryViewMode.SQUARE} />
|
|
104
|
+
* @optional
|
|
105
|
+
*/
|
|
106
|
+
viewMode?: GalleryViewMode;
|
|
107
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const StyledGalleryEditor: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
2
|
+
export declare const StyledGalleryEditorGrid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
3
|
+
$fileMinWidth: number;
|
|
4
|
+
}>> & string;
|