@tecsinapse/cortex-react 1.13.9 → 1.14.0-beta.0

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.
@@ -1,29 +1,38 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var React = require('react');
4
7
  var Button = require('../Button.js');
5
- var reactSpringCarousel = require('react-spring-carousel');
6
8
  var io = require('react-icons/io');
7
9
  var CarouselItem = require('./CarouselItem.js');
10
+ var useEmblaCarousel = require('embla-carousel-react');
8
11
 
9
12
  const Carousel = ({ images }) => {
13
+ const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true });
10
14
  const itemsCarousel = images.map((imageProp, i) => ({
11
15
  id: `${imageProp.alt}-${i}`,
12
16
  renderItem: /* @__PURE__ */ jsxRuntime.jsx(CarouselItem.CarouselItem, { item: imageProp })
13
17
  }));
14
- const { carouselFragment, slideToNextItem, slideToPrevItem } = reactSpringCarousel.useSpringCarousel({
15
- withLoop: true,
16
- items: itemsCarousel
17
- });
18
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden w-fit relative", children: [
19
- carouselFragment,
20
- itemsCarousel.length > 1 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
18
+ const slideToPrevItem = React.useCallback(() => {
19
+ if (emblaApi) emblaApi.scrollPrev();
20
+ }, [emblaApi]);
21
+ const slideToNextItem = React.useCallback(() => {
22
+ if (emblaApi) emblaApi.scrollNext();
23
+ }, [emblaApi]);
24
+ React.useEffect(() => {
25
+ emblaApi?.reInit();
26
+ }, [emblaApi, images.length]);
27
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden w-fit relative", ref: emblaRef, children: [
28
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex", children: images.map((image, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-full flex-shrink-0 relative", children: /* @__PURE__ */ jsxRuntime.jsx(CarouselItem.CarouselItem, { item: image }) }, `${image.alt}-${i}`)) }),
29
+ itemsCarousel.length > 1 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
21
30
  /* @__PURE__ */ jsxRuntime.jsx(
22
31
  Button.Button,
23
32
  {
24
33
  type: "button",
25
34
  "data-testid": "button-carousel-prev",
26
- className: "z-absolute absolute left-deca top-[50%] transform -translate-y-[50%] p-centi hidden lg:flex",
35
+ className: "z-select absolute left-deca top-[50%] transform -translate-y-[50%] p-centi flex",
27
36
  size: "square",
28
37
  onClick: slideToPrevItem,
29
38
  children: /* @__PURE__ */ jsxRuntime.jsx(io.IoIosArrowBack, {})
@@ -35,13 +44,14 @@ const Carousel = ({ images }) => {
35
44
  type: "button",
36
45
  "data-testid": "button-carousel-next",
37
46
  size: "square",
38
- className: "z-absolute absolute right-deca top-[50%] transform -translate-y-[50%] p-centi hidden lg:flex",
47
+ className: "z-select absolute right-deca top-[50%] transform -translate-y-[50%] p-centi flex",
39
48
  onClick: slideToNextItem,
40
49
  children: /* @__PURE__ */ jsxRuntime.jsx(io.IoIosArrowForward, {})
41
50
  }
42
51
  )
43
- ] }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
52
+ ] })
44
53
  ] });
45
54
  };
46
55
 
47
56
  exports.Carousel = Carousel;
57
+ exports.default = Carousel;
@@ -1,27 +1,34 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useCallback, useEffect } from 'react';
2
3
  import { Button } from '../Button.js';
3
- import { useSpringCarousel } from 'react-spring-carousel';
4
4
  import { IoIosArrowBack, IoIosArrowForward } from 'react-icons/io';
5
5
  import { CarouselItem } from './CarouselItem.js';
6
+ import useEmblaCarousel from 'embla-carousel-react';
6
7
 
7
8
  const Carousel = ({ images }) => {
9
+ const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true });
8
10
  const itemsCarousel = images.map((imageProp, i) => ({
9
11
  id: `${imageProp.alt}-${i}`,
10
12
  renderItem: /* @__PURE__ */ jsx(CarouselItem, { item: imageProp })
11
13
  }));
