@yamada-ui/carousel 0.2.4 → 0.2.6

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.
@@ -0,0 +1,8 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { IconButtonProps } from '@yamada-ui/button';
3
+
4
+ type CarouselControlProps = IconButtonProps;
5
+ declare const CarouselControlPrev: _yamada_ui_core.Component<"button", IconButtonProps>;
6
+ declare const CarouselControlNext: _yamada_ui_core.Component<"button", IconButtonProps>;
7
+
8
+ export { CarouselControlNext, CarouselControlPrev, CarouselControlProps };
@@ -0,0 +1,17 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps } from '@yamada-ui/core';
3
+ import { FC } from 'react';
4
+
5
+ type CarouselIndicatorsOptions = {
6
+ /**
7
+ * The custom curousel indicator to use.
8
+ */
9
+ component?: FC<{
10
+ index: number;
11
+ isSelected: boolean;
12
+ }>;
13
+ };
14
+ type CarouselIndicatorsProps = Omit<HTMLUIProps<'div'>, 'children'> & CarouselIndicatorsOptions;
15
+ declare const CarouselIndicators: _yamada_ui_core.Component<"div", CarouselIndicatorsProps>;
16
+
17
+ export { CarouselIndicators, CarouselIndicatorsProps };
@@ -0,0 +1,18 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, UIProps } from '@yamada-ui/core';
3
+ import { UseCarouselSlideProps } from './use-carousel.mjs';
4
+ import 'react';
5
+ import '@yamada-ui/button';
6
+ import '@yamada-ui/utils';
7
+ import 'embla-carousel-react';
8
+
9
+ type CarouselSlideOptions = {
10
+ /**
11
+ * The CSS `width` property.
12
+ */
13
+ size?: UIProps['width'];
14
+ };
15
+ type CarouselSlideProps = HTMLUIProps<'div'> & UseCarouselSlideProps & CarouselSlideOptions;
16
+ declare const CarouselSlide: _yamada_ui_core.Component<"div", CarouselSlideProps>;
17
+
18
+ export { CarouselSlide, CarouselSlideProps };
@@ -0,0 +1,140 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { ThemeProps, HTMLUIProps, Token, UIProps } from '@yamada-ui/core';
3
+ import { UseCarouselProps } from './use-carousel.mjs';
4
+ import { CarouselControlProps } from './carousel-control.mjs';
5
+ import { CarouselIndicatorsProps } from './carousel-indicators.mjs';
6
+ import 'react';
7
+ import '@yamada-ui/button';
8
+ import '@yamada-ui/utils';
9
+ import 'embla-carousel-react';
10
+
11
+ type CarouselOptions = {
12
+ /**
13
+ * The orientation of the carousel.
14
+ *
15
+ * @default 'horizontal'
16
+ */
17
+ orientation?: Token<'vertical' | 'horizontal'>;
18
+ /**
19
+ * The alignment of the carousel.
20
+ *
21
+ * @default 'center'
22
+ */
23
+ align?: Token<'start' | 'center' | 'end' | number>;
24
+ /**
25
+ * Clear leading and trailing empty space that causes excessive scrolling.
26
+ * Use trimSnaps to only use snap points that trigger scrolling or keepSnaps to keep them.
27
+ *
28
+ * @default ''
29
+ */
30
+ containScroll?: Token<'trimSnaps' | 'keepSnaps' | ''>;
31
+ /**
32
+ * The number of slides that should be scrolled with next or previous buttons.
33
+ *
34
+ * @default 1
35
+ */
36
+ slidesToScroll?: Token<number>;
37
+ /**
38
+ * If `true`, momentum scrolling will be enabled.
39
+ *
40
+ * @default false
41
+ */
42
+ dragFree?: Token<boolean>;
43
+ /**
44
+ * If `true`, carousel can be scrolled with mouse and touch interactions.
45
+ *
46
+ * @default true
47
+ */
48
+ draggable?: Token<boolean>;
49
+ /**
50
+ * Choose a fraction representing the percentage portion of a slide that needs to be visible in order to be considered in view.
51
+ *
52
+ * @default 0
53
+ */
54
+ inViewThreshold?: Token<number>;
55
+ /**
56
+ * If `true`, infinite looping.
57
+ * Automatically falls back to false if slide content isn't enough to loop.
58
+ *
59
+ * @default true
60
+ */
61
+ loop?: Token<boolean>;
62
+ /**
63
+ * If `true`, allow the carousel to skip scroll snaps if it's dragged vigorously.
64
+ * Note that this option will be ignored if the dragFree option is set to true.
65
+ *
66
+ * @default false
67
+ */
68
+ skipSnaps?: Token<boolean>;
69
+ /**
70
+ * Adjusts scroll speed when triggered by any of the methods.
71
+ * Higher numbers enables faster scrolling.
72
+ *
73
+ * @default 10
74
+ */
75
+ speed?: Token<number>;
76
+ /**
77
+ * The number for the autoplay interval of the carousel.
78
+ *
79
+ * @default 4000
80
+ */
81
+ delay?: Token<number>;
82
+ /**
83
+ * If `true`, the carousel will be autoplay.
84
+ *
85
+ * @default false
86
+ */
87
+ autoplay?: Token<boolean>;
88
+ /**
89
+ * If `true`, autoplay will pause when the mouse entries over.
90
+ *
91
+ * @default true
92
+ */
93
+ stopMouseEnterAutoplay?: Token<boolean>;
94
+ /**
95
+ * If `true`, gap will be treated as part of the carousel slide size.
96
+ *
97
+ * @default true
98
+ */
99
+ includeGapInSize?: Token<boolean>;
100
+ /**
101
+ * The CSS `width` property.
102
+ */
103
+ slideSize?: UIProps['width'];
104
+ /**
105
+ * Props for carousel inner element.
106
+ */
107
+ innerProps?: HTMLUIProps<'div'>;
108
+ /**
109
+ * If `true`, display the carousel control buttons.
110
+ *
111
+ * @default true
112
+ */
113
+ withControls?: Token<boolean>;
114
+ /**
115
+ * Props for carousel control element.
116
+ */
117
+ controlProps?: CarouselControlProps;
118
+ /**
119
+ * Props for previous of the carousel control element.
120
+ */
121
+ controlPrevProps?: CarouselControlProps;
122
+ /**
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
130
+ */
131
+ withIndicators?: Token<boolean>;
132
+ /**
133
+ * Props for carousel indicators element.
134
+ */
135
+ indicatorsProps?: CarouselIndicatorsProps;
136
+ };
137
+ type CarouselProps = ThemeProps<'Carousel'> & Omit<HTMLUIProps<'div'>, 'onChange' | 'draggable'> & Pick<UseCarouselProps, 'index' | 'defaultIndex' | 'onChange' | 'onScrollProgress'> & CarouselOptions;
138
+ declare const Carousel: _yamada_ui_core.Component<"div", CarouselProps>;
139
+
140
+ export { Carousel, CarouselProps };
@@ -0,0 +1,10 @@
1
+ export { Carousel, CarouselProps } from './carousel.mjs';
2
+ export { CarouselSlide, CarouselSlideProps } from './carousel-slide.mjs';
3
+ export { CarouselControlNext, CarouselControlPrev, CarouselControlProps } from './carousel-control.mjs';
4
+ export { CarouselIndicators, CarouselIndicatorsProps } from './carousel-indicators.mjs';
5
+ import '@yamada-ui/core';
6
+ import './use-carousel.mjs';
7
+ import 'react';
8
+ import '@yamada-ui/button';
9
+ import '@yamada-ui/utils';
10
+ import 'embla-carousel-react';
@@ -0,0 +1,177 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, UIProps, CSSUIObject } from '@yamada-ui/core';
3
+ import * as react from 'react';
4
+ import { IconButtonProps } from '@yamada-ui/button';
5
+ import { PropGetter, RequiredPropGetter } from '@yamada-ui/utils';
6
+ import { EmblaCarouselType } from 'embla-carousel-react';
7
+
8
+ type CarouselContext = {
9
+ carousel: EmblaCarouselType | undefined;
10
+ indexes: number[];
11
+ selectedIndex: number;
12
+ orientation: 'vertical' | 'horizontal';
13
+ includeGapInSize: boolean;
14
+ slidesToScroll: number;
15
+ slideSize: string | number;
16
+ gap: UIProps['gap'];
17
+ styles: Record<string, CSSUIObject>;
18
+ };
19
+ declare const CarouselProvider: react.Provider<CarouselContext>;
20
+ declare const useCarouselContext: () => CarouselContext;
21
+ type UseCarouselProps = Omit<HTMLUIProps<'div'>, 'onChange' | 'draggable' | 'gap'> & {
22
+ /**
23
+ * The index of the carousel slide.
24
+ */
25
+ index?: number;
26
+ /**
27
+ * The initial index of the carousel slide.
28
+ *
29
+ * @default 0
30
+ */
31
+ defaultIndex?: number;
32
+ /**
33
+ * The callback invoked when carousel slide selected.
34
+ */
35
+ onChange?: (index: number) => void;
36
+ /**
37
+ * The orientation of the carousel.
38
+ *
39
+ * @default 'horizontal'
40
+ */
41
+ orientation?: 'vertical' | 'horizontal';
42
+ /**
43
+ * The alignment of the carousel.
44
+ *
45
+ * @default 'center'
46
+ */
47
+ align?: 'start' | 'center' | 'end' | number;
48
+ /**
49
+ * Clear leading and trailing empty space that causes excessive scrolling.
50
+ * Use trimSnaps to only use snap points that trigger scrolling or keepSnaps to keep them.
51
+ *
52
+ * @default ''
53
+ */
54
+ containScroll?: 'trimSnaps' | 'keepSnaps' | '';
55
+ /**
56
+ * The number of slides that should be scrolled with next or previous buttons.
57
+ *
58
+ * @default 1
59
+ */
60
+ slidesToScroll?: number;
61
+ /**
62
+ * If `true`, momentum scrolling will be enabled.
63
+ *
64
+ * @default false
65
+ */
66
+ dragFree?: boolean;
67
+ /**
68
+ * If `true`, carousel can be scrolled with mouse and touch interactions.
69
+ *
70
+ * @default true
71
+ */
72
+ draggable?: boolean;
73
+ /**
74
+ * Choose a fraction representing the percentage portion of a slide that needs to be visible in order to be considered in view.
75
+ *
76
+ * @default 0
77
+ */
78
+ inViewThreshold?: number;
79
+ /**
80
+ * If `true`, infinite looping.
81
+ * Automatically falls back to false if slide content isn't enough to loop.
82
+ *
83
+ * @default true
84
+ */
85
+ loop?: boolean;
86
+ /**
87
+ * If `true`, allow the carousel to skip scroll snaps if it's dragged vigorously.
88
+ * Note that this option will be ignored if the dragFree option is set to true.
89
+ *
90
+ * @default false
91
+ */
92
+ skipSnaps?: boolean;
93
+ /**
94
+ * Adjusts scroll speed when triggered by any of the methods.
95
+ * Higher numbers enables faster scrolling.
96
+ *
97
+ * @default 10
98
+ */
99
+ speed?: number;
100
+ /**
101
+ * The number for the autoplay interval of the carousel.
102
+ *
103
+ * @default 4000
104
+ */
105
+ delay?: number;
106
+ /**
107
+ * If `true`, the carousel will be autoplay.
108
+ *
109
+ * @default false
110
+ */
111
+ autoplay?: boolean;
112
+ /**
113
+ * If `true`, autoplay will pause when the mouse entries over.
114
+ *
115
+ * @default true
116
+ */
117
+ stopMouseEnterAutoplay?: boolean;
118
+ /**
119
+ * If `true`, gap will be treated as part of the carousel slide size.
120
+ *
121
+ * @default true
122
+ */
123
+ includeGapInSize?: boolean;
124
+ /**
125
+ * The CSS `gap` property.
126
+ *
127
+ * @default 'md'
128
+ */
129
+ gap?: UIProps['gap'];
130
+ /**
131
+ * The carousel slide width.
132
+ *
133
+ * @default '100%'
134
+ */
135
+ slideSize?: string | number;
136
+ /**
137
+ * A callback that return the current scroll amount when the carousel is scrolled.
138
+ */
139
+ onScrollProgress?: (progress: number) => void;
140
+ };
141
+ 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) => {
142
+ carousel: EmblaCarouselType | undefined;
143
+ children: react.ReactNode;
144
+ indexes: number[];
145
+ selectedIndex: number;
146
+ orientation: "vertical" | "horizontal";
147
+ slideSize: string | number;
148
+ gap: number | "px" | (string & {}) | "sm" | "md" | "lg" | "xl" | "2xl" | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "1" | "-1" | "2" | "-2" | "3" | "-3" | "4" | "-4" | "5" | "-5" | "6" | "-6" | "7" | "-7" | "8" | "-8" | "9" | "-9" | "10" | "-10" | "12" | "-12" | "14" | "-14" | "16" | "-16" | "20" | "-20" | "24" | "-24" | "28" | "-28" | "32" | "-32" | "36" | "-36" | "40" | "-40" | "44" | "-44" | "48" | "-48" | "52" | "-52" | "56" | "-56" | "60" | "-60" | "64" | "-64" | "70" | "-70" | "72" | "-72" | "80" | "-80" | "84" | "-84" | "96" | "-96" | "xs" | "-xs" | "-sm" | "-md" | "normal" | "-normal" | "-lg" | "-xl" | "-2xl" | "3xl" | "-3xl" | "4xl" | "-4xl" | "-px" | "0.5" | "-0.5" | "1.5" | "-1.5" | "2.5" | "-2.5" | "3.5" | "-3.5" | _yamada_ui_core.ResponsiveObject<number | "px" | (string & {}) | "sm" | "md" | "lg" | "xl" | "2xl" | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "1" | "-1" | "2" | "-2" | "3" | "-3" | "4" | "-4" | "5" | "-5" | "6" | "-6" | "7" | "-7" | "8" | "-8" | "9" | "-9" | "10" | "-10" | "12" | "-12" | "14" | "-14" | "16" | "-16" | "20" | "-20" | "24" | "-24" | "28" | "-28" | "32" | "-32" | "36" | "-36" | "40" | "-40" | "44" | "-44" | "48" | "-48" | "52" | "-52" | "56" | "-56" | "60" | "-60" | "64" | "-64" | "70" | "-70" | "72" | "-72" | "80" | "-80" | "84" | "-84" | "96" | "-96" | "xs" | "-xs" | "-sm" | "-md" | "normal" | "-normal" | "-lg" | "-xl" | "-2xl" | "3xl" | "-3xl" | "4xl" | "-4xl" | "-px" | "0.5" | "-0.5" | "1.5" | "-1.5" | "2.5" | "-2.5" | "3.5" | "-3.5"> | _yamada_ui_core.ColorModeArray<number | "px" | (string & {}) | "sm" | "md" | "lg" | "xl" | "2xl" | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "1" | "-1" | "2" | "-2" | "3" | "-3" | "4" | "-4" | "5" | "-5" | "6" | "-6" | "7" | "-7" | "8" | "-8" | "9" | "-9" | "10" | "-10" | "12" | "-12" | "14" | "-14" | "16" | "-16" | "20" | "-20" | "24" | "-24" | "28" | "-28" | "32" | "-32" | "36" | "-36" | "40" | "-40" | "44" | "-44" | "48" | "-48" | "52" | "-52" | "56" | "-56" | "60" | "-60" | "64" | "-64" | "70" | "-70" | "72" | "-72" | "80" | "-80" | "84" | "-84" | "96" | "-96" | "xs" | "-xs" | "-sm" | "-md" | "normal" | "-normal" | "-lg" | "-xl" | "-2xl" | "3xl" | "-3xl" | "4xl" | "-4xl" | "-px" | "0.5" | "-0.5" | "1.5" | "-1.5" | "2.5" | "-2.5" | "3.5" | "-3.5">;
149
+ slidesToScroll: number;
150
+ includeGapInSize: boolean;
151
+ getContainerProps: PropGetter;
152
+ getSlidesProps: PropGetter;
153
+ };
154
+ type UseCarouselReturn = ReturnType<typeof useCarousel>;
155
+ type UseCarouselSlideProps = {
156
+ index?: number;
157
+ };
158
+ declare const useCarouselSlide: ({ index }: UseCarouselSlideProps) => {
159
+ getSlideProps: PropGetter;
160
+ };
161
+ type UseCarouselSlideReturn = ReturnType<typeof useCarouselSlide>;
162
+ type UseCarouselControlProps = IconButtonProps & {
163
+ operation: 'prev' | 'next';
164
+ };
165
+ declare const useCarouselControl: ({ operation, ...rest }: UseCarouselControlProps) => {
166
+ getControlProps: PropGetter;
167
+ };
168
+ type UseCarouselControlReturn = ReturnType<typeof useCarouselControl>;
169
+ declare const useCarouselIndicators: () => {
170
+ indexes: number[];
171
+ getIndicatorProps: RequiredPropGetter<{
172
+ index: number;
173
+ }>;
174
+ };
175
+ type UseCarouselIndicatorsReturn = ReturnType<typeof useCarouselIndicators>;
176
+
177
+ export { CarouselProvider, UseCarouselControlProps, UseCarouselControlReturn, UseCarouselIndicatorsReturn, UseCarouselProps, UseCarouselReturn, UseCarouselSlideProps, UseCarouselSlideReturn, useCarousel, useCarouselContext, useCarouselControl, useCarouselIndicators, useCarouselSlide };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/carousel",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
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.4",
40
- "@yamada-ui/core": "0.4.3",
41
- "@yamada-ui/icon": "0.2.4",
42
- "@yamada-ui/use-controllable-state": "0.1.3",
43
- "@yamada-ui/use-token": "0.1.16",
44
- "@yamada-ui/use-value": "0.1.16",
45
- "@yamada-ui/utils": "0.1.2"
39
+ "@yamada-ui/button": "0.2.6",
40
+ "@yamada-ui/core": "0.5.1",
41
+ "@yamada-ui/icon": "0.2.6",
42
+ "@yamada-ui/use-controllable-state": "0.1.4",
43
+ "@yamada-ui/use-token": "0.1.18",
44
+ "@yamada-ui/use-value": "0.1.18",
45
+ "@yamada-ui/utils": "0.1.3"
46
46
  },
47
47
  "devDependencies": {
48
48
  "clean-package": "2.2.0",