@alfalab/core-components-gallery 7.3.0 → 7.4.0-alfasans
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/Component.d.ts +5 -1
- package/Component.js +2 -1
- package/Component.js.map +1 -1
- package/components/bottom-button/index.css +5 -5
- package/components/bottom-button/index.module.css.js +1 -1
- package/components/buttons/index.css +5 -5
- package/components/buttons/index.d.ts +3 -0
- package/components/buttons/index.js +7 -0
- package/components/buttons/index.js.map +1 -1
- package/components/buttons/index.module.css.js +1 -1
- package/components/header/Component.js +3 -2
- package/components/header/Component.js.map +1 -1
- package/components/header/index.css +1 -1
- package/components/header/index.module.css.js +1 -1
- package/components/header-info-block/index.css +4 -4
- package/components/header-info-block/index.module.css.js +1 -1
- package/components/header-mobile/Component.js +2 -1
- package/components/header-mobile/Component.js.map +1 -1
- package/components/header-mobile/index.css +6 -6
- package/components/header-mobile/index.module.css.js +1 -1
- package/components/image-preview/index.css +17 -17
- package/components/image-preview/index.module.css.js +1 -1
- package/components/image-viewer/index.css +28 -28
- package/components/image-viewer/index.module.css.js +1 -1
- package/components/image-viewer/video/index.css +9 -9
- package/components/image-viewer/video/index.module.css.js +1 -1
- package/components/info-bar/index.css +3 -3
- package/components/info-bar/index.module.css.js +1 -1
- package/components/navigation-bar/index.css +10 -10
- package/components/navigation-bar/index.module.css.js +1 -1
- package/components/subtitles/index.css +3 -3
- package/components/subtitles/index.module.css.js +1 -1
- package/context.d.ts +2 -1
- package/context.js.map +1 -1
- package/cssm/Component.d.ts +5 -1
- package/cssm/Component.js +2 -1
- package/cssm/Component.js.map +1 -1
- package/cssm/components/buttons/index.d.ts +3 -0
- package/cssm/components/buttons/index.js +7 -0
- package/cssm/components/buttons/index.js.map +1 -1
- package/cssm/components/header/Component.js +3 -2
- package/cssm/components/header/Component.js.map +1 -1
- package/cssm/components/header-mobile/Component.js +2 -1
- package/cssm/components/header-mobile/Component.js.map +1 -1
- package/cssm/context.d.ts +2 -1
- package/cssm/context.js.map +1 -1
- package/cssm/index.d.ts +1 -0
- package/cssm/types.d.ts +6 -0
- package/cssm/utils/constants.d.ts +1 -0
- package/cssm/utils/constants.js +1 -0
- package/cssm/utils/constants.js.map +1 -1
- package/esm/Component.d.ts +5 -1
- package/esm/Component.js +2 -1
- package/esm/Component.js.map +1 -1
- package/esm/components/bottom-button/index.css +5 -5
- package/esm/components/bottom-button/index.module.css.js +1 -1
- package/esm/components/buttons/index.css +5 -5
- package/esm/components/buttons/index.d.ts +3 -0
- package/esm/components/buttons/index.js +7 -1
- package/esm/components/buttons/index.js.map +1 -1
- package/esm/components/buttons/index.module.css.js +1 -1
- package/esm/components/header/Component.js +4 -3
- package/esm/components/header/Component.js.map +1 -1
- package/esm/components/header/index.css +1 -1
- package/esm/components/header/index.module.css.js +1 -1
- package/esm/components/header-info-block/index.css +4 -4
- package/esm/components/header-info-block/index.module.css.js +1 -1
- package/esm/components/header-mobile/Component.js +4 -3
- package/esm/components/header-mobile/Component.js.map +1 -1
- package/esm/components/header-mobile/index.css +6 -6
- package/esm/components/header-mobile/index.module.css.js +1 -1
- package/esm/components/image-preview/index.css +17 -17
- package/esm/components/image-preview/index.module.css.js +1 -1
- package/esm/components/image-viewer/index.css +28 -28
- package/esm/components/image-viewer/index.module.css.js +1 -1
- package/esm/components/image-viewer/video/index.css +9 -9
- package/esm/components/image-viewer/video/index.module.css.js +1 -1
- package/esm/components/info-bar/index.css +3 -3
- package/esm/components/info-bar/index.module.css.js +1 -1
- package/esm/components/navigation-bar/index.css +10 -10
- package/esm/components/navigation-bar/index.module.css.js +1 -1
- package/esm/components/subtitles/index.css +3 -3
- package/esm/components/subtitles/index.module.css.js +1 -1
- package/esm/context.d.ts +2 -1
- package/esm/context.js.map +1 -1
- package/esm/index.css +9 -9
- package/esm/index.d.ts +1 -0
- package/esm/index.module.css.js +1 -1
- package/esm/types.d.ts +6 -0
- package/esm/utils/constants.d.ts +1 -0
- package/esm/utils/constants.js +1 -0
- package/esm/utils/constants.js.map +1 -1
- package/index.css +9 -9
- package/index.d.ts +1 -0
- package/index.module.css.js +1 -1
- package/modern/Component.d.ts +5 -1
- package/modern/Component.js +2 -1
- package/modern/Component.js.map +1 -1
- package/modern/components/bottom-button/index.css +5 -5
- package/modern/components/bottom-button/index.module.css.js +1 -1
- package/modern/components/buttons/index.css +5 -5
- package/modern/components/buttons/index.d.ts +3 -0
- package/modern/components/buttons/index.js +6 -1
- package/modern/components/buttons/index.js.map +1 -1
- package/modern/components/buttons/index.module.css.js +1 -1
- package/modern/components/header/Component.js +3 -2
- package/modern/components/header/Component.js.map +1 -1
- package/modern/components/header/index.css +1 -1
- package/modern/components/header/index.module.css.js +1 -1
- package/modern/components/header-info-block/index.css +4 -4
- package/modern/components/header-info-block/index.module.css.js +1 -1
- package/modern/components/header-mobile/Component.js +3 -2
- package/modern/components/header-mobile/Component.js.map +1 -1
- package/modern/components/header-mobile/index.css +6 -6
- package/modern/components/header-mobile/index.module.css.js +1 -1
- package/modern/components/image-preview/index.css +17 -17
- package/modern/components/image-preview/index.module.css.js +1 -1
- package/modern/components/image-viewer/index.css +28 -28
- package/modern/components/image-viewer/index.module.css.js +1 -1
- package/modern/components/image-viewer/video/index.css +9 -9
- package/modern/components/image-viewer/video/index.module.css.js +1 -1
- package/modern/components/info-bar/index.css +3 -3
- package/modern/components/info-bar/index.module.css.js +1 -1
- package/modern/components/navigation-bar/index.css +10 -10
- package/modern/components/navigation-bar/index.module.css.js +1 -1
- package/modern/components/subtitles/index.css +3 -3
- package/modern/components/subtitles/index.module.css.js +1 -1
- package/modern/context.d.ts +2 -1
- package/modern/context.js.map +1 -1
- package/modern/index.css +9 -9
- package/modern/index.d.ts +1 -0
- package/modern/index.module.css.js +1 -1
- package/modern/types.d.ts +6 -0
- package/modern/utils/constants.d.ts +1 -0
- package/modern/utils/constants.js +1 -0
- package/modern/utils/constants.js.map +1 -1
- package/moderncssm/Component.d.ts +5 -1
- package/moderncssm/Component.js +2 -1
- package/moderncssm/Component.js.map +1 -1
- package/moderncssm/components/buttons/index.d.ts +3 -0
- package/moderncssm/components/buttons/index.js +6 -1
- package/moderncssm/components/buttons/index.js.map +1 -1
- package/moderncssm/components/header/Component.js +3 -2
- package/moderncssm/components/header/Component.js.map +1 -1
- package/moderncssm/components/header-mobile/Component.js +3 -2
- package/moderncssm/components/header-mobile/Component.js.map +1 -1
- package/moderncssm/context.d.ts +2 -1
- package/moderncssm/context.js.map +1 -1
- package/moderncssm/index.d.ts +1 -0
- package/moderncssm/types.d.ts +6 -0
- package/moderncssm/utils/constants.d.ts +1 -0
- package/moderncssm/utils/constants.js +1 -0
- package/moderncssm/utils/constants.js.map +1 -1
- package/package.json +12 -12
- package/src/Component.tsx +8 -1
- package/src/components/buttons/index.tsx +24 -0
- package/src/components/header/Component.tsx +5 -0
- package/src/components/header-mobile/Component.tsx +4 -0
- package/src/context.ts +2 -1
- package/src/index.ts +1 -0
- package/src/types.ts +8 -0
- package/src/utils/constants.ts +1 -0
- package/types.d.ts +6 -0
- package/utils/constants.d.ts +1 -0
- package/utils/constants.js +1 -0
- package/utils/constants.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, { type FC, type MouseEvent, useCallback, useEffect, useState } from 'react';\nimport cn from 'classnames';\nimport type SwiperCore from 'swiper';\n\nimport { BaseModal } from '@alfalab/core-components-base-modal';\nimport { useIsDesktop } from '@alfalab/core-components-mq';\n\nimport { BottomButton } from './components/bottom-button';\nimport { Single } from './components/image-viewer/single';\nimport { Subtitles } from './components/subtitles';\nimport { Header, HeaderMobile, ImageViewer, InfoBar, NavigationBar } from './components';\nimport { SWIPE_THRESHOLD } from './constants';\nimport { GalleryContext } from './context';\nimport { type GalleryImage, type ImageMeta } from './types';\n\nimport styles from './index.module.css';\n\nexport type GalleryProps = {\n /**\n * Управление видимостью\n */\n open: boolean;\n\n /**\n * Массив изображений\n */\n images: GalleryImage[];\n\n /**\n * Зациклить галерею\n * @default true\n */\n loop?: boolean;\n\n /**\n * Индекс открытого изображение\n * @default 0\n */\n initialSlide?: number;\n\n /**\n * Обработчик закрытия\n */\n onClose: () => void;\n\n /**\n * Индекс текущего изображения\n */\n slideIndex?: number;\n\n /**\n * Обработчик изменения текущего изображения\n */\n onSlideIndexChange?: (index: number) => void;\n\n /**\n * Дополнительный класс для попапа\n */\n popupClassName?: string;\n};\n\nconst DEFAULT_FULL_SCREEN = false;\nconst DEFAULT_MUTED_VIDEO = true;\nconst DEFAULT_PLAYING_VIDEO = true;\nconst DEFAULT_HIDE_NAVIGATION = false;\n\nconst Backdrop = () => null;\n\nexport const Gallery: FC<GalleryProps> = ({\n open,\n images,\n slideIndex,\n initialSlide = 0,\n loop = true,\n onClose,\n onSlideIndexChange,\n popupClassName,\n}) => {\n const currentSlideIndexState = useState(initialSlide);\n const uncontrolled = slideIndex === undefined;\n const [currentSlideIndex, setCurrentSlideIndex] = uncontrolled\n ? currentSlideIndexState\n : [slideIndex, onSlideIndexChange];\n\n const [swiper, setSwiper] = useState<SwiperCore>();\n const [imagesMeta, setImagesMeta] = useState<ImageMeta[]>([]);\n const [fullScreen, setFullScreen] = useState<boolean>(DEFAULT_FULL_SCREEN);\n const [mutedVideo, setMutedVideo] = useState<boolean>(DEFAULT_MUTED_VIDEO);\n const [playingVideo, setPlayingVideo] = useState<boolean>(DEFAULT_PLAYING_VIDEO);\n const [hideNavigation, setHideNavigation] = useState<boolean>(DEFAULT_HIDE_NAVIGATION);\n const [swipeY, setSwipeY] = useState<number>(0);\n\n const isDesktop = useIsDesktop();\n\n const isCurrentVideo = !!imagesMeta[currentSlideIndex]?.player?.current;\n\n const bottomButton = images[currentSlideIndex]?.bottomButton;\n\n const slideTo = useCallback(\n (index: number) => {\n if (images[index]) {\n setCurrentSlideIndex?.(index);\n\n if (swiper) {\n setPlayingVideo(true);\n swiper.slideTo(index);\n }\n }\n },\n [images, setCurrentSlideIndex, swiper],\n );\n\n const slideNext = useCallback(() => {\n const lastIndex = images.length - 1;\n\n let nextIndex = currentSlideIndex + 1;\n\n if (nextIndex >= images.length) {\n nextIndex = loop ? 0 : lastIndex;\n }\n\n slideTo(nextIndex);\n }, [images.length, loop, currentSlideIndex, slideTo]);\n\n const slidePrev = useCallback(() => {\n const lastIndex = images.length - 1;\n\n let nextIndex = currentSlideIndex - 1;\n\n if (nextIndex < 0) {\n nextIndex = loop ? lastIndex : 0;\n }\n\n slideTo(nextIndex);\n }, [images.length, loop, currentSlideIndex, slideTo]);\n\n const setImageMeta = useCallback((meta: ImageMeta, index: number) => {\n setImagesMeta((prevImagesMeta) => {\n const nextImagesMeta = prevImagesMeta.slice();\n\n nextImagesMeta[index] = meta;\n\n return nextImagesMeta;\n });\n }, []);\n\n const handleBottomButtonClick = useCallback(\n (e: MouseEvent) => {\n e.stopPropagation();\n if (bottomButton?.onClick) {\n bottomButton.onClick(e);\n }\n },\n [bottomButton],\n );\n\n const handleClose = useCallback(() => {\n onClose();\n\n if (uncontrolled) {\n setCurrentSlideIndex?.(initialSlide);\n }\n\n setFullScreen(false);\n }, [initialSlide, onClose, setCurrentSlideIndex, uncontrolled]);\n\n const handleEscapeKeyDown = () => {\n if (fullScreen) {\n setFullScreen(false);\n } else {\n handleClose();\n }\n };\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (!open || fullScreen) {\n return;\n }\n\n switch (event.key) {\n case 'ArrowLeft':\n slidePrev();\n break;\n case 'ArrowRight':\n slideNext();\n break;\n }\n },\n [fullScreen, open, slideNext, slidePrev],\n );\n\n const onUnmount = useCallback(() => {\n setPlayingVideo(DEFAULT_PLAYING_VIDEO);\n setMutedVideo(DEFAULT_MUTED_VIDEO);\n }, [setPlayingVideo]);\n\n useEffect(() => {\n if (!uncontrolled && !swiper?.destroyed) {\n swiper?.slideTo(currentSlideIndex);\n }\n }, [uncontrolled, currentSlideIndex, swiper]);\n\n useEffect(() => {\n if (!open) {\n setSwipeY(0);\n }\n }, [open]);\n\n useEffect(() => {\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [handleKeyDown]);\n\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n\n let startX = 0;\n let startY = 0;\n let lockedDirection: 'horizontal' | 'vertical' | null = null;\n const directionLockThreshold = 10;\n\n const abortController = new AbortController();\n const { signal } = abortController;\n\n document.addEventListener(\n 'touchstart',\n (e) => {\n startX = e.touches[0].clientX;\n startY = e.touches[0].clientY;\n lockedDirection = null;\n },\n { signal },\n );\n\n document.addEventListener(\n 'touchmove',\n (e) => {\n const currentX = e.touches[0].clientX;\n const currentY = e.touches[0].clientY;\n const deltaX = currentX - startX;\n const deltaY = currentY - startY;\n\n if (!lockedDirection) {\n const absX = Math.abs(deltaX);\n const absY = Math.abs(deltaY);\n\n if (absX > absY && absX > directionLockThreshold) {\n lockedDirection = 'horizontal';\n } else if (absY > absX && absY > directionLockThreshold) {\n lockedDirection = 'vertical';\n } else {\n return;\n }\n }\n\n if (lockedDirection === 'horizontal') {\n return;\n }\n\n if (deltaY <= 0) {\n setSwipeY(0);\n\n return;\n }\n\n setSwipeY(deltaY);\n\n if (deltaY > SWIPE_THRESHOLD) {\n setSwipeY(0);\n onClose();\n }\n },\n { signal },\n );\n\n document.addEventListener(\n 'touchend',\n () => {\n lockedDirection = null;\n setSwipeY(0);\n },\n { signal },\n );\n\n return () => {\n abortController.abort();\n };\n }, [onClose, open]);\n\n const singleSlide = images.length === 1;\n\n const showNavigationBar = !singleSlide && !fullScreen;\n\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n const galleryContext: GalleryContext = {\n view: isDesktop ? 'desktop' : 'mobile',\n singleSlide,\n currentSlideIndex,\n images,\n imagesMeta,\n fullScreen,\n initialSlide: uncontrolled ? initialSlide : currentSlideIndex,\n setFullScreen,\n playingVideo,\n setPlayingVideo,\n mutedVideo,\n setMutedVideo,\n hideNavigation,\n setHideNavigation,\n setImageMeta,\n slideNext,\n slidePrev,\n slideTo,\n getSwiper: () => swiper,\n setSwiper,\n onClose: handleClose,\n setCurrentSlideIndex,\n getCurrentImage: () => images[currentSlideIndex],\n getCurrentImageMeta: () => imagesMeta[currentSlideIndex],\n };\n\n return (\n <GalleryContext.Provider value={galleryContext}>\n <BaseModal\n open={open}\n className={cn(styles.modal, popupClassName)}\n onEscapeKeyDown={handleEscapeKeyDown}\n Backdrop={Backdrop}\n onUnmount={onUnmount}\n >\n <div\n data-content-area={true}\n style={{\n transform: `translateY(${swipeY}px)`,\n }}\n className={cn(styles.container, {\n [styles.mobile]: !isDesktop,\n })}\n >\n {isDesktop ? <Header /> : <HeaderMobile />}\n {images.length === 1 ? <Single /> : <ImageViewer />}\n <nav\n className={cn({\n [styles.navigationVideo]: isCurrentVideo && !isDesktop,\n [styles.hide]: showNavigationBar && hideNavigation && !isDesktop,\n [styles.hideInfo]: !showNavigationBar && hideNavigation && !isDesktop,\n })}\n >\n {!isDesktop && <Subtitles />}\n {isCurrentVideo && !isDesktop && bottomButton && (\n <BottomButton\n bottomButton={bottomButton}\n onClick={handleBottomButtonClick}\n className={styles.bottomButton}\n />\n )}\n\n {showNavigationBar && <NavigationBar />}\n {!isDesktop && <InfoBar />}\n </nav>\n </div>\n </BaseModal>\n </GalleryContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA6DA,MAAM,mBAAmB,GAAG,KAAK;AACjC,MAAM,mBAAmB,GAAG,IAAI;AAChC,MAAM,qBAAqB,GAAG,IAAI;AAClC,MAAM,uBAAuB,GAAG,KAAK;AAErC,MAAM,QAAQ,GAAG,MAAM,IAAI;AAEd,MAAA,OAAO,GAAqB,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,UAAU,EACV,YAAY,GAAG,CAAC,EAChB,IAAI,GAAG,IAAI,EACX,OAAO,EACP,kBAAkB,EAClB,cAAc,GACjB,KAAI;AACD,IAAA,MAAM,sBAAsB,GAAG,QAAQ,CAAC,YAAY,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BAChE,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,iBAAiB,IAAI,cAAc,IAAI,CAAC,SAAS;qBACxE,CAAC,EAAA;AAED,oBAAA,CAAC,SAAS,IAAI,KAAC,CAAA,aAAA,CAAA,SAAS,EAAG,IAAA,CAAA;oBAC3B,cAAc,IAAI,CAAC,SAAS,IAAI,YAAY,KACzC,KAAA,CAAA,aAAA,CAAC,YAAY,EAAA,EACT,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,uBAAuB,EAChC,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA,CAChC,CACL;oBAEA,iBAAiB,IAAI,KAAC,CAAA,aAAA,CAAA,aAAa,EAAG,IAAA,CAAA;oBACtC,CAAC,SAAS,IAAI,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,IAAA,CAAG,CACxB,CACJ,CACE,CACU;AAElC;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, { type FC, type MouseEvent, useCallback, useEffect, useState } from 'react';\nimport cn from 'classnames';\nimport type SwiperCore from 'swiper';\n\nimport { BaseModal } from '@alfalab/core-components-base-modal';\nimport { useIsDesktop } from '@alfalab/core-components-mq';\n\nimport { BottomButton } from './components/bottom-button';\nimport { Single } from './components/image-viewer/single';\nimport { Subtitles } from './components/subtitles';\nimport { Header, HeaderMobile, ImageViewer, InfoBar, NavigationBar } from './components';\nimport { SWIPE_THRESHOLD } from './constants';\nimport { GalleryContext } from './context';\nimport { type GalleryCustomButton, type GalleryImage, type ImageMeta } from './types';\n\nimport styles from './index.module.css';\n\nexport type GalleryProps = {\n /**\n * Управление видимостью\n */\n open: boolean;\n\n /**\n * Массив изображений\n */\n images: GalleryImage[];\n\n /**\n * Зациклить галерею\n * @default true\n */\n loop?: boolean;\n\n /**\n * Индекс открытого изображение\n * @default 0\n */\n initialSlide?: number;\n\n /**\n * Обработчик закрытия\n */\n onClose: () => void;\n\n /**\n * Индекс текущего изображения\n */\n slideIndex?: number;\n\n /**\n * Обработчик изменения текущего изображения\n */\n onSlideIndexChange?: (index: number) => void;\n\n /**\n * Дополнительный класс для попапа\n */\n popupClassName?: string;\n\n /**\n * Дополнительная кнопка в шапке галереи\n */\n customButton?: GalleryCustomButton;\n};\n\nconst DEFAULT_FULL_SCREEN = false;\nconst DEFAULT_MUTED_VIDEO = true;\nconst DEFAULT_PLAYING_VIDEO = true;\nconst DEFAULT_HIDE_NAVIGATION = false;\n\nconst Backdrop = () => null;\n\nexport const Gallery: FC<GalleryProps> = ({\n open,\n images,\n slideIndex,\n initialSlide = 0,\n loop = true,\n onClose,\n onSlideIndexChange,\n popupClassName,\n customButton,\n}) => {\n const currentSlideIndexState = useState(initialSlide);\n const uncontrolled = slideIndex === undefined;\n const [currentSlideIndex, setCurrentSlideIndex] = uncontrolled\n ? currentSlideIndexState\n : [slideIndex, onSlideIndexChange];\n\n const [swiper, setSwiper] = useState<SwiperCore>();\n const [imagesMeta, setImagesMeta] = useState<ImageMeta[]>([]);\n const [fullScreen, setFullScreen] = useState<boolean>(DEFAULT_FULL_SCREEN);\n const [mutedVideo, setMutedVideo] = useState<boolean>(DEFAULT_MUTED_VIDEO);\n const [playingVideo, setPlayingVideo] = useState<boolean>(DEFAULT_PLAYING_VIDEO);\n const [hideNavigation, setHideNavigation] = useState<boolean>(DEFAULT_HIDE_NAVIGATION);\n const [swipeY, setSwipeY] = useState<number>(0);\n\n const isDesktop = useIsDesktop();\n\n const isCurrentVideo = !!imagesMeta[currentSlideIndex]?.player?.current;\n\n const bottomButton = images[currentSlideIndex]?.bottomButton;\n\n const slideTo = useCallback(\n (index: number) => {\n if (images[index]) {\n setCurrentSlideIndex?.(index);\n\n if (swiper) {\n setPlayingVideo(true);\n swiper.slideTo(index);\n }\n }\n },\n [images, setCurrentSlideIndex, swiper],\n );\n\n const slideNext = useCallback(() => {\n const lastIndex = images.length - 1;\n\n let nextIndex = currentSlideIndex + 1;\n\n if (nextIndex >= images.length) {\n nextIndex = loop ? 0 : lastIndex;\n }\n\n slideTo(nextIndex);\n }, [images.length, loop, currentSlideIndex, slideTo]);\n\n const slidePrev = useCallback(() => {\n const lastIndex = images.length - 1;\n\n let nextIndex = currentSlideIndex - 1;\n\n if (nextIndex < 0) {\n nextIndex = loop ? lastIndex : 0;\n }\n\n slideTo(nextIndex);\n }, [images.length, loop, currentSlideIndex, slideTo]);\n\n const setImageMeta = useCallback((meta: ImageMeta, index: number) => {\n setImagesMeta((prevImagesMeta) => {\n const nextImagesMeta = prevImagesMeta.slice();\n\n nextImagesMeta[index] = meta;\n\n return nextImagesMeta;\n });\n }, []);\n\n const handleBottomButtonClick = useCallback(\n (e: MouseEvent) => {\n e.stopPropagation();\n if (bottomButton?.onClick) {\n bottomButton.onClick(e);\n }\n },\n [bottomButton],\n );\n\n const handleClose = useCallback(() => {\n onClose();\n\n if (uncontrolled) {\n setCurrentSlideIndex?.(initialSlide);\n }\n\n setFullScreen(false);\n }, [initialSlide, onClose, setCurrentSlideIndex, uncontrolled]);\n\n const handleEscapeKeyDown = () => {\n if (fullScreen) {\n setFullScreen(false);\n } else {\n handleClose();\n }\n };\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (!open || fullScreen) {\n return;\n }\n\n switch (event.key) {\n case 'ArrowLeft':\n slidePrev();\n break;\n case 'ArrowRight':\n slideNext();\n break;\n }\n },\n [fullScreen, open, slideNext, slidePrev],\n );\n\n const onUnmount = useCallback(() => {\n setPlayingVideo(DEFAULT_PLAYING_VIDEO);\n setMutedVideo(DEFAULT_MUTED_VIDEO);\n }, [setPlayingVideo]);\n\n useEffect(() => {\n if (!uncontrolled && !swiper?.destroyed) {\n swiper?.slideTo(currentSlideIndex);\n }\n }, [uncontrolled, currentSlideIndex, swiper]);\n\n useEffect(() => {\n if (!open) {\n setSwipeY(0);\n }\n }, [open]);\n\n useEffect(() => {\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [handleKeyDown]);\n\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n\n let startX = 0;\n let startY = 0;\n let lockedDirection: 'horizontal' | 'vertical' | null = null;\n const directionLockThreshold = 10;\n\n const abortController = new AbortController();\n const { signal } = abortController;\n\n document.addEventListener(\n 'touchstart',\n (e) => {\n startX = e.touches[0].clientX;\n startY = e.touches[0].clientY;\n lockedDirection = null;\n },\n { signal },\n );\n\n document.addEventListener(\n 'touchmove',\n (e) => {\n const currentX = e.touches[0].clientX;\n const currentY = e.touches[0].clientY;\n const deltaX = currentX - startX;\n const deltaY = currentY - startY;\n\n if (!lockedDirection) {\n const absX = Math.abs(deltaX);\n const absY = Math.abs(deltaY);\n\n if (absX > absY && absX > directionLockThreshold) {\n lockedDirection = 'horizontal';\n } else if (absY > absX && absY > directionLockThreshold) {\n lockedDirection = 'vertical';\n } else {\n return;\n }\n }\n\n if (lockedDirection === 'horizontal') {\n return;\n }\n\n if (deltaY <= 0) {\n setSwipeY(0);\n\n return;\n }\n\n setSwipeY(deltaY);\n\n if (deltaY > SWIPE_THRESHOLD) {\n setSwipeY(0);\n onClose();\n }\n },\n { signal },\n );\n\n document.addEventListener(\n 'touchend',\n () => {\n lockedDirection = null;\n setSwipeY(0);\n },\n { signal },\n );\n\n return () => {\n abortController.abort();\n };\n }, [onClose, open]);\n\n const singleSlide = images.length === 1;\n\n const showNavigationBar = !singleSlide && !fullScreen;\n\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n const galleryContext: GalleryContext = {\n view: isDesktop ? 'desktop' : 'mobile',\n singleSlide,\n currentSlideIndex,\n images,\n imagesMeta,\n fullScreen,\n initialSlide: uncontrolled ? initialSlide : currentSlideIndex,\n setFullScreen,\n playingVideo,\n setPlayingVideo,\n mutedVideo,\n setMutedVideo,\n hideNavigation,\n setHideNavigation,\n setImageMeta,\n slideNext,\n slidePrev,\n slideTo,\n getSwiper: () => swiper,\n setSwiper,\n onClose: handleClose,\n setCurrentSlideIndex,\n getCurrentImage: () => images[currentSlideIndex],\n getCurrentImageMeta: () => imagesMeta[currentSlideIndex],\n customButton,\n };\n\n return (\n <GalleryContext.Provider value={galleryContext}>\n <BaseModal\n open={open}\n className={cn(styles.modal, popupClassName)}\n onEscapeKeyDown={handleEscapeKeyDown}\n Backdrop={Backdrop}\n onUnmount={onUnmount}\n >\n <div\n data-content-area={true}\n style={{\n transform: `translateY(${swipeY}px)`,\n }}\n className={cn(styles.container, {\n [styles.mobile]: !isDesktop,\n })}\n >\n {isDesktop ? <Header /> : <HeaderMobile />}\n {images.length === 1 ? <Single /> : <ImageViewer />}\n <nav\n className={cn({\n [styles.navigationVideo]: isCurrentVideo && !isDesktop,\n [styles.hide]: showNavigationBar && hideNavigation && !isDesktop,\n [styles.hideInfo]: !showNavigationBar && hideNavigation && !isDesktop,\n })}\n >\n {!isDesktop && <Subtitles />}\n {isCurrentVideo && !isDesktop && bottomButton && (\n <BottomButton\n bottomButton={bottomButton}\n onClick={handleBottomButtonClick}\n className={styles.bottomButton}\n />\n )}\n\n {showNavigationBar && <NavigationBar />}\n {!isDesktop && <InfoBar />}\n </nav>\n </div>\n </BaseModal>\n </GalleryContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAkEA,MAAM,mBAAmB,GAAG,KAAK;AACjC,MAAM,mBAAmB,GAAG,IAAI;AAChC,MAAM,qBAAqB,GAAG,IAAI;AAClC,MAAM,uBAAuB,GAAG,KAAK;AAErC,MAAM,QAAQ,GAAG,MAAM,IAAI;AAEpB,MAAM,OAAO,GAAqB,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,UAAU,EACV,YAAY,GAAG,CAAC,EAChB,IAAI,GAAG,IAAI,EACX,OAAO,EACP,kBAAkB,EAClB,cAAc,EACd,YAAY,GACf,KAAI;AACD,IAAA,MAAM,sBAAsB,GAAG,QAAQ,CAAC,YAAY,CAAC;AACrD,IAAA,MAAM,YAAY,GAAG,UAAU,KAAK,SAAS;AAC7C,IAAA,MAAM,CAAC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,CAAC,SAAS;qBACxE,CAAC,EAAA;AAED,oBAAA,CAAC,SAAS,IAAI,KAAC,CAAA,aAAA,CAAA,SAAS,EAAG,IAAA,CAAA;oBAC3B,cAAc,IAAI,CAAC,SAAS,IAAI,YAAY,KACzC,KAAA,CAAA,aAAA,CAAC,YAAY,EAAA,EACT,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,uBAAuB,EAChC,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA,CAChC,CACL;oBAEA,iBAAiB,IAAI,KAAC,CAAA,aAAA,CAAA,aAAa,EAAG,IAAA,CAAA;oBACtC,CAAC,SAAS,IAAI,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,IAAA,CAAG,CACxB,CACJ,CACE,CACU;AAElC;;;;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type FC, type MutableRefObject } from 'react';
|
|
2
2
|
import { type IconButtonProps } from '@alfalab/core-components-icon-button/moderncssm';
|
|
3
|
+
import { type GalleryCustomButton } from '../../types';
|
|
3
4
|
type Props = Omit<IconButtonProps, 'icon' | 'colors'> & {
|
|
4
5
|
buttonRef?: MutableRefObject<HTMLButtonElement | null>;
|
|
5
6
|
download?: string | boolean;
|
|
6
7
|
};
|
|
8
|
+
type CustomButtonProps = GalleryCustomButton & Props;
|
|
7
9
|
export declare const Fullscreen: FC<Props>;
|
|
8
10
|
export declare const BackArrow: FC<Props>;
|
|
9
11
|
export declare const Play: FC<Props>;
|
|
@@ -15,5 +17,6 @@ export declare const Download: FC<Props & {
|
|
|
15
17
|
href?: string;
|
|
16
18
|
}>;
|
|
17
19
|
export declare const Share: FC<Props>;
|
|
20
|
+
export declare const CustomButton: FC<CustomButtonProps>;
|
|
18
21
|
export declare const Exit: FC<Props>;
|
|
19
22
|
export {};
|
|
@@ -68,7 +68,12 @@ const Share = (props) => {
|
|
|
68
68
|
const iconButton = (React.createElement(IconButton, { ...props, icon: ShareMIcon, "aria-label": '\u041F\u043E\u0434\u0435\u043B\u0438\u0442\u044C\u0441\u044F', className: styles.iconButton }));
|
|
69
69
|
return isDesktop ? (React.createElement(TooltipDesktop, { view: 'hint', colors: 'inverted', trigger: 'hover', position: 'bottom', content: '\u041F\u043E\u0434\u0435\u043B\u0438\u0442\u044C\u0441\u044F', fallbackPlacements: ['bottom-end'] }, iconButton)) : (iconButton);
|
|
70
70
|
};
|
|
71
|
+
const CustomButton = ({ text, icon, ...restProps }) => {
|
|
72
|
+
const isDesktop = useIsDesktop();
|
|
73
|
+
const iconButton = (React.createElement(IconButton, { ...restProps, icon: icon, "aria-label": text, className: styles.iconButton }));
|
|
74
|
+
return isDesktop ? (React.createElement(TooltipDesktop, { trigger: 'hover', position: 'bottom', content: text, fallbackPlacements: ['bottom-end'] }, iconButton)) : (iconButton);
|
|
75
|
+
};
|
|
71
76
|
const Exit = (props) => (React.createElement(IconButton, { ...props, icon: CrossMIcon, "aria-label": '\u0417\u0430\u043A\u0440\u044B\u0442\u044C', className: styles.iconButton }));
|
|
72
77
|
|
|
73
|
-
export { BackArrow, Download, Exit, ExitFullscreen, Fullscreen, MuteVideo, Pause, Play, Share, UnmuteVideo };
|
|
78
|
+
export { BackArrow, CustomButton, Download, Exit, ExitFullscreen, Fullscreen, MuteVideo, Pause, Play, Share, UnmuteVideo };
|
|
74
79
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/buttons/index.tsx"],"sourcesContent":["import React, { type FC, type MutableRefObject } from 'react';\nimport cn from 'classnames';\n\nimport { IconButton, type IconButtonProps } from '@alfalab/core-components-icon-button';\nimport { useIsDesktop } from '@alfalab/core-components-mq';\nimport { TooltipDesktop } from '@alfalab/core-components-tooltip/desktop';\nimport { ArrowLeftMIcon } from '@alfalab/icons-glyph/ArrowLeftMIcon';\nimport { ArrowsInwardMIcon } from '@alfalab/icons-glyph/ArrowsInwardMIcon';\nimport { ArrowsOutwardMIcon } from '@alfalab/icons-glyph/ArrowsOutwardMIcon';\nimport { CrossMIcon } from '@alfalab/icons-glyph/CrossMIcon';\nimport { PauseCompactMIcon } from '@alfalab/icons-glyph/PauseCompactMIcon';\nimport { PlayCompactMIcon } from '@alfalab/icons-glyph/PlayCompactMIcon';\nimport { PointerDownMIcon } from '@alfalab/icons-glyph/PointerDownMIcon';\nimport { ShareMIcon } from '@alfalab/icons-glyph/ShareMIcon';\nimport { SoundCrossMIcon } from '@alfalab/icons-glyph/SoundCrossMIcon';\nimport { SoundMIcon } from '@alfalab/icons-glyph/SoundMIcon';\n\nimport { downloadFile, isVideo } from '../../utils';\n\nimport styles from './index.module.css';\n\ntype Props = Omit<IconButtonProps, 'icon' | 'colors'> & {\n buttonRef?: MutableRefObject<HTMLButtonElement | null>;\n download?: string | boolean;\n};\n\nexport const Fullscreen: FC<Props> = ({ buttonRef, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={ArrowsOutwardMIcon}\n aria-label='Открыть в полноэкранном режиме'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Открыть в полноэкранном режиме'\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const BackArrow: FC<Props> = ({ buttonRef, ...restProps }) => (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={ArrowLeftMIcon}\n aria-label='Вернуться назад'\n className={styles.iconButton}\n />\n);\n\nexport const Play: FC<Props> = ({ buttonRef, className, ...restProps }) => (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={PlayCompactMIcon}\n aria-label='Проиграть видео'\n className={cn(styles.iconButton, className)}\n />\n);\n\nexport const Pause: FC<Props> = ({ buttonRef, className, ...restProps }) => (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={PauseCompactMIcon}\n aria-label='Поставить паузу на видео'\n className={cn(styles.iconButton, className)}\n />\n);\n\nexport const ExitFullscreen: FC<Props> = ({ buttonRef, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={ArrowsInwardMIcon}\n aria-label='Выйти из полноэкранного режима'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Выйти из полноэкранного режима'\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const MuteVideo: FC<Props> = ({ buttonRef, className, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={SoundMIcon}\n aria-label='Выключить звук'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Выключить звук'\n fallbackPlacements={['bottom-end']}\n targetClassName={className}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const UnmuteVideo: FC<Props> = ({ buttonRef, className, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={SoundCrossMIcon}\n aria-label='Включить звук'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Включить звук'\n fallbackPlacements={['bottom-end']}\n targetClassName={className}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const Download: FC<Props & { href?: string }> = ({ href, ...props }) => {\n const isDesktop = useIsDesktop();\n\n const handleMobileVideoDownload = async (e: React.MouseEvent) => {\n e.preventDefault();\n\n if (!href) return;\n\n const fileName = props.download?.toString() || 'video';\n const fileType = isVideo(href) ? 'video/*' : undefined;\n\n await downloadFile({\n url: href,\n fileName,\n fileType,\n });\n };\n\n const iconButtonProps = {\n ...props,\n icon: PointerDownMIcon,\n 'aria-label': 'Скачать' as const,\n className: styles.iconButton,\n };\n\n const iconButton =\n !isDesktop && isVideo(href) ? (\n <IconButton {...iconButtonProps} onClick={handleMobileVideoDownload} />\n ) : (\n <IconButton {...iconButtonProps} href={href} />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Скачать'\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const Share: FC<Props> = (props) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...props}\n icon={ShareMIcon}\n aria-label='Поделиться'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Поделиться'\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const Exit: FC<Props> = (props) => (\n <IconButton {...props} icon={CrossMIcon} aria-label='Закрыть' className={styles.iconButton} />\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA0BO,MAAM,UAAU,GAAc,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,KAAI;AACjE,IAAA,MAAM,SAAS,GAAG,YAAY,EAAE;IAEhC,MAAM,UAAU,IACZ,KAAC,CAAA,aAAA,CAAA,UAAU,OACH,SAAS,EACb,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,kBAAkB,EACb,YAAA,EAAA,uKAAgC,EAC3C,SAAS,EAAE,MAAM,CAAC,UAAU,EAC9B,CAAA,CACL;AAED,IAAA,OAAO,SAAS,IACZ,KAAA,CAAA,aAAA,CAAC,cAAc,EACX,EAAA,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,UAAU,EACjB,OAAO,EAA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AAI,EAAC,MAAM,EACX,MAAM,EAAC,UAAU,EACjB,OAAO,EAAC,OAAO,EACf,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,4CAAS,EACjB,kBAAkB,EAAE,CAAC,YAAY,CAAC,IAEjC,UAAU,CACE,KAEjB,UAAU,CACb;AACL;AAEa,MAAA,KAAK,GAAc,CAAC,KAAK,KAAI;AACtC,IAAA,MAAM,SAAS,GAAG,YAAY,EAAE;IAEhC,MAAM,UAAU,IACZ,KAAA,CAAA,aAAA,CAAC,UAAU,EACH,EAAA,GAAA,KAAK,EACT,IAAI,EAAE,UAAU,EACL,YAAA,EAAA,8DAAY,EACvB,SAAS,EAAE,MAAM,CAAC,UAAU,EAC9B,CAAA,CACL;AAED,IAAA,OAAO,SAAS,IACZ,KAAA,CAAA,aAAA,CAAC,cAAc,EACX,EAAA,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,UAAU,EACjB,OAAO,EAAC,OAAO,EACf,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,8DAAY,EACpB,kBAAkB,EAAE,CAAC,YAAY,CAAC,IAEjC,UAAU,CACE,KAEjB,UAAU,CACb;AACL;AAEO,MAAM,IAAI,GAAc,CAAC,KAAK,MACjC,KAAC,CAAA,aAAA,CAAA,UAAU,EAAK,EAAA,GAAA,KAAK,EAAE,IAAI,EAAE,UAAU,EAAa,YAAA,EAAA,4CAAS,EAAC,SAAS,EAAE,MAAM,CAAC,UAAU,EAAI,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/buttons/index.tsx"],"sourcesContent":["import React, { type FC, type MutableRefObject } from 'react';\nimport cn from 'classnames';\n\nimport { IconButton, type IconButtonProps } from '@alfalab/core-components-icon-button';\nimport { useIsDesktop } from '@alfalab/core-components-mq';\nimport { TooltipDesktop } from '@alfalab/core-components-tooltip/desktop';\nimport { ArrowLeftMIcon } from '@alfalab/icons-glyph/ArrowLeftMIcon';\nimport { ArrowsInwardMIcon } from '@alfalab/icons-glyph/ArrowsInwardMIcon';\nimport { ArrowsOutwardMIcon } from '@alfalab/icons-glyph/ArrowsOutwardMIcon';\nimport { CrossMIcon } from '@alfalab/icons-glyph/CrossMIcon';\nimport { PauseCompactMIcon } from '@alfalab/icons-glyph/PauseCompactMIcon';\nimport { PlayCompactMIcon } from '@alfalab/icons-glyph/PlayCompactMIcon';\nimport { PointerDownMIcon } from '@alfalab/icons-glyph/PointerDownMIcon';\nimport { ShareMIcon } from '@alfalab/icons-glyph/ShareMIcon';\nimport { SoundCrossMIcon } from '@alfalab/icons-glyph/SoundCrossMIcon';\nimport { SoundMIcon } from '@alfalab/icons-glyph/SoundMIcon';\n\nimport { type GalleryCustomButton } from '../../types';\nimport { downloadFile, isVideo } from '../../utils';\n\nimport styles from './index.module.css';\n\ntype Props = Omit<IconButtonProps, 'icon' | 'colors'> & {\n buttonRef?: MutableRefObject<HTMLButtonElement | null>;\n download?: string | boolean;\n};\n\ntype CustomButtonProps = GalleryCustomButton & Props;\n\nexport const Fullscreen: FC<Props> = ({ buttonRef, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={ArrowsOutwardMIcon}\n aria-label='Открыть в полноэкранном режиме'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Открыть в полноэкранном режиме'\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const BackArrow: FC<Props> = ({ buttonRef, ...restProps }) => (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={ArrowLeftMIcon}\n aria-label='Вернуться назад'\n className={styles.iconButton}\n />\n);\n\nexport const Play: FC<Props> = ({ buttonRef, className, ...restProps }) => (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={PlayCompactMIcon}\n aria-label='Проиграть видео'\n className={cn(styles.iconButton, className)}\n />\n);\n\nexport const Pause: FC<Props> = ({ buttonRef, className, ...restProps }) => (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={PauseCompactMIcon}\n aria-label='Поставить паузу на видео'\n className={cn(styles.iconButton, className)}\n />\n);\n\nexport const ExitFullscreen: FC<Props> = ({ buttonRef, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={ArrowsInwardMIcon}\n aria-label='Выйти из полноэкранного режима'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Выйти из полноэкранного режима'\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const MuteVideo: FC<Props> = ({ buttonRef, className, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={SoundMIcon}\n aria-label='Выключить звук'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Выключить звук'\n fallbackPlacements={['bottom-end']}\n targetClassName={className}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const UnmuteVideo: FC<Props> = ({ buttonRef, className, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...restProps}\n ref={buttonRef}\n icon={SoundCrossMIcon}\n aria-label='Включить звук'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Включить звук'\n fallbackPlacements={['bottom-end']}\n targetClassName={className}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const Download: FC<Props & { href?: string }> = ({ href, ...props }) => {\n const isDesktop = useIsDesktop();\n\n const handleMobileVideoDownload = async (e: React.MouseEvent) => {\n e.preventDefault();\n\n if (!href) return;\n\n const fileName = props.download?.toString() || 'video';\n const fileType = isVideo(href) ? 'video/*' : undefined;\n\n await downloadFile({\n url: href,\n fileName,\n fileType,\n });\n };\n\n const iconButtonProps = {\n ...props,\n icon: PointerDownMIcon,\n 'aria-label': 'Скачать' as const,\n className: styles.iconButton,\n };\n\n const iconButton =\n !isDesktop && isVideo(href) ? (\n <IconButton {...iconButtonProps} onClick={handleMobileVideoDownload} />\n ) : (\n <IconButton {...iconButtonProps} href={href} />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Скачать'\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const Share: FC<Props> = (props) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton\n {...props}\n icon={ShareMIcon}\n aria-label='Поделиться'\n className={styles.iconButton}\n />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n view='hint'\n colors='inverted'\n trigger='hover'\n position='bottom'\n content='Поделиться'\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const CustomButton: FC<CustomButtonProps> = ({ text, icon, ...restProps }) => {\n const isDesktop = useIsDesktop();\n\n const iconButton = (\n <IconButton {...restProps} icon={icon} aria-label={text} className={styles.iconButton} />\n );\n\n return isDesktop ? (\n <TooltipDesktop\n trigger='hover'\n position='bottom'\n content={text}\n fallbackPlacements={['bottom-end']}\n >\n {iconButton}\n </TooltipDesktop>\n ) : (\n iconButton\n );\n};\n\nexport const Exit: FC<Props> = (props) => (\n <IconButton {...props} icon={CrossMIcon} aria-label='Закрыть' className={styles.iconButton} />\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA6BO,MAAM,UAAU,GAAc,CAAC,EAAE,SAA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,YAAY,EAAE;IAEhC,MAAM,UAAU,IACZ,KAAA,CAAA,aAAA,CAAC,UAAU,EAAK,EAAA,GAAA,SAAS,EAAE,IAAI,EAAE,IAAI,EAAc,YAAA,EAAA,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,EAAI,CAAA,CAC5F;AAED,IAAA,OAAO,SAAS,IACZ,KAAC,CAAA,aAAA,CAAA,cAAc,EACX,EAAA,OAAO,EAAC,OAAO,EACf,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAE,IAAI,EACb,kBAAkB,EAAE,CAAC,YAAY,CAAC,EAEjC,EAAA,UAAU,CACE,KAEjB,UAAU,CACb;AACL;AAEO,MAAM,IAAI,GAAc,CAAC,KAAK,MACjC,KAAC,CAAA,aAAA,CAAA,UAAU,EAAK,EAAA,GAAA,KAAK,EAAE,IAAI,EAAE,UAAU,EAAa,YAAA,EAAA,4CAAS,EAAC,SAAS,EAAE,MAAM,CAAC,UAAU,EAAI,CAAA;;;;"}
|
|
@@ -2,12 +2,12 @@ import React, { useContext, useRef, useEffect } from 'react';
|
|
|
2
2
|
import { GalleryContext } from '../../context.js';
|
|
3
3
|
import { isSmallImage, isVideo } from '../../utils/utils.js';
|
|
4
4
|
import { TestIds } from '../../utils/constants.js';
|
|
5
|
-
import { Download, Exit, UnmuteVideo, MuteVideo, ExitFullscreen, Fullscreen } from '../buttons/index.js';
|
|
5
|
+
import { Download, CustomButton, Exit, UnmuteVideo, MuteVideo, ExitFullscreen, Fullscreen } from '../buttons/index.js';
|
|
6
6
|
import { HeaderInfoBlock } from '../header-info-block/Component.js';
|
|
7
7
|
import styles from './index.module.css';
|
|
8
8
|
|
|
9
9
|
const Header = () => {
|
|
10
|
-
const { currentSlideIndex, singleSlide, images, fullScreen, getCurrentImageMeta, getCurrentImage, setFullScreen, onClose, mutedVideo, setMutedVideo, } = useContext(GalleryContext);
|
|
10
|
+
const { currentSlideIndex, singleSlide, images, fullScreen, getCurrentImageMeta, getCurrentImage, setFullScreen, onClose, mutedVideo, setMutedVideo, customButton, } = useContext(GalleryContext);
|
|
11
11
|
const currentImage = getCurrentImage();
|
|
12
12
|
const meta = getCurrentImageMeta();
|
|
13
13
|
const toggleFullScreenButton = useRef(null);
|
|
@@ -46,6 +46,7 @@ const Header = () => {
|
|
|
46
46
|
isVideo(currentImage?.src) && renderToggleMuteVideo(),
|
|
47
47
|
showFullScreenButton && renderToggleFullScreenButton(),
|
|
48
48
|
showDownloadButton && (React.createElement(Download, { href: currentImage?.src, download: currentImage?.name, dataTestId: TestIds.DOWNLOAD_BUTTON })),
|
|
49
|
+
customButton && (React.createElement(CustomButton, { ...customButton, dataTestId: TestIds.CUSTOM_BUTTON })),
|
|
49
50
|
React.createElement(Exit, { onClick: onClose, dataTestId: TestIds.CLOSE_BUTTON }))));
|
|
50
51
|
};
|
|
51
52
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../../../src/components/header/Component.tsx"],"sourcesContent":["import React, { type FC, useContext, useEffect, useRef } from 'react';\n\nimport { GalleryContext } from '../../context';\nimport { isSmallImage, isVideo, TestIds } from '../../utils';\nimport * as Buttons from '../buttons';\nimport { HeaderInfoBlock } from '../header-info-block';\n\nimport styles from './index.module.css';\n\nexport const Header: FC = () => {\n const {\n currentSlideIndex,\n singleSlide,\n images,\n fullScreen,\n getCurrentImageMeta,\n getCurrentImage,\n setFullScreen,\n onClose,\n mutedVideo,\n setMutedVideo,\n } = useContext(GalleryContext);\n\n const currentImage = getCurrentImage();\n const meta = getCurrentImageMeta();\n\n const toggleFullScreenButton = useRef<HTMLButtonElement>(null);\n\n const onMuteButtonClick = () => {\n if (currentImage) {\n if (mutedVideo && currentImage.onUnmute) {\n currentImage.onUnmute();\n } else if (currentImage.onMute) {\n currentImage.onMute();\n }\n }\n setMutedVideo(!mutedVideo);\n };\n\n const closeFullScreen = () => {\n setFullScreen(false);\n };\n\n const openFullScreen = () => {\n setFullScreen(true);\n };\n\n useEffect(() => {\n if (toggleFullScreenButton.current) {\n toggleFullScreenButton.current.focus();\n }\n }, [fullScreen]);\n\n const canDownload = currentImage?.canDownload ?? true;\n const filename = currentImage?.name || '';\n const description =\n singleSlide || !images.length ? '' : `${currentSlideIndex + 1} из ${images.length}`;\n\n const showFullScreenButton = !isSmallImage(meta) && !meta?.broken;\n const showDownloadButton = !meta?.broken && canDownload;\n\n const renderToggleFullScreenButton = () =>\n fullScreen ? (\n <Buttons.ExitFullscreen\n onClick={closeFullScreen}\n buttonRef={toggleFullScreenButton}\n dataTestId={TestIds.EXIT_FULLSCREEN_BUTTON}\n />\n ) : (\n <Buttons.Fullscreen\n onClick={openFullScreen}\n buttonRef={toggleFullScreenButton}\n dataTestId={TestIds.FULLSCREEN_BUTTON}\n />\n );\n\n const renderToggleMuteVideo = () =>\n mutedVideo ? (\n <Buttons.UnmuteVideo onClick={onMuteButtonClick} dataTestId={TestIds.UNMUTE_BUTTON} />\n ) : (\n <Buttons.MuteVideo onClick={onMuteButtonClick} dataTestId={TestIds.MUTE_BUTTON} />\n );\n\n return (\n <div className={styles.header}>\n <HeaderInfoBlock filename={filename} description={description} />\n\n <div className={styles.buttons}>\n {isVideo(currentImage?.src) && renderToggleMuteVideo()}\n {showFullScreenButton && renderToggleFullScreenButton()}\n\n {showDownloadButton && (\n <Buttons.Download\n href={currentImage?.src}\n download={currentImage?.name}\n dataTestId={TestIds.DOWNLOAD_BUTTON}\n />\n )}\n\n <Buttons.Exit onClick={onClose} dataTestId={TestIds.CLOSE_BUTTON} />\n </div>\n </div>\n );\n};\n"],"names":["Buttons.ExitFullscreen","Buttons.Fullscreen","Buttons.UnmuteVideo","Buttons.MuteVideo","Buttons.Download","Buttons.Exit"],"mappings":";;;;;;;;AASO,MAAM,MAAM,GAAO,MAAK;
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../../../src/components/header/Component.tsx"],"sourcesContent":["import React, { type FC, useContext, useEffect, useRef } from 'react';\n\nimport { GalleryContext } from '../../context';\nimport { isSmallImage, isVideo, TestIds } from '../../utils';\nimport * as Buttons from '../buttons';\nimport { HeaderInfoBlock } from '../header-info-block';\n\nimport styles from './index.module.css';\n\nexport const Header: FC = () => {\n const {\n currentSlideIndex,\n singleSlide,\n images,\n fullScreen,\n getCurrentImageMeta,\n getCurrentImage,\n setFullScreen,\n onClose,\n mutedVideo,\n setMutedVideo,\n customButton,\n } = useContext(GalleryContext);\n\n const currentImage = getCurrentImage();\n const meta = getCurrentImageMeta();\n\n const toggleFullScreenButton = useRef<HTMLButtonElement>(null);\n\n const onMuteButtonClick = () => {\n if (currentImage) {\n if (mutedVideo && currentImage.onUnmute) {\n currentImage.onUnmute();\n } else if (currentImage.onMute) {\n currentImage.onMute();\n }\n }\n setMutedVideo(!mutedVideo);\n };\n\n const closeFullScreen = () => {\n setFullScreen(false);\n };\n\n const openFullScreen = () => {\n setFullScreen(true);\n };\n\n useEffect(() => {\n if (toggleFullScreenButton.current) {\n toggleFullScreenButton.current.focus();\n }\n }, [fullScreen]);\n\n const canDownload = currentImage?.canDownload ?? true;\n const filename = currentImage?.name || '';\n const description =\n singleSlide || !images.length ? '' : `${currentSlideIndex + 1} из ${images.length}`;\n\n const showFullScreenButton = !isSmallImage(meta) && !meta?.broken;\n const showDownloadButton = !meta?.broken && canDownload;\n\n const renderToggleFullScreenButton = () =>\n fullScreen ? (\n <Buttons.ExitFullscreen\n onClick={closeFullScreen}\n buttonRef={toggleFullScreenButton}\n dataTestId={TestIds.EXIT_FULLSCREEN_BUTTON}\n />\n ) : (\n <Buttons.Fullscreen\n onClick={openFullScreen}\n buttonRef={toggleFullScreenButton}\n dataTestId={TestIds.FULLSCREEN_BUTTON}\n />\n );\n\n const renderToggleMuteVideo = () =>\n mutedVideo ? (\n <Buttons.UnmuteVideo onClick={onMuteButtonClick} dataTestId={TestIds.UNMUTE_BUTTON} />\n ) : (\n <Buttons.MuteVideo onClick={onMuteButtonClick} dataTestId={TestIds.MUTE_BUTTON} />\n );\n\n return (\n <div className={styles.header}>\n <HeaderInfoBlock filename={filename} description={description} />\n\n <div className={styles.buttons}>\n {isVideo(currentImage?.src) && renderToggleMuteVideo()}\n {showFullScreenButton && renderToggleFullScreenButton()}\n\n {showDownloadButton && (\n <Buttons.Download\n href={currentImage?.src}\n download={currentImage?.name}\n dataTestId={TestIds.DOWNLOAD_BUTTON}\n />\n )}\n\n {customButton && (\n <Buttons.CustomButton {...customButton} dataTestId={TestIds.CUSTOM_BUTTON} />\n )}\n\n <Buttons.Exit onClick={onClose} dataTestId={TestIds.CLOSE_BUTTON} />\n </div>\n </div>\n );\n};\n"],"names":["Buttons.ExitFullscreen","Buttons.Fullscreen","Buttons.UnmuteVideo","Buttons.MuteVideo","Buttons.Download","Buttons.CustomButton","Buttons.Exit"],"mappings":";;;;;;;;AASO,MAAM,MAAM,GAAO,MAAK;AAC3B,IAAA,MAAM,EACF,iBAAiB,EACjB,WAAW,EACX,MAAM,EACN,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,OAAO,EACP,UAAU,EACV,aAAa,EACb,YAAY,GACf,GAAG,UAAU,CAAC,cAAc,CAAC;AAE9B,IAAA,MAAM,YAAY,GAAG,eAAe,EAAE;AACtC,IAAA,MAAM,IAAI,GAAG,mBAAmB,EAAE;AAElC,IAAA,MAAM,sBAAsB,GAAG,MAAM,CAAoB,IAAI,CAAC;IAE9D,MAAM,iBAAiB,GAAG,MAAK;QAC3B,IAAI,YAAY,EAAE;AACd,YAAA,IAAI,UAAU,IAAI,YAAY,CAAC,QAAQ,EAAE;gBACrC,YAAY,CAAC,QAAQ,EAAE;;AACpB,iBAAA,IAAI,YAAY,CAAC,MAAM,EAAE;gBAC5B,YAAY,CAAC,MAAM,EAAE;;;AAG7B,QAAA,aAAa,CAAC,CAAC,UAAU,CAAC;AAC9B,KAAC;IAED,MAAM,eAAe,GAAG,MAAK;QACzB,aAAa,CAAC,KAAK,CAAC;AACxB,KAAC;IAED,MAAM,cAAc,GAAG,MAAK;QACxB,aAA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AA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,MAAM,EAAA;QACzB,KAAC,CAAA,aAAA,CAAA,eAAe,IAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAI,CAAA;AAEjE,QAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,OAAO,EAAA;AACzB,YAAA,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,IAAI,qBAAqB,EAAE;YACrD,oBAAoB,IAAI,4BAA4B,EAAE;YAEtD,kBAAkB,KACf,KAAA,CAAA,aAAA,CAACC,QAAgB,EACb,EAAA,IAAI,EAAE,YAAY,EAAE,GAAG,EACvB,QAAQ,EAAE,YAAY,EAAE,IAAI,EAC5B,UAAU,EAAE,OAAO,CAAC,eAAe,EAAA,CACrC,CACL;AAEA,YAAA,YAAY,KACT,KAAC,CAAA,aAAA,CAAAC,YAAoB,EAAA,EAAA,GAAK,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,aAAa,GAAI,CAChF;AAED,YAAA,KAAA,CAAA,aAAA,CAACC,IAAY,EAAC,EAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,YAAY,GAAI,CAClE,CACJ;AAEd;;;;"}
|
|
@@ -4,11 +4,11 @@ import { TypographyText } from '@alfalab/core-components-typography/moderncssm';
|
|
|
4
4
|
import { GalleryContext } from '../../context.js';
|
|
5
5
|
import { isVideo } from '../../utils/utils.js';
|
|
6
6
|
import { TestIds } from '../../utils/constants.js';
|
|
7
|
-
import { BackArrow, Download, Share } from '../buttons/index.js';
|
|
7
|
+
import { BackArrow, CustomButton, Download, Share } from '../buttons/index.js';
|
|
8
8
|
import styles from './index.module.css';
|
|
9
9
|
|
|
10
10
|
const HeaderMobile = () => {
|
|
11
|
-
const { onClose, images, currentSlideIndex, getCurrentImage, getCurrentImageMeta, hideNavigation, } = useContext(GalleryContext);
|
|
11
|
+
const { onClose, images, currentSlideIndex, getCurrentImage, getCurrentImageMeta, hideNavigation, customButton, } = useContext(GalleryContext);
|
|
12
12
|
const currentImage = getCurrentImage();
|
|
13
13
|
const meta = getCurrentImageMeta();
|
|
14
14
|
const description = images.length > 1 && `${currentSlideIndex + 1} из ${images.length}`;
|
|
@@ -71,6 +71,7 @@ const HeaderMobile = () => {
|
|
|
71
71
|
React.createElement(BackArrow, { onClick: onClose }),
|
|
72
72
|
React.createElement(TypographyText, { className: styles.description, tag: 'div', view: 'component-primary', color: 'static-primary-light' }, description),
|
|
73
73
|
React.createElement("div", { className: styles.rightButtons },
|
|
74
|
+
customButton && (React.createElement(CustomButton, { ...customButton, dataTestId: TestIds.CUSTOM_BUTTON })),
|
|
74
75
|
showDownloadButton && (React.createElement(Download, { href: currentImage?.src, download: currentImage?.name, dataTestId: TestIds.DOWNLOAD_BUTTON })),
|
|
75
76
|
showShareButton && React.createElement(Share, { onClick: handleShareClick }))));
|
|
76
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../../../src/components/header-mobile/Component.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport cn from 'classnames';\n\nimport { TypographyText } from '@alfalab/core-components-typography';\n\nimport { GalleryContext } from '../../context';\nimport { isVideo, TestIds } from '../../utils';\nimport * as Buttons from '../buttons';\n\nimport styles from './index.module.css';\n\nexport const HeaderMobile = () => {\n const {\n onClose,\n images,\n currentSlideIndex,\n getCurrentImage,\n getCurrentImageMeta,\n hideNavigation,\n } = useContext(GalleryContext);\n\n const currentImage = getCurrentImage();\n const meta = getCurrentImageMeta();\n\n const description = images.length > 1 && `${currentSlideIndex + 1} из ${images.length}`;\n\n const canDownload = currentImage?.canDownload ?? true;\n const showDownloadButton = !meta?.broken && canDownload;\n const canShare = currentImage?.canShare ?? true;\n const showShareButton = !meta?.broken && canShare;\n\n const handleShareClick = async () => {\n if (!currentImage || !navigator.share) {\n return;\n }\n\n const title = currentImage.name ?? new Date().toISOString().split('T')[0];\n const url = currentImage.src;\n\n try {\n if (isVideo(url)) {\n // Если видео — всегда делим ссылку\n await navigator.share({\n title,\n url,\n text: 'Видео',\n });\n\n return;\n }\n\n // Попробуем скачать изображение\n const response = await fetch(url, { mode: 'cors' });\n const blob = await response.blob();\n\n const file = new File([blob], `${title}.png`, {\n type: blob.type,\n lastModified: Date.now(),\n });\n\n const shareData: ShareData = {\n files: [file],\n title,\n text: 'Картинка',\n };\n\n // Попробуем поделиться файлом\n if (navigator.canShare?.(shareData) && response.ok) {\n await navigator.share(shareData);\n } else {\n // Fallback: делимся только ссылкой\n await navigator.share({\n title,\n text: 'Картинка',\n url,\n });\n }\n } catch {\n await navigator.share({\n title,\n url,\n });\n }\n };\n\n return (\n <div\n className={cn(styles.headerMobile, {\n [styles.video]: isVideo(currentImage?.src),\n [styles.hide]: hideNavigation,\n })}\n >\n <Buttons.BackArrow onClick={onClose} />\n <TypographyText\n className={styles.description}\n tag='div'\n view='component-primary'\n color='static-primary-light'\n >\n {description}\n </TypographyText>\n <div className={styles.rightButtons}>\n {showDownloadButton && (\n <Buttons.Download\n href={currentImage?.src}\n download={currentImage?.name}\n dataTestId={TestIds.DOWNLOAD_BUTTON}\n />\n )}\n {showShareButton && <Buttons.Share onClick={handleShareClick} />}\n </div>\n </div>\n );\n};\n"],"names":["Buttons.BackArrow","Buttons.Download","Buttons.Share"],"mappings":";;;;;;;;;AAWO,MAAM,YAAY,GAAG,MAAK;
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../../../src/components/header-mobile/Component.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport cn from 'classnames';\n\nimport { TypographyText } from '@alfalab/core-components-typography';\n\nimport { GalleryContext } from '../../context';\nimport { isVideo, TestIds } from '../../utils';\nimport * as Buttons from '../buttons';\n\nimport styles from './index.module.css';\n\nexport const HeaderMobile = () => {\n const {\n onClose,\n images,\n currentSlideIndex,\n getCurrentImage,\n getCurrentImageMeta,\n hideNavigation,\n customButton,\n } = useContext(GalleryContext);\n\n const currentImage = getCurrentImage();\n const meta = getCurrentImageMeta();\n\n const description = images.length > 1 && `${currentSlideIndex + 1} из ${images.length}`;\n\n const canDownload = currentImage?.canDownload ?? true;\n const showDownloadButton = !meta?.broken && canDownload;\n const canShare = currentImage?.canShare ?? true;\n const showShareButton = !meta?.broken && canShare;\n\n const handleShareClick = async () => {\n if (!currentImage || !navigator.share) {\n return;\n }\n\n const title = currentImage.name ?? new Date().toISOString().split('T')[0];\n const url = currentImage.src;\n\n try {\n if (isVideo(url)) {\n // Если видео — всегда делим ссылку\n await navigator.share({\n title,\n url,\n text: 'Видео',\n });\n\n return;\n }\n\n // Попробуем скачать изображение\n const response = await fetch(url, { mode: 'cors' });\n const blob = await response.blob();\n\n const file = new File([blob], `${title}.png`, {\n type: blob.type,\n lastModified: Date.now(),\n });\n\n const shareData: ShareData = {\n files: [file],\n title,\n text: 'Картинка',\n };\n\n // Попробуем поделиться файлом\n if (navigator.canShare?.(shareData) && response.ok) {\n await navigator.share(shareData);\n } else {\n // Fallback: делимся только ссылкой\n await navigator.share({\n title,\n text: 'Картинка',\n url,\n });\n }\n } catch {\n await navigator.share({\n title,\n url,\n });\n }\n };\n\n return (\n <div\n className={cn(styles.headerMobile, {\n [styles.video]: isVideo(currentImage?.src),\n [styles.hide]: hideNavigation,\n })}\n >\n <Buttons.BackArrow onClick={onClose} />\n <TypographyText\n className={styles.description}\n tag='div'\n view='component-primary'\n color='static-primary-light'\n >\n {description}\n </TypographyText>\n <div className={styles.rightButtons}>\n {customButton && (\n <Buttons.CustomButton {...customButton} dataTestId={TestIds.CUSTOM_BUTTON} />\n )}\n {showDownloadButton && (\n <Buttons.Download\n href={currentImage?.src}\n download={currentImage?.name}\n dataTestId={TestIds.DOWNLOAD_BUTTON}\n />\n )}\n {showShareButton && <Buttons.Share onClick={handleShareClick} />}\n </div>\n </div>\n );\n};\n"],"names":["Buttons.BackArrow","Buttons.CustomButton","Buttons.Download","Buttons.Share"],"mapp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QAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA;AAC9B,YAAA,YAAY,KACT,KAAC,CAAA,aAAA,CAAAC,YAAoB,EAAA,EAAA,GAAK,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,aAAa,GAAI,CAChF;YACA,kBAAkB,KACf,KAAA,CAAA,aAAA,CAACC,QAAgB,EACb,EAAA,IAAI,EAAE,YAAY,EAAE,GAAG,EACvB,QAAQ,EAAE,YAAY,EAAE,IAAI,EAC5B,UAAU,EAAE,OAAO,CAAC,eAAe,EAAA,CACrC,CACL;AACA,YAAA,eAAe,IAAI,KAAA,CAAA,aAAA,CAACC,KAAa,EAAA,EAAC,OAAO,EAAE,gBAAgB,EAAA,CAAI,CAC9D,CACJ;AAEd;;;;"}
|
package/moderncssm/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type SwiperCore from 'swiper';
|
|
2
|
-
import { type GalleryImage, type ImageMeta } from './types';
|
|
2
|
+
import { type GalleryCustomButton, type GalleryImage, type ImageMeta } from './types';
|
|
3
3
|
export type GalleryContext = {
|
|
4
4
|
view: 'desktop' | 'mobile';
|
|
5
5
|
singleSlide: boolean;
|
|
@@ -25,5 +25,6 @@ export type GalleryContext = {
|
|
|
25
25
|
setCurrentSlideIndex?: (index: number) => void;
|
|
26
26
|
getCurrentImage: () => GalleryImage | undefined;
|
|
27
27
|
getCurrentImageMeta: () => ImageMeta | undefined;
|
|
28
|
+
customButton?: GalleryCustomButton;
|
|
28
29
|
};
|
|
29
30
|
export declare const GalleryContext: import("react").Context<GalleryContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport type SwiperCore from 'swiper';\n\nimport { type GalleryImage, type ImageMeta } from './types';\n\nexport type GalleryContext = {\n view: 'desktop' | 'mobile';\n singleSlide: boolean;\n currentSlideIndex: number;\n images: GalleryImage[];\n imagesMeta: ImageMeta[];\n fullScreen: boolean;\n mutedVideo: boolean;\n playingVideo: boolean;\n hideNavigation: boolean;\n setHideNavigation: (hideNavigation: boolean) => void;\n initialSlide: number;\n setFullScreen: (fullScreen: boolean) => void;\n setMutedVideo: (muteVideo: boolean) => void;\n setPlayingVideo: (playingVideo: boolean) => void;\n setImageMeta: (meta: ImageMeta, index: number) => void;\n slideTo: (index: number) => void;\n slideNext: () => void;\n slidePrev: () => void;\n getSwiper: () => SwiperCore | undefined;\n setSwiper: (swiper: SwiperCore) => void;\n onClose: () => void;\n setCurrentSlideIndex?: (index: number) => void;\n getCurrentImage: () => GalleryImage | undefined;\n getCurrentImageMeta: () => ImageMeta | undefined;\n};\n\nconst mockFn = () => undefined;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const GalleryContext = createContext<GalleryContext>({\n view: 'desktop',\n singleSlide: false,\n currentSlideIndex: 0,\n images: [],\n imagesMeta: [],\n fullScreen: false,\n mutedVideo: false,\n playingVideo: false,\n hideNavigation: false,\n setHideNavigation: mockFn,\n setMutedVideo: mockFn,\n setPlayingVideo: mockFn,\n initialSlide: 0,\n setFullScreen: mockFn,\n setImageMeta: mockFn,\n slideTo: mockFn,\n slideNext: mockFn,\n slidePrev: mockFn,\n getSwiper: mockFn,\n setSwiper: mockFn,\n onClose: mockFn,\n setCurrentSlideIndex: mockFn,\n getCurrentImage: mockFn,\n getCurrentImageMeta: mockFn,\n});\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport type SwiperCore from 'swiper';\n\nimport { type GalleryCustomButton, type GalleryImage, type ImageMeta } from './types';\n\nexport type GalleryContext = {\n view: 'desktop' | 'mobile';\n singleSlide: boolean;\n currentSlideIndex: number;\n images: GalleryImage[];\n imagesMeta: ImageMeta[];\n fullScreen: boolean;\n mutedVideo: boolean;\n playingVideo: boolean;\n hideNavigation: boolean;\n setHideNavigation: (hideNavigation: boolean) => void;\n initialSlide: number;\n setFullScreen: (fullScreen: boolean) => void;\n setMutedVideo: (muteVideo: boolean) => void;\n setPlayingVideo: (playingVideo: boolean) => void;\n setImageMeta: (meta: ImageMeta, index: number) => void;\n slideTo: (index: number) => void;\n slideNext: () => void;\n slidePrev: () => void;\n getSwiper: () => SwiperCore | undefined;\n setSwiper: (swiper: SwiperCore) => void;\n onClose: () => void;\n setCurrentSlideIndex?: (index: number) => void;\n getCurrentImage: () => GalleryImage | undefined;\n getCurrentImageMeta: () => ImageMeta | undefined;\n customButton?: GalleryCustomButton;\n};\n\nconst mockFn = () => undefined;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const GalleryContext = createContext<GalleryContext>({\n view: 'desktop',\n singleSlide: false,\n currentSlideIndex: 0,\n images: [],\n imagesMeta: [],\n fullScreen: false,\n mutedVideo: false,\n playingVideo: false,\n hideNavigation: false,\n setHideNavigation: mockFn,\n setMutedVideo: mockFn,\n setPlayingVideo: mockFn,\n initialSlide: 0,\n setFullScreen: mockFn,\n setImageMeta: mockFn,\n slideTo: mockFn,\n slideNext: mockFn,\n slidePrev: mockFn,\n getSwiper: mockFn,\n setSwiper: mockFn,\n onClose: mockFn,\n setCurrentSlideIndex: mockFn,\n getCurrentImage: mockFn,\n getCurrentImageMeta: mockFn,\n});\n"],"names":[],"mappings":";;AAiCA,MAAM,MAAM,GAAG,MAAM,SAAS;AAE9B;AACO,MAAM,cAAc,GAAG,aAAa,CAAiB;AACxD,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,iBAAiB,EAAE,CAAC;AACpB,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,YAAY,EAAE,KAAK;AACnB,IAAA,cAAc,EAAE,KAAK;AACrB,IAAA,iBAAiB,EAAE,MAAM;AACzB,IAAA,aAAa,EAAE,MAAM;AACrB,IAAA,eAAe,EAAE,MAAM;AACvB,IAAA,YAAY,EAAE,CAAC;AACf,IAAA,aAAa,EAAE,MAAM;AACrB,IAAA,YAAY,EAAE,MAAM;AACpB,IAAA,OAAO,EAAE,MAAM;AACf,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,OAAO,EAAE,MAAM;AACf,IAAA,oBAAoB,EAAE,MAAM;AAC5B,IAAA,eAAe,EAAE,MAAM;AACvB,IAAA,mBAAmB,EAAE,MAAM;AAC9B,CAAA;;;;"}
|
package/moderncssm/index.d.ts
CHANGED
package/moderncssm/types.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type MouseEvent, type RefObject } from 'react';
|
|
2
|
+
import { type IconButtonProps } from '@alfalab/core-components-icon-button/moderncssm';
|
|
3
|
+
export type GalleryCustomButton = {
|
|
4
|
+
text: string;
|
|
5
|
+
icon: IconButtonProps['icon'];
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
};
|
|
2
8
|
export type TBottomButton = {
|
|
3
9
|
text: string;
|
|
4
10
|
onClick: (e: MouseEvent) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../src/utils/constants.ts"],"sourcesContent":["export const TestIds = {\n ACTIVE_IMAGE: 'active-image',\n PREV_SLIDE_BUTTON: 'prev-slide-button',\n NEXT_SLIDE_BUTTON: 'next-slide-button',\n CLOSE_BUTTON: 'close-button',\n FULLSCREEN_BUTTON: 'fullscreen-button',\n EXIT_FULLSCREEN_BUTTON: 'exit-fullscreen-button',\n DOWNLOAD_BUTTON: 'download-button',\n NAVIGATION_BAR: 'navigation-bar',\n MUTE_BUTTON: 'mute-button',\n UNMUTE_BUTTON: 'unmute-button',\n};\n"],"names":[],"mappings":"AAAa,MAAA,OAAO,GAAG;AACnB,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,sBAAsB,EAAE,wBAAwB;AAChD,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,aAAa,EAAE,eAAe;;;;;"}
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../src/utils/constants.ts"],"sourcesContent":["export const TestIds = {\n ACTIVE_IMAGE: 'active-image',\n PREV_SLIDE_BUTTON: 'prev-slide-button',\n NEXT_SLIDE_BUTTON: 'next-slide-button',\n CLOSE_BUTTON: 'close-button',\n FULLSCREEN_BUTTON: 'fullscreen-button',\n EXIT_FULLSCREEN_BUTTON: 'exit-fullscreen-button',\n DOWNLOAD_BUTTON: 'download-button',\n NAVIGATION_BAR: 'navigation-bar',\n MUTE_BUTTON: 'mute-button',\n UNMUTE_BUTTON: 'unmute-button',\n CUSTOM_BUTTON: 'custom-button',\n};\n"],"names":[],"mappings":"AAAa,MAAA,OAAO,GAAG;AACnB,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,sBAAsB,EAAE,wBAAwB;AAChD,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,aAAa,EAAE,eAAe;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-gallery",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0-alfasans",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"build": "rollup -c ../../tools/rollup/rollup.config.mjs --silent"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@alfalab/core-components-base-modal": "
|
|
17
|
-
"@alfalab/core-components-button": "
|
|
18
|
-
"@alfalab/core-components-icon-button": "
|
|
19
|
-
"@alfalab/core-components-icon-view": "
|
|
20
|
-
"@alfalab/core-components-mq": "
|
|
21
|
-
"@alfalab/core-components-shared": "
|
|
22
|
-
"@alfalab/core-components-spinner": "
|
|
23
|
-
"@alfalab/core-components-tooltip": "
|
|
24
|
-
"@alfalab/core-components-typography": "
|
|
16
|
+
"@alfalab/core-components-base-modal": "7.1.8-alfasans",
|
|
17
|
+
"@alfalab/core-components-button": "13.2.2-alfasans",
|
|
18
|
+
"@alfalab/core-components-icon-button": "8.0.10-alfasans",
|
|
19
|
+
"@alfalab/core-components-icon-view": "5.0.4-alfasans",
|
|
20
|
+
"@alfalab/core-components-mq": "6.0.7-alfasans",
|
|
21
|
+
"@alfalab/core-components-shared": "2.2.3-alfasans",
|
|
22
|
+
"@alfalab/core-components-spinner": "6.0.7-alfasans",
|
|
23
|
+
"@alfalab/core-components-tooltip": "9.0.18-alfasans",
|
|
24
|
+
"@alfalab/core-components-typography": "6.0.10-alfasans",
|
|
25
25
|
"@alfalab/hooks": "^1.17.0",
|
|
26
26
|
"@alfalab/icons-glyph": "^2.260.0",
|
|
27
27
|
"classnames": "^2.5.1",
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
"access": "public",
|
|
39
39
|
"directory": "dist"
|
|
40
40
|
},
|
|
41
|
-
"themesVersion": "15.2.1",
|
|
42
|
-
"varsVersion": "11.2.1"
|
|
41
|
+
"themesVersion": "15.2.1-alfasans",
|
|
42
|
+
"varsVersion": "11.2.1-alfasans"
|
|
43
43
|
}
|
package/src/Component.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import { Subtitles } from './components/subtitles';
|
|
|
11
11
|
import { Header, HeaderMobile, ImageViewer, InfoBar, NavigationBar } from './components';
|
|
12
12
|
import { SWIPE_THRESHOLD } from './constants';
|
|
13
13
|
import { GalleryContext } from './context';
|
|
14
|
-
import { type GalleryImage, type ImageMeta } from './types';
|
|
14
|
+
import { type GalleryCustomButton, type GalleryImage, type ImageMeta } from './types';
|
|
15
15
|
|
|
16
16
|
import styles from './index.module.css';
|
|
17
17
|
|
|
@@ -57,6 +57,11 @@ export type GalleryProps = {
|
|
|
57
57
|
* Дополнительный класс для попапа
|
|
58
58
|
*/
|
|
59
59
|
popupClassName?: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Дополнительная кнопка в шапке галереи
|
|
63
|
+
*/
|
|
64
|
+
customButton?: GalleryCustomButton;
|
|
60
65
|
};
|
|
61
66
|
|
|
62
67
|
const DEFAULT_FULL_SCREEN = false;
|
|
@@ -75,6 +80,7 @@ export const Gallery: FC<GalleryProps> = ({
|
|
|
75
80
|
onClose,
|
|
76
81
|
onSlideIndexChange,
|
|
77
82
|
popupClassName,
|
|
83
|
+
customButton,
|
|
78
84
|
}) => {
|
|
79
85
|
const currentSlideIndexState = useState(initialSlide);
|
|
80
86
|
const uncontrolled = slideIndex === undefined;
|
|
@@ -323,6 +329,7 @@ export const Gallery: FC<GalleryProps> = ({
|
|
|
323
329
|
setCurrentSlideIndex,
|
|
324
330
|
getCurrentImage: () => images[currentSlideIndex],
|
|
325
331
|
getCurrentImageMeta: () => imagesMeta[currentSlideIndex],
|
|
332
|
+
customButton,
|
|
326
333
|
};
|
|
327
334
|
|
|
328
335
|
return (
|
|
@@ -15,6 +15,7 @@ import { ShareMIcon } from '@alfalab/icons-glyph/ShareMIcon';
|
|
|
15
15
|
import { SoundCrossMIcon } from '@alfalab/icons-glyph/SoundCrossMIcon';
|
|
16
16
|
import { SoundMIcon } from '@alfalab/icons-glyph/SoundMIcon';
|
|
17
17
|
|
|
18
|
+
import { type GalleryCustomButton } from '../../types';
|
|
18
19
|
import { downloadFile, isVideo } from '../../utils';
|
|
19
20
|
|
|
20
21
|
import styles from './index.module.css';
|
|
@@ -24,6 +25,8 @@ type Props = Omit<IconButtonProps, 'icon' | 'colors'> & {
|
|
|
24
25
|
download?: string | boolean;
|
|
25
26
|
};
|
|
26
27
|
|
|
28
|
+
type CustomButtonProps = GalleryCustomButton & Props;
|
|
29
|
+
|
|
27
30
|
export const Fullscreen: FC<Props> = ({ buttonRef, ...restProps }) => {
|
|
28
31
|
const isDesktop = useIsDesktop();
|
|
29
32
|
|
|
@@ -248,6 +251,27 @@ export const Share: FC<Props> = (props) => {
|
|
|
248
251
|
);
|
|
249
252
|
};
|
|
250
253
|
|
|
254
|
+
export const CustomButton: FC<CustomButtonProps> = ({ text, icon, ...restProps }) => {
|
|
255
|
+
const isDesktop = useIsDesktop();
|
|
256
|
+
|
|
257
|
+
const iconButton = (
|
|
258
|
+
<IconButton {...restProps} icon={icon} aria-label={text} className={styles.iconButton} />
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
return isDesktop ? (
|
|
262
|
+
<TooltipDesktop
|
|
263
|
+
trigger='hover'
|
|
264
|
+
position='bottom'
|
|
265
|
+
content={text}
|
|
266
|
+
fallbackPlacements={['bottom-end']}
|
|
267
|
+
>
|
|
268
|
+
{iconButton}
|
|
269
|
+
</TooltipDesktop>
|
|
270
|
+
) : (
|
|
271
|
+
iconButton
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
|
|
251
275
|
export const Exit: FC<Props> = (props) => (
|
|
252
276
|
<IconButton {...props} icon={CrossMIcon} aria-label='Закрыть' className={styles.iconButton} />
|
|
253
277
|
);
|
|
@@ -19,6 +19,7 @@ export const Header: FC = () => {
|
|
|
19
19
|
onClose,
|
|
20
20
|
mutedVideo,
|
|
21
21
|
setMutedVideo,
|
|
22
|
+
customButton,
|
|
22
23
|
} = useContext(GalleryContext);
|
|
23
24
|
|
|
24
25
|
const currentImage = getCurrentImage();
|
|
@@ -97,6 +98,10 @@ export const Header: FC = () => {
|
|
|
97
98
|
/>
|
|
98
99
|
)}
|
|
99
100
|
|
|
101
|
+
{customButton && (
|
|
102
|
+
<Buttons.CustomButton {...customButton} dataTestId={TestIds.CUSTOM_BUTTON} />
|
|
103
|
+
)}
|
|
104
|
+
|
|
100
105
|
<Buttons.Exit onClick={onClose} dataTestId={TestIds.CLOSE_BUTTON} />
|
|
101
106
|
</div>
|
|
102
107
|
</div>
|
|
@@ -17,6 +17,7 @@ export const HeaderMobile = () => {
|
|
|
17
17
|
getCurrentImage,
|
|
18
18
|
getCurrentImageMeta,
|
|
19
19
|
hideNavigation,
|
|
20
|
+
customButton,
|
|
20
21
|
} = useContext(GalleryContext);
|
|
21
22
|
|
|
22
23
|
const currentImage = getCurrentImage();
|
|
@@ -100,6 +101,9 @@ export const HeaderMobile = () => {
|
|
|
100
101
|
{description}
|
|
101
102
|
</TypographyText>
|
|
102
103
|
<div className={styles.rightButtons}>
|
|
104
|
+
{customButton && (
|
|
105
|
+
<Buttons.CustomButton {...customButton} dataTestId={TestIds.CUSTOM_BUTTON} />
|
|
106
|
+
)}
|
|
103
107
|
{showDownloadButton && (
|
|
104
108
|
<Buttons.Download
|
|
105
109
|
href={currentImage?.src}
|
package/src/context.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
import type SwiperCore from 'swiper';
|
|
3
3
|
|
|
4
|
-
import { type GalleryImage, type ImageMeta } from './types';
|
|
4
|
+
import { type GalleryCustomButton, type GalleryImage, type ImageMeta } from './types';
|
|
5
5
|
|
|
6
6
|
export type GalleryContext = {
|
|
7
7
|
view: 'desktop' | 'mobile';
|
|
@@ -28,6 +28,7 @@ export type GalleryContext = {
|
|
|
28
28
|
setCurrentSlideIndex?: (index: number) => void;
|
|
29
29
|
getCurrentImage: () => GalleryImage | undefined;
|
|
30
30
|
getCurrentImageMeta: () => ImageMeta | undefined;
|
|
31
|
+
customButton?: GalleryCustomButton;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
const mockFn = () => undefined;
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { type MouseEvent, type RefObject } from 'react';
|
|
2
2
|
|
|
3
|
+
import { type IconButtonProps } from '@alfalab/core-components-icon-button';
|
|
4
|
+
|
|
5
|
+
export type GalleryCustomButton = {
|
|
6
|
+
text: string;
|
|
7
|
+
icon: IconButtonProps['icon'];
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
3
11
|
export type TBottomButton = {
|
|
4
12
|
text: string;
|
|
5
13
|
onClick: (e: MouseEvent) => void;
|
package/src/utils/constants.ts
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type MouseEvent, type RefObject } from 'react';
|
|
2
|
+
import { type IconButtonProps } from '@alfalab/core-components-icon-button';
|
|
3
|
+
export type GalleryCustomButton = {
|
|
4
|
+
text: string;
|
|
5
|
+
icon: IconButtonProps['icon'];
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
};
|
|
2
8
|
export type TBottomButton = {
|
|
3
9
|
text: string;
|
|
4
10
|
onClick: (e: MouseEvent) => void;
|
package/utils/constants.d.ts
CHANGED