UNPKG

design-react-kit

Version:

Componenti React per Bootstrap 5

1 lines 7.67 kB
{"version":3,"sources":["../../src/Carousel/Carousel.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport classNames from 'classnames';\n\nimport {Splide, SplideProps} from '@splidejs/react-splide'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst CONFIG_DEFAULT: any = {\n slideFocus: false,\n rewind: true,\n perMove: 1,\n i18n: {\n prev: 'Slide precedente',\n next: 'Slide successiva',\n first: 'Vai alla prima slide',\n last: 'Vai all’ultima slide',\n slideX: 'Vai alla slide %s',\n pageX: 'Vai a pagina %s',\n play: 'Attiva autoplay',\n pause: 'Pausa autoplay',\n carousel: 'Carosello',\n select: 'Seleziona una slide da mostrare',\n slide: 'slide',\n slideLabel: '%s di %s',\n },\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst CONFIGS: any= {\n 'landscape-three-cols': {\n type: 'slide',\n perPage: 3,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: false,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n 992: {\n perPage: 2,\n gap: 24,\n padding: { left: 40, right: 40 },\n arrows: false,\n },\n },\n },\n 'landscape-three-cols-arrows': {\n type: 'slide',\n perPage: 3,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: true,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 24,\n padding: { left: 40, right: 40 },\n arrows: true,\n },\n 992: {\n perPage: 2,\n gap: 24,\n padding: { left: 40, right: 40 },\n arrows: true,\n },\n },\n },\n 'big-image': {\n type: 'loop',\n perPage: 1,\n gap: 48,\n padding: { left: 320, right: 320 },\n arrows: false,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 0,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n 992: {\n perPage: 1,\n gap: 24,\n padding: { left: 160, right: 160 },\n arrows: false,\n },\n },\n },\n 'standard-image': {\n type: 'loop',\n perPage: 3,\n gap: 24,\n padding: { left: 48, right: 48 },\n arrows: false,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 24,\n padding: { left: 40, right: 40 },\n arrows: false,\n },\n 992: {\n perPage: 2,\n gap: 24,\n padding: { left: 48, right: 48 },\n arrows: false,\n },\n },\n },\n 'landscape': {\n type: 'slide',\n perPage: 1,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: false,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n 992: {\n perPage: 1,\n gap: 24,\n padding: { left: 24, right: 24 },\n arrows: false,\n },\n },\n },\n 'calendar-wrapper': {\n type: 'slide',\n perPage: 4,\n gap: 0,\n padding: { left: 0, right: 0 },\n arrows: false,\n breakpoints: {\n 560: {\n perPage: 1,\n gap: 0,\n padding: { left: 24, right: 24 },\n arrows: false,\n },\n 768: {\n perPage: 2,\n gap: 0,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n 992: {\n perPage: 3,\n gap: 0,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n },\n },\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst EXTRA_CLASSES: any= {\n 'landscape-three-cols': [\n 'it-carousel-landscape-abstract-three-cols'\n ],\n 'landscape-three-cols-arrows': [\n 'it-carousel-landscape-abstract-three-cols-arrow-visible'\n ],\n 'big-image': [\n 'it-carousel-landscape-abstract-three-cols',\n 'it-full-carousel',\n 'it-big-img'\n ],\n 'standard-image': [\n 'it-carousel-landscape-abstract-three-cols',\n 'it-full-carousel',\n 'it-standard-image'\n ],\n 'landscape': [\n 'it-carousel-landscape-abstract'\n ],\n 'calendar-wrapper': [\n 'it-calendar-wrapper'\n ]\n}\n\nexport interface CarouselProps extends SplideProps {\n type: string;\n children?: React.ReactNode;\n}\n\n// Splide wrapper\nexport const Carousel: FC<CarouselProps> = ({\n className = '',\n type,\n children,\n ...attributes\n}) => {\n let conf = Object.assign({}, CONFIG_DEFAULT)\n if (['big-image', 'standard-image'].includes(type)){\n conf = Object.assign({}, conf, CONFIGS['landscape-three-cols'])\n }\n conf = Object.assign({}, conf, CONFIGS[type])\n return <Splide\n {...attributes}\n className={classNames('it-carousel-wrapper', className, ...EXTRA_CLASSES[type])}\n options={conf}>{children}</Splide>;\n};\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,sBAC1BC,EAAuB,2BAEvBC,EAAkC,kCAG5BC,EAAsB,CAC1B,WAAY,GACZ,OAAQ,GACR,QAAS,EACT,KAAM,CACJ,KAAM,mBACN,KAAM,mBACN,MAAO,uBACP,KAAM,4BACN,OAAQ,oBACR,MAAO,kBACP,KAAM,kBACN,MAAO,iBACP,SAAU,YACV,OAAQ,kCACR,MAAO,QACP,WAAY,UACd,CACF,EAGMC,EAAc,CAClB,uBAAwB,CACtB,KAAM,QACN,QAAS,EACT,IAAK,GACL,QAAS,CAAE,KAAM,EAAG,MAAO,CAAE,EAC7B,OAAQ,GACR,YAAa,CACX,IAAK,CACH,QAAS,EACT,IAAK,GACL,QAAS,CAAE,KAAM,EAAG,MAAO,CAAE,EAC7B,OAAQ,EACV,EACA,IAAK,CACH,QAAS,EACT,IAAK,GACL,QAAS,CAAE,KAAM,GAAI,MAAO,EAAG,EAC/B,OAAQ,EACV,CACF,CACF,EACA,8BAA+B,CAC7B,KAAM,QACN,QAAS,EACT,IAAK,GACL,QAAS,CAAE,KAAM,EAAG,MAAO,CAAE,EAC7B,OAAQ,GACR,YAAa,CACX,IAAK,CACH,QAAS,EACT,IAAK,GACL,QAAS,CAAE,KAAM,GAAI,MAAO,EAAG,EAC/B,OAAQ,EACV,EACA,IAAK,CACH,QAAS,EACT,IAAK,GACL,QAAS,CAAE,KAAM,GAAI,MAAO,EAAG,EAC/B,OAAQ,EACV,CACF,CACF,EACA,YAAa,CACX,KAAM,OACN,QAAS,EACT,IAAK,GAC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O,CAAE,EAC7B,OAAQ,EACV,CACF,CACF,CACF,EAGMC,EAAoB,CACxB,uBAAwB,CACtB,2CACF,EACA,8BAA+B,CAC7B,yDACF,EACA,YAAa,CACX,4CACA,mBACA,YACF,EACA,iBAAkB,CAChB,4CACA,mBACA,mBACF,EACA,UAAa,CACX,gCACF,EACA,mBAAoB,CAClB,qBACF,CACF,EAQaP,EAA8B,CAAC,CAC1C,UAAAQ,EAAY,GACZ,KAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAAM,CACJ,IAAIC,EAAO,OAAO,OAAO,CAAC,EAAGP,CAAc,EAC3C,MAAI,CAAC,YAAa,gBAAgB,EAAE,SAASI,CAAI,IAC/CG,EAAO,OAAO,OAAO,CAAC,EAAGA,EAAMN,EAAQ,sBAAsB,CAAC,GAEhEM,EAAO,OAAO,OAAO,CAAC,EAAGA,EAAMN,EAAQG,CAAI,CAAC,EACrC,EAAAI,QAAA,cAAC,UACL,GAAGF,EACJ,aAAW,EAAAG,SAAW,sBAAuBN,EAAW,GAAGD,EAAcE,CAAI,CAAC,EAC9E,QAASG,GAAOF,CAAS,CAC7B","names":["Carousel_exports","__export","Carousel","__toCommonJS","import_react","import_classnames","import_react_splide","CONFIG_DEFAULT","CONFIGS","EXTRA_CLASSES","className","type","children","attributes","conf","React","classNames"]}