@mantine/carousel 6.0.17 → 7.0.0-alpha.21

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.
Files changed (45) hide show
  1. package/cjs/Carousel.context.js +4 -3
  2. package/cjs/Carousel.context.js.map +1 -1
  3. package/cjs/Carousel.js +150 -118
  4. package/cjs/Carousel.js.map +1 -1
  5. package/cjs/Carousel.module.css.js +8 -0
  6. package/cjs/Carousel.module.css.js.map +1 -0
  7. package/cjs/CarouselSlide/CarouselSlide.js +17 -21
  8. package/cjs/CarouselSlide/CarouselSlide.js.map +1 -1
  9. package/cjs/CarouselVariables/CarouselVariables.js +45 -0
  10. package/cjs/CarouselVariables/CarouselVariables.js.map +1 -0
  11. package/cjs/get-chevron-rotation.js.map +1 -1
  12. package/cjs/index.css +205 -0
  13. package/cjs/index.js +3 -0
  14. package/cjs/index.js.map +1 -1
  15. package/cjs/use-animation-offset-effect.js.map +1 -1
  16. package/esm/Carousel.context.js +4 -3
  17. package/esm/Carousel.context.js.map +1 -1
  18. package/esm/Carousel.js +151 -118
  19. package/esm/Carousel.js.map +1 -1
  20. package/esm/Carousel.module.css.js +4 -0
  21. package/esm/Carousel.module.css.js.map +1 -0
  22. package/esm/CarouselSlide/CarouselSlide.js +19 -23
  23. package/esm/CarouselSlide/CarouselSlide.js.map +1 -1
  24. package/esm/CarouselVariables/CarouselVariables.js +37 -0
  25. package/esm/CarouselVariables/CarouselVariables.js.map +1 -0
  26. package/esm/get-chevron-rotation.js.map +1 -1
  27. package/esm/index.css +205 -0
  28. package/esm/index.js +2 -0
  29. package/esm/index.js.map +1 -1
  30. package/esm/use-animation-offset-effect.js.map +1 -1
  31. package/lib/Carousel.context.d.ts +8 -16
  32. package/lib/Carousel.context.d.ts.map +1 -1
  33. package/lib/Carousel.d.ts +54 -43
  34. package/lib/Carousel.d.ts.map +1 -1
  35. package/lib/CarouselSlide/CarouselSlide.d.ts +15 -12
  36. package/lib/CarouselSlide/CarouselSlide.d.ts.map +1 -1
  37. package/lib/CarouselVariables/CarouselVariables.d.ts +8 -0
  38. package/lib/CarouselVariables/CarouselVariables.d.ts.map +1 -0
  39. package/lib/get-chevron-rotation.d.ts +1 -2
  40. package/lib/get-chevron-rotation.d.ts.map +1 -1
  41. package/lib/index.d.ts +4 -2
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/use-animation-offset-effect.d.ts +2 -2
  44. package/lib/use-animation-offset-effect.d.ts.map +1 -1
  45. package/package.json +18 -11
