@yamada-ui/carousel 0.1.0

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/index.js ADDED
@@ -0,0 +1,529 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ Carousel: () => Carousel,
34
+ CarouselControlNext: () => CarouselControlNext,
35
+ CarouselControlPrev: () => CarouselControlPrev,
36
+ CarouselIndicators: () => CarouselIndicators,
37
+ CarouselSlide: () => CarouselSlide
38
+ });
39
+ module.exports = __toCommonJS(src_exports);
40
+
41
+ // src/carousel.tsx
42
+ var import_core2 = require("@yamada-ui/core");
43
+ var import_use_token = require("@yamada-ui/use-token");
44
+ var import_use_value = require("@yamada-ui/use-value");
45
+ var import_utils2 = require("@yamada-ui/utils");
46
+ var import_react2 = require("react");
47
+
48
+ // src/use-carousel.ts
49
+ var import_core = require("@yamada-ui/core");
50
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
51
+ var import_utils = require("@yamada-ui/utils");
52
+ var import_embla_carousel_react = __toESM(require("embla-carousel-react"));
53
+ var import_react = require("react");
54
+ var [CarouselProvider, useCarouselContext] = (0, import_utils.createContext)({
55
+ name: "CarouselContext",
56
+ errorMessage: `useCarouselContext returned is 'undefined'. Seems you forgot to wrap the components in "<Carousel />"`
57
+ });
58
+ var useCarousel = ({
59
+ index,
60
+ defaultIndex = 0,
61
+ onChange,
62
+ align = "center",
63
+ orientation = "horizontal",
64
+ autoplay = false,
65
+ stopMouseEnterAutoplay = true,
66
+ loop = true,
67
+ speed = 10,
68
+ delay = 4e3,
69
+ gap = "md",
70
+ slidesToScroll = 1,
71
+ draggable = true,
72
+ dragFree = false,
73
+ inViewThreshold = 0,
74
+ skipSnaps = false,
75
+ containScroll = "",
76
+ slideSize = "100%",
77
+ includeGapInSize = true,
78
+ onScrollProgress,
79
+ children,
80
+ ...rest
81
+ }) => {
82
+ const computedProps = (0, import_utils.splitObject)(rest, import_core.layoutStylesProperties);
83
+ const [selectedIndex, setSelectedIndex] = (0, import_use_controllable_state.useControllableState)({
84
+ value: index,
85
+ defaultValue: defaultIndex,
86
+ onChange
87
+ });
88
+ const isVertical = orientation === "vertical";
89
+ const [carouselRef, carousel] = (0, import_embla_carousel_react.default)({
90
+ axis: isVertical ? "y" : "x",
91
+ startIndex: defaultIndex,
92
+ loop,
93
+ align,
94
+ slidesToScroll,
95
+ draggable,
96
+ dragFree,
97
+ speed,
98
+ inViewThreshold,
99
+ skipSnaps,
100
+ containScroll
101
+ });
102
+ const [indexes, setIndexes] = (0, import_react.useState)([]);
103
+ const [isMouseEnter, setIsMouseEnter] = (0, import_react.useState)(false);
104
+ const timeoutId = (0, import_react.useRef)(void 0);
105
+ const onScroll = (0, import_react.useCallback)(() => {
106
+ if (!carousel)
107
+ return;
108
+ const progress = Math.round(Math.max(0, Math.min(1, carousel.scrollProgress())) * 100);
109
+ onScrollProgress == null ? void 0 : onScrollProgress(progress);
110
+ }, [carousel, onScrollProgress]);
111
+ const onSelect = (0, import_react.useCallback)(() => {
112
+ if (!carousel)
113
+ return;
114
+ const index2 = carousel.selectedScrollSnap();
115
+ setSelectedIndex(index2);
116
+ }, [carousel, setSelectedIndex]);
117
+ (0, import_react.useEffect)(() => {
118
+ const isStop = isMouseEnter && stopMouseEnterAutoplay;
119
+ const isLast = !(carousel == null ? void 0 : carousel.canScrollNext());
120
+ if (carousel && autoplay && !isStop && !isLast) {
121
+ timeoutId.current = setInterval(() => {
122
+ carousel.scrollNext();
123
+ }, delay);
124
+ } else {
125
+ if (timeoutId.current)
126
+ clearInterval(timeoutId.current);
127
+ timeoutId.current = void 0;
128
+ }
129
+ return () => {
130
+ if (timeoutId.current)
131
+ clearInterval(timeoutId.current);
132
+ };
133
+ }, [autoplay, delay, stopMouseEnterAutoplay, carousel, isMouseEnter, loop, selectedIndex]);
134
+ (0, import_utils.useUpdateEffect)(() => {
135
+ if (!carousel)
136
+ return;
137
+ carousel.reInit();
138
+ const snapList = carousel.scrollSnapList();
139
+ const indexes2 = snapList.map((_, i) => i);
140
+ setIndexes(indexes2);
141
+ }, [
142
+ import_react.Children.toArray(children).length,
143
+ align,
144
+ orientation,
145
+ loop,
146
+ speed,
147
+ gap,
148
+ slidesToScroll,
149
+ draggable,
150
+ dragFree,
151
+ inViewThreshold,
152
+ skipSnaps,
153
+ containScroll,
154
+ slideSize,
155
+ includeGapInSize
156
+ ]);
157
+ (0, import_utils.useUpdateEffect)(() => {
158
+ if (!carousel)
159
+ return;
160
+ const snapList = carousel.scrollSnapList();
161
+ const indexes2 = snapList.map((_, i) => i);
162
+ setIndexes(indexes2);
163
+ }, [carousel]);
164
+ (0, import_utils.useUpdateEffect)(() => {
165
+ if (carousel) {
166
+ carousel.on("select", onSelect);
167
+ carousel.on("scroll", onScroll);
168
+ onScroll();
169
+ return () => {
170
+ carousel.off("select", onSelect);
171
+ carousel.off("scroll", onScroll);
172
+ };
173
+ }
174
+ }, [carousel, onScroll]);
175
+ const getContainerProps = (0, import_react.useCallback)(
176
+ (props = {}, ref = null) => ({
177
+ ...computedProps[0],
178
+ ...props,
179
+ ref,
180
+ onMouseEnter: (0, import_utils.handlerAll)(props.onMouseEnter, () => {
181
+ setIsMouseEnter(true);
182
+ }),
183
+ onMouseLeave: (0, import_utils.handlerAll)(props.onMouseLeave, () => {
184
+ setIsMouseEnter(false);
185
+ })
186
+ }),
187
+ [computedProps]
188
+ );
189
+ const getSlidesProps = (0, import_react.useCallback)(
190
+ (props = {}) => ({
191
+ ...computedProps[1],
192
+ ...props,
193
+ ref: carouselRef
194
+ }),
195
+ [computedProps, carouselRef]
196
+ );
197
+ return {
198
+ carousel,
199
+ children,
200
+ indexes,
201
+ selectedIndex,
202
+ orientation,
203
+ slideSize,
204
+ gap,
205
+ slidesToScroll,
206
+ includeGapInSize,
207
+ getContainerProps,
208
+ getSlidesProps
209
+ };
210
+ };
211
+ var useCarouselSlide = ({ index }) => {
212
+ const { selectedIndex, slidesToScroll } = useCarouselContext();
213
+ index = Math.floor((index != null ? index : 0) / (slidesToScroll != null ? slidesToScroll : 1));
214
+ const isSelected = index === selectedIndex;
215
+ const getSlideProps = (0, import_react.useCallback)(
216
+ (props = {}) => ({
217
+ ...props,
218
+ role: "carousel-slide",
219
+ "data-index": index,
220
+ "data-selected": (0, import_utils.dataAttr)(isSelected)
221
+ }),
222
+ [isSelected, index]
223
+ );
224
+ return { getSlideProps };
225
+ };
226
+ var useCarouselControl = ({ operation, ...rest }) => {
227
+ var _a, _b;
228
+ const { carousel } = useCarouselContext();
229
+ const isPrev = operation === "prev";
230
+ const disabled = (_b = (_a = rest.disabled) != null ? _a : rest.isDisabled) != null ? _b : isPrev ? !(carousel == null ? void 0 : carousel.canScrollPrev()) : !(carousel == null ? void 0 : carousel.canScrollNext());
231
+ const onClick = (0, import_react.useCallback)(() => {
232
+ if (!carousel)
233
+ return;
234
+ if (isPrev) {
235
+ carousel.scrollPrev();
236
+ } else {
237
+ carousel.scrollNext();
238
+ }
239
+ }, [carousel, isPrev]);
240
+ const getControlProps = (0, import_react.useCallback)(
241
+ (props = {}, ref = null) => ({
242
+ ...props,
243
+ ref,
244
+ disabled,
245
+ role: "carousel-control",
246
+ onClick: (0, import_utils.handlerAll)(props.onClick, onClick)
247
+ }),
248
+ [disabled, onClick]
249
+ );
250
+ return { getControlProps };
251
+ };
252
+ var useCarouselIndicators = () => {
253
+ const { selectedIndex, carousel, indexes } = useCarouselContext();
254
+ const onClick = (0, import_react.useCallback)(
255
+ (ev, index) => {
256
+ if (!carousel)
257
+ return;
258
+ ev.stopPropagation();
259
+ carousel.scrollTo(index);
260
+ },
261
+ [carousel]
262
+ );
263
+ const getIndicatorProps = (0, import_react.useCallback)(
264
+ ({ index, ...props } = {}) => {
265
+ const isSelected = index === selectedIndex;
266
+ return {
267
+ ...props,
268
+ key: index,
269
+ role: "carousel-indicator",
270
+ "data-index": index,
271
+ "data-selected": (0, import_utils.dataAttr)(isSelected),
272
+ onClick: (0, import_utils.handlerAll)(props.onClick, (ev) => onClick(ev, index))
273
+ };
274
+ },
275
+ [onClick, selectedIndex]
276
+ );
277
+ return { indexes, getIndicatorProps };
278
+ };
279
+
280
+ // src/carousel.tsx
281
+ var import_jsx_runtime = require("react/jsx-runtime");
282
+ var Carousel = (0, import_core2.forwardRef)(
283
+ ({ h, height, minH, minHeight, ...props }, ref) => {
284
+ var _a, _b;
285
+ const orientation = (0, import_use_value.useValue)(props.orientation);
286
+ const align = (0, import_use_value.useValue)(props.align);
287
+ const autoplay = (0, import_use_value.useValue)(props.autoplay);
288
+ const stopMouseEnterAutoplay = (0, import_use_value.useValue)(props.stopMouseEnterAutoplay);
289
+ const loop = (0, import_use_value.useValue)(props.loop);
290
+ const speed = (0, import_use_value.useValue)(props.speed);
291
+ const delay = (0, import_use_value.useValue)(props.delay);
292
+ const slidesToScroll = (0, import_use_value.useValue)(props.slidesToScroll);
293
+ const draggable = (0, import_use_value.useValue)(props.draggable);
294
+ const dragFree = (0, import_use_value.useValue)(props.dragFree);
295
+ const inViewThreshold = (0, import_use_value.useValue)(props.inViewThreshold);
296
+ const skipSnaps = (0, import_use_value.useValue)(props.skipSnaps);
297
+ const containScroll = (0, import_use_value.useValue)(props.containScroll);
298
+ const includeGapInSize = (0, import_use_value.useValue)(props.includeGapInSize);
299
+ 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);
300
+ 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);
301
+ const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Carousel", {
302
+ ...props,
303
+ orientation,
304
+ align,
305
+ autoplay,
306
+ stopMouseEnterAutoplay,
307
+ loop,
308
+ speed,
309
+ delay,
310
+ slidesToScroll,
311
+ draggable,
312
+ dragFree,
313
+ inViewThreshold,
314
+ skipSnaps,
315
+ containScroll,
316
+ includeGapInSize,
317
+ gap,
318
+ slideSize
319
+ });
320
+ const {
321
+ className,
322
+ inner,
323
+ withControls = true,
324
+ controlProps,
325
+ controlPrevProps,
326
+ controlNextProps,
327
+ withIndicators = true,
328
+ indicatorsProps,
329
+ ...computedProps
330
+ } = (0, import_core2.omitThemeProps)(mergedProps);
331
+ const computedWithControls = (0, import_use_value.useValue)(withControls);
332
+ const computedWithIndicators = (0, import_use_value.useValue)(withIndicators);
333
+ const { getContainerProps, getSlidesProps, children, ...rest } = useCarousel({
334
+ ...computedProps
335
+ });
336
+ const validChildren = (0, import_utils2.getValidChildren)(children);
337
+ const [customCarouselControlPrev] = (0, import_utils2.findChildren)(validChildren, CarouselControlPrev);
338
+ const [customCarouselControlNext] = (0, import_utils2.findChildren)(validChildren, CarouselControlNext);
339
+ const [customCarouselIndicators] = (0, import_utils2.findChildren)(validChildren, CarouselIndicators);
340
+ const slideChildren = (0, import_utils2.pickChildren)(validChildren, CarouselSlide);
341
+ const otherChildren = (0, import_utils2.omitChildren)(
342
+ validChildren,
343
+ CarouselControlPrev,
344
+ CarouselControlNext,
345
+ CarouselIndicators,
346
+ CarouselSlide
347
+ );
348
+ const cloneSlideChildren = slideChildren.map((child, index) => (0, import_react2.cloneElement)(child, { index }));
349
+ h != null ? h : h = height;
350
+ minH != null ? minH : minH = minHeight;
351
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
352
+ import_core2.ui.div,
353
+ {
354
+ className: (0, import_utils2.cx)("ui-carousel", className),
355
+ __css: { position: "relative", h: "fit-content", ...styles.container },
356
+ ...getContainerProps({}, ref),
357
+ children: [
358
+ customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselControlPrev, { ...controlProps, ...controlPrevProps }) : null,
359
+ customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselControlNext, { ...controlProps, ...controlNextProps }) : null,
360
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselSlides, { ...getSlidesProps({ ...(0, import_utils2.filterUndefined)({ h, minH }), ...inner }), children: cloneSlideChildren }),
361
+ customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselIndicators, { ...indicatorsProps }) : null,
362
+ otherChildren
363
+ ]
364
+ }
365
+ ) });
366
+ }
367
+ );
368
+ var CarouselSlides = (0, import_core2.forwardRef)(({ ...rest }, ref) => {
369
+ const css = { w: "100%", h: "fit-content", overflow: "hidden" };
370
+ 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 }) });
371
+ });
372
+ var CarouselSlidesInner = ({ ...rest }) => {
373
+ const { orientation, includeGapInSize, gap, styles } = useCarouselContext();
374
+ const css = {
375
+ display: "flex",
376
+ flexDirection: orientation === "vertical" ? "column" : "row",
377
+ ...styles.inner,
378
+ ...includeGapInSize ? { [orientation === "vertical" ? "mb" : "mr"]: `-${gap}` } : {}
379
+ };
380
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.ui.div, { className: "ui-carousel-sliders-inner", __css: css, ...rest });
381
+ };
382
+
383
+ // src/carousel-slide.tsx
384
+ var import_core3 = require("@yamada-ui/core");
385
+ var import_utils3 = require("@yamada-ui/utils");
386
+ var import_jsx_runtime2 = require("react/jsx-runtime");
387
+ var CarouselSlide = (0, import_core3.forwardRef)(
388
+ ({ className, size, ...rest }, ref) => {
389
+ const { slideSize, includeGapInSize, orientation, gap } = useCarouselContext();
390
+ const { getSlideProps } = useCarouselSlide(rest);
391
+ size != null ? size : size = slideSize;
392
+ const css = {
393
+ position: "relative",
394
+ flex: `0 0 ${size}`,
395
+ ...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
396
+ };
397
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core3.ui.div, { className: (0, import_utils3.cx)("ui-carousel-slide", className), __css: css, ...getSlideProps({}), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CarouselSlideInner, { ref, ...rest }) });
398
+ }
399
+ );
400
+ var CarouselSlideInner = (0, import_core3.forwardRef)(({ ...rest }, ref) => {
401
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core3.ui.div, { ref, className: "ui-carousel-slide-inner", w: "100%", h: "100%", ...rest });
402
+ });
403
+
404
+ // src/carousel-control.tsx
405
+ var import_button = require("@yamada-ui/button");
406
+ var import_core4 = require("@yamada-ui/core");
407
+ var import_icon = require("@yamada-ui/icon");
408
+ var import_utils4 = require("@yamada-ui/utils");
409
+ var import_jsx_runtime3 = require("react/jsx-runtime");
410
+ var CarouselControlPrev = (0, import_core4.forwardRef)(
411
+ ({ className, ...rest }, ref) => {
412
+ const { orientation } = useCarouselContext();
413
+ const { getControlProps } = useCarouselControl({ operation: "prev" });
414
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
415
+ CarouselControl,
416
+ {
417
+ operation: "prev",
418
+ className: (0, import_utils4.cx)("ui-carousel-control-prev", className),
419
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
420
+ import_icon.ChevronIcon,
421
+ {
422
+ __css: {
423
+ fontSize: "1.5em",
424
+ transform: orientation === "vertical" ? "rotate(180deg)" : "rotate(90deg)"
425
+ }
426
+ }
427
+ ),
428
+ ...getControlProps(rest, ref)
429
+ }
430
+ );
431
+ }
432
+ );
433
+ var CarouselControlNext = (0, import_core4.forwardRef)(
434
+ ({ className, ...rest }, ref) => {
435
+ const { orientation } = useCarouselContext();
436
+ const { getControlProps } = useCarouselControl({ operation: "next" });
437
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
438
+ CarouselControl,
439
+ {
440
+ operation: "next",
441
+ className: (0, import_utils4.cx)("ui-carousel-control-next", className),
442
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
443
+ import_icon.ChevronIcon,
444
+ {
445
+ __css: {
446
+ fontSize: "1.5em",
447
+ transform: orientation === "vertical" ? "rotate(0deg)" : "rotate(-90deg)"
448
+ }
449
+ }
450
+ ),
451
+ ...getControlProps(rest, ref)
452
+ }
453
+ );
454
+ }
455
+ );
456
+ var CarouselControl = (0, import_core4.forwardRef)(
457
+ ({ className, operation, ...rest }, ref) => {
458
+ const { styles } = useCarouselContext();
459
+ const colorScheme = (0, import_core4.useColorModetValue)("whiteAlpha", "blackAlpha");
460
+ const css = {
461
+ position: "absolute",
462
+ zIndex: "kurillin",
463
+ ...styles.control,
464
+ ...styles[operation]
465
+ };
466
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
467
+ import_button.IconButton,
468
+ {
469
+ ref,
470
+ className: (0, import_utils4.cx)("ui-carousel-control", className),
471
+ colorScheme,
472
+ isRound: true,
473
+ __css: css,
474
+ ...rest
475
+ }
476
+ );
477
+ }
478
+ );
479
+
480
+ // src/carousel-indicators.tsx
481
+ var import_core5 = require("@yamada-ui/core");
482
+ var import_utils5 = require("@yamada-ui/utils");
483
+ var import_react3 = require("react");
484
+ var import_jsx_runtime4 = require("react/jsx-runtime");
485
+ var CarouselIndicators = (0, import_core5.forwardRef)(
486
+ ({ className, component = CarouselIndicator, ...rest }, ref) => {
487
+ const { selectedIndex, orientation, styles } = useCarouselContext();
488
+ const { indexes, getIndicatorProps } = useCarouselIndicators();
489
+ const cloneChildren = indexes.map((index) => {
490
+ const isSelected = index === selectedIndex;
491
+ const child = component({ index, isSelected });
492
+ if (!child)
493
+ return null;
494
+ const props = getIndicatorProps({ ...child.props, index });
495
+ return (0, import_react3.cloneElement)(child, props);
496
+ });
497
+ const css = {
498
+ position: "absolute",
499
+ zIndex: "kurillin",
500
+ display: "flex",
501
+ justifyContent: "center",
502
+ ...styles.indicators,
503
+ ...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
504
+ };
505
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core5.ui.div, { ref, className: (0, import_utils5.cx)("ui-carousel-indicators", className), __css: css, ...rest, children: cloneChildren });
506
+ }
507
+ );
508
+ var CarouselIndicator = ({ className, ...rest }) => {
509
+ const { styles } = useCarouselContext();
510
+ const css = { ...styles.indicator };
511
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
512
+ import_core5.ui.button,
513
+ {
514
+ type: "button",
515
+ tabIndex: -1,
516
+ className: (0, import_utils5.cx)("ui-carousel-indicator", className),
517
+ __css: css,
518
+ ...rest
519
+ }
520
+ );
521
+ };
522
+ // Annotate the CommonJS export names for ESM import in node:
523
+ 0 && (module.exports = {
524
+ Carousel,
525
+ CarouselControlNext,
526
+ CarouselControlPrev,
527
+ CarouselIndicators,
528
+ CarouselSlide
529
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,21 @@
1
+ import {
2
+ Carousel
3
+ } from "./chunk-PQ3S6YEB.mjs";
4
+ import {
5
+ CarouselControlNext,
6
+ CarouselControlPrev
7
+ } from "./chunk-FDF2QUCY.mjs";
8
+ import {
9
+ CarouselIndicators
10
+ } from "./chunk-UMRTZXZW.mjs";
11
+ import {
12
+ CarouselSlide
13
+ } from "./chunk-BWFAE3UJ.mjs";
14
+ import "./chunk-4P3A5PTO.mjs";
15
+ export {
16
+ Carousel,
17
+ CarouselControlNext,
18
+ CarouselControlPrev,
19
+ CarouselIndicators,
20
+ CarouselSlide
21
+ };
@@ -0,0 +1,82 @@
1
+ import * as _yamada_ui_utils from '@yamada-ui/utils';
2
+ import { PropGetter, RequiredPropGetter } from '@yamada-ui/utils';
3
+ import * as react from 'react';
4
+ import { IconButtonProps } from '@yamada-ui/button';
5
+ import { HTMLUIProps, CSSUIObject } from '@yamada-ui/core';
6
+ import { EmblaCarouselType } from 'embla-carousel-react';
7
+
8
+ type Orientation = 'vertical' | 'horizontal';
9
+ type Align = 'start' | 'center' | 'end' | number;
10
+ type ContainScroll = '' | 'trimSnaps' | 'keepSnaps';
11
+ type CarouselContext = {
12
+ carousel: EmblaCarouselType | undefined;
13
+ indexes: number[];
14
+ selectedIndex: number;
15
+ orientation: Orientation;
16
+ includeGapInSize: boolean;
17
+ slidesToScroll: number;
18
+ slideSize: string | number;
19
+ gap: string | number;
20
+ styles: Record<string, CSSUIObject>;
21
+ };
22
+ declare const CarouselProvider: react.Provider<CarouselContext>;
23
+ declare const useCarouselContext: () => CarouselContext;
24
+ type UseCarouselProps = Omit<HTMLUIProps<'div'>, 'onChange' | 'draggable' | 'gap'> & {
25
+ index?: number;
26
+ defaultIndex?: number;
27
+ onChange?: (index: number) => void;
28
+ orientation?: Orientation;
29
+ align?: Align;
30
+ containScroll?: ContainScroll;
31
+ slidesToScroll?: number;
32
+ dragFree?: boolean;
33
+ draggable?: boolean;
34
+ inViewThreshold?: number;
35
+ loop?: boolean;
36
+ skipSnaps?: boolean;
37
+ speed?: number;
38
+ delay?: number;
39
+ autoplay?: boolean;
40
+ stopMouseEnterAutoplay?: boolean;
41
+ includeGapInSize?: boolean;
42
+ gap?: string | number;
43
+ slideSize?: string | number;
44
+ onScrollProgress?: (progress: number) => void;
45
+ };
46
+ declare const useCarousel: ({ index, defaultIndex, onChange, align, orientation, autoplay, stopMouseEnterAutoplay, loop, speed, delay, gap, slidesToScroll, draggable, dragFree, inViewThreshold, skipSnaps, containScroll, slideSize, includeGapInSize, onScrollProgress, children, ...rest }: UseCarouselProps) => {
47
+ carousel: EmblaCarouselType | undefined;
48
+ children: react.ReactNode;
49
+ indexes: number[];
50
+ selectedIndex: number;
51
+ orientation: Orientation;
52
+ slideSize: string | number;
53
+ gap: string | number;
54
+ slidesToScroll: number;
55
+ includeGapInSize: boolean;
56
+ getContainerProps: PropGetter<Record<string, unknown>, _yamada_ui_utils.DOMAttributes<Element & HTMLOrSVGElement>>;
57
+ getSlidesProps: PropGetter<Record<string, unknown>, _yamada_ui_utils.DOMAttributes<Element & HTMLOrSVGElement>>;
58
+ };
59
+ type UseCarouselReturn = ReturnType<typeof useCarousel>;
60
+ type UseCarouselSlideProps = {
61
+ index?: number;
62
+ };
63
+ declare const useCarouselSlide: ({ index }: UseCarouselSlideProps) => {
64
+ getSlideProps: PropGetter<Record<string, unknown>, _yamada_ui_utils.DOMAttributes<Element & HTMLOrSVGElement>>;
65
+ };
66
+ type UseCarouselSlideReturn = ReturnType<typeof useCarouselSlide>;
67
+ type UseCarouselControlProps = IconButtonProps & {
68
+ operation: 'prev' | 'next';
69
+ };
70
+ declare const useCarouselControl: ({ operation, ...rest }: UseCarouselControlProps) => {
71
+ getControlProps: PropGetter<Record<string, unknown>, _yamada_ui_utils.DOMAttributes<Element & HTMLOrSVGElement>>;
72
+ };
73
+ type UseCarouselControlReturn = ReturnType<typeof useCarouselControl>;
74
+ declare const useCarouselIndicators: () => {
75
+ indexes: number[];
76
+ getIndicatorProps: RequiredPropGetter<{
77
+ index: number;
78
+ }, _yamada_ui_utils.DOMAttributes<Element & HTMLOrSVGElement>>;
79
+ };
80
+ type UseCarouselIndicatorsReturn = ReturnType<typeof useCarouselIndicators>;
81
+
82
+ export { Align, CarouselProvider, ContainScroll, Orientation, UseCarouselControlProps, UseCarouselControlReturn, UseCarouselIndicatorsReturn, UseCarouselProps, UseCarouselReturn, UseCarouselSlideProps, UseCarouselSlideReturn, useCarousel, useCarouselContext, useCarouselControl, useCarouselIndicators, useCarouselSlide };