@yamada-ui/carousel 2.0.7-dev-20241005224505 → 2.0.7-dev-20241006032009

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/dist/carousel-control.js +4 -4
  2. package/dist/carousel-control.js.map +1 -1
  3. package/dist/carousel-control.mjs +2 -2
  4. package/dist/carousel-indicators.js +5 -5
  5. package/dist/carousel-indicators.js.map +1 -1
  6. package/dist/carousel-indicators.mjs +2 -2
  7. package/dist/carousel-slide.js +4 -4
  8. package/dist/carousel-slide.js.map +1 -1
  9. package/dist/carousel-slide.mjs +2 -2
  10. package/dist/carousel.d.mts +47 -47
  11. package/dist/carousel.d.ts +47 -47
  12. package/dist/carousel.js +57 -57
  13. package/dist/carousel.js.map +1 -1
  14. package/dist/carousel.mjs +5 -5
  15. package/dist/{chunk-W6XPFRNI.mjs → chunk-EWXY4PR7.mjs} +7 -7
  16. package/dist/chunk-EWXY4PR7.mjs.map +1 -0
  17. package/dist/{chunk-LV5JHVV6.mjs → chunk-O4PTHTS2.mjs} +28 -28
  18. package/dist/chunk-O4PTHTS2.mjs.map +1 -0
  19. package/dist/{chunk-LRO4RIBJ.mjs → chunk-PT5TQ6V4.mjs} +27 -27
  20. package/dist/chunk-PT5TQ6V4.mjs.map +1 -0
  21. package/dist/{chunk-T3LMURPY.mjs → chunk-ULHGDRXH.mjs} +6 -6
  22. package/dist/chunk-ULHGDRXH.mjs.map +1 -0
  23. package/dist/{chunk-OQNU22B2.mjs → chunk-WMW5LTJO.mjs} +6 -6
  24. package/dist/chunk-WMW5LTJO.mjs.map +1 -0
  25. package/dist/index.d.mts +1 -1
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +57 -57
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +5 -5
  30. package/dist/use-carousel.d.mts +98 -98
  31. package/dist/use-carousel.d.ts +98 -98
  32. package/dist/use-carousel.js +26 -26
  33. package/dist/use-carousel.js.map +1 -1
  34. package/dist/use-carousel.mjs +1 -1
  35. package/package.json +8 -8
  36. package/dist/chunk-LRO4RIBJ.mjs.map +0 -1
  37. package/dist/chunk-LV5JHVV6.mjs.map +0 -1
  38. package/dist/chunk-OQNU22B2.mjs.map +0 -1
  39. package/dist/chunk-T3LMURPY.mjs.map +0 -1
  40. package/dist/chunk-W6XPFRNI.mjs.map +0 -1
@@ -8,18 +8,18 @@ import 'react';
8
8
  import 'embla-carousel';
9
9
 
