@yamada-ui/carousel 0.2.5 → 0.2.7
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.js +25 -24
- package/dist/carousel-control.mjs +2 -2
- package/dist/carousel-indicators.js +28 -13
- package/dist/carousel-indicators.mjs +2 -2
- package/dist/carousel-slide.js +23 -4
- package/dist/carousel-slide.mjs +2 -2
- package/dist/carousel.js +124 -53
- package/dist/carousel.mjs +5 -5
- package/dist/{chunk-WQL2NFWH.mjs → chunk-4PHQQK4S.mjs} +40 -14
- package/dist/{chunk-YF54MDFK.mjs → chunk-6FKEASJN.mjs} +29 -14
- package/dist/{chunk-W7IEYNRW.mjs → chunk-D5HQSKWR.mjs} +22 -24
- package/dist/{chunk-4P3A5PTO.mjs → chunk-QR66JOUK.mjs} +26 -5
- package/dist/{chunk-BWFAE3UJ.mjs → chunk-T2MDCOCV.mjs} +28 -6
- package/dist/index.js +124 -53
- package/dist/index.mjs +5 -5
- package/dist/use-carousel.js +16 -3
- package/dist/use-carousel.mjs +1 -1
- package/package.json +8 -8
package/dist/carousel-control.js
CHANGED
|
@@ -49,7 +49,10 @@ var [CarouselProvider, useCarouselContext] = (0, import_utils.createContext)({
|
|
|
49
49
|
name: "CarouselContext",
|
|
50
50
|
errorMessage: `useCarouselContext returned is 'undefined'. Seems you forgot to wrap the components in "<Carousel />"`
|
|
51
51
|
});
|
|
52
|
-
var useCarouselControl = ({
|
|
52
|
+
var useCarouselControl = ({
|
|
53
|
+
operation,
|
|
54
|
+
...rest
|
|
55
|
+
}) => {
|
|
53
56
|
var _a, _b;
|
|
54
57
|
const { carousel } = useCarouselContext();
|
|
55
58
|
const isPrev = operation === "prev";
|
|
@@ -124,29 +127,27 @@ var CarouselControlNext = (0, import_core2.forwardRef)(
|
|
|
124
127
|
);
|
|
125
128
|
}
|
|
126
129
|
);
|
|
127
|
-
var CarouselControl = (0, import_core2.forwardRef)(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
);
|
|
130
|
+
var CarouselControl = (0, import_core2.forwardRef)(({ className, operation, ...rest }, ref) => {
|
|
131
|
+
const { styles } = useCarouselContext();
|
|
132
|
+
const colorScheme = (0, import_core2.useColorModetValue)("whiteAlpha", "blackAlpha");
|
|
133
|
+
const css = {
|
|
134
|
+
position: "absolute",
|
|
135
|
+
zIndex: "kurillin",
|
|
136
|
+
...styles.control,
|
|
137
|
+
...styles[operation]
|
|
138
|
+
};
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
140
|
+
import_button.IconButton,
|
|
141
|
+
{
|
|
142
|
+
ref,
|
|
143
|
+
className: (0, import_utils2.cx)("ui-carousel-control", className),
|
|
144
|
+
colorScheme,
|
|
145
|
+
isRounded: true,
|
|
146
|
+
__css: css,
|
|
147
|
+
...rest
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
});
|
|
150
151
|
// Annotate the CommonJS export names for ESM import in node:
|
|
151
152
|
0 && (module.exports = {
|
|
152
153
|
CarouselControlNext,
|
|
@@ -89,22 +89,37 @@ var CarouselIndicators = (0, import_core2.forwardRef)(
|
|
|
89
89
|
...styles.indicators,
|
|
90
90
|
...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
|
|
91
91
|
};
|
|
92
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
93
|
+
import_core2.ui.div,
|
|
94
|
+
{
|
|
95
|
+
ref,
|
|
96
|
+
className: (0, import_utils2.cx)("ui-carousel-indicators", className),
|
|
97
|
+
__css: css,
|
|
98
|
+
...rest,
|
|
99
|
+
children: indexes.map((index) => {
|
|
100
|
+
const isSelected = index === selectedIndex;
|
|
101
|
+
if (typeof component === "function") {
|
|
102
|
+
const child = component({
|
|
103
|
+
index,
|
|
104
|
+
isSelected
|
|
105
|
+
});
|
|
106
|
+
if (!child)
|
|
107
|
+
return null;
|
|
108
|
+
const props = getIndicatorProps({ ...child.props, index });
|
|
109
|
+
return (0, import_react2.cloneElement)(child, props);
|
|
110
|
+
} else {
|
|
111
|
+
const { key, ...props } = getIndicatorProps({ index });
|
|
112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselIndicator, { ...props }, key);
|
|
113
|
+
}
|
|
114
|
+
})
|
|
103
115
|
}
|
|
104
|
-
|
|
116
|
+
);
|
|
105
117
|
}
|
|
106
118
|
);
|
|
107
|
-
var CarouselIndicator = ({
|
|
119
|
+
var CarouselIndicator = ({
|
|
120
|
+
className,
|
|
121
|
+
...rest
|
|
122
|
+
}) => {
|
|
108
123
|
const { styles } = useCarouselContext();
|
|
109
124
|
const css = { ...styles.indicator };
|
|
110
125
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
package/dist/carousel-slide.js
CHANGED
|
@@ -74,12 +74,31 @@ var CarouselSlide = (0, import_core2.forwardRef)(
|
|
|
74
74
|
flex: `0 0 ${size}`,
|
|
75
75
|
...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
|
|
76
76
|
};
|
|
77
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
|
+
import_core2.ui.div,
|
|
79
|
+
{
|
|
80
|
+
className: (0, import_utils2.cx)("ui-carousel-slide", className),
|
|
81
|
+
__css: css,
|
|
82
|
+
...getSlideProps({}),
|
|
83
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselSlideInner, { ref, ...rest })
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
var CarouselSlideInner = (0, import_core2.forwardRef)(
|
|
89
|
+
({ ...rest }, ref) => {
|
|
90
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
91
|
+
import_core2.ui.div,
|
|
92
|
+
{
|
|
93
|
+
ref,
|
|
94
|
+
className: "ui-carousel-slide-inner",
|
|
95
|
+
w: "100%",
|
|
96
|
+
h: "100%",
|
|
97
|
+
...rest
|
|
98
|
+
}
|
|
99
|
+
);
|
|
78
100
|
}
|
|
79
101
|
);
|
|
80
|
-
var CarouselSlideInner = (0, import_core2.forwardRef)(({ ...rest }, ref) => {
|
|
81
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.ui.div, { ref, className: "ui-carousel-slide-inner", w: "100%", h: "100%", ...rest });
|
|
82
|
-
});
|
|
83
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
103
|
0 && (module.exports = {
|
|
85
104
|
CarouselSlide
|
package/dist/carousel-slide.mjs
CHANGED
package/dist/carousel.js
CHANGED
|
@@ -99,7 +99,9 @@ var useCarousel = ({
|
|
|
99
99
|
const onScroll = (0, import_react.useCallback)(() => {
|
|
100
100
|
if (!carousel)
|
|
101
101
|
return;
|
|
102
|
-
const progress = Math.round(
|
|
102
|
+
const progress = Math.round(
|
|
103
|
+
Math.max(0, Math.min(1, carousel.scrollProgress())) * 100
|
|
104
|
+
);
|
|
103
105
|
onScrollProgress == null ? void 0 : onScrollProgress(progress);
|
|
104
106
|
}, [carousel, onScrollProgress]);
|
|
105
107
|
const onSelect = (0, import_react.useCallback)(() => {
|
|
@@ -124,7 +126,15 @@ var useCarousel = ({
|
|
|
124
126
|
if (timeoutId.current)
|
|
125
127
|
clearInterval(timeoutId.current);
|
|
126
128
|
};
|
|
127
|
-
}, [
|
|
129
|
+
}, [
|
|
130
|
+
autoplay,
|
|
131
|
+
delay,
|
|
132
|
+
stopMouseEnterAutoplay,
|
|
133
|
+
carousel,
|
|
134
|
+
isMouseEnter,
|
|
135
|
+
loop,
|
|
136
|
+
selectedIndex
|
|
137
|
+
]);
|
|
128
138
|
(0, import_utils.useUpdateEffect)(() => {
|
|
129
139
|
if (!carousel)
|
|
130
140
|
return;
|
|
@@ -217,7 +227,10 @@ var useCarouselSlide = ({ index }) => {
|
|
|
217
227
|
);
|
|
218
228
|
return { getSlideProps };
|
|
219
229
|
};
|
|
220
|
-
var useCarouselControl = ({
|
|
230
|
+
var useCarouselControl = ({
|
|
231
|
+
operation,
|
|
232
|
+
...rest
|
|
233
|
+
}) => {
|
|
221
234
|
var _a, _b;
|
|
222
235
|
const { carousel } = useCarouselContext();
|
|
223
236
|
const isPrev = operation === "prev";
|
|
@@ -285,12 +298,31 @@ var CarouselSlide = (0, import_core2.forwardRef)(
|
|
|
285
298
|
flex: `0 0 ${size}`,
|
|
286
299
|
...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
|
|
287
300
|
};
|
|
288
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
302
|
+
import_core2.ui.div,
|
|
303
|
+
{
|
|
304
|
+
className: (0, import_utils2.cx)("ui-carousel-slide", className),
|
|
305
|
+
__css: css,
|
|
306
|
+
...getSlideProps({}),
|
|
307
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselSlideInner, { ref, ...rest })
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
var CarouselSlideInner = (0, import_core2.forwardRef)(
|
|
313
|
+
({ ...rest }, ref) => {
|
|
314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
315
|
+
import_core2.ui.div,
|
|
316
|
+
{
|
|
317
|
+
ref,
|
|
318
|
+
className: "ui-carousel-slide-inner",
|
|
319
|
+
w: "100%",
|
|
320
|
+
h: "100%",
|
|
321
|
+
...rest
|
|
322
|
+
}
|
|
323
|
+
);
|
|
289
324
|
}
|
|
290
325
|
);
|
|
291
|
-
var CarouselSlideInner = (0, import_core2.forwardRef)(({ ...rest }, ref) => {
|
|
292
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.ui.div, { ref, className: "ui-carousel-slide-inner", w: "100%", h: "100%", ...rest });
|
|
293
|
-
});
|
|
294
326
|
|
|
295
327
|
// src/carousel-control.tsx
|
|
296
328
|
var import_button = require("@yamada-ui/button");
|
|
@@ -344,29 +376,27 @@ var CarouselControlNext = (0, import_core3.forwardRef)(
|
|
|
344
376
|
);
|
|
345
377
|
}
|
|
346
378
|
);
|
|
347
|
-
var CarouselControl = (0, import_core3.forwardRef)(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
);
|
|
379
|
+
var CarouselControl = (0, import_core3.forwardRef)(({ className, operation, ...rest }, ref) => {
|
|
380
|
+
const { styles } = useCarouselContext();
|
|
381
|
+
const colorScheme = (0, import_core3.useColorModetValue)("whiteAlpha", "blackAlpha");
|
|
382
|
+
const css = {
|
|
383
|
+
position: "absolute",
|
|
384
|
+
zIndex: "kurillin",
|
|
385
|
+
...styles.control,
|
|
386
|
+
...styles[operation]
|
|
387
|
+
};
|
|
388
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
389
|
+
import_button.IconButton,
|
|
390
|
+
{
|
|
391
|
+
ref,
|
|
392
|
+
className: (0, import_utils3.cx)("ui-carousel-control", className),
|
|
393
|
+
colorScheme,
|
|
394
|
+
isRounded: true,
|
|
395
|
+
__css: css,
|
|
396
|
+
...rest
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
});
|
|
370
400
|
|
|
371
401
|
// src/carousel-indicators.tsx
|
|
372
402
|
var import_core4 = require("@yamada-ui/core");
|
|
@@ -385,22 +415,37 @@ var CarouselIndicators = (0, import_core4.forwardRef)(
|
|
|
385
415
|
...styles.indicators,
|
|
386
416
|
...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
|
|
387
417
|
};
|
|
388
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
419
|
+
import_core4.ui.div,
|
|
420
|
+
{
|
|
421
|
+
ref,
|
|
422
|
+
className: (0, import_utils4.cx)("ui-carousel-indicators", className),
|
|
423
|
+
__css: css,
|
|
424
|
+
...rest,
|
|
425
|
+
children: indexes.map((index) => {
|
|
426
|
+
const isSelected = index === selectedIndex;
|
|
427
|
+
if (typeof component === "function") {
|
|
428
|
+
const child = component({
|
|
429
|
+
index,
|
|
430
|
+
isSelected
|
|
431
|
+
});
|
|
432
|
+
if (!child)
|
|
433
|
+
return null;
|
|
434
|
+
const props = getIndicatorProps({ ...child.props, index });
|
|
435
|
+
return (0, import_react2.cloneElement)(child, props);
|
|
436
|
+
} else {
|
|
437
|
+
const { key, ...props } = getIndicatorProps({ index });
|
|
438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CarouselIndicator, { ...props }, key);
|
|
439
|
+
}
|
|
440
|
+
})
|
|
399
441
|
}
|
|
400
|
-
|
|
442
|
+
);
|
|
401
443
|
}
|
|
402
444
|
);
|
|
403
|
-
var CarouselIndicator = ({
|
|
445
|
+
var CarouselIndicator = ({
|
|
446
|
+
className,
|
|
447
|
+
...rest
|
|
448
|
+
}) => {
|
|
404
449
|
const { styles } = useCarouselContext();
|
|
405
450
|
const css = { ...styles.indicator };
|
|
406
451
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -472,9 +517,18 @@ var Carousel = (0, import_core5.forwardRef)(
|
|
|
472
517
|
...computedProps
|
|
473
518
|
});
|
|
474
519
|
const validChildren = (0, import_utils5.getValidChildren)(children);
|
|
475
|
-
const [customCarouselControlPrev] = (0, import_utils5.findChildren)(
|
|
476
|
-
|
|
477
|
-
|
|
520
|
+
const [customCarouselControlPrev] = (0, import_utils5.findChildren)(
|
|
521
|
+
validChildren,
|
|
522
|
+
CarouselControlPrev
|
|
523
|
+
);
|
|
524
|
+
const [customCarouselControlNext] = (0, import_utils5.findChildren)(
|
|
525
|
+
validChildren,
|
|
526
|
+
CarouselControlNext
|
|
527
|
+
);
|
|
528
|
+
const [customCarouselIndicators] = (0, import_utils5.findChildren)(
|
|
529
|
+
validChildren,
|
|
530
|
+
CarouselIndicators
|
|
531
|
+
);
|
|
478
532
|
const slideChildren = (0, import_utils5.pickChildren)(validChildren, CarouselSlide);
|
|
479
533
|
const otherChildren = (0, import_utils5.omitChildren)(
|
|
480
534
|
validChildren,
|
|
@@ -483,19 +537,34 @@ var Carousel = (0, import_core5.forwardRef)(
|
|
|
483
537
|
CarouselIndicators,
|
|
484
538
|
CarouselSlide
|
|
485
539
|
);
|
|
486
|
-
const cloneSlideChildren = slideChildren.map(
|
|
540
|
+
const cloneSlideChildren = slideChildren.map(
|
|
541
|
+
(child, index) => (0, import_react3.cloneElement)(child, { index })
|
|
542
|
+
);
|
|
487
543
|
h != null ? h : h = height;
|
|
488
544
|
minH != null ? minH : minH = minHeight;
|
|
489
545
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
490
546
|
import_core5.ui.div,
|
|
491
547
|
{
|
|
492
548
|
className: (0, import_utils5.cx)("ui-carousel", className),
|
|
493
|
-
__css: {
|
|
549
|
+
__css: {
|
|
550
|
+
position: "relative",
|
|
551
|
+
h: "fit-content",
|
|
552
|
+
...styles.container
|
|
553
|
+
},
|
|
494
554
|
...getContainerProps({}, ref),
|
|
495
555
|
children: [
|
|
496
556
|
customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselControlPrev, { ...controlProps, ...controlPrevProps }) : null,
|
|
497
557
|
customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselControlNext, { ...controlProps, ...controlNextProps }) : null,
|
|
498
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
558
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
559
|
+
CarouselSlides,
|
|
560
|
+
{
|
|
561
|
+
...getSlidesProps({
|
|
562
|
+
...(0, import_utils5.filterUndefined)({ h, minH }),
|
|
563
|
+
...innerProps
|
|
564
|
+
}),
|
|
565
|
+
children: cloneSlideChildren
|
|
566
|
+
}
|
|
567
|
+
),
|
|
499
568
|
customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicators, { ...indicatorsProps }) : null,
|
|
500
569
|
otherChildren
|
|
501
570
|
]
|
|
@@ -503,10 +572,12 @@ var Carousel = (0, import_core5.forwardRef)(
|
|
|
503
572
|
) });
|
|
504
573
|
}
|
|
505
574
|
);
|
|
506
|
-
var CarouselSlides = (0, import_core5.forwardRef)(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
});
|
|
575
|
+
var CarouselSlides = (0, import_core5.forwardRef)(
|
|
576
|
+
({ ...rest }, ref) => {
|
|
577
|
+
const css = { w: "100%", h: "fit-content", overflow: "hidden" };
|
|
578
|
+
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 }) });
|
|
579
|
+
}
|
|
580
|
+
);
|
|
510
581
|
var CarouselSlidesInner = ({ ...rest }) => {
|
|
511
582
|
const { orientation, includeGapInSize, gap, styles } = useCarouselContext();
|
|
512
583
|
const css = {
|
package/dist/carousel.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Carousel
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-4PHQQK4S.mjs";
|
|
4
|
+
import "./chunk-D5HQSKWR.mjs";
|
|
5
|
+
import "./chunk-6FKEASJN.mjs";
|
|
6
|
+
import "./chunk-T2MDCOCV.mjs";
|
|
7
|
+
import "./chunk-QR66JOUK.mjs";
|
|
8
8
|
export {
|
|
9
9
|
Carousel
|
|
10
10
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CarouselControlNext,
|
|
3
3
|
CarouselControlPrev
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-D5HQSKWR.mjs";
|
|
5
5
|
import {
|
|
6
6
|
CarouselIndicators
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6FKEASJN.mjs";
|
|
8
8
|
import {
|
|
9
9
|
CarouselSlide
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-T2MDCOCV.mjs";
|
|
11
11
|
import {
|
|
12
12
|
CarouselProvider,
|
|
13
13
|
useCarousel,
|
|
14
14
|
useCarouselContext
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QR66JOUK.mjs";
|
|
16
16
|
|
|
17
17
|
// src/carousel.tsx
|
|
18
18
|
import {
|
|
@@ -88,9 +88,18 @@ var Carousel = forwardRef(
|
|
|
88
88
|
...computedProps
|
|
89
89
|
});
|
|
90
90
|
const validChildren = getValidChildren(children);
|
|
91
|
-
const [customCarouselControlPrev] = findChildren(
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
const [customCarouselControlPrev] = findChildren(
|
|
92
|
+
validChildren,
|
|
93
|
+
CarouselControlPrev
|
|
94
|
+
);
|
|
95
|
+
const [customCarouselControlNext] = findChildren(
|
|
96
|
+
validChildren,
|
|
97
|
+
CarouselControlNext
|
|
98
|
+
);
|
|
99
|
+
const [customCarouselIndicators] = findChildren(
|
|
100
|
+
validChildren,
|
|
101
|
+
CarouselIndicators
|
|
102
|
+
);
|
|
94
103
|
const slideChildren = pickChildren(validChildren, CarouselSlide);
|
|
95
104
|
const otherChildren = omitChildren(
|
|
96
105
|
validChildren,
|
|
@@ -99,19 +108,34 @@ var Carousel = forwardRef(
|
|
|
99
108
|
CarouselIndicators,
|
|
100
109
|
CarouselSlide
|
|
101
110
|
);
|
|
102
|
-
const cloneSlideChildren = slideChildren.map(
|
|
111
|
+
const cloneSlideChildren = slideChildren.map(
|
|
112
|
+
(child, index) => cloneElement(child, { index })
|
|
113
|
+
);
|
|
103
114
|
h != null ? h : h = height;
|
|
104
115
|
minH != null ? minH : minH = minHeight;
|
|
105
116
|
return /* @__PURE__ */ jsx(CarouselProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ jsxs(
|
|
106
117
|
ui.div,
|
|
107
118
|
{
|
|
108
119
|
className: cx("ui-carousel", className),
|
|
109
|
-
__css: {
|
|
120
|
+
__css: {
|
|
121
|
+
position: "relative",
|
|
122
|
+
h: "fit-content",
|
|
123
|
+
...styles.container
|
|
124
|
+
},
|
|
110
125
|
...getContainerProps({}, ref),
|
|
111
126
|
children: [
|
|
112
127
|
customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ jsx(CarouselControlPrev, { ...controlProps, ...controlPrevProps }) : null,
|
|
113
128
|
customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ jsx(CarouselControlNext, { ...controlProps, ...controlNextProps }) : null,
|
|
114
|
-
/* @__PURE__ */ jsx(
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
CarouselSlides,
|
|
131
|
+
{
|
|
132
|
+
...getSlidesProps({
|
|
133
|
+
...filterUndefined({ h, minH }),
|
|
134
|
+
...innerProps
|
|
135
|
+
}),
|
|
136
|
+
children: cloneSlideChildren
|
|
137
|
+
}
|
|
138
|
+
),
|
|
115
139
|
customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ jsx(CarouselIndicators, { ...indicatorsProps }) : null,
|
|
116
140
|
otherChildren
|
|
117
141
|
]
|
|
@@ -119,10 +143,12 @@ var Carousel = forwardRef(
|
|
|
119
143
|
) });
|
|
120
144
|
}
|
|
121
145
|
);
|
|
122
|
-
var CarouselSlides = forwardRef(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
146
|
+
var CarouselSlides = forwardRef(
|
|
147
|
+
({ ...rest }, ref) => {
|
|
148
|
+
const css = { w: "100%", h: "fit-content", overflow: "hidden" };
|
|
149
|
+
return /* @__PURE__ */ jsx(ui.div, { ref, className: "ui-carousel-sliders", __css: css, children: /* @__PURE__ */ jsx(CarouselSlidesInner, { ...rest }) });
|
|
150
|
+
}
|
|
151
|
+
);
|
|
126
152
|
var CarouselSlidesInner = ({ ...rest }) => {
|
|
127
153
|
const { orientation, includeGapInSize, gap, styles } = useCarouselContext();
|
|
128
154
|
const css = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCarouselContext,
|
|
3
3
|
useCarouselIndicators
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QR66JOUK.mjs";
|
|
5
5
|
|
|
6
6
|
// src/carousel-indicators.tsx
|
|
7
7
|
import { ui, forwardRef } from "@yamada-ui/core";
|
|
@@ -20,22 +20,37 @@ var CarouselIndicators = forwardRef(
|
|
|
20
20
|
...styles.indicators,
|
|
21
21
|
...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
|
|
22
22
|
};
|
|
23
|
-
return /* @__PURE__ */ jsx(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
ui.div,
|
|
25
|
+
{
|
|
26
|
+
ref,
|
|
27
|
+
className: cx("ui-carousel-indicators", className),
|
|
28
|
+
__css: css,
|
|
29
|
+
...rest,
|
|
30
|
+
children: indexes.map((index) => {
|
|
31
|
+
const isSelected = index === selectedIndex;
|
|
32
|
+
if (typeof component === "function") {
|
|
33
|
+
const child = component({
|
|
34
|
+
index,
|
|
35
|
+
isSelected
|
|
36
|
+
});
|
|
37
|
+
if (!child)
|
|
38
|
+
return null;
|
|
39
|
+
const props = getIndicatorProps({ ...child.props, index });
|
|
40
|
+
return cloneElement(child, props);
|
|
41
|
+
} else {
|
|
42
|
+
const { key, ...props } = getIndicatorProps({ index });
|
|
43
|
+
return /* @__PURE__ */ jsx(CarouselIndicator, { ...props }, key);
|
|
44
|
+
}
|
|
45
|
+
})
|
|
34
46
|
}
|
|
35
|
-
|
|
47
|
+
);
|
|
36
48
|
}
|
|
37
49
|
);
|
|
38
|
-
var CarouselIndicator = ({
|
|
50
|
+
var CarouselIndicator = ({
|
|
51
|
+
className,
|
|
52
|
+
...rest
|
|
53
|
+
}) => {
|
|
39
54
|
const { styles } = useCarouselContext();
|
|
40
55
|
const css = { ...styles.indicator };
|
|
41
56
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCarouselContext,
|
|
3
3
|
useCarouselControl
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QR66JOUK.mjs";
|
|
5
5
|
|
|
6
6
|
// src/carousel-control.tsx
|
|
7
7
|
import { IconButton } from "@yamada-ui/button";
|
|
@@ -55,29 +55,27 @@ var CarouselControlNext = forwardRef(
|
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
);
|
|
58
|
-
var CarouselControl = forwardRef(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
);
|
|
58
|
+
var CarouselControl = forwardRef(({ className, operation, ...rest }, ref) => {
|
|
59
|
+
const { styles } = useCarouselContext();
|
|
60
|
+
const colorScheme = useColorModetValue("whiteAlpha", "blackAlpha");
|
|
61
|
+
const css = {
|
|
62
|
+
position: "absolute",
|
|
63
|
+
zIndex: "kurillin",
|
|
64
|
+
...styles.control,
|
|
65
|
+
...styles[operation]
|
|
66
|
+
};
|
|
67
|
+
return /* @__PURE__ */ jsx(
|
|
68
|
+
IconButton,
|
|
69
|
+
{
|
|
70
|
+
ref,
|
|
71
|
+
className: cx("ui-carousel-control", className),
|
|
72
|
+
colorScheme,
|
|
73
|
+
isRounded: true,
|
|
74
|
+
__css: css,
|
|
75
|
+
...rest
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
});
|
|
81
79
|
|
|
82
80
|
export {
|
|
83
81
|
CarouselControlPrev,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/use-carousel.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
layoutStylesProperties
|
|
4
|
+
} from "@yamada-ui/core";
|
|
3
5
|
import { useControllableState } from "@yamada-ui/use-controllable-state";
|
|
4
6
|
import {
|
|
5
7
|
createContext,
|
|
@@ -9,7 +11,13 @@ import {
|
|
|
9
11
|
useUpdateEffect
|
|
10
12
|
} from "@yamada-ui/utils";
|
|
11
13
|
import useEmblaCarousel from "embla-carousel-react";
|
|
12
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Children,
|
|
16
|
+
useCallback,
|
|
17
|
+
useEffect,
|
|
18
|
+
useRef,
|
|
19
|
+
useState
|
|
20
|
+
} from "react";
|
|
13
21
|
var [CarouselProvider, useCarouselContext] = createContext({
|
|
14
22
|
name: "CarouselContext",
|
|
15
23
|
errorMessage: `useCarouselContext returned is 'undefined'. Seems you forgot to wrap the components in "<Carousel />"`
|
|
@@ -64,7 +72,9 @@ var useCarousel = ({
|
|
|
64
72
|
const onScroll = useCallback(() => {
|
|
65
73
|
if (!carousel)
|
|
66
74
|
return;
|
|
67
|
-
const progress = Math.round(
|
|
75
|
+
const progress = Math.round(
|
|
76
|
+
Math.max(0, Math.min(1, carousel.scrollProgress())) * 100
|
|
77
|
+
);
|
|
68
78
|
onScrollProgress == null ? void 0 : onScrollProgress(progress);
|
|
69
79
|
}, [carousel, onScrollProgress]);
|
|
70
80
|
const onSelect = useCallback(() => {
|
|
@@ -89,7 +99,15 @@ var useCarousel = ({
|
|
|
89
99
|
if (timeoutId.current)
|
|
90
100
|
clearInterval(timeoutId.current);
|
|
91
101
|
};
|
|
92
|
-
}, [
|
|
102
|
+
}, [
|
|
103
|
+
autoplay,
|
|
104
|
+
delay,
|
|
105
|
+
stopMouseEnterAutoplay,
|
|
106
|
+
carousel,
|
|
107
|
+
isMouseEnter,
|
|
108
|
+
loop,
|
|
109
|
+
selectedIndex
|
|
110
|
+
]);
|
|
93
111
|
useUpdateEffect(() => {
|
|
94
112
|
if (!carousel)
|
|
95
113
|
return;
|
|
@@ -182,7 +200,10 @@ var useCarouselSlide = ({ index }) => {
|
|
|
182
200
|
);
|
|
183
201
|
return { getSlideProps };
|
|
184
202
|
};
|
|
185
|
-
var useCarouselControl = ({
|
|
203
|
+
var useCarouselControl = ({
|
|
204
|
+
operation,
|
|
205
|
+
...rest
|
|
206
|
+
}) => {
|
|
186
207
|
var _a, _b;
|
|
187
208
|
const { carousel } = useCarouselContext();
|
|
188
209
|
const isPrev = operation === "prev";
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCarouselContext,
|
|
3
3
|
useCarouselSlide
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QR66JOUK.mjs";
|
|
5
5
|
|
|
6
6
|
// src/carousel-slide.tsx
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ui,
|
|
9
|
+
forwardRef
|
|
10
|
+
} from "@yamada-ui/core";
|
|
8
11
|
import { cx } from "@yamada-ui/utils";
|
|
9
12
|
import { jsx } from "react/jsx-runtime";
|
|
10
13
|
var CarouselSlide = forwardRef(
|
|
@@ -17,12 +20,31 @@ var CarouselSlide = forwardRef(
|
|
|
17
20
|
flex: `0 0 ${size}`,
|
|
18
21
|
...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
|
|
19
22
|
};
|
|
20
|
-
return /* @__PURE__ */ jsx(
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
ui.div,
|
|
25
|
+
{
|
|
26
|
+
className: cx("ui-carousel-slide", className),
|
|
27
|
+
__css: css,
|
|
28
|
+
...getSlideProps({}),
|
|
29
|
+
children: /* @__PURE__ */ jsx(CarouselSlideInner, { ref, ...rest })
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
var CarouselSlideInner = forwardRef(
|
|
35
|
+
({ ...rest }, ref) => {
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
ui.div,
|
|
38
|
+
{
|
|
39
|
+
ref,
|
|
40
|
+
className: "ui-carousel-slide-inner",
|
|
41
|
+
w: "100%",
|
|
42
|
+
h: "100%",
|
|
43
|
+
...rest
|
|
44
|
+
}
|
|
45
|
+
);
|
|
21
46
|
}
|
|
22
47
|
);
|
|
23
|
-
var CarouselSlideInner = forwardRef(({ ...rest }, ref) => {
|
|
24
|
-
return /* @__PURE__ */ jsx(ui.div, { ref, className: "ui-carousel-slide-inner", w: "100%", h: "100%", ...rest });
|
|
25
|
-
});
|
|
26
48
|
|
|
27
49
|
export {
|
|
28
50
|
CarouselSlide
|
package/dist/index.js
CHANGED
|
@@ -105,7 +105,9 @@ var useCarousel = ({
|
|
|
105
105
|
const onScroll = (0, import_react.useCallback)(() => {
|
|
106
106
|
if (!carousel)
|
|
107
107
|
return;
|
|
108
|
-
const progress = Math.round(
|
|
108
|
+
const progress = Math.round(
|
|
109
|
+
Math.max(0, Math.min(1, carousel.scrollProgress())) * 100
|
|
110
|
+
);
|
|
109
111
|
onScrollProgress == null ? void 0 : onScrollProgress(progress);
|
|
110
112
|
}, [carousel, onScrollProgress]);
|
|
111
113
|
const onSelect = (0, import_react.useCallback)(() => {
|
|
@@ -130,7 +132,15 @@ var useCarousel = ({
|
|
|
130
132
|
if (timeoutId.current)
|
|
131
133
|
clearInterval(timeoutId.current);
|
|
132
134
|
};
|
|
133
|
-
}, [
|
|
135
|
+
}, [
|
|
136
|
+
autoplay,
|
|
137
|
+
delay,
|
|
138
|
+
stopMouseEnterAutoplay,
|
|
139
|
+
carousel,
|
|
140
|
+
isMouseEnter,
|
|
141
|
+
loop,
|
|
142
|
+
selectedIndex
|
|
143
|
+
]);
|
|
134
144
|
(0, import_utils.useUpdateEffect)(() => {
|
|
135
145
|
if (!carousel)
|
|
136
146
|
return;
|
|
@@ -223,7 +233,10 @@ var useCarouselSlide = ({ index }) => {
|
|
|
223
233
|
);
|
|
224
234
|
return { getSlideProps };
|
|
225
235
|
};
|
|
226
|
-
var useCarouselControl = ({
|
|
236
|
+
var useCarouselControl = ({
|
|
237
|
+
operation,
|
|
238
|
+
...rest
|
|
239
|
+
}) => {
|
|
227
240
|
var _a, _b;
|
|
228
241
|
const { carousel } = useCarouselContext();
|
|
229
242
|
const isPrev = operation === "prev";
|
|
@@ -334,9 +347,18 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
|
334
347
|
...computedProps
|
|
335
348
|
});
|
|
336
349
|
const validChildren = (0, import_utils2.getValidChildren)(children);
|
|
337
|
-
const [customCarouselControlPrev] = (0, import_utils2.findChildren)(
|
|
338
|
-
|
|
339
|
-
|
|
350
|
+
const [customCarouselControlPrev] = (0, import_utils2.findChildren)(
|
|
351
|
+
validChildren,
|
|
352
|
+
CarouselControlPrev
|
|
353
|
+
);
|
|
354
|
+
const [customCarouselControlNext] = (0, import_utils2.findChildren)(
|
|
355
|
+
validChildren,
|
|
356
|
+
CarouselControlNext
|
|
357
|
+
);
|
|
358
|
+
const [customCarouselIndicators] = (0, import_utils2.findChildren)(
|
|
359
|
+
validChildren,
|
|
360
|
+
CarouselIndicators
|
|
361
|
+
);
|
|
340
362
|
const slideChildren = (0, import_utils2.pickChildren)(validChildren, CarouselSlide);
|
|
341
363
|
const otherChildren = (0, import_utils2.omitChildren)(
|
|
342
364
|
validChildren,
|
|
@@ -345,19 +367,34 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
|
345
367
|
CarouselIndicators,
|
|
346
368
|
CarouselSlide
|
|
347
369
|
);
|
|
348
|
-
const cloneSlideChildren = slideChildren.map(
|
|
370
|
+
const cloneSlideChildren = slideChildren.map(
|
|
371
|
+
(child, index) => (0, import_react2.cloneElement)(child, { index })
|
|
372
|
+
);
|
|
349
373
|
h != null ? h : h = height;
|
|
350
374
|
minH != null ? minH : minH = minHeight;
|
|
351
375
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselProvider, { value: { styles, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
352
376
|
import_core2.ui.div,
|
|
353
377
|
{
|
|
354
378
|
className: (0, import_utils2.cx)("ui-carousel", className),
|
|
355
|
-
__css: {
|
|
379
|
+
__css: {
|
|
380
|
+
position: "relative",
|
|
381
|
+
h: "fit-content",
|
|
382
|
+
...styles.container
|
|
383
|
+
},
|
|
356
384
|
...getContainerProps({}, ref),
|
|
357
385
|
children: [
|
|
358
386
|
customCarouselControlPrev != null ? customCarouselControlPrev : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselControlPrev, { ...controlProps, ...controlPrevProps }) : null,
|
|
359
387
|
customCarouselControlNext != null ? customCarouselControlNext : computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselControlNext, { ...controlProps, ...controlNextProps }) : null,
|
|
360
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
389
|
+
CarouselSlides,
|
|
390
|
+
{
|
|
391
|
+
...getSlidesProps({
|
|
392
|
+
...(0, import_utils2.filterUndefined)({ h, minH }),
|
|
393
|
+
...innerProps
|
|
394
|
+
}),
|
|
395
|
+
children: cloneSlideChildren
|
|
396
|
+
}
|
|
397
|
+
),
|
|
361
398
|
customCarouselIndicators != null ? customCarouselIndicators : computedWithIndicators ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselIndicators, { ...indicatorsProps }) : null,
|
|
362
399
|
otherChildren
|
|
363
400
|
]
|
|
@@ -365,10 +402,12 @@ var Carousel = (0, import_core2.forwardRef)(
|
|
|
365
402
|
) });
|
|
366
403
|
}
|
|
367
404
|
);
|
|
368
|
-
var CarouselSlides = (0, import_core2.forwardRef)(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
});
|
|
405
|
+
var CarouselSlides = (0, import_core2.forwardRef)(
|
|
406
|
+
({ ...rest }, ref) => {
|
|
407
|
+
const css = { w: "100%", h: "fit-content", overflow: "hidden" };
|
|
408
|
+
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 }) });
|
|
409
|
+
}
|
|
410
|
+
);
|
|
372
411
|
var CarouselSlidesInner = ({ ...rest }) => {
|
|
373
412
|
const { orientation, includeGapInSize, gap, styles } = useCarouselContext();
|
|
374
413
|
const css = {
|
|
@@ -394,12 +433,31 @@ var CarouselSlide = (0, import_core3.forwardRef)(
|
|
|
394
433
|
flex: `0 0 ${size}`,
|
|
395
434
|
...includeGapInSize ? { [orientation === "vertical" ? "pb" : "pr"]: gap } : { [orientation === "vertical" ? "mb" : "mr"]: gap }
|
|
396
435
|
};
|
|
397
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
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
|
+
);
|
|
398
459
|
}
|
|
399
460
|
);
|
|
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
461
|
|
|
404
462
|
// src/carousel-control.tsx
|
|
405
463
|
var import_button = require("@yamada-ui/button");
|
|
@@ -453,29 +511,27 @@ var CarouselControlNext = (0, import_core4.forwardRef)(
|
|
|
453
511
|
);
|
|
454
512
|
}
|
|
455
513
|
);
|
|
456
|
-
var CarouselControl = (0, import_core4.forwardRef)(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
);
|
|
514
|
+
var CarouselControl = (0, import_core4.forwardRef)(({ className, operation, ...rest }, ref) => {
|
|
515
|
+
const { styles } = useCarouselContext();
|
|
516
|
+
const colorScheme = (0, import_core4.useColorModetValue)("whiteAlpha", "blackAlpha");
|
|
517
|
+
const css = {
|
|
518
|
+
position: "absolute",
|
|
519
|
+
zIndex: "kurillin",
|
|
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
|
+
});
|
|
479
535
|
|
|
480
536
|
// src/carousel-indicators.tsx
|
|
481
537
|
var import_core5 = require("@yamada-ui/core");
|
|
@@ -494,22 +550,37 @@ var CarouselIndicators = (0, import_core5.forwardRef)(
|
|
|
494
550
|
...styles.indicators,
|
|
495
551
|
...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
|
|
496
552
|
};
|
|
497
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
554
|
+
import_core5.ui.div,
|
|
555
|
+
{
|
|
556
|
+
ref,
|
|
557
|
+
className: (0, import_utils5.cx)("ui-carousel-indicators", className),
|
|
558
|
+
__css: css,
|
|
559
|
+
...rest,
|
|
560
|
+
children: indexes.map((index) => {
|
|
561
|
+
const isSelected = index === selectedIndex;
|
|
562
|
+
if (typeof component === "function") {
|
|
563
|
+
const child = component({
|
|
564
|
+
index,
|
|
565
|
+
isSelected
|
|
566
|
+
});
|
|
567
|
+
if (!child)
|
|
568
|
+
return null;
|
|
569
|
+
const props = getIndicatorProps({ ...child.props, index });
|
|
570
|
+
return (0, import_react3.cloneElement)(child, props);
|
|
571
|
+
} else {
|
|
572
|
+
const { key, ...props } = getIndicatorProps({ index });
|
|
573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicator, { ...props }, key);
|
|
574
|
+
}
|
|
575
|
+
})
|
|
508
576
|
}
|
|
509
|
-
|
|
577
|
+
);
|
|
510
578
|
}
|
|
511
579
|
);
|
|
512
|
-
var CarouselIndicator = ({
|
|
580
|
+
var CarouselIndicator = ({
|
|
581
|
+
className,
|
|
582
|
+
...rest
|
|
583
|
+
}) => {
|
|
513
584
|
const { styles } = useCarouselContext();
|
|
514
585
|
const css = { ...styles.indicator };
|
|
515
586
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Carousel
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4PHQQK4S.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CarouselControlNext,
|
|
6
6
|
CarouselControlPrev
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-D5HQSKWR.mjs";
|
|
8
8
|
import {
|
|
9
9
|
CarouselIndicators
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6FKEASJN.mjs";
|
|
11
11
|
import {
|
|
12
12
|
CarouselSlide
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-T2MDCOCV.mjs";
|
|
14
|
+
import "./chunk-QR66JOUK.mjs";
|
|
15
15
|
export {
|
|
16
16
|
Carousel,
|
|
17
17
|
CarouselControlNext,
|
package/dist/use-carousel.js
CHANGED
|
@@ -97,7 +97,9 @@ var useCarousel = ({
|
|
|
97
97
|
const onScroll = (0, import_react.useCallback)(() => {
|
|
98
98
|
if (!carousel)
|
|
99
99
|
return;
|
|
100
|
-
const progress = Math.round(
|
|
100
|
+
const progress = Math.round(
|
|
101
|
+
Math.max(0, Math.min(1, carousel.scrollProgress())) * 100
|
|
102
|
+
);
|
|
101
103
|
onScrollProgress == null ? void 0 : onScrollProgress(progress);
|
|
102
104
|
}, [carousel, onScrollProgress]);
|
|
103
105
|
const onSelect = (0, import_react.useCallback)(() => {
|
|
@@ -122,7 +124,15 @@ var useCarousel = ({
|
|
|
122
124
|
if (timeoutId.current)
|
|
123
125
|
clearInterval(timeoutId.current);
|
|
124
126
|
};
|
|
125
|
-
}, [
|
|
127
|
+
}, [
|
|
128
|
+
autoplay,
|
|
129
|
+
delay,
|
|
130
|
+
stopMouseEnterAutoplay,
|
|
131
|
+
carousel,
|
|
132
|
+
isMouseEnter,
|
|
133
|
+
loop,
|
|
134
|
+
selectedIndex
|
|
135
|
+
]);
|
|
126
136
|
(0, import_utils.useUpdateEffect)(() => {
|
|
127
137
|
if (!carousel)
|
|
128
138
|
return;
|
|
@@ -215,7 +225,10 @@ var useCarouselSlide = ({ index }) => {
|
|
|
215
225
|
);
|
|
216
226
|
return { getSlideProps };
|
|
217
227
|
};
|
|
218
|
-
var useCarouselControl = ({
|
|
228
|
+
var useCarouselControl = ({
|
|
229
|
+
operation,
|
|
230
|
+
...rest
|
|
231
|
+
}) => {
|
|
219
232
|
var _a, _b;
|
|
220
233
|
const { carousel } = useCarouselContext();
|
|
221
234
|
const isPrev = operation === "prev";
|
package/dist/use-carousel.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/carousel",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Yamada UI carousel component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yamada",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"embla-carousel-react": "^7.0.0",
|
|
39
|
-
"@yamada-ui/button": "0.2.
|
|
40
|
-
"@yamada-ui/core": "0.5.
|
|
41
|
-
"@yamada-ui/icon": "0.2.
|
|
42
|
-
"@yamada-ui/use-controllable-state": "0.1.
|
|
43
|
-
"@yamada-ui/use-token": "0.1.
|
|
44
|
-
"@yamada-ui/use-value": "0.1.
|
|
45
|
-
"@yamada-ui/utils": "0.1.
|
|
39
|
+
"@yamada-ui/button": "0.2.7",
|
|
40
|
+
"@yamada-ui/core": "0.5.2",
|
|
41
|
+
"@yamada-ui/icon": "0.2.7",
|
|
42
|
+
"@yamada-ui/use-controllable-state": "0.1.5",
|
|
43
|
+
"@yamada-ui/use-token": "0.1.19",
|
|
44
|
+
"@yamada-ui/use-value": "0.1.19",
|
|
45
|
+
"@yamada-ui/utils": "0.1.4"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"clean-package": "2.2.0",
|