@yamada-ui/carousel 0.1.5 → 0.1.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.
@@ -78,17 +78,9 @@ var useCarouselIndicators = () => {
78
78
  // src/carousel-indicators.tsx
79
79
  var import_jsx_runtime = require("react/jsx-runtime");
80
80
  var CarouselIndicators = (0, import_core2.forwardRef)(
81
- ({ className, component = CarouselIndicator, ...rest }, ref) => {
81
+ ({ className, component, ...rest }, ref) => {
82
82
  const { selectedIndex, orientation, styles } = useCarouselContext();
83
83
  const { indexes, getIndicatorProps } = useCarouselIndicators();
84
- const cloneChildren = indexes.map((index) => {
85
- const isSelected = index === selectedIndex;
86
- const child = component({ index, isSelected });
87
- if (!child)
88
- return null;
89
- const props = getIndicatorProps({ ...child.props, index });
90
- return (0, import_react2.cloneElement)(child, props);
91
- });
92
84
  const css = {
93
85
  position: "absolute",
94
86
  zIndex: "kurillin",
@@ -97,7 +89,19 @@ var CarouselIndicators = (0, import_core2.forwardRef)(
97
89
  ...styles.indicators,
98
90
  ...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
99
91
  };
100
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-carousel-indicators", className), __css: css, ...rest, children: cloneChildren });
92
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-carousel-indicators", className), __css: css, ...rest, children: indexes.map((index) => {
93
+ const isSelected = index === selectedIndex;
94
+ if (typeof component === "function") {
95
+ const child = component({ index, isSelected });
96
+ if (!child)
97
+ return null;
98
+ const props = getIndicatorProps({ ...child.props, index });
99
+ return (0, import_react2.cloneElement)(child, props);
100
+ } else {
101
+ const { key, ...props } = getIndicatorProps({ index });
102
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CarouselIndicator, { ...props }, key);
103
+ }
104
+ }) });
101
105
  }
102
106
  );
103
107
  var CarouselIndicator = ({ className, ...rest }) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CarouselIndicators
3
- } from "./chunk-UMRTZXZW.mjs";
3
+ } from "./chunk-YF54MDFK.mjs";
4
4
  import "./chunk-4P3A5PTO.mjs";
5
5
  export {
6
6
  CarouselIndicators
@@ -1,9 +1,9 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps, UIProps } from '@yamada-ui/core';
3
3
  import { UseCarouselSlideProps } from './use-carousel.js';
4
- import '@yamada-ui/utils';
5
4
  import 'react';
6
5
  import '@yamada-ui/button';
6
+ import '@yamada-ui/utils';
7
7
  import 'embla-carousel-react';
8
8
 
9
9
  type CarouselSlideOptions = {
@@ -3,9 +3,9 @@ import { ThemeProps, HTMLUIProps, Token, UIProps } from '@yamada-ui/core';
3
3
  import { UseCarouselProps, Orientation, Align, ContainScroll } from './use-carousel.js';
4
4
  import { CarouselControlProps } from './carousel-control.js';
5
5
  import { CarouselIndicatorsProps } from './carousel-indicators.js';
6
- import '@yamada-ui/utils';
7
6
  import 'react';
8
7
  import '@yamada-ui/button';
8
+ import '@yamada-ui/utils';
9
9
  import 'embla-carousel-react';
10
10
 
11
11
  type CarouselOptions = {
package/dist/carousel.js CHANGED
@@ -374,17 +374,9 @@ var import_utils4 = require("@yamada-ui/utils");
374
374
  var import_react2 = require("react");
375
375
  var import_jsx_runtime3 = require("react/jsx-runtime");
376
376
  var CarouselIndicators = (0, import_core4.forwardRef)(
377
- ({ className, component = CarouselIndicator, ...rest }, ref) => {
377
+ ({ className, component, ...rest }, ref) => {
378
378
  const { selectedIndex, orientation, styles } = useCarouselContext();
379
379
  const { indexes, getIndicatorProps } = useCarouselIndicators();
380
- const cloneChildren = indexes.map((index) => {
381
- const isSelected = index === selectedIndex;
382
- const child = component({ index, isSelected });
383
- if (!child)
384
- return null;
385
- const props = getIndicatorProps({ ...child.props, index });
386
- return (0, import_react2.cloneElement)(child, props);
387
- });
388
380
  const css = {
389
381
  position: "absolute",
390
382
  zIndex: "kurillin",
@@ -393,7 +385,19 @@ var CarouselIndicators = (0, import_core4.forwardRef)(
393
385
  ...styles.indicators,
394
386
  ...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
395
387
  };
396
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core4.ui.div, { ref, className: (0, import_utils4.cx)("ui-carousel-indicators", className), __css: css, ...rest, children: cloneChildren });
388
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core4.ui.div, { ref, className: (0, import_utils4.cx)("ui-carousel-indicators", className), __css: css, ...rest, children: indexes.map((index) => {
389
+ const isSelected = index === selectedIndex;
390
+ if (typeof component === "function") {
391
+ const child = component({ index, isSelected });
392
+ if (!child)
393
+ return null;
394
+ const props = getIndicatorProps({ ...child.props, index });
395
+ return (0, import_react2.cloneElement)(child, props);
396
+ } else {
397
+ const { key, ...props } = getIndicatorProps({ index });
398
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CarouselIndicator, { ...props }, key);
399
+ }
400
+ }) });
397
401
  }
398
402
  );
399
403
  var CarouselIndicator = ({ className, ...rest }) => {
package/dist/carousel.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Carousel
3
- } from "./chunk-PQ3S6YEB.mjs";
3
+ } from "./chunk-ASYTKKOY.mjs";
4
4
  import "./chunk-FDF2QUCY.mjs";
