@atom-learning/components 6.17.0-beta.0 → 6.17.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.
@@ -38,9 +38,10 @@ export declare const Carousel: {
38
38
  Slide: ({ children, className, index, ...rest }: React.PropsWithChildren<{
39
39
  index: number;
40
40
  } & React.HTMLAttributes<HTMLDivElement>>) => React.JSX.Element;
41
- Slider: ({ children, className, overflow, tabIndex, ...rest }: {
41
+ Slider: ({ children, className, gap, overflow, tabIndex, ...rest }: {
42
42
  children?: React.ReactNode;
43
43
  className?: string;
44
+ gap?: import("./CarouselSlider").TCarouselSlideGap;
44
45
  overflow?: boolean;
45
46
  tabIndex?: number;
46
47
  }) => React.JSX.Element;
@@ -1,8 +1,8 @@
1
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
7
  import useEmblaCarousel from "embla-carousel-react";
8
8
  //#region src/components/carousel/Carousel.tsx
@@ -1,16 +1,18 @@
1
1
  import { cn } from "../../styled.js";
2
+ import { CarouselSlideGapContext, toSlideGapClass } from "./CarouselSlider.js";
2
3
  import { useCarousel } from "./Carousel.js";
3
4
  import * as React$1 from "react";
4
5
  //#region src/components/carousel/CarouselSlide.tsx
5
6
  var CarouselSlide = ({ children, className, index, ...rest }) => {
6
7
  const { selectedIndex } = useCarousel();
8
+ const gap = React$1.useContext(CarouselSlideGapContext);
7
9
  const isSelected = selectedIndex === index;
8
10
  return /* @__PURE__ */ React$1.createElement("div", {
9
11
  role: "option",
10
12
  "aria-selected": isSelected,
11
- className: cn("basis-full", "shrink-0", className),
13
+ className: cn("min-w-0", "basis-full", "shrink-0", className),
12
14
  ...rest
13
- }, /* @__PURE__ */ React$1.createElement("div", { className: "grid place-items-center px-3" }, children));
15
+ }, /* @__PURE__ */ React$1.createElement("div", { className: cn("flex items-center justify-center", toSlideGapClass[gap]) }, children));
14
16
  };
15
17
  //#endregion
16
18
  export { CarouselSlide };
@@ -1 +1 @@
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'\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 isSelected = selectedIndex === index\n\n return (\n <div\n role=\"option\"\n aria-selected={isSelected}\n className={cn('basis-full', 'shrink-0', className)}\n {...rest}\n >\n {/* padding to create the gap between slides */}\n <div className=\"grid place-items-center px-3\">{children}</div>\n </div>\n )\n}\n"],"mappings":";;;;AAMA,IAAa,iBAAiB,EAC5B,UACA,WACA,OACA,GAAG,WAGC;CACJ,MAAM,EAAE,kBAAkB,aAAa;CACvC,MAAM,aAAa,kBAAkB;AAErC,QACE,wBAAA,cAAC,OAAD;EACE,MAAK;EACL,iBAAe;EACf,WAAW,GAAG,cAAc,YAAY,UAAU;EAClD,GAAI;EAIA,EADJ,wBAAA,cAAC,OAAD,EAAK,WAAU,gCAA+C,EAAf,SAAe,CAC1D"}
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,9 +1,13 @@
1
1
  import * as React from 'react';
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>;
2
5
  type CarouselSliderProps = {
3
6
  children?: React.ReactNode;
4
7
  className?: string;
8
+ gap?: TCarouselSlideGap;
5
9
  overflow?: boolean;
6
10
  tabIndex?: number;
7
11
  };
8
- export declare const CarouselSlider: ({ children, className, overflow, tabIndex, ...rest }: CarouselSliderProps) => React.JSX.Element;
12
+ export declare const CarouselSlider: ({ children, className, gap, overflow, tabIndex, ...rest }: CarouselSliderProps) => React.JSX.Element;
9
13
  export {};
@@ -2,7 +2,16 @@ import { cn } from "../../styled.js";
2
2
  import { useCarousel } from "./Carousel.js";
3
3
  import * as React$1 from "react";
4
4
  //#region src/components/carousel/CarouselSlider.tsx
5
- var CarouselSlider = ({ children, className, overflow, tabIndex = 0, ...rest }) => {
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 }) => {
6
15
  const { emblaRef } = useCarousel();
7
16
  return /* @__PURE__ */ React$1.createElement("div", {
8
17
  ref: emblaRef,
@@ -11,9 +20,9 @@ var CarouselSlider = ({ children, className, overflow, tabIndex = 0, ...rest })
11
20
  "aria-live": "polite",
12
21
  tabIndex,
13
22
  ...rest
14
- }, /* @__PURE__ */ React$1.createElement("div", { className: "flex" }, children));
23
+ }, /* @__PURE__ */ React$1.createElement("div", { className: "flex" }, /* @__PURE__ */ React$1.createElement(CarouselSlideGapContext.Provider, { value: gap }, children)));
15
24
  };
16
25
  //#endregion
17
- export { CarouselSlider };
26
+ export { CarouselSlideGapContext, CarouselSlider, toSlideGapClass };
18
27
 
19
28
  //# sourceMappingURL=CarouselSlider.js.map
@@ -1 +1 @@
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\ntype CarouselSliderProps = {\n children?: React.ReactNode\n className?: string\n overflow?: boolean\n tabIndex?: number\n}\n\nexport const CarouselSlider = ({\n children,\n className,\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\">{children}</div>\n </div>\n )\n}\n"],"mappings":";;;;AAaA,IAAa,kBAAkB,EAC7B,UACA,WACA,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;EAGA,EADJ,wBAAA,cAAC,OAAD,EAAK,WAAU,QAAuB,EAAf,SAAe,CAClC"}
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"}