@@ -1 +1 @@
1
- {"version":3,"file":"get-chevron-rotation.js","sources":["../src/get-chevron-rotation.ts"],"sourcesContent":["import { CarouselOrientation } from './types';\n\ninterface Options {\n dir: 'rtl' | 'ltr';\n orientation: CarouselOrientation;\n direction: 'next' | 'previous';\n}\n\nexport function getChevronRotation({ dir, orientation, direction }: Options) {\n if (direction === 'previous') {\n return orientation === 'horizontal' ? 90 * (dir === 'ltr' ? 1 : -1) : -180;\n }\n\n return orientation === 'horizontal' ? 90 * (dir === 'ltr' ? -1 : 1) : 0;\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,kBAAkB,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE;AACpE,EAAE,IAAI,SAAS,KAAK,UAAU,EAAE;AAChC,IAAI,OAAO,WAAW,KAAK,YAAY,GAAG,EAAE,IAAI,GAAG,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;AAC/E,GAAG;AACH,EAAE,OAAO,WAAW,KAAK,YAAY,GAAG,EAAE,IAAI,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC1E;;;;"}
1
+ {"version":3,"file":"get-chevron-rotation.js","sources":["../src/get-chevron-rotation.ts"],"sourcesContent":["interface Options {\n dir: 'rtl' | 'ltr';\n orientation: 'horizontal' | 'vertical' | undefined;\n direction: 'next' | 'previous';\n}\n\nexport function getChevronRotation({ dir, orientation, direction }: Options) {\n if (direction === 'previous') {\n return orientation === 'horizontal' ? 90 * (dir === 'ltr' ? 1 : -1) : -180;\n }\n\n return orientation === 'horizontal' ? 90 * (dir === 'ltr' ? -1 : 1) : 0;\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,kBAAkB,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE;AACpE,EAAE,IAAI,SAAS,KAAK,UAAU,EAAE;AAChC,IAAI,OAAO,WAAW,KAAK,YAAY,GAAG,EAAE,IAAI,GAAG,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;AAC/E,GAAG;AACH,EAAE,OAAO,WAAW,KAAK,YAAY,GAAG,EAAE,IAAI,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC1E;;;;"}
package/cjs/index.css ADDED
@@ -0,0 +1,205 @@
1
+ .m-17884d0f {
2
+ position: relative;
3
+ }
4
+
5
+ .m-a2dae653 {
6
+ height: var(--carousel-height, auto);
7
+ overflow: hidden;
8
+ }
9
+
10
+ .m-fcd81474 {
11
+ display: flex;
12
+ flex-direction: var(--_container-direction, row);
13
+ height: var(--carousel-height, auto);
14
+ margin-right: var(--_container-mr);
15
+ margin-left: var(--_container-ml);
16
+ margin-bottom: var(--_container-mb);
17
+ }
18
+
19
+ [data-include-gap-in-size] .m-fcd81474[data-orientation='vertical'] {
20
+ --_container-mb: calc(var(--carousel-slide-gap) * -1);
21
+ }
22
+
23
+ [data-include-gap-in-size] .m-fcd81474[data-orientation='horizontal'] {
24
+ --_container-mr: calc(var(--carousel-slide-gap) * -1);
25
+ }
26
+
27
+ [dir="rtl"] [data-include-gap-in-size] .m-fcd81474[data-orientation='horizontal'] {
28
+ --_container-ml: calc(var(--carousel-slide-gap) * -1);
29
+ --_container-mr: 0;
30
+ }
31
+
32
+ .m-fcd81474[data-orientation='vertical'] {
33
+ --_container-direction: column;
34
+ }
35
+
36
+ .m-39bc3463 {
37
+ position: absolute;
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: space-between;
41
+ z-index: 1;
42
+ pointer-events: none;
43
+ flex-direction: var(--_controls-direction);
44
+ left: var(--_controls-left);
45
+ right: var(--_controls-right);
46
+ top: var(--_controls-top);
47
+ bottom: var(--_controls-bottom);
48
+ padding: var(--_controls-padding);
49
+ }
50
+
51
+ .m-17884d0f[data-orientation='vertical'] .m-39bc3463 {
52
+ --_controls-left: calc(50% - var(--carousel-control-size) / 2);
53
+ --_controls-top: 0;
54
+ --_controls-bottom: 0;
55
+ --_controls-direction: column;
56
+ --_controls-padding: var(--carousel-controls-offset) 0;
57
+ }
58
+
59
+ .m-17884d0f[data-orientation='horizontal'] .m-39bc3463 {
60
+ --_controls-left: 0;
61
+ --_controls-right: 0;
62
+ --_controls-top: calc(50% - var(--carousel-control-size) / 2);
63
+ --_controls-direction: row;
64
+ --_controls-padding: 0 var(--carousel-controls-offset);
65
+ }
66
+
67
+ .m-64f58e10 {
68
+ display: flex;
69
+ justify-content: center;
70
+ align-items: center;
71
+ min-width: var(--carousel-control-size);
72
+ min-height: var(--carousel-control-size);
73
+ border-radius: var(--carousel-control-size);
74
+ pointer-events: all;
75
+ background-color: var(--mantine-color-white);
76
+ color: var(--mantine-color-black);
77
+ box-shadow: var(--mantine-shadow-md);
78
+ opacity: var(--_control-opacity);
79
+ border: calc(0.0625rem * var(--mantine-scale)) solid var(--mantine-color-gray-3);
80
+ transition: opacity 100ms ease;
81
+ }
82
+
83
+ [data-mantine-color-scheme='light'] .m-64f58e10 {
84
+ --_control-opacity: 0.85;
85
+ }
86
+
87
+ [data-mantine-color-scheme='dark'] .m-64f58e10 {
88
+ --_control-opacity: 0.65;
89
+ }
90
+
91
+ @media (hover: hover) {
92
+
93
+ .m-64f58e10:hover {
94
+ --_control-opacity: 1;
95
+ }
96
+ }
97
+
98
+ @media (hover: none) {
99
+
100
+ .m-64f58e10:active {
101
+ --_control-opacity: 1;
102
+ }
103
+ }
104
+
105
+ .m-71ea3ab1 {
106
+ position: absolute;
107
+ display: flex;
108
+ justify-content: center;
109
+ gap: calc(0.5rem * var(--mantine-scale));
110
+ pointer-events: none;
111
+ flex-direction: var(--_indicators-direction);
112
+ bottom: var(--_indicators-bottom);
113
+ left: var(--_indicators-left);
114
+ right: var(--_indicators-right);
115
+ top: var(--_indicators-top);
116
+ }
117
+
118
+ .m-17884d0f[data-orientation='vertical'] .m-71ea3ab1 {
119
+ --_indicators-bottom: 0;
120
+ --_indicators-top: 0;
121
+ --_indicators-right: var(--mantine-spacing-md);
122
+ --_indicators-direction: column;
123
+ }
124
+
125
+ .m-17884d0f[data-orientation='horizontal'] .m-71ea3ab1 {
126
+ --_indicators-bottom: var(--mantine-spacing-md);
127
+ --_indicators-left: 0;
128
+ --_indicators-right: 0;
129
+ --_indicators-direction: row;
130
+ }
131
+
132
+ .m-eae68602 {
133
+ pointer-events: all;
134
+ width: var(--_indicator-width);
135
+ height: var(--_indicator-height);
136
+ border-radius: var(--mantine-radius-xl);
137
+ box-shadow: var(--mantine-shadow-sm);
138
+ opacity: var(--_indicator-opacity, 0.6);
139
+ background-color: var(--mantine-color-white);
140
+ }
141
+
142
+ @media (hover: hover) {
143
+
144
+ .m-eae68602:hover {
145
+ --_indicator-opacity: 1;
146
+ }
147
+ }
148
+
149
+ @media (hover: none) {
150
+
151
+ .m-eae68602:active {
152
+ --_indicator-opacity: 1;
153
+ }
154
+ }
155
+
156
+ .m-eae68602[data-active] {
157
+ --_indicator-opacity: 1;
158
+ }
159
+
160
+ .m-17884d0f[data-orientation='vertical'] .m-eae68602 {
161
+ --_indicator-width: calc(0.3125rem * var(--mantine-scale));
162
+ --_indicator-height: calc(1.5625rem * var(--mantine-scale));
163
+ }
164
+
165
+ .m-17884d0f[data-orientation='horizontal'] .m-eae68602 {
166
+ --_indicator-width: calc(1.5625rem * var(--mantine-scale));
167
+ --_indicator-height: calc(0.3125rem * var(--mantine-scale));
168
+ }
169
+
170
+ .m-d98df724 {
171
+ position: relative;
172
+ flex: 0 0 var(--carousel-slide-size);
173
+ padding-right: var(--_slide-pr, 0);
174
+ padding-left: var(--_slide-pl, 0);
175
+ padding-bottom: var(--_slide-pb, 0);
176
+ margin-right: var(--_slide-mr, 0);
177
+ margin-left: var(--_slide-ml, 0);
178
+ margin-bottom: var(--_slide-mb, 0);
179
+ }
180
+
181
+ .m-17884d0f[data-include-gap-in-size] .m-d98df724[data-orientation='vertical'] {
182
+ --_slide-pb: var(--carousel-slide-gap);
183
+ }
184
+
185
+ .m-17884d0f[data-include-gap-in-size] .m-d98df724[data-orientation='horizontal'] {
186
+ --_slide-pr: var(--carousel-slide-gap);
187
+ }
188
+
189
+ [dir="rtl"] .m-17884d0f[data-include-gap-in-size] .m-d98df724[data-orientation='horizontal'] {
190
+ --_slide-pl: var(--carousel-slide-gap);
191
+ --_slide-pr: 0;
192
+ }
193
+
194
+ .m-17884d0f:not([data-include-gap-in-size]) .m-d98df724[data-orientation='vertical'] {
195
+ --_slide-mb: var(--carousel-slide-gap);
196
+ }
197
+
198
+ .m-17884d0f:not([data-include-gap-in-size]) .m-d98df724[data-orientation='horizontal'] {
199
+ --_slide-mr: var(--carousel-slide-gap);
200
+ }
201
+
202
+ [dir="rtl"] .m-17884d0f:not([data-include-gap-in-size]) .m-d98df724[data-orientation='horizontal'] {
203
+ --_slide-ml: var(--carousel-slide-gap);
204
+ --_slide-mr: 0;
205
+ }
package/cjs/index.js CHANGED
@@ -1,12 +1,15 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
4
  Object.defineProperty(exports, '__esModule', { value: true });
4
5
 
5
6
  var Carousel = require('./Carousel.js');
6
7
  var useAnimationOffsetEffect = require('./use-animation-offset-effect.js');
8
+ var CarouselSlide = require('./CarouselSlide/CarouselSlide.js');
7
9
 
8
10
 
9
11
 
10
12
  exports.Carousel = Carousel.Carousel;
11
13
  exports.useAnimationOffsetEffect = useAnimationOffsetEffect.useAnimationOffsetEffect;
14
+ exports.CarouselSlide = CarouselSlide.CarouselSlide;
12
15
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-animation-offset-effect.js","sources":["../src/use-animation-offset-effect.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { Embla } from './types';\n\nexport function useAnimationOffsetEffect(\n embla: Embla | null | undefined,\n transitionDuration: number\n) {\n useEffect(() => {\n if (embla) {\n window.setTimeout(() => {\n embla.reInit();\n }, transitionDuration);\n }\n }, [embla, transitionDuration]);\n}\n"],"names":["useEffect"],"mappings":";;;;;;AACO,SAAS,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,EAAE;AACpE,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,KAAK,EAAE;AACf,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM;AAC9B,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;AACvB,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC7B,KAAK;AACL,GAAG,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAClC;;;;"}
1
+ {"version":3,"file":"use-animation-offset-effect.js","sources":["../src/use-animation-offset-effect.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { EmblaCarouselType } from 'embla-carousel-react';\n\nexport function useAnimationOffsetEffect(\n embla: EmblaCarouselType | null | undefined,\n transitionDuration: number\n) {\n useEffect(() => {\n if (embla) {\n window.setTimeout(() => {\n embla.reInit();\n }, transitionDuration);\n }\n }, [embla, transitionDuration]);\n}\n"],"names":["useEffect"],"mappings":";;;;;;AACO,SAAS,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,EAAE;AACpE,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,KAAK,EAAE;AACf,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM;AAC9B,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;AACvB,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC7B,KAAK;AACL,GAAG,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAClC;;;;"}
@@ -1,7 +1,8 @@
1
- import { createSafeContext } from '@mantine/utils';
2
- import { CAROUSEL_ERRORS } from './Carousel.errors.js';
1
+ import { createSafeContext } from '@mantine/core';
3
2
 
4
- const [CarouselProvider, useCarouselContext] = createSafeContext(CAROUSEL_ERRORS.context);
3
+ const [CarouselProvider, useCarouselContext] = createSafeContext(
4
+ "Carousel component was not found in tree"
5
+ );
5
6
 
6
7
  export { CarouselProvider, useCarouselContext };
7
8
  //# sourceMappingURL=Carousel.context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Carousel.context.js","sources":["../src/Carousel.context.ts"],"sourcesContent":["import { MantineNumberSize, Styles, ClassNames } from '@mantine/core';\nimport { createSafeContext } from '@mantine/utils';\nimport { CAROUSEL_ERRORS } from './Carousel.errors';\nimport { CarouselOrientation, Embla, CarouselBreakpoint } from './types';\nimport type { CarouselStylesNames } from './Carousel';\n\ninterface CarouselContext {\n embla: Embla;\n slideSize: string | number;\n slideGap: MantineNumberSize;\n orientation: CarouselOrientation;\n includeGapInSize: boolean;\n breakpoints: CarouselBreakpoint[];\n classNames: ClassNames<CarouselStylesNames>;\n styles: Styles<CarouselStylesNames>;\n unstyled: boolean;\n variant: string;\n}\n\nexport const [CarouselProvider, useCarouselContext] = createSafeContext<CarouselContext>(\n CAROUSEL_ERRORS.context\n);\n"],"names":[],"mappings":";;;AAEY,MAAC,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,GAAG,iBAAiB,CAAC,eAAe,CAAC,OAAO;;;;"}
1
+ {"version":3,"file":"Carousel.context.js","sources":["../src/Carousel.context.ts"],"sourcesContent":["import { createSafeContext, GetStylesApi } from '@mantine/core';\nimport type { CarouselFactory } from './Carousel';\n\ninterface CarouselContextValue {\n getStyles: GetStylesApi<CarouselFactory>;\n orientation: 'horizontal' | 'vertical' | undefined;\n}\n\nexport const [CarouselProvider, useCarouselContext] = createSafeContext<CarouselContextValue>(\n 'Carousel component was not found in tree'\n);\n"],"names":[],"mappings":";;AACY,MAAC,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,GAAG,iBAAiB;AACvE,EAAE,0CAA0C;AAC5C;;;;"}
package/esm/Carousel.js CHANGED
@@ -1,13 +1,16 @@
1
- import { useComponentDefaultProps, UnstyledButton, Box, ChevronIcon } from '@mantine/core';
1
+ import React, { useState, useCallback, useEffect, Children } from 'react';
2
+ import { createVarsResolver, rem, getSpacing, factory, useProps, useStyles, useRandomClassName, useDirection, UnstyledButton, Box, AccordionChevron } from '@mantine/core';
2
3
  import { clamp } from '@mantine/hooks';
3
4
  import useEmblaCarousel from 'embla-carousel-react';
4
- import React, { forwardRef, useState, useCallback, useEffect, Children } from 'react';
5
+ import { getChevronRotation } from './get-chevron-rotation.js';
5
6
  import { CarouselProvider } from './Carousel.context.js';
6
- import useStyles from './Carousel.styles.js';
7
7
  import { CarouselSlide } from './CarouselSlide/CarouselSlide.js';
8
- import { getChevronRotation } from './get-chevron-rotation.js';
8
+ import { CarouselVariables } from './CarouselVariables/CarouselVariables.js';
9
+ import classes from './Carousel.module.css.js';
9
10
 
10
11
  var __defProp = Object.defineProperty;
12
+ var __defProps = Object.defineProperties;
13
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
11
14
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
16
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -23,6 +26,7 @@ var __spreadValues = (a, b) => {
23
26
  }
24
27
  return a;
25
28
  };
29
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
30
  var __objRest = (source, exclude) => {
27
31
  var target = {};
28
32
  for (var prop in source)
@@ -56,21 +60,33 @@ const defaultProps = {
56
60
  containScroll: "",
57
61
  withKeyboardEvents: true
58
62
  };
59
- const _Carousel = forwardRef((props, ref) => {
60
- const _a = useComponentDefaultProps("Carousel", defaultProps, props), {
61
- children,
63
+ const varsResolver = createVarsResolver(
64
+ (_, { height, controlSize, controlsOffset }) => ({
65
+ root: {
66
+ "--carousel-height": rem(height),
67
+ "--carousel-control-size": rem(controlSize),
68
+ "--carousel-controls-offset": getSpacing(controlsOffset)
69
+ }
70
+ })
71
+ );
72
+ const Carousel = factory((_props, ref) => {
73
+ const props = useProps("Carousel", defaultProps, _props);
74
+ const _a = props, {
75
+ classNames,
62
76
  className,
77
+ style,
78
+ styles,
79
+ unstyled,
80
+ vars,
81
+ children,
63
82
  getEmblaApi,
64
83
  onNextSlide,
65
84
  onPreviousSlide,
66
85
  onSlideChange,
67
- nextControlLabel,
68
- previousControlLabel,
86
+ nextControlProps,
87
+ previousControlProps,
69
88
  controlSize,
70
89
  controlsOffset,
71
- classNames,
72
- styles,
73
- unstyled,
74
90
  slideSize,
75
91
  slideGap,
76
92
  orientation,
@@ -89,25 +105,25 @@ const _Carousel = forwardRef((props, ref) => {
89
105
  plugins,
90
106
  nextControlIcon,
91
107
  previousControlIcon,
92
- breakpoints,
93
108
  skipSnaps,
94
109
  containScroll,
95
- withKeyboardEvents,
96
- variant
110
+ withKeyboardEvents
97
111
  } = _a, others = __objRest(_a, [
98
- "children",
112
+ "classNames",
99
113
  "className",
114
+ "style",
115
+ "styles",
116
+ "unstyled",
117
+ "vars",
118
+ "children",
100
119
  "getEmblaApi",
101
120
  "onNextSlide",
102
121
  "onPreviousSlide",
103
122
  "onSlideChange",
104
- "nextControlLabel",
105
- "previousControlLabel",
123
+ "nextControlProps",
124
+ "previousControlProps",
106
125
  "controlSize",
107
126
  "controlsOffset",
108
- "classNames",
109
- "styles",
110
- "unstyled",
111
127
  "slideSize",
112
128
  "slideGap",
113
129
  "orientation",
@@ -126,27 +142,41 @@ const _Carousel = forwardRef((props, ref) => {
126
142
  "plugins",
127
143
  "nextControlIcon",
128
144
  "previousControlIcon",
129
- "breakpoints",
130
145
  "skipSnaps",
131
146
  "containScroll",
132
- "withKeyboardEvents",
133
- "variant"
147
+ "withKeyboardEvents"
134
148
  ]);
135
- const { classes, cx, theme } = useStyles({ controlSize, controlsOffset, orientation, height, includeGapInSize, breakpoints, slideGap }, { name: "Carousel", classNames, styles, unstyled, variant });
136
- const [emblaRefElement, embla] = useEmblaCarousel({
137
- axis: orientation === "horizontal" ? "x" : "y",
138
- direction: orientation === "horizontal" ? theme.dir : void 0,
139
- startIndex: initialSlide,
140
- loop,
141
- align,
142
- slidesToScroll,
143
- draggable,
144
- dragFree,
145
- speed,
146
- inViewThreshold,
147
- skipSnaps,
148
- containScroll
149
- }, plugins);
149
+ const getStyles = useStyles({
150
+ name: "Carousel",
151
+ classes,
152
+ props,
153
+ className,
154
+ style,
155
+ classNames,
156
+ styles,
157
+ unstyled,
158
+ vars,
159
+ varsResolver
160
+ });
161
+ const responsiveClassName = useRandomClassName();
162
+ const { dir } = useDirection();
163
+ const [emblaRefElement, embla] = useEmblaCarousel(
164
+ {
165
+ axis: orientation === "horizontal" ? "x" : "y",
166
+ direction: orientation === "horizontal" ? dir : void 0,
167
+ startIndex: initialSlide,
168
+ loop,
169
+ align,
170
+ slidesToScroll,
171
+ draggable,
172
+ dragFree,
173
+ speed,
174
+ inViewThreshold,
175
+ skipSnaps,
176
+ containScroll
177
+ },
178
+ plugins
179
+ );
150
180
  const [selected, setSelected] = useState(0);
151
181
  const [slidesCount, setSlidesCount] = useState(0);
152
182
  const handleScroll = useCallback((index) => embla && embla.scrollTo(index), [embla]);
@@ -165,18 +195,21 @@ const _Carousel = forwardRef((props, ref) => {
165
195
  embla == null ? void 0 : embla.scrollNext();
166
196
  onNextSlide == null ? void 0 : onNextSlide();
167
197
  }, [embla]);
168
- const handleKeydown = useCallback((event) => {
169
- if (withKeyboardEvents) {
170
- if (event.key === "ArrowRight") {
171
- event.preventDefault();
172
- handleNext();
198
+ const handleKeydown = useCallback(
199
+ (event) => {
200
+ if (withKeyboardEvents) {
201
+ if (event.key === "ArrowRight") {
202
+ event.preventDefault();
203
+ handleNext();
204
+ }
205
+ if (event.key === "ArrowLeft") {
206
+ event.preventDefault();
207
+ handlePrevious();
208
+ }
173
209
  }
174
- if (event.key === "ArrowLeft") {
175
- event.preventDefault();
176
- handlePrevious();
177
- }
178
- }
179
- }, [embla]);
210
+ },
211
+ [embla]
212
+ );
180
213
  useEffect(() => {
181
214
  if (embla) {
182
215
  getEmblaApi == null ? void 0 : getEmblaApi(embla);
@@ -193,78 +226,78 @@ const _Carousel = forwardRef((props, ref) => {
193
226
  if (embla) {
194
227
  embla.reInit();
195
228
  setSlidesCount(embla.scrollSnapList().length);
196
- setSelected((currentSelected) => clamp(currentSelected, 0, Children.toArray(children).length - 1));
229
+ setSelected(
230
+ (currentSelected) => clamp(currentSelected, 0, Children.toArray(children).length - 1)
231
+ );
197
232
  }
198
233
  }, [Children.toArray(children).length, slidesToScroll]);
199
234
  const canScrollPrev = (embla == null ? void 0 : embla.canScrollPrev()) || false;
200
235
  const canScrollNext = (embla == null ? void 0 : embla.canScrollNext()) || false;
201
- const indicators = Array(slidesCount).fill(0).map((_, index) => /* @__PURE__ */ React.createElement(UnstyledButton, {
202
- key: index,
203
- "data-active": index === selected || void 0,
204
- className: classes.indicator,
205
- "aria-hidden": true,
206
- tabIndex: -1,
207
- onClick: () => handleScroll(index)
208
- }));
209
- return /* @__PURE__ */ React.createElement(CarouselProvider, {
210
- value: {
211
- slideGap,
212
- slideSize,
213
- embla,
214
- orientation,
215
- includeGapInSize,
216
- breakpoints,
217
- classNames,
218
- styles,
219
- unstyled,
220
- variant
221
- }
222
- }, /* @__PURE__ */ React.createElement(Box, __spreadValues({
223
- className: cx(classes.root, className),
224
- ref,
225
- onKeyDownCapture: handleKeydown
226
- }, others), /* @__PURE__ */ React.createElement("div", {
227
- className: classes.viewport,
228
- ref: emblaRefElement
229
- }, /* @__PURE__ */ React.createElement("div", {
230
- className: classes.container
231
- }, children)), withIndicators && /* @__PURE__ */ React.createElement("div", {
232
- className: classes.indicators
233
- }, indicators), withControls && /* @__PURE__ */ React.createElement("div", {
234
- className: classes.controls
235
- }, /* @__PURE__ */ React.createElement(UnstyledButton, {
236
- onClick: handlePrevious,
237
- className: classes.control,
238
- "aria-label": previousControlLabel,
239
- "data-inactive": !canScrollPrev || void 0,
240
- tabIndex: canScrollPrev ? 0 : -1
241
- }, typeof previousControlIcon !== "undefined" ? previousControlIcon : /* @__PURE__ */ React.createElement(ChevronIcon, {
242
- style: {
243
- transform: `rotate(${getChevronRotation({
244
- dir: theme.dir,
245
- orientation,
246
- direction: "previous"
247
- })}deg)`
248
- }
249
- })), /* @__PURE__ */ React.createElement(UnstyledButton, {
250
- onClick: handleNext,
251
- className: classes.control,
252
- "aria-label": nextControlLabel,
253
- "data-inactive": !canScrollNext || void 0,
254
- tabIndex: canScrollNext ? 0 : -1
255
- }, typeof nextControlIcon !== "undefined" ? nextControlIcon : /* @__PURE__ */ React.createElement(ChevronIcon, {
256
- style: {
257
- transform: `rotate(${getChevronRotation({
258
- dir: theme.dir,
259
- orientation,
260
- direction: "next"
261
- })}deg)`
262
- }
263
- })))));
236
+ const indicators = Array(slidesCount).fill(0).map((_, index) => /* @__PURE__ */ React.createElement(
237
+ UnstyledButton,
238
+ __spreadProps(__spreadValues({}, getStyles("indicator")), {
239
+ key: index,
240
+ "data-active": index === selected || void 0,
241
+ "aria-hidden": true,
242
+ tabIndex: -1,
243
+ onClick: () => handleScroll(index)
244
+ })
245
+ ));
246
+ return /* @__PURE__ */ React.createElement(CarouselProvider, { value: { getStyles, orientation } }, /* @__PURE__ */ React.createElement(CarouselVariables, __spreadProps(__spreadValues({}, props), { selector: `.${responsiveClassName}` })), /* @__PURE__ */ React.createElement(
247
+ Box,
248
+ __spreadProps(__spreadValues(__spreadValues({
249
+ ref
250
+ }, getStyles("root", { className: responsiveClassName })), others), {
251
+ mod: { orientation, "include-gap-in-size": includeGapInSize },
252
+ onKeyDownCapture: handleKeydown
253
+ }),
254
+ /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, getStyles("viewport")), { ref: emblaRefElement }), /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, getStyles("container")), { "data-orientation": orientation }), children)),
255
+ withIndicators && /* @__PURE__ */ React.createElement("div", __spreadValues({}, getStyles("indicators")), indicators),
256
+ withControls && /* @__PURE__ */ React.createElement("div", __spreadValues({}, getStyles("controls")), /* @__PURE__ */ React.createElement(
257
+ UnstyledButton,
258
+ __spreadProps(__spreadValues(__spreadValues({}, previousControlProps), getStyles("control")), {
259
+ onClick: handlePrevious,
260
+ "data-inactive": !canScrollPrev || void 0,
261
+ tabIndex: canScrollPrev ? 0 : -1
262
+ }),
263
+ typeof previousControlIcon !== "undefined" ? previousControlIcon : /* @__PURE__ */ React.createElement(
264
+ AccordionChevron,
265
+ {
266
+ style: {
267
+ transform: `rotate(${getChevronRotation({
268
+ dir,
269
+ orientation,
270
+ direction: "previous"
271
+ })}deg)`
272
+ }
273
+ }
274
+ )
275
+ ), /* @__PURE__ */ React.createElement(
276
+ UnstyledButton,
277
+ __spreadProps(__spreadValues(__spreadValues({
278
+ onClick: handleNext
279
+ }, getStyles("control")), nextControlProps), {
280
+ "data-inactive": !canScrollNext || void 0,
281
+ tabIndex: canScrollNext ? 0 : -1
282
+ }),
283
+ typeof nextControlIcon !== "undefined" ? nextControlIcon : /* @__PURE__ */ React.createElement(
284
+ AccordionChevron,
285
+ {
286
+ style: {
287
+ transform: `rotate(${getChevronRotation({
288
+ dir,
289
+ orientation,
290
+ direction: "next"
291
+ })}deg)`
292
+ }
293
+ }
294
+ )
295
+ ))
296
+ ));
264
297
  });
265
- _Carousel.Slide = CarouselSlide;
266
- _Carousel.displayName = "@mantine/carousel/Carousel";
267
- const Carousel = _Carousel;
298
+ Carousel.classes = classes;
299
+ Carousel.displayName = "@mantine/core/Carousel";
300
+ Carousel.Slide = CarouselSlide;
268
301
 
269
- export { Carousel, _Carousel };
302
+ export { Carousel };
270
303
  //# sourceMappingURL=Carousel.js.map