5
- import "./chunk-UMRTZXZW.mjs";
5
+ import "./chunk-YF54MDFK.mjs";
6
6
  import "./chunk-BWFAE3UJ.mjs";
7
7
  import "./chunk-4P3A5PTO.mjs";
8
8
  export {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-FDF2QUCY.mjs";
5
5
  import {
6
6
  CarouselIndicators
7
- } from "./chunk-UMRTZXZW.mjs";
7
+ } from "./chunk-YF54MDFK.mjs";
8
8
  import {
9
9
  CarouselSlide
10
10
  } from "./chunk-BWFAE3UJ.mjs";
@@ -9,17 +9,9 @@ import { cx } from "@yamada-ui/utils";
9
9
  import { cloneElement } from "react";
10
10
  import { jsx } from "react/jsx-runtime";
11
11
  var CarouselIndicators = forwardRef(
12
- ({ className, component = CarouselIndicator, ...rest }, ref) => {
12
+ ({ className, component, ...rest }, ref) => {
13
13
  const { selectedIndex, orientation, styles } = useCarouselContext();
14
14
  const { indexes, getIndicatorProps } = useCarouselIndicators();
15
- const cloneChildren = indexes.map((index) => {
16
- const isSelected = index === selectedIndex;
17
- const child = component({ index, isSelected });
18
- if (!child)
19
- return null;
20
- const props = getIndicatorProps({ ...child.props, index });
21
- return cloneElement(child, props);
22
- });
23
15
  const css = {
24
16
  position: "absolute",
25
17
  zIndex: "kurillin",
@@ -28,7 +20,19 @@ var CarouselIndicators = forwardRef(
28
20
  ...styles.indicators,
29
21
  ...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
30
22
  };
31
- return /* @__PURE__ */ jsx(ui.div, { ref, className: cx("ui-carousel-indicators", className), __css: css, ...rest, children: cloneChildren });
23
+ return /* @__PURE__ */ jsx(ui.div, { ref, className: cx("ui-carousel-indicators", className), __css: css, ...rest, children: indexes.map((index) => {
24
+ const isSelected = index === selectedIndex;
25
+ if (typeof component === "function") {
26
+ const child = component({ index, isSelected });
27
+ if (!child)
28
+ return null;
29
+ const props = getIndicatorProps({ ...child.props, index });
30
+ return cloneElement(child, props);
31
+ } else {
32
+ const { key, ...props } = getIndicatorProps({ index });
33
+ return /* @__PURE__ */ jsx(CarouselIndicator, { ...props }, key);
34
+ }
35
+ }) });
32
36
  }
33
37
  );
34
38
  var CarouselIndicator = ({ className, ...rest }) => {
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { CarouselControlNext, CarouselControlPrev, CarouselControlProps } from '
4
4
  export { CarouselIndicators, CarouselIndicatorsProps } from './carousel-indicators.js';
5
5
  import '@yamada-ui/core';
6
6
  import './use-carousel.js';
7
- import '@yamada-ui/utils';
8
7
  import 'react';
9
8
  import '@yamada-ui/button';
9
+ import '@yamada-ui/utils';
10
10
  import 'embla-carousel-react';
package/dist/index.js CHANGED
@@ -483,17 +483,9 @@ var import_utils5 = require("@yamada-ui/utils");
483
483
  var import_react3 = require("react");
484
484
  var import_jsx_runtime4 = require("react/jsx-runtime");
485
485
  var CarouselIndicators = (0, import_core5.forwardRef)(
486
- ({ className, component = CarouselIndicator, ...rest }, ref) => {
486
+ ({ className, component, ...rest }, ref) => {
487
487
  const { selectedIndex, orientation, styles } = useCarouselContext();
488
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
489
  const css = {
498
490
  position: "absolute",
499
491
  zIndex: "kurillin",
@@ -502,7 +494,19 @@ var CarouselIndicators = (0, import_core5.forwardRef)(
502
494
  ...styles.indicators,
503
495
  ...orientation === "vertical" ? { flexDirection: "column" } : { flexDirection: "row" }
504
496
  };
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 });
497
+ 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: indexes.map((index) => {
498
+ const isSelected = index === selectedIndex;
499
+ if (typeof component === "function") {
500
+ const child = component({ index, isSelected });
501
+ if (!child)
502
+ return null;
503
+ const props = getIndicatorProps({ ...child.props, index });
504
+ return (0, import_react3.cloneElement)(child, props);
505
+ } else {
506
+ const { key, ...props } = getIndicatorProps({ index });
507
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CarouselIndicator, { ...props }, key);
508
+ }
509
+ }) });
506
510
  }
507
511
  );