10
10
  interface CarouselOptions {
11
- /**
12
- * The orientation of the carousel.
13
- *
14
- * @default 'horizontal'
15
- */
16
- orientation?: Token<"vertical" | "horizontal">;
17
11
  /**
18
12
  * The alignment of the carousel.
19
13
  *
20
14
  * @default 'center'
21
15
  */
22
16
  align?: Token<AlignmentOptionType>;
17
+ /**
18
+ * If `true`, the carousel will be autoplay.
19
+ *
20
+ * @default false
21
+ */
22
+ autoplay?: Token<boolean>;
23
23
  /**
24
24
  * Clear leading and trailing empty space that causes excessive scrolling.
25
25
  * Use trimSnaps to only use snap points that trigger scrolling or keepSnaps to keep them.
@@ -28,11 +28,11 @@ interface CarouselOptions {
28
28
  */
29
29
  containScroll?: Token<ScrollContainOptionType>;
30
30
  /**
31
- * The number of slides that should be scrolled with next or previous buttons.
31
+ * The number for the autoplay interval of the carousel.
32
32
  *
33
- * @default 1
33
+ * @default 4000
34
34
  */
35
- slidesToScroll?: Token<number>;
35
+ delay?: Token<number>;
36
36
  /**
37
37
  * If `true`, momentum scrolling will be enabled.
38
38
  *
@@ -45,6 +45,20 @@ interface CarouselOptions {
45
45
  * @default true
46
46
  */
47
47
  draggable?: Token<boolean>;
48
+ /**
49
+ * Set scroll duration when triggered by any of the API methods.
50
+ * Higher numbers enables slower scrolling.
51
+ * Drag interactions are not affected because duration is then determined by the drag force.
52
+ *
53
+ * @default 25
54
+ */
55
+ duration?: Token<number>;
56
+ /**
57
+ * If `true`, gap will be treated as part of the carousel slide size.
58
+ *
59
+ * @default true
60
+ */
61
+ includeGapInSize?: Token<boolean>;
48
62
  /**
49
63
  * Choose a fraction representing the percentage portion of a slide that needs to be visible in order to be considered in view.
50
64
  *
@@ -58,6 +72,12 @@ interface CarouselOptions {
58
72
  * @default true
59
73
  */
60
74
  loop?: Token<boolean>;
75
+ /**
76
+ * The orientation of the carousel.
77
+ *
78
+ * @default 'horizontal'
79
+ */
80
+ orientation?: Token<"horizontal" | "vertical">;
61
81
  /**
62
82
  * If `true`, allow the carousel to skip scroll snaps if it's dragged vigorously.
63
83
  * Note that this option will be ignored if the dragFree option is set to true.
@@ -66,25 +86,15 @@ interface CarouselOptions {
66
86
  */
67
87
  skipSnaps?: Token<boolean>;
68
88
  /**
69
- * Set scroll duration when triggered by any of the API methods.
70
- * Higher numbers enables slower scrolling.
71
- * Drag interactions are not affected because duration is then determined by the drag force.
72
- *
73
- * @default 25
74
- */
75
- duration?: Token<number>;
76
- /**
77
- * The number for the autoplay interval of the carousel.
78
- *
79
- * @default 4000
89
+ * The CSS `width` property.
80
90
  */
81
- delay?: Token<number>;
91
+ slideSize?: CSSUIProps["width"];
82
92
  /**
83
- * If `true`, the carousel will be autoplay.
93
+ * The number of slides that should be scrolled with next or previous buttons.
84
94
  *
85
- * @default false
95
+ * @default 1
86
96
  */
87
- autoplay?: Token<boolean>;
97
+ slidesToScroll?: Token<number>;
88
98
  /**
89
99
  * If `true`, autoplay will pause when the mouse entries over.
90
100
  *
@@ -92,49 +102,39 @@ interface CarouselOptions {
92
102
  */
93
103
  stopMouseEnterAutoplay?: Token<boolean>;
94
104
  /**
95
- * If `true`, gap will be treated as part of the carousel slide size.
105
+ * If `true`, display the carousel control buttons.
96
106
  *
97
107
  * @default true
98
108
  */
99
- includeGapInSize?: Token<boolean>;
100
- /**
101
- * The CSS `width` property.
102
- */
103
- slideSize?: CSSUIProps["width"];
104
- /**
105
- * Props for carousel inner element.
106
- */
107
- innerProps?: HTMLUIProps;
109
+ withControls?: Token<boolean>;
108
110
  /**
109
- * If `true`, display the carousel control buttons.
111
+ * If `true`, display the carousel indicator buttons.
110
112
  *
111
113
  * @default true
112
114
  */
113
- withControls?: Token<boolean>;
115
+ withIndicators?: Token<boolean>;
114
116
  /**
115
- * Props for carousel control element.
117
+ * Props for next of the carousel control element.
116
118
  */
117
- controlProps?: CarouselControlProps;
119
+ controlNextProps?: CarouselControlProps;
118
120
  /**
119
121
  * Props for previous of the carousel control element.
120
122
  */
121
123
  controlPrevProps?: CarouselControlProps;
122
124
  /**
123
- * Props for next of the carousel control element.
124
- */
125
- controlNextProps?: CarouselControlProps;
126
- /**
127
- * If `true`, display the carousel indicator buttons.
128
- *
129
- * @default true
125
+ * Props for carousel control element.
130
126
  */
131
- withIndicators?: Token<boolean>;
127
+ controlProps?: CarouselControlProps;
132
128
  /**
133
129
  * Props for carousel indicators element.
134
130
  */
135
131
  indicatorsProps?: CarouselIndicatorsProps;
132
+ /**
133
+ * Props for carousel inner element.
134
+ */
135
+ innerProps?: HTMLUIProps;
136
136
  }