12
- const { carouselFragment, slideToNextItem, slideToPrevItem } = useSpringCarousel({
13
- withLoop: true,
14
- items: itemsCarousel
15
- });
16
- return /* @__PURE__ */ jsxs("div", { className: "overflow-hidden w-fit relative", children: [
17
- carouselFragment,
18
- itemsCarousel.length > 1 ? /* @__PURE__ */ jsxs(Fragment, { children: [
14
+ const slideToPrevItem = useCallback(() => {
15
+ if (emblaApi) emblaApi.scrollPrev();
16
+ }, [emblaApi]);
17
+ const slideToNextItem = useCallback(() => {
18
+ if (emblaApi) emblaApi.scrollNext();
19
+ }, [emblaApi]);
20
+ useEffect(() => {
21
+ emblaApi?.reInit();
22
+ }, [emblaApi, images.length]);
23
+ return /* @__PURE__ */ jsxs("div", { className: "overflow-hidden w-fit relative", ref: emblaRef, children: [
24
+ /* @__PURE__ */ jsx("div", { className: "flex", children: images.map((image, i) => /* @__PURE__ */ jsx("div", { className: "min-w-full flex-shrink-0 relative", children: /* @__PURE__ */ jsx(CarouselItem, { item: image }) }, `${image.alt}-${i}`)) }),
25
+ itemsCarousel.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
19
26
  /* @__PURE__ */ jsx(
20
27
  Button,
21
28
  {
22
29
  type: "button",
23
30
  "data-testid": "button-carousel-prev",
24
- className: "z-absolute absolute left-deca top-[50%] transform -translate-y-[50%] p-centi hidden lg:flex",
31
+ className: "z-select absolute left-deca top-[50%] transform -translate-y-[50%] p-centi flex",
25
32
  size: "square",
26
33
  onClick: slideToPrevItem,
27
34
  children: /* @__PURE__ */ jsx(IoIosArrowBack, {})
@@ -33,13 +40,13 @@ const Carousel = ({ images }) => {
33
40
  type: "button",
34
41
  "data-testid": "button-carousel-next",
35
42
  size: "square",
36
- className: "z-absolute absolute right-deca top-[50%] transform -translate-y-[50%] p-centi hidden lg:flex",
43
+ className: "z-select absolute right-deca top-[50%] transform -translate-y-[50%] p-centi flex",
37
44
  onClick: slideToNextItem,
38
45
  children: /* @__PURE__ */ jsx(IoIosArrowForward, {})
39
46
  }
40
47
  )
41
- ] }) : /* @__PURE__ */ jsx(Fragment, {})
48
+ ] })
42
49
  ] });
43
50
  };
44
51
 
45
- export { Carousel };
52
+ export { Carousel, Carousel as default };
@@ -19,4 +19,4 @@ export interface CarouselProps {
19
19
  images: ImageCarousel[];
20
20
  }
21
21
  export declare const Carousel: ({ images }: CarouselProps) => import("react/jsx-runtime").JSX.Element;
22
- export {};
22
+ export default Carousel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-react",
3
- "version": "1.13.9",
3
+ "version": "1.14.0-beta.0",
4
4
  "description": "React components based in @tecsinapse/cortex-core",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
@@ -23,11 +23,11 @@
23
23
  "@tecsinapse/cortex-core": "1.1.3",
24
24
  "clsx": "2.1.1",
25
25
  "currency.js": "2.0.4",
26
+ "embla-carousel-react": "^8.6.0",
26
27
  "react-aria": "3.38.1",
27
28
  "react-dropzone": "14.3.8",
28
29
  "react-imask": "7.6.1",
29
30
  "react-spring": "9.7.5",
30
- "react-spring-carousel": "2.0.19",
31
31
  "react-stately": "3.36.1",
32
32
  "sonner": "1.7.3",
33
33
  "uuid": "11.1.0"
@@ -47,5 +47,5 @@
47
47
  "react-icons": ">=5.2.0",
48
48
  "tailwind": ">=3.3.0"
49
49
  },
50
- "gitHead": "f1146d1caa2209ad725a07dc1e89fd2d8093347e"
50
+ "gitHead": "c6c3c82ea4d5328849d1d80853defbbdd3c41601"
51
51
  }