@chayns-components/gallery 5.0.0-beta.132 → 5.0.0-beta.1320
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/README.md +4 -15
- package/lib/cjs/components/Gallery.js +319 -0
- package/lib/cjs/components/Gallery.js.map +1 -0
- package/lib/cjs/components/Gallery.styles.js +93 -0
- package/lib/cjs/components/Gallery.styles.js.map +1 -0
- package/lib/cjs/components/add-file/AddFile.js +32 -0
- package/lib/cjs/components/add-file/AddFile.js.map +1 -0
- package/lib/cjs/components/add-file/AddFile.styles.js +23 -0
- package/lib/cjs/components/add-file/AddFile.styles.js.map +1 -0
- package/lib/cjs/components/gallery-item/GalleryItem.js +44 -0
- package/lib/cjs/components/gallery-item/GalleryItem.js.map +1 -0
- package/lib/cjs/components/gallery-item/GalleryItem.styles.js +51 -0
- package/lib/cjs/components/gallery-item/GalleryItem.styles.js.map +1 -0
- package/lib/cjs/components/gallery-item/media-item/MediaItem.js +52 -0
- package/lib/cjs/components/gallery-item/media-item/MediaItem.js.map +1 -0
- package/lib/cjs/components/gallery-item/media-item/MediaItem.styles.js +62 -0
- package/lib/cjs/components/gallery-item/media-item/MediaItem.styles.js.map +1 -0
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.js +45 -0
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.js.map +1 -0
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.styles.js +43 -0
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.styles.js.map +1 -0
- package/lib/cjs/index.js +21 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/types/gallery.js +12 -0
- package/lib/cjs/types/gallery.js.map +1 -0
- package/lib/cjs/utils/file.js +51 -0
- package/lib/cjs/utils/file.js.map +1 -0
- package/lib/esm/components/Gallery.js +305 -0
- package/lib/esm/components/Gallery.js.map +1 -0
- package/lib/esm/components/Gallery.styles.js +86 -0
- package/lib/esm/components/Gallery.styles.js.map +1 -0
- package/lib/esm/components/add-file/AddFile.js +25 -0
- package/lib/esm/components/add-file/AddFile.js.map +1 -0
- package/lib/esm/components/add-file/AddFile.styles.js +16 -0
- package/lib/esm/components/add-file/AddFile.styles.js.map +1 -0
- package/lib/esm/components/gallery-item/GalleryItem.js +36 -0
- package/lib/esm/components/gallery-item/GalleryItem.js.map +1 -0
- package/lib/esm/components/gallery-item/GalleryItem.styles.js +44 -0
- package/lib/esm/components/gallery-item/GalleryItem.styles.js.map +1 -0
- package/lib/esm/components/gallery-item/media-item/MediaItem.js +42 -0
- package/lib/esm/components/gallery-item/media-item/MediaItem.js.map +1 -0
- package/lib/esm/components/gallery-item/media-item/MediaItem.styles.js +55 -0
- package/lib/esm/components/gallery-item/media-item/MediaItem.styles.js.map +1 -0
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.js +38 -0
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.js.map +1 -0
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.styles.js +36 -0
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.styles.js.map +1 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types/gallery.js +6 -0
- package/lib/esm/types/gallery.js.map +1 -0
- package/lib/esm/utils/file.js +41 -0
- package/lib/esm/utils/file.js.map +1 -0
- package/lib/types/components/Gallery.d.ts +47 -0
- package/lib/types/components/Gallery.styles.d.ts +10 -0
- package/lib/types/components/add-file/AddFile.d.ts +9 -0
- package/lib/types/components/add-file/AddFile.styles.d.ts +4 -0
- package/lib/{components → types/components}/gallery-item/GalleryItem.d.ts +10 -6
- package/lib/types/components/gallery-item/GalleryItem.styles.d.ts +5 -0
- package/lib/types/components/gallery-item/media-item/MediaItem.d.ts +22 -0
- package/lib/types/components/gallery-item/media-item/MediaItem.styles.d.ts +16 -0
- package/lib/types/components/gallery-item/preview-item/PreviewItem.d.ts +14 -0
- package/lib/types/components/gallery-item/preview-item/PreviewItem.styles.d.ts +10 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/types/gallery.d.ts +4 -0
- package/lib/types/utils/file.d.ts +17 -0
- package/package.json +49 -29
- package/lib/api/image/post.d.ts +0 -16
- package/lib/api/image/post.js +0 -34
- package/lib/api/image/post.js.map +0 -1
- package/lib/api/video/post.d.ts +0 -16
- package/lib/api/video/post.js +0 -30
- package/lib/api/video/post.js.map +0 -1
- package/lib/components/Gallery.d.ts +0 -34
- package/lib/components/Gallery.js +0 -163
- package/lib/components/Gallery.js.map +0 -1
- package/lib/components/Gallery.styles.d.ts +0 -6
- package/lib/components/Gallery.styles.js +0 -40
- package/lib/components/Gallery.styles.js.map +0 -1
- package/lib/components/add-file/AddFile.d.ts +0 -26
- package/lib/components/add-file/AddFile.js +0 -83
- package/lib/components/add-file/AddFile.js.map +0 -1
- package/lib/components/add-file/AddFile.styles.d.ts +0 -4
- package/lib/components/add-file/AddFile.styles.js +0 -31
- package/lib/components/add-file/AddFile.styles.js.map +0 -1
- package/lib/components/gallery-item/GalleryItem.js +0 -60
- package/lib/components/gallery-item/GalleryItem.js.map +0 -1
- package/lib/components/gallery-item/GalleryItem.styles.d.ts +0 -17
- package/lib/components/gallery-item/GalleryItem.styles.js +0 -107
- package/lib/components/gallery-item/GalleryItem.styles.js.map +0 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -40
- package/lib/index.js.map +0 -1
- package/lib/types/file.d.ts +0 -20
- package/lib/types/file.js +0 -6
- package/lib/types/file.js.map +0 -1
- package/lib/utils/file.d.ts +0 -17
- package/lib/utils/file.js +0 -92
- package/lib/utils/file.js.map +0 -1
- package/lib/utils/upload.d.ts +0 -8
- package/lib/utils/upload.js +0 -56
- package/lib/utils/upload.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaItem.js","names":["Icon","React","StyledMediaItemImage","StyledMediaItemImageWrapper","StyledMediaItemPlayIcon","StyledMediaItemVideo","StyledMediaItemVideoWrapper","StyledMotionMediaItem","MediaItem","fileItem","isEditMode","openSelectedFile","ratio","createElement","animate","opacity","initial","exit","transition","duration","uploadedFile","onClick","$ratio","size","icons","poster","thumbnailUrl","src","url","type","draggable","displayName"],"sources":["../../../../../src/components/gallery-item/media-item/MediaItem.tsx"],"sourcesContent":["import { Icon, type InternalFileItem } from '@chayns-components/core';\nimport React, { FC } from 'react';\nimport {\n StyledMediaItemImage,\n StyledMediaItemImageWrapper,\n StyledMediaItemPlayIcon,\n StyledMediaItemVideo,\n StyledMediaItemVideoWrapper,\n StyledMotionMediaItem,\n} from './MediaItem.styles';\n\nexport type MediaItemProps = {\n /**\n * Images and videos which should be displayed\n */\n fileItem: InternalFileItem;\n /**\n * Whether images and videos can be edited\n */\n isEditMode: boolean;\n /**\n * Function to be executed when a file is selected\n */\n openSelectedFile: (file: InternalFileItem) => void;\n /**\n * The ratio of the image\n */\n ratio: number;\n};\n\nconst MediaItem: FC<MediaItemProps> = ({ fileItem, isEditMode, openSelectedFile, ratio }) => (\n <StyledMotionMediaItem\n animate={{ opacity: 1 }}\n initial={{ opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 3.2 }}\n >\n {fileItem.uploadedFile && 'thumbnailUrl' in fileItem.uploadedFile ? (\n <StyledMediaItemVideoWrapper onClick={() => openSelectedFile(fileItem)} $ratio={ratio}>\n <StyledMediaItemPlayIcon>\n <Icon size={isEditMode ? 30 : 50} icons={['fa fa-play']} />\n </StyledMediaItemPlayIcon>\n <StyledMediaItemVideo poster={fileItem.uploadedFile.thumbnailUrl}>\n <source src={fileItem.uploadedFile.url} type=\"video/mp4\" />\n </StyledMediaItemVideo>\n </StyledMediaItemVideoWrapper>\n ) : (\n <StyledMediaItemImageWrapper onClick={() => openSelectedFile(fileItem)} $ratio={ratio}>\n <StyledMediaItemImage draggable={false} src={fileItem.uploadedFile?.url} />\n </StyledMediaItemImageWrapper>\n )}\n </StyledMotionMediaItem>\n);\n\nMediaItem.displayName = 'MediaItem';\n\nexport default MediaItem;\n"],"mappings":"AAAA,SAASA,IAAI,QAA+B,yBAAyB;AACrE,OAAOC,KAAK,MAAc,OAAO;AACjC,SACIC,oBAAoB,EACpBC,2BAA2B,EAC3BC,uBAAuB,EACvBC,oBAAoB,EACpBC,2BAA2B,EAC3BC,qBAAqB,QAClB,oBAAoB;AAqB3B,MAAMC,SAA6B,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,UAAU;EAAEC,gBAAgB;EAAEC;AAAM,CAAC,kBACpFX,KAAA,CAAAY,aAAA,CAACN,qBAAqB;EAClBO,OAAO,EAAE;IAAEC,OAAO,EAAE;EAAE,CAAE;EACxBC,OAAO,EAAE;IAAED,OAAO,EAAE;EAAE,CAAE;EACxBE,IAAI,EAAE;IAAEF,OAAO,EAAE;EAAE,CAAE;EACrBG,UAAU,EAAE;IAAEC,QAAQ,EAAE;EAAI;AAAE,GAE7BV,QAAQ,CAACW,YAAY,IAAI,cAAc,IAAIX,QAAQ,CAACW,YAAY,gBAC7DnB,KAAA,CAAAY,aAAA,CAACP,2BAA2B;EAACe,OAAO,EAAEA,CAAA,KAAMV,gBAAgB,CAACF,QAAQ,CAAE;EAACa,MAAM,EAAEV;AAAM,gBAClFX,KAAA,CAAAY,aAAA,CAACT,uBAAuB,qBACpBH,KAAA,CAAAY,aAAA,CAACb,IAAI;EAACuB,IAAI,EAAEb,UAAU,GAAG,EAAE,GAAG,EAAG;EAACc,KAAK,EAAE,CAAC,YAAY;AAAE,CAAE,CACrC,CAAC,eAC1BvB,KAAA,CAAAY,aAAA,CAACR,oBAAoB;EAACoB,MAAM,EAAEhB,QAAQ,CAACW,YAAY,CAACM;AAAa,gBAC7DzB,KAAA,CAAAY,aAAA;EAAQc,GAAG,EAAElB,QAAQ,CAACW,YAAY,CAACQ,GAAI;EAACC,IAAI,EAAC;AAAW,CAAE,CACxC,CACG,CAAC,gBAE9B5B,KAAA,CAAAY,aAAA,CAACV,2BAA2B;EAACkB,OAAO,EAAEA,CAAA,KAAMV,gBAAgB,CAACF,QAAQ,CAAE;EAACa,MAAM,EAAEV;AAAM,gBAClFX,KAAA,CAAAY,aAAA,CAACX,oBAAoB;EAAC4B,SAAS,EAAE,KAAM;EAACH,GAAG,EAAElB,QAAQ,CAACW,YAAY,EAAEQ;AAAI,CAAE,CACjD,CAEd,CAC1B;AAEDpB,SAAS,CAACuB,WAAW,GAAG,WAAW;AAEnC,eAAevB,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { motion } from 'motion/react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const StyledMotionMediaItem = styled(motion.div)`
|
|
4
|
+
display: flex;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
`;
|
|
8
|
+
export const StyledMediaItemVideoWrapper = styled.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
aspect-ratio: ${({
|
|
13
|
+
$ratio
|
|
14
|
+
}) => $ratio};
|
|
15
|
+
`;
|
|
16
|
+
export const StyledMediaItemImageWrapper = styled.div`
|
|
17
|
+
display: flex;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
aspect-ratio: ${({
|
|
21
|
+
$ratio
|
|
22
|
+
}) => $ratio};
|
|
23
|
+
`;
|
|
24
|
+
export const StyledMediaItemImage = styled.img`
|
|
25
|
+
background-color: ${({
|
|
26
|
+
theme
|
|
27
|
+
}) => theme['101']};
|
|
28
|
+
box-shadow: 0 0 0 1px rgba(${({
|
|
29
|
+
theme
|
|
30
|
+
}) => theme['009-rgb']}, 0.08)
|
|
31
|
+
inset;
|
|
32
|
+
z-index: 1;
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
object-fit: cover;
|
|
36
|
+
`;
|
|
37
|
+
export const StyledMediaItemVideo = styled.video`
|
|
38
|
+
background-color: ${({
|
|
39
|
+
theme
|
|
40
|
+
}) => theme['101']};
|
|
41
|
+
box-shadow: 0 0 0 1px rgba(${({
|
|
42
|
+
theme
|
|
43
|
+
}) => theme['009-rgb']}, 0.08)
|
|
44
|
+
inset;
|
|
45
|
+
width: 100%;
|
|
46
|
+
object-fit: cover;
|
|
47
|
+
`;
|
|
48
|
+
export const StyledMediaItemPlayIcon = styled.div`
|
|
49
|
+
position: absolute;
|
|
50
|
+
z-index: 2;
|
|
51
|
+
top: 50%;
|
|
52
|
+
left: 50%;
|
|
53
|
+
transform: translate(-50%, -50%);
|
|
54
|
+
`;
|
|
55
|
+
//# sourceMappingURL=MediaItem.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaItem.styles.js","names":["motion","styled","StyledMotionMediaItem","div","StyledMediaItemVideoWrapper","$ratio","StyledMediaItemImageWrapper","StyledMediaItemImage","img","theme","StyledMediaItemVideo","video","StyledMediaItemPlayIcon"],"sources":["../../../../../src/components/gallery-item/media-item/MediaItem.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'motion/react';\nimport styled from 'styled-components';\n\nexport const StyledMotionMediaItem = styled(motion.div)`\n display: flex;\n width: 100%;\n height: 100%;\n`;\n\nexport const StyledMediaItemVideoWrapper = styled.div<{ $ratio: number }>`\n display: flex;\n width: 100%;\n height: 100%;\n aspect-ratio: ${({ $ratio }) => $ratio};\n`;\n\nexport const StyledMediaItemImageWrapper = styled.div<{ $ratio: number }>`\n display: flex;\n width: 100%;\n height: 100%;\n aspect-ratio: ${({ $ratio }) => $ratio};\n`;\n\ntype StyledMediaItemVideoProps = WithTheme<unknown>;\n\ntype StyledMediaItemImageProps = WithTheme<unknown>;\n\nexport const StyledMediaItemImage = styled.img<StyledMediaItemImageProps>`\n background-color: ${({ theme }: StyledMediaItemImageProps) => theme['101']};\n box-shadow: 0 0 0 1px rgba(${({ theme }: StyledMediaItemImageProps) => theme['009-rgb']}, 0.08)\n inset;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n`;\n\nexport const StyledMediaItemVideo = styled.video<StyledMediaItemVideoProps>`\n background-color: ${({ theme }: StyledMediaItemVideoProps) => theme['101']};\n box-shadow: 0 0 0 1px rgba(${({ theme }: StyledMediaItemVideoProps) => theme['009-rgb']}, 0.08)\n inset;\n width: 100%;\n object-fit: cover;\n`;\n\nexport const StyledMediaItemPlayIcon = styled.div`\n position: absolute;\n z-index: 2;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,qBAAqB,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAC;AACvD;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAGH,MAAM,CAACE,GAAuB;AACzE;AACA;AACA;AACA,oBAAoB,CAAC;EAAEE;AAAO,CAAC,KAAKA,MAAM;AAC1C,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAGL,MAAM,CAACE,GAAuB;AACzE;AACA;AACA;AACA,oBAAoB,CAAC;EAAEE;AAAO,CAAC,KAAKA,MAAM;AAC1C,CAAC;AAMD,OAAO,MAAME,oBAAoB,GAAGN,MAAM,CAACO,GAA8B;AACzE,wBAAwB,CAAC;EAAEC;AAAiC,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AAC9E,iCAAiC,CAAC;EAAEA;AAAiC,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AAC3F;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAGT,MAAM,CAACU,KAAgC;AAC3E,wBAAwB,CAAC;EAAEF;AAAiC,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AAC9E,iCAAiC,CAAC;EAAEA;AAAiC,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AAC3F;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMG,uBAAuB,GAAGX,MAAM,CAACE,GAAG;AACjD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SmallWaitCursor } from '@chayns-components/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StyledMotionPreviewItem, StyledPreviewItemImage, StyledPreviewItemImageWrapper, StyledPreviewItemLoadingIcon } from './PreviewItem.styles';
|
|
4
|
+
const PreviewItem = ({
|
|
5
|
+
fileItem,
|
|
6
|
+
ratio
|
|
7
|
+
}) => /*#__PURE__*/React.createElement(StyledMotionPreviewItem, {
|
|
8
|
+
animate: {
|
|
9
|
+
opacity: 1
|
|
10
|
+
},
|
|
11
|
+
initial: {
|
|
12
|
+
opacity: 0
|
|
13
|
+
},
|
|
14
|
+
exit: {
|
|
15
|
+
opacity: 0,
|
|
16
|
+
transition: {
|
|
17
|
+
duration: 3.2,
|
|
18
|
+
delay: 3.2
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
transition: {
|
|
22
|
+
duration: 3.2
|
|
23
|
+
},
|
|
24
|
+
style: {
|
|
25
|
+
position: 'absolute'
|
|
26
|
+
}
|
|
27
|
+
}, /*#__PURE__*/React.createElement(StyledPreviewItemImageWrapper, {
|
|
28
|
+
$ratio: ratio
|
|
29
|
+
}, /*#__PURE__*/React.createElement(StyledPreviewItemLoadingIcon, null, /*#__PURE__*/React.createElement(SmallWaitCursor, {
|
|
30
|
+
shouldHideWaitCursor: false,
|
|
31
|
+
shouldHideBackground: true
|
|
32
|
+
})), /*#__PURE__*/React.createElement(StyledPreviewItemImage, {
|
|
33
|
+
draggable: false,
|
|
34
|
+
src: fileItem.previewUrl
|
|
35
|
+
})));
|
|
36
|
+
PreviewItem.displayName = 'PreviewItem';
|
|
37
|
+
export default PreviewItem;
|
|
38
|
+
//# sourceMappingURL=PreviewItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewItem.js","names":["SmallWaitCursor","React","StyledMotionPreviewItem","StyledPreviewItemImage","StyledPreviewItemImageWrapper","StyledPreviewItemLoadingIcon","PreviewItem","fileItem","ratio","createElement","animate","opacity","initial","exit","transition","duration","delay","style","position","$ratio","shouldHideWaitCursor","shouldHideBackground","draggable","src","previewUrl","displayName"],"sources":["../../../../../src/components/gallery-item/preview-item/PreviewItem.tsx"],"sourcesContent":["import { InternalFileItem, SmallWaitCursor } from '@chayns-components/core';\nimport React, { FC } from 'react';\nimport {\n StyledMotionPreviewItem,\n StyledPreviewItemImage,\n StyledPreviewItemImageWrapper,\n StyledPreviewItemLoadingIcon,\n} from './PreviewItem.styles';\n\nexport type PreviewItemProps = {\n /**\n * Images and videos which should be displayed\n */\n fileItem: InternalFileItem;\n /**\n * The ratio of the image\n */\n ratio: number;\n};\n\nconst PreviewItem: FC<PreviewItemProps> = ({ fileItem, ratio }) => (\n <StyledMotionPreviewItem\n animate={{ opacity: 1 }}\n initial={{ opacity: 0 }}\n exit={{\n opacity: 0,\n transition: { duration: 3.2, delay: 3.2 },\n }}\n transition={{ duration: 3.2 }}\n style={{ position: 'absolute' }}\n >\n <StyledPreviewItemImageWrapper $ratio={ratio}>\n <StyledPreviewItemLoadingIcon>\n <SmallWaitCursor shouldHideWaitCursor={false} shouldHideBackground />\n </StyledPreviewItemLoadingIcon>\n <StyledPreviewItemImage draggable={false} src={fileItem.previewUrl} />\n </StyledPreviewItemImageWrapper>\n </StyledMotionPreviewItem>\n);\n\nPreviewItem.displayName = 'PreviewItem';\n\nexport default PreviewItem;\n"],"mappings":"AAAA,SAA2BA,eAAe,QAAQ,yBAAyB;AAC3E,OAAOC,KAAK,MAAc,OAAO;AACjC,SACIC,uBAAuB,EACvBC,sBAAsB,EACtBC,6BAA6B,EAC7BC,4BAA4B,QACzB,sBAAsB;AAa7B,MAAMC,WAAiC,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;AAAM,CAAC,kBAC1DP,KAAA,CAAAQ,aAAA,CAACP,uBAAuB;EACpBQ,OAAO,EAAE;IAAEC,OAAO,EAAE;EAAE,CAAE;EACxBC,OAAO,EAAE;IAAED,OAAO,EAAE;EAAE,CAAE;EACxBE,IAAI,EAAE;IACFF,OAAO,EAAE,CAAC;IACVG,UAAU,EAAE;MAAEC,QAAQ,EAAE,GAAG;MAAEC,KAAK,EAAE;IAAI;EAC5C,CAAE;EACFF,UAAU,EAAE;IAAEC,QAAQ,EAAE;EAAI,CAAE;EAC9BE,KAAK,EAAE;IAAEC,QAAQ,EAAE;EAAW;AAAE,gBAEhCjB,KAAA,CAAAQ,aAAA,CAACL,6BAA6B;EAACe,MAAM,EAAEX;AAAM,gBACzCP,KAAA,CAAAQ,aAAA,CAACJ,4BAA4B,qBACzBJ,KAAA,CAAAQ,aAAA,CAACT,eAAe;EAACoB,oBAAoB,EAAE,KAAM;EAACC,oBAAoB;AAAA,CAAE,CAC1C,CAAC,eAC/BpB,KAAA,CAAAQ,aAAA,CAACN,sBAAsB;EAACmB,SAAS,EAAE,KAAM;EAACC,GAAG,EAAEhB,QAAQ,CAACiB;AAAW,CAAE,CAC1C,CACV,CAC5B;AAEDlB,WAAW,CAACmB,WAAW,GAAG,aAAa;AAEvC,eAAenB,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { motion } from 'motion/react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const StyledMotionPreviewItem = styled(motion.div)`
|
|
4
|
+
display: flex;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
`;
|
|
8
|
+
export const StyledPreviewItemImageWrapper = styled.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
aspect-ratio: ${({
|
|
13
|
+
$ratio
|
|
14
|
+
}) => $ratio};
|
|
15
|
+
`;
|
|
16
|
+
export const StyledPreviewItemImage = styled.img`
|
|
17
|
+
background-color: ${({
|
|
18
|
+
theme
|
|
19
|
+
}) => theme['101']};
|
|
20
|
+
box-shadow: 0 0 0 1px
|
|
21
|
+
rgba(${({
|
|
22
|
+
theme
|
|
23
|
+
}) => theme['009-rgb']}, 0.08) inset;
|
|
24
|
+
z-index: 1;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
object-fit: cover;
|
|
28
|
+
`;
|
|
29
|
+
export const StyledPreviewItemLoadingIcon = styled.div`
|
|
30
|
+
position: absolute;
|
|
31
|
+
z-index: 2;
|
|
32
|
+
top: 50%;
|
|
33
|
+
left: 50%;
|
|
34
|
+
transform: translate(-50%, -50%);
|
|
35
|
+
`;
|
|
36
|
+
//# sourceMappingURL=PreviewItem.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewItem.styles.js","names":["motion","styled","StyledMotionPreviewItem","div","StyledPreviewItemImageWrapper","$ratio","StyledPreviewItemImage","img","theme","StyledPreviewItemLoadingIcon"],"sources":["../../../../../src/components/gallery-item/preview-item/PreviewItem.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'motion/react';\nimport styled from 'styled-components';\n\nexport const StyledMotionPreviewItem = styled(motion.div)`\n display: flex;\n width: 100%;\n height: 100%;\n`;\n\nexport const StyledPreviewItemImageWrapper = styled.div<{ $ratio: number }>`\n display: flex;\n width: 100%;\n height: 100%;\n aspect-ratio: ${({ $ratio }) => $ratio};\n`;\n\ntype StyledPreviewItemImageProps = WithTheme<unknown>;\n\nexport const StyledPreviewItemImage = styled.img<StyledPreviewItemImageProps>`\n background-color: ${({ theme }: StyledPreviewItemImageProps) => theme['101']};\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledPreviewItemImageProps) => theme['009-rgb']}, 0.08) inset;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n`;\n\nexport const StyledPreviewItemLoadingIcon = styled.div`\n position: absolute;\n z-index: 2;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,uBAAuB,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAC;AACzD;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,6BAA6B,GAAGH,MAAM,CAACE,GAAuB;AAC3E;AACA;AACA;AACA,oBAAoB,CAAC;EAAEE;AAAO,CAAC,KAAKA,MAAM;AAC1C,CAAC;AAID,OAAO,MAAMC,sBAAsB,GAAGL,MAAM,CAACM,GAAgC;AAC7E,wBAAwB,CAAC;EAAEC;AAAmC,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AAChF;AACA,eAAe,CAAC;EAAEA;AAAmC,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AAC3E;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,4BAA4B,GAAGR,MAAM,CAACE,GAAG;AACtD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gallery.js","names":["GalleryViewMode"],"sources":["../../../src/types/gallery.ts"],"sourcesContent":["export enum GalleryViewMode {\n SQUARE,\n GRID,\n}\n"],"mappings":"AAAA,WAAYA,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const filterDuplicateFile = ({
|
|
2
|
+
newFile,
|
|
3
|
+
files
|
|
4
|
+
}) => {
|
|
5
|
+
const duplicates = files.filter(({
|
|
6
|
+
file
|
|
7
|
+
}) => file && file.name === newFile.name && file.size === newFile.size);
|
|
8
|
+
return duplicates.length > 0;
|
|
9
|
+
};
|
|
10
|
+
export const generatePreviewUrl = ({
|
|
11
|
+
callback,
|
|
12
|
+
file
|
|
13
|
+
}) => {
|
|
14
|
+
const reader = new FileReader();
|
|
15
|
+
reader.onload = event => {
|
|
16
|
+
const previewUrl = event.target?.result;
|
|
17
|
+
callback(previewUrl);
|
|
18
|
+
};
|
|
19
|
+
reader.readAsDataURL(file);
|
|
20
|
+
};
|
|
21
|
+
export const generateVideoThumbnail = ({
|
|
22
|
+
file,
|
|
23
|
+
callback
|
|
24
|
+
}) => {
|
|
25
|
+
const canvas = document.createElement('canvas');
|
|
26
|
+
const video = document.createElement('video');
|
|
27
|
+
|
|
28
|
+
// this is important
|
|
29
|
+
video.autoplay = true;
|
|
30
|
+
video.muted = true;
|
|
31
|
+
video.src = URL.createObjectURL(file);
|
|
32
|
+
video.onloadeddata = () => {
|
|
33
|
+
const ctx = canvas.getContext('2d');
|
|
34
|
+
canvas.width = video.videoWidth;
|
|
35
|
+
canvas.height = video.videoHeight;
|
|
36
|
+
ctx?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
37
|
+
video.pause();
|
|
38
|
+
callback(canvas.toDataURL('image/png'));
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","names":["filterDuplicateFile","newFile","files","duplicates","filter","file","name","size","length","generatePreviewUrl","callback","reader","FileReader","onload","event","previewUrl","target","result","readAsDataURL","generateVideoThumbnail","canvas","document","createElement","video","autoplay","muted","src","URL","createObjectURL","onloadeddata","ctx","getContext","width","videoWidth","height","videoHeight","drawImage","pause","toDataURL"],"sources":["../../../src/utils/file.ts"],"sourcesContent":["import type { InternalFileItem } from '@chayns-components/core';\n\ninterface FilerDuplicateFileOptions {\n files: InternalFileItem[];\n newFile: File;\n}\n\nexport const filterDuplicateFile = ({ newFile, files }: FilerDuplicateFileOptions) => {\n const duplicates = files.filter(\n ({ file }) => file && file.name === newFile.name && file.size === newFile.size,\n );\n\n return duplicates.length > 0;\n};\n\ninterface GeneratePreviewUrlOptions {\n file: File;\n callback: (previewUrl: string) => void;\n}\n\nexport const generatePreviewUrl = ({ callback, file }: GeneratePreviewUrlOptions): void => {\n const reader = new FileReader();\n\n reader.onload = (event) => {\n const previewUrl = event.target?.result as string;\n\n callback(previewUrl);\n };\n\n reader.readAsDataURL(file);\n};\n\ninterface GenerateVideoThumbnailOptions {\n file: File;\n callback: (previewUrl: string) => void;\n}\n\nexport const generateVideoThumbnail = ({ file, callback }: GenerateVideoThumbnailOptions) => {\n const canvas = document.createElement('canvas');\n const video = document.createElement('video');\n\n // this is important\n video.autoplay = true;\n video.muted = true;\n video.src = URL.createObjectURL(file);\n\n video.onloadeddata = () => {\n const ctx = canvas.getContext('2d');\n\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n ctx?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n video.pause();\n\n callback(canvas.toDataURL('image/png'));\n };\n};\n"],"mappings":"AAOA,OAAO,MAAMA,mBAAmB,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAiC,CAAC,KAAK;EAClF,MAAMC,UAAU,GAAGD,KAAK,CAACE,MAAM,CAC3B,CAAC;IAAEC;EAAK,CAAC,KAAKA,IAAI,IAAIA,IAAI,CAACC,IAAI,KAAKL,OAAO,CAACK,IAAI,IAAID,IAAI,CAACE,IAAI,KAAKN,OAAO,CAACM,IAC9E,CAAC;EAED,OAAOJ,UAAU,CAACK,MAAM,GAAG,CAAC;AAChC,CAAC;AAOD,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,QAAQ;EAAEL;AAAgC,CAAC,KAAW;EACvF,MAAMM,MAAM,GAAG,IAAIC,UAAU,CAAC,CAAC;EAE/BD,MAAM,CAACE,MAAM,GAAIC,KAAK,IAAK;IACvB,MAAMC,UAAU,GAAGD,KAAK,CAACE,MAAM,EAAEC,MAAgB;IAEjDP,QAAQ,CAACK,UAAU,CAAC;EACxB,CAAC;EAEDJ,MAAM,CAACO,aAAa,CAACb,IAAI,CAAC;AAC9B,CAAC;AAOD,OAAO,MAAMc,sBAAsB,GAAGA,CAAC;EAAEd,IAAI;EAAEK;AAAwC,CAAC,KAAK;EACzF,MAAMU,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;EAC/C,MAAMC,KAAK,GAAGF,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;;EAE7C;EACAC,KAAK,CAACC,QAAQ,GAAG,IAAI;EACrBD,KAAK,CAACE,KAAK,GAAG,IAAI;EAClBF,KAAK,CAACG,GAAG,GAAGC,GAAG,CAACC,eAAe,CAACvB,IAAI,CAAC;EAErCkB,KAAK,CAACM,YAAY,GAAG,MAAM;IACvB,MAAMC,GAAG,GAAGV,MAAM,CAACW,UAAU,CAAC,IAAI,CAAC;IAEnCX,MAAM,CAACY,KAAK,GAAGT,KAAK,CAACU,UAAU;IAC/Bb,MAAM,CAACc,MAAM,GAAGX,KAAK,CAACY,WAAW;IAEjCL,GAAG,EAAEM,SAAS,CAACb,KAAK,EAAE,CAAC,EAAE,CAAC,EAAEA,KAAK,CAACU,UAAU,EAAEV,KAAK,CAACY,WAAW,CAAC;IAChEZ,KAAK,CAACc,KAAK,CAAC,CAAC;IAEb3B,QAAQ,CAACU,MAAM,CAACkB,SAAS,CAAC,WAAW,CAAC,CAAC;EAC3C,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type FileItem } from '@chayns-components/core';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { GalleryViewMode } from '../types/gallery';
|
|
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
|
+
};
|
|
46
|
+
declare const Gallery: FC<GalleryProps>;
|
|
47
|
+
export default Gallery;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GalleryViewMode } from '../types/gallery';
|
|
2
|
+
export declare const StyledGallery: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const StyledGalleryItemWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
4
|
+
$uploadedFileLength: number;
|
|
5
|
+
$ratio: number;
|
|
6
|
+
$viewMode: GalleryViewMode;
|
|
7
|
+
}>> & string;
|
|
8
|
+
export declare const StyledGalleryEditModeWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
9
|
+
$fileMinWidth: number;
|
|
10
|
+
}>> & string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const StyledAddFile: 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 StyledAddFIleIconWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
3
|
+
theme: import("@chayns-components/core").Theme;
|
|
4
|
+
}>> & string;
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
+
import { type InternalFileItem } from '@chayns-components/core';
|
|
1
2
|
import { FC } from 'react';
|
|
2
|
-
import type { UploadedFile } from '../../types/file';
|
|
3
3
|
export type GalleryItemProps = {
|
|
4
4
|
/**
|
|
5
5
|
* Images and videos which should be displayed
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
fileItem: InternalFileItem;
|
|
8
8
|
/**
|
|
9
9
|
* Whether images and videos can be edited
|
|
10
10
|
*/
|
|
11
11
|
isEditMode: boolean;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Function to be executed when a file is deleted
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
handleDeleteFile: (id?: string) => void;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* The ratio of the image
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
ratio?: number;
|
|
20
20
|
/**
|
|
21
21
|
* Length of the uploaded files
|
|
22
22
|
*/
|
|
23
23
|
remainingItemsLength?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Function to be executed if a file should be opened
|
|
26
|
+
*/
|
|
27
|
+
onClick: (file: InternalFileItem) => void;
|
|
24
28
|
};
|
|
25
29
|
declare const GalleryItem: FC<GalleryItemProps>;
|
|
26
30
|
export default GalleryItem;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const StyledGalleryItem: 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 StyledGalleryItemDeleteButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
3
|
+
theme: import("@chayns-components/core").Theme;
|
|
4
|
+
}>> & string;
|
|
5
|
+
export declare const StyledGalleryItemMoreItemsIndicator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type InternalFileItem } from '@chayns-components/core';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
export type MediaItemProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Images and videos which should be displayed
|
|
6
|
+
*/
|
|
7
|
+
fileItem: InternalFileItem;
|
|
8
|
+
/**
|
|
9
|
+
* Whether images and videos can be edited
|
|
10
|
+
*/
|
|
11
|
+
isEditMode: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Function to be executed when a file is selected
|
|
14
|
+
*/
|
|
15
|
+
openSelectedFile: (file: InternalFileItem) => void;
|
|
16
|
+
/**
|
|
17
|
+
* The ratio of the image
|
|
18
|
+
*/
|
|
19
|
+
ratio: number;
|
|
20
|
+
};
|
|
21
|
+
declare const MediaItem: FC<MediaItemProps>;
|
|
22
|
+
export default MediaItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const StyledMotionMediaItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("motion/react").HTMLMotionProps<"div">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
2
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
3
|
+
}, never>> & string & Omit<import("motion/react").ForwardRefComponent<HTMLDivElement, import("motion/react").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
4
|
+
export declare const StyledMediaItemVideoWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
5
|
+
$ratio: number;
|
|
6
|
+
}>> & string;
|
|
7
|
+
export declare const StyledMediaItemImageWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
8
|
+
$ratio: number;
|
|
9
|
+
}>> & string;
|
|
10
|
+
export declare const StyledMediaItemImage: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {
|
|
11
|
+
theme: import("@chayns-components/core").Theme;
|
|
12
|
+
}>> & string;
|
|
13
|
+
export declare const StyledMediaItemVideo: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, {
|
|
14
|
+
theme: import("@chayns-components/core").Theme;
|
|
15
|
+
}>> & string;
|
|
16
|
+
export declare const StyledMediaItemPlayIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InternalFileItem } from '@chayns-components/core';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
export type PreviewItemProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Images and videos which should be displayed
|
|
6
|
+
*/
|
|
7
|
+
fileItem: InternalFileItem;
|
|
8
|
+
/**
|
|
9
|
+
* The ratio of the image
|
|
10
|
+
*/
|
|
11
|
+
ratio: number;
|
|
12
|
+
};
|
|
13
|
+
declare const PreviewItem: FC<PreviewItemProps>;
|
|
14
|
+
export default PreviewItem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const StyledMotionPreviewItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("motion/react").HTMLMotionProps<"div">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
2
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
3
|
+
}, never>> & string & Omit<import("motion/react").ForwardRefComponent<HTMLDivElement, import("motion/react").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
4
|
+
export declare const StyledPreviewItemImageWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
5
|
+
$ratio: number;
|
|
6
|
+
}>> & string;
|
|
7
|
+
export declare const StyledPreviewItemImage: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {
|
|
8
|
+
theme: import("@chayns-components/core").Theme;
|
|
9
|
+
}>> & string;
|
|
10
|
+
export declare const StyledPreviewItemLoadingIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { InternalFileItem } from '@chayns-components/core';
|
|
2
|
+
interface FilerDuplicateFileOptions {
|
|
3
|
+
files: InternalFileItem[];
|
|
4
|
+
newFile: File;
|
|
5
|
+
}
|
|
6
|
+
export declare const filterDuplicateFile: ({ newFile, files }: FilerDuplicateFileOptions) => boolean;
|
|
7
|
+
interface GeneratePreviewUrlOptions {
|
|
8
|
+
file: File;
|
|
9
|
+
callback: (previewUrl: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const generatePreviewUrl: ({ callback, file }: GeneratePreviewUrlOptions) => void;
|
|
12
|
+
interface GenerateVideoThumbnailOptions {
|
|
13
|
+
file: File;
|
|
14
|
+
callback: (previewUrl: string) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const generateVideoThumbnail: ({ file, callback }: GenerateVideoThumbnailOptions) => void;
|
|
17
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/gallery",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.1320",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"browserslist": [
|
|
7
|
+
">0.5%",
|
|
8
|
+
"not dead",
|
|
9
|
+
"not op_mini all",
|
|
10
|
+
"not IE 11"
|
|
11
|
+
],
|
|
5
12
|
"keywords": [
|
|
6
13
|
"chayns",
|
|
7
14
|
"react",
|
|
@@ -10,8 +17,17 @@
|
|
|
10
17
|
"author": "Tobit.Software",
|
|
11
18
|
"homepage": "https://github.com/TobitSoftware/chayns-components/tree/main/packages/gallery#readme",
|
|
12
19
|
"license": "MIT",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
20
|
+
"types": "lib/types/index.d.ts",
|
|
21
|
+
"main": "lib/cjs/index.js",
|
|
22
|
+
"module": "lib/esm/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./lib/types/index.d.ts",
|
|
26
|
+
"node": "./lib/cjs/index.js",
|
|
27
|
+
"require": "./lib/cjs/index.js",
|
|
28
|
+
"default": "./lib/esm/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
15
31
|
"directories": {
|
|
16
32
|
"lib": "lib",
|
|
17
33
|
"test": "__tests__"
|
|
@@ -24,44 +40,48 @@
|
|
|
24
40
|
"url": "git+https://github.com/TobitSoftware/chayns-components.git"
|
|
25
41
|
},
|
|
26
42
|
"scripts": {
|
|
27
|
-
"build": "npm run build:
|
|
28
|
-
"build:js": "babel src --out-dir lib --extensions=.ts,.tsx --source-maps --ignore=src/stories",
|
|
43
|
+
"build": "npm run build:cjs && npm run build:esm && npm run build:types",
|
|
29
44
|
"build:types": "tsc",
|
|
30
|
-
"
|
|
45
|
+
"build:cjs": "cross-env NODE_ENV=cjs babel src --out-dir lib/cjs --extensions=.ts,.tsx --source-maps --ignore=src/stories",
|
|
46
|
+
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir lib/esm --extensions=.ts,.tsx --source-maps --ignore=src/stories",
|
|
47
|
+
"prepublishOnly": "npm run build",
|
|
48
|
+
"watch:js": "npm run build:esm -- --watch",
|
|
49
|
+
"link": "npm link && npm run watch:js"
|
|
31
50
|
},
|
|
32
51
|
"bugs": {
|
|
33
52
|
"url": "https://github.com/TobitSoftware/chayns-components/issues"
|
|
34
53
|
},
|
|
35
54
|
"devDependencies": {
|
|
36
|
-
"@babel/cli": "^7.
|
|
37
|
-
"@babel/core": "^7.
|
|
38
|
-
"@babel/preset-env": "^7.
|
|
39
|
-
"@babel/preset-react": "^7.
|
|
40
|
-
"@babel/preset-typescript": "^7.
|
|
41
|
-
"@types/react": "^
|
|
42
|
-
"@types/react-dom": "^
|
|
43
|
-
"@types/styled-components": "^5.1.
|
|
44
|
-
"@types/uuid": "^
|
|
45
|
-
"babel-loader": "^
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"react
|
|
49
|
-
"
|
|
55
|
+
"@babel/cli": "^7.28.3",
|
|
56
|
+
"@babel/core": "^7.28.5",
|
|
57
|
+
"@babel/preset-env": "^7.28.5",
|
|
58
|
+
"@babel/preset-react": "^7.28.5",
|
|
59
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
60
|
+
"@types/react": "^18.3.26",
|
|
61
|
+
"@types/react-dom": "^18.3.7",
|
|
62
|
+
"@types/styled-components": "^5.1.35",
|
|
63
|
+
"@types/uuid": "^10.0.0",
|
|
64
|
+
"babel-loader": "^9.2.1",
|
|
65
|
+
"cross-env": "^7.0.3",
|
|
66
|
+
"lerna": "^8.2.4",
|
|
67
|
+
"react": "^18.3.1",
|
|
68
|
+
"react-dom": "^18.3.1",
|
|
69
|
+
"styled-components": "^6.1.19",
|
|
70
|
+
"typescript": "^5.9.3"
|
|
50
71
|
},
|
|
51
72
|
"dependencies": {
|
|
52
|
-
"@chayns-components/core": "^5.0.0-beta.
|
|
53
|
-
"
|
|
54
|
-
"clsx": "^1.2.1",
|
|
55
|
-
"framer-motion": "^6.5.1",
|
|
56
|
-
"styled-components": "^5.3.10",
|
|
57
|
-
"uuid": "^9.0.0"
|
|
73
|
+
"@chayns-components/core": "^5.0.0-beta.1320",
|
|
74
|
+
"uuid": "^10.0.0"
|
|
58
75
|
},
|
|
59
76
|
"peerDependencies": {
|
|
60
|
-
"
|
|
61
|
-
"
|
|
77
|
+
"chayns-api": ">=2.2.0",
|
|
78
|
+
"motion": ">=12.4.1",
|
|
79
|
+
"react": ">=18.0.0",
|
|
80
|
+
"react-dom": ">=18.0.0",
|
|
81
|
+
"styled-components": ">=5.3.11"
|
|
62
82
|
},
|
|
63
83
|
"publishConfig": {
|
|
64
84
|
"access": "public"
|
|
65
85
|
},
|
|
66
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "f22f157bf32a2f22860819d019ceab2da4c8a385"
|
|
67
87
|
}
|
package/lib/api/image/post.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Meta } from '../../types/file';
|
|
2
|
-
export interface PostImageResult {
|
|
3
|
-
key: string;
|
|
4
|
-
base: string;
|
|
5
|
-
meta?: Meta;
|
|
6
|
-
}
|
|
7
|
-
interface PostImageOptions {
|
|
8
|
-
accessToken: string;
|
|
9
|
-
file: File;
|
|
10
|
-
personId: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Uploads an image to the tsimg cloud service
|
|
14
|
-
*/
|
|
15
|
-
export declare const postImage: ({ accessToken, file, personId, }: PostImageOptions) => Promise<PostImageResult>;
|
|
16
|
-
export {};
|
package/lib/api/image/post.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.postImage = void 0;
|
|
7
|
-
var _file = require("../../utils/file");
|
|
8
|
-
/**
|
|
9
|
-
* Uploads an image to the tsimg cloud service
|
|
10
|
-
*/
|
|
11
|
-
const postImage = async _ref => {
|
|
12
|
-
let {
|
|
13
|
-
accessToken,
|
|
14
|
-
file,
|
|
15
|
-
personId
|
|
16
|
-
} = _ref;
|
|
17
|
-
const body = await (0, _file.getFileAsArrayBuffer)(file);
|
|
18
|
-
const response = await fetch('https://api.tsimg.cloud/image', {
|
|
19
|
-
body,
|
|
20
|
-
headers: {
|
|
21
|
-
Accept: 'application/json',
|
|
22
|
-
Authorization: `bearer ${accessToken}`,
|
|
23
|
-
'Content-Type': 'image/*',
|
|
24
|
-
'X-Person-Id': personId
|
|
25
|
-
},
|
|
26
|
-
method: 'POST'
|
|
27
|
-
});
|
|
28
|
-
if (response.ok) {
|
|
29
|
-
return await response.json();
|
|
30
|
-
}
|
|
31
|
-
throw Error(`Failed to POST image (status code: ${response.status}).`);
|
|
32
|
-
};
|
|
33
|
-
exports.postImage = postImage;
|
|
34
|
-
//# sourceMappingURL=post.js.map
|