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BtB,EAAMhB,aAAalB,KAAI,CAACC,EAAOmD,KAC9B,SAAC,KAAW,UACT5B,EAAgBvB,IADDmD,MAGpB,SAACnB,EAAiB,CAChBd,QAAS,IAAMe,EAAMf,QAAQqC,GAC7BhB,YAAaN,EAAMhB,aAAa5B,OAChCgD,kBAAmBkB,OAG3B","sources":["webpack://empori-base/./src/controls/ImageGallery.tsx","webpack://empori-base/./src/backoffice/controllers/common.ts","webpack://empori-base/./src/controls/ImageGalleryFullscreen.tsx"],"sourcesContent":["import { Swiper, Navigation, SwiperOptions, Autoplay } from 'swiper';\r\nimport { ImageGalleryModel } from '../empracoTypes';\r\nimport { ImageGalleryFullscreenWrapper } from './ImageGalleryFullscreen';\r\nimport { render } from '../main';\r\nimport ReactDOM from 'react-dom';\r\n\r\nexport default function ImageGallery(parent: HTMLDivElement | null, model: ImageGalleryModel) {\r\n if (!parent) {\r\n return;\r\n }\r\n\r\n const slides = model.imageGalleryEditorModel.slides;\r\n\r\n const options: SwiperOptions = {\r\n modules: [\r\n Navigation,\r\n Autoplay\r\n ],\r\n autoplay: model.autoplay ? { delay: model.delay } : false,\r\n lazy: true,\r\n loop: slides.length > 1,\r\n autoHeight: model.staticHeight === 0,\r\n navigation: {\r\n nextEl: '.swiper-button-next',\r\n prevEl: '.swiper-button-prev'\r\n },\r\n spaceBetween: 0\r\n };\r\n\r\n const swiper = new Swiper(parent, options);\r\n\r\n if (model.fullscreenEnabled) {\r\n const fsSlides = slides.map(slide => slide.image);\r\n\r\n if (!fsSlides) {\r\n return;\r\n }\r\n\r\n const fsTrigger = parent.querySelector('.empori-image-gallery-fullscreen-trigger');\r\n\r\n if (!fsTrigger) {\r\n return;\r\n }\r\n\r\n const fsEl = document.createElement('div');\r\n fsEl.classList.add('empori-fullscreen-image-gallery');\r\n document.body.appendChild(fsEl);\r\n\r\n const removeInnerContent = (activeIndex: number) => {\r\n swiper.slideToLoop(activeIndex);\r\n fsEl.classList.remove('visible');\r\n ReactDOM.unmountComponentAtNode(fsEl);\r\n };\r\n\r\n fsTrigger.addEventListener('click', e => {\r\n fsEl.classList.add('visible');\r\n render(\r\n , fsEl);\r\n });\r\n }\r\n return swiper;\r\n}","export interface EnumListItem {\r\n label: string;\r\n value: string;\r\n}\r\n\r\nexport interface MediaSelectionItem {\r\n name: string;\r\n id: number;\r\n udi: string;\r\n icon: string;\r\n trashed: boolean;\r\n key: string;\r\n parentId: number;\r\n alias: string;\r\n path: string;\r\n metaData: MediaSelectionMetaData;\r\n thumbnail: string;\r\n image: string;\r\n updateDate: string;\r\n filtered: boolean | null;\r\n $$hashKey: string;\r\n isFolder: boolean;\r\n width: number;\r\n height: number;\r\n aspectRatio: number;\r\n selectable: boolean;\r\n flexStyle: MediaSelectionFlexStyle;\r\n selected: boolean;\r\n altText?: string;\r\n}\r\n\r\ninterface MediaSelectionMetaData {\r\n ContentTypeAlias: string;\r\n UpdateDate: string;\r\n MediaPath: string;\r\n IsContainer: boolean;\r\n}\r\n\r\ninterface MediaSelectionFlexStyle {\r\n flex: string;\r\n 'max-width': string;\r\n 'min-width': string;\r\n 'min-height': string;\r\n}\r\n\r\nexport interface MediaPickerOutput {\r\n multiPicker: boolean;\r\n view: string;\r\n size: string;\r\n updatedMediaNodes: any[]; // TODO: Find out what this does contain\r\n infiniteMode: boolean;\r\n inFront: boolean;\r\n moveRight: boolean;\r\n level: number;\r\n styleIndex: number;\r\n animating: boolean;\r\n $$hashKey: string;\r\n selection: MediaSelectionItem[];\r\n title: string;\r\n}\r\n\r\nexport interface LinkPickerOutPut {\r\n target: LinkPickerTarget;\r\n}\r\n\r\nexport interface LinkPickerTarget {\r\n anchor: string;\r\n id: string;\r\n name: string;\r\n target: string;\r\n udi: string; // Umbraco reference\r\n url: string;\r\n}\r\n\r\nexport const isImage = (url: string) => {\r\n return /\\.(jpg|jpeg|png|webp|avif|gif|svg)$/.test(url);\r\n};\r\n\r\nexport const isVideo = (url: string) => {\r\n return /\\.(mp4|ogg|mov)$/.test(url);\r\n};","import * as React from 'react';\r\nimport { Swiper, SwiperSlide, useSwiper } from 'swiper/react';\r\nimport ReactDOM from 'react-dom';\r\nimport { isImage } from '../backoffice/controllers/common';\r\nimport { className } from '@empori/util';\r\n\r\nexport function FullscreenSlide(slide: string) {\r\n const isSlideImage = isImage(slide);\r\n\r\n return(\r\n
\r\n {!isSlideImage &&\r\n }\r\n
\r\n );\r\n}\r\n\r\ninterface ToobarProps {\r\n onClose: () => void;\r\n totalSlides: number;\r\n currentSlideIndex: number;\r\n}\r\n\r\nexport function FullscreenToolbar(props: ToobarProps) {\r\n const [ ready, getReady ] = React.useState(false);\r\n const swiper = useSwiper();\r\n const prevPossible = props.currentSlideIndex !== 0;\r\n const nextPossible = props.currentSlideIndex + 1 < props.totalSlides;\r\n\r\n // Only for a simple fade-in animation.\r\n React.useEffect(() => {\r\n setTimeout(() => {\r\n getReady(true);\r\n }, 500);\r\n }, []);\r\n\r\n return(\r\n
\r\n swiper.slidePrev()}>\r\n \r\n \r\n \r\n {`${props.currentSlideIndex + 1}/${props.totalSlides}`}\r\n \r\n \r\n swiper.slideNext()}>\r\n \r\n \r\n
\r\n );\r\n}\r\n\r\ninterface ImageGalleryFullscreenProps {\r\n slideImgUrls: string[];\r\n toggled: boolean;\r\n viewingIndex: number;\r\n open: () => void;\r\n close: () => void;\r\n setIndex: (index: number) => void;\r\n}\r\n\r\nexport function ImageGalleryFullscreen(props: ImageGalleryFullscreenProps) {\r\n const { toggled, slideImgUrls } = props;\r\n\r\n if (!toggled || !slideImgUrls) {\r\n return
props.open()}>\r\n \r\n
;\r\n }\r\n\r\n return(\r\n ReactDOM.createPortal(\r\n
\r\n props.setIndex(swiper.realIndex)}\r\n initialSlide={props.viewingIndex}>\r\n {slideImgUrls.map((slide, index) =>\r\n \r\n {FullscreenSlide(slide)}\r\n )}\r\n \r\n \r\n
, document.body\r\n )\r\n );\r\n}\r\n\r\ninterface ImageGalleryFullscreenWrapperProps {\r\n slideImgUrls: string[];\r\n onClose: (activeIndex: number) => void;\r\n activeIndex: number;\r\n}\r\n\r\nexport function ImageGalleryFullscreenWrapper(props: ImageGalleryFullscreenWrapperProps) {\r\n const [currentIndex, setCurrentIndex] = React.useState(props.activeIndex);\r\n\r\n return(\r\n setCurrentIndex(fsSwiper.realIndex)}\r\n initialSlide={currentIndex}>\r\n {props.slideImgUrls.map((slide, index) =>\r\n \r\n {FullscreenSlide(slide)}\r\n )}\r\n props.onClose(currentIndex)}\r\n totalSlides={props.slideImgUrls.length}\r\n currentSlideIndex={currentIndex} />\r\n \r\n );\r\n}"],"names":["ImageGallery","parent","model","slides","imageGalleryEditorModel","options","modules","autoplay","delay","lazy","loop","length","autoHeight","staticHeight","navigation","nextEl","prevEl","spaceBetween","swiper","fullscreenEnabled","fsSlides","map","slide","image","fsTrigger","querySelector","fsEl","document","createElement","classList","add","body","appendChild","removeInnerContent","activeIndex","slideToLoop","remove","addEventListener","e","slideImgUrls","onClose","realIndex","isImage","url","test","FullscreenSlide","isSlideImage","className","style","backgroundImage","backgroundColor","controls","src","type","FullscreenToolbar","props","ready","getReady","prevPossible","currentSlideIndex","nextPossible","totalSlides","setTimeout","disabled","onClick","slidePrev","slideNext","ImageGalleryFullscreen","toggled","onSlideChange","setIndex","initialSlide","viewingIndex","index","close","open","ImageGalleryFullscreenWrapper","currentIndex","setCurrentIndex","fsSwiper"],"sourceRoot":""}