508
512
  var CarouselIndicator = ({ className, ...rest }) => {
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Carousel
3
- } from "./chunk-PQ3S6YEB.mjs";
3
+ } from "./chunk-ASYTKKOY.mjs";
4
4
  import {
5
5
  CarouselControlNext,
6
6
  CarouselControlPrev
7
7
  } from "./chunk-FDF2QUCY.mjs";
8
8
  import {
9
9
  CarouselIndicators
10
- } from "./chunk-UMRTZXZW.mjs";
10
+ } from "./chunk-YF54MDFK.mjs";
11
11
  import {
12
12
  CarouselSlide
13
13
  } from "./chunk-BWFAE3UJ.mjs";
@@ -1,8 +1,7 @@
1
- import * as _yamada_ui_utils from '@yamada-ui/utils';
2
- import { PropGetter, RequiredPropGetter } from '@yamada-ui/utils';
3
1
  import * as react from 'react';
4
2
  import { IconButtonProps } from '@yamada-ui/button';
5
3
  import { HTMLUIProps, CSSUIObject } from '@yamada-ui/core';
4
+ import { PropGetter, RequiredPropGetter } from '@yamada-ui/utils';
6
5
  import { EmblaCarouselType } from 'embla-carousel-react';
7
6
 
8
7
  type Orientation = 'vertical' | 'horizontal';
@@ -53,29 +52,29 @@ declare const useCarousel: ({ index, defaultIndex, onChange, align, orientation,
53
52
  gap: string | number;
54
53
  slidesToScroll: number;
55
54
  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>>;
55
+ getContainerProps: PropGetter;
56
+ getSlidesProps: PropGetter;
58
57
  };
59
58
  type UseCarouselReturn = ReturnType<typeof useCarousel>;
60
59
  type UseCarouselSlideProps = {
61
60
  index?: number;
62
61
  };
63
62
  declare const useCarouselSlide: ({ index }: UseCarouselSlideProps) => {
64
- getSlideProps: PropGetter<Record<string, unknown>, _yamada_ui_utils.DOMAttributes<Element & HTMLOrSVGElement>>;
63
+ getSlideProps: PropGetter;
65
64
  };
66
65
  type UseCarouselSlideReturn = ReturnType<typeof useCarouselSlide>;
67
66
  type UseCarouselControlProps = IconButtonProps & {
68
67
  operation: 'prev' | 'next';
69
68
  };
70
69
  declare const useCarouselControl: ({ operation, ...rest }: UseCarouselControlProps) => {
71
- getControlProps: PropGetter<Record<string, unknown>, _yamada_ui_utils.DOMAttributes<Element & HTMLOrSVGElement>>;
70
+ getControlProps: PropGetter;
72
71
  };
73
72
  type UseCarouselControlReturn = ReturnType<typeof useCarouselControl>;
74
73
  declare const useCarouselIndicators: () => {
75
74
  indexes: number[];
76
75
  getIndicatorProps: RequiredPropGetter<{
77
76
  index: number;
78
- }, _yamada_ui_utils.DOMAttributes<Element & HTMLOrSVGElement>>;
77
+ }>;
79
78
  };
80
79
  type UseCarouselIndicatorsReturn = ReturnType<typeof useCarouselIndicators>;
81
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/carousel",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Yamada UI carousel component",
5
5
  "keywords": [
6
6
  "yamada",
@@ -36,12 +36,12 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "embla-carousel-react": "^7.0.0",
39
- "@yamada-ui/button": "0.1.5",
40
- "@yamada-ui/core": "0.1.5",
41
- "@yamada-ui/icon": "0.1.5",
39
+ "@yamada-ui/button": "0.1.6",
40
+ "@yamada-ui/core": "0.1.6",
41
+ "@yamada-ui/icon": "0.1.6",
42
42
  "@yamada-ui/use-controllable-state": "0.1.1",
43
- "@yamada-ui/use-token": "0.1.5",
44
- "@yamada-ui/use-value": "0.1.5",
43
+ "@yamada-ui/use-token": "0.1.6",
44
+ "@yamada-ui/use-value": "0.1.6",
45
45
  "@yamada-ui/utils": "0.1.1"
46
46
  },
47
47
  "devDependencies": {