@yamada-ui/carousel 2.0.5-dev-20240915031944 → 2.0.5-dev-20240917064938
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/carousel-control.d.mts +4 -3
- package/dist/carousel-control.d.ts +4 -3
- package/dist/carousel-control.js.map +1 -1
- package/dist/carousel-control.mjs +2 -2
- package/dist/carousel-indicators.d.mts +4 -3
- package/dist/carousel-indicators.d.ts +4 -3
- package/dist/carousel-indicators.js.map +1 -1
- package/dist/carousel-indicators.mjs +2 -2
- package/dist/carousel-slide.d.mts +4 -3
- package/dist/carousel-slide.d.ts +4 -3
- package/dist/carousel-slide.js.map +1 -1
- package/dist/carousel-slide.mjs +2 -2
- package/dist/carousel.d.mts +7 -6
- package/dist/carousel.d.ts +7 -6
- package/dist/carousel.js +71 -69
- package/dist/carousel.js.map +1 -1
- package/dist/carousel.mjs +5 -5
- package/dist/{chunk-PENCADVD.mjs → chunk-3OKZ522Y.mjs} +2 -2
- package/dist/chunk-3OKZ522Y.mjs.map +1 -0
- package/dist/{chunk-C3NMMSZM.mjs → chunk-4D3RMGS7.mjs} +2 -2
- package/dist/chunk-4D3RMGS7.mjs.map +1 -0
- package/dist/{chunk-QON3FG3O.mjs → chunk-OJGFCI5M.mjs} +2 -2
- package/dist/chunk-OJGFCI5M.mjs.map +1 -0
- package/dist/{chunk-VM6YPBJ6.mjs → chunk-SPB76HNU.mjs} +7 -7
- package/dist/chunk-SPB76HNU.mjs.map +1 -0
- package/dist/{chunk-H4J2Q2O6.mjs → chunk-YSHRYDOY.mjs} +1 -1
- package/dist/chunk-YSHRYDOY.mjs.map +1 -0
- package/dist/index.js +203 -201
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/use-carousel.d.mts +43 -18
- package/dist/use-carousel.d.ts +43 -18
- package/dist/use-carousel.js.map +1 -1
- package/dist/use-carousel.mjs +1 -1
- package/package.json +8 -8
- package/dist/chunk-C3NMMSZM.mjs.map +0 -1
- package/dist/chunk-H4J2Q2O6.mjs.map +0 -1
- package/dist/chunk-PENCADVD.mjs.map +0 -1
- package/dist/chunk-QON3FG3O.mjs.map +0 -1
- package/dist/chunk-VM6YPBJ6.mjs.map +0 -1
|
@@ -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,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,OAAO,sBAAsB;AAE7B,SAAS,UAAU,aAAa,WAAW,QAAQ,gBAAgB;AAsB5D,IAAM,CAAC,kBAAkB,kBAAkB,IAChD,cAA+B;AAAA,EAC7B,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAsJI,IAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,WAAW;AAAA,EACX,yBAAyB;AAAA,EACzB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,WAAW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.exports = __toCommonJS(src_exports);
|
|
41
41
|
|
|
42
42
|
// src/carousel.tsx
|
|
43
|
-
var
|
|
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");
|
|
@@ -290,9 +296,182 @@ var useCarouselIndicators = () => {
|
|
|
290
296
|
return { indexes, getIndicatorProps };
|
|
291
297
|
};
|
|
292
298
|
|
|
293
|
-
// src/carousel.tsx
|
|
299
|
+
// src/carousel-control.tsx
|
|
294
300
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
295
|
-
var
|
|
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
|
+
position: "absolute",
|
|
354
|
+
zIndex: "fallback(kurillin, 9)",
|
|
355
|
+
...styles.control,
|
|
356
|
+
...styles[operation]
|
|
357
|
+
};
|
|
358
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
359
|
+
import_button.IconButton,
|
|
360
|
+
{
|
|
361
|
+
ref,
|
|
362
|
+
className: (0, import_utils2.cx)("ui-carousel__control", className),
|
|
363
|
+
colorScheme,
|
|
364
|
+
isRounded: true,
|
|
365
|
+
__css: css,
|
|
366
|
+
...rest
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// src/carousel-indicators.tsx
|
|
372
|
+
var import_core3 = require("@yamada-ui/core");
|
|
373
|
+
var import_utils3 = require("@yamada-ui/utils");
|
|
374
|
+
var import_react2 = require("react");
|
|
375
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
376
|
+
var CarouselIndicators = (0, import_core3.forwardRef)(
|
|
377
|
+
({ className, component, ...rest }, ref) => {
|
|
378
|
+
const { selectedIndex, orientation, styles } = useCarouselContext();
|
|
379
|
+
const { indexes, getIndicatorProps } = useCarouselIndicators();
|
|
380
|
+
const css = {
|
|
381
|
+
position: "absolute",
|
|
382
|
+
zIndex: "fallback(kurillin, 9)",
|
|
383
|
+
display: "flex",
|
|
384
|
+
justifyContent: "center",
|
|
385
|
+
...styles.indicators,
|
|
386
|
+
...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
|
|
387
|
+
};
|
|
388
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
389
|
+
import_core3.ui.div,
|
|
390
|
+
{
|
|
391
|
+
ref,
|
|
392
|
+
className: (0, import_utils3.cx)("ui-carousel__indicators", className),
|
|
393
|
+
__css: css,
|
|
394
|
+
...rest,
|
|
395
|
+
children: indexes.map((index) => {
|
|
396
|
+
const isSelected = index === selectedIndex;
|
|
397
|
+
if (typeof component === "function") {
|
|
398
|
+
const child = component({
|
|
399
|
+
index,
|
|
400
|
+
isSelected
|
|
401
|
+
});
|
|
402
|
+
if (!child) return null;
|
|
403
|
+
const props = getIndicatorProps({ ...child.props, index });
|
|
404
|
+
return (0, import_react2.cloneElement)(child, props);
|
|
405
|
+
} else {
|
|
406
|
+
const { key, ...props } = getIndicatorProps({ index });
|
|
407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CarouselIndicator, { ...props }, key);
|
|
408
|
+
}
|
|
409
|
+
})
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
var CarouselIndicator = ({
|
|
415
|
+
className,
|
|
416
|
+
...rest
|
|
417
|
+
}) => {
|
|
418
|
+
const { styles } = useCarouselContext();
|
|
419
|
+
const css = { ...styles.indicator };
|
|
420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
421
|
+
import_core3.ui.button,
|
|
422
|
+
{
|
|
423
|
+
type: "button",
|
|
424
|
+
tabIndex: -1,
|
|
425
|
+
className: (0, import_utils3.cx)("ui-carousel__indicators__indicator", className),
|
|
426
|
+
__css: css,
|
|
427
|
+
...rest
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
// src/carousel-slide.tsx
|
|
433
|
+
var import_core4 = require("@yamada-ui/core");
|
|
434
|
+
var import_utils4 = require("@yamada-ui/utils");
|
|
435
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
436
|
+
var CarouselSlide = (0, import_core4.forwardRef)(
|
|
437
|
+
({ className, size, ...rest }, ref) => {
|
|
438
|
+
const { slideSize, includeGapInSize, orientation, gap } = useCarouselContext();
|
|
439
|
+
const { getSlideProps } = useCarouselSlide(rest);
|
|
440
|
+
size != null ? size : size = slideSize;
|
|
441
|
+
const css = {
|
|
442
|
+
position: "relative",
|
|
443
|
+
flex: `0 0 ${size}`,
|
|
444
|
+
...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
|
|
445
|
+
};
|
|
446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
447
|
+
import_core4.ui.div,
|
|
448
|
+
{
|
|
449
|
+
className: (0, import_utils4.cx)("ui-carousel__slide", className),
|
|
450
|
+
__css: css,
|
|
451
|
+
...getSlideProps({}),
|
|
452
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CarouselSlideInner, { ref, ...rest })
|
|
453
|
+
}
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
var CarouselSlideInner = (0, import_core4.forwardRef)(
|
|
458
|
+
({ ...rest }, ref) => {
|
|
459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
460
|
+
import_core4.ui.div,
|
|
461
|
+
{
|
|
462
|
+
ref,
|
|
463
|
+
className: "ui-carousel__slide__inner",
|
|
464
|
+
w: "100%",
|
|
465
|
+
h: "100%",
|
|
466
|
+
...rest
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
);
|
|
471
|
+
|
|
472
|
+
// src/carousel.tsx
|
|
473
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
474
|
+
var Carousel = (0, import_core5.forwardRef)(
|
|
296
475
|
({ h, height, minH, minHeight, ...props }, ref) => {
|
|
297
476
|
var _a, _b;
|
|
298
477
|
const orientation = (0, import_use_value.useValue)(props.orientation);
|
|
@@ -313,7 +492,7 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
|
313
492
|
const gap = (_a = (0, import_use_token.useToken)("spaces", _gap)) != null ? _a : _gap;
|
|
314
493
|
const _slideSize = (0, import_use_value.useValue)(props.slideSize);
|
|
315
494
|
const slideSize = (_b = (0, import_use_token.useToken)("sizes", _slideSize)) != null ? _b : _slideSize;
|
|
316
|
-
const [styles, mergedProps] = (0,
|
|
495
|
+
const [styles, mergedProps] = (0, import_core5.useComponentMultiStyle)("Carousel", {
|
|
317
496
|
...props,
|
|
318
497
|
orientation,
|
|
319
498
|
align,
|
|
@@ -342,27 +521,27 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
|
342
521
|
withIndicators = true,
|
|
343
522
|
indicatorsProps,
|
|
344
523
|
...computedProps
|
|
345
|
-
} = (0,
|
|
524
|
+
} = (0, import_core5.omitThemeProps)(mergedProps);
|
|
346
525
|
const computedWithControls = (0, import_use_value.useValue)(withControls);
|
|
347
526
|
const computedWithIndicators = (0, import_use_value.useValue)(withIndicators);
|
|
348
527
|
const { getContainerProps, getSlidesProps, children, ...rest } = useCarousel({
|
|
349
528
|
...computedProps
|
|
350
529
|
});
|
|
351
|
-
const validChildren = (0,
|
|
352
|
-
const [customCarouselControlPrev] = (0,
|
|
530
|
+
const validChildren = (0, import_utils5.getValidChildren)(children);
|
|
531
|
+
const [customCarouselControlPrev] = (0, import_utils5.findChildren)(
|
|
353
532
|
validChildren,
|
|
354
533
|
CarouselControlPrev
|
|
355
534
|
);
|
|
356
|
-
const [customCarouselControlNext] = (0,
|
|
535
|
+
const [customCarouselControlNext] = (0, import_utils5.findChildren)(
|
|
357
536
|
validChildren,
|
|
358
537
|
CarouselControlNext
|
|
359
538
|
);
|
|
360
|
-
const [customCarouselIndicators] = (0,
|
|
539
|
+
const [customCarouselIndicators] = (0, import_utils5.findChildren)(
|
|
361
540
|
validChildren,
|
|
362
541
|
CarouselIndicators
|
|
363
542
|
);
|
|
364
|
-
const slideChildren = (0,
|
|
365
|
-
const otherChildren = (0,
|
|
543
|
+
const slideChildren = (0, import_utils5.pickChildren)(validChildren, CarouselSlide);
|
|
544
|
+
const otherChildren = (0, import_utils5.omitChildren)(
|
|
366
545
|
validChildren,
|
|
367
546
|
CarouselControlPrev,
|
|
368
547
|
CarouselControlNext,
|
|
@@ -370,14 +549,14 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
|
370
549
|
CarouselSlide
|
|
371
550
|
);
|
|
372
551
|
const cloneSlideChildren = slideChildren.map(
|
|
373
|
-
(child, index) => (0,
|
|
552
|
+
(child, index) => (0, import_react3.cloneElement)(child, { index })
|
|
374
553
|
);
|
|
375
554
|
h != null ? h : h = height;
|
|
376
555
|
minH != null ? minH : minH = minHeight;
|
|
377
|
-
return /* @__PURE__ */ (0,
|
|
378
|
-
|
|
556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
557
|
+
import_core5.ui.div,
|
|
379
558
|
{
|
|
380
|
-
className: (0,
|
|
559
|
+
className: (0, import_utils5.cx)("ui-carousel", className),
|
|
381
560
|
__css: {
|
|
382
561
|
position: "relative",
|
|
383
562
|
h: "fit-content",
|
|
@@ -385,29 +564,29 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
|
385
564
|
},
|
|
386
565
|
...getContainerProps({}, ref),
|
|
387
566
|
children: [
|
|
388
|
-
customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ (0,
|
|
389
|
-
customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ (0,
|
|
390
|
-
/* @__PURE__ */ (0,
|
|
567
|
+
customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselControlPrev, { ...controlProps, ...controlPrevProps }) : null,
|
|
568
|
+
customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselControlNext, { ...controlProps, ...controlNextProps }) : null,
|
|
569
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
391
570
|
CarouselSlides,
|
|
392
571
|
{
|
|
393
572
|
...getSlidesProps({
|
|
394
|
-
...(0,
|
|
573
|
+
...(0, import_utils5.filterUndefined)({ h, minH }),
|
|
395
574
|
...innerProps
|
|
396
575
|
}),
|
|
397
576
|
children: cloneSlideChildren
|
|
398
577
|
}
|
|
399
578
|
),
|
|
400
|
-
customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0,
|
|
579
|
+
customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicators, { ...indicatorsProps }) : null,
|
|
401
580
|
otherChildren
|
|
402
581
|
]
|
|
403
582
|
}
|
|
404
583
|
) });
|
|
405
584
|
}
|
|
406
585
|
);
|
|
407
|
-
var CarouselSlides = (0,
|
|
586
|
+
var CarouselSlides = (0, import_core5.forwardRef)(
|
|
408
587
|
({ ...rest }, ref) => {
|
|
409
588
|
const css = { w: "100%", h: "fit-content", overflow: "hidden" };
|
|
410
|
-
return /* @__PURE__ */ (0,
|
|
589
|
+
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 }) });
|
|
411
590
|
}
|
|
412
591
|
);
|
|
413
592
|
var CarouselSlidesInner = ({ ...rest }) => {
|
|
@@ -421,184 +600,7 @@ var CarouselSlidesInner = ({ ...rest }) => {
|
|
|
421
600
|
[orientation === "vertical" ? "mb" : "mr"]: "calc($gap * -1)"
|
|
422
601
|
} : {}
|
|
423
602
|
};
|
|
424
|
-
return /* @__PURE__ */ (0,
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
// src/carousel-slide.tsx
|
|
428
|
-
var import_core3 = require("@yamada-ui/core");
|
|
429
|
-
var import_utils3 = require("@yamada-ui/utils");
|
|
430
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
431
|
-
var CarouselSlide = (0, import_core3.forwardRef)(
|
|
432
|
-
({ className, size, ...rest }, ref) => {
|
|
433
|
-
const { slideSize, includeGapInSize, orientation, gap } = useCarouselContext();
|
|
434
|
-
const { getSlideProps } = useCarouselSlide(rest);
|
|
435
|
-
size != null ? size : size = slideSize;
|
|
436
|
-
const css = {
|
|
437
|
-
position: "relative",
|
|
438
|
-
flex: `0 0 ${size}`,
|
|
439
|
-
...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
|
|
440
|
-
};
|
|
441
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
442
|
-
import_core3.ui.div,
|
|
443
|
-
{
|
|
444
|
-
className: (0, import_utils3.cx)("ui-carousel__slide", className),
|
|
445
|
-
__css: css,
|
|
446
|
-
...getSlideProps({}),
|
|
447
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CarouselSlideInner, { ref, ...rest })
|
|
448
|
-
}
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
);
|
|
452
|
-
var CarouselSlideInner = (0, import_core3.forwardRef)(
|
|
453
|
-
({ ...rest }, ref) => {
|
|
454
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
455
|
-
import_core3.ui.div,
|
|
456
|
-
{
|
|
457
|
-
ref,
|
|
458
|
-
className: "ui-carousel__slide__inner",
|
|
459
|
-
w: "100%",
|
|
460
|
-
h: "100%",
|
|
461
|
-
...rest
|
|
462
|
-
}
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
|
-
|
|
467
|
-
// src/carousel-control.tsx
|
|
468
|
-
var import_button = require("@yamada-ui/button");
|
|
469
|
-
var import_core4 = require("@yamada-ui/core");
|
|
470
|
-
var import_icon = require("@yamada-ui/icon");
|
|
471
|
-
var import_utils4 = require("@yamada-ui/utils");
|
|
472
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
473
|
-
var CarouselControlPrev = (0, import_core4.forwardRef)(
|
|
474
|
-
({ className, ...rest }, ref) => {
|
|
475
|
-
const { orientation } = useCarouselContext();
|
|
476
|
-
const { getControlProps } = useCarouselControl({ operation: "prev" });
|
|
477
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
478
|
-
CarouselControl,
|
|
479
|
-
{
|
|
480
|
-
operation: "prev",
|
|
481
|
-
className: (0, import_utils4.cx)("ui-carousel__control--prev", className),
|
|
482
|
-
"aria-label": "Go to previous slide",
|
|
483
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
484
|
-
import_icon.ChevronIcon,
|
|
485
|
-
{
|
|
486
|
-
__css: {
|
|
487
|
-
fontSize: "1.5em",
|
|
488
|
-
transform: orientation === "vertical" ? "rotate(180deg)" : "rotate(90deg)"
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
),
|
|
492
|
-
...getControlProps(rest, ref)
|
|
493
|
-
}
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
);
|
|
497
|
-
var CarouselControlNext = (0, import_core4.forwardRef)(
|
|
498
|
-
({ className, ...rest }, ref) => {
|
|
499
|
-
const { orientation } = useCarouselContext();
|
|
500
|
-
const { getControlProps } = useCarouselControl({ operation: "next" });
|
|
501
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
502
|
-
CarouselControl,
|
|
503
|
-
{
|
|
504
|
-
operation: "next",
|
|
505
|
-
className: (0, import_utils4.cx)("ui-carousel__control--next", className),
|
|
506
|
-
"aria-label": "Go to next slide",
|
|
507
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
508
|
-
import_icon.ChevronIcon,
|
|
509
|
-
{
|
|
510
|
-
__css: {
|
|
511
|
-
fontSize: "1.5em",
|
|
512
|
-
transform: orientation === "vertical" ? "rotate(0deg)" : "rotate(-90deg)"
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
),
|
|
516
|
-
...getControlProps(rest, ref)
|
|
517
|
-
}
|
|
518
|
-
);
|
|
519
|
-
}
|
|
520
|
-
);
|
|
521
|
-
var CarouselControl = (0, import_core4.forwardRef)(({ className, operation, ...rest }, ref) => {
|
|
522
|
-
const { styles } = useCarouselContext();
|
|
523
|
-
const colorScheme = (0, import_core4.useColorModeValue)("whiteAlpha", "blackAlpha");
|
|
524
|
-
const css = {
|
|
525
|
-
position: "absolute",
|
|
526
|
-
zIndex: "fallback(kurillin, 9)",
|
|
527
|
-
...styles.control,
|
|
528
|
-
...styles[operation]
|
|
529
|
-
};
|
|
530
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
531
|
-
import_button.IconButton,
|
|
532
|
-
{
|
|
533
|
-
ref,
|
|
534
|
-
className: (0, import_utils4.cx)("ui-carousel__control", className),
|
|
535
|
-
colorScheme,
|
|
536
|
-
isRounded: true,
|
|
537
|
-
__css: css,
|
|
538
|
-
...rest
|
|
539
|
-
}
|
|
540
|
-
);
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
// src/carousel-indicators.tsx
|
|
544
|
-
var import_core5 = require("@yamada-ui/core");
|
|
545
|
-
var import_utils5 = require("@yamada-ui/utils");
|
|
546
|
-
var import_react3 = require("react");
|
|
547
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
548
|
-
var CarouselIndicators = (0, import_core5.forwardRef)(
|
|
549
|
-
({ className, component, ...rest }, ref) => {
|
|
550
|
-
const { selectedIndex, orientation, styles } = useCarouselContext();
|
|
551
|
-
const { indexes, getIndicatorProps } = useCarouselIndicators();
|
|
552
|
-
const css = {
|
|
553
|
-
position: "absolute",
|
|
554
|
-
zIndex: "fallback(kurillin, 9)",
|
|
555
|
-
display: "flex",
|
|
556
|
-
justifyContent: "center",
|
|
557
|
-
...styles.indicators,
|
|
558
|
-
...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
|
|
559
|
-
};
|
|
560
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
561
|
-
import_core5.ui.div,
|
|
562
|
-
{
|
|
563
|
-
ref,
|
|
564
|
-
className: (0, import_utils5.cx)("ui-carousel__indicators", className),
|
|
565
|
-
__css: css,
|
|
566
|
-
...rest,
|
|
567
|
-
children: indexes.map((index) => {
|
|
568
|
-
const isSelected = index === selectedIndex;
|
|
569
|
-
if (typeof component === "function") {
|
|
570
|
-
const child = component({
|
|
571
|
-
index,
|
|
572
|
-
isSelected
|
|
573
|
-
});
|
|
574
|
-
if (!child) return null;
|
|
575
|
-
const props = getIndicatorProps({ ...child.props, index });
|
|
576
|
-
return (0, import_react3.cloneElement)(child, props);
|
|
577
|
-
} else {
|
|
578
|
-
const { key, ...props } = getIndicatorProps({ index });
|
|
579
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicator, { ...props }, key);
|
|
580
|
-
}
|
|
581
|
-
})
|
|
582
|
-
}
|
|
583
|
-
);
|
|
584
|
-
}
|
|
585
|
-
);
|
|
586
|
-
var CarouselIndicator = ({
|
|
587
|
-
className,
|
|
588
|
-
...rest
|
|
589
|
-
}) => {
|
|
590
|
-
const { styles } = useCarouselContext();
|
|
591
|
-
const css = { ...styles.indicator };
|
|
592
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
593
|
-
import_core5.ui.button,
|
|
594
|
-
{
|
|
595
|
-
type: "button",
|
|
596
|
-
tabIndex: -1,
|
|
597
|
-
className: (0, import_utils5.cx)("ui-carousel__indicators__indicator", className),
|
|
598
|
-
__css: css,
|
|
599
|
-
...rest
|
|
600
|
-
}
|
|
601
|
-
);
|
|
603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core5.ui.div, { className: "ui-carousel__sliders__inner", __css: css, ...rest });
|
|
602
604
|
};
|
|
603
605
|
// Annotate the CommonJS export names for ESM import in node:
|
|
604
606
|
0 && (module.exports = {
|