@yamada-ui/carousel 3.0.0-next-20240908154823 → 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.
- 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 +75 -71
- package/dist/carousel.js.map +1 -1
- package/dist/carousel.mjs +5 -5
- package/dist/{chunk-XJHVMEOT.mjs → chunk-KDTZL7V5.mjs} +11 -9
- package/dist/chunk-KDTZL7V5.mjs.map +1 -0
- package/dist/{chunk-ASHU4NCB.mjs → chunk-OW2M7LIB.mjs} +2 -2
- package/dist/chunk-OW2M7LIB.mjs.map +1 -0
- package/dist/{chunk-O7UZOX72.mjs → chunk-PDUQUV53.mjs} +2 -2
- package/dist/chunk-PDUQUV53.mjs.map +1 -0
- package/dist/{chunk-FX52VXMU.mjs → chunk-X4MS32G3.mjs} +2 -2
- package/dist/chunk-X4MS32G3.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 +201 -197
- 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-ASHU4NCB.mjs.map +0 -1
- package/dist/chunk-FX52VXMU.mjs.map +0 -1
- package/dist/chunk-H4J2Q2O6.mjs.map +0 -1
- package/dist/chunk-O7UZOX72.mjs.map +0 -1
- package/dist/chunk-XJHVMEOT.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;AAAA,EAC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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,176 @@ 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
|
+
...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)(
|
296
469
|
({ h, height, minH, minHeight, ...props }, ref) => {
|
297
470
|
var _a, _b;
|
298
471
|
const orientation = (0, import_use_value.useValue)(props.orientation);
|
@@ -309,9 +482,11 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
309
482
|
const skipSnaps = (0, import_use_value.useValue)(props.skipSnaps);
|
310
483
|
const containScroll = (0, import_use_value.useValue)(props.containScroll);
|
311
484
|
const includeGapInSize = (0, import_use_value.useValue)(props.includeGapInSize);
|
312
|
-
const
|
313
|
-
const
|
314
|
-
const
|
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", {
|
315
490
|
...props,
|
316
491
|
orientation,
|
317
492
|
align,
|
@@ -340,27 +515,27 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
340
515
|
withIndicators = true,
|
341
516
|
indicatorsProps,
|
342
517
|
...computedProps
|
343
|
-
} = (0,
|
518
|
+
} = (0, import_core5.omitThemeProps)(mergedProps);
|
344
519
|
const computedWithControls = (0, import_use_value.useValue)(withControls);
|
345
520
|
const computedWithIndicators = (0, import_use_value.useValue)(withIndicators);
|
346
521
|
const { getContainerProps, getSlidesProps, children, ...rest } = useCarousel({
|
347
522
|
...computedProps
|
348
523
|
});
|
349
|
-
const validChildren = (0,
|
350
|
-
const [customCarouselControlPrev] = (0,
|
524
|
+
const validChildren = (0, import_utils5.getValidChildren)(children);
|
525
|
+
const [customCarouselControlPrev] = (0, import_utils5.findChildren)(
|
351
526
|
validChildren,
|
352
527
|
CarouselControlPrev
|
353
528
|
);
|
354
|
-
const [customCarouselControlNext] = (0,
|
529
|
+
const [customCarouselControlNext] = (0, import_utils5.findChildren)(
|
355
530
|
validChildren,
|
356
531
|
CarouselControlNext
|
357
532
|
);
|
358
|
-
const [customCarouselIndicators] = (0,
|
533
|
+
const [customCarouselIndicators] = (0, import_utils5.findChildren)(
|
359
534
|
validChildren,
|
360
535
|
CarouselIndicators
|
361
536
|
);
|
362
|
-
const slideChildren = (0,
|
363
|
-
const otherChildren = (0,
|
537
|
+
const slideChildren = (0, import_utils5.pickChildren)(validChildren, CarouselSlide);
|
538
|
+
const otherChildren = (0, import_utils5.omitChildren)(
|
364
539
|
validChildren,
|
365
540
|
CarouselControlPrev,
|
366
541
|
CarouselControlNext,
|
@@ -368,42 +543,42 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
368
543
|
CarouselSlide
|
369
544
|
);
|
370
545
|
const cloneSlideChildren = slideChildren.map(
|
371
|
-
(child, index) => (0,
|
546
|
+
(child, index) => (0, import_react3.cloneElement)(child, { index })
|
372
547
|
);
|
373
548
|
h != null ? h : h = height;
|
374
549
|
minH != null ? minH : minH = minHeight;
|
375
|
-
return /* @__PURE__ */ (0,
|
376
|
-
|
550
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
551
|
+
import_core5.ui.div,
|
377
552
|
{
|
378
|
-
className: (0,
|
553
|
+
className: (0, import_utils5.cx)("ui-carousel", className),
|
379
554
|
__css: {
|
380
555
|
...styles.container
|
381
556
|
},
|
382
557
|
...getContainerProps({}, ref),
|
383
558
|
children: [
|
384
|
-
customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ (0,
|
385
|
-
customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ (0,
|
386
|
-
/* @__PURE__ */ (0,
|
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)(
|
387
562
|
CarouselSlides,
|
388
563
|
{
|
389
564
|
...getSlidesProps({
|
390
|
-
...(0,
|
565
|
+
...(0, import_utils5.filterUndefined)({ h, minH }),
|
391
566
|
...innerProps
|
392
567
|
}),
|
393
568
|
children: cloneSlideChildren
|
394
569
|
}
|
395
570
|
),
|
396
|
-
customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0,
|
571
|
+
customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicators, { ...indicatorsProps }) : null,
|
397
572
|
otherChildren
|
398
573
|
]
|
399
574
|
}
|
400
575
|
) });
|
401
576
|
}
|
402
577
|
);
|
403
|
-
var CarouselSlides = (0,
|
578
|
+
var CarouselSlides = (0, import_core5.forwardRef)(
|
404
579
|
({ ...rest }, ref) => {
|
405
580
|
const css = { w: "100%", h: "fit-content", overflow: "hidden" };
|
406
|
-
return /* @__PURE__ */ (0,
|
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 }) });
|
407
582
|
}
|
408
583
|
);
|
409
584
|
var CarouselSlidesInner = ({ ...rest }) => {
|
@@ -416,178 +591,7 @@ var CarouselSlidesInner = ({ ...rest }) => {
|
|
416
591
|
[orientation === "vertical" ? "mb" : "mr"]: "calc($gap * -1)"
|
417
592
|
} : {}
|
418
593
|
};
|
419
|
-
return /* @__PURE__ */ (0,
|
420
|
-
};
|
421
|
-
|
422
|
-
// src/carousel-slide.tsx
|
423
|
-
var import_core3 = require("@yamada-ui/core");
|
424
|
-
var import_utils3 = require("@yamada-ui/utils");
|
425
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
426
|
-
var CarouselSlide = (0, import_core3.forwardRef)(
|
427
|
-
({ className, size, ...rest }, ref) => {
|
428
|
-
const { slideSize, includeGapInSize, orientation, gap } = useCarouselContext();
|
429
|
-
const { getSlideProps } = useCarouselSlide(rest);
|
430
|
-
size != null ? size : size = slideSize;
|
431
|
-
const css = {
|
432
|
-
position: "relative",
|
433
|
-
flex: `0 0 ${size}`,
|
434
|
-
...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
|
435
|
-
};
|
436
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
437
|
-
import_core3.ui.div,
|
438
|
-
{
|
439
|
-
className: (0, import_utils3.cx)("ui-carousel__slide", className),
|
440
|
-
__css: css,
|
441
|
-
...getSlideProps({}),
|
442
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CarouselSlideInner, { ref, ...rest })
|
443
|
-
}
|
444
|
-
);
|
445
|
-
}
|
446
|
-
);
|
447
|
-
var CarouselSlideInner = (0, import_core3.forwardRef)(
|
448
|
-
({ ...rest }, ref) => {
|
449
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
450
|
-
import_core3.ui.div,
|
451
|
-
{
|
452
|
-
ref,
|
453
|
-
className: "ui-carousel__slide-inner",
|
454
|
-
w: "100%",
|
455
|
-
h: "100%",
|
456
|
-
...rest
|
457
|
-
}
|
458
|
-
);
|
459
|
-
}
|
460
|
-
);
|
461
|
-
|
462
|
-
// src/carousel-control.tsx
|
463
|
-
var import_button = require("@yamada-ui/button");
|
464
|
-
var import_core4 = require("@yamada-ui/core");
|
465
|
-
var import_icon = require("@yamada-ui/icon");
|
466
|
-
var import_utils4 = require("@yamada-ui/utils");
|
467
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
468
|
-
var CarouselControlPrev = (0, import_core4.forwardRef)(
|
469
|
-
({ className, ...rest }, ref) => {
|
470
|
-
const { orientation } = useCarouselContext();
|
471
|
-
const { getControlProps } = useCarouselControl({ operation: "prev" });
|
472
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
473
|
-
CarouselControl,
|
474
|
-
{
|
475
|
-
operation: "prev",
|
476
|
-
className: (0, import_utils4.cx)("ui-carousel__control--prev", className),
|
477
|
-
"aria-label": "Go to previous slide",
|
478
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
479
|
-
import_icon.ChevronIcon,
|
480
|
-
{
|
481
|
-
__css: {
|
482
|
-
fontSize: "1.5em",
|
483
|
-
transform: orientation === "vertical" ? "rotate(180deg)" : "rotate(90deg)"
|
484
|
-
}
|
485
|
-
}
|
486
|
-
),
|
487
|
-
...getControlProps(rest, ref)
|
488
|
-
}
|
489
|
-
);
|
490
|
-
}
|
491
|
-
);
|
492
|
-
var CarouselControlNext = (0, import_core4.forwardRef)(
|
493
|
-
({ className, ...rest }, ref) => {
|
494
|
-
const { orientation } = useCarouselContext();
|
495
|
-
const { getControlProps } = useCarouselControl({ operation: "next" });
|
496
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
497
|
-
CarouselControl,
|
498
|
-
{
|
499
|
-
operation: "next",
|
500
|
-
className: (0, import_utils4.cx)("ui-carousel__control--next", className),
|
501
|
-
"aria-label": "Go to next slide",
|
502
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
503
|
-
import_icon.ChevronIcon,
|
504
|
-
{
|
505
|
-
__css: {
|
506
|
-
fontSize: "1.5em",
|
507
|
-
transform: orientation === "vertical" ? "rotate(0deg)" : "rotate(-90deg)"
|
508
|
-
}
|
509
|
-
}
|
510
|
-
),
|
511
|
-
...getControlProps(rest, ref)
|
512
|
-
}
|
513
|
-
);
|
514
|
-
}
|
515
|
-
);
|
516
|
-
var CarouselControl = (0, import_core4.forwardRef)(({ className, operation, ...rest }, ref) => {
|
517
|
-
const { styles } = useCarouselContext();
|
518
|
-
const colorScheme = (0, import_core4.useColorModeValue)("whiteAlpha", "blackAlpha");
|
519
|
-
const css = {
|
520
|
-
...styles.control,
|
521
|
-
...styles[operation]
|
522
|
-
};
|
523
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
524
|
-
import_button.IconButton,
|
525
|
-
{
|
526
|
-
ref,
|
527
|
-
className: (0, import_utils4.cx)("ui-carousel__control", className),
|
528
|
-
colorScheme,
|
529
|
-
isRounded: true,
|
530
|
-
__css: css,
|
531
|
-
...rest
|
532
|
-
}
|
533
|
-
);
|
534
|
-
});
|
535
|
-
|
536
|
-
// src/carousel-indicators.tsx
|
537
|
-
var import_core5 = require("@yamada-ui/core");
|
538
|
-
var import_utils5 = require("@yamada-ui/utils");
|
539
|
-
var import_react3 = require("react");
|
540
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
541
|
-
var CarouselIndicators = (0, import_core5.forwardRef)(
|
542
|
-
({ className, component, ...rest }, ref) => {
|
543
|
-
const { selectedIndex, orientation, styles } = useCarouselContext();
|
544
|
-
const { indexes, getIndicatorProps } = useCarouselIndicators();
|
545
|
-
const css = {
|
546
|
-
...styles.indicators,
|
547
|
-
...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
|
548
|
-
};
|
549
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
550
|
-
import_core5.ui.div,
|
551
|
-
{
|
552
|
-
ref,
|
553
|
-
className: (0, import_utils5.cx)("ui-carousel__indicators", className),
|
554
|
-
__css: css,
|
555
|
-
...rest,
|
556
|
-
children: indexes.map((index) => {
|
557
|
-
const isSelected = index === selectedIndex;
|
558
|
-
if (typeof component === "function") {
|
559
|
-
const child = component({
|
560
|
-
index,
|
561
|
-
isSelected
|
562
|
-
});
|
563
|
-
if (!child) return null;
|
564
|
-
const props = getIndicatorProps({ ...child.props, index });
|
565
|
-
return (0, import_react3.cloneElement)(child, props);
|
566
|
-
} else {
|
567
|
-
const { key, ...props } = getIndicatorProps({ index });
|
568
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicator, { ...props }, key);
|
569
|
-
}
|
570
|
-
})
|
571
|
-
}
|
572
|
-
);
|
573
|
-
}
|
574
|
-
);
|
575
|
-
var CarouselIndicator = ({
|
576
|
-
className,
|
577
|
-
...rest
|
578
|
-
}) => {
|
579
|
-
const { styles } = useCarouselContext();
|
580
|
-
const css = { ...styles.indicator };
|
581
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
582
|
-
import_core5.ui.button,
|
583
|
-
{
|
584
|
-
type: "button",
|
585
|
-
tabIndex: -1,
|
586
|
-
className: (0, import_utils5.cx)("ui-carousel__indicator", className),
|
587
|
-
__css: css,
|
588
|
-
...rest
|
589
|
-
}
|
590
|
-
);
|
594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core5.ui.div, { className: "ui-carousel__sliders-inner", __css: css, ...rest });
|
591
595
|
};
|
592
596
|
// Annotate the CommonJS export names for ESM import in node:
|
593
597
|
0 && (module.exports = {
|