@yamada-ui/carousel 3.0.0-next-20240825145710 → 3.0.0-next-20240921202825

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.
Files changed (41) hide show
  1. package/dist/carousel-control.d.mts +4 -3
  2. package/dist/carousel-control.d.ts +4 -3
  3. package/dist/carousel-control.js.map +1 -1
  4. package/dist/carousel-control.mjs +2 -2
  5. package/dist/carousel-indicators.d.mts +4 -3
  6. package/dist/carousel-indicators.d.ts +4 -3
  7. package/dist/carousel-indicators.js.map +1 -1
  8. package/dist/carousel-indicators.mjs +2 -2
  9. package/dist/carousel-slide.d.mts +4 -3
  10. package/dist/carousel-slide.d.ts +4 -3
  11. package/dist/carousel-slide.js.map +1 -1
  12. package/dist/carousel-slide.mjs +2 -2
  13. package/dist/carousel.d.mts +7 -6
  14. package/dist/carousel.d.ts +7 -6
  15. package/dist/carousel.js +81 -78
  16. package/dist/carousel.js.map +1 -1
  17. package/dist/carousel.mjs +5 -5
  18. package/dist/{chunk-KKGGV2LP.mjs → chunk-KDTZL7V5.mjs} +12 -10
  19. package/dist/chunk-KDTZL7V5.mjs.map +1 -0
  20. package/dist/{chunk-7JZQTAOC.mjs → chunk-OW2M7LIB.mjs} +2 -2
  21. package/dist/chunk-OW2M7LIB.mjs.map +1 -0
  22. package/dist/{chunk-N7FKTABA.mjs → chunk-PDUQUV53.mjs} +2 -2
  23. package/dist/chunk-PDUQUV53.mjs.map +1 -0
  24. package/dist/{chunk-QCRQ6FXC.mjs → chunk-X4MS32G3.mjs} +2 -2
  25. package/dist/chunk-X4MS32G3.mjs.map +1 -0
  26. package/dist/{chunk-27FJSIPV.mjs → chunk-YSHRYDOY.mjs} +6 -7
  27. package/dist/chunk-YSHRYDOY.mjs.map +1 -0
  28. package/dist/index.js +207 -204
  29. package/dist/index.js.map +1 -1
  30. package/dist/index.mjs +5 -5
  31. package/dist/use-carousel.d.mts +44 -19
  32. package/dist/use-carousel.d.ts +44 -19
  33. package/dist/use-carousel.js +5 -6
  34. package/dist/use-carousel.js.map +1 -1
  35. package/dist/use-carousel.mjs +1 -1
  36. package/package.json +10 -10
  37. package/dist/chunk-27FJSIPV.mjs.map +0 -1
  38. package/dist/chunk-7JZQTAOC.mjs.map +0 -1
  39. package/dist/chunk-KKGGV2LP.mjs.map +0 -1
  40. package/dist/chunk-N7FKTABA.mjs.map +0 -1
  41. package/dist/chunk-QCRQ6FXC.mjs.map +0 -1
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  useCarouselContext,
4
4
  useCarouselSlide
5
- } from "./chunk-27FJSIPV.mjs";
5
+ } from "./chunk-YSHRYDOY.mjs";
6
6
 
7
7
  // src/carousel-slide.tsx
8
8
  import { ui, forwardRef } from "@yamada-ui/core";
@@ -47,4 +47,4 @@ var CarouselSlideInner = forwardRef(
47
47
  export {
48
48
  CarouselSlide
49
49
  };
50
- //# sourceMappingURL=chunk-N7FKTABA.mjs.map
50
+ //# sourceMappingURL=chunk-PDUQUV53.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/carousel-slide.tsx"],"sourcesContent":["import type { HTMLUIProps, CSSUIObject } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { UseCarouselSlideProps } from \"./use-carousel\"\nimport { useCarouselContext, useCarouselSlide } from \"./use-carousel\"\n\ninterface CarouselSlideOptions {\n /**\n * The CSS `width` property.\n */\n size?: CSSUIObject[\"width\"]\n}\n\nexport interface CarouselSlideProps\n extends HTMLUIProps,\n UseCarouselSlideProps,\n CarouselSlideOptions {}\n\nexport const CarouselSlide = forwardRef<CarouselSlideProps, \"div\">(\n ({ className, size, ...rest }, ref) => {\n const { slideSize, includeGapInSize, orientation, gap } =\n useCarouselContext()\n\n const { getSlideProps } = useCarouselSlide(rest)\n\n size ??= slideSize\n\n const css: CSSUIObject = {\n position: \"relative\",\n flex: `0 0 ${size}`,\n ...(includeGapInSize\n ? { [orientation === \"vertical\" ? \"pb\" : \"pr\"]: gap }\n : { [orientation === \"vertical\" ? \"mb\" : \"mr\"]: gap }),\n }\n\n return (\n <ui.div\n className={cx(\"ui-carousel__slide\", className)}\n __css={css}\n {...getSlideProps({})}\n >\n <CarouselSlideInner ref={ref} {...rest} />\n </ui.div>\n )\n },\n)\n\ninterface CarouselSlideInnerProps extends HTMLUIProps {}\n\nconst CarouselSlideInner = forwardRef<CarouselSlideInnerProps, \"div\">(\n ({ ...rest }, ref) => {\n return (\n <ui.div\n ref={ref}\n className=\"ui-carousel__slide-inner\"\n w=\"100%\"\n h=\"100%\"\n {...rest}\n />\n )\n },\n)\n"],"mappings":";;;;;;;AACA,SAAS,IAAI,kBAAkB;AAC/B,SAAS,UAAU;AAuCX;AAvBD,IAAM,gBAAgB;AAAA,EAC3B,CAAC,EAAE,WAAW,MAAM,GAAG,KAAK,GAAG,QAAQ;AACrC,UAAM,EAAE,WAAW,kBAAkB,aAAa,IAAI,IACpD,mBAAmB;AAErB,UAAM,EAAE,cAAc,IAAI,iBAAiB,IAAI;AAE/C,iCAAS;AAET,UAAM,MAAmB;AAAA,MACvB,UAAU;AAAA,MACV,MAAM,OAAO,IAAI;AAAA,MACjB,GAAI,mBACA,EAAE,CAAC,gBAAgB,aAAa,OAAO,IAAI,GAAG,IAAI,IAClD,EAAE,CAAC,gBAAgB,aAAa,OAAO,IAAI,GAAG,IAAI;AAAA,IACxD;AAEA,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC,WAAW,GAAG,sBAAsB,SAAS;AAAA,QAC7C,OAAO;AAAA,QACN,GAAG,cAAc,CAAC,CAAC;AAAA,QAEpB,8BAAC,sBAAmB,KAAW,GAAG,MAAM;AAAA;AAAA,IAC1C;AAAA,EAEJ;AACF;AAIA,IAAM,qBAAqB;AAAA,EACzB,CAAC,EAAE,GAAG,KAAK,GAAG,QAAQ;AACpB,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,WAAU;AAAA,QACV,GAAE;AAAA,QACF,GAAE;AAAA,QACD,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":[]}
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  useCarouselContext,
4
4
  useCarouselControl
5
- } from "./chunk-27FJSIPV.mjs";
5
+ } from "./chunk-YSHRYDOY.mjs";
6
6
 
