@fluentui/react-carousel 9.1.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -2
- package/dist/index.d.ts +58 -2
- package/lib/Carousel.js.map +1 -1
- package/lib/CarouselAutoplayButton.js.map +1 -1
- package/lib/CarouselButton.js.map +1 -1
- package/lib/CarouselCard.js.map +1 -1
- package/lib/CarouselContext.js.map +1 -1
- package/lib/CarouselNav.js.map +1 -1
- package/lib/CarouselNavButton.js.map +1 -1
- package/lib/CarouselNavContainer.js.map +1 -1
- package/lib/CarouselNavImageButton.js.map +1 -1
- package/lib/CarouselSlider.js.map +1 -1
- package/lib/CarouselViewport.js +1 -0
- package/lib/CarouselViewport.js.map +1 -0
- package/lib/components/Carousel/Carousel.js +2 -3
- package/lib/components/Carousel/Carousel.js.map +1 -1
- package/lib/components/Carousel/Carousel.types.js.map +1 -1
- package/lib/components/Carousel/index.js.map +1 -1
- package/lib/components/Carousel/renderCarousel.js.map +1 -1
- package/lib/components/Carousel/useCarousel.js +9 -6
- package/lib/components/Carousel/useCarousel.js.map +1 -1
- package/lib/components/Carousel/useCarouselContextValues.js +5 -3
- package/lib/components/Carousel/useCarouselContextValues.js.map +1 -1
- package/lib/components/Carousel/useCarouselStyles.styles.js +3 -10
- package/lib/components/Carousel/useCarouselStyles.styles.js.map +1 -1
- package/lib/components/CarouselAutoplayButton/CarouselAutoplayButton.js +2 -3
- package/lib/components/CarouselAutoplayButton/CarouselAutoplayButton.js.map +1 -1
- package/lib/components/CarouselAutoplayButton/CarouselAutoplayButton.types.js.map +1 -1
- package/lib/components/CarouselAutoplayButton/index.js.map +1 -1
- package/lib/components/CarouselAutoplayButton/renderCarouselAutoplayButton.js +1 -1
- package/lib/components/CarouselAutoplayButton/renderCarouselAutoplayButton.js.map +1 -1
- package/lib/components/CarouselAutoplayButton/useCarouselAutoplayButton.js.map +1 -1
- package/lib/components/CarouselAutoplayButton/useCarouselAutoplayButtonStyles.styles.js +1 -2
- package/lib/components/CarouselButton/CarouselButton.js +2 -3
- package/lib/components/CarouselButton/CarouselButton.js.map +1 -1
- package/lib/components/CarouselButton/CarouselButton.types.js.map +1 -1
- package/lib/components/CarouselButton/index.js.map +1 -1
- package/lib/components/CarouselButton/renderCarouselButton.js +1 -1
- package/lib/components/CarouselButton/renderCarouselButton.js.map +1 -1
- package/lib/components/CarouselButton/useCarouselButton.js.map +1 -1
- package/lib/components/CarouselButton/useCarouselButtonStyles.styles.js +1 -2
- package/lib/components/CarouselCard/CarouselCard.js +2 -3
- package/lib/components/CarouselCard/CarouselCard.js.map +1 -1
- package/lib/components/CarouselCard/CarouselCard.types.js.map +1 -1
- package/lib/components/CarouselCard/index.js.map +1 -1
- package/lib/components/CarouselCard/renderCarouselCard.js.map +1 -1
- package/lib/components/CarouselCard/useCarouselCard.js +17 -10
- package/lib/components/CarouselCard/useCarouselCard.js.map +1 -1
- package/lib/components/CarouselCard/useCarouselCardStyles.styles.js +1 -2
- package/lib/components/CarouselContext.js +2 -1
- package/lib/components/CarouselContext.js.map +1 -1
- package/lib/components/CarouselContext.types.js.map +1 -1
- package/lib/components/CarouselNav/CarouselNav.js +2 -3
- package/lib/components/CarouselNav/CarouselNav.js.map +1 -1
- package/lib/components/CarouselNav/CarouselNav.types.js.map +1 -1
- package/lib/components/CarouselNav/CarouselNavContext.js.map +1 -1
- package/lib/components/CarouselNav/CarouselNavIndexContext.js.map +1 -1
- package/lib/components/CarouselNav/index.js.map +1 -1
- package/lib/components/CarouselNav/renderCarouselNav.js.map +1 -1
- package/lib/components/CarouselNav/useCarouselNav.js.map +1 -1
- package/lib/components/CarouselNav/useCarouselNavStyles.styles.js +1 -2
- package/lib/components/CarouselNavButton/CarouselNavButton.js +2 -3
- package/lib/components/CarouselNavButton/CarouselNavButton.js.map +1 -1
- package/lib/components/CarouselNavButton/CarouselNavButton.types.js.map +1 -1
- package/lib/components/CarouselNavButton/index.js.map +1 -1
- package/lib/components/CarouselNavButton/renderCarouselNavButton.js.map +1 -1
- package/lib/components/CarouselNavButton/useCarouselNavButton.js.map +1 -1
- package/lib/components/CarouselNavButton/useCarouselNavButtonStyles.styles.js +1 -2
- package/lib/components/CarouselNavContainer/CarouselNavContainer.js +2 -8
- package/lib/components/CarouselNavContainer/CarouselNavContainer.js.map +1 -1
- package/lib/components/CarouselNavContainer/CarouselNavContainer.types.js.map +1 -1
- package/lib/components/CarouselNavContainer/index.js.map +1 -1
- package/lib/components/CarouselNavContainer/renderCarouselNavContainer.js.map +1 -1
- package/lib/components/CarouselNavContainer/useCarouselNavContainer.js.map +1 -1
- package/lib/components/CarouselNavContainer/useCarouselNavContainerStyles.styles.js +1 -2
- package/lib/components/CarouselNavImageButton/CarouselNavImageButton.js +2 -3
- package/lib/components/CarouselNavImageButton/CarouselNavImageButton.js.map +1 -1
- package/lib/components/CarouselNavImageButton/CarouselNavImageButton.types.js.map +1 -1
- package/lib/components/CarouselNavImageButton/index.js.map +1 -1
- package/lib/components/CarouselNavImageButton/renderCarouselNavImageButton.js.map +1 -1
- package/lib/components/CarouselNavImageButton/useCarouselNavImageButton.js.map +1 -1
- package/lib/components/CarouselNavImageButton/useCarouselNavImageButtonStyles.styles.js +1 -2
- package/lib/components/CarouselSlider/CarouselSlider.js +2 -3
- package/lib/components/CarouselSlider/CarouselSlider.js.map +1 -1
- package/lib/components/CarouselSlider/CarouselSlider.types.js +3 -1
- package/lib/components/CarouselSlider/CarouselSlider.types.js.map +1 -1
- package/lib/components/CarouselSlider/CarouselSliderContext.js.map +1 -1
- package/lib/components/CarouselSlider/index.js.map +1 -1
- package/lib/components/CarouselSlider/renderCarouselSlider.js.map +1 -1
- package/lib/components/CarouselSlider/useCarouselSlider.js +3 -1
- package/lib/components/CarouselSlider/useCarouselSlider.js.map +1 -1
- package/lib/components/CarouselSlider/useCarouselSliderStyles.styles.js +1 -2
- package/lib/components/CarouselViewport/CarouselViewport.js +16 -0
- package/lib/components/CarouselViewport/CarouselViewport.js.map +1 -0
- package/lib/components/CarouselViewport/CarouselViewport.types.js +3 -0
- package/lib/components/CarouselViewport/CarouselViewport.types.js.map +1 -0
- package/lib/components/CarouselViewport/index.js +5 -0
- package/lib/components/CarouselViewport/index.js.map +1 -0
- package/lib/components/CarouselViewport/renderCarouselViewport.js +12 -0
- package/lib/components/CarouselViewport/renderCarouselViewport.js.map +1 -0
- package/lib/components/CarouselViewport/useCarouselViewport.js +28 -0
- package/lib/components/CarouselViewport/useCarouselViewport.js.map +1 -0
- package/lib/components/CarouselViewport/useCarouselViewportStyles.styles.js +25 -0
- package/lib/components/CarouselViewport/useCarouselViewportStyles.styles.js.map +1 -0
- package/lib/components/pointerEvents.js +58 -0
- package/lib/components/pointerEvents.js.map +1 -0
- package/lib/components/useEmblaCarousel.js +53 -30
- package/lib/components/useEmblaCarousel.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Carousel.js.map +1 -1
- package/lib-commonjs/CarouselAutoplayButton.js.map +1 -1
- package/lib-commonjs/CarouselButton.js.map +1 -1
- package/lib-commonjs/CarouselCard.js.map +1 -1
- package/lib-commonjs/CarouselContext.js.map +1 -1
- package/lib-commonjs/CarouselNav.js.map +1 -1
- package/lib-commonjs/CarouselNavButton.js.map +1 -1
- package/lib-commonjs/CarouselNavContainer.js.map +1 -1
- package/lib-commonjs/CarouselNavImageButton.js.map +1 -1
- package/lib-commonjs/CarouselSlider.js.map +1 -1
- package/lib-commonjs/CarouselViewport.js +6 -0
- package/lib-commonjs/CarouselViewport.js.map +1 -0
- package/lib-commonjs/components/Carousel/Carousel.js +2 -3
- package/lib-commonjs/components/Carousel/Carousel.js.map +1 -1
- package/lib-commonjs/components/Carousel/Carousel.types.js.map +1 -1
- package/lib-commonjs/components/Carousel/index.js.map +1 -1
- package/lib-commonjs/components/Carousel/renderCarousel.js.map +1 -1
- package/lib-commonjs/components/Carousel/useCarousel.js +9 -6
- package/lib-commonjs/components/Carousel/useCarousel.js.map +1 -1
- package/lib-commonjs/components/Carousel/useCarouselContextValues.js +5 -3
- package/lib-commonjs/components/Carousel/useCarouselContextValues.js.map +1 -1
- package/lib-commonjs/components/Carousel/useCarouselStyles.styles.js +3 -12
- package/lib-commonjs/components/Carousel/useCarouselStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CarouselAutoplayButton/CarouselAutoplayButton.js +2 -3
- package/lib-commonjs/components/CarouselAutoplayButton/CarouselAutoplayButton.js.map +1 -1
- package/lib-commonjs/components/CarouselAutoplayButton/CarouselAutoplayButton.types.js.map +1 -1
- package/lib-commonjs/components/CarouselAutoplayButton/index.js.map +1 -1
- package/lib-commonjs/components/CarouselAutoplayButton/renderCarouselAutoplayButton.js.map +1 -1
- package/lib-commonjs/components/CarouselAutoplayButton/useCarouselAutoplayButton.js.map +1 -1
- package/lib-commonjs/components/CarouselAutoplayButton/useCarouselAutoplayButtonStyles.styles.js +1 -1
- package/lib-commonjs/components/CarouselButton/CarouselButton.js +2 -3
- package/lib-commonjs/components/CarouselButton/CarouselButton.js.map +1 -1
- package/lib-commonjs/components/CarouselButton/CarouselButton.types.js.map +1 -1
- package/lib-commonjs/components/CarouselButton/index.js.map +1 -1
- package/lib-commonjs/components/CarouselButton/renderCarouselButton.js.map +1 -1
- package/lib-commonjs/components/CarouselButton/useCarouselButton.js.map +1 -1
- package/lib-commonjs/components/CarouselButton/useCarouselButtonStyles.styles.js +1 -1
- package/lib-commonjs/components/CarouselCard/CarouselCard.js +2 -3
- package/lib-commonjs/components/CarouselCard/CarouselCard.js.map +1 -1
- package/lib-commonjs/components/CarouselCard/CarouselCard.types.js.map +1 -1
- package/lib-commonjs/components/CarouselCard/index.js.map +1 -1
- package/lib-commonjs/components/CarouselCard/renderCarouselCard.js.map +1 -1
- package/lib-commonjs/components/CarouselCard/useCarouselCard.js +16 -10
- package/lib-commonjs/components/CarouselCard/useCarouselCard.js.map +1 -1
- package/lib-commonjs/components/CarouselCard/useCarouselCardStyles.styles.js +1 -1
- package/lib-commonjs/components/CarouselContext.js +2 -1
- package/lib-commonjs/components/CarouselContext.js.map +1 -1
- package/lib-commonjs/components/CarouselContext.types.js.map +1 -1
- package/lib-commonjs/components/CarouselNav/CarouselNav.js +2 -3
- package/lib-commonjs/components/CarouselNav/CarouselNav.js.map +1 -1
- package/lib-commonjs/components/CarouselNav/CarouselNav.types.js.map +1 -1
- package/lib-commonjs/components/CarouselNav/CarouselNavContext.js.map +1 -1
- package/lib-commonjs/components/CarouselNav/CarouselNavIndexContext.js.map +1 -1
- package/lib-commonjs/components/CarouselNav/index.js.map +1 -1
- package/lib-commonjs/components/CarouselNav/renderCarouselNav.js.map +1 -1
- package/lib-commonjs/components/CarouselNav/useCarouselNav.js.map +1 -1
- package/lib-commonjs/components/CarouselNav/useCarouselNavStyles.styles.js +1 -1
- package/lib-commonjs/components/CarouselNavButton/CarouselNavButton.js +2 -3
- package/lib-commonjs/components/CarouselNavButton/CarouselNavButton.js.map +1 -1
- package/lib-commonjs/components/CarouselNavButton/CarouselNavButton.types.js.map +1 -1
- package/lib-commonjs/components/CarouselNavButton/index.js.map +1 -1
- package/lib-commonjs/components/CarouselNavButton/renderCarouselNavButton.js.map +1 -1
- package/lib-commonjs/components/CarouselNavButton/useCarouselNavButton.js.map +1 -1
- package/lib-commonjs/components/CarouselNavButton/useCarouselNavButtonStyles.styles.js +1 -1
- package/lib-commonjs/components/CarouselNavContainer/CarouselNavContainer.js +2 -8
- package/lib-commonjs/components/CarouselNavContainer/CarouselNavContainer.js.map +1 -1
- package/lib-commonjs/components/CarouselNavContainer/CarouselNavContainer.types.js.map +1 -1
- package/lib-commonjs/components/CarouselNavContainer/index.js.map +1 -1
- package/lib-commonjs/components/CarouselNavContainer/renderCarouselNavContainer.js.map +1 -1
- package/lib-commonjs/components/CarouselNavContainer/useCarouselNavContainer.js.map +1 -1
- package/lib-commonjs/components/CarouselNavContainer/useCarouselNavContainerStyles.styles.js +1 -1
- package/lib-commonjs/components/CarouselNavImageButton/CarouselNavImageButton.js +2 -3
- package/lib-commonjs/components/CarouselNavImageButton/CarouselNavImageButton.js.map +1 -1
- package/lib-commonjs/components/CarouselNavImageButton/CarouselNavImageButton.types.js.map +1 -1
- package/lib-commonjs/components/CarouselNavImageButton/index.js.map +1 -1
- package/lib-commonjs/components/CarouselNavImageButton/renderCarouselNavImageButton.js.map +1 -1
- package/lib-commonjs/components/CarouselNavImageButton/useCarouselNavImageButton.js.map +1 -1
- package/lib-commonjs/components/CarouselNavImageButton/useCarouselNavImageButtonStyles.styles.js +1 -1
- package/lib-commonjs/components/CarouselSlider/CarouselSlider.js +2 -3
- package/lib-commonjs/components/CarouselSlider/CarouselSlider.js.map +1 -1
- package/lib-commonjs/components/CarouselSlider/CarouselSlider.types.js +3 -1
- package/lib-commonjs/components/CarouselSlider/CarouselSlider.types.js.map +1 -1
- package/lib-commonjs/components/CarouselSlider/CarouselSliderContext.js.map +1 -1
- package/lib-commonjs/components/CarouselSlider/index.js.map +1 -1
- package/lib-commonjs/components/CarouselSlider/renderCarouselSlider.js.map +1 -1
- package/lib-commonjs/components/CarouselSlider/useCarouselSlider.js +3 -1
- package/lib-commonjs/components/CarouselSlider/useCarouselSlider.js.map +1 -1
- package/lib-commonjs/components/CarouselSlider/useCarouselSliderStyles.styles.js +1 -1
- package/lib-commonjs/components/CarouselViewport/CarouselViewport.js +25 -0
- package/lib-commonjs/components/CarouselViewport/CarouselViewport.js.map +1 -0
- package/lib-commonjs/components/CarouselViewport/CarouselViewport.types.js +6 -0
- package/lib-commonjs/components/CarouselViewport/CarouselViewport.types.js.map +1 -0
- package/lib-commonjs/components/CarouselViewport/index.js +10 -0
- package/lib-commonjs/components/CarouselViewport/index.js.map +1 -0
- package/lib-commonjs/components/CarouselViewport/renderCarouselViewport.js +20 -0
- package/lib-commonjs/components/CarouselViewport/renderCarouselViewport.js.map +1 -0
- package/lib-commonjs/components/CarouselViewport/useCarouselViewport.js +31 -0
- package/lib-commonjs/components/CarouselViewport/useCarouselViewport.js.map +1 -0
- package/lib-commonjs/components/CarouselViewport/useCarouselViewportStyles.styles.js +41 -0
- package/lib-commonjs/components/CarouselViewport/useCarouselViewportStyles.styles.js.map +1 -0
- package/lib-commonjs/components/pointerEvents.js +68 -0
- package/lib-commonjs/components/pointerEvents.js.map +1 -0
- package/lib-commonjs/components/useEmblaCarousel.js +52 -29
- package/lib-commonjs/components/useEmblaCarousel.js.map +1 -1
- package/lib-commonjs/index.js +16 -0
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +12 -22
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { useControllableState } from '@fluentui/react-utilities';
|
|
1
|
+
import { useControllableState, useEventCallback } from '@fluentui/react-utilities';
|
|
2
2
|
import EmblaCarousel from 'embla-carousel';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { carouselCardClassNames } from './CarouselCard/useCarouselCardStyles.styles';
|
|
5
5
|
import { carouselSliderClassNames } from './CarouselSlider/useCarouselSliderStyles.styles';
|
|
6
6
|
import Autoplay from 'embla-carousel-autoplay';
|
|
7
|
+
import Fade from 'embla-carousel-fade';
|
|
8
|
+
import { pointerEventPlugin } from './pointerEvents';
|
|
7
9
|
const sliderClassname = `.${carouselSliderClassNames.root}`;
|
|
8
10
|
const DEFAULT_EMBLA_OPTIONS = {
|
|
9
11
|
containScroll: 'trimSnaps',
|
|
@@ -26,12 +28,19 @@ export function setTabsterDefault(element, isDefault) {
|
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
export function useEmblaCarousel(options) {
|
|
29
|
-
const { align, direction, loop, slidesToScroll, watchDrag, containScroll } = options;
|
|
31
|
+
const { align, direction, loop, slidesToScroll, watchDrag, containScroll, motion, onDragIndexChange } = options;
|
|
30
32
|
const [activeIndex, setActiveIndex] = useControllableState({
|
|
31
33
|
defaultState: options.defaultActiveIndex,
|
|
32
34
|
state: options.activeIndex,
|
|
33
35
|
initialState: 0
|
|
34
36
|
});
|
|
37
|
+
const onDragEvent = useEventCallback((event, index)=>{
|
|
38
|
+
onDragIndexChange === null || onDragIndexChange === void 0 ? void 0 : onDragIndexChange(event, {
|
|
39
|
+
event,
|
|
40
|
+
type: 'drag',
|
|
41
|
+
index
|
|
42
|
+
});
|
|
43
|
+
});
|
|
35
44
|
const emblaOptions = React.useRef({
|
|
36
45
|
align,
|
|
37
46
|
direction,
|
|
@@ -61,6 +70,30 @@ export function useEmblaCarousel(options) {
|
|
|
61
70
|
}, [
|
|
62
71
|
resetAutoplay
|
|
63
72
|
]);
|
|
73
|
+
const getPlugins = React.useCallback(()=>{
|
|
74
|
+
const plugins = [
|
|
75
|
+
Autoplay({
|
|
76
|
+
playOnInit: autoplayRef.current,
|
|
77
|
+
stopOnInteraction: !autoplayRef.current,
|
|
78
|
+
stopOnMouseEnter: true,
|
|
79
|
+
stopOnFocusIn: true
|
|
80
|
+
})
|
|
81
|
+
];
|
|
82
|
+
// Optionally add Fade plugin
|
|
83
|
+
if (motion === 'fade') {
|
|
84
|
+
plugins.push(Fade());
|
|
85
|
+
}
|
|
86
|
+
if (watchDrag) {
|
|
87
|
+
plugins.push(pointerEventPlugin({
|
|
88
|
+
onSelectViaDrag: onDragEvent
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
return plugins;
|
|
92
|
+
}, [
|
|
93
|
+
motion,
|
|
94
|
+
onDragEvent,
|
|
95
|
+
watchDrag
|
|
96
|
+
]);
|
|
64
97
|
// Listeners contains callbacks for UI elements that may require state update based on embla changes
|
|
65
98
|
const listeners = React.useRef(new Set());
|
|
66
99
|
const subscribeForValues = React.useCallback((listener)=>{
|
|
@@ -69,6 +102,7 @@ export function useEmblaCarousel(options) {
|
|
|
69
102
|
listeners.current.delete(listener);
|
|
70
103
|
};
|
|
71
104
|
}, []);
|
|
105
|
+
const viewportRef = React.useRef(null);
|
|
72
106
|
const containerRef = React.useMemo(()=>{
|
|
73
107
|
let currentElement = null;
|
|
74
108
|
const handleIndexChange = ()=>{
|
|
@@ -116,6 +150,7 @@ export function useEmblaCarousel(options) {
|
|
|
116
150
|
}));
|
|
117
151
|
});
|
|
118
152
|
};
|
|
153
|
+
const plugins = getPlugins();
|
|
119
154
|
return {
|
|
120
155
|
set current (newElement){
|
|
121
156
|
if (currentElement) {
|
|
@@ -125,24 +160,16 @@ export function useEmblaCarousel(options) {
|
|
|
125
160
|
(_emblaApi_current2 = emblaApi.current) === null || _emblaApi_current2 === void 0 ? void 0 : _emblaApi_current2.off('reInit', handleReinit);
|
|
126
161
|
(_emblaApi_current3 = emblaApi.current) === null || _emblaApi_current3 === void 0 ? void 0 : _emblaApi_current3.destroy();
|
|
127
162
|
}
|
|
128
|
-
|
|
163
|
+
var _viewportRef_current;
|
|
164
|
+
// Use direct viewport if available, else fallback to container (includes Carousel controls).
|
|
165
|
+
const wrapperElement = (_viewportRef_current = viewportRef.current) !== null && _viewportRef_current !== void 0 ? _viewportRef_current : newElement;
|
|
166
|
+
if (wrapperElement) {
|
|
129
167
|
var _emblaApi_current4, _emblaApi_current5, _emblaApi_current6;
|
|
130
|
-
currentElement =
|
|
131
|
-
emblaApi.current = EmblaCarousel(
|
|
168
|
+
currentElement = wrapperElement;
|
|
169
|
+
emblaApi.current = EmblaCarousel(wrapperElement, {
|
|
132
170
|
...DEFAULT_EMBLA_OPTIONS,
|
|
133
171
|
...emblaOptions.current
|
|
134
|
-
},
|
|
135
|
-
Autoplay({
|
|
136
|
-
playOnInit: autoplayRef.current,
|
|
137
|
-
stopOnInteraction: !autoplayRef.current,
|
|
138
|
-
stopOnMouseEnter: true,
|
|
139
|
-
stopOnFocusIn: true,
|
|
140
|
-
rootNode: (emblaRoot)=>{
|
|
141
|
-
var _emblaRoot_querySelector;
|
|
142
|
-
return (_emblaRoot_querySelector = emblaRoot.querySelector(sliderClassname)) !== null && _emblaRoot_querySelector !== void 0 ? _emblaRoot_querySelector : emblaRoot;
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
]);
|
|
172
|
+
}, plugins);
|
|
146
173
|
(_emblaApi_current4 = emblaApi.current) === null || _emblaApi_current4 === void 0 ? void 0 : _emblaApi_current4.on('reInit', handleReinit);
|
|
147
174
|
(_emblaApi_current5 = emblaApi.current) === null || _emblaApi_current5 === void 0 ? void 0 : _emblaApi_current5.on('slidesInView', handleVisibilityChange);
|
|
148
175
|
(_emblaApi_current6 = emblaApi.current) === null || _emblaApi_current6 === void 0 ? void 0 : _emblaApi_current6.on('select', handleIndexChange);
|
|
@@ -150,6 +177,7 @@ export function useEmblaCarousel(options) {
|
|
|
150
177
|
}
|
|
151
178
|
};
|
|
152
179
|
}, [
|
|
180
|
+
getPlugins,
|
|
153
181
|
setActiveIndex
|
|
154
182
|
]);
|
|
155
183
|
const carouselApi = React.useMemo(()=>({
|
|
@@ -187,7 +215,9 @@ export function useEmblaCarousel(options) {
|
|
|
187
215
|
React.useEffect(()=>{
|
|
188
216
|
var _emblaApi_current;
|
|
189
217
|
var _emblaApi_current_selectedScrollSnap;
|
|
218
|
+
// Scroll to controlled values on update
|
|
190
219
|
const currentActiveIndex = (_emblaApi_current_selectedScrollSnap = (_emblaApi_current = emblaApi.current) === null || _emblaApi_current === void 0 ? void 0 : _emblaApi_current.selectedScrollSnap()) !== null && _emblaApi_current_selectedScrollSnap !== void 0 ? _emblaApi_current_selectedScrollSnap : 0;
|
|
220
|
+
emblaOptions.current.startIndex = activeIndex;
|
|
191
221
|
if (activeIndex !== currentActiveIndex) {
|
|
192
222
|
var _emblaApi_current1;
|
|
193
223
|
(_emblaApi_current1 = emblaApi.current) === null || _emblaApi_current1 === void 0 ? void 0 : _emblaApi_current1.scrollTo(activeIndex);
|
|
@@ -197,7 +227,9 @@ export function useEmblaCarousel(options) {
|
|
|
197
227
|
]);
|
|
198
228
|
React.useEffect(()=>{
|
|
199
229
|
var _emblaApi_current;
|
|
230
|
+
const plugins = getPlugins();
|
|
200
231
|
emblaOptions.current = {
|
|
232
|
+
startIndex: emblaOptions.current.startIndex,
|
|
201
233
|
align,
|
|
202
234
|
direction,
|
|
203
235
|
loop,
|
|
@@ -208,29 +240,20 @@ export function useEmblaCarousel(options) {
|
|
|
208
240
|
(_emblaApi_current = emblaApi.current) === null || _emblaApi_current === void 0 ? void 0 : _emblaApi_current.reInit({
|
|
209
241
|
...DEFAULT_EMBLA_OPTIONS,
|
|
210
242
|
...emblaOptions.current
|
|
211
|
-
},
|
|
212
|
-
Autoplay({
|
|
213
|
-
playOnInit: autoplayRef.current,
|
|
214
|
-
stopOnInteraction: !autoplayRef.current,
|
|
215
|
-
stopOnMouseEnter: true,
|
|
216
|
-
stopOnFocusIn: true,
|
|
217
|
-
rootNode: (emblaRoot)=>{
|
|
218
|
-
var _emblaRoot_querySelector;
|
|
219
|
-
return (_emblaRoot_querySelector = emblaRoot.querySelector(sliderClassname)) !== null && _emblaRoot_querySelector !== void 0 ? _emblaRoot_querySelector : emblaRoot;
|
|
220
|
-
}
|
|
221
|
-
})
|
|
222
|
-
]);
|
|
243
|
+
}, plugins);
|
|
223
244
|
}, [
|
|
224
245
|
align,
|
|
225
246
|
direction,
|
|
226
247
|
loop,
|
|
227
248
|
slidesToScroll,
|
|
228
249
|
watchDrag,
|
|
229
|
-
containScroll
|
|
250
|
+
containScroll,
|
|
251
|
+
getPlugins
|
|
230
252
|
]);
|
|
231
253
|
return {
|
|
232
254
|
activeIndex,
|
|
233
255
|
carouselApi,
|
|
256
|
+
viewportRef,
|
|
234
257
|
containerRef,
|
|
235
258
|
subscribeForValues,
|
|
236
259
|
enableAutoplay,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useEmblaCarousel.ts"],"sourcesContent":["import { useControllableState } from '@fluentui/react-utilities';\nimport EmblaCarousel, { type EmblaCarouselType, type EmblaOptionsType } from 'embla-carousel';\nimport * as React from 'react';\n\nimport { carouselCardClassNames } from './CarouselCard/useCarouselCardStyles.styles';\nimport { carouselSliderClassNames } from './CarouselSlider/useCarouselSliderStyles.styles';\nimport { CarouselUpdateData, CarouselVisibilityEventDetail } from '../Carousel';\nimport Autoplay from 'embla-carousel-autoplay';\n\nconst sliderClassname = `.${carouselSliderClassNames.root}`;\n\nconst DEFAULT_EMBLA_OPTIONS: EmblaOptionsType = {\n containScroll: 'trimSnaps',\n inViewThreshold: 0.99,\n watchDrag: false,\n skipSnaps: true,\n\n container: sliderClassname,\n slides: `.${carouselCardClassNames.root}`,\n};\n\nexport const EMBLA_VISIBILITY_EVENT = 'embla:visibilitychange';\n\nexport function setTabsterDefault(element: Element, isDefault: boolean) {\n const tabsterAttr = element.getAttribute('data-tabster');\n\n if (tabsterAttr) {\n const tabsterAttributes = JSON.parse(tabsterAttr);\n if (tabsterAttributes.focusable) {\n // If tabster.focusable isn't present, we will ignore.\n tabsterAttributes.focusable.isDefault = isDefault;\n element.setAttribute('data-tabster', JSON.stringify(tabsterAttributes));\n }\n }\n}\n\nexport function useEmblaCarousel(\n options: Pick<EmblaOptionsType, 'align' | 'direction' | 'loop' | 'slidesToScroll' | 'watchDrag' | 'containScroll'> & {\n defaultActiveIndex: number | undefined;\n activeIndex: number | undefined;\n },\n) {\n const { align, direction, loop, slidesToScroll, watchDrag, containScroll } = options;\n const [activeIndex, setActiveIndex] = useControllableState({\n defaultState: options.defaultActiveIndex,\n state: options.activeIndex,\n initialState: 0,\n });\n\n const emblaOptions = React.useRef<EmblaOptionsType>({\n align,\n direction,\n loop,\n slidesToScroll,\n startIndex: activeIndex,\n watchDrag,\n containScroll,\n });\n\n const emblaApi = React.useRef<EmblaCarouselType | null>(null);\n const autoplayRef = React.useRef<boolean>(false);\n\n const resetAutoplay = React.useCallback(() => {\n emblaApi.current?.plugins().autoplay.reset();\n }, []);\n\n /* Our autoplay button, which is required by standards for autoplay to be enabled, will handle controlled state */\n const enableAutoplay = React.useCallback(\n (autoplay: boolean) => {\n autoplayRef.current = autoplay;\n if (autoplay) {\n emblaApi.current?.plugins().autoplay.play();\n // Reset after play to ensure timing and any focus/mouse pause state is reset.\n resetAutoplay();\n } else {\n emblaApi.current?.plugins().autoplay.stop();\n }\n },\n [resetAutoplay],\n );\n\n // Listeners contains callbacks for UI elements that may require state update based on embla changes\n const listeners = React.useRef(new Set<(data: CarouselUpdateData) => void>());\n const subscribeForValues = React.useCallback((listener: (data: CarouselUpdateData) => void) => {\n listeners.current.add(listener);\n\n return () => {\n listeners.current.delete(listener);\n };\n }, []);\n\n const containerRef: React.RefObject<HTMLDivElement> = React.useMemo(() => {\n let currentElement: HTMLDivElement | null = null;\n\n const handleIndexChange = () => {\n const newIndex = emblaApi.current?.selectedScrollSnap() ?? 0;\n const slides = emblaApi.current?.slideNodes();\n const actualIndex = emblaApi.current?.internalEngine().slideRegistry[newIndex][0] ?? 0;\n // We set the active or first index of group on-screen as the selected tabster index\n slides?.forEach((slide, slideIndex) => {\n setTabsterDefault(slide, slideIndex === actualIndex);\n });\n setActiveIndex(newIndex);\n };\n const handleReinit = () => {\n const nodes: HTMLElement[] = emblaApi.current?.slideNodes() ?? [];\n const groupIndexList: number[][] = emblaApi.current?.internalEngine().slideRegistry ?? [];\n const navItemsCount = groupIndexList.length > 0 ? groupIndexList.length : nodes.length;\n\n const data: CarouselUpdateData = {\n navItemsCount,\n activeIndex: emblaApi.current?.selectedScrollSnap() ?? 0,\n groupIndexList,\n slideNodes: nodes,\n };\n\n for (const listener of listeners.current) {\n listener(data);\n }\n };\n const handleVisibilityChange = () => {\n const cardElements = emblaApi.current?.slideNodes();\n const visibleIndexes = emblaApi.current?.slidesInView() ?? [];\n\n cardElements?.forEach((cardElement, index) => {\n cardElement.dispatchEvent(\n new CustomEvent<CarouselVisibilityEventDetail>(EMBLA_VISIBILITY_EVENT, {\n bubbles: false,\n detail: { isVisible: visibleIndexes.includes(index) },\n }),\n );\n });\n };\n\n return {\n set current(newElement: HTMLDivElement | null) {\n if (currentElement) {\n emblaApi.current?.off('slidesInView', handleVisibilityChange);\n emblaApi.current?.off('select', handleIndexChange);\n emblaApi.current?.off('reInit', handleReinit);\n emblaApi.current?.destroy();\n }\n\n if (newElement) {\n currentElement = newElement;\n emblaApi.current = EmblaCarousel(\n newElement,\n {\n ...DEFAULT_EMBLA_OPTIONS,\n ...emblaOptions.current,\n },\n [\n Autoplay({\n playOnInit: autoplayRef.current,\n stopOnInteraction: !autoplayRef.current,\n stopOnMouseEnter: true,\n stopOnFocusIn: true,\n rootNode: (emblaRoot: HTMLElement) => {\n return emblaRoot.querySelector(sliderClassname) ?? emblaRoot;\n },\n }),\n ],\n );\n\n emblaApi.current?.on('reInit', handleReinit);\n emblaApi.current?.on('slidesInView', handleVisibilityChange);\n emblaApi.current?.on('select', handleIndexChange);\n }\n },\n };\n }, [setActiveIndex]);\n\n const carouselApi = React.useMemo(\n () => ({\n scrollToElement: (element: HTMLElement, jump?: boolean) => {\n const cardElements = emblaApi.current?.slideNodes();\n const groupIndexList = emblaApi.current?.internalEngine().slideRegistry ?? [];\n const cardIndex = cardElements?.indexOf(element) ?? 0;\n const groupIndex = groupIndexList.findIndex(group => {\n return group.includes(cardIndex);\n });\n const indexFocus = groupIndex ?? cardIndex;\n emblaApi.current?.scrollTo(indexFocus, jump);\n\n return indexFocus;\n },\n scrollToIndex: (index: number, jump?: boolean) => {\n emblaApi.current?.scrollTo(index, jump);\n },\n scrollInDirection: (dir: 'prev' | 'next') => {\n if (dir === 'prev') {\n emblaApi.current?.scrollPrev();\n } else {\n emblaApi.current?.scrollNext();\n }\n\n return emblaApi.current?.selectedScrollSnap() ?? 0;\n },\n }),\n [],\n );\n\n React.useEffect(() => {\n const currentActiveIndex = emblaApi.current?.selectedScrollSnap() ?? 0;\n\n if (activeIndex !== currentActiveIndex) {\n emblaApi.current?.scrollTo(activeIndex);\n }\n }, [activeIndex]);\n\n React.useEffect(() => {\n emblaOptions.current = { align, direction, loop, slidesToScroll, watchDrag, containScroll };\n emblaApi.current?.reInit(\n {\n ...DEFAULT_EMBLA_OPTIONS,\n ...emblaOptions.current,\n },\n [\n Autoplay({\n playOnInit: autoplayRef.current,\n stopOnInteraction: !autoplayRef.current,\n stopOnMouseEnter: true,\n stopOnFocusIn: true,\n rootNode: (emblaRoot: HTMLElement) => {\n return emblaRoot.querySelector(sliderClassname) ?? emblaRoot;\n },\n }),\n ],\n );\n }, [align, direction, loop, slidesToScroll, watchDrag, containScroll]);\n\n return {\n activeIndex,\n carouselApi,\n containerRef,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n };\n}\n"],"names":["useControllableState","EmblaCarousel","React","carouselCardClassNames","carouselSliderClassNames","Autoplay","sliderClassname","root","DEFAULT_EMBLA_OPTIONS","containScroll","inViewThreshold","watchDrag","skipSnaps","container","slides","EMBLA_VISIBILITY_EVENT","setTabsterDefault","element","isDefault","tabsterAttr","getAttribute","tabsterAttributes","JSON","parse","focusable","setAttribute","stringify","useEmblaCarousel","options","align","direction","loop","slidesToScroll","activeIndex","setActiveIndex","defaultState","defaultActiveIndex","state","initialState","emblaOptions","useRef","startIndex","emblaApi","autoplayRef","resetAutoplay","useCallback","current","plugins","autoplay","reset","enableAutoplay","play","stop","listeners","Set","subscribeForValues","listener","add","delete","containerRef","useMemo","currentElement","handleIndexChange","newIndex","selectedScrollSnap","slideNodes","actualIndex","internalEngine","slideRegistry","forEach","slide","slideIndex","handleReinit","nodes","groupIndexList","navItemsCount","length","data","handleVisibilityChange","cardElements","visibleIndexes","slidesInView","cardElement","index","dispatchEvent","CustomEvent","bubbles","detail","isVisible","includes","newElement","off","destroy","playOnInit","stopOnInteraction","stopOnMouseEnter","stopOnFocusIn","rootNode","emblaRoot","querySelector","on","carouselApi","scrollToElement","jump","cardIndex","indexOf","groupIndex","findIndex","group","indexFocus","scrollTo","scrollToIndex","scrollInDirection","dir","scrollPrev","scrollNext","useEffect","currentActiveIndex","reInit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;YACnD;QACF,CAAA,GACA,EAAE;IAGJxC,MAAMkH,SAAS,CAAC;YACa1E;YAAAA;QAA3B,MAAM2E,qBAAqB3E,CAAAA,wCAAAA,oBAAAA,SAASI,OAAO,cAAhBJ,wCAAAA,kBAAkBsB,kBAAkB,gBAApCtB,kDAAAA,uCAA0C;QAErE,IAAIT,gBAAgBoF,oBAAoB;gBACtC3E;aAAAA,qBAAAA,SAASI,OAAO,cAAhBJ,yCAAAA,mBAAkBoE,QAAQ,CAAC7E;QAC7B;IACF,GAAG;QAACA;KAAY;IAEhB/B,MAAMkH,SAAS,CAAC;YAEd1E;QADAH,aAAaO,OAAO,GAAG;YAAEjB;YAAOC;YAAWC;YAAMC;YAAgBrB;YAAWF;QAAc;SAC1FiC,oBAAAA,SAASI,OAAO,cAAhBJ,wCAAAA,kBAAkB4E,MAAM,CACtB;YACE,GAAG9G,qBAAqB;YACxB,GAAG+B,aAAaO,OAAO;QACzB,GACA;YACEzC,SAAS;gBACPwF,YAAYlD,YAAYG,OAAO;gBAC/BgD,mBAAmB,CAACnD,YAAYG,OAAO;gBACvCiD,kBAAkB;gBAClBC,eAAe;gBACfC,UAAU,CAACC;wBACFA;oBAAP,OAAOA,CAAAA,2BAAAA,UAAUC,aAAa,CAAC7F,8BAAxB4F,sCAAAA,2BAA4CA;gBACrD;YACF;SACD;IAEL,GAAG;QAACrE;QAAOC;QAAWC;QAAMC;QAAgBrB;QAAWF;KAAc;IAErE,OAAO;QACLwB;QACAoE;QACA1C;QACAJ;QACAL;QACAN;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../src/components/useEmblaCarousel.ts"],"sourcesContent":["import { type EventHandler, useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport EmblaCarousel, { EmblaPluginType, type EmblaCarouselType, type EmblaOptionsType } from 'embla-carousel';\nimport * as React from 'react';\n\nimport { carouselCardClassNames } from './CarouselCard/useCarouselCardStyles.styles';\nimport { carouselSliderClassNames } from './CarouselSlider/useCarouselSliderStyles.styles';\nimport { CarouselMotion, CarouselUpdateData, CarouselVisibilityEventDetail } from '../Carousel';\nimport Autoplay from 'embla-carousel-autoplay';\nimport Fade from 'embla-carousel-fade';\nimport { pointerEventPlugin } from './pointerEvents';\nimport type { CarouselIndexChangeData } from './CarouselContext.types';\n\nconst sliderClassname = `.${carouselSliderClassNames.root}`;\n\nconst DEFAULT_EMBLA_OPTIONS: EmblaOptionsType = {\n containScroll: 'trimSnaps',\n inViewThreshold: 0.99,\n watchDrag: false,\n skipSnaps: true,\n\n container: sliderClassname,\n slides: `.${carouselCardClassNames.root}`,\n};\n\nexport const EMBLA_VISIBILITY_EVENT = 'embla:visibilitychange';\n\nexport function setTabsterDefault(element: Element, isDefault: boolean) {\n const tabsterAttr = element.getAttribute('data-tabster');\n\n if (tabsterAttr) {\n const tabsterAttributes = JSON.parse(tabsterAttr);\n if (tabsterAttributes.focusable) {\n // If tabster.focusable isn't present, we will ignore.\n tabsterAttributes.focusable.isDefault = isDefault;\n element.setAttribute('data-tabster', JSON.stringify(tabsterAttributes));\n }\n }\n}\n\nexport function useEmblaCarousel(\n options: Pick<EmblaOptionsType, 'align' | 'direction' | 'loop' | 'slidesToScroll' | 'watchDrag' | 'containScroll'> & {\n defaultActiveIndex: number | undefined;\n activeIndex: number | undefined;\n motion?: CarouselMotion;\n onDragIndexChange?: EventHandler<CarouselIndexChangeData>;\n },\n) {\n const { align, direction, loop, slidesToScroll, watchDrag, containScroll, motion, onDragIndexChange } = options;\n const [activeIndex, setActiveIndex] = useControllableState({\n defaultState: options.defaultActiveIndex,\n state: options.activeIndex,\n initialState: 0,\n });\n\n const onDragEvent = useEventCallback((event: PointerEvent | MouseEvent, index: number) => {\n onDragIndexChange?.(event, { event, type: 'drag', index });\n });\n\n const emblaOptions = React.useRef<EmblaOptionsType>({\n align,\n direction,\n loop,\n slidesToScroll,\n startIndex: activeIndex,\n watchDrag,\n containScroll,\n });\n\n const emblaApi = React.useRef<EmblaCarouselType | null>(null);\n const autoplayRef = React.useRef<boolean>(false);\n\n const resetAutoplay = React.useCallback(() => {\n emblaApi.current?.plugins().autoplay.reset();\n }, []);\n\n /* Our autoplay button, which is required by standards for autoplay to be enabled, will handle controlled state */\n const enableAutoplay = React.useCallback(\n (autoplay: boolean) => {\n autoplayRef.current = autoplay;\n if (autoplay) {\n emblaApi.current?.plugins().autoplay.play();\n // Reset after play to ensure timing and any focus/mouse pause state is reset.\n resetAutoplay();\n } else {\n emblaApi.current?.plugins().autoplay.stop();\n }\n },\n [resetAutoplay],\n );\n\n const getPlugins = React.useCallback(() => {\n const plugins: EmblaPluginType[] = [\n Autoplay({\n playOnInit: autoplayRef.current,\n stopOnInteraction: !autoplayRef.current,\n stopOnMouseEnter: true,\n stopOnFocusIn: true,\n }),\n ];\n\n // Optionally add Fade plugin\n if (motion === 'fade') {\n plugins.push(Fade());\n }\n\n if (watchDrag) {\n plugins.push(\n pointerEventPlugin({\n onSelectViaDrag: onDragEvent,\n }),\n );\n }\n\n return plugins;\n }, [motion, onDragEvent, watchDrag]);\n\n // Listeners contains callbacks for UI elements that may require state update based on embla changes\n const listeners = React.useRef(new Set<(data: CarouselUpdateData) => void>());\n const subscribeForValues = React.useCallback((listener: (data: CarouselUpdateData) => void) => {\n listeners.current.add(listener);\n\n return () => {\n listeners.current.delete(listener);\n };\n }, []);\n\n const viewportRef: React.RefObject<HTMLDivElement> = React.useRef(null);\n const containerRef: React.RefObject<HTMLDivElement> = React.useMemo(() => {\n let currentElement: HTMLDivElement | null = null;\n\n const handleIndexChange = () => {\n const newIndex = emblaApi.current?.selectedScrollSnap() ?? 0;\n const slides = emblaApi.current?.slideNodes();\n const actualIndex = emblaApi.current?.internalEngine().slideRegistry[newIndex][0] ?? 0;\n\n // We set the active or first index of group on-screen as the selected tabster index\n slides?.forEach((slide, slideIndex) => {\n setTabsterDefault(slide, slideIndex === actualIndex);\n });\n setActiveIndex(newIndex);\n };\n const handleReinit = () => {\n const nodes: HTMLElement[] = emblaApi.current?.slideNodes() ?? [];\n const groupIndexList: number[][] = emblaApi.current?.internalEngine().slideRegistry ?? [];\n const navItemsCount = groupIndexList.length > 0 ? groupIndexList.length : nodes.length;\n\n const data: CarouselUpdateData = {\n navItemsCount,\n activeIndex: emblaApi.current?.selectedScrollSnap() ?? 0,\n groupIndexList,\n slideNodes: nodes,\n };\n\n for (const listener of listeners.current) {\n listener(data);\n }\n };\n const handleVisibilityChange = () => {\n const cardElements = emblaApi.current?.slideNodes();\n const visibleIndexes = emblaApi.current?.slidesInView() ?? [];\n\n cardElements?.forEach((cardElement, index) => {\n cardElement.dispatchEvent(\n new CustomEvent<CarouselVisibilityEventDetail>(EMBLA_VISIBILITY_EVENT, {\n bubbles: false,\n detail: { isVisible: visibleIndexes.includes(index) },\n }),\n );\n });\n };\n\n const plugins = getPlugins();\n\n return {\n set current(newElement: HTMLDivElement | null) {\n if (currentElement) {\n emblaApi.current?.off('slidesInView', handleVisibilityChange);\n emblaApi.current?.off('select', handleIndexChange);\n emblaApi.current?.off('reInit', handleReinit);\n emblaApi.current?.destroy();\n }\n\n // Use direct viewport if available, else fallback to container (includes Carousel controls).\n const wrapperElement = viewportRef.current ?? newElement;\n if (wrapperElement) {\n currentElement = wrapperElement;\n emblaApi.current = EmblaCarousel(\n wrapperElement,\n {\n ...DEFAULT_EMBLA_OPTIONS,\n ...emblaOptions.current,\n },\n plugins,\n );\n\n emblaApi.current?.on('reInit', handleReinit);\n emblaApi.current?.on('slidesInView', handleVisibilityChange);\n emblaApi.current?.on('select', handleIndexChange);\n }\n },\n };\n }, [getPlugins, setActiveIndex]);\n\n const carouselApi = React.useMemo(\n () => ({\n scrollToElement: (element: HTMLElement, jump?: boolean) => {\n const cardElements = emblaApi.current?.slideNodes();\n const groupIndexList = emblaApi.current?.internalEngine().slideRegistry ?? [];\n const cardIndex = cardElements?.indexOf(element) ?? 0;\n const groupIndex = groupIndexList.findIndex(group => {\n return group.includes(cardIndex);\n });\n const indexFocus = groupIndex ?? cardIndex;\n emblaApi.current?.scrollTo(indexFocus, jump);\n\n return indexFocus;\n },\n scrollToIndex: (index: number, jump?: boolean) => {\n emblaApi.current?.scrollTo(index, jump);\n },\n scrollInDirection: (dir: 'prev' | 'next') => {\n if (dir === 'prev') {\n emblaApi.current?.scrollPrev();\n } else {\n emblaApi.current?.scrollNext();\n }\n\n return emblaApi.current?.selectedScrollSnap() ?? 0;\n },\n }),\n [],\n );\n\n React.useEffect(() => {\n // Scroll to controlled values on update\n const currentActiveIndex = emblaApi.current?.selectedScrollSnap() ?? 0;\n emblaOptions.current.startIndex = activeIndex;\n if (activeIndex !== currentActiveIndex) {\n emblaApi.current?.scrollTo(activeIndex);\n }\n }, [activeIndex]);\n\n React.useEffect(() => {\n const plugins = getPlugins();\n\n emblaOptions.current = {\n startIndex: emblaOptions.current.startIndex,\n align,\n direction,\n loop,\n slidesToScroll,\n watchDrag,\n containScroll,\n };\n emblaApi.current?.reInit(\n {\n ...DEFAULT_EMBLA_OPTIONS,\n ...emblaOptions.current,\n },\n plugins,\n );\n }, [align, direction, loop, slidesToScroll, watchDrag, containScroll, getPlugins]);\n\n return {\n activeIndex,\n carouselApi,\n viewportRef,\n containerRef,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n };\n}\n"],"names":["useControllableState","useEventCallback","EmblaCarousel","React","carouselCardClassNames","carouselSliderClassNames","Autoplay","Fade","pointerEventPlugin","sliderClassname","root","DEFAULT_EMBLA_OPTIONS","containScroll","inViewThreshold","watchDrag","skipSnaps","container","slides","EMBLA_VISIBILITY_EVENT","setTabsterDefault","element","isDefault","tabsterAttr","getAttribute","tabsterAttributes","JSON","parse","focusable","setAttribute","stringify","useEmblaCarousel","options","align","direction","loop","slidesToScroll","motion","onDragIndexChange","activeIndex","setActiveIndex","defaultState","defaultActiveIndex","state","initialState","onDragEvent","event","index","type","emblaOptions","useRef","startIndex","emblaApi","autoplayRef","resetAutoplay","useCallback","current","plugins","autoplay","reset","enableAutoplay","play","stop","getPlugins","playOnInit","stopOnInteraction","stopOnMouseEnter","stopOnFocusIn","push","onSelectViaDrag","listeners","Set","subscribeForValues","listener","add","delete","viewportRef","containerRef","useMemo","currentElement","handleIndexChange","newIndex","selectedScrollSnap","slideNodes","actualIndex","internalEngine","slideRegistry","forEach","slide","slideIndex","handleReinit","nodes","groupIndexList","navItemsCount","length","data","handleVisibilityChange","cardElements","visibleIndexes","slidesInView","cardElement","dispatchEvent","CustomEvent","bubbles","detail","isVisible","includes","newElement","off","destroy","wrapperElement","on","carouselApi","scrollToElement","jump","cardIndex","indexOf","groupIndex","findIndex","group","indexFocus","scrollTo","scrollToIndex","scrollInDirection","dir","scrollPrev","scrollNext","useEffect","currentActiveIndex","reInit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAA4BA,oBAAoB,EAAEC,gBAAgB,QAAQ,4BAA4B;AACtG,OAAOC,mBAAuF,iBAAiB;AAC/G,YAAYC,WAAW,QAAQ;AAE/B,SAASC,sBAAsB,QAAQ,8CAA8C;AACrF,SAASC,wBAAwB,QAAQ,kDAAkD;AAE3F,OAAOC,cAAc,0BAA0B;AAC/C,OAAOC,UAAU,sBAAsB;AACvC,SAASC,kBAAkB,QAAQ,kBAAkB;AAGrD,MAAMC,kBAAkB,CAAC,CAAC,EAAEJ,yBAAyBK,IAAI,CAAC,CAAC;AAE3D,MAAMC,wBAA0C;IAC9CC,eAAe;IACfC,iBAAiB;IACjBC,WAAW;IACXC,WAAW;IAEXC,WAAWP;IACXQ,QAAQ,CAAC,CAAC,EA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kDAAAA,uCAA0C;YACnD;QACF,CAAA,GACA,EAAE;IAGJhD,MAAM2H,SAAS,CAAC;YAEa3E;YAAAA;QAD3B,wCAAwC;QACxC,MAAM4E,qBAAqB5E,CAAAA,wCAAAA,oBAAAA,SAASI,OAAO,cAAhBJ,wCAAAA,kBAAkB8B,kBAAkB,gBAApC9B,kDAAAA,uCAA0C;QACrEH,aAAaO,OAAO,CAACL,UAAU,GAAGZ;QAClC,IAAIA,gBAAgByF,oBAAoB;gBACtC5E;aAAAA,qBAAAA,SAASI,OAAO,cAAhBJ,yCAAAA,mBAAkBqE,QAAQ,CAAClF;QAC7B;IACF,GAAG;QAACA;KAAY;IAEhBnC,MAAM2H,SAAS,CAAC;YAYd3E;QAXA,MAAMK,UAAUM;QAEhBd,aAAaO,OAAO,GAAG;YACrBL,YAAYF,aAAaO,OAAO,CAACL,UAAU;YAC3ClB;YACAC;YACAC;YACAC;YACArB;YACAF;QACF;SACAuC,oBAAAA,SAASI,OAAO,cAAhBJ,wCAAAA,kBAAkB6E,MAAM,CACtB;YACE,GAAGrH,qBAAqB;YACxB,GAAGqC,aAAaO,OAAO;QACzB,GACAC;IAEJ,GAAG;QAACxB;QAAOC;QAAWC;QAAMC;QAAgBrB;QAAWF;QAAekD;KAAW;IAEjF,OAAO;QACLxB;QACAyE;QACApC;QACAC;QACAL;QACAZ;QACAN;IACF;AACF"}
|
package/lib/index.js
CHANGED
|
@@ -8,3 +8,4 @@ export { CarouselNavImageButton, carouselNavImageButtonClassNames, renderCarouse
|
|
|
8
8
|
export { CarouselSlider, carouselSliderClassNames, renderCarouselSlider_unstable, useCarouselSliderStyles_unstable, useCarouselSlider_unstable } from './CarouselSlider';
|
|
9
9
|
export { CarouselNavContainer, carouselNavContainerClassNames, renderCarouselNavContainer_unstable, useCarouselNavContainerStyles_unstable, useCarouselNavContainer_unstable } from './CarouselNavContainer';
|
|
10
10
|
export { carouselContextDefaultValue, CarouselProvider, useCarouselContext_unstable } from './CarouselContext';
|
|
11
|
+
export { CarouselViewport, carouselViewportClassNames, renderCarouselViewport_unstable, useCarouselViewportStyles_unstable, useCarouselViewport_unstable } from './CarouselViewport';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { CarouselButtonProps, CarouselButtonSlots, CarouselButtonState } from './CarouselButton';\nexport {\n CarouselButton,\n carouselButtonClassNames,\n renderCarouselButton_unstable,\n useCarouselButtonStyles_unstable,\n useCarouselButton_unstable,\n} from './CarouselButton';\nexport type { CarouselNavProps, CarouselNavSlots, CarouselNavState, NavButtonRenderFunction } from './CarouselNav';\nexport {\n CarouselNav,\n carouselNavClassNames,\n renderCarouselNav_unstable,\n useCarouselNavStyles_unstable,\n useCarouselNav_unstable,\n} from './CarouselNav';\nexport type { CarouselNavButtonProps, CarouselNavButtonSlots, CarouselNavButtonState } from './CarouselNavButton';\nexport {\n CarouselNavButton,\n carouselNavButtonClassNames,\n renderCarouselNavButton_unstable,\n useCarouselNavButtonStyles_unstable,\n useCarouselNavButton_unstable,\n} from './CarouselNavButton';\nexport type { CarouselProps, CarouselSlots, CarouselState, CarouselAnnouncerFunction } from './Carousel';\nexport {\n Carousel,\n carouselClassNames,\n renderCarousel_unstable,\n useCarouselStyles_unstable,\n useCarousel_unstable,\n} from './Carousel';\nexport type { CarouselCardProps, CarouselCardSlots, CarouselCardState } from './CarouselCard';\nexport {\n CarouselCard,\n carouselCardClassNames,\n renderCarouselCard_unstable,\n useCarouselCardStyles_unstable,\n useCarouselCard_unstable,\n} from './CarouselCard';\nexport type {\n CarouselAutoplayButtonProps,\n CarouselAutoplayButtonSlots,\n CarouselAutoplayButtonState,\n} from './CarouselAutoplayButton';\nexport {\n CarouselAutoplayButton,\n carouselAutoplayButtonClassNames,\n renderCarouselAutoplayButton_unstable,\n useCarouselAutoplayButtonStyles_unstable,\n useCarouselAutoplayButton_unstable,\n} from './CarouselAutoplayButton';\nexport type {\n CarouselNavImageButtonProps,\n CarouselNavImageButtonSlots,\n CarouselNavImageButtonState,\n} from './CarouselNavImageButton';\nexport {\n CarouselNavImageButton,\n carouselNavImageButtonClassNames,\n renderCarouselNavImageButton_unstable,\n useCarouselNavImageButtonStyles_unstable,\n useCarouselNavImageButton_unstable,\n} from './CarouselNavImageButton';\nexport {\n CarouselSlider,\n carouselSliderClassNames,\n renderCarouselSlider_unstable,\n useCarouselSliderStyles_unstable,\n useCarouselSlider_unstable,\n} from './CarouselSlider';\nexport type { CarouselSliderProps, CarouselSliderSlots, CarouselSliderState } from './CarouselSlider';\nexport type {\n CarouselNavContainerProps,\n CarouselNavContainerSlots,\n CarouselNavContainerState,\n} from './CarouselNavContainer';\nexport {\n CarouselNavContainer,\n carouselNavContainerClassNames,\n renderCarouselNavContainer_unstable,\n useCarouselNavContainerStyles_unstable,\n useCarouselNavContainer_unstable,\n} from './CarouselNavContainer';\nexport { carouselContextDefaultValue, CarouselProvider, useCarouselContext_unstable } from './CarouselContext';\nexport type { CarouselIndexChangeData, CarouselContextValue, CarouselContextValues } from './CarouselContext';\n"],"names":["CarouselButton","carouselButtonClassNames","renderCarouselButton_unstable","useCarouselButtonStyles_unstable","useCarouselButton_unstable","CarouselNav","carouselNavClassNames","renderCarouselNav_unstable","useCarouselNavStyles_unstable","useCarouselNav_unstable","CarouselNavButton","carouselNavButtonClassNames","renderCarouselNavButton_unstable","useCarouselNavButtonStyles_unstable","useCarouselNavButton_unstable","Carousel","carouselClassNames","renderCarousel_unstable","useCarouselStyles_unstable","useCarousel_unstable","CarouselCard","carouselCardClassNames","renderCarouselCard_unstable","useCarouselCardStyles_unstable","useCarouselCard_unstable","CarouselAutoplayButton","carouselAutoplayButtonClassNames","renderCarouselAutoplayButton_unstable","useCarouselAutoplayButtonStyles_unstable","useCarouselAutoplayButton_unstable","CarouselNavImageButton","carouselNavImageButtonClassNames","renderCarouselNavImageButton_unstable","useCarouselNavImageButtonStyles_unstable","useCarouselNavImageButton_unstable","CarouselSlider","carouselSliderClassNames","renderCarouselSlider_unstable","useCarouselSliderStyles_unstable","useCarouselSlider_unstable","CarouselNavContainer","carouselNavContainerClassNames","renderCarouselNavContainer_unstable","useCarouselNavContainerStyles_unstable","useCarouselNavContainer_unstable","carouselContextDefaultValue","CarouselProvider","useCarouselContext_unstable"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { CarouselButtonProps, CarouselButtonSlots, CarouselButtonState } from './CarouselButton';\nexport {\n CarouselButton,\n carouselButtonClassNames,\n renderCarouselButton_unstable,\n useCarouselButtonStyles_unstable,\n useCarouselButton_unstable,\n} from './CarouselButton';\nexport type { CarouselNavProps, CarouselNavSlots, CarouselNavState, NavButtonRenderFunction } from './CarouselNav';\nexport {\n CarouselNav,\n carouselNavClassNames,\n renderCarouselNav_unstable,\n useCarouselNavStyles_unstable,\n useCarouselNav_unstable,\n} from './CarouselNav';\nexport type { CarouselNavButtonProps, CarouselNavButtonSlots, CarouselNavButtonState } from './CarouselNavButton';\nexport {\n CarouselNavButton,\n carouselNavButtonClassNames,\n renderCarouselNavButton_unstable,\n useCarouselNavButtonStyles_unstable,\n useCarouselNavButton_unstable,\n} from './CarouselNavButton';\nexport type { CarouselProps, CarouselSlots, CarouselState, CarouselAnnouncerFunction } from './Carousel';\nexport {\n Carousel,\n carouselClassNames,\n renderCarousel_unstable,\n useCarouselStyles_unstable,\n useCarousel_unstable,\n} from './Carousel';\nexport type { CarouselCardProps, CarouselCardSlots, CarouselCardState } from './CarouselCard';\nexport {\n CarouselCard,\n carouselCardClassNames,\n renderCarouselCard_unstable,\n useCarouselCardStyles_unstable,\n useCarouselCard_unstable,\n} from './CarouselCard';\nexport type {\n CarouselAutoplayButtonProps,\n CarouselAutoplayButtonSlots,\n CarouselAutoplayButtonState,\n} from './CarouselAutoplayButton';\nexport {\n CarouselAutoplayButton,\n carouselAutoplayButtonClassNames,\n renderCarouselAutoplayButton_unstable,\n useCarouselAutoplayButtonStyles_unstable,\n useCarouselAutoplayButton_unstable,\n} from './CarouselAutoplayButton';\nexport type {\n CarouselNavImageButtonProps,\n CarouselNavImageButtonSlots,\n CarouselNavImageButtonState,\n} from './CarouselNavImageButton';\nexport {\n CarouselNavImageButton,\n carouselNavImageButtonClassNames,\n renderCarouselNavImageButton_unstable,\n useCarouselNavImageButtonStyles_unstable,\n useCarouselNavImageButton_unstable,\n} from './CarouselNavImageButton';\nexport {\n CarouselSlider,\n carouselSliderClassNames,\n renderCarouselSlider_unstable,\n useCarouselSliderStyles_unstable,\n useCarouselSlider_unstable,\n} from './CarouselSlider';\nexport type { CarouselSliderProps, CarouselSliderSlots, CarouselSliderState } from './CarouselSlider';\nexport type {\n CarouselNavContainerProps,\n CarouselNavContainerSlots,\n CarouselNavContainerState,\n} from './CarouselNavContainer';\nexport {\n CarouselNavContainer,\n carouselNavContainerClassNames,\n renderCarouselNavContainer_unstable,\n useCarouselNavContainerStyles_unstable,\n useCarouselNavContainer_unstable,\n} from './CarouselNavContainer';\nexport { carouselContextDefaultValue, CarouselProvider, useCarouselContext_unstable } from './CarouselContext';\nexport type { CarouselIndexChangeData, CarouselContextValue, CarouselContextValues } from './CarouselContext';\nexport type { CarouselViewportProps, CarouselViewportSlots, CarouselViewportState } from './CarouselViewport';\nexport {\n CarouselViewport,\n carouselViewportClassNames,\n renderCarouselViewport_unstable,\n useCarouselViewportStyles_unstable,\n useCarouselViewport_unstable,\n} from './CarouselViewport';\n"],"names":["CarouselButton","carouselButtonClassNames","renderCarouselButton_unstable","useCarouselButtonStyles_unstable","useCarouselButton_unstable","CarouselNav","carouselNavClassNames","renderCarouselNav_unstable","useCarouselNavStyles_unstable","useCarouselNav_unstable","CarouselNavButton","carouselNavButtonClassNames","renderCarouselNavButton_unstable","useCarouselNavButtonStyles_unstable","useCarouselNavButton_unstable","Carousel","carouselClassNames","renderCarousel_unstable","useCarouselStyles_unstable","useCarousel_unstable","CarouselCard","carouselCardClassNames","renderCarouselCard_unstable","useCarouselCardStyles_unstable","useCarouselCard_unstable","CarouselAutoplayButton","carouselAutoplayButtonClassNames","renderCarouselAutoplayButton_unstable","useCarouselAutoplayButtonStyles_unstable","useCarouselAutoplayButton_unstable","CarouselNavImageButton","carouselNavImageButtonClassNames","renderCarouselNavImageButton_unstable","useCarouselNavImageButtonStyles_unstable","useCarouselNavImageButton_unstable","CarouselSlider","carouselSliderClassNames","renderCarouselSlider_unstable","useCarouselSliderStyles_unstable","useCarouselSlider_unstable","CarouselNavContainer","carouselNavContainerClassNames","renderCarouselNavContainer_unstable","useCarouselNavContainerStyles_unstable","useCarouselNavContainer_unstable","carouselContextDefaultValue","CarouselProvider","useCarouselContext_unstable","CarouselViewport","carouselViewportClassNames","renderCarouselViewport_unstable","useCarouselViewportStyles_unstable","useCarouselViewport_unstable"],"rangeMappings":";;;;;;;;;;","mappings":"AACA,SACEA,cAAc,EACdC,wBAAwB,EACxBC,6BAA6B,EAC7BC,gCAAgC,EAChCC,0BAA0B,QACrB,mBAAmB;AAE1B,SACEC,WAAW,EACXC,qBAAqB,EACrBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,uBAAuB,QAClB,gBAAgB;AAEvB,SACEC,iBAAiB,EACjBC,2BAA2B,EAC3BC,gCAAgC,EAChCC,mCAAmC,EACnCC,6BAA6B,QACxB,sBAAsB;AAE7B,SACEC,QAAQ,EACRC,kBAAkB,EAClBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,oBAAoB,QACf,aAAa;AAEpB,SACEC,YAAY,EACZC,sBAAsB,EACtBC,2BAA2B,EAC3BC,8BAA8B,EAC9BC,wBAAwB,QACnB,iBAAiB;AAMxB,SACEC,sBAAsB,EACtBC,gCAAgC,EAChCC,qCAAqC,EACrCC,wCAAwC,EACxCC,kCAAkC,QAC7B,2BAA2B;AAMlC,SACEC,sBAAsB,EACtBC,gCAAgC,EAChCC,qCAAqC,EACrCC,wCAAwC,EACxCC,kCAAkC,QAC7B,2BAA2B;AAClC,SACEC,cAAc,EACdC,wBAAwB,EACxBC,6BAA6B,EAC7BC,gCAAgC,EAChCC,0BAA0B,QACrB,mBAAmB;AAO1B,SACEC,oBAAoB,EACpBC,8BAA8B,EAC9BC,mCAAmC,EACnCC,sCAAsC,EACtCC,gCAAgC,QAC3B,yBAAyB;AAChC,SAASC,2BAA2B,EAAEC,gBAAgB,EAAEC,2BAA2B,QAAQ,oBAAoB;AAG/G,SACEC,gBAAgB,EAChBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,kCAAkC,EAClCC,4BAA4B,QACvB,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Carousel.ts"],"sourcesContent":["export * from './components/Carousel/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/Carousel.ts"],"sourcesContent":["export * from './components/Carousel/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselAutoplayButton.ts"],"sourcesContent":["export * from './components/CarouselAutoplayButton/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselAutoplayButton.ts"],"sourcesContent":["export * from './components/CarouselAutoplayButton/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselButton.ts"],"sourcesContent":["export * from './components/CarouselButton/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselButton.ts"],"sourcesContent":["export * from './components/CarouselButton/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselCard.ts"],"sourcesContent":["export * from './components/CarouselCard/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselCard.ts"],"sourcesContent":["export * from './components/CarouselCard/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselContext.ts"],"sourcesContent":["export * from './components/CarouselContext';\nexport * from './components/CarouselContext.types';\n"],"names":[],"rangeMappings":";;;;;;","mappings":";;;;;uBAAc;uBACA"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselContext.ts"],"sourcesContent":["export * from './components/CarouselContext';\nexport * from './components/CarouselContext.types';\n"],"names":[],"rangeMappings":";;;;;;","mappings":";;;;;uBAAc;uBACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselNav.ts"],"sourcesContent":["export * from './components/CarouselNav/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselNav.ts"],"sourcesContent":["export * from './components/CarouselNav/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselNavButton.ts"],"sourcesContent":["export * from './components/CarouselNavButton/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselNavButton.ts"],"sourcesContent":["export * from './components/CarouselNavButton/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselNavContainer.ts"],"sourcesContent":["export * from './components/CarouselNavContainer/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselNavContainer.ts"],"sourcesContent":["export * from './components/CarouselNavContainer/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselNavImageButton.ts"],"sourcesContent":["export * from './components/CarouselNavImageButton/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselNavImageButton.ts"],"sourcesContent":["export * from './components/CarouselNavImageButton/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselSlider.ts"],"sourcesContent":["export * from './components/CarouselSlider/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
1
|
+
{"version":3,"sources":["../src/CarouselSlider.ts"],"sourcesContent":["export * from './components/CarouselSlider/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/CarouselViewport.ts"],"sourcesContent":["export * from './components/CarouselViewport/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -14,13 +14,12 @@ const _useCarousel = require("./useCarousel");
|
|
|
14
14
|
const _renderCarousel = require("./renderCarousel");
|
|
15
15
|
const _useCarouselStylesstyles = require("./useCarouselStyles.styles");
|
|
16
16
|
const _useCarouselContextValues = require("./useCarouselContextValues");
|
|
17
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
17
18
|
const Carousel = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
18
19
|
const state = (0, _useCarousel.useCarousel_unstable)(props, ref);
|
|
19
20
|
(0, _useCarouselStylesstyles.useCarouselStyles_unstable)(state);
|
|
21
|
+
(0, _reactsharedcontexts.useCustomStyleHook_unstable)('useCarouselStyles_unstable')(state);
|
|
20
22
|
const contextValues = (0, _useCarouselContextValues.useCarouselContextValues_unstable)(state);
|
|
21
|
-
// TODO update types in packages/react-components/react-shared-contexts/src/CustomStyleHooksContext/CustomStyleHooksContext.ts
|
|
22
|
-
// https://github.com/microsoft/fluentui/blob/master/rfcs/react-components/convergence/custom-styling.md
|
|
23
|
-
// useCustomStyleHook_unstable('useCarouselStyles_unstable')(state);
|
|
24
23
|
return (0, _renderCarousel.renderCarousel_unstable)(state, contextValues);
|
|
25
24
|
});
|
|
26
25
|
Carousel.displayName = 'Carousel';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Carousel.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCarousel_unstable } from './useCarousel';\nimport { renderCarousel_unstable } from './renderCarousel';\nimport { useCarouselStyles_unstable } from './useCarouselStyles.styles';\nimport type { CarouselProps } from './Carousel.types';\nimport { useCarouselContextValues_unstable } from './useCarouselContextValues';\n\n/**\n * Carousel is the context wrapper and container for all carousel content/controls,\n * it has no direct style or slot opinions.\n *\n * Carousel also provides API interfaces for callbacks that will occur on navigation events.\n */\nexport const Carousel: ForwardRefComponent<CarouselProps> = React.forwardRef((props, ref) => {\n const state = useCarousel_unstable(props, ref);\n\n useCarouselStyles_unstable(state);\n\n const contextValues = useCarouselContextValues_unstable(state);\n
|
|
1
|
+
{"version":3,"sources":["../src/components/Carousel/Carousel.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCarousel_unstable } from './useCarousel';\nimport { renderCarousel_unstable } from './renderCarousel';\nimport { useCarouselStyles_unstable } from './useCarouselStyles.styles';\nimport type { CarouselProps } from './Carousel.types';\nimport { useCarouselContextValues_unstable } from './useCarouselContextValues';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Carousel is the context wrapper and container for all carousel content/controls,\n * it has no direct style or slot opinions.\n *\n * Carousel also provides API interfaces for callbacks that will occur on navigation events.\n */\nexport const Carousel: ForwardRefComponent<CarouselProps> = React.forwardRef((props, ref) => {\n const state = useCarousel_unstable(props, ref);\n\n useCarouselStyles_unstable(state);\n useCustomStyleHook_unstable('useCarouselStyles_unstable')(state);\n\n const contextValues = useCarouselContextValues_unstable(state);\n\n return renderCarousel_unstable(state, contextValues);\n});\n\nCarousel.displayName = 'Carousel';\n"],"names":["Carousel","React","forwardRef","props","ref","state","useCarousel_unstable","useCarouselStyles_unstable","useCustomStyleHook_unstable","contextValues","useCarouselContextValues_unstable","renderCarousel_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAeaA;;;eAAAA;;;;iEAfU;6BAEc;gCACG;yCACG;0CAEO;qCACN;AAQrC,MAAMA,WAAAA,WAAAA,GAA+CC,OAAMC,UAAU,CAAC,CAACC,OAAOC;IACnF,MAAMC,QAAQC,IAAAA,iCAAAA,EAAqBH,OAAOC;IAE1CG,IAAAA,mDAAAA,EAA2BF;IAC3BG,IAAAA,gDAAAA,EAA4B,8BAA8BH;IAE1D,MAAMI,gBAAgBC,IAAAA,2DAAAA,EAAkCL;IAExD,OAAOM,IAAAA,uCAAAA,EAAwBN,OAAOI;AACxC;AAEAT,SAASY,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Carousel.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, EventHandler, Slot } from '@fluentui/react-utilities';\nimport type { CarouselContextValue, CarouselIndexChangeData } from '../CarouselContext.types';\n\nexport type CarouselSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * Children function replacement, passes through updated context index and carousel information for localization\n */\nexport type CarouselAnnouncerFunction = (index: number, totalSlides: number, slideGroupList: number[][]) => string;\n\n/**\n * Carousel Props\n */\nexport type CarouselProps = ComponentProps<CarouselSlots> & {\n /**\n * The initial page to display in uncontrolled mode.\n */\n defaultActiveIndex?: number;\n\n /**\n * The alignment of the carousel.\n */\n align?: 'center' | 'start' | 'end';\n\n /**\n * The value of the currently active page.\n */\n activeIndex?: number;\n\n /**\n * Callback to notify a page change.\n */\n onActiveIndexChange?: EventHandler<CarouselIndexChangeData>;\n\n /**\n * Circular enables the carousel to loop back around on navigation past trailing index.\n */\n circular?: boolean;\n\n /**\n * Controls the number of carousel cards per navigation element, will default to 'auto'\n * Recommended to set to '1' when using full page carousel cards.\n */\n groupSize?: number | 'auto';\n\n /**\n * Enables drag to scroll on carousel items.\n * Defaults to: False\n */\n draggable?: boolean;\n\n /**\n * Adds whitespace to start/end so that 'align' prop is always respected for current index\n * Defaults to: False\n */\n whitespace?: boolean;\n\n /**\n * Localizes the string used to announce carousel page changes\n * Defaults to: undefined\n */\n announcement?: CarouselAnnouncerFunction;\n};\n\n/**\n * State used in rendering Carousel\n */\nexport type CarouselState = ComponentState<CarouselSlots> & CarouselContextValue;\n\nexport interface CarouselVisibilityEventDetail {\n isVisible: boolean;\n}\n\nexport type CarouselVisibilityChangeEvent = CustomEvent<CarouselVisibilityEventDetail>;\n\n/**\n * @internal\n */\nexport interface CarouselUpdateData {\n /**\n * The current carousel index, a change in index will not trigger the callback (use context index instead).\n */\n activeIndex: number;\n /**\n * The total number of slides to be navigated, accounts for grouping.\n */\n navItemsCount: number;\n /**\n * A breakdown of the card indexes contained within each slide index.\n */\n groupIndexList: number[][];\n /**\n * An array of the card DOM elements after render\n */\n slideNodes: HTMLElement[];\n}\n"],"names":[],"rangeMappings":";;","mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/Carousel/Carousel.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, EventHandler, Slot } from '@fluentui/react-utilities';\nimport type { CarouselContextValue, CarouselIndexChangeData } from '../CarouselContext.types';\n\nexport type CarouselSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * Children function replacement, passes through updated context index and carousel information for localization\n */\nexport type CarouselAnnouncerFunction = (index: number, totalSlides: number, slideGroupList: number[][]) => string;\n\n/**\n * List of integrated motion types\n */\nexport type CarouselMotion = 'slide' | 'fade';\n\n/**\n * Carousel Props\n */\nexport type CarouselProps = ComponentProps<CarouselSlots> & {\n /**\n * The initial page to display in uncontrolled mode.\n */\n defaultActiveIndex?: number;\n\n /**\n * The alignment of the carousel.\n */\n align?: 'center' | 'start' | 'end';\n\n /**\n * The value of the currently active page.\n */\n activeIndex?: number;\n\n /**\n * Callback to notify a page change.\n */\n onActiveIndexChange?: EventHandler<CarouselIndexChangeData>;\n\n /**\n * Circular enables the carousel to loop back around on navigation past trailing index.\n */\n circular?: boolean;\n\n /**\n * Controls the number of carousel cards per navigation element, will default to 'auto'\n * Recommended to set to '1' when using full page carousel cards.\n */\n groupSize?: number | 'auto';\n\n /**\n * Enables drag to scroll on carousel items.\n * Defaults to: False\n */\n draggable?: boolean;\n\n /**\n * Adds whitespace to start/end so that 'align' prop is always respected for current index\n * Defaults to: False\n */\n whitespace?: boolean;\n\n /**\n * Sets motion to fade in/out style with minimal movement\n * Defaults: false\n */\n motion?: CarouselMotion;\n\n /**\n * Localizes the string used to announce carousel page changes\n * Defaults to: undefined\n */\n announcement?: CarouselAnnouncerFunction;\n};\n\n/**\n * State used in rendering Carousel\n */\nexport type CarouselState = ComponentState<CarouselSlots> & CarouselContextValue;\n\nexport interface CarouselVisibilityEventDetail {\n isVisible: boolean;\n}\n\nexport type CarouselVisibilityChangeEvent = CustomEvent<CarouselVisibilityEventDetail>;\n\n/**\n * @internal\n */\nexport interface CarouselUpdateData {\n /**\n * The current carousel index, a change in index will not trigger the callback (use context index instead).\n */\n activeIndex: number;\n /**\n * The total number of slides to be navigated, accounts for grouping.\n */\n navItemsCount: number;\n /**\n * A breakdown of the card indexes contained within each slide index.\n */\n groupIndexList: number[][];\n /**\n * An array of the card DOM elements after render\n */\n slideNodes: HTMLElement[];\n}\n"],"names":[],"rangeMappings":";;","mappings":"AAwFA;;CAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './Carousel';\nexport * from './Carousel.types';\nexport * from './renderCarousel';\nexport * from './useCarousel';\nexport * from './useCarouselStyles.styles';\n"],"names":[],"rangeMappings":";;;;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Carousel/index.ts"],"sourcesContent":["export * from './Carousel';\nexport * from './Carousel.types';\nexport * from './renderCarousel';\nexport * from './useCarousel';\nexport * from './useCarouselStyles.styles';\n"],"names":[],"rangeMappings":";;;;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renderCarousel.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { CarouselState, CarouselSlots } from './Carousel.types';\nimport { CarouselProvider } from '../CarouselContext';\nimport type { CarouselContextValues } from '../CarouselContext.types';\n\n/**\n * Render the final JSX of Carousel\n */\nexport const renderCarousel_unstable = (state: CarouselState, contextValues: CarouselContextValues) => {\n assertSlots<CarouselSlots>(state);\n\n return (\n <CarouselProvider value={contextValues.carousel}>\n <state.root />\n </CarouselProvider>\n );\n};\n"],"names":["renderCarousel_unstable","state","contextValues","assertSlots","_jsx","CarouselProvider","value","carousel","root"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAWaA;;;eAAAA;;;4BAVb;gCAE4B;iCAEK;AAM1B,MAAMA,0BAA0B,CAACC,OAAsBC;IAC5DC,IAAAA,2BAAAA,EAA2BF;IAE3B,OAAA,WAAA,GACEG,IAAAA,eAAA,EAACC,iCAAAA,EAAAA;QAAiBC,OAAOJ,cAAcK,QAAQ;kBAC7C,WAAA,GAAAH,IAAAA,eAAA,EAACH,MAAMO,IAAI,EAAA,CAAA;;AAGjB"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Carousel/renderCarousel.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { CarouselState, CarouselSlots } from './Carousel.types';\nimport { CarouselProvider } from '../CarouselContext';\nimport type { CarouselContextValues } from '../CarouselContext.types';\n\n/**\n * Render the final JSX of Carousel\n */\nexport const renderCarousel_unstable = (state: CarouselState, contextValues: CarouselContextValues) => {\n assertSlots<CarouselSlots>(state);\n\n return (\n <CarouselProvider value={contextValues.carousel}>\n <state.root />\n </CarouselProvider>\n );\n};\n"],"names":["renderCarousel_unstable","state","contextValues","assertSlots","_jsx","CarouselProvider","value","carousel","root"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAWaA;;;eAAAA;;;4BAVb;gCAE4B;iCAEK;AAM1B,MAAMA,0BAA0B,CAACC,OAAsBC;IAC5DC,IAAAA,2BAAAA,EAA2BF;IAE3B,OAAA,WAAA,GACEG,IAAAA,eAAA,EAACC,iCAAAA,EAAAA;QAAiBC,OAAOJ,cAAcK,QAAQ;kBAC7C,WAAA,GAAAH,IAAAA,eAAA,EAACH,MAAMO,IAAI,EAAA,CAAA;;AAGjB"}
|
|
@@ -15,9 +15,9 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
|
15
15
|
const _useEmblaCarousel = require("../useEmblaCarousel");
|
|
16
16
|
function useCarousel_unstable(props, ref) {
|
|
17
17
|
'use no memo';
|
|
18
|
-
const { align = 'center', circular = false, onActiveIndexChange, groupSize = 'auto', draggable = false, whitespace = false, announcement } = props;
|
|
18
|
+
const { align = 'center', circular = false, onActiveIndexChange, groupSize = 'auto', draggable = false, whitespace = false, announcement, motion = 'slide' } = props;
|
|
19
19
|
const { dir } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
20
|
-
const { activeIndex, carouselApi, containerRef, subscribeForValues, enableAutoplay, resetAutoplay } = (0, _useEmblaCarousel.useEmblaCarousel)({
|
|
20
|
+
const { activeIndex, carouselApi, containerRef, viewportRef, subscribeForValues, enableAutoplay, resetAutoplay } = (0, _useEmblaCarousel.useEmblaCarousel)({
|
|
21
21
|
align,
|
|
22
22
|
direction: dir,
|
|
23
23
|
loop: circular,
|
|
@@ -25,7 +25,9 @@ function useCarousel_unstable(props, ref) {
|
|
|
25
25
|
defaultActiveIndex: props.defaultActiveIndex,
|
|
26
26
|
activeIndex: props.activeIndex,
|
|
27
27
|
watchDrag: draggable,
|
|
28
|
-
containScroll: whitespace ? false : 'keepSnaps'
|
|
28
|
+
containScroll: whitespace ? false : 'keepSnaps',
|
|
29
|
+
motion,
|
|
30
|
+
onDragIndexChange: onActiveIndexChange
|
|
29
31
|
});
|
|
30
32
|
const selectPageByElement = (0, _reactutilities.useEventCallback)((event, element, jump)=>{
|
|
31
33
|
const foundIndex = carouselApi.scrollToElement(element, jump);
|
|
@@ -53,7 +55,7 @@ function useCarousel_unstable(props, ref) {
|
|
|
53
55
|
});
|
|
54
56
|
return nextPageIndex;
|
|
55
57
|
});
|
|
56
|
-
const
|
|
58
|
+
const mergedContainerRef = (0, _reactutilities.useMergedRefs)(ref, containerRef);
|
|
57
59
|
// Announce carousel updates
|
|
58
60
|
const announcementTextRef = _react.useRef('');
|
|
59
61
|
const totalNavLength = _react.useRef(0);
|
|
@@ -100,7 +102,7 @@ function useCarousel_unstable(props, ref) {
|
|
|
100
102
|
root: 'div'
|
|
101
103
|
},
|
|
102
104
|
root: _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', {
|
|
103
|
-
ref:
|
|
105
|
+
ref: mergedContainerRef,
|
|
104
106
|
role: 'region',
|
|
105
107
|
...props
|
|
106
108
|
}), {
|
|
@@ -108,7 +110,8 @@ function useCarousel_unstable(props, ref) {
|
|
|
108
110
|
}),
|
|
109
111
|
activeIndex,
|
|
110
112
|
circular,
|
|
111
|
-
containerRef:
|
|
113
|
+
containerRef: mergedContainerRef,
|
|
114
|
+
viewportRef,
|
|
112
115
|
selectPageByElement,
|
|
113
116
|
selectPageByDirection,
|
|
114
117
|
selectPageByIndex,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCarousel.ts"],"sourcesContent":["import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n getIntrinsicElementProps,\n slot,\n useEventCallback,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport type { CarouselProps, CarouselState } from './Carousel.types';\nimport type { CarouselContextValue } from '../CarouselContext.types';\nimport { useEmblaCarousel } from '../useEmblaCarousel';\nimport { useAnnounce } from '@fluentui/react-shared-contexts';\n\n/**\n * Create the state required to render Carousel.\n *\n * The returned state can be modified with hooks such as useCarouselStyles_unstable,\n * before being passed to renderCarousel_unstable.\n *\n * @param props - props from this instance of Carousel\n * @param ref - reference to root HTMLDivElement of Carousel\n */\nexport function useCarousel_unstable(props: CarouselProps, ref: React.Ref<HTMLDivElement>): CarouselState {\n 'use no memo';\n\n const {\n align = 'center',\n circular = false,\n onActiveIndexChange,\n groupSize = 'auto',\n draggable = false,\n whitespace = false,\n announcement,\n } = props;\n\n const { dir } = useFluent();\n const { activeIndex, carouselApi, containerRef, subscribeForValues, enableAutoplay, resetAutoplay } =\n useEmblaCarousel({\n align,\n direction: dir,\n loop: circular,\n slidesToScroll: groupSize,\n defaultActiveIndex: props.defaultActiveIndex,\n activeIndex: props.activeIndex,\n watchDrag: draggable,\n containScroll: whitespace ? false : 'keepSnaps',\n });\n\n const selectPageByElement: CarouselContextValue['selectPageByElement'] = useEventCallback((event, element, jump) => {\n const foundIndex = carouselApi.scrollToElement(element, jump);\n onActiveIndexChange?.(event, { event, type: 'focus', index: foundIndex });\n\n return foundIndex;\n });\n\n const selectPageByIndex: CarouselContextValue['selectPageByIndex'] = useEventCallback((event, index, jump) => {\n carouselApi.scrollToIndex(index, jump);\n\n onActiveIndexChange?.(event, { event, type: 'click', index });\n });\n\n const selectPageByDirection: CarouselContextValue['selectPageByDirection'] = useEventCallback((event, direction) => {\n const nextPageIndex = carouselApi.scrollInDirection(direction);\n onActiveIndexChange?.(event, { event, type: 'click', index: nextPageIndex });\n\n return nextPageIndex;\n });\n\n const
|
|
1
|
+
{"version":3,"sources":["../src/components/Carousel/useCarousel.ts"],"sourcesContent":["import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n getIntrinsicElementProps,\n slot,\n useEventCallback,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport type { CarouselProps, CarouselState } from './Carousel.types';\nimport type { CarouselContextValue } from '../CarouselContext.types';\nimport { useEmblaCarousel } from '../useEmblaCarousel';\nimport { useAnnounce } from '@fluentui/react-shared-contexts';\n\n/**\n * Create the state required to render Carousel.\n *\n * The returned state can be modified with hooks such as useCarouselStyles_unstable,\n * before being passed to renderCarousel_unstable.\n *\n * @param props - props from this instance of Carousel\n * @param ref - reference to root HTMLDivElement of Carousel\n */\nexport function useCarousel_unstable(props: CarouselProps, ref: React.Ref<HTMLDivElement>): CarouselState {\n 'use no memo';\n\n const {\n align = 'center',\n circular = false,\n onActiveIndexChange,\n groupSize = 'auto',\n draggable = false,\n whitespace = false,\n announcement,\n motion = 'slide',\n } = props;\n\n const { dir } = useFluent();\n const { activeIndex, carouselApi, containerRef, viewportRef, subscribeForValues, enableAutoplay, resetAutoplay } =\n useEmblaCarousel({\n align,\n direction: dir,\n loop: circular,\n slidesToScroll: groupSize,\n defaultActiveIndex: props.defaultActiveIndex,\n activeIndex: props.activeIndex,\n watchDrag: draggable,\n containScroll: whitespace ? false : 'keepSnaps',\n motion,\n onDragIndexChange: onActiveIndexChange,\n });\n\n const selectPageByElement: CarouselContextValue['selectPageByElement'] = useEventCallback((event, element, jump) => {\n const foundIndex = carouselApi.scrollToElement(element, jump);\n onActiveIndexChange?.(event, { event, type: 'focus', index: foundIndex });\n\n return foundIndex;\n });\n\n const selectPageByIndex: CarouselContextValue['selectPageByIndex'] = useEventCallback((event, index, jump) => {\n carouselApi.scrollToIndex(index, jump);\n\n onActiveIndexChange?.(event, { event, type: 'click', index });\n });\n\n const selectPageByDirection: CarouselContextValue['selectPageByDirection'] = useEventCallback((event, direction) => {\n const nextPageIndex = carouselApi.scrollInDirection(direction);\n onActiveIndexChange?.(event, { event, type: 'click', index: nextPageIndex });\n\n return nextPageIndex;\n });\n\n const mergedContainerRef = useMergedRefs(ref, containerRef);\n\n // Announce carousel updates\n const announcementTextRef = React.useRef<string>('');\n const totalNavLength = React.useRef<number>(0);\n const navGroupRef = React.useRef<number[][]>([]);\n\n const { announce } = useAnnounce();\n\n const updateAnnouncement = useEventCallback(() => {\n if (totalNavLength.current <= 0 || !announcement) {\n // Ignore announcements until slides discovered\n return;\n }\n\n const announcementText = announcement(activeIndex, totalNavLength.current, navGroupRef.current);\n\n if (announcementText !== announcementTextRef.current) {\n announcementTextRef.current = announcementText;\n announce(announcementText, { polite: true });\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n // Subscribe to any non-index carousel state changes\n return subscribeForValues(data => {\n if (totalNavLength.current <= 0 && data.navItemsCount > 0 && announcement) {\n const announcementText = announcement(data.activeIndex, data.navItemsCount, data.groupIndexList);\n // Initialize our string to prevent updateAnnouncement from reading an initial load\n announcementTextRef.current = announcementText;\n }\n totalNavLength.current = data.navItemsCount;\n navGroupRef.current = data.groupIndexList;\n updateAnnouncement();\n });\n }, [subscribeForValues, updateAnnouncement, announcement]);\n\n useIsomorphicLayoutEffect(() => {\n updateAnnouncement();\n }, [activeIndex, updateAnnouncement]);\n\n return {\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: mergedContainerRef,\n role: 'region',\n ...props,\n }),\n { elementType: 'div' },\n ),\n\n activeIndex,\n circular,\n containerRef: mergedContainerRef,\n viewportRef,\n selectPageByElement,\n selectPageByDirection,\n selectPageByIndex,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n };\n}\n"],"names":["useCarousel_unstable","props","ref","align","circular","onActiveIndexChange","groupSize","draggable","whitespace","announcement","motion","dir","useFluent","activeIndex","carouselApi","containerRef","viewportRef","subscribeForValues","enableAutoplay","resetAutoplay","useEmblaCarousel","direction","loop","slidesToScroll","defaultActiveIndex","watchDrag","containScroll","onDragIndexChange","selectPageByElement","useEventCallback","event","element","jump","foundIndex","scrollToElement","type","index","selectPageByIndex","scrollToIndex","selectPageByDirection","nextPageIndex","scrollInDirection","mergedContainerRef","useMergedRefs","announcementTextRef","React","useRef","totalNavLength","navGroupRef","announce","useAnnounce","updateAnnouncement","current","announcementText","polite","useIsomorphicLayoutEffect","data","navItemsCount","groupIndexList","components","root","slot","always","getIntrinsicElementProps","role","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAwBgBA;;;eAAAA;;;;qCAxBgC;gCAOzC;iEACgB;kCAIU;AAY1B,SAASA,qBAAqBC,KAAoB,EAAEC,GAA8B;IACvF;IAEA,MAAM,EACJC,QAAQ,QAAQ,EAChBC,WAAW,KAAK,EAChBC,mBAAmB,EACnBC,YAAY,MAAM,EAClBC,YAAY,KAAK,EACjBC,aAAa,KAAK,EAClBC,YAAY,EACZC,SAAS,OAAO,EACjB,GAAGT;IAEJ,MAAM,EAAEU,GAAG,EAAE,GAAGC,IAAAA,uCAAAA;IAChB,MAAM,EAAEC,WAAW,EAAEC,WAAW,EAAEC,YAAY,EAAEC,WAAW,EAAEC,kBAAkB,EAAEC,cAAc,EAAEC,aAAa,EAAE,GAC9GC,IAAAA,kCAAAA,EAAiB;QACfjB;QACAkB,WAAWV;QACXW,MAAMlB;QACNmB,gBAAgBjB;QAChBkB,oBAAoBvB,MAAMuB,kBAAkB;QAC5CX,aAAaZ,MAAMY,WAAW;QAC9BY,WAAWlB;QACXmB,eAAelB,aAAa,QAAQ;QACpCE;QACAiB,mBAAmBtB;IACrB;IAEF,MAAMuB,sBAAm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;YAC9BJ,SAASI,kBAAkB;gBAAEC,QAAQ;YAAK;QAC5C;IACF;IAEAC,IAAAA,yCAAAA,EAA0B;QACxB,oDAAoD;QACpD,OAAOtC,mBAAmBuC,CAAAA;YACxB,IAAIT,eAAeK,OAAO,IAAI,KAAKI,KAAKC,aAAa,GAAG,KAAKhD,cAAc;gBACzE,MAAM4C,mBAAmB5C,aAAa+C,KAAK3C,WAAW,EAAE2C,KAAKC,aAAa,EAAED,KAAKE,cAAc;gBAC/F,mFAAmF;gBACnFd,oBAAoBQ,OAAO,GAAGC;YAChC;YACAN,eAAeK,OAAO,GAAGI,KAAKC,aAAa;YAC3CT,YAAYI,OAAO,GAAGI,KAAKE,cAAc;YACzCP;QACF;IACF,GAAG;QAAClC;QAAoBkC;QAAoB1C;KAAa;IAEzD8C,IAAAA,yCAAAA,EAA0B;QACxBJ;IACF,GAAG;QAACtC;QAAasC;KAAmB;IAEpC,OAAO;QACLQ,YAAY;YACVC,MAAM;QACR;QACAA,MAAMC,oBAAAA,CAAKC,MAAM,CACfC,IAAAA,wCAAAA,EAAyB,OAAO;YAC9B7D,KAAKwC;YACLsB,MAAM;YACN,GAAG/D,KAAK;QACV,IACA;YAAEgE,aAAa;QAAM;QAGvBpD;QACAT;QACAW,cAAc2B;QACd1B;QACAY;QACAW;QACAF;QACApB;QACAC;QACAC;IACF;AACF"}
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "useCarouselContextValues_unstable", {
|
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
13
|
function useCarouselContextValues_unstable(state) {
|
|
14
|
-
const { activeIndex, selectPageByElement, selectPageByDirection, selectPageByIndex, subscribeForValues, enableAutoplay, resetAutoplay, circular, containerRef } = state;
|
|
14
|
+
const { activeIndex, selectPageByElement, selectPageByDirection, selectPageByIndex, subscribeForValues, enableAutoplay, resetAutoplay, circular, containerRef, viewportRef } = state;
|
|
15
15
|
const carousel = _react.useMemo(()=>({
|
|
16
16
|
activeIndex,
|
|
17
17
|
selectPageByElement,
|
|
@@ -21,7 +21,8 @@ function useCarouselContextValues_unstable(state) {
|
|
|
21
21
|
enableAutoplay,
|
|
22
22
|
resetAutoplay,
|
|
23
23
|
circular,
|
|
24
|
-
containerRef
|
|
24
|
+
containerRef,
|
|
25
|
+
viewportRef
|
|
25
26
|
}), [
|
|
26
27
|
activeIndex,
|
|
27
28
|
selectPageByElement,
|
|
@@ -31,7 +32,8 @@ function useCarouselContextValues_unstable(state) {
|
|
|
31
32
|
enableAutoplay,
|
|
32
33
|
resetAutoplay,
|
|
33
34
|
circular,
|
|
34
|
-
containerRef
|
|
35
|
+
containerRef,
|
|
36
|
+
viewportRef
|
|
35
37
|
]);
|
|
36
38
|
return {
|
|
37
39
|
carousel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCarouselContextValues.ts"],"sourcesContent":["import * as React from 'react';\n\nimport type { CarouselContextValues } from '../CarouselContext.types';\nimport type { CarouselState } from './Carousel.types';\n\nexport function useCarouselContextValues_unstable(state: CarouselState): CarouselContextValues {\n const {\n activeIndex,\n selectPageByElement,\n selectPageByDirection,\n selectPageByIndex,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n circular,\n containerRef,\n } = state;\n\n const carousel = React.useMemo(\n () => ({\n activeIndex,\n selectPageByElement,\n selectPageByDirection,\n selectPageByIndex,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n circular,\n containerRef,\n }),\n [\n activeIndex,\n selectPageByElement,\n selectPageByDirection,\n selectPageByIndex,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n circular,\n containerRef,\n ],\n );\n\n return { carousel };\n}\n"],"names":["useCarouselContextValues_unstable","state","activeIndex","selectPageByElement","selectPageByDirection","selectPageByIndex","subscribeForValues","enableAutoplay","resetAutoplay","circular","containerRef","carousel","React","useMemo"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/Carousel/useCarouselContextValues.ts"],"sourcesContent":["import * as React from 'react';\n\nimport type { CarouselContextValues } from '../CarouselContext.types';\nimport type { CarouselState } from './Carousel.types';\n\nexport function useCarouselContextValues_unstable(state: CarouselState): CarouselContextValues {\n const {\n activeIndex,\n selectPageByElement,\n selectPageByDirection,\n selectPageByIndex,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n circular,\n containerRef,\n viewportRef,\n } = state;\n\n const carousel = React.useMemo(\n () => ({\n activeIndex,\n selectPageByElement,\n selectPageByDirection,\n selectPageByIndex,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n circular,\n containerRef,\n viewportRef,\n }),\n [\n activeIndex,\n selectPageByElement,\n selectPageByDirection,\n selectPageByIndex,\n subscribeForValues,\n enableAutoplay,\n resetAutoplay,\n circular,\n containerRef,\n viewportRef,\n ],\n );\n\n return { carousel };\n}\n"],"names":["useCarouselContextValues_unstable","state","activeIndex","selectPageByElement","selectPageByDirection","selectPageByIndex","subscribeForValues","enableAutoplay","resetAutoplay","circular","containerRef","viewportRef","carousel","React","useMemo"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAKgBA;;;eAAAA;;;;iEALO;AAKhB,SAASA,kCAAkCC,KAAoB;IACpE,MAAM,EACJC,WAAW,EACXC,mBAAmB,EACnBC,qBAAqB,EACrBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,EACdC,aAAa,EACbC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACZ,GAAGV;IAEJ,MAAMW,WAAWC,OAAMC,OAAO,CAC5B,IAAO,CAAA;YACLZ;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF,CAAA,GACA;QACET;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACD;IAGH,OAAO;QAAEC;IAAS;AACpB"}
|
|
@@ -24,22 +24,13 @@ const carouselClassNames = {
|
|
|
24
24
|
* Styles for the root slot
|
|
25
25
|
*/ const useStyles = /*#__PURE__*/ (0, _react.__styles)({
|
|
26
26
|
root: {
|
|
27
|
-
|
|
28
|
-
B68tc82: 0,
|
|
29
|
-
Bmxbyg5: 0,
|
|
30
|
-
Bpg54ce: "f1a3p1vp",
|
|
27
|
+
B68tc82: "f1p9o1ba",
|
|
31
28
|
Eiaeu8: "f1115ve7",
|
|
32
29
|
qhf8xq: "f10pi13n"
|
|
33
30
|
}
|
|
34
31
|
}, {
|
|
35
32
|
d: [
|
|
36
|
-
".
|
|
37
|
-
[
|
|
38
|
-
".f1a3p1vp{overflow:hidden;}",
|
|
39
|
-
{
|
|
40
|
-
p: -1
|
|
41
|
-
}
|
|
42
|
-
],
|
|
33
|
+
".f1p9o1ba{overflow-x:hidden;}",
|
|
43
34
|
".f1115ve7{overflow-anchor:none;}",
|
|
44
35
|
".f10pi13n{position:relative;}"
|
|
45
36
|
]
|
|
@@ -49,4 +40,4 @@ const useCarouselStyles_unstable = (state)=>{
|
|
|
49
40
|
const styles = useStyles();
|
|
50
41
|
state.root.className = (0, _react.mergeClasses)(carouselClassNames.root, styles.root, state.root.className);
|
|
51
42
|
return state;
|
|
52
|
-
};
|
|
43
|
+
};
|