@tecsinapse/cortex-react 1.14.0-beta.0 → 1.14.0-beta.2
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.
|
@@ -8,9 +8,11 @@ var Button = require('../Button.js');
|
|
|
8
8
|
var io = require('react-icons/io');
|
|
9
9
|
var CarouselItem = require('./CarouselItem.js');
|
|
10
10
|
var useEmblaCarousel = require('embla-carousel-react');
|
|
11
|
+
var Autoplay = require('embla-carousel-autoplay');
|
|
11
12
|
|
|
12
|
-
const Carousel = ({ images }) => {
|
|
13
|
-
const
|
|
13
|
+
const Carousel = ({ images, autoScroll }) => {
|
|
14
|
+
const plugins = autoScroll ? [Autoplay()] : [];
|
|
15
|
+
const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true }, plugins);
|
|
14
16
|
const itemsCarousel = images.map((imageProp, i) => ({
|
|
15
17
|
id: `${imageProp.alt}-${i}`,
|
|
16
18
|
renderItem: /* @__PURE__ */ jsxRuntime.jsx(CarouselItem.CarouselItem, { item: imageProp })
|
|
@@ -24,7 +26,7 @@ const Carousel = ({ images }) => {
|
|
|
24
26
|
React.useEffect(() => {
|
|
25
27
|
emblaApi?.reInit();
|
|
26
28
|
}, [emblaApi, images.length]);
|
|
27
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden w-
|
|
29
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden w-full relative", ref: emblaRef, children: [
|
|
28
30
|
/* @__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
31
|
itemsCarousel.length > 1 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
30
32
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -32,7 +34,7 @@ const Carousel = ({ images }) => {
|
|
|
32
34
|
{
|
|
33
35
|
type: "button",
|
|
34
36
|
"data-testid": "button-carousel-prev",
|
|
35
|
-
className: "z-
|
|
37
|
+
className: "z-absolute absolute left-deca top-[50%] transform -translate-y-[50%] p-centi flex",
|
|
36
38
|
size: "square",
|
|
37
39
|
onClick: slideToPrevItem,
|
|
38
40
|
children: /* @__PURE__ */ jsxRuntime.jsx(io.IoIosArrowBack, {})
|
|
@@ -44,7 +46,7 @@ const Carousel = ({ images }) => {
|
|
|
44
46
|
type: "button",
|
|
45
47
|
"data-testid": "button-carousel-next",
|
|
46
48
|
size: "square",
|
|
47
|
-
className: "z-
|
|
49
|
+
className: "z-absolute absolute right-deca top-[50%] transform -translate-y-[50%] p-centi flex",
|
|
48
50
|
onClick: slideToNextItem,
|
|
49
51
|
children: /* @__PURE__ */ jsxRuntime.jsx(io.IoIosArrowForward, {})
|
|
50
52
|
}
|
|
@@ -4,9 +4,11 @@ import { Button } from '../Button.js';
|
|
|
4
4
|
import { IoIosArrowBack, IoIosArrowForward } from 'react-icons/io';
|
|
5
5
|
import { CarouselItem } from './CarouselItem.js';
|
|
6
6
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
7
|
+
import Autoplay from 'embla-carousel-autoplay';
|
|
7
8
|
|
|
8
|
-
const Carousel = ({ images }) => {
|
|
9
|
-
const
|
|
9
|
+
const Carousel = ({ images, autoScroll }) => {
|
|
10
|
+
const plugins = autoScroll ? [Autoplay()] : [];
|
|
11
|
+
const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true }, plugins);
|
|
10
12
|
const itemsCarousel = images.map((imageProp, i) => ({
|
|
11
13
|
id: `${imageProp.alt}-${i}`,
|
|
12
14
|
renderItem: /* @__PURE__ */ jsx(CarouselItem, { item: imageProp })
|
|
@@ -20,7 +22,7 @@ const Carousel = ({ images }) => {
|
|
|
20
22
|
useEffect(() => {
|
|
21
23
|
emblaApi?.reInit();
|
|
22
24
|
}, [emblaApi, images.length]);
|
|
23
|
-
return /* @__PURE__ */ jsxs("div", { className: "overflow-hidden w-
|
|
25
|
+
return /* @__PURE__ */ jsxs("div", { className: "overflow-hidden w-full relative", ref: emblaRef, children: [
|
|
24
26
|
/* @__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
27
|
itemsCarousel.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
28
|
/* @__PURE__ */ jsx(
|
|
@@ -28,7 +30,7 @@ const Carousel = ({ images }) => {
|
|
|
28
30
|
{
|
|
29
31
|
type: "button",
|
|
30
32
|
"data-testid": "button-carousel-prev",
|
|
31
|
-
className: "z-
|
|
33
|
+
className: "z-absolute absolute left-deca top-[50%] transform -translate-y-[50%] p-centi flex",
|
|
32
34
|
size: "square",
|
|
33
35
|
onClick: slideToPrevItem,
|
|
34
36
|
children: /* @__PURE__ */ jsx(IoIosArrowBack, {})
|
|
@@ -40,7 +42,7 @@ const Carousel = ({ images }) => {
|
|
|
40
42
|
type: "button",
|
|
41
43
|
"data-testid": "button-carousel-next",
|
|
42
44
|
size: "square",
|
|
43
|
-
className: "z-
|
|
45
|
+
className: "z-absolute absolute right-deca top-[50%] transform -translate-y-[50%] p-centi flex",
|
|
44
46
|
onClick: slideToNextItem,
|
|
45
47
|
children: /* @__PURE__ */ jsx(IoIosArrowForward, {})
|
|
46
48
|
}
|
|
@@ -17,6 +17,7 @@ export type ImageCarousel = {
|
|
|
17
17
|
};
|
|
18
18
|
export interface CarouselProps {
|
|
19
19
|
images: ImageCarousel[];
|
|
20
|
+
autoScroll?: boolean;
|
|
20
21
|
}
|
|
21
|
-
export declare const Carousel: ({ images }: CarouselProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const Carousel: ({ images, autoScroll }: CarouselProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
23
|
export default Carousel;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.14.0-beta.
|
|
3
|
+
"version": "1.14.0-beta.2",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@tecsinapse/cortex-core": "1.1.3",
|
|
24
24
|
"clsx": "2.1.1",
|
|
25
25
|
"currency.js": "2.0.4",
|
|
26
|
+
"embla-carousel-autoplay": "^8.0.0",
|
|
26
27
|
"embla-carousel-react": "^8.6.0",
|
|
27
28
|
"react-aria": "3.38.1",
|
|
28
29
|
"react-dropzone": "14.3.8",
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"react-icons": ">=5.2.0",
|
|
48
49
|
"tailwind": ">=3.3.0"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "09a0296670858e486b1626094f4fd22dbcf9ff13"
|
|
51
52
|
}
|