@atom-learning/components 6.17.0 → 7.0.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.
- package/dist/components/carousel/Carousel.d.ts +33 -25
- package/dist/components/carousel/Carousel.js +84 -14
- package/dist/components/carousel/Carousel.js.map +1 -1
- package/dist/components/carousel/CarouselArrows.d.ts +5 -6
- package/dist/components/carousel/CarouselArrows.js +25 -9
- package/dist/components/carousel/CarouselArrows.js.map +1 -1
- package/dist/components/carousel/CarouselPagination.d.ts +2 -3
- package/dist/components/carousel/CarouselPagination.js +31 -17
- package/dist/components/carousel/CarouselPagination.js.map +1 -1
- package/dist/components/carousel/CarouselSlide.d.ts +2 -4
- package/dist/components/carousel/CarouselSlide.js +14 -5
- package/dist/components/carousel/CarouselSlide.js.map +1 -1
- package/dist/components/carousel/CarouselSlider.d.ts +10 -4
- package/dist/components/carousel/CarouselSlider.js +22 -6
- package/dist/components/carousel/CarouselSlider.js.map +1 -1
- package/dist/docgen.json +1 -1
- package/dist/index.cjs.js +170 -47
- package/dist/index.cjs.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
import
|
|
1
|
+
import useEmblaCarousel from 'embla-carousel-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
|
|
3
|
+
type EmblaApi = ReturnType<typeof useEmblaCarousel>[1];
|
|
4
4
|
type CarouselProps = {
|
|
5
|
-
|
|
6
|
-
slideWidth: number;
|
|
7
|
-
numSlides: number;
|
|
5
|
+
currentSlide?: number;
|
|
8
6
|
};
|
|
9
7
|
export declare const CarouselComponent: {
|
|
10
|
-
({ children,
|
|
8
|
+
({ children, currentSlide, ...props }: React.PropsWithChildren<CarouselProps & React.HTMLAttributes<HTMLDivElement>>): React.JSX.Element;
|
|
11
9
|
displayName: string;
|
|
12
10
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export declare const useCarousel: () => {
|
|
12
|
+
currentSlide: number;
|
|
13
|
+
emblaRef: React.RefCallback<HTMLDivElement>;
|
|
14
|
+
emblaApi: EmblaApi;
|
|
15
|
+
selectedIndex: number;
|
|
16
|
+
scrollSnaps: number[];
|
|
17
|
+
canScrollPrev: boolean;
|
|
18
|
+
canScrollNext: boolean;
|
|
19
|
+
scrollPrev: () => void;
|
|
20
|
+
scrollNext: () => void;
|
|
21
|
+
scrollTo: (index: number) => void;
|
|
22
|
+
};
|
|
18
23
|
export declare const Carousel: {
|
|
19
|
-
({ children,
|
|
24
|
+
({ children, currentSlide, ...props }: React.PropsWithChildren<CarouselProps & React.HTMLAttributes<HTMLDivElement>>): React.JSX.Element;
|
|
20
25
|
displayName: string;
|
|
21
26
|
} & {
|
|
22
|
-
ArrowNext: (props:
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
ArrowPrevious: (props: Omit<React.ComponentProps<React.ForwardRefExoticComponent<Omit<import("pure-react-carousel").ButtonBackProps & React.RefAttributes<React.Component<import("pure-react-carousel").ButtonBackProps, any, any>>, never> & {
|
|
27
|
+
ArrowNext: (props: React.ComponentProps<React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
28
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
29
|
+
}, never> & {
|
|
26
30
|
as?: React.ElementType;
|
|
27
|
-
}
|
|
28
|
-
|
|
31
|
+
}>>) => React.JSX.Element;
|
|
32
|
+
ArrowPrevious: (props: React.ComponentProps<React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
33
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
34
|
+
}, never> & {
|
|
29
35
|
as?: React.ElementType;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
}>>) => React.JSX.Element;
|
|
37
|
+
Pagination: ({ className, ...rest }: React.HTMLAttributes<HTMLDivElement>) => React.JSX.Element;
|
|
38
|
+
Slide: ({ children, className, index, ...rest }: React.PropsWithChildren<{
|
|
33
39
|
index: number;
|
|
34
|
-
}) => React.JSX.Element;
|
|
35
|
-
Slider: ({ children, className, overflow, ...rest }:
|
|
36
|
-
|
|
40
|
+
} & React.HTMLAttributes<HTMLDivElement>>) => React.JSX.Element;
|
|
41
|
+
Slider: ({ children, className, gap, overflow, tabIndex, ...rest }: {
|
|
42
|
+
children?: React.ReactNode;
|
|
37
43
|
className?: string;
|
|
44
|
+
gap?: import("./CarouselSlider").TCarouselSlideGap;
|
|
38
45
|
overflow?: boolean;
|
|
39
|
-
|
|
46
|
+
tabIndex?: number;
|
|
47
|
+
}) => React.JSX.Element;
|
|
40
48
|
};
|
|
41
49
|
export {};
|
|
@@ -1,22 +1,92 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cn } from "../../styled.js";
|
|
2
2
|
import { CarouselArrowNext, CarouselArrowPrevious } from "./CarouselArrows.js";
|
|
3
3
|
import { CarouselPagination } from "./CarouselPagination.js";
|
|
4
|
-
import { CarouselSlide } from "./CarouselSlide.js";
|
|
5
4
|
import { CarouselSlider } from "./CarouselSlider.js";
|
|
5
|
+
import { CarouselSlide } from "./CarouselSlide.js";
|
|
6
6
|
import * as React$1 from "react";
|
|
7
|
-
import
|
|
7
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
8
8
|
//#region src/components/carousel/Carousel.tsx
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
var CarouselContext = React$1.createContext(null);
|
|
10
|
+
var CarouselComponent = ({ children, currentSlide = 0, ...props }) => {
|
|
11
|
+
const [emblaRef, emblaApi] = useEmblaCarousel({
|
|
12
|
+
startIndex: currentSlide,
|
|
13
|
+
align: "center"
|
|
14
|
+
});
|
|
15
|
+
const [selectedIndex, setSelectedIndex] = React$1.useState(currentSlide);
|
|
16
|
+
const [scrollSnaps, setScrollSnaps] = React$1.useState([]);
|
|
17
|
+
const [canScrollPrev, setCanScrollPrev] = React$1.useState(false);
|
|
18
|
+
const [canScrollNext, setCanScrollNext] = React$1.useState(false);
|
|
19
|
+
const scrollPrev = React$1.useCallback(() => {
|
|
20
|
+
emblaApi?.scrollPrev();
|
|
21
|
+
}, [emblaApi]);
|
|
22
|
+
const scrollNext = React$1.useCallback(() => {
|
|
23
|
+
emblaApi?.scrollNext();
|
|
24
|
+
}, [emblaApi]);
|
|
25
|
+
const scrollTo = React$1.useCallback((index) => {
|
|
26
|
+
emblaApi?.scrollTo(index);
|
|
27
|
+
}, [emblaApi]);
|
|
28
|
+
const onSelect = React$1.useCallback(() => {
|
|
29
|
+
if (!emblaApi) return;
|
|
30
|
+
setSelectedIndex(emblaApi.selectedScrollSnap());
|
|
31
|
+
setCanScrollPrev(emblaApi.canScrollPrev());
|
|
32
|
+
setCanScrollNext(emblaApi.canScrollNext());
|
|
33
|
+
}, [emblaApi]);
|
|
34
|
+
const onInit = React$1.useCallback(() => {
|
|
35
|
+
if (!emblaApi) return;
|
|
36
|
+
setScrollSnaps(emblaApi.scrollSnapList());
|
|
37
|
+
}, [emblaApi]);
|
|
38
|
+
React$1.useEffect(() => {
|
|
39
|
+
if (!emblaApi) return;
|
|
40
|
+
onInit();
|
|
41
|
+
onSelect();
|
|
42
|
+
emblaApi.on("reInit", onInit);
|
|
43
|
+
emblaApi.on("reInit", onSelect);
|
|
44
|
+
emblaApi.on("select", onSelect);
|
|
45
|
+
return () => {
|
|
46
|
+
emblaApi.off("reInit", onInit);
|
|
47
|
+
emblaApi.off("reInit", onSelect);
|
|
48
|
+
emblaApi.off("select", onSelect);
|
|
49
|
+
};
|
|
50
|
+
}, [
|
|
51
|
+
emblaApi,
|
|
52
|
+
onInit,
|
|
53
|
+
onSelect
|
|
54
|
+
]);
|
|
55
|
+
const contextValue = React$1.useMemo(() => ({
|
|
56
|
+
emblaRef,
|
|
57
|
+
emblaApi,
|
|
58
|
+
selectedIndex,
|
|
59
|
+
scrollSnaps,
|
|
60
|
+
canScrollPrev,
|
|
61
|
+
canScrollNext,
|
|
62
|
+
scrollPrev,
|
|
63
|
+
scrollNext,
|
|
64
|
+
scrollTo
|
|
65
|
+
}), [
|
|
66
|
+
emblaRef,
|
|
67
|
+
emblaApi,
|
|
68
|
+
selectedIndex,
|
|
69
|
+
scrollSnaps,
|
|
70
|
+
canScrollPrev,
|
|
71
|
+
canScrollNext,
|
|
72
|
+
scrollPrev,
|
|
73
|
+
scrollNext,
|
|
74
|
+
scrollTo
|
|
75
|
+
]);
|
|
76
|
+
const { className, ...rest } = props;
|
|
77
|
+
return /* @__PURE__ */ React$1.createElement("div", {
|
|
78
|
+
className: cn("relative", "w-full", className),
|
|
79
|
+
...rest
|
|
80
|
+
}, /* @__PURE__ */ React$1.createElement(CarouselContext.Provider, { value: contextValue }, children));
|
|
81
|
+
};
|
|
82
|
+
var useCarousel = () => {
|
|
83
|
+
const context = React$1.useContext(CarouselContext);
|
|
84
|
+
if (!context) throw new Error("useCarousel must be used within a Carousel");
|
|
85
|
+
return {
|
|
86
|
+
...context,
|
|
87
|
+
currentSlide: context.selectedIndex
|
|
88
|
+
};
|
|
89
|
+
};
|
|
20
90
|
var Carousel = Object.assign(CarouselComponent, {
|
|
21
91
|
ArrowNext: CarouselArrowNext,
|
|
22
92
|
ArrowPrevious: CarouselArrowPrevious,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.js","names":[],"sources":["../../../src/components/carousel/Carousel.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Carousel.js","names":[],"sources":["../../../src/components/carousel/Carousel.tsx"],"sourcesContent":["import useEmblaCarousel from 'embla-carousel-react'\nimport * as React from 'react'\n\nimport { cn } from '~/styled'\n\nimport { CarouselArrowNext, CarouselArrowPrevious } from './CarouselArrows'\nimport { CarouselPagination } from './CarouselPagination'\nimport { CarouselSlide } from './CarouselSlide'\nimport { CarouselSlider } from './CarouselSlider'\n\ntype EmblaApi = ReturnType<typeof useEmblaCarousel>[1]\n\ntype CarouselContextValue = {\n emblaRef: React.RefCallback<HTMLDivElement>\n emblaApi: EmblaApi\n selectedIndex: number\n scrollSnaps: number[]\n canScrollPrev: boolean\n canScrollNext: boolean\n scrollPrev: () => void\n scrollNext: () => void\n scrollTo: (index: number) => void\n}\n\nconst CarouselContext = React.createContext<CarouselContextValue | null>(null)\n\ntype CarouselProps = {\n currentSlide?: number\n}\n\nexport const CarouselComponent = ({\n children,\n currentSlide = 0,\n ...props\n}: React.PropsWithChildren<\n CarouselProps & React.HTMLAttributes<HTMLDivElement>\n>) => {\n const [emblaRef, emblaApi] = useEmblaCarousel({\n startIndex: currentSlide,\n align: 'center'\n })\n\n const [selectedIndex, setSelectedIndex] = React.useState(currentSlide)\n const [scrollSnaps, setScrollSnaps] = React.useState<number[]>([])\n const [canScrollPrev, setCanScrollPrev] = React.useState(false)\n const [canScrollNext, setCanScrollNext] = React.useState(false)\n\n const scrollPrev = React.useCallback(() => {\n emblaApi?.scrollPrev()\n }, [emblaApi])\n\n const scrollNext = React.useCallback(() => {\n emblaApi?.scrollNext()\n }, [emblaApi])\n\n const scrollTo = React.useCallback(\n (index: number) => {\n emblaApi?.scrollTo(index)\n },\n [emblaApi]\n )\n\n const onSelect = React.useCallback(() => {\n if (!emblaApi) return\n setSelectedIndex(emblaApi.selectedScrollSnap())\n setCanScrollPrev(emblaApi.canScrollPrev())\n setCanScrollNext(emblaApi.canScrollNext())\n }, [emblaApi])\n\n const onInit = React.useCallback(() => {\n if (!emblaApi) return\n setScrollSnaps(emblaApi.scrollSnapList())\n }, [emblaApi])\n\n React.useEffect(() => {\n if (!emblaApi) return\n\n onInit()\n onSelect()\n\n emblaApi.on('reInit', onInit)\n emblaApi.on('reInit', onSelect)\n emblaApi.on('select', onSelect)\n\n return () => {\n emblaApi.off('reInit', onInit)\n emblaApi.off('reInit', onSelect)\n emblaApi.off('select', onSelect)\n }\n }, [emblaApi, onInit, onSelect])\n\n const contextValue = React.useMemo<CarouselContextValue>(\n () => ({\n emblaRef,\n emblaApi,\n selectedIndex,\n scrollSnaps,\n canScrollPrev,\n canScrollNext,\n scrollPrev,\n scrollNext,\n scrollTo\n }),\n [\n emblaRef,\n emblaApi,\n selectedIndex,\n scrollSnaps,\n canScrollPrev,\n canScrollNext,\n scrollPrev,\n scrollNext,\n scrollTo\n ]\n )\n\n const { className, ...rest } = props\n\n return (\n <div className={cn('relative', 'w-full', className)} {...rest}>\n <CarouselContext.Provider value={contextValue}>\n {children}\n </CarouselContext.Provider>\n </div>\n )\n}\n\nexport const useCarousel = () => {\n const context = React.useContext(CarouselContext)\n if (!context) {\n throw new Error('useCarousel must be used within a Carousel')\n }\n\n return {\n ...context,\n // Alias for backward compatibility\n currentSlide: context.selectedIndex\n }\n}\n\nexport const Carousel = Object.assign(CarouselComponent, {\n ArrowNext: CarouselArrowNext,\n ArrowPrevious: CarouselArrowPrevious,\n Pagination: CarouselPagination,\n Slide: CarouselSlide,\n Slider: CarouselSlider\n})\n\nCarouselComponent.displayName = 'Carousel'\n"],"mappings":";;;;;;;;AAwBA,IAAM,kBAAkB,QAAM,cAA2C,KAAK;AAM9E,IAAa,qBAAqB,EAChC,UACA,eAAe,GACf,GAAG,YAGC;CACJ,MAAM,CAAC,UAAU,YAAY,iBAAiB;EAC5C,YAAY;EACZ,OAAO;EACR,CAAC;CAEF,MAAM,CAAC,eAAe,oBAAoB,QAAM,SAAS,aAAa;CACtE,MAAM,CAAC,aAAa,kBAAkB,QAAM,SAAmB,EAAE,CAAC;CAClE,MAAM,CAAC,eAAe,oBAAoB,QAAM,SAAS,MAAM;CAC/D,MAAM,CAAC,eAAe,oBAAoB,QAAM,SAAS,MAAM;CAE/D,MAAM,aAAa,QAAM,kBAAkB;AACzC,YAAU,YAAY;IACrB,CAAC,SAAS,CAAC;CAEd,MAAM,aAAa,QAAM,kBAAkB;AACzC,YAAU,YAAY;IACrB,CAAC,SAAS,CAAC;CAEd,MAAM,WAAW,QAAM,aACpB,UAAkB;AACjB,YAAU,SAAS,MAAM;IAE3B,CAAC,SAAS,CACX;CAED,MAAM,WAAW,QAAM,kBAAkB;AACvC,MAAI,CAAC,SAAU;AACf,mBAAiB,SAAS,oBAAoB,CAAC;AAC/C,mBAAiB,SAAS,eAAe,CAAC;AAC1C,mBAAiB,SAAS,eAAe,CAAC;IACzC,CAAC,SAAS,CAAC;CAEd,MAAM,SAAS,QAAM,kBAAkB;AACrC,MAAI,CAAC,SAAU;AACf,iBAAe,SAAS,gBAAgB,CAAC;IACxC,CAAC,SAAS,CAAC;AAEd,SAAM,gBAAgB;AACpB,MAAI,CAAC,SAAU;AAEf,UAAQ;AACR,YAAU;AAEV,WAAS,GAAG,UAAU,OAAO;AAC7B,WAAS,GAAG,UAAU,SAAS;AAC/B,WAAS,GAAG,UAAU,SAAS;AAE/B,eAAa;AACX,YAAS,IAAI,UAAU,OAAO;AAC9B,YAAS,IAAI,UAAU,SAAS;AAChC,YAAS,IAAI,UAAU,SAAS;;IAEjC;EAAC;EAAU;EAAQ;EAAS,CAAC;CAEhC,MAAM,eAAe,QAAM,eAClB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,GACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAED,MAAM,EAAE,WAAW,GAAG,SAAS;AAE/B,QACE,wBAAA,cAAC,OAAD;EAAK,WAAW,GAAG,YAAY,UAAU,UAAU;EAAE,GAAI;EAInD,EAHJ,wBAAA,cAAC,gBAAgB,UAAjB,EAA0B,OAAO,cAEN,EADxB,SACwB,CACvB;;AAIV,IAAa,oBAAoB;CAC/B,MAAM,UAAU,QAAM,WAAW,gBAAgB;AACjD,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,6CAA6C;AAG/D,QAAO;EACL,GAAG;EAEH,cAAc,QAAQ;EACvB;;AAGH,IAAa,WAAW,OAAO,OAAO,mBAAmB;CACvD,WAAW;CACX,eAAe;CACf,YAAY;CACZ,OAAO;CACP,QAAQ;CACT,CAAC;AAEF,kBAAkB,cAAc"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const
|
|
2
|
+
declare const ArrowButton: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
3
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
4
|
+
}, never> & {
|
|
3
5
|
as?: React.ElementType;
|
|
4
6
|
}>;
|
|
5
|
-
declare const
|
|
6
|
-
|
|
7
|
-
}>;
|
|
8
|
-
export declare const CarouselArrowPrevious: (props: Omit<React.ComponentProps<typeof StyledButtonBack>, "children">) => React.JSX.Element;
|
|
9
|
-
export declare const CarouselArrowNext: (props: Omit<React.ComponentProps<typeof StyledButtonNext>, "children">) => React.JSX.Element;
|
|
7
|
+
export declare const CarouselArrowPrevious: (props: React.ComponentProps<typeof ArrowButton>) => React.JSX.Element;
|
|
8
|
+
export declare const CarouselArrowNext: (props: React.ComponentProps<typeof ArrowButton>) => React.JSX.Element;
|
|
10
9
|
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { styled } from "../../styled.js";
|
|
2
2
|
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { useCarousel } from "./Carousel.js";
|
|
3
4
|
import * as React$1 from "react";
|
|
4
5
|
import { ChevronLeft, ChevronRight } from "@atom-learning/icons";
|
|
5
|
-
import { ButtonBack, ButtonNext } from "pure-react-carousel";
|
|
6
6
|
//#region src/components/carousel/CarouselArrows.tsx
|
|
7
|
-
var
|
|
7
|
+
var ArrowButton = styled("button", { base: [
|
|
8
8
|
"items-center",
|
|
9
|
-
"bg-[unset]",
|
|
10
9
|
"text-primary-800",
|
|
11
10
|
"cursor-pointer",
|
|
12
11
|
"flex",
|
|
@@ -19,12 +18,29 @@ var buttonStyles = [
|
|
|
19
18
|
"ease-in-out",
|
|
20
19
|
"hover:text-primary-900",
|
|
21
20
|
"active:text-primary-1000",
|
|
22
|
-
"disabled:text-grey-200"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
"disabled:text-grey-200",
|
|
22
|
+
"disabled:cursor-not-allowed"
|
|
23
|
+
] });
|
|
24
|
+
var CarouselArrowPrevious = (props) => {
|
|
25
|
+
const { scrollPrev, canScrollPrev } = useCarousel();
|
|
26
|
+
return /* @__PURE__ */ React$1.createElement(ArrowButton, {
|
|
27
|
+
type: "button",
|
|
28
|
+
onClick: scrollPrev,
|
|
29
|
+
disabled: !canScrollPrev,
|
|
30
|
+
"aria-label": "Previous slide",
|
|
31
|
+
...props
|
|
32
|
+
}, /* @__PURE__ */ React$1.createElement(Icon, { is: ChevronLeft }));
|
|
33
|
+
};
|
|
34
|
+
var CarouselArrowNext = (props) => {
|
|
35
|
+
const { scrollNext, canScrollNext } = useCarousel();
|
|
36
|
+
return /* @__PURE__ */ React$1.createElement(ArrowButton, {
|
|
37
|
+
type: "button",
|
|
38
|
+
onClick: scrollNext,
|
|
39
|
+
disabled: !canScrollNext,
|
|
40
|
+
"aria-label": "Next slide",
|
|
41
|
+
...props
|
|
42
|
+
}, /* @__PURE__ */ React$1.createElement(Icon, { is: ChevronRight }));
|
|
43
|
+
};
|
|
28
44
|
//#endregion
|
|
29
45
|
export { CarouselArrowNext, CarouselArrowPrevious };
|
|
30
46
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselArrows.js","names":[],"sources":["../../../src/components/carousel/CarouselArrows.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from '@atom-learning/icons'\nimport
|
|
1
|
+
{"version":3,"file":"CarouselArrows.js","names":[],"sources":["../../../src/components/carousel/CarouselArrows.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from '@atom-learning/icons'\nimport * as React from 'react'\n\nimport { Icon } from '~/components/icon/Icon'\nimport { styled } from '~/styled'\n\nimport { useCarousel } from './Carousel'\n\nconst ArrowButton = styled('button', {\n base: [\n 'items-center',\n 'text-primary-800',\n 'cursor-pointer',\n 'flex',\n 'justify-center',\n 'size-12',\n 'top-1/2',\n '-translate-y-1/2',\n 'transition-colors',\n 'duration-150',\n 'ease-in-out',\n 'hover:text-primary-900',\n 'active:text-primary-1000',\n 'disabled:text-grey-200',\n 'disabled:cursor-not-allowed'\n ]\n})\n\nexport const CarouselArrowPrevious = (\n props: React.ComponentProps<typeof ArrowButton>\n) => {\n const { scrollPrev, canScrollPrev } = useCarousel()\n\n return (\n <ArrowButton\n type=\"button\"\n onClick={scrollPrev}\n disabled={!canScrollPrev}\n aria-label=\"Previous slide\"\n {...props}\n >\n <Icon is={ChevronLeft} />\n </ArrowButton>\n )\n}\n\nexport const CarouselArrowNext = (\n props: React.ComponentProps<typeof ArrowButton>\n) => {\n const { scrollNext, canScrollNext } = useCarousel()\n\n return (\n <ArrowButton\n type=\"button\"\n onClick={scrollNext}\n disabled={!canScrollNext}\n aria-label=\"Next slide\"\n {...props}\n >\n <Icon is={ChevronRight} />\n </ArrowButton>\n )\n}\n"],"mappings":";;;;;;AAQA,IAAM,cAAc,OAAO,UAAU,EACnC,MAAM;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EACF,CAAC;AAEF,IAAa,yBACX,UACG;CACH,MAAM,EAAE,YAAY,kBAAkB,aAAa;AAEnD,QACE,wBAAA,cAAC,aAAD;EACE,MAAK;EACL,SAAS;EACT,UAAU,CAAC;EACX,cAAW;EACX,GAAI;EAGQ,EADZ,wBAAA,cAAC,MAAD,EAAM,IAAI,aAAe,CAAA,CACb;;AAIlB,IAAa,qBACX,UACG;CACH,MAAM,EAAE,YAAY,kBAAkB,aAAa;AAEnD,QACE,wBAAA,cAAC,aAAD;EACE,MAAK;EACL,SAAS;EACT,UAAU,CAAC;EACX,cAAW;EACX,GAAI;EAGQ,EADZ,wBAAA,cAAC,MAAD,EAAM,IAAI,cAAgB,CAAA,CACd"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}>;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const CarouselPagination: ({ className, ...rest }: React.HTMLAttributes<HTMLDivElement>) => React.JSX.Element;
|
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
import { styled } from "../../styled.js";
|
|
2
|
-
import {
|
|
1
|
+
import { cn, styled } from "../../styled.js";
|
|
2
|
+
import { useCarousel } from "./Carousel.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
3
4
|
//#region src/components/carousel/CarouselPagination.tsx
|
|
4
|
-
var
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"[&_button]:transition-all"
|
|
5
|
+
var Dot = styled("button", { base: [
|
|
6
|
+
"bg-grey-600",
|
|
7
|
+
"cursor-pointer",
|
|
8
|
+
"duration-100",
|
|
9
|
+
"ease-in",
|
|
10
|
+
"focus:bg-primary-900",
|
|
11
|
+
"hover:bg-primary-900",
|
|
12
|
+
"mx-1",
|
|
13
|
+
"p-1",
|
|
14
|
+
"rounded-full",
|
|
15
|
+
"size-3",
|
|
16
|
+
"transition-all",
|
|
17
|
+
"disabled:bg-primary-800",
|
|
18
|
+
"disabled:cursor-default"
|
|
19
19
|
] });
|
|
20
|
+
var CarouselPagination = ({ className, ...rest }) => {
|
|
21
|
+
const { scrollSnaps, selectedIndex, scrollTo } = useCarousel();
|
|
22
|
+
const dots = Array.from({ length: scrollSnaps.length }, (_, i) => i);
|
|
23
|
+
return /* @__PURE__ */ React$1.createElement("div", {
|
|
24
|
+
className: cn("flex", "justify-center", className),
|
|
25
|
+
...rest
|
|
26
|
+
}, dots.map((index) => /* @__PURE__ */ React$1.createElement(Dot, {
|
|
27
|
+
key: index,
|
|
28
|
+
type: "button",
|
|
29
|
+
onClick: () => scrollTo(index),
|
|
30
|
+
disabled: index === selectedIndex,
|
|
31
|
+
"aria-label": "slide dot"
|
|
32
|
+
})));
|
|
33
|
+
};
|
|
20
34
|
//#endregion
|
|
21
35
|
export { CarouselPagination };
|
|
22
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselPagination.js","names":[],"sources":["../../../src/components/carousel/CarouselPagination.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"CarouselPagination.js","names":[],"sources":["../../../src/components/carousel/CarouselPagination.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { cn, styled } from '~/styled'\n\nimport { useCarousel } from './Carousel'\n\nconst Dot = styled('button', {\n base: [\n 'bg-grey-600',\n 'cursor-pointer',\n 'duration-100',\n 'ease-in',\n 'focus:bg-primary-900',\n 'hover:bg-primary-900',\n 'mx-1',\n 'p-1',\n 'rounded-full',\n 'size-3',\n 'transition-all',\n 'disabled:bg-primary-800',\n 'disabled:cursor-default'\n ]\n})\n\nexport const CarouselPagination = ({\n className,\n ...rest\n}: React.HTMLAttributes<HTMLDivElement>) => {\n const { scrollSnaps, selectedIndex, scrollTo } = useCarousel()\n\n const dots = Array.from({ length: scrollSnaps.length }, (_, i) => i)\n\n return (\n <div className={cn('flex', 'justify-center', className)} {...rest}>\n {dots.map((index) => (\n <Dot\n key={index}\n type=\"button\"\n onClick={() => scrollTo(index)}\n disabled={index === selectedIndex}\n aria-label=\"slide dot\"\n />\n ))}\n </div>\n )\n}\n"],"mappings":";;;;AAMA,IAAM,MAAM,OAAO,UAAU,EAC3B,MAAM;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EACF,CAAC;AAEF,IAAa,sBAAsB,EACjC,WACA,GAAG,WACuC;CAC1C,MAAM,EAAE,aAAa,eAAe,aAAa,aAAa;CAE9D,MAAM,OAAO,MAAM,KAAK,EAAE,QAAQ,YAAY,QAAQ,GAAG,GAAG,MAAM,EAAE;AAEpE,QACE,wBAAA,cAAC,OAAD;EAAK,WAAW,GAAG,QAAQ,kBAAkB,UAAU;EAAE,GAAI;EAUvD,EATH,KAAK,KAAK,UACT,wBAAA,cAAC,KAAD;EACE,KAAK;EACL,MAAK;EACL,eAAe,SAAS,MAAM;EAC9B,UAAU,UAAU;EACpB,cAAW;EACX,CAAA,CACF,CACE"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Slide as BaseSlide } from 'pure-react-carousel';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
export declare const CarouselSlide: ({ children, ...
|
|
4
|
-
className?: string;
|
|
2
|
+
export declare const CarouselSlide: ({ children, className, index, ...rest }: React.PropsWithChildren<{
|
|
5
3
|
index: number;
|
|
6
|
-
}) => React.JSX.Element;
|
|
4
|
+
} & React.HTMLAttributes<HTMLDivElement>>) => React.JSX.Element;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { cn } from "../../styled.js";
|
|
2
|
+
import { CarouselSlideGapContext, toSlideGapClass } from "./CarouselSlider.js";
|
|
3
|
+
import { useCarousel } from "./Carousel.js";
|
|
1
4
|
import * as React$1 from "react";
|
|
2
|
-
import { Slide } from "pure-react-carousel";
|
|
3
5
|
//#region src/components/carousel/CarouselSlide.tsx
|
|
4
|
-
var CarouselSlide = ({ children, ...
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var CarouselSlide = ({ children, className, index, ...rest }) => {
|
|
7
|
+
const { selectedIndex } = useCarousel();
|
|
8
|
+
const gap = React$1.useContext(CarouselSlideGapContext);
|
|
9
|
+
const isSelected = selectedIndex === index;
|
|
10
|
+
return /* @__PURE__ */ React$1.createElement("div", {
|
|
11
|
+
role: "option",
|
|
12
|
+
"aria-selected": isSelected,
|
|
13
|
+
className: cn("min-w-0", "basis-full", "shrink-0", className),
|
|
14
|
+
...rest
|
|
15
|
+
}, /* @__PURE__ */ React$1.createElement("div", { className: cn("flex items-center justify-center", toSlideGapClass[gap]) }, children));
|
|
16
|
+
};
|
|
8
17
|
//#endregion
|
|
9
18
|
export { CarouselSlide };
|
|
10
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselSlide.js","names":[],"sources":["../../../src/components/carousel/CarouselSlide.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"CarouselSlide.js","names":[],"sources":["../../../src/components/carousel/CarouselSlide.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { cn } from '~/styled'\n\nimport { useCarousel } from './Carousel'\nimport { CarouselSlideGapContext, toSlideGapClass } from './CarouselSlider'\n\nexport const CarouselSlide = ({\n children,\n className,\n index,\n ...rest\n}: React.PropsWithChildren<\n { index: number } & React.HTMLAttributes<HTMLDivElement>\n>) => {\n const { selectedIndex } = useCarousel()\n const gap = React.useContext(CarouselSlideGapContext)\n const isSelected = selectedIndex === index\n\n return (\n <div\n role=\"option\"\n aria-selected={isSelected}\n // min-w-0 so basis-full wins over the content's min-content size and\n // the slide never outgrows the slider viewport\n className={cn('min-w-0', 'basis-full', 'shrink-0', className)}\n {...rest}\n >\n {/* padding to create the gap between slides; gap=\"none\" for full-bleed */}\n <div\n className={cn('flex items-center justify-center', toSlideGapClass[gap])}\n >\n {children}\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;AAOA,IAAa,iBAAiB,EAC5B,UACA,WACA,OACA,GAAG,WAGC;CACJ,MAAM,EAAE,kBAAkB,aAAa;CACvC,MAAM,MAAM,QAAM,WAAW,wBAAwB;CACrD,MAAM,aAAa,kBAAkB;AAErC,QACE,wBAAA,cAAC,OAAD;EACE,MAAK;EACL,iBAAe;EAGf,WAAW,GAAG,WAAW,cAAc,YAAY,UAAU;EAC7D,GAAI;EAQA,EALJ,wBAAA,cAAC,OAAD,EACE,WAAW,GAAG,oCAAoC,gBAAgB,KAAK,EAGnE,EADH,SACG,CACF"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { Slider as BaseSlider } from 'pure-react-carousel';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
export type TCarouselSlideGap = 'none' | 0 | 1 | 2 | 3 | 4;
|
|
3
|
+
export declare const toSlideGapClass: Record<TCarouselSlideGap, string>;
|
|
4
|
+
export declare const CarouselSlideGapContext: React.Context<TCarouselSlideGap>;
|
|
5
|
+
type CarouselSliderProps = {
|
|
6
|
+
children?: React.ReactNode;
|
|
5
7
|
className?: string;
|
|
8
|
+
gap?: TCarouselSlideGap;
|
|
6
9
|
overflow?: boolean;
|
|
7
|
-
|
|
10
|
+
tabIndex?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const CarouselSlider: ({ children, className, gap, overflow, tabIndex, ...rest }: CarouselSliderProps) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { cn } from "../../styled.js";
|
|
2
|
+
import { useCarousel } from "./Carousel.js";
|
|
2
3
|
import * as React$1 from "react";
|
|
3
|
-
import { Slider } from "pure-react-carousel";
|
|
4
4
|
//#region src/components/carousel/CarouselSlider.tsx
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var toSlideGapClass = {
|
|
6
|
+
none: "",
|
|
7
|
+
0: "px-0.5",
|
|
8
|
+
1: "px-1",
|
|
9
|
+
2: "px-2",
|
|
10
|
+
3: "px-3",
|
|
11
|
+
4: "px-4"
|
|
12
|
+
};
|
|
13
|
+
var CarouselSlideGapContext = React$1.createContext(3);
|
|
14
|
+
var CarouselSlider = ({ children, className, gap = 3, overflow, tabIndex = 0, ...rest }) => {
|
|
15
|
+
const { emblaRef } = useCarousel();
|
|
16
|
+
return /* @__PURE__ */ React$1.createElement("div", {
|
|
17
|
+
ref: emblaRef,
|
|
18
|
+
className: cn("ml-[50%]", "-translate-x-1/2", "cursor-grab", overflow ? "overflow-visible" : "overflow-hidden", className),
|
|
19
|
+
role: "listbox",
|
|
20
|
+
"aria-live": "polite",
|
|
21
|
+
tabIndex,
|
|
22
|
+
...rest
|
|
23
|
+
}, /* @__PURE__ */ React$1.createElement("div", { className: "flex" }, /* @__PURE__ */ React$1.createElement(CarouselSlideGapContext.Provider, { value: gap }, children)));
|
|
24
|
+
};
|
|
9
25
|
//#endregion
|
|
10
|
-
export { CarouselSlider };
|
|
26
|
+
export { CarouselSlideGapContext, CarouselSlider, toSlideGapClass };
|
|
11
27
|
|
|
12
28
|
//# sourceMappingURL=CarouselSlider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselSlider.js","names":[],"sources":["../../../src/components/carousel/CarouselSlider.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"CarouselSlider.js","names":[],"sources":["../../../src/components/carousel/CarouselSlider.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { cn } from '~/styled'\n\nimport { useCarousel } from './Carousel'\n\nexport type TCarouselSlideGap = 'none' | 0 | 1 | 2 | 3 | 4\n\n// Horizontal padding applied around each slide's content, on the same\n// spacing scale as Flex/ToggleGroup's gap. 'none' renders full-bleed slides.\nexport const toSlideGapClass: Record<TCarouselSlideGap, string> = {\n none: '',\n 0: 'px-0.5',\n 1: 'px-1',\n 2: 'px-2',\n 3: 'px-3',\n 4: 'px-4'\n}\n\n// Slides read the gap via context so it is configured once on the slider.\nexport const CarouselSlideGapContext = React.createContext<TCarouselSlideGap>(3)\n\ntype CarouselSliderProps = {\n children?: React.ReactNode\n className?: string\n gap?: TCarouselSlideGap\n overflow?: boolean\n tabIndex?: number\n}\n\nexport const CarouselSlider = ({\n children,\n className,\n gap = 3,\n overflow,\n tabIndex = 0,\n ...rest\n}: CarouselSliderProps) => {\n const { emblaRef } = useCarousel()\n\n return (\n <div\n ref={emblaRef}\n className={cn(\n 'ml-[50%]',\n '-translate-x-1/2',\n 'cursor-grab',\n overflow ? 'overflow-visible' : 'overflow-hidden',\n className\n )}\n role=\"listbox\"\n aria-live=\"polite\"\n tabIndex={tabIndex}\n {...rest}\n >\n <div className=\"flex\">\n <CarouselSlideGapContext.Provider value={gap}>\n {children}\n </CarouselSlideGapContext.Provider>\n </div>\n </div>\n )\n}\n"],"mappings":";;;;AAUA,IAAa,kBAAqD;CAChE,MAAM;CACN,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAGD,IAAa,0BAA0B,QAAM,cAAiC,EAAE;AAUhF,IAAa,kBAAkB,EAC7B,UACA,WACA,MAAM,GACN,UACA,WAAW,GACX,GAAG,WACsB;CACzB,MAAM,EAAE,aAAa,aAAa;AAElC,QACE,wBAAA,cAAC,OAAD;EACE,KAAK;EACL,WAAW,GACT,YACA,oBACA,eACA,WAAW,qBAAqB,mBAChC,UACD;EACD,MAAK;EACL,aAAU;EACA;EACV,GAAI;EAOA,EALJ,wBAAA,cAAC,OAAD,EAAK,WAAU,QAIT,EAHJ,wBAAA,cAAC,wBAAwB,UAAzB,EAAkC,OAAO,KAEN,EADhC,SACgC,CAC/B,CACF"}
|