137
- interface CarouselProps extends ThemeProps<"Carousel">, Omit<HTMLUIProps, "onChange" | "draggable">, Pick<UseCarouselProps, "index" | "defaultIndex" | "onChange" | "onScrollProgress" | "watchDrag" | "watchResize" | "watchSlides" | "controlRef">, CarouselOptions {
137
+ interface CarouselProps extends ThemeProps<"Carousel">, Omit<HTMLUIProps, "draggable" | "onChange">, Pick<UseCarouselProps, "controlRef" | "defaultIndex" | "index" | "onChange" | "onScrollProgress" | "watchDrag" | "watchResize" | "watchSlides">, CarouselOptions {
138
138
  }
139
139
  /**
140
140
  * `Carousel` is a component that displays multiple elements like a slideshow.
package/dist/carousel.js CHANGED
@@ -57,51 +57,51 @@ var [CarouselProvider, useCarouselContext] = (0, import_utils.createContext)({
57
57
  errorMessage: `useCarouselContext returned is 'undefined'. Seems you forgot to wrap the components in "<Carousel />"`
58
58
  });
59
59
  var useCarousel = ({
60
- index,
61
- defaultIndex = 0,
62
- onChange,
63
60
  align = "center",
64
- orientation = "horizontal",
65
61
  autoplay = false,
66
- stopMouseEnterAutoplay = true,
67
- loop = true,
68
- duration = 25,
62
+ children,
63
+ containScroll = false,
64
+ controlRef,
65
+ defaultIndex = 0,
69
66
  delay = 4e3,
70
- slidesToScroll = 1,
71
- draggable = true,
72
67
  dragFree = false,
68
+ draggable = true,
69
+ duration = 25,
70
+ includeGapInSize = true,
71
+ index,
73
72
  inViewThreshold = 0,
73
+ loop = true,
74
+ orientation = "horizontal",
74
75
  skipSnaps = false,
75
- containScroll = false,
76
76
  slideSize = "100%",
77
- includeGapInSize = true,
78
- onScrollProgress,
77
+ slidesToScroll = 1,
78
+ stopMouseEnterAutoplay = true,
79
79
  watchDrag = draggable,
80
80
  watchResize = true,
81
81
  watchSlides = true,
82
- controlRef,
83
- children,
82
+ onChange,
83
+ onScrollProgress,
84
84
  ...rest
85
85
  }) => {
86
86
  const [{ gap = "fallback(4, 1rem)", ...containerProps }, slidesProps] = (0, import_utils.splitObject)(rest, import_core.layoutStyleProperties);
87
87
  const [selectedIndex, setSelectedIndex] = (0, import_use_controllable_state.useControllableState)({
88
- value: index,
89
88
  defaultValue: defaultIndex,
89
+ value: index,
90
90
  onChange
91
91
  });
92
92
  const isVertical = orientation === "vertical";
93
93
  const [carouselRef, carousel] = (0, import_embla_carousel_react.default)(
94
94
  {
95
- axis: isVertical ? "y" : "x",
96
- startIndex: defaultIndex,
97
- loop,
98
95
  align,
99
- slidesToScroll,
100
- duration,
96
+ axis: isVertical ? "y" : "x",
97
+ containScroll,
101
98
  dragFree,
99
+ duration,
102
100
  inViewThreshold,
101
+ loop,
103
102
  skipSnaps,
104
- containScroll,
103
+ slidesToScroll,
104
+ startIndex: defaultIndex,
105
105
  watchDrag,
106
106
  watchResize,
107
107
  watchSlides
@@ -211,20 +211,20 @@ var useCarousel = ({
211
211
  return {
212
212
  carousel,
213
213
  children,
214
+ gap,
215
+ includeGapInSize,
214
216
  indexes,
215
- selectedIndex,
216
217
  orientation,
218
+ selectedIndex,
217
219
  slideSize,
218
- gap,
219
220
  slidesToScroll,
220
- includeGapInSize,
221
221
  getContainerProps,
222
222
  getSlidesProps
223
223
  };
224
224
  };
225
225
  var useCarouselSlide = ({ index }) => {
226
226
  const { selectedIndex, slidesToScroll } = useCarouselContext();
227
- index = Math.floor((index != null ? index : 0) / (slidesToScroll != null ? slidesToScroll : 1));
227
+ index = Math.floor((index != null ? index : 0) / slidesToScroll);
228
228
  const isSelected = index === selectedIndex;
229
229
  const getSlideProps = (0, import_react.useCallback)(
230
230
  (props = {}) => ({
@@ -264,7 +264,7 @@ var useCarouselControl = ({
264
264
  return { getControlProps };
265
265
  };
266
266
  var useCarouselIndicators = () => {
267
- const { selectedIndex, carousel, indexes } = useCarouselContext();
267
+ const { carousel, indexes, selectedIndex } = useCarouselContext();
268
268
  const onClick = (0, import_react.useCallback)(
269
269
  (ev, index) => {
270
270
  if (!carousel) return;
@@ -299,9 +299,7 @@ var CarouselControlPrev = (0, import_core2.forwardRef)(
299
299
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
300
300
  CarouselControl,
301
301
  {
302
- operation: "prev",
303
302
  className: (0, import_utils2.cx)("ui-carousel__control--prev", className),
304
- "aria-label": "Go to previous slide",
305
303
  icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
306
304
  import_icon.ChevronIcon,
307
305
  {
@@ -311,6 +309,8 @@ var CarouselControlPrev = (0, import_core2.forwardRef)(
311
309
  }
312
310
  }
313
311
  ),
312
+ operation: "prev",
313
+ "aria-label": "Go to previous slide",
314
314
  ...getControlProps(rest, ref)
315
315
  }
316
316
  );
@@ -325,9 +325,7 @@ var CarouselControlNext = (0, import_core2.forwardRef)(
325
325
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
326
326
  CarouselControl,
327
327
  {
328
- operation: "next",
329
328
  className: (0, import_utils2.cx)("ui-carousel__control--next", className),
330
- "aria-label": "Go to next slide",
331
329
  icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
332
330
  import_icon.ChevronIcon,
333
331
  {
@@ -337,6 +335,8 @@ var CarouselControlNext = (0, import_core2.forwardRef)(
337
335
  }
338
336
  }
339
337
  ),
338
+ operation: "next",
339
+ "aria-label": "Go to next slide",
340
340
  ...getControlProps(rest, ref)
341
341
  }
342
342
  );
@@ -374,13 +374,13 @@ var import_react2 = require("react");
374
374
  var import_jsx_runtime2 = require("react/jsx-runtime");
375
375
  var CarouselIndicators = (0, import_core3.forwardRef)(
376
376
  ({ className, component, ...rest }, ref) => {
377
- const { selectedIndex, orientation, styles } = useCarouselContext();
377
+ const { orientation, selectedIndex, styles } = useCarouselContext();
378
378
  const { indexes, getIndicatorProps } = useCarouselIndicators();
379
379
  const css = {
380
- position: "absolute",
381
- zIndex: "fallback(kurillin, 9)",
382
380
  display: "flex",
383
381
  justifyContent: "center",
382
+ position: "absolute",
383
+ zIndex: "fallback(kurillin, 9)",
384
384
  ...styles.indicators,
385
385
  ...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
386
386
  };
@@ -422,8 +422,8 @@ var CarouselIndicator = ({
422
422
  import_core3.ui.button,
423
423
  {
424
424
  type: "button",
425
- tabIndex: -1,
426
425
  className: (0, import_utils3.cx)("ui-carousel__indicators__indicator", className),
426
+ tabIndex: -1,
427
427
  __css: css,
428
428
  ...rest
429
429
  }
@@ -438,12 +438,12 @@ var import_utils4 = require("@yamada-ui/utils");
438
438
  var import_jsx_runtime3 = require("react/jsx-runtime");
439
439
  var CarouselSlide = (0, import_core4.forwardRef)(
440
440
  ({ className, size, ...rest }, ref) => {
441
- const { slideSize, includeGapInSize, orientation, gap } = useCarouselContext();
441
+ const { gap, includeGapInSize, orientation, slideSize } = useCarouselContext();
442
442
  const { getSlideProps } = useCarouselSlide(rest);
443
443
  size != null ? size : size = slideSize;
444
444
  const css = {
445
- position: "relative",
446
445
  flex: `0 0 ${size}`,
446
+ position: "relative",
447
447
  ...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
448
448
  };
449
449
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -466,8 +466,8 @@ var CarouselSlideInner = (0, import_core4.forwardRef)(
466
466
  {
467
467
  ref,
468
468
  className: "ui-carousel__slide__inner",
469
- w: "100%",
470
469
  h: "100%",
470
+ w: "100%",
471
471
  ...rest
472
472
  }
473
473
  );
@@ -501,37 +501,37 @@ var Carousel = (0, import_core5.forwardRef)(
501
501
  const slideSize = (_b = (0, import_use_token.useToken)("sizes", _slideSize)) != null ? _b : _slideSize;
502
502
  const [styles, mergedProps] = (0, import_core5.useComponentMultiStyle)("Carousel", {
503
503
  ...props,
504
- orientation,
505
504
  align,
506
505
  autoplay,
507
- stopMouseEnterAutoplay,
508
- loop,
509
- duration,
506
+ containScroll,
510
507
  delay,
511
- slidesToScroll,
512
- draggable,
513
508
  dragFree,
509
+ draggable,
510
+ duration,
511
+ gap,
512
+ includeGapInSize,
514
513
  inViewThreshold,
514
+ loop,
515
+ orientation,
515
516
  skipSnaps,
516
- containScroll,
517
- includeGapInSize,
518
- gap,
519
- slideSize
517
+ slideSize,
518
+ slidesToScroll,
519
+ stopMouseEnterAutoplay
520
520
  });
521
521
  const {
522
522
  className,
523
- innerProps,
524
523
  withControls = true,
525
- controlProps,
526
- controlPrevProps,
527
- controlNextProps,
528
524
  withIndicators = true,
525
+ controlNextProps,
526
+ controlPrevProps,
527
+ controlProps,
529
528
  indicatorsProps,
529
+ innerProps,
530
530
  ...computedProps
531
531
  } = (0, import_core5.omitThemeProps)(mergedProps);
532
532
  const computedWithControls = (0, import_use_value.useValue)(withControls);
533
533
  const computedWithIndicators = (0, import_use_value.useValue)(withIndicators);
534
- const { getContainerProps, getSlidesProps, children, ...rest } = useCarousel({
534
+ const { children, getContainerProps, getSlidesProps, ...rest } = useCarousel({
535
535
  ...computedProps
536
536
  });
537
537
  const validChildren = (0, import_utils5.getValidChildren)(children);
@@ -565,8 +565,8 @@ var Carousel = (0, import_core5.forwardRef)(
565
565
  {
566
566
  className: (0, import_utils5.cx)("ui-carousel", className),
567
567
  __css: {
568
- position: "relative",
569
568
  h: "fit-content",
569
+ position: "relative",
570
570
  ...styles.container
571
571
  },
572
572
  ...getContainerProps({}, ref),
@@ -594,21 +594,21 @@ Carousel.displayName = "Carousel";
594
594
  Carousel.__ui__ = "Carousel";
595
595
  var CarouselSlides = (0, import_core5.forwardRef)(
596
596
  ({ ...rest }, ref) => {
597
- const css = { w: "100%", h: "fit-content", overflow: "hidden" };
597
+ const css = { h: "fit-content", overflow: "hidden", w: "100%" };
598
598
  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 }) });
599
599
  }
600
600
  );
601
601
  CarouselSlides.displayName = "CarouselSlides";
602
602
  CarouselSlides.__ui__ = "CarouselSlides";
603
603
  var CarouselSlidesInner = ({ ...rest }) => {
604
- const { orientation, includeGapInSize, gap, styles } = useCarouselContext();
604
+ const { gap, includeGapInSize, orientation, styles } = useCarouselContext();
605
605
  const css = {
606
606
  display: "flex",
607
607
  flexDirection: orientation === "vertical" ? "column" : "row",
608
608
  ...styles.inner,
609
609
  ...includeGapInSize ? {
610
- vars: [{ name: "gap", token: "spaces", value: gap }],
611
- [orientation === "vertical" ? "mb" : "mr"]: "calc($gap * -1)"
610
+ [orientation === "vertical" ? "mb" : "mr"]: "calc($gap * -1)",
611
+ vars: [{ name: "gap", token: "spaces", value: gap }]
612
612
  } : {}
613
613
  };
614
614
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core5.ui.div, { className: "ui-carousel__sliders__inner", __css: css, ...rest });