7
7
  // src/carousel-control.tsx
8
8
  import { IconButton } from "@yamada-ui/button";
@@ -82,4 +82,4 @@ export {
82
82
  CarouselControlPrev,
83
83
  CarouselControlNext
84
84
  };
85
- //# sourceMappingURL=chunk-QCRQ6FXC.mjs.map
85
+ //# sourceMappingURL=chunk-X4MS32G3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/carousel-control.tsx"],"sourcesContent":["import type { IconButtonProps } from \"@yamada-ui/button\"\nimport { IconButton } from \"@yamada-ui/button\"\nimport type { CSSUIObject } from \"@yamada-ui/core\"\nimport { forwardRef, useColorModeValue } from \"@yamada-ui/core\"\nimport { ChevronIcon } from \"@yamada-ui/icon\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useCarouselContext, useCarouselControl } from \"./use-carousel\"\n\nexport interface CarouselControlProps extends IconButtonProps {}\n\nexport const CarouselControlPrev = forwardRef<CarouselControlProps, \"button\">(\n ({ className, ...rest }, ref) => {\n const { orientation } = useCarouselContext()\n\n const { getControlProps } = useCarouselControl({ operation: \"prev\" })\n\n return (\n <CarouselControl\n operation=\"prev\"\n className={cx(\"ui-carousel__control--prev\", className)}\n aria-label=\"Go to previous slide\"\n icon={\n <ChevronIcon\n __css={{\n fontSize: \"1.5em\",\n transform:\n orientation === \"vertical\" ? \"rotate(180deg)\" : \"rotate(90deg)\",\n }}\n />\n }\n {...getControlProps(rest, ref)}\n />\n )\n },\n)\n\nexport const CarouselControlNext = forwardRef<CarouselControlProps, \"button\">(\n ({ className, ...rest }, ref) => {\n const { orientation } = useCarouselContext()\n\n const { getControlProps } = useCarouselControl({ operation: \"next\" })\n\n return (\n <CarouselControl\n operation=\"next\"\n className={cx(\"ui-carousel__control--next\", className)}\n aria-label=\"Go to next slide\"\n icon={\n <ChevronIcon\n __css={{\n fontSize: \"1.5em\",\n transform:\n orientation === \"vertical\" ? \"rotate(0deg)\" : \"rotate(-90deg)\",\n }}\n />\n }\n {...getControlProps(rest, ref)}\n />\n )\n },\n)\n\nconst CarouselControl = forwardRef<\n CarouselControlProps & { operation: \"prev\" | \"next\" },\n \"button\"\n>(({ className, operation, ...rest }, ref) => {\n const { styles } = useCarouselContext()\n const colorScheme = useColorModeValue(\"whiteAlpha\", \"blackAlpha\")\n\n const css: CSSUIObject = {\n ...styles.control,\n ...styles[operation],\n }\n\n return (\n <IconButton\n ref={ref}\n className={cx(\"ui-carousel__control\", className)}\n colorScheme={colorScheme}\n isRounded\n __css={css}\n {...rest}\n />\n )\n})\n"],"mappings":";;;;;;;AACA,SAAS,kBAAkB;AAE3B,SAAS,YAAY,yBAAyB;AAC9C,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AAiBT;AAZH,IAAM,sBAAsB;AAAA,EACjC,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,QAAQ;AAC/B,UAAM,EAAE,YAAY,IAAI,mBAAmB;AAE3C,UAAM,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,WAAW,OAAO,CAAC;AAEpE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,WAAW,GAAG,8BAA8B,SAAS;AAAA,QACrD,cAAW;AAAA,QACX,MACE;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,WACE,gBAAgB,aAAa,mBAAmB;AAAA,YACpD;AAAA;AAAA,QACF;AAAA,QAED,GAAG,gBAAgB,MAAM,GAAG;AAAA;AAAA,IAC/B;AAAA,EAEJ;AACF;AAEO,IAAM,sBAAsB;AAAA,EACjC,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,QAAQ;AAC/B,UAAM,EAAE,YAAY,IAAI,mBAAmB;AAE3C,UAAM,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,WAAW,OAAO,CAAC;AAEpE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,WAAW,GAAG,8BAA8B,SAAS;AAAA,QACrD,cAAW;AAAA,QACX,MACE;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,WACE,gBAAgB,aAAa,iBAAiB;AAAA,YAClD;AAAA;AAAA,QACF;AAAA,QAED,GAAG,gBAAgB,MAAM,GAAG;AAAA;AAAA,IAC/B;AAAA,EAEJ;AACF;AAEA,IAAM,kBAAkB,WAGtB,CAAC,EAAE,WAAW,WAAW,GAAG,KAAK,GAAG,QAAQ;AAC5C,QAAM,EAAE,OAAO,IAAI,mBAAmB;AACtC,QAAM,cAAc,kBAAkB,cAAc,YAAY;AAEhE,QAAM,MAAmB;AAAA,IACvB,GAAG,OAAO;AAAA,IACV,GAAG,OAAO,SAAS;AAAA,EACrB;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW,GAAG,wBAAwB,SAAS;AAAA,MAC/C;AAAA,MACA,WAAS;AAAA,MACT,OAAO;AAAA,MACN,GAAG;AAAA;AAAA,EACN;AAEJ,CAAC;","names":[]}
@@ -28,7 +28,6 @@ var useCarousel = ({
28
28
  loop = true,
29
29
  duration = 25,
30
30
  delay = 4e3,
31
- gap = "fallback(4, 1rem)",
32
31
  slidesToScroll = 1,
33
32
  draggable = true,
34
33
  dragFree = false,
@@ -45,7 +44,7 @@ var useCarousel = ({
45
44
  children,
46
45
  ...rest
47
46
  }) => {
48
- const computedProps = splitObject(rest, layoutStyleProperties);
47
+ const [{ gap = "fallback(4, 1rem)", ...containerProps }, slidesProps] = splitObject(rest, layoutStyleProperties);
49
48
  const [selectedIndex, setSelectedIndex] = useControllableState({
50
49
  value: index,
51
50
  defaultValue: defaultIndex,
@@ -150,7 +149,7 @@ var useCarousel = ({
150
149
  }, [carousel, onScroll]);
151
150
  const getContainerProps = useCallback(
152
151
  (props = {}, ref = null) => ({
153
- ...computedProps[0],
152
+ ...containerProps,
154
153
  ...props,
155
154
  ref,
156
155
  onMouseEnter: handlerAll(props.onMouseEnter, () => {
@@ -160,15 +159,15 @@ var useCarousel = ({
160
159
  setIsMouseEnter(false);
161
160
  })
162
161
  }),
163
- [computedProps]
162
+ [containerProps]
164
163
  );
165
164
  const getSlidesProps = useCallback(
166
165
  (props = {}) => ({
167
- ...computedProps[1],
166
+ ...slidesProps,
168
167
  ...props,
169
168
  ref: carouselRef
170
169
  }),
171
- [computedProps, carouselRef]
170
+ [slidesProps, carouselRef]
172
171
  );
173
172
  return {
174
173
  carousel,
@@ -260,4 +259,4 @@ export {
260
259
  useCarouselControl,
261
260
  useCarouselIndicators
262
261
  };
263
- //# sourceMappingURL=chunk-27FJSIPV.mjs.map
262
+ //# sourceMappingURL=chunk-YSHRYDOY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-carousel.ts"],"sourcesContent":["import type { IconButtonProps } from \"@yamada-ui/button\"\nimport type {\n CSSUIObject,\n HTMLUIProps,\n CSSUIProps,\n PropGetter,\n RequiredPropGetter,\n HTMLProps,\n} from \"@yamada-ui/core\"\nimport { layoutStyleProperties } from \"@yamada-ui/core\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport {\n assignRef,\n createContext,\n dataAttr,\n handlerAll,\n splitObject,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport type { EmblaCarouselType, EmblaOptionsType } from \"embla-carousel\"\nimport useEmblaCarousel from \"embla-carousel-react\"\nimport type { MouseEvent, RefObject } from \"react\"\nimport { Children, useCallback, useEffect, useRef, useState } from \"react\"\n\nexport type AlignmentOptionType = EmblaOptionsType[\"align\"]\nexport type ScrollContainOptionType = EmblaOptionsType[\"containScroll\"]\nexport type SlidesInViewOptionsType = EmblaOptionsType[\"inViewThreshold\"]\nexport type DragHandlerOptionType = EmblaOptionsType[\"watchDrag\"]\nexport type ResizeHandlerOptionType = EmblaOptionsType[\"watchResize\"]\nexport type SlidesHandlerOptionType = EmblaOptionsType[\"watchSlides\"]\nexport type CarouselControl = EmblaCarouselType\n\ninterface CarouselContext {\n carousel: CarouselControl | undefined\n indexes: number[]\n selectedIndex: number\n orientation: \"vertical\" | \"horizontal\"\n includeGapInSize: boolean\n slidesToScroll: number\n slideSize: string | number\n gap: CSSUIProps[\"gap\"]\n styles: { [key: string]: CSSUIObject }\n}\n\nexport const [CarouselProvider, useCarouselContext] =\n createContext<CarouselContext>({\n name: \"CarouselContext\",\n errorMessage: `useCarouselContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Carousel />\"`,\n })\n\nexport interface UseCarouselProps\n extends Omit<HTMLUIProps, \"onChange\" | \"draggable\" | \"gap\"> {\n /**\n * The index of the carousel slide.\n */\n index?: number\n /**\n * The initial index of the carousel slide.\n *\n * @default 0\n */\n defaultIndex?: number\n /**\n * The callback invoked when carousel slide selected.\n */\n onChange?: (index: number) => void\n /**\n * The orientation of the carousel.\n *\n * @default 'horizontal'\n */\n orientation?: \"vertical\" | \"horizontal\"\n /**\n * The alignment of the carousel.\n *\n * @default 'center'\n */\n align?: AlignmentOptionType\n /**\n * Clear leading and trailing empty space that causes excessive scrolling.\n * Use trimSnaps to only use snap points that trigger scrolling or keepSnaps to keep them.\n *\n * @default false\n */\n containScroll?: ScrollContainOptionType\n /**\n * The number of slides that should be scrolled with next or previous buttons.\n *\n * @default 1\n */\n slidesToScroll?: number\n /**\n * If `true`, momentum scrolling will be enabled.\n *\n * @default false\n */\n dragFree?: boolean\n /**\n * If `true`, carousel can be scrolled with mouse and touch interactions.\n *\n * @default true\n */\n draggable?: boolean\n /**\n * Choose a fraction representing the percentage portion of a slide that needs to be visible in order to be considered in view.\n *\n * @default 0\n */\n inViewThreshold?: SlidesInViewOptionsType\n /**\n * If `true`, infinite looping.\n * Automatically falls back to false if slide content isn't enough to loop.\n *\n * @default true\n */\n loop?: boolean\n /**\n * If `true`, allow the carousel to skip scroll snaps if it's dragged vigorously.\n * Note that this option will be ignored if the dragFree option is set to true.\n *\n * @default false\n */\n skipSnaps?: boolean\n /**\n * Set scroll duration when triggered by any of the API methods.\n * Higher numbers enables slower scrolling.\n * Drag interactions are not affected because duration is then determined by the drag force.\n *\n * @default 25\n */\n duration?: number\n /**\n * The number for the autoplay interval of the carousel.\n *\n * @default 4000\n */\n delay?: number\n /**\n * If `true`, the carousel will be autoplay.\n *\n * @default false\n */\n autoplay?: boolean\n /**\n * If `true`, autoplay will pause when the mouse entries over.\n *\n * @default true\n */\n stopMouseEnterAutoplay?: boolean\n /**\n * If `true`, gap will be treated as part of the carousel slide size.\n *\n * @default true\n */\n includeGapInSize?: boolean\n /**\n * The CSS `gap` property.\n *\n * @default '4'\n */\n gap?: CSSUIProps[\"gap\"]\n /**\n * The carousel slide width.\n *\n * @default '100%'\n */\n slideSize?: string | number\n /**\n * A callback that return the current scroll amount when the carousel is scrolled.\n */\n onScrollProgress?: (progress: number) => void\n /**\n * Enables for scrolling the carousel with mouse and touch interactions.\n * Set this to `false` to disable drag events or pass a custom callback to add your own drag logic.\n *\n * @default true\n */\n watchDrag?: DragHandlerOptionType\n /**\n * Embla automatically watches the container and slides for size changes and runs `reInit` when any size has changed.\n * Set this to `false` to disable this behaviour or pass a custom callback to add your own resize logic.\n *\n * @default true\n */\n watchResize?: ResizeHandlerOptionType\n /**\n * Embla automatically watches the container for added and/or removed slides and runs `reInit` if needed.\n * Set this to `false` to disable this behaviour or pass a custom callback to add your own slides changed logic.\n *\n * @default true\n */\n watchSlides?: SlidesHandlerOptionType\n /**\n * Ref of the resizable item callback.\n */\n controlRef?: RefObject<CarouselControl | undefined>\n}\n\nexport const useCarousel = ({\n index,\n defaultIndex = 0,\n onChange,\n align = \"center\",\n orientation = \"horizontal\",\n autoplay = false,\n stopMouseEnterAutoplay = true,\n loop = true,\n duration = 25,\n delay = 4000,\n slidesToScroll = 1,\n draggable = true,\n dragFree = false,\n inViewThreshold = 0,\n skipSnaps = false,\n containScroll = false,\n slideSize = \"100%\",\n includeGapInSize = true,\n onScrollProgress,\n watchDrag = draggable,\n watchResize,\n watchSlides,\n controlRef,\n children,\n ...rest\n}: UseCarouselProps) => {\n const [{ gap = \"fallback(4, 1rem)\", ...containerProps }, slidesProps] =\n splitObject(rest, layoutStyleProperties)\n\n const [selectedIndex, setSelectedIndex] = useControllableState({\n value: index,\n defaultValue: defaultIndex,\n onChange,\n })\n\n const isVertical = orientation === \"vertical\"\n\n const [carouselRef, carousel] = useEmblaCarousel(\n {\n axis: isVertical ? \"y\" : \"x\",\n startIndex: defaultIndex,\n loop,\n align,\n slidesToScroll,\n duration,\n dragFree,\n inViewThreshold,\n skipSnaps,\n containScroll,\n watchDrag,\n watchResize,\n watchSlides,\n },\n [],\n )\n\n assignRef(controlRef, carousel)\n\n const [indexes, setIndexes] = useState<number[]>([])\n const [isMouseEnter, setIsMouseEnter] = useState<boolean>(false)\n\n const timeoutId = useRef<any>(undefined)\n\n const onScroll = useCallback(() => {\n if (!carousel) return\n\n const progress = Math.round(\n Math.max(0, Math.min(1, carousel.scrollProgress())) * 100,\n )\n\n onScrollProgress?.(progress)\n }, [carousel, onScrollProgress])\n\n const onSelect = useCallback(() => {\n if (!carousel) return\n\n const index = carousel.selectedScrollSnap()\n\n setSelectedIndex(index)\n }, [carousel, setSelectedIndex])\n\n useEffect(() => {\n const isStop = isMouseEnter && stopMouseEnterAutoplay\n const isLast = !carousel?.canScrollNext()\n\n if (carousel && autoplay && !isStop && !isLast) {\n timeoutId.current = setInterval(() => {\n carousel.scrollNext()\n }, delay)\n } else {\n if (timeoutId.current) clearInterval(timeoutId.current)\n\n timeoutId.current = undefined\n }\n\n return () => {\n if (timeoutId.current) clearInterval(timeoutId.current)\n }\n }, [\n autoplay,\n delay,\n stopMouseEnterAutoplay,\n carousel,\n isMouseEnter,\n loop,\n selectedIndex,\n ])\n\n useUpdateEffect(() => {\n if (!carousel) return\n\n carousel.reInit()\n\n const snapList = carousel.scrollSnapList()\n const indexes = snapList.map((_, i) => i)\n\n setIndexes(indexes)\n }, [\n Children.toArray(children).length,\n align,\n orientation,\n loop,\n duration,\n gap,\n slidesToScroll,\n draggable,\n dragFree,\n inViewThreshold,\n skipSnaps,\n containScroll,\n slideSize,\n includeGapInSize,\n ])\n\n useUpdateEffect(() => {\n if (!carousel) return\n\n const snapList = carousel.scrollSnapList()\n const indexes = snapList.map((_, i) => i)\n\n setIndexes(indexes)\n }, [carousel])\n\n useUpdateEffect(() => {\n if (carousel) {\n carousel.on(\"select\", onSelect)\n carousel.on(\"scroll\", onScroll)\n\n onScroll()\n\n return () => {\n carousel.off(\"select\", onSelect)\n carousel.off(\"scroll\", onScroll)\n }\n }\n }, [carousel, onScroll])\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...containerProps,\n ...props,\n ref,\n onMouseEnter: handlerAll(props.onMouseEnter, () => {\n setIsMouseEnter(true)\n }),\n onMouseLeave: handlerAll(props.onMouseLeave, () => {\n setIsMouseEnter(false)\n }),\n }),\n [containerProps],\n )\n\n const getSlidesProps: PropGetter = useCallback(\n (props = {}) => ({\n ...slidesProps,\n ...props,\n ref: carouselRef,\n }),\n [slidesProps, carouselRef],\n )\n\n return {\n carousel,\n children,\n indexes,\n selectedIndex,\n orientation,\n slideSize,\n gap,\n slidesToScroll,\n includeGapInSize,\n getContainerProps,\n getSlidesProps,\n }\n}\n\nexport type UseCarouselReturn = ReturnType<typeof useCarousel>\n\nexport interface UseCarouselSlideProps {\n index?: number\n}\n\nexport const useCarouselSlide = ({ index }: UseCarouselSlideProps) => {\n const { selectedIndex, slidesToScroll } = useCarouselContext()\n\n index = Math.floor((index ?? 0) / (slidesToScroll ?? 1))\n\n const isSelected = index === selectedIndex\n\n const getSlideProps: PropGetter = useCallback(\n (props = {}) => ({\n ...props,\n \"data-index\": index,\n \"data-selected\": dataAttr(isSelected),\n }),\n [isSelected, index],\n )\n\n return { getSlideProps }\n}\n\nexport type UseCarouselSlideReturn = ReturnType<typeof useCarouselSlide>\n\nexport interface UseCarouselControlProps extends IconButtonProps {\n operation: \"prev\" | \"next\"\n}\n\nexport const useCarouselControl = ({\n operation,\n ...rest\n}: UseCarouselControlProps) => {\n const { carousel } = useCarouselContext()\n\n const isPrev = operation === \"prev\"\n\n const disabled =\n rest.disabled ??\n rest.isDisabled ??\n (isPrev ? !carousel?.canScrollPrev() : !carousel?.canScrollNext())\n\n const onClick = useCallback(() => {\n if (!carousel) return\n\n if (isPrev) {\n carousel.scrollPrev()\n } else {\n carousel.scrollNext()\n }\n }, [carousel, isPrev])\n\n const getControlProps: PropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ref,\n disabled,\n onClick: handlerAll(props.onClick, onClick),\n }),\n [disabled, onClick],\n )\n\n return { getControlProps }\n}\n\nexport type UseCarouselControlReturn = ReturnType<typeof useCarouselControl>\n\nexport const useCarouselIndicators = () => {\n const { selectedIndex, carousel, indexes } = useCarouselContext()\n\n const onClick = useCallback(\n (ev: MouseEvent, index: number) => {\n if (!carousel) return\n\n ev.stopPropagation()\n\n carousel.scrollTo(index)\n },\n [carousel],\n )\n\n const getIndicatorProps: RequiredPropGetter<\n HTMLProps<\"button\"> & { index: number },\n HTMLProps<\"button\">\n > = useCallback(\n ({ index, ...props }) => {\n const isSelected = index === selectedIndex\n\n return {\n \"aria-label\": `Go to ${index + 1} slide`,\n ...props,\n key: index,\n \"data-index\": index,\n \"data-selected\": dataAttr(isSelected),\n onClick: handlerAll(props.onClick, (ev) => onClick(ev, index)),\n }\n },\n [onClick, selectedIndex],\n )\n\n return { indexes, getIndicatorProps }\n}\n\nexport type UseCarouselIndicatorsReturn = ReturnType<\n typeof useCarouselIndicators\n>\n"],"mappings":";;;AASA,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,E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AE,OAAO,GAAG,MAAM,MAAM;AACvB,YAAM,aAAa,UAAU;AAE7B,aAAO;AAAA,QACL,cAAc,SAAS,QAAQ,CAAC;AAAA,QAChC,GAAG;AAAA,QACH,KAAK;AAAA,QACL,cAAc;AAAA,QACd,iBAAiB,SAAS,UAAU;AAAA,QACpC,SAAS,WAAW,MAAM,SAAS,CAAC,OAAO,QAAQ,IAAI,KAAK,CAAC;AAAA,MAC/D;AAAA,IACF;AAAA,IACA,CAAC,SAAS,aAAa;AAAA,EACzB;AAEA,SAAO,EAAE,SAAS,kBAAkB;AACtC;","names":["index","indexes"]}
package/dist/index.js CHANGED
@@ -40,11 +40,17 @@ __export(src_exports, {
40
40
  module.exports = __toCommonJS(src_exports);
41
41
 
42
42
  // src/carousel.tsx
43
- var import_core2 = require("@yamada-ui/core");
43
+ var import_core5 = require("@yamada-ui/core");
44
44
  var import_use_token = require("@yamada-ui/use-token");
45
45
  var import_use_value = require("@yamada-ui/use-value");
46
+ var import_utils5 = require("@yamada-ui/utils");
47
+ var import_react3 = require("react");
48
+
49
+ // src/carousel-control.tsx
50
+ var import_button = require("@yamada-ui/button");
51
+ var import_core2 = require("@yamada-ui/core");
52
+ var import_icon = require("@yamada-ui/icon");
46
53
  var import_utils2 = require("@yamada-ui/utils");
47
- var import_react2 = require("react");
48
54
 
49
55
  // src/use-carousel.ts
50
56
  var import_core = require("@yamada-ui/core");
@@ -67,7 +73,6 @@ var useCarousel = ({
67
73
  loop = true,
68
74
  duration = 25,
69
75
  delay = 4e3,
70
- gap = "fallback(4, 1rem)",
71
76
  slidesToScroll = 1,
72
77
  draggable = true,
73
78
  dragFree = false,
@@ -84,7 +89,7 @@ var useCarousel = ({
84
89
  children,
85
90
  ...rest
86
91
  }) => {
87
- const computedProps = (0, import_utils.splitObject)(rest, import_core.layoutStyleProperties);
92
+ const [{ gap = "fallback(4, 1rem)", ...containerProps }, slidesProps] = (0, import_utils.splitObject)(rest, import_core.layoutStyleProperties);
88
93
  const [selectedIndex, setSelectedIndex] = (0, import_use_controllable_state.useControllableState)({
89
94
  value: index,
90
95
  defaultValue: defaultIndex,
@@ -189,7 +194,7 @@ var useCarousel = ({
189
194
  }, [carousel, onScroll]);
190
195
  const getContainerProps = (0, import_react.useCallback)(
191
196
  (props = {}, ref = null) => ({
192
- ...computedProps[0],
197
+ ...containerProps,
193
198
  ...props,
194
199
  ref,
195
200
  onMouseEnter: (0, import_utils.handlerAll)(props.onMouseEnter, () => {
@@ -199,15 +204,15 @@ var useCarousel = ({
199
204
  setIsMouseEnter(false);
200
205
  })
201
206
  }),
202
- [computedProps]
207
+ [containerProps]
203
208
  );
204
209
  const getSlidesProps = (0, import_react.useCallback)(
205
210
  (props = {}) => ({
206
- ...computedProps[1],
211
+ ...slidesProps,
207
212
  ...props,
208
213
  ref: carouselRef
209
214
  }),
210
- [computedProps, carouselRef]
215
+ [slidesProps, carouselRef]
211
216
  );
212
217
  return {
213
218
  carousel,
@@ -291,9 +296,176 @@ var useCarouselIndicators = () => {
291
296
  return { indexes, getIndicatorProps };
292
297
  };
293
298
 
294
- // src/carousel.tsx
299
+ // src/carousel-control.tsx
295
300
  var import_jsx_runtime = require("react/jsx-runtime");
296
- var Carousel = (0, import_core2.forwardRef)(
301
+ var CarouselControlPrev = (0, import_core2.forwardRef)(
302
+ ({ className, ...rest }, ref) => {
303
+ const { orientation } = useCarouselContext();
304
+ const { getControlProps } = useCarouselControl({ operation: "prev" });
305
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
306
+ CarouselControl,
307
+ {
308
+ operation: "prev",
309
+ className: (0, import_utils2.cx)("ui-carousel__control--prev", className),
310
+ "aria-label": "Go to previous slide",
311
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
312
+ import_icon.ChevronIcon,
313
+ {
314
+ __css: {
315
+ fontSize: "1.5em",
316
+ transform: orientation === "vertical" ? "rotate(180deg)" : "rotate(90deg)"
317
+ }
318
+ }
319
+ ),
320
+ ...getControlProps(rest, ref)
321
+ }
322
+ );
323
+ }
324
+ );
325
+ var CarouselControlNext = (0, import_core2.forwardRef)(
326
+ ({ className, ...rest }, ref) => {
327
+ const { orientation } = useCarouselContext();
328
+ const { getControlProps } = useCarouselControl({ operation: "next" });
329
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
330
+ CarouselControl,
331
+ {
332
+ operation: "next",
333
+ className: (0, import_utils2.cx)("ui-carousel__control--next", className),
334
+ "aria-label": "Go to next slide",
335
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
336
+ import_icon.ChevronIcon,
337
+ {
338
+ __css: {
339
+ fontSize: "1.5em",
340
+ transform: orientation === "vertical" ? "rotate(0deg)" : "rotate(-90deg)"
341
+ }
342
+ }
343
+ ),
344
+ ...getControlProps(rest, ref)
345
+ }
346
+ );
347
+ }
348
+ );
349
+ var CarouselControl = (0, import_core2.forwardRef)(({ className, operation, ...rest }, ref) => {
350
+ const { styles } = useCarouselContext();
351
+ const colorScheme = (0, import_core2.useColorModeValue)("whiteAlpha", "blackAlpha");
352
+ const css = {
353
+ ...styles.control,
354
+ ...styles[operation]
355
+ };
356
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
357
+ import_button.IconButton,
358
+ {
359
+ ref,
360
+ className: (0, import_utils2.cx)("ui-carousel__control", className),
361
+ colorScheme,
362
+ isRounded: true,
363
+ __css: css,
364
+ ...rest
365
+ }
366
+ );
367
+ });
368
+
369
+ // src/carousel-indicators.tsx
370
+ var import_core3 = require("@yamada-ui/core");
371
+ var import_utils3 = require("@yamada-ui/utils");
372
+ var import_react2 = require("react");
373
+ var import_jsx_runtime2 = require("react/jsx-runtime");
374
+ var CarouselIndicators = (0, import_core3.forwardRef)(
375
+ ({ className, component, ...rest }, ref) => {
376
+ const { selectedIndex, orientation, styles } = useCarouselContext();
377
+ const { indexes, getIndicatorProps } = useCarouselIndicators();
378
+ const css = {
379
+ ...styles.indicators,
380
+ ...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
381
+ };
382
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
383
+ import_core3.ui.div,
384
+ {
385
+ ref,
386
+ className: (0, import_utils3.cx)("ui-carousel__indicators", className),
387
+ __css: css,
388
+ ...rest,
389
+ children: indexes.map((index) => {
390
+ const isSelected = index === selectedIndex;
391
+ if (typeof component === "function") {
392
+ const child = component({
393
+ index,
394
+ isSelected
395
+ });
396
+ if (!child) return null;
397
+ const props = getIndicatorProps({ ...child.props, index });
398
+ return (0, import_react2.cloneElement)(child, props);
399
+ } else {
400
+ const { key, ...props } = getIndicatorProps({ index });
401
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CarouselIndicator, { ...props }, key);
402
+ }
403
+ })
404
+ }
405
+ );
406
+ }
407
+ );
408
+ var CarouselIndicator = ({
409
+ className,
410
+ ...rest
411
+ }) => {
412
+ const { styles } = useCarouselContext();
413
+ const css = { ...styles.indicator };
414
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
415
+ import_core3.ui.button,
416
+ {
417
+ type: "button",
418
+ tabIndex: -1,
419
+ className: (0, import_utils3.cx)("ui-carousel__indicator", className),
420
+ __css: css,
421
+ ...rest
422
+ }
423
+ );
424
+ };
425
+
426
+ // src/carousel-slide.tsx
427
+ var import_core4 = require("@yamada-ui/core");
428
+ var import_utils4 = require("@yamada-ui/utils");
429
+ var import_jsx_runtime3 = require("react/jsx-runtime");
430
+ var CarouselSlide = (0, import_core4.forwardRef)(
431
+ ({ className, size, ...rest }, ref) => {
432
+ const { slideSize, includeGapInSize, orientation, gap } = useCarouselContext();
433
+ const { getSlideProps } = useCarouselSlide(rest);
434
+ size != null ? size : size = slideSize;
435
+ const css = {
436
+ position: "relative",
437
+ flex: `0 0 ${size}`,
438
+ ...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
439
+ };
440
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
441
+ import_core4.ui.div,
442
+ {
443
+ className: (0, import_utils4.cx)("ui-carousel__slide", className),
444
+ __css: css,
445
+ ...getSlideProps({}),
446
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CarouselSlideInner, { ref, ...rest })
447
+ }
448
+ );
449
+ }
450
+ );
451
+ var CarouselSlideInner = (0, import_core4.forwardRef)(
452
+ ({ ...rest }, ref) => {
453
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
454
+ import_core4.ui.div,
455
+ {
456
+ ref,
457
+ className: "ui-carousel__slide-inner",
458
+ w: "100%",
459
+ h: "100%",
460
+ ...rest
461
+ }
462
+ );
463
+ }
464
+ );
465
+
466
+ // src/carousel.tsx
467
+ var import_jsx_runtime4 = require("react/jsx-runtime");
468
+ var Carousel = (0, import_core5.forwardRef)(
297
469
  ({ h, height, minH, minHeight, ...props }, ref) => {
298
470
  var _a, _b;
299
471
  const orientation = (0, import_use_value.useValue)(props.orientation);
@@ -310,9 +482,11 @@ var Carousel = (0, import_core2.forwardRef)(
310
482
  const skipSnaps = (0, import_use_value.useValue)(props.skipSnaps);
311
483
  const containScroll = (0, import_use_value.useValue)(props.containScroll);
312
484
  const includeGapInSize = (0, import_use_value.useValue)(props.includeGapInSize);
313
- const gap = (_a = (0, import_use_token.useToken)("spaces", (0, import_use_value.useValue)(props.gap))) != null ? _a : (0, import_use_value.useValue)(props.gap);
314
- const slideSize = (_b = (0, import_use_token.useToken)("sizes", (0, import_use_value.useValue)(props.slideSize))) != null ? _b : (0, import_use_value.useValue)(props.slideSize);
315
- const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Carousel", {
485
+ const _gap = (0, import_use_value.useValue)(props.gap);
486
+ const gap = (_a = (0, import_use_token.useToken)("spaces", _gap)) != null ? _a : _gap;
487
+ const _slideSize = (0, import_use_value.useValue)(props.slideSize);
488
+ const slideSize = (_b = (0, import_use_token.useToken)("sizes", _slideSize)) != null ? _b : _slideSize;
489
+ const [styles, mergedProps] = (0, import_core5.useComponentMultiStyle)("Carousel", {
316
490
  ...props,
317
491
  orientation,
318
492
  align,
@@ -341,27 +515,27 @@ var Carousel = (0, import_core2.forwardRef)(
341
515
  withIndicators = true,
342
516
  indicatorsProps,
343
517
  ...computedProps
344
- } = (0, import_core2.omitThemeProps)(mergedProps);
518
+ } = (0, import_core5.omitThemeProps)(mergedProps);
345
519
  const computedWithControls = (0, import_use_value.useValue)(withControls);
346
520
  const computedWithIndicators = (0, import_use_value.useValue)(withIndicators);
347
521
  const { getContainerProps, getSlidesProps, children, ...rest } = useCarousel({
348
522
  ...computedProps
349
523
  });
350
- const validChildren = (0, import_utils2.getValidChildren)(children);
351
- const [customCarouselControlPrev] = (0, import_utils2.findChildren)(
524
+ const validChildren = (0, import_utils5.getValidChildren)(children);
525
+ const [customCarouselControlPrev] = (0, import_utils5.findChildren)(
352
526
  validChildren,
353
527
  CarouselControlPrev
354
528
  );
355
- const [customCarouselControlNext] = (0, import_utils2.findChildren)(
529
+ const [customCarouselControlNext] = (0, import_utils5.findChildren)(
356
530
  validChildren,
357
531
  CarouselControlNext
358
532
  );
359
- const [customCarouselIndicators] = (0, import_utils2.findChildren)(
533
+ const [customCarouselIndicators] = (0, import_utils5.findChildren)(
360
534
  validChildren,
361
535
  CarouselIndicators
362
536
  );
363
- const slideChildren = (0, import_utils2.pickChildren)(validChildren, CarouselSlide);
364
- const otherChildren = (0, import_utils2.omitChildren)(
537
+ const slideChildren = (0, import_utils5.pickChildren)(validChildren, CarouselSlide);
538
+ const otherChildren = (0, import_utils5.omitChildren)(
365
539
  validChildren,
366
540
  CarouselControlPrev,
367
541
  CarouselControlNext,
@@ -369,42 +543,42 @@ var Carousel = (0, import_core2.forwardRef)(
369
543
  CarouselSlide
370
544
  );
371
545
  const cloneSlideChildren = slideChildren.map(
372
- (child, index) => (0, import_react2.cloneElement)(child, { index })
546
+ (child, index) => (0, import_react3.cloneElement)(child, { index })
373
547
  );
374
548
  h != null ? h : h = height;
375
549
  minH != null ? minH : minH = minHeight;
376
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
377
- import_core2.ui.div,
550
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
551
+ import_core5.ui.div,
378
552
  {
379
- className: (0, import_utils2.cx)("ui-carousel", className),
553
+ className: (0, import_utils5.cx)("ui-carousel", className),
380
554
  __css: {
381
555
  ...styles.container
382
556
  },
383
557
  ...getContainerProps({}, ref),
384
558
  children: [
385
- customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselControlPrev, { ...controlProps, ...controlPrevProps }) : null,
386
- customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselControlNext, { ...controlProps, ...controlNextProps }) : null,
387
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
559
+ customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselControlPrev, { ...controlProps, ...controlPrevProps }) : null,
560
+ customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselControlNext, { ...controlProps, ...controlNextProps }) : null,
561
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
388
562
  CarouselSlides,
389
563
  {
390
564
  ...getSlidesProps({
391
- ...(0, import_utils2.filterUndefined)({ h, minH }),
565
+ ...(0, import_utils5.filterUndefined)({ h, minH }),
392
566
  ...innerProps
393
567
  }),
394
568
  children: cloneSlideChildren
395
569
  }
396
570
  ),
397
- customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselIndicators, { ...indicatorsProps }) : null,
571
+ customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicators, { ...indicatorsProps }) : null,
398
572
  otherChildren
399
573
  ]
400
574
  }
401
575
  ) });
402
576
  }
403
577
  );
404
- var CarouselSlides = (0, import_core2.forwardRef)(
578
+ var CarouselSlides = (0, import_core5.forwardRef)(
405
579
  ({ ...rest }, ref) => {
406
580
  const css = { w: "100%", h: "fit-content", overflow: "hidden" };
407
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.ui.div, { ref, className: "ui-carousel__sliders", __css: css, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselSlidesInner, { ...rest }) });
581
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core5.ui.div, { ref, className: "ui-carousel__sliders", __css: css, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselSlidesInner, { ...rest }) });
408
582
  }
409
583
  );
410
584
  var CarouselSlidesInner = ({ ...rest }) => {
@@ -413,182 +587,11 @@ var CarouselSlidesInner = ({ ...rest }) => {
413
587
  flexDirection: orientation === "vertical" ? "column" : "row",
414
588
  ...styles.inner,
415
589
  ...includeGapInSize ? {
416
- var: [{ name: "gap", token: "spaces", value: gap }],
590
+ vars: [{ name: "gap", token: "spaces", value: gap }],
417
591
  [orientation === "vertical" ? "mb" : "mr"]: "calc($gap * -1)"
418
592
  } : {}
419
593
  };
420
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.ui.div, { className: "ui-carousel__sliders-inner", __css: css, ...rest });
421
- };
422
-
423
- // src/carousel-slide.tsx
424
- var import_core3 = require("@yamada-ui/core");
425
- var import_utils3 = require("@yamada-ui/utils");
426
- var import_jsx_runtime2 = require("react/jsx-runtime");
427
- var CarouselSlide = (0, import_core3.forwardRef)(
428
- ({ className, size, ...rest }, ref) => {
429
- const { slideSize, includeGapInSize, orientation, gap } = useCarouselContext();
430
- const { getSlideProps } = useCarouselSlide(rest);
431
- size != null ? size : size = slideSize;
432
- const css = {
433
- position: "relative",
434
- flex: `0 0 ${size}`,
435
- ...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
436
- };
437
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
438
- import_core3.ui.div,
439
- {
440
- className: (0, import_utils3.cx)("ui-carousel__slide", className),
441
- __css: css,
442
- ...getSlideProps({}),
443
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CarouselSlideInner, { ref, ...rest })
444
- }
445
- );
446
- }
447
- );
448
- var CarouselSlideInner = (0, import_core3.forwardRef)(
449
- ({ ...rest }, ref) => {
450
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
451
- import_core3.ui.div,
452
- {
453
- ref,
454
- className: "ui-carousel__slide-inner",
455
- w: "100%",
456
- h: "100%",
457
- ...rest
458
- }
459
- );
460
- }
461
- );
462
-
463
- // src/carousel-control.tsx
464
- var import_button = require("@yamada-ui/button");
465
- var import_core4 = require("@yamada-ui/core");
466
- var import_icon = require("@yamada-ui/icon");
467
- var import_utils4 = require("@yamada-ui/utils");
468
- var import_jsx_runtime3 = require("react/jsx-runtime");
469
- var CarouselControlPrev = (0, import_core4.forwardRef)(
470
- ({ className, ...rest }, ref) => {
471
- const { orientation } = useCarouselContext();
472
- const { getControlProps } = useCarouselControl({ operation: "prev" });
473
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
474
- CarouselControl,
475
- {
476
- operation: "prev",
477
- className: (0, import_utils4.cx)("ui-carousel__control--prev", className),
478
- "aria-label": "Go to previous slide",
479
- icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
480
- import_icon.ChevronIcon,
481
- {
482
- __css: {
483
- fontSize: "1.5em",
484
- transform: orientation === "vertical" ? "rotate(180deg)" : "rotate(90deg)"
485
- }
486
- }
487
- ),
488
- ...getControlProps(rest, ref)
489
- }
490
- );
491
- }
492
- );
493
- var CarouselControlNext = (0, import_core4.forwardRef)(
494
- ({ className, ...rest }, ref) => {
495
- const { orientation } = useCarouselContext();
496
- const { getControlProps } = useCarouselControl({ operation: "next" });
497
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
498
- CarouselControl,
499
- {
500
- operation: "next",
501
- className: (0, import_utils4.cx)("ui-carousel__control--next", className),
502
- "aria-label": "Go to next slide",
503
- icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
504
- import_icon.ChevronIcon,
505
- {
506
- __css: {
507
- fontSize: "1.5em",
508
- transform: orientation === "vertical" ? "rotate(0deg)" : "rotate(-90deg)"
509
- }
510
- }
511
- ),
512
- ...getControlProps(rest, ref)
513
- }
514
- );
515
- }
516
- );
517
- var CarouselControl = (0, import_core4.forwardRef)(({ className, operation, ...rest }, ref) => {
518
- const { styles } = useCarouselContext();
519
- const colorScheme = (0, import_core4.useColorModeValue)("whiteAlpha", "blackAlpha");
520
- const css = {
521
- ...styles.control,
522
- ...styles[operation]
523
- };
524
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
525
- import_button.IconButton,
526
- {
527
- ref,
528
- className: (0, import_utils4.cx)("ui-carousel__control", className),
529
- colorScheme,
530
- isRounded: true,
531
- __css: css,
532
- ...rest
533
- }
534
- );
535
- });
536
-
537
- // src/carousel-indicators.tsx
538
- var import_core5 = require("@yamada-ui/core");
539
- var import_utils5 = require("@yamada-ui/utils");
540
- var import_react3 = require("react");
541
- var import_jsx_runtime4 = require("react/jsx-runtime");
542
- var CarouselIndicators = (0, import_core5.forwardRef)(
543
- ({ className, component, ...rest }, ref) => {
544
- const { selectedIndex, orientation, styles } = useCarouselContext();
545
- const { indexes, getIndicatorProps } = useCarouselIndicators();
546
- const css = {
547
- ...styles.indicators,
548
- ...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
549
- };
550
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
551
- import_core5.ui.div,
552
- {
553
- ref,
554
- className: (0, import_utils5.cx)("ui-carousel__indicators", className),
555
- __css: css,
556
- ...rest,
557
- children: indexes.map((index) => {
558
- const isSelected = index === selectedIndex;
559
- if (typeof component === "function") {
560
- const child = component({
561
- index,
562
- isSelected
563
- });
564
- if (!child) return null;
565
- const props = getIndicatorProps({ ...child.props, index });
566
- return (0, import_react3.cloneElement)(child, props);
567
- } else {
568
- const { key, ...props } = getIndicatorProps({ index });
569
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicator, { ...props }, key);
570
- }
571
- })
572
- }
573
- );
574
- }
575
- );
576
- var CarouselIndicator = ({
577
- className,
578
- ...rest
579
- }) => {
580
- const { styles } = useCarouselContext();
581
- const css = { ...styles.indicator };
582
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
583
- import_core5.ui.button,
584
- {
585
- type: "button",
586
- tabIndex: -1,
587
- className: (0, import_utils5.cx)("ui-carousel__indicator", className),
588
- __css: css,
589
- ...rest
590
- }
591
- );
594
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core5.ui.div, { className: "ui-carousel__sliders-inner", __css: css, ...rest });
592
595
  };
593
596
  // Annotate the CommonJS export names for ESM import in node:
594
597
  0 && (module.exports = {