@fluentui/react-carousel 0.0.0-nightly-20241008-0405.1
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 +129 -0
- package/LICENSE +15 -0
- package/README.md +33 -0
- package/dist/index.d.ts +625 -0
- package/lib/Carousel.js +1 -0
- package/lib/Carousel.js.map +1 -0
- package/lib/CarouselAutoplayButton.js +1 -0
- package/lib/CarouselAutoplayButton.js.map +1 -0
- package/lib/CarouselButton.js +1 -0
- package/lib/CarouselButton.js.map +1 -0
- package/lib/CarouselCard.js +1 -0
- package/lib/CarouselCard.js.map +1 -0
- package/lib/CarouselContext.js +2 -0
- package/lib/CarouselContext.js.map +1 -0
- package/lib/CarouselNav.js +1 -0
- package/lib/CarouselNav.js.map +1 -0
- package/lib/CarouselNavButton.js +1 -0
- package/lib/CarouselNavButton.js.map +1 -0
- package/lib/CarouselNavContainer.js +1 -0
- package/lib/CarouselNavContainer.js.map +1 -0
- package/lib/CarouselNavImageButton.js +1 -0
- package/lib/CarouselNavImageButton.js.map +1 -0
- package/lib/CarouselSlider.js +1 -0
- package/lib/CarouselSlider.js.map +1 -0
- package/lib/components/Carousel/Carousel.js +20 -0
- package/lib/components/Carousel/Carousel.js.map +1 -0
- package/lib/components/Carousel/Carousel.types.js +3 -0
- package/lib/components/Carousel/Carousel.types.js.map +1 -0
- package/lib/components/Carousel/index.js +5 -0
- package/lib/components/Carousel/index.js.map +1 -0
- package/lib/components/Carousel/renderCarousel.js +12 -0
- package/lib/components/Carousel/renderCarousel.js.map +1 -0
- package/lib/components/Carousel/useCarousel.js +117 -0
- package/lib/components/Carousel/useCarousel.js.map +1 -0
- package/lib/components/Carousel/useCarouselContextValues.js +28 -0
- package/lib/components/Carousel/useCarouselContextValues.js.map +1 -0
- package/lib/components/Carousel/useCarouselStyles.styles.js +33 -0
- package/lib/components/Carousel/useCarouselStyles.styles.js.map +1 -0
- package/lib/components/CarouselAutoplayButton/CarouselAutoplayButton.js +18 -0
- package/lib/components/CarouselAutoplayButton/CarouselAutoplayButton.js.map +1 -0
- package/lib/components/CarouselAutoplayButton/CarouselAutoplayButton.types.js +1 -0
- package/lib/components/CarouselAutoplayButton/CarouselAutoplayButton.types.js.map +1 -0
- package/lib/components/CarouselAutoplayButton/index.js +5 -0
- package/lib/components/CarouselAutoplayButton/index.js.map +1 -0
- package/lib/components/CarouselAutoplayButton/renderCarouselAutoplayButton.js +9 -0
- package/lib/components/CarouselAutoplayButton/renderCarouselAutoplayButton.js.map +1 -0
- package/lib/components/CarouselAutoplayButton/useCarouselAutoplayButton.js +64 -0
- package/lib/components/CarouselAutoplayButton/useCarouselAutoplayButton.js.map +1 -0
- package/lib/components/CarouselAutoplayButton/useCarouselAutoplayButtonStyles.styles.js +42 -0
- package/lib/components/CarouselAutoplayButton/useCarouselAutoplayButtonStyles.styles.js.map +1 -0
- package/lib/components/CarouselButton/CarouselButton.js +16 -0
- package/lib/components/CarouselButton/CarouselButton.js.map +1 -0
- package/lib/components/CarouselButton/CarouselButton.types.js +3 -0
- package/lib/components/CarouselButton/CarouselButton.types.js.map +1 -0
- package/lib/components/CarouselButton/index.js +5 -0
- package/lib/components/CarouselButton/index.js.map +1 -0
- package/lib/components/CarouselButton/renderCarouselButton.js +9 -0
- package/lib/components/CarouselButton/renderCarouselButton.js.map +1 -0
- package/lib/components/CarouselButton/useCarouselButton.js +87 -0
- package/lib/components/CarouselButton/useCarouselButton.js.map +1 -0
- package/lib/components/CarouselButton/useCarouselButtonStyles.styles.js +41 -0
- package/lib/components/CarouselButton/useCarouselButtonStyles.styles.js.map +1 -0
- package/lib/components/CarouselCard/CarouselCard.js +20 -0
- package/lib/components/CarouselCard/CarouselCard.js.map +1 -0
- package/lib/components/CarouselCard/CarouselCard.types.js +3 -0
- package/lib/components/CarouselCard/CarouselCard.types.js.map +1 -0
- package/lib/components/CarouselCard/index.js +5 -0
- package/lib/components/CarouselCard/index.js.map +1 -0
- package/lib/components/CarouselCard/renderCarouselCard.js +8 -0
- package/lib/components/CarouselCard/renderCarouselCard.js.map +1 -0
- package/lib/components/CarouselCard/useCarouselCard.js +91 -0
- package/lib/components/CarouselCard/useCarouselCard.js.map +1 -0
- package/lib/components/CarouselCard/useCarouselCardStyles.styles.js +45 -0
- package/lib/components/CarouselCard/useCarouselCardStyles.styles.js.map +1 -0
- package/lib/components/CarouselContext.js +23 -0
- package/lib/components/CarouselContext.js.map +1 -0
- package/lib/components/CarouselContext.types.js +1 -0
- package/lib/components/CarouselContext.types.js.map +1 -0
- package/lib/components/CarouselNav/CarouselNav.js +20 -0
- package/lib/components/CarouselNav/CarouselNav.js.map +1 -0
- package/lib/components/CarouselNav/CarouselNav.types.js +1 -0
- package/lib/components/CarouselNav/CarouselNav.types.js.map +1 -0
- package/lib/components/CarouselNav/CarouselNavContext.js +21 -0
- package/lib/components/CarouselNav/CarouselNavContext.js.map +1 -0
- package/lib/components/CarouselNav/CarouselNavIndexContext.js +8 -0
- package/lib/components/CarouselNav/CarouselNavIndexContext.js.map +1 -0
- package/lib/components/CarouselNav/index.js +5 -0
- package/lib/components/CarouselNav/index.js.map +1 -0
- package/lib/components/CarouselNav/renderCarouselNav.js +19 -0
- package/lib/components/CarouselNav/renderCarouselNav.js.map +1 -0
- package/lib/components/CarouselNav/useCarouselNav.js +49 -0
- package/lib/components/CarouselNav/useCarouselNav.js.map +1 -0
- package/lib/components/CarouselNav/useCarouselNavStyles.styles.js +63 -0
- package/lib/components/CarouselNav/useCarouselNavStyles.styles.js.map +1 -0
- package/lib/components/CarouselNavButton/CarouselNavButton.js +15 -0
- package/lib/components/CarouselNavButton/CarouselNavButton.js.map +1 -0
- package/lib/components/CarouselNavButton/CarouselNavButton.types.js +3 -0
- package/lib/components/CarouselNavButton/CarouselNavButton.types.js.map +1 -0
- package/lib/components/CarouselNavButton/index.js +5 -0
- package/lib/components/CarouselNavButton/index.js.map +1 -0
- package/lib/components/CarouselNavButton/renderCarouselNavButton.js +9 -0
- package/lib/components/CarouselNavButton/renderCarouselNavButton.js.map +1 -0
- package/lib/components/CarouselNavButton/useCarouselNavButton.js +73 -0
- package/lib/components/CarouselNavButton/useCarouselNavButton.js.map +1 -0
- package/lib/components/CarouselNavButton/useCarouselNavButtonStyles.styles.js +196 -0
- package/lib/components/CarouselNavButton/useCarouselNavButtonStyles.styles.js.map +1 -0
- package/lib/components/CarouselNavContainer/CarouselNavContainer.js +20 -0
- package/lib/components/CarouselNavContainer/CarouselNavContainer.js.map +1 -0
- package/lib/components/CarouselNavContainer/CarouselNavContainer.types.js +3 -0
- package/lib/components/CarouselNavContainer/CarouselNavContainer.types.js.map +1 -0
- package/lib/components/CarouselNavContainer/index.js +5 -0
- package/lib/components/CarouselNavContainer/index.js.map +1 -0
- package/lib/components/CarouselNavContainer/renderCarouselNavContainer.js +15 -0
- package/lib/components/CarouselNavContainer/renderCarouselNavContainer.js.map +1 -0
- package/lib/components/CarouselNavContainer/useCarouselNavContainer.js +51 -0
- package/lib/components/CarouselNavContainer/useCarouselNavContainer.js.map +1 -0
- package/lib/components/CarouselNavContainer/useCarouselNavContainerStyles.styles.js +104 -0
- package/lib/components/CarouselNavContainer/useCarouselNavContainerStyles.styles.js.map +1 -0
- package/lib/components/CarouselNavImageButton/CarouselNavImageButton.js +16 -0
- package/lib/components/CarouselNavImageButton/CarouselNavImageButton.js.map +1 -0
- package/lib/components/CarouselNavImageButton/CarouselNavImageButton.types.js +3 -0
- package/lib/components/CarouselNavImageButton/CarouselNavImageButton.types.js.map +1 -0
- package/lib/components/CarouselNavImageButton/index.js +5 -0
- package/lib/components/CarouselNavImageButton/index.js.map +1 -0
- package/lib/components/CarouselNavImageButton/renderCarouselNavImageButton.js +10 -0
- package/lib/components/CarouselNavImageButton/renderCarouselNavImageButton.js.map +1 -0
- package/lib/components/CarouselNavImageButton/useCarouselNavImageButton.js +76 -0
- package/lib/components/CarouselNavImageButton/useCarouselNavImageButton.js.map +1 -0
- package/lib/components/CarouselNavImageButton/useCarouselNavImageButtonStyles.styles.js +85 -0
- package/lib/components/CarouselNavImageButton/useCarouselNavImageButtonStyles.styles.js.map +1 -0
- package/lib/components/CarouselSlider/CarouselSlider.js +18 -0
- package/lib/components/CarouselSlider/CarouselSlider.js.map +1 -0
- package/lib/components/CarouselSlider/CarouselSlider.types.js +1 -0
- package/lib/components/CarouselSlider/CarouselSlider.types.js.map +1 -0
- package/lib/components/CarouselSlider/CarouselSliderContext.js +21 -0
- package/lib/components/CarouselSlider/CarouselSliderContext.js.map +1 -0
- package/lib/components/CarouselSlider/index.js +5 -0
- package/lib/components/CarouselSlider/index.js.map +1 -0
- package/lib/components/CarouselSlider/renderCarouselSlider.js +12 -0
- package/lib/components/CarouselSlider/renderCarouselSlider.js.map +1 -0
- package/lib/components/CarouselSlider/useCarouselSlider.js +36 -0
- package/lib/components/CarouselSlider/useCarouselSlider.js.map +1 -0
- package/lib/components/CarouselSlider/useCarouselSliderStyles.styles.js +26 -0
- package/lib/components/CarouselSlider/useCarouselSliderStyles.styles.js.map +1 -0
- package/lib/components/useEmblaCarousel.js +239 -0
- package/lib/components/useEmblaCarousel.js.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib-commonjs/Carousel.js +6 -0
- package/lib-commonjs/Carousel.js.map +1 -0
- package/lib-commonjs/CarouselAutoplayButton.js +6 -0
- package/lib-commonjs/CarouselAutoplayButton.js.map +1 -0
- package/lib-commonjs/CarouselButton.js +6 -0
- package/lib-commonjs/CarouselButton.js.map +1 -0
- package/lib-commonjs/CarouselCard.js +6 -0
- package/lib-commonjs/CarouselCard.js.map +1 -0
- package/lib-commonjs/CarouselContext.js +7 -0
- package/lib-commonjs/CarouselContext.js.map +1 -0
- package/lib-commonjs/CarouselNav.js +6 -0
- package/lib-commonjs/CarouselNav.js.map +1 -0
- package/lib-commonjs/CarouselNavButton.js +6 -0
- package/lib-commonjs/CarouselNavButton.js.map +1 -0
- package/lib-commonjs/CarouselNavContainer.js +6 -0
- package/lib-commonjs/CarouselNavContainer.js.map +1 -0
- package/lib-commonjs/CarouselNavImageButton.js +6 -0
- package/lib-commonjs/CarouselNavImageButton.js.map +1 -0
- package/lib-commonjs/CarouselSlider.js +6 -0
- package/lib-commonjs/CarouselSlider.js.map +1 -0
- package/lib-commonjs/components/Carousel/Carousel.js +26 -0
- package/lib-commonjs/components/Carousel/Carousel.js.map +1 -0
- package/lib-commonjs/components/Carousel/Carousel.types.js +6 -0
- package/lib-commonjs/components/Carousel/Carousel.types.js.map +1 -0
- package/lib-commonjs/components/Carousel/index.js +10 -0
- package/lib-commonjs/components/Carousel/index.js.map +1 -0
- package/lib-commonjs/components/Carousel/renderCarousel.js +20 -0
- package/lib-commonjs/components/Carousel/renderCarousel.js.map +1 -0
- package/lib-commonjs/components/Carousel/useCarousel.js +119 -0
- package/lib-commonjs/components/Carousel/useCarousel.js.map +1 -0
- package/lib-commonjs/components/Carousel/useCarouselContextValues.js +39 -0
- package/lib-commonjs/components/Carousel/useCarouselContextValues.js.map +1 -0
- package/lib-commonjs/components/Carousel/useCarouselStyles.styles.js +52 -0
- package/lib-commonjs/components/Carousel/useCarouselStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CarouselAutoplayButton/CarouselAutoplayButton.js +24 -0
- package/lib-commonjs/components/CarouselAutoplayButton/CarouselAutoplayButton.js.map +1 -0
- package/lib-commonjs/components/CarouselAutoplayButton/CarouselAutoplayButton.types.js +6 -0
- package/lib-commonjs/components/CarouselAutoplayButton/CarouselAutoplayButton.types.js.map +1 -0
- package/lib-commonjs/components/CarouselAutoplayButton/index.js +10 -0
- package/lib-commonjs/components/CarouselAutoplayButton/index.js.map +1 -0
- package/lib-commonjs/components/CarouselAutoplayButton/renderCarouselAutoplayButton.js +17 -0
- package/lib-commonjs/components/CarouselAutoplayButton/renderCarouselAutoplayButton.js.map +1 -0
- package/lib-commonjs/components/CarouselAutoplayButton/useCarouselAutoplayButton.js +67 -0
- package/lib-commonjs/components/CarouselAutoplayButton/useCarouselAutoplayButton.js.map +1 -0
- package/lib-commonjs/components/CarouselAutoplayButton/useCarouselAutoplayButtonStyles.styles.js +71 -0
- package/lib-commonjs/components/CarouselAutoplayButton/useCarouselAutoplayButtonStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CarouselButton/CarouselButton.js +24 -0
- package/lib-commonjs/components/CarouselButton/CarouselButton.js.map +1 -0
- package/lib-commonjs/components/CarouselButton/CarouselButton.types.js +6 -0
- package/lib-commonjs/components/CarouselButton/CarouselButton.types.js.map +1 -0
- package/lib-commonjs/components/CarouselButton/index.js +10 -0
- package/lib-commonjs/components/CarouselButton/index.js.map +1 -0
- package/lib-commonjs/components/CarouselButton/renderCarouselButton.js +17 -0
- package/lib-commonjs/components/CarouselButton/renderCarouselButton.js.map +1 -0
- package/lib-commonjs/components/CarouselButton/useCarouselButton.js +89 -0
- package/lib-commonjs/components/CarouselButton/useCarouselButton.js.map +1 -0
- package/lib-commonjs/components/CarouselButton/useCarouselButtonStyles.styles.js +60 -0
- package/lib-commonjs/components/CarouselButton/useCarouselButtonStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CarouselCard/CarouselCard.js +24 -0
- package/lib-commonjs/components/CarouselCard/CarouselCard.js.map +1 -0
- package/lib-commonjs/components/CarouselCard/CarouselCard.types.js +6 -0
- package/lib-commonjs/components/CarouselCard/CarouselCard.types.js.map +1 -0
- package/lib-commonjs/components/CarouselCard/index.js +10 -0
- package/lib-commonjs/components/CarouselCard/index.js.map +1 -0
- package/lib-commonjs/components/CarouselCard/renderCarouselCard.js +16 -0
- package/lib-commonjs/components/CarouselCard/renderCarouselCard.js.map +1 -0
- package/lib-commonjs/components/CarouselCard/useCarouselCard.js +94 -0
- package/lib-commonjs/components/CarouselCard/useCarouselCard.js.map +1 -0
- package/lib-commonjs/components/CarouselCard/useCarouselCardStyles.styles.js +67 -0
- package/lib-commonjs/components/CarouselCard/useCarouselCardStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CarouselContext.js +44 -0
- package/lib-commonjs/components/CarouselContext.js.map +1 -0
- package/lib-commonjs/components/CarouselContext.types.js +6 -0
- package/lib-commonjs/components/CarouselContext.types.js.map +1 -0
- package/lib-commonjs/components/CarouselNav/CarouselNav.js +26 -0
- package/lib-commonjs/components/CarouselNav/CarouselNav.js.map +1 -0
- package/lib-commonjs/components/CarouselNav/CarouselNav.types.js +6 -0
- package/lib-commonjs/components/CarouselNav/CarouselNav.types.js.map +1 -0
- package/lib-commonjs/components/CarouselNav/CarouselNavContext.js +46 -0
- package/lib-commonjs/components/CarouselNav/CarouselNavContext.js.map +1 -0
- package/lib-commonjs/components/CarouselNav/CarouselNavIndexContext.js +30 -0
- package/lib-commonjs/components/CarouselNav/CarouselNavIndexContext.js.map +1 -0
- package/lib-commonjs/components/CarouselNav/index.js +10 -0
- package/lib-commonjs/components/CarouselNav/index.js.map +1 -0
- package/lib-commonjs/components/CarouselNav/renderCarouselNav.js +27 -0
- package/lib-commonjs/components/CarouselNav/renderCarouselNav.js.map +1 -0
- package/lib-commonjs/components/CarouselNav/useCarouselNav.js +52 -0
- package/lib-commonjs/components/CarouselNav/useCarouselNav.js.map +1 -0
- package/lib-commonjs/components/CarouselNav/useCarouselNavStyles.styles.js +106 -0
- package/lib-commonjs/components/CarouselNav/useCarouselNavStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CarouselNavButton/CarouselNavButton.js +24 -0
- package/lib-commonjs/components/CarouselNavButton/CarouselNavButton.js.map +1 -0
- package/lib-commonjs/components/CarouselNavButton/CarouselNavButton.types.js +6 -0
- package/lib-commonjs/components/CarouselNavButton/CarouselNavButton.types.js.map +1 -0
- package/lib-commonjs/components/CarouselNavButton/index.js +10 -0
- package/lib-commonjs/components/CarouselNavButton/index.js.map +1 -0
- package/lib-commonjs/components/CarouselNavButton/renderCarouselNavButton.js +17 -0
- package/lib-commonjs/components/CarouselNavButton/renderCarouselNavButton.js.map +1 -0
- package/lib-commonjs/components/CarouselNavButton/useCarouselNavButton.js +76 -0
- package/lib-commonjs/components/CarouselNavButton/useCarouselNavButton.js.map +1 -0
- package/lib-commonjs/components/CarouselNavButton/useCarouselNavButtonStyles.styles.js +293 -0
- package/lib-commonjs/components/CarouselNavButton/useCarouselNavButtonStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CarouselNavContainer/CarouselNavContainer.js +29 -0
- package/lib-commonjs/components/CarouselNavContainer/CarouselNavContainer.js.map +1 -0
- package/lib-commonjs/components/CarouselNavContainer/CarouselNavContainer.types.js +6 -0
- package/lib-commonjs/components/CarouselNavContainer/CarouselNavContainer.types.js.map +1 -0
- package/lib-commonjs/components/CarouselNavContainer/index.js +10 -0
- package/lib-commonjs/components/CarouselNavContainer/index.js.map +1 -0
- package/lib-commonjs/components/CarouselNavContainer/renderCarouselNavContainer.js +23 -0
- package/lib-commonjs/components/CarouselNavContainer/renderCarouselNavContainer.js.map +1 -0
- package/lib-commonjs/components/CarouselNavContainer/useCarouselNavContainer.js +54 -0
- package/lib-commonjs/components/CarouselNavContainer/useCarouselNavContainer.js.map +1 -0
- package/lib-commonjs/components/CarouselNavContainer/useCarouselNavContainerStyles.styles.js +163 -0
- package/lib-commonjs/components/CarouselNavContainer/useCarouselNavContainerStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CarouselNavImageButton/CarouselNavImageButton.js +24 -0
- package/lib-commonjs/components/CarouselNavImageButton/CarouselNavImageButton.js.map +1 -0
- package/lib-commonjs/components/CarouselNavImageButton/CarouselNavImageButton.types.js +6 -0
- package/lib-commonjs/components/CarouselNavImageButton/CarouselNavImageButton.types.js.map +1 -0
- package/lib-commonjs/components/CarouselNavImageButton/index.js +10 -0
- package/lib-commonjs/components/CarouselNavImageButton/index.js.map +1 -0
- package/lib-commonjs/components/CarouselNavImageButton/renderCarouselNavImageButton.js +18 -0
- package/lib-commonjs/components/CarouselNavImageButton/renderCarouselNavImageButton.js.map +1 -0
- package/lib-commonjs/components/CarouselNavImageButton/useCarouselNavImageButton.js +79 -0
- package/lib-commonjs/components/CarouselNavImageButton/useCarouselNavImageButton.js.map +1 -0
- package/lib-commonjs/components/CarouselNavImageButton/useCarouselNavImageButtonStyles.styles.js +132 -0
- package/lib-commonjs/components/CarouselNavImageButton/useCarouselNavImageButtonStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CarouselSlider/CarouselSlider.js +26 -0
- package/lib-commonjs/components/CarouselSlider/CarouselSlider.js.map +1 -0
- package/lib-commonjs/components/CarouselSlider/CarouselSlider.types.js +4 -0
- package/lib-commonjs/components/CarouselSlider/CarouselSlider.types.js.map +1 -0
- package/lib-commonjs/components/CarouselSlider/CarouselSliderContext.js +46 -0
- package/lib-commonjs/components/CarouselSlider/CarouselSliderContext.js.map +1 -0
- package/lib-commonjs/components/CarouselSlider/index.js +10 -0
- package/lib-commonjs/components/CarouselSlider/index.js.map +1 -0
- package/lib-commonjs/components/CarouselSlider/renderCarouselSlider.js +20 -0
- package/lib-commonjs/components/CarouselSlider/renderCarouselSlider.js.map +1 -0
- package/lib-commonjs/components/CarouselSlider/useCarouselSlider.js +39 -0
- package/lib-commonjs/components/CarouselSlider/useCarouselSlider.js.map +1 -0
- package/lib-commonjs/components/CarouselSlider/useCarouselSliderStyles.styles.js +41 -0
- package/lib-commonjs/components/CarouselSlider/useCarouselSliderStyles.styles.js.map +1 -0
- package/lib-commonjs/components/useEmblaCarousel.js +262 -0
- package/lib-commonjs/components/useEmblaCarousel.js.map +1 -0
- package/lib-commonjs/index.js +166 -0
- package/lib-commonjs/index.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useButton_unstable } from '@fluentui/react-button';
|
|
2
|
+
import { ChevronLeftRegular, ChevronRightRegular } from '@fluentui/react-icons';
|
|
3
|
+
import { mergeCallbacks, useEventCallback, slot, useIsomorphicLayoutEffect, useMergedRefs } from '@fluentui/react-utilities';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useCarouselContext_unstable as useCarouselContext } from '../CarouselContext';
|
|
6
|
+
import { carouselButtonClassNames } from './useCarouselButtonStyles.styles';
|
|
7
|
+
import { useRef } from 'react';
|
|
8
|
+
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
9
|
+
/**
|
|
10
|
+
* Create the state required to render CarouselButton.
|
|
11
|
+
*
|
|
12
|
+
* The returned state can be modified with hooks such as useCarouselButtonStyles_unstable,
|
|
13
|
+
* before being passed to renderCarouselButton_unstable.
|
|
14
|
+
*
|
|
15
|
+
* @param props - props from this instance of CarouselButton
|
|
16
|
+
* @param ref - reference to root HTMLDivElement of CarouselButton
|
|
17
|
+
*/ export const useCarouselButton_unstable = (props, ref)=>{
|
|
18
|
+
const { navType = 'next' } = props;
|
|
19
|
+
// Locally tracks the total number of slides, will only update if this changes.
|
|
20
|
+
const [totalSlides, setTotalSlides] = React.useState(0);
|
|
21
|
+
const { dir } = useFluent();
|
|
22
|
+
const buttonRef = useRef();
|
|
23
|
+
const circular = useCarouselContext((ctx)=>ctx.circular);
|
|
24
|
+
const containerRef = useCarouselContext((ctx)=>ctx.containerRef);
|
|
25
|
+
const selectPageByDirection = useCarouselContext((ctx)=>ctx.selectPageByDirection);
|
|
26
|
+
const subscribeForValues = useCarouselContext((ctx)=>ctx.subscribeForValues);
|
|
27
|
+
const resetAutoplay = useCarouselContext((ctx)=>ctx.resetAutoplay);
|
|
28
|
+
const isTrailing = useCarouselContext((ctx)=>{
|
|
29
|
+
if (circular) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (navType === 'prev') {
|
|
33
|
+
return ctx.activeIndex === 0;
|
|
34
|
+
}
|
|
35
|
+
return ctx.activeIndex === totalSlides - 1;
|
|
36
|
+
});
|
|
37
|
+
const handleClick = (event)=>{
|
|
38
|
+
if (event.isDefaultPrevented()) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const nextIndex = selectPageByDirection(event, navType);
|
|
42
|
+
let _trailing = false;
|
|
43
|
+
if (navType === 'prev') {
|
|
44
|
+
_trailing = nextIndex === 0;
|
|
45
|
+
} else {
|
|
46
|
+
_trailing = nextIndex === totalSlides - 1;
|
|
47
|
+
}
|
|
48
|
+
if (!circular && _trailing && (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current)) {
|
|
49
|
+
// Focus non-disabled element
|
|
50
|
+
const buttonRefs = containerRef.current.querySelectorAll(`.${carouselButtonClassNames.root}`);
|
|
51
|
+
buttonRefs.forEach((_buttonRef)=>{
|
|
52
|
+
if (_buttonRef !== buttonRef.current) {
|
|
53
|
+
_buttonRef.focus();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
resetAutoplay();
|
|
58
|
+
};
|
|
59
|
+
useIsomorphicLayoutEffect(()=>{
|
|
60
|
+
return subscribeForValues((data)=>{
|
|
61
|
+
setTotalSlides(data.navItemsCount);
|
|
62
|
+
});
|
|
63
|
+
}, [
|
|
64
|
+
subscribeForValues
|
|
65
|
+
]);
|
|
66
|
+
const nextArrowIcon = dir === 'ltr' ? /*#__PURE__*/ React.createElement(ChevronRightRegular, null) : /*#__PURE__*/ React.createElement(ChevronLeftRegular, null);
|
|
67
|
+
const prevArrowIcon = dir === 'ltr' ? /*#__PURE__*/ React.createElement(ChevronLeftRegular, null) : /*#__PURE__*/ React.createElement(ChevronRightRegular, null);
|
|
68
|
+
return {
|
|
69
|
+
navType,
|
|
70
|
+
// We lean on react-button class to handle styling and icon enhancements
|
|
71
|
+
...useButton_unstable({
|
|
72
|
+
icon: slot.optional(props.icon, {
|
|
73
|
+
defaultProps: {
|
|
74
|
+
children: navType === 'next' ? nextArrowIcon : prevArrowIcon
|
|
75
|
+
},
|
|
76
|
+
renderByDefault: true,
|
|
77
|
+
elementType: 'span'
|
|
78
|
+
}),
|
|
79
|
+
disabled: isTrailing,
|
|
80
|
+
tabIndex: isTrailing ? -1 : 0,
|
|
81
|
+
'aria-disabled': isTrailing,
|
|
82
|
+
appearance: 'subtle',
|
|
83
|
+
...props,
|
|
84
|
+
onClick: useEventCallback(mergeCallbacks(handleClick, props.onClick))
|
|
85
|
+
}, useMergedRefs(ref, buttonRef))
|
|
86
|
+
};
|
|
87
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useCarouselButton.tsx"],"sourcesContent":["import { type ARIAButtonElement } from '@fluentui/react-aria';\nimport { useButton_unstable } from '@fluentui/react-button';\nimport { ChevronLeftRegular, ChevronRightRegular } from '@fluentui/react-icons';\nimport {\n mergeCallbacks,\n useEventCallback,\n slot,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useCarouselContext_unstable as useCarouselContext } from '../CarouselContext';\nimport type { CarouselButtonProps, CarouselButtonState } from './CarouselButton.types';\nimport type { CarouselUpdateData } from '../Carousel/Carousel.types';\nimport { carouselButtonClassNames } from './useCarouselButtonStyles.styles';\nimport { useRef } from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\n/**\n * Create the state required to render CarouselButton.\n *\n * The returned state can be modified with hooks such as useCarouselButtonStyles_unstable,\n * before being passed to renderCarouselButton_unstable.\n *\n * @param props - props from this instance of CarouselButton\n * @param ref - reference to root HTMLDivElement of CarouselButton\n */\nexport const useCarouselButton_unstable = (\n props: CarouselButtonProps,\n ref: React.Ref<ARIAButtonElement>,\n): CarouselButtonState => {\n const { navType = 'next' } = props;\n\n // Locally tracks the total number of slides, will only update if this changes.\n const [totalSlides, setTotalSlides] = React.useState(0);\n\n const { dir } = useFluent();\n const buttonRef = useRef<HTMLButtonElement>();\n const circular = useCarouselContext(ctx => ctx.circular);\n const containerRef = useCarouselContext(ctx => ctx.containerRef);\n const selectPageByDirection = useCarouselContext(ctx => ctx.selectPageByDirection);\n const subscribeForValues = useCarouselContext(ctx => ctx.subscribeForValues);\n const resetAutoplay = useCarouselContext(ctx => ctx.resetAutoplay);\n\n const isTrailing = useCarouselContext(ctx => {\n if (circular) {\n return false;\n }\n\n if (navType === 'prev') {\n return ctx.activeIndex === 0;\n }\n\n return ctx.activeIndex === totalSlides - 1;\n });\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement>) => {\n if (event.isDefaultPrevented()) {\n return;\n }\n\n const nextIndex = selectPageByDirection(event, navType);\n\n let _trailing = false;\n if (navType === 'prev') {\n _trailing = nextIndex === 0;\n } else {\n _trailing = nextIndex === totalSlides - 1;\n }\n\n if (!circular && _trailing && containerRef?.current) {\n // Focus non-disabled element\n const buttonRefs: NodeListOf<HTMLButtonElement> = containerRef.current.querySelectorAll(\n `.${carouselButtonClassNames.root}`,\n );\n buttonRefs.forEach(_buttonRef => {\n if (_buttonRef !== buttonRef.current) {\n _buttonRef.focus();\n }\n });\n }\n\n resetAutoplay();\n };\n\n useIsomorphicLayoutEffect(() => {\n return subscribeForValues((data: CarouselUpdateData) => {\n setTotalSlides(data.navItemsCount);\n });\n }, [subscribeForValues]);\n\n const nextArrowIcon = dir === 'ltr' ? <ChevronRightRegular /> : <ChevronLeftRegular />;\n const prevArrowIcon = dir === 'ltr' ? <ChevronLeftRegular /> : <ChevronRightRegular />;\n\n return {\n navType,\n // We lean on react-button class to handle styling and icon enhancements\n ...useButton_unstable(\n {\n icon: slot.optional(props.icon, {\n defaultProps: {\n children: navType === 'next' ? nextArrowIcon : prevArrowIcon,\n },\n renderByDefault: true,\n elementType: 'span',\n }),\n disabled: isTrailing,\n tabIndex: isTrailing ? -1 : 0,\n 'aria-disabled': isTrailing,\n appearance: 'subtle',\n ...props,\n onClick: useEventCallback(mergeCallbacks(handleClick, props.onClick)),\n },\n useMergedRefs(ref, buttonRef) as React.Ref<HTMLButtonElement>,\n ),\n };\n};\n"],"names":["useButton_unstable","ChevronLeftRegular","ChevronRightRegular","mergeCallbacks","useEventCallback","slot","useIsomorphicLayoutEffect","useMergedRefs","React","useCarouselContext_unstable","useCarouselContext","carouselButtonClassNames","useRef","useFluent_unstable","useFluent","useCarouselButton_unstable","props","ref","navType","totalSlides","setTotalSlides","useState","dir","buttonRef","circular","ctx","containerRef","selectPageByDirection","subscribeForValues","resetAutoplay","isTrailing","activeIndex","handleClick","event","isDefaultPrevented","nextIndex","_trailing","current","buttonRefs","querySelectorAll","root","forEach","_buttonRef","focus","data","navItemsCount","nextArrowIcon","prevArrowIcon","icon","optional","defaultProps","children","renderByDefault","elementType","disabled","tabIndex","appearance","onClick"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,wBAAwB;AAChF,SACEC,cAAc,EACdC,gBAAgB,EAChBC,IAAI,EACJC,yBAAyB,EACzBC,aAAa,QACR,4BAA4B;AACnC,YAAYC,WAAW,QAAQ;AAE/B,SAASC,+BAA+BC,kBAAkB,QAAQ,qBAAqB;AAGvF,SAASC,wBAAwB,QAAQ,mCAAmC;AAC5E,SAASC,MAAM,QAAQ,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF;;;;;;;;CAQC,GACD,OAAO,MAAMC,6BAA6B,CACxCC,OACAC;IAEA,MAAM,EAAEC,UAAU,MAAM,EAAE,GAAGF;IAE7B,+EAA+E;IAC/E,MAAM,CAACG,aAAaC,eAAe,GAAGZ,MAAMa,QAAQ,CAAC;IAErD,MAAM,EAAEC,GAAG,EAAE,GAAGR;IAChB,MAAMS,YAAYX;IAClB,MAAMY,WAAWd,mBAAmBe,CAAAA,MAAOA,IAAID,QAAQ;IACvD,MAAME,eAAehB,mBAAmBe,CAAAA,MAAOA,IAAIC,YAAY;IAC/D,MAAMC,wBAAwBjB,mBAAmBe,CAAAA,MAAOA,IAAIE,qBAAqB;IACjF,MAAMC,qBAAqBlB,mBAAmBe,CAAAA,MAAOA,IAAIG,kBAAkB;IAC3E,MAAMC,gBAAgBnB,mBAAmBe,CAAAA,MAAOA,IAAII,aAAa;IAEjE,MAAMC,aAAapB,mBAAmBe,CAAAA;QACpC,IAAID,UAAU;YACZ,OAAO;QACT;QAEA,IAAIN,YAAY,QAAQ;YACtB,OAAOO,IAAIM,WAAW,KAAK;QAC7B;QAEA,OAAON,IAAIM,WAAW,KAAKZ,cAAc;IAC3C;IAEA,MAAMa,cAAc,CAACC;QACnB,IAAIA,MAAMC,kBAAkB,IAAI;YAC9B;QACF;QAEA,MAAMC,YAAYR,sBAAsBM,OAAOf;QAE/C,IAAIkB,YAAY;QAChB,IAAIlB,YAAY,QAAQ;YACtBkB,YAAYD,cAAc;QAC5B,OAAO;YACLC,YAAYD,cAAchB,cAAc;QAC1C;QAEA,IAAI,CAACK,YAAYY,cAAaV,yBAAAA,mCAAAA,aAAcW,OAAO,GAAE;YACnD,6BAA6B;YAC7B,MAAMC,aAA4CZ,aAAaW,OAAO,CAACE,gBAAgB,CACrF,CAAC,CAAC,EAAE5B,yBAAyB6B,IAAI,CAAC,CAAC;YAErCF,WAAWG,OAAO,CAACC,CAAAA;gBACjB,IAAIA,eAAenB,UAAUc,OAAO,EAAE;oBACpCK,WAAWC,KAAK;gBAClB;YACF;QACF;QAEAd;IACF;IAEAvB,0BAA0B;QACxB,OAAOsB,mBAAmB,CAACgB;YACzBxB,eAAewB,KAAKC,aAAa;QACnC;IACF,GAAG;QAACjB;KAAmB;IAEvB,MAAMkB,gBAAgBxB,QAAQ,sBAAQ,oBAACpB,2CAAyB,oBAACD;IACjE,MAAM8C,gBAAgBzB,QAAQ,sBAAQ,oBAACrB,0CAAwB,oBAACC;IAEhE,OAAO;QACLgB;QACA,wEAAwE;QACxE,GAAGlB,mBACD;YACEgD,MAAM3C,KAAK4C,QAAQ,CAACjC,MAAMgC,IAAI,EAAE;gBAC9BE,cAAc;oBACZC,UAAUjC,YAAY,SAAS4B,gBAAgBC;gBACjD;gBACAK,iBAAiB;gBACjBC,aAAa;YACf;YACAC,UAAUxB;YACVyB,UAAUzB,aAAa,CAAC,IAAI;YAC5B,iBAAiBA;YACjB0B,YAAY;YACZ,GAAGxC,KAAK;YACRyC,SAASrD,iBAAiBD,eAAe6B,aAAahB,MAAMyC,OAAO;QACrE,GACAlD,cAAcU,KAAKM,WACpB;IACH;AACF,EAAE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __styles, mergeClasses } from '@griffel/react';
|
|
2
|
+
import { useButtonStyles_unstable } from '@fluentui/react-button';
|
|
3
|
+
import { tokens } from '@fluentui/react-theme';
|
|
4
|
+
export const carouselButtonClassNames = {
|
|
5
|
+
root: 'fui-CarouselButton',
|
|
6
|
+
icon: 'fui-CarouselButton__icon'
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Styles for the root slot
|
|
10
|
+
*/
|
|
11
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
12
|
+
root: {
|
|
13
|
+
B6of3ja: "fgr6219",
|
|
14
|
+
jrapky: "f10jk5vf",
|
|
15
|
+
sj55zd: "fkfq4zb",
|
|
16
|
+
De3pzq: "fkfdr9r",
|
|
17
|
+
Bkecrkj: "fc5wo7j",
|
|
18
|
+
eoavqd: "f8491dx"
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
d: [".fgr6219{margin-top:auto;}", ".f10jk5vf{margin-bottom:auto;}", ".fkfq4zb{color:var(--colorNeutralForeground2);}", ".fkfdr9r{background-color:var(--colorNeutralBackgroundAlpha);}", ".fc5wo7j{pointer-events:all;}"],
|
|
22
|
+
h: [".f8491dx:hover{cursor:pointer;}"]
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Apply styling to the CarouselButton slots based on the state
|
|
26
|
+
*/
|
|
27
|
+
export const useCarouselButtonStyles_unstable = state => {
|
|
28
|
+
'use no memo';
|
|
29
|
+
|
|
30
|
+
const styles = useStyles();
|
|
31
|
+
state = {
|
|
32
|
+
...state,
|
|
33
|
+
...useButtonStyles_unstable(state)
|
|
34
|
+
};
|
|
35
|
+
state.root.className = mergeClasses(carouselButtonClassNames.root, styles.root, state.root.className);
|
|
36
|
+
if (state.icon) {
|
|
37
|
+
state.icon.className = mergeClasses(carouselButtonClassNames.icon, state.icon.className);
|
|
38
|
+
}
|
|
39
|
+
return state;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=useCarouselButtonStyles.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__styles","mergeClasses","useButtonStyles_unstable","tokens","carouselButtonClassNames","root","icon","useStyles","B6of3ja","jrapky","sj55zd","De3pzq","Bkecrkj","eoavqd","d","h","useCarouselButtonStyles_unstable","state","styles","className"],"sources":["useCarouselButtonStyles.styles.js"],"sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nimport { useButtonStyles_unstable } from '@fluentui/react-button';\nimport { tokens } from '@fluentui/react-theme';\nexport const carouselButtonClassNames = {\n root: 'fui-CarouselButton',\n icon: 'fui-CarouselButton__icon'\n};\n/**\n * Styles for the root slot\n */ const useStyles = makeStyles({\n root: {\n marginTop: 'auto',\n marginBottom: 'auto',\n color: tokens.colorNeutralForeground2,\n backgroundColor: tokens.colorNeutralBackgroundAlpha,\n pointerEvents: 'all',\n ':hover': {\n cursor: 'pointer'\n }\n }\n});\n/**\n * Apply styling to the CarouselButton slots based on the state\n */ export const useCarouselButtonStyles_unstable = (state)=>{\n 'use no memo';\n const styles = useStyles();\n state = {\n ...state,\n ...useButtonStyles_unstable(state)\n };\n state.root.className = mergeClasses(carouselButtonClassNames.root, styles.root, state.root.className);\n if (state.icon) {\n state.icon.className = mergeClasses(carouselButtonClassNames.icon, state.icon.className);\n }\n return state;\n};\n"],"mappings":"AAAA,SAAAA,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,SAASC,wBAAwB,QAAQ,wBAAwB;AACjE,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,OAAO,MAAMC,wBAAwB,GAAG;EACpCC,IAAI,EAAE,oBAAoB;EAC1BC,IAAI,EAAE;AACV,CAAC;AACD;AACA;AACA;AAAI,MAAMC,SAAS,gBAAGP,QAAA;EAAAK,IAAA;IAAAG,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAC,CAAA;EAAAC,CAAA;AAAA,CAWrB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,gCAAgC,GAAIC,KAAK,IAAG;EACzD,aAAa;;EACb,MAAMC,MAAM,GAAGX,SAAS,CAAC,CAAC;EAC1BU,KAAK,GAAG;IACJ,GAAGA,KAAK;IACR,GAAGf,wBAAwB,CAACe,KAAK;EACrC,CAAC;EACDA,KAAK,CAACZ,IAAI,CAACc,SAAS,GAAGlB,YAAY,CAACG,wBAAwB,CAACC,IAAI,EAAEa,MAAM,CAACb,IAAI,EAAEY,KAAK,CAACZ,IAAI,CAACc,SAAS,CAAC;EACrG,IAAIF,KAAK,CAACX,IAAI,EAAE;IACZW,KAAK,CAACX,IAAI,CAACa,SAAS,GAAGlB,YAAY,CAACG,wBAAwB,CAACE,IAAI,EAAEW,KAAK,CAACX,IAAI,CAACa,SAAS,CAAC;EAC5F;EACA,OAAOF,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useCarouselCard_unstable } from './useCarouselCard';
|
|
3
|
+
import { renderCarouselCard_unstable } from './renderCarouselCard';
|
|
4
|
+
import { useCarouselCardStyles_unstable } from './useCarouselCardStyles.styles';
|
|
5
|
+
/**
|
|
6
|
+
* The defining wrapper of a carousel's indexed content, they will take up the full
|
|
7
|
+
* viewport of CarouselSlider or div wrapper,
|
|
8
|
+
* users may place multiple items within this Card if desired, with consideration of viewport width.
|
|
9
|
+
*
|
|
10
|
+
* Clickable actions within the content area are available via mouse and tab as expected,
|
|
11
|
+
* non-active card content will be set to inert until moved to active card.
|
|
12
|
+
*/ export const CarouselCard = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
13
|
+
const state = useCarouselCard_unstable(props, ref);
|
|
14
|
+
useCarouselCardStyles_unstable(state);
|
|
15
|
+
// TODO update types in packages/react-components/react-shared-contexts/src/CustomStyleHooksContext/CustomStyleHooksContext.ts
|
|
16
|
+
// https://github.com/microsoft/fluentui/blob/master/rfcs/react-components/convergence/custom-styling.md
|
|
17
|
+
// useCustomStyleHook_unstable('useCarouselCardStyles_unstable')(state);
|
|
18
|
+
return renderCarouselCard_unstable(state);
|
|
19
|
+
});
|
|
20
|
+
CarouselCard.displayName = 'CarouselCard';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CarouselCard.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCarouselCard_unstable } from './useCarouselCard';\nimport { renderCarouselCard_unstable } from './renderCarouselCard';\nimport { useCarouselCardStyles_unstable } from './useCarouselCardStyles.styles';\nimport type { CarouselCardProps } from './CarouselCard.types';\n\n/**\n * The defining wrapper of a carousel's indexed content, they will take up the full\n * viewport of CarouselSlider or div wrapper,\n * users may place multiple items within this Card if desired, with consideration of viewport width.\n *\n * Clickable actions within the content area are available via mouse and tab as expected,\n * non-active card content will be set to inert until moved to active card.\n */\nexport const CarouselCard: ForwardRefComponent<CarouselCardProps> = React.forwardRef((props, ref) => {\n const state = useCarouselCard_unstable(props, ref);\n\n useCarouselCardStyles_unstable(state);\n // TODO update types in packages/react-components/react-shared-contexts/src/CustomStyleHooksContext/CustomStyleHooksContext.ts\n // https://github.com/microsoft/fluentui/blob/master/rfcs/react-components/convergence/custom-styling.md\n // useCustomStyleHook_unstable('useCarouselCardStyles_unstable')(state);\n return renderCarouselCard_unstable(state);\n});\n\nCarouselCard.displayName = 'CarouselCard';\n"],"names":["React","useCarouselCard_unstable","renderCarouselCard_unstable","useCarouselCardStyles_unstable","CarouselCard","forwardRef","props","ref","state","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,2BAA2B,QAAQ,uBAAuB;AACnE,SAASC,8BAA8B,QAAQ,iCAAiC;AAGhF;;;;;;;CAOC,GACD,OAAO,MAAMC,6BAAuDJ,MAAMK,UAAU,CAAC,CAACC,OAAOC;IAC3F,MAAMC,QAAQP,yBAAyBK,OAAOC;IAE9CJ,+BAA+BK;IAC/B,8HAA8H;IAC9H,wGAAwG;IACxG,wEAAwE;IACxE,OAAON,4BAA4BM;AACrC,GAAG;AAEHJ,aAAaK,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CarouselCard.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type CarouselCardSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * CarouselCard Props\n */\nexport type CarouselCardProps = ComponentProps<CarouselCardSlots> & {\n /**\n * Sets the card styling to be responsive based on content.\n */\n autoSize?: boolean;\n};\n\n/**\n * State used in rendering CarouselCard\n */\nexport type CarouselCardState = ComponentState<CarouselCardSlots> & Pick<CarouselCardProps, 'autoSize'>;\n"],"names":[],"rangeMappings":";;","mappings":"AAgBA;;CAEC,GACD,WAAwG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './CarouselCard';\nexport * from './CarouselCard.types';\nexport * from './renderCarouselCard';\nexport * from './useCarouselCard';\nexport * from './useCarouselCardStyles.styles';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,iBAAiB;AAC/B,cAAc,uBAAuB;AACrC,cAAc,uBAAuB;AACrC,cAAc,oBAAoB;AAClC,cAAc,iCAAiC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
+
import { assertSlots } from '@fluentui/react-utilities';
|
|
3
|
+
/**
|
|
4
|
+
* Render the final JSX of CarouselCard
|
|
5
|
+
*/ export const renderCarouselCard_unstable = (state)=>{
|
|
6
|
+
assertSlots(state);
|
|
7
|
+
return /*#__PURE__*/ _jsx(state.root, {});
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renderCarouselCard.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { CarouselCardState, CarouselCardSlots } from './CarouselCard.types';\n\n/**\n * Render the final JSX of CarouselCard\n */\nexport const renderCarouselCard_unstable = (state: CarouselCardState) => {\n assertSlots<CarouselCardSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderCarouselCard_unstable","state","root"],"rangeMappings":";;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD;;CAEC,GACD,OAAO,MAAMC,8BAA8B,CAACC;IAC1CF,YAA+BE;IAE/B,qBAAO,KAACA,MAAMC,IAAI;AACpB,EAAE"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useFocusableGroup } from '@fluentui/react-tabster';
|
|
2
|
+
import { getIntrinsicElementProps, isHTMLElement, mergeCallbacks, slot, useMergedRefs, useId } from '@fluentui/react-utilities';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useCarouselContext_unstable as useCarouselContext } from '../CarouselContext';
|
|
5
|
+
import { EMBLA_VISIBILITY_EVENT } from '../useEmblaCarousel';
|
|
6
|
+
import { carouselCardClassNames } from './useCarouselCardStyles.styles';
|
|
7
|
+
import { useCarouselSliderContext } from '../CarouselSlider/CarouselSliderContext';
|
|
8
|
+
/**
|
|
9
|
+
* Create the state required to render CarouselCard.
|
|
10
|
+
*
|
|
11
|
+
* The returned state can be modified with hooks such as useCarouselCardStyles_unstable,
|
|
12
|
+
* before being passed to renderCarouselCard_unstable.
|
|
13
|
+
*
|
|
14
|
+
* @param props - props from this instance of CarouselCard
|
|
15
|
+
* @param ref - reference to root HTMLDivElement of CarouselCard
|
|
16
|
+
*/ export const useCarouselCard_unstable = (props, ref)=>{
|
|
17
|
+
const { autoSize } = props;
|
|
18
|
+
const elementRef = React.useRef(null);
|
|
19
|
+
const isMouseEvent = React.useRef(false);
|
|
20
|
+
const selectPageByElement = useCarouselContext((ctx)=>ctx.selectPageByElement);
|
|
21
|
+
const { cardFocus } = useCarouselSliderContext();
|
|
22
|
+
const focusAttr = useFocusableGroup({
|
|
23
|
+
tabBehavior: 'limited'
|
|
24
|
+
});
|
|
25
|
+
const focusAttrProps = cardFocus ? {
|
|
26
|
+
...focusAttr,
|
|
27
|
+
tabIndex: 0
|
|
28
|
+
} : {};
|
|
29
|
+
// We attach a unique card id if user does not provide
|
|
30
|
+
const id = useId(carouselCardClassNames.root, props.id);
|
|
31
|
+
React.useEffect(()=>{
|
|
32
|
+
const element = elementRef.current;
|
|
33
|
+
if (element) {
|
|
34
|
+
const listener = (_e)=>{
|
|
35
|
+
const event = _e;
|
|
36
|
+
// When there is no tab index present, only current cards should be visible to accessibility
|
|
37
|
+
if (!cardFocus) {
|
|
38
|
+
const hidden = !event.detail.isVisible;
|
|
39
|
+
element.ariaHidden = hidden.toString();
|
|
40
|
+
element.inert = hidden;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
element.addEventListener(EMBLA_VISIBILITY_EVENT, listener);
|
|
44
|
+
return ()=>{
|
|
45
|
+
element.removeEventListener(EMBLA_VISIBILITY_EVENT, listener);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}, [
|
|
49
|
+
cardFocus
|
|
50
|
+
]);
|
|
51
|
+
const handleFocusCapture = React.useCallback((e)=>{
|
|
52
|
+
if (!e.defaultPrevented && isHTMLElement(e.currentTarget) && !isMouseEvent.current) {
|
|
53
|
+
selectPageByElement(e, e.currentTarget, true);
|
|
54
|
+
}
|
|
55
|
+
}, [
|
|
56
|
+
selectPageByElement
|
|
57
|
+
]);
|
|
58
|
+
const handleMouseDown = (e)=>{
|
|
59
|
+
if (!e.defaultPrevented) {
|
|
60
|
+
isMouseEvent.current = true;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const handleMouseUp = (e)=>{
|
|
64
|
+
if (!e.defaultPrevented) {
|
|
65
|
+
isMouseEvent.current = false;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const onFocusCapture = mergeCallbacks(props.onFocusCapture, handleFocusCapture);
|
|
69
|
+
const onMouseUp = mergeCallbacks(props.onMouseUp, handleMouseUp);
|
|
70
|
+
const onMouseDown = mergeCallbacks(props.onMouseDown, handleMouseDown);
|
|
71
|
+
const state = {
|
|
72
|
+
autoSize,
|
|
73
|
+
components: {
|
|
74
|
+
root: 'div'
|
|
75
|
+
},
|
|
76
|
+
root: slot.always(getIntrinsicElementProps('div', {
|
|
77
|
+
ref: useMergedRefs(elementRef, ref),
|
|
78
|
+
role: 'tabpanel',
|
|
79
|
+
tabIndex: cardFocus ? 0 : undefined,
|
|
80
|
+
...props,
|
|
81
|
+
id,
|
|
82
|
+
onFocusCapture,
|
|
83
|
+
onMouseDown,
|
|
84
|
+
onMouseUp,
|
|
85
|
+
...focusAttrProps
|
|
86
|
+
}), {
|
|
87
|
+
elementType: 'div'
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
return state;
|
|
91
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useCarouselCard.ts"],"sourcesContent":["import { useFocusableGroup } from '@fluentui/react-tabster';\nimport {\n getIntrinsicElementProps,\n isHTMLElement,\n mergeCallbacks,\n slot,\n useMergedRefs,\n useId,\n} from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useCarouselContext_unstable as useCarouselContext } from '../CarouselContext';\nimport type { CarouselVisibilityChangeEvent } from '../Carousel/Carousel.types';\nimport { EMBLA_VISIBILITY_EVENT } from '../useEmblaCarousel';\nimport type { CarouselCardProps, CarouselCardState } from './CarouselCard.types';\nimport { carouselCardClassNames } from './useCarouselCardStyles.styles';\nimport { useCarouselSliderContext } from '../CarouselSlider/CarouselSliderContext';\n\n/**\n * Create the state required to render CarouselCard.\n *\n * The returned state can be modified with hooks such as useCarouselCardStyles_unstable,\n * before being passed to renderCarouselCard_unstable.\n *\n * @param props - props from this instance of CarouselCard\n * @param ref - reference to root HTMLDivElement of CarouselCard\n */\nexport const useCarouselCard_unstable = (\n props: CarouselCardProps,\n ref: React.Ref<HTMLDivElement>,\n): CarouselCardState => {\n const { autoSize } = props;\n const elementRef = React.useRef<HTMLDivElement>(null);\n const isMouseEvent = React.useRef<boolean>(false);\n const selectPageByElement = useCarouselContext(ctx => ctx.selectPageByElement);\n const { cardFocus } = useCarouselSliderContext();\n\n const focusAttr = useFocusableGroup({\n tabBehavior: 'limited',\n });\n const focusAttrProps = cardFocus ? { ...focusAttr, tabIndex: 0 } : {};\n\n // We attach a unique card id if user does not provide\n const id = useId(carouselCardClassNames.root, props.id);\n\n React.useEffect(() => {\n const element = elementRef.current;\n\n if (element) {\n const listener = (_e: Event) => {\n const event = _e as CarouselVisibilityChangeEvent;\n // When there is no tab index present, only current cards should be visible to accessibility\n if (!cardFocus) {\n const hidden = !event.detail.isVisible;\n element.ariaHidden = hidden.toString();\n element.inert = hidden;\n }\n };\n\n element.addEventListener(EMBLA_VISIBILITY_EVENT, listener);\n\n return () => {\n element.removeEventListener(EMBLA_VISIBILITY_EVENT, listener);\n };\n }\n }, [cardFocus]);\n\n const handleFocusCapture = React.useCallback(\n (e: React.FocusEvent) => {\n if (!e.defaultPrevented && isHTMLElement(e.currentTarget) && !isMouseEvent.current) {\n selectPageByElement(e, e.currentTarget, true);\n }\n },\n [selectPageByElement],\n );\n\n const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {\n if (!e.defaultPrevented) {\n isMouseEvent.current = true;\n }\n };\n const handleMouseUp = (e: React.MouseEvent<HTMLDivElement>) => {\n if (!e.defaultPrevented) {\n isMouseEvent.current = false;\n }\n };\n\n const onFocusCapture = mergeCallbacks(props.onFocusCapture, handleFocusCapture);\n const onMouseUp = mergeCallbacks(props.onMouseUp, handleMouseUp);\n const onMouseDown = mergeCallbacks(props.onMouseDown, handleMouseDown);\n const state: CarouselCardState = {\n autoSize,\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: useMergedRefs(elementRef, ref),\n role: 'tabpanel',\n tabIndex: cardFocus ? 0 : undefined,\n ...props,\n id,\n onFocusCapture,\n onMouseDown,\n onMouseUp,\n ...focusAttrProps,\n }),\n { elementType: 'div' },\n ),\n };\n\n return state;\n};\n"],"names":["useFocusableGroup","getIntrinsicElementProps","isHTMLElement","mergeCallbacks","slot","useMergedRefs","useId","React","useCarouselContext_unstable","useCarouselContext","EMBLA_VISIBILITY_EVENT","carouselCardClassNames","useCarouselSliderContext","useCarouselCard_unstable","props","ref","autoSize","elementRef","useRef","isMouseEvent","selectPageByElement","ctx","cardFocus","focusAttr","tabBehavior","focusAttrProps","tabIndex","id","root","useEffect","element","current","listener","_e","event","hidden","detail","isVisible","ariaHidden","toString","inert","addEventListener","removeEventListener","handleFocusCapture","useCallback","e","defaultPrevented","currentTarget","handleMouseDown","handleMouseUp","onFocusCapture","onMouseUp","onMouseDown","state","components","always","role","undefined","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,iBAAiB,QAAQ,0BAA0B;AAC5D,SACEC,wBAAwB,EACxBC,aAAa,EACbC,cAAc,EACdC,IAAI,EACJC,aAAa,EACbC,KAAK,QACA,4BAA4B;AACnC,YAAYC,WAAW,QAAQ;AAE/B,SAASC,+BAA+BC,kBAAkB,QAAQ,qBAAqB;AAEvF,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,sBAAsB,QAAQ,iCAAiC;AACxE,SAASC,wBAAwB,QAAQ,0CAA0C;AAEnF;;;;;;;;CAQC,GACD,OAAO,MAAMC,2BAA2B,CACtCC,OACAC;IAEA,MAAM,EAAEC,QAAQ,EAAE,GAAGF;IACrB,MAAMG,aAAaV,MAAMW,MAAM,CAAiB;IAChD,MAAMC,eAAeZ,MAAMW,MAAM,CAAU;IAC3C,MAAME,sBAAsBX,mBAAmBY,CAAAA,MAAOA,IAAID,mBAAmB;IAC7E,MAAM,EAAEE,SAAS,EAAE,GAAGV;IAEtB,MAAMW,YAAYvB,kBAAkB;QAClCwB,aAAa;IACf;IACA,MAAMC,iBAAiBH,YAAY;QAAE,GAAGC,SAAS;QAAEG,UAAU;IAAE,IAAI,CAAC;IAEpE,sDAAsD;IACtD,MAAMC,KAAKrB,MAAMK,uBAAuBiB,IAAI,EAAEd,MAAMa,EAAE;IAEtDpB,MAAMsB,SAAS,CAAC;QACd,MAAMC,UAAUb,WAAWc,OAAO;QAElC,IAAID,SAAS;YACX,MAAME,WAAW,CAACC;gBAChB,MAAMC,QAAQD;gBACd,4FAA4F;gBAC5F,IAAI,CAACX,WAAW;oBACd,MAAMa,SAAS,CAACD,MAAME,MAAM,CAACC,SAAS;oBACtCP,QAAQQ,UAAU,GAAGH,OAAOI,QAAQ;oBACpCT,QAAQU,KAAK,GAAGL;gBAClB;YACF;YAEAL,QAAQW,gBAAgB,CAAC/B,wBAAwBsB;YAEjD,OAAO;gBACLF,QAAQY,mBAAmB,CAAChC,wBAAwBsB;YACtD;QACF;IACF,GAAG;QAACV;KAAU;IAEd,MAAMqB,qBAAqBpC,MAAMqC,WAAW,CAC1C,CAACC;QACC,IAAI,CAACA,EAAEC,gBAAgB,IAAI5C,cAAc2C,EAAEE,aAAa,KAAK,CAAC5B,aAAaY,OAAO,EAAE;YAClFX,oBAAoByB,GAAGA,EAAEE,aAAa,EAAE;QAC1C;IACF,GACA;QAAC3B;KAAoB;IAGvB,MAAM4B,kBAAkB,CAACH;QACvB,IAAI,CAACA,EAAEC,gBAAgB,EAAE;YACvB3B,aAAaY,OAAO,GAAG;QACzB;IACF;IACA,MAAMkB,gBAAgB,CAACJ;QACrB,IAAI,CAACA,EAAEC,gBAAgB,EAAE;YACvB3B,aAAaY,OAAO,GAAG;QACzB;IACF;IAEA,MAAMmB,iBAAiB/C,eAAeW,MAAMoC,cAAc,EAAEP;IAC5D,MAAMQ,YAAYhD,eAAeW,MAAMqC,SAAS,EAAEF;IAClD,MAAMG,cAAcjD,eAAeW,MAAMsC,WAAW,EAAEJ;IACtD,MAAMK,QAA2B;QAC/BrC;QACAsC,YAAY;YACV1B,MAAM;QACR;QACAA,MAAMxB,KAAKmD,MAAM,CACftD,yBAAyB,OAAO;YAC9Bc,KAAKV,cAAcY,YAAYF;YAC/ByC,MAAM;YACN9B,UAAUJ,YAAY,IAAImC;YAC1B,GAAG3C,KAAK;YACRa;YACAuB;YACAE;YACAD;YACA,GAAG1B,cAAc;QACnB,IACA;YAAEiC,aAAa;QAAM;IAEzB;IAEA,OAAOL;AACT,EAAE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __styles, mergeClasses } from '@griffel/react';
|
|
2
|
+
export const carouselCardClassNames = {
|
|
3
|
+
root: 'fui-CarouselCard'
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Styles for the root slot
|
|
7
|
+
*/
|
|
8
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
9
|
+
root: {
|
|
10
|
+
xawz: 0,
|
|
11
|
+
Bh6795r: 0,
|
|
12
|
+
Bnnss6s: 0,
|
|
13
|
+
fkmc3a: "fg68ejw",
|
|
14
|
+
B2u0y6b: "f6dzj5z"
|
|
15
|
+
},
|
|
16
|
+
autoSize: {
|
|
17
|
+
xawz: 0,
|
|
18
|
+
Bh6795r: 0,
|
|
19
|
+
Bnnss6s: 0,
|
|
20
|
+
fkmc3a: "fd9q35j",
|
|
21
|
+
Bf4jedk: "fy77jfu",
|
|
22
|
+
a9b677: "f14z66ap",
|
|
23
|
+
B2u0y6b: "f6dzj5z"
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
d: [[".fg68ejw{flex:0 0 100%;}", {
|
|
27
|
+
p: -1
|
|
28
|
+
}], ".f6dzj5z{max-width:100%;}", [".fd9q35j{flex:0 0 auto;}", {
|
|
29
|
+
p: -1
|
|
30
|
+
}], ".fy77jfu{min-width:0;}", ".f14z66ap{width:auto;}"]
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Apply styling to the CarouselCard slots based on the state
|
|
34
|
+
*/
|
|
35
|
+
export const useCarouselCardStyles_unstable = state => {
|
|
36
|
+
'use no memo';
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
autoSize
|
|
40
|
+
} = state;
|
|
41
|
+
const styles = useStyles();
|
|
42
|
+
state.root.className = mergeClasses(carouselCardClassNames.root, styles.root, autoSize && styles.autoSize, state.root.className);
|
|
43
|
+
return state;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=useCarouselCardStyles.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__styles","mergeClasses","carouselCardClassNames","root","useStyles","xawz","Bh6795r","Bnnss6s","fkmc3a","B2u0y6b","autoSize","Bf4jedk","a9b677","d","p","useCarouselCardStyles_unstable","state","styles","className"],"sources":["useCarouselCardStyles.styles.js"],"sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nexport const carouselCardClassNames = {\n root: 'fui-CarouselCard'\n};\n/**\n * Styles for the root slot\n */ const useStyles = makeStyles({\n root: {\n flex: '0 0 100%',\n maxWidth: '100%'\n },\n autoSize: {\n flex: '0 0 auto' /* Adapt slide size to its content */ ,\n minWidth: 0,\n width: 'auto',\n maxWidth: '100%'\n }\n});\n/**\n * Apply styling to the CarouselCard slots based on the state\n */ export const useCarouselCardStyles_unstable = (state)=>{\n 'use no memo';\n const { autoSize } = state;\n const styles = useStyles();\n state.root.className = mergeClasses(carouselCardClassNames.root, styles.root, autoSize && styles.autoSize, state.root.className);\n return state;\n};\n"],"mappings":"AAAA,SAAAA,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,OAAO,MAAMC,sBAAsB,GAAG;EAClCC,IAAI,EAAE;AACV,CAAC;AACD;AACA;AACA;AAAI,MAAMC,SAAS,gBAAGJ,QAAA;EAAAG,IAAA;IAAAE,IAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,QAAA;IAAAL,IAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAG,OAAA;IAAAC,MAAA;IAAAH,OAAA;EAAA;AAAA;EAAAI,CAAA;IAAAC,CAAA;EAAA;IAAAA,CAAA;EAAA;AAAA,CAWrB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,8BAA8B,GAAIC,KAAK,IAAG;EACvD,aAAa;;EACb,MAAM;IAAEN;EAAS,CAAC,GAAGM,KAAK;EAC1B,MAAMC,MAAM,GAAGb,SAAS,CAAC,CAAC;EAC1BY,KAAK,CAACb,IAAI,CAACe,SAAS,GAAGjB,YAAY,CAACC,sBAAsB,CAACC,IAAI,EAAEc,MAAM,CAACd,IAAI,EAAEO,QAAQ,IAAIO,MAAM,CAACP,QAAQ,EAAEM,KAAK,CAACb,IAAI,CAACe,SAAS,CAAC;EAChI,OAAOF,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
|
2
|
+
export const carouselContextDefaultValue = {
|
|
3
|
+
activeIndex: 0,
|
|
4
|
+
selectPageByElement: ()=>{
|
|
5
|
+
return 0;
|
|
6
|
+
},
|
|
7
|
+
selectPageByDirection: ()=>{
|
|
8
|
+
return 0;
|
|
9
|
+
},
|
|
10
|
+
selectPageByIndex: ()=>{
|
|
11
|
+
/** noop */ },
|
|
12
|
+
subscribeForValues: ()=>()=>{
|
|
13
|
+
/** noop */ },
|
|
14
|
+
enableAutoplay: ()=>{
|
|
15
|
+
/** noop */ },
|
|
16
|
+
resetAutoplay: ()=>{
|
|
17
|
+
/** noop */ },
|
|
18
|
+
circular: false,
|
|
19
|
+
containerRef: undefined
|
|
20
|
+
};
|
|
21
|
+
const CarouselContext = createContext(undefined);
|
|
22
|
+
export const CarouselProvider = CarouselContext.Provider;
|
|
23
|
+
export const useCarouselContext_unstable = (selector)=>useContextSelector(CarouselContext, (ctx = carouselContextDefaultValue)=>selector(ctx));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CarouselContext.ts"],"sourcesContent":["import { ContextSelector, createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { CarouselContextValue } from './CarouselContext.types';\n\nexport const carouselContextDefaultValue: CarouselContextValue = {\n activeIndex: 0,\n selectPageByElement: () => {\n return 0;\n },\n selectPageByDirection: () => {\n return 0;\n },\n selectPageByIndex: () => {\n /** noop */\n },\n subscribeForValues: () => () => {\n /** noop */\n },\n enableAutoplay: () => {\n /** noop */\n },\n resetAutoplay: () => {\n /** noop */\n },\n circular: false,\n containerRef: undefined,\n};\n\nconst CarouselContext = createContext<CarouselContextValue | undefined>(undefined);\n\nexport const CarouselProvider = CarouselContext.Provider;\n\nexport const useCarouselContext_unstable = <T>(selector: ContextSelector<CarouselContextValue, T>): T =>\n useContextSelector(CarouselContext, (ctx = carouselContextDefaultValue) => selector(ctx));\n"],"names":["createContext","useContextSelector","carouselContextDefaultValue","activeIndex","selectPageByElement","selectPageByDirection","selectPageByIndex","subscribeForValues","enableAutoplay","resetAutoplay","circular","containerRef","undefined","CarouselContext","CarouselProvider","Provider","useCarouselContext_unstable","selector","ctx"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAA0BA,aAAa,EAAEC,kBAAkB,QAAQ,mCAAmC;AAGtG,OAAO,MAAMC,8BAAoD;IAC/DC,aAAa;IACbC,qBAAqB;QACnB,OAAO;IACT;IACAC,uBAAuB;QACrB,OAAO;IACT;IACAC,mBAAmB;IACjB,SAAS,GACX;IACAC,oBAAoB,IAAM;QACxB,SAAS,GACX;IACAC,gBAAgB;IACd,SAAS,GACX;IACAC,eAAe;IACb,SAAS,GACX;IACAC,UAAU;IACVC,cAAcC;AAChB,EAAE;AAEF,MAAMC,kBAAkBb,cAAgDY;AAExE,OAAO,MAAME,mBAAmBD,gBAAgBE,QAAQ,CAAC;AAEzD,OAAO,MAAMC,8BAA8B,CAAIC,WAC7ChB,mBAAmBY,iBAAiB,CAACK,MAAMhB,2BAA2B,GAAKe,SAASC,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CarouselContext.types.ts"],"sourcesContent":["import type { EventData } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport type { CarouselUpdateData } from '../Carousel';\n\nexport type CarouselIndexChangeData = EventData<\n 'click' | 'focus',\n React.FocusEvent | React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>\n> & {\n /**\n * The index to be set after event has occurred.\n */\n index: number;\n};\n\nexport type CarouselContextValue = {\n activeIndex: number;\n circular: boolean;\n selectPageByElement: (event: React.FocusEvent, element: HTMLElement, jump?: boolean) => number;\n selectPageByDirection: (\n event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>,\n direction: 'next' | 'prev',\n ) => number;\n selectPageByIndex: (\n event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>,\n value: number,\n jump?: boolean,\n ) => void;\n subscribeForValues: (listener: (data: CarouselUpdateData) => void) => () => void;\n enableAutoplay: (autoplay: boolean) => void;\n resetAutoplay: () => void;\n containerRef?: React.RefObject<HTMLDivElement>;\n};\n\n/**\n * Context shared between Carousel and its children components\n */\nexport type CarouselContextValues = {\n carousel: CarouselContextValue;\n};\n"],"names":["React"],"rangeMappings":"","mappings":"AACA,YAAYA,WAAW,QAAQ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useCarouselNavContextValues_unstable } from './CarouselNavContext';
|
|
3
|
+
import { renderCarouselNav_unstable } from './renderCarouselNav';
|
|
4
|
+
import { useCarouselNav_unstable } from './useCarouselNav';
|
|
5
|
+
import { useCarouselNavStyles_unstable } from './useCarouselNavStyles.styles';
|
|
6
|
+
/**
|
|
7
|
+
* Used to jump to a card based on index, using arrow navigation via Tabster.
|
|
8
|
+
*
|
|
9
|
+
* The children of this component will be wrapped in a context to
|
|
10
|
+
* provide the appropriate value based on their index position.
|
|
11
|
+
*/ export const CarouselNav = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
12
|
+
const state = useCarouselNav_unstable(props, ref);
|
|
13
|
+
const contextValues = useCarouselNavContextValues_unstable(state);
|
|
14
|
+
useCarouselNavStyles_unstable(state);
|
|
15
|
+
// TODO update types in packages/react-components/react-shared-contexts/src/CustomStyleHooksContext/CustomStyleHooksContext.ts
|
|
16
|
+
// https://github.com/microsoft/fluentui/blob/master/rfcs/react-components/convergence/custom-styling.md
|
|
17
|
+
// useCustomStyleHook_unstable('useCarouselNavStyles_unstable')(state);
|
|
18
|
+
return renderCarouselNav_unstable(state, contextValues);
|
|
19
|
+
});
|
|
20
|
+
CarouselNav.displayName = 'CarouselNav';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CarouselNav.tsx"],"sourcesContent":["import type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport type { CarouselNavProps } from './CarouselNav.types';\nimport { useCarouselNavContextValues_unstable } from './CarouselNavContext';\nimport { renderCarouselNav_unstable } from './renderCarouselNav';\nimport { useCarouselNav_unstable } from './useCarouselNav';\nimport { useCarouselNavStyles_unstable } from './useCarouselNavStyles.styles';\n\n/**\n * Used to jump to a card based on index, using arrow navigation via Tabster.\n *\n * The children of this component will be wrapped in a context to\n * provide the appropriate value based on their index position.\n */\nexport const CarouselNav: ForwardRefComponent<CarouselNavProps> = React.forwardRef((props, ref) => {\n const state = useCarouselNav_unstable(props, ref);\n const contextValues = useCarouselNavContextValues_unstable(state);\n\n useCarouselNavStyles_unstable(state);\n // TODO update types in packages/react-components/react-shared-contexts/src/CustomStyleHooksContext/CustomStyleHooksContext.ts\n // https://github.com/microsoft/fluentui/blob/master/rfcs/react-components/convergence/custom-styling.md\n // useCustomStyleHook_unstable('useCarouselNavStyles_unstable')(state);\n\n return renderCarouselNav_unstable(state, contextValues);\n});\n\nCarouselNav.displayName = 'CarouselNav';\n"],"names":["React","useCarouselNavContextValues_unstable","renderCarouselNav_unstable","useCarouselNav_unstable","useCarouselNavStyles_unstable","CarouselNav","forwardRef","props","ref","state","contextValues","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AACA,YAAYA,WAAW,QAAQ;AAG/B,SAASC,oCAAoC,QAAQ,uBAAuB;AAC5E,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,6BAA6B,QAAQ,gCAAgC;AAE9E;;;;;CAKC,GACD,OAAO,MAAMC,4BAAqDL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IACzF,MAAMC,QAAQN,wBAAwBI,OAAOC;IAC7C,MAAME,gBAAgBT,qCAAqCQ;IAE3DL,8BAA8BK;IAC9B,8HAA8H;IAC9H,wGAAwG;IACxG,uEAAuE;IAEvE,OAAOP,2BAA2BO,OAAOC;AAC3C,GAAG;AAEHL,YAAYM,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CarouselNav.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nexport type CarouselNavSlots = {\n /**\n * The element wrapping the carousel pagination. By default, this is a div.\n */\n root: NonNullable<Slot<'div'>>;\n};\n\nexport type NavButtonRenderFunction = (index: number) => React.ReactNode;\n\nexport type CarouselNavState = ComponentState<CarouselNavSlots> & {\n /**\n * Enables an alternate brand style when set to 'brand'\n */\n appearance?: 'brand';\n\n /**\n * The function that will render nav items based on total slides and their index.\n */\n renderNavButton: NavButtonRenderFunction;\n\n /**\n * The total number of slides available.\n * Users may override if using the component without a Carousel wrapper or implementing custom functionality.\n */\n totalSlides: number;\n};\n\nexport type CarouselNavProps = Omit<ComponentProps<Partial<CarouselNavSlots>>, 'children'> & {\n children: NavButtonRenderFunction;\n} & Partial<Pick<CarouselNavState, 'appearance' | 'totalSlides'>>;\n\nexport type CarouselNavContextValue = Pick<CarouselNavState, 'appearance'>;\n"],"names":["React"],"rangeMappings":"","mappings":"AACA,YAAYA,WAAW,QAAQ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const carouselNavContext = React.createContext(undefined);
|
|
3
|
+
export const carouselNavContextDefaultValue = {
|
|
4
|
+
appearance: undefined
|
|
5
|
+
};
|
|
6
|
+
export const useCarouselNavContext = ()=>{
|
|
7
|
+
var _React_useContext;
|
|
8
|
+
return (_React_useContext = React.useContext(carouselNavContext)) !== null && _React_useContext !== void 0 ? _React_useContext : carouselNavContextDefaultValue;
|
|
9
|
+
};
|
|
10
|
+
export const CarouselNavContextProvider = carouselNavContext.Provider;
|
|
11
|
+
export function useCarouselNavContextValues_unstable(state) {
|
|
12
|
+
const { appearance } = state;
|
|
13
|
+
const carouselNav = React.useMemo(()=>({
|
|
14
|
+
appearance
|
|
15
|
+
}), [
|
|
16
|
+
appearance
|
|
17
|
+
]);
|
|
18
|
+
return {
|
|
19
|
+
carouselNav
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CarouselNavContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { CarouselNavContextValue, CarouselNavState } from './CarouselNav.types';\n\nconst carouselNavContext = React.createContext<CarouselNavContextValue | undefined>(undefined);\n\nexport const carouselNavContextDefaultValue: CarouselNavContextValue = {\n appearance: undefined,\n};\n\nexport const useCarouselNavContext = () => React.useContext(carouselNavContext) ?? carouselNavContextDefaultValue;\n\nexport const CarouselNavContextProvider = carouselNavContext.Provider;\n\n/**\n * Context shared between CarouselNav and its children components\n */\nexport type CarouselNavContextValues = {\n carouselNav: CarouselNavContextValue;\n};\n\nexport function useCarouselNavContextValues_unstable(state: CarouselNavState): CarouselNavContextValues {\n const { appearance } = state;\n const carouselNav = React.useMemo(() => ({ appearance }), [appearance]);\n\n return { carouselNav };\n}\n"],"names":["React","carouselNavContext","createContext","undefined","carouselNavContextDefaultValue","appearance","useCarouselNavContext","useContext","CarouselNavContextProvider","Provider","useCarouselNavContextValues_unstable","state","carouselNav","useMemo"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B,MAAMC,qBAAqBD,MAAME,aAAa,CAAsCC;AAEpF,OAAO,MAAMC,iCAA0D;IACrEC,YAAYF;AACd,EAAE;AAEF,OAAO,MAAMG,wBAAwB;QAAMN;WAAAA,CAAAA,oBAAAA,MAAMO,UAAU,CAACN,iCAAjBD,+BAAAA,oBAAwCI;AAA6B,EAAE;AAElH,OAAO,MAAMI,6BAA6BP,mBAAmBQ,QAAQ,CAAC;AAStE,OAAO,SAASC,qCAAqCC,KAAuB;IAC1E,MAAM,EAAEN,UAAU,EAAE,GAAGM;IACvB,MAAMC,cAAcZ,MAAMa,OAAO,CAAC,IAAO,CAAA;YAAER;QAAW,CAAA,GAAI;QAACA;KAAW;IAEtE,OAAO;QAAEO;IAAY;AACvB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const carouselNavIndexContext = React.createContext(undefined);
|
|
3
|
+
export const carouselNavIndexContextDefaultValue = 0;
|
|
4
|
+
export const useCarouselNavIndexContext = ()=>{
|
|
5
|
+
var _React_useContext;
|
|
6
|
+
return (_React_useContext = React.useContext(carouselNavIndexContext)) !== null && _React_useContext !== void 0 ? _React_useContext : carouselNavIndexContextDefaultValue;
|
|
7
|
+
};
|
|
8
|
+
export const CarouselNavIndexContextProvider = carouselNavIndexContext.Provider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["CarouselNavIndexContext.ts"],"sourcesContent":["import * as React from 'react';\n\nconst carouselNavIndexContext = React.createContext<number | undefined>(undefined);\n\nexport const carouselNavIndexContextDefaultValue: number = 0;\n\nexport const useCarouselNavIndexContext = () =>\n React.useContext(carouselNavIndexContext) ?? carouselNavIndexContextDefaultValue;\n\nexport const CarouselNavIndexContextProvider = carouselNavIndexContext.Provider;\n"],"names":["React","carouselNavIndexContext","createContext","undefined","carouselNavIndexContextDefaultValue","useCarouselNavIndexContext","useContext","CarouselNavIndexContextProvider","Provider"],"rangeMappings":";;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,MAAMC,0BAA0BD,MAAME,aAAa,CAAqBC;AAExE,OAAO,MAAMC,sCAA8C,EAAE;AAE7D,OAAO,MAAMC,6BAA6B;QACxCL;WAAAA,CAAAA,oBAAAA,MAAMM,UAAU,CAACL,sCAAjBD,+BAAAA,oBAA6CI;AAAkC,EAAE;AAEnF,OAAO,MAAMG,kCAAkCN,wBAAwBO,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './CarouselNav';\nexport * from './CarouselNav.types';\nexport * from './renderCarouselNav';\nexport * from './useCarouselNav';\nexport * from './useCarouselNavStyles.styles';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,gCAAgC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
+
import { assertSlots } from '@fluentui/react-utilities';
|
|
3
|
+
import { CarouselNavContextProvider } from './CarouselNavContext';
|
|
4
|
+
import { CarouselNavIndexContextProvider } from './CarouselNavIndexContext';
|
|
5
|
+
/**
|
|
6
|
+
* Render the final JSX of CarouselNav
|
|
7
|
+
*/ export const renderCarouselNav_unstable = (state, contextValues)=>{
|
|
8
|
+
assertSlots(state);
|
|
9
|
+
const { totalSlides, renderNavButton } = state;
|
|
10
|
+
return /*#__PURE__*/ _jsx(state.root, {
|
|
11
|
+
children: /*#__PURE__*/ _jsx(CarouselNavContextProvider, {
|
|
12
|
+
value: contextValues.carouselNav,
|
|
13
|
+
children: new Array(totalSlides).fill(null).map((_, index)=>/*#__PURE__*/ _jsx(CarouselNavIndexContextProvider, {
|
|
14
|
+
value: index,
|
|
15
|
+
children: renderNavButton(index)
|
|
16
|
+
}, index))
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renderCarouselNav.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\n\nimport type { CarouselNavState, CarouselNavSlots } from './CarouselNav.types';\nimport { CarouselNavContextProvider, type CarouselNavContextValues } from './CarouselNavContext';\nimport { CarouselNavIndexContextProvider } from './CarouselNavIndexContext';\n\n/**\n * Render the final JSX of CarouselNav\n */\nexport const renderCarouselNav_unstable = (state: CarouselNavState, contextValues: CarouselNavContextValues) => {\n assertSlots<CarouselNavSlots>(state);\n\n const { totalSlides, renderNavButton } = state;\n\n return (\n <state.root>\n <CarouselNavContextProvider value={contextValues.carouselNav}>\n {new Array(totalSlides).fill(null).map((_, index) => (\n <CarouselNavIndexContextProvider key={index} value={index}>\n {renderNavButton(index)}\n </CarouselNavIndexContextProvider>\n ))}\n </CarouselNavContextProvider>\n </state.root>\n );\n};\n"],"names":["assertSlots","CarouselNavContextProvider","CarouselNavIndexContextProvider","renderCarouselNav_unstable","state","contextValues","totalSlides","renderNavButton","root","value","carouselNav","Array","fill","map","_","index"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD,SAASC,0BAA0B,QAAuC,uBAAuB;AACjG,SAASC,+BAA+B,QAAQ,4BAA4B;AAE5E;;CAEC,GACD,OAAO,MAAMC,6BAA6B,CAACC,OAAyBC;IAClEL,YAA8BI;IAE9B,MAAM,EAAEE,WAAW,EAAEC,eAAe,EAAE,GAAGH;IAEzC,qBACE,KAACA,MAAMI,IAAI;kBACT,cAAA,KAACP;YAA2BQ,OAAOJ,cAAcK,WAAW;sBACzD,IAAIC,MAAML,aAAaM,IAAI,CAAC,MAAMC,GAAG,CAAC,CAACC,GAAGC,sBACzC,KAACb;oBAA4CO,OAAOM;8BACjDR,gBAAgBQ;mBADmBA;;;AAOhD,EAAE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
2
|
+
import { getIntrinsicElementProps, slot, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useCarouselContext_unstable as useCarouselContext } from '../CarouselContext';
|
|
5
|
+
/**
|
|
6
|
+
* Create the state required to render CarouselNav.
|
|
7
|
+
*
|
|
8
|
+
* The returned state can be modified with hooks such as useCarouselNavStyles_unstable,
|
|
9
|
+
* before being passed to renderCarouselNav_unstable.
|
|
10
|
+
*
|
|
11
|
+
* @param props - props from this instance of CarouselNav
|
|
12
|
+
* @param ref - reference to root HTMLDivElement of CarouselNav
|
|
13
|
+
*/ export const useCarouselNav_unstable = (props, ref)=>{
|
|
14
|
+
const { appearance } = props;
|
|
15
|
+
const focusableGroupAttr = useArrowNavigationGroup({
|
|
16
|
+
circular: false,
|
|
17
|
+
axis: 'horizontal',
|
|
18
|
+
memorizeCurrent: false,
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
20
|
+
unstable_hasDefault: true
|
|
21
|
+
});
|
|
22
|
+
var _props_totalSlides;
|
|
23
|
+
const [totalSlides, setTotalSlides] = React.useState((_props_totalSlides = props.totalSlides) !== null && _props_totalSlides !== void 0 ? _props_totalSlides : 0);
|
|
24
|
+
const subscribeForValues = useCarouselContext((ctx)=>ctx.subscribeForValues);
|
|
25
|
+
useIsomorphicLayoutEffect(()=>{
|
|
26
|
+
return subscribeForValues((data)=>{
|
|
27
|
+
setTotalSlides(data.navItemsCount);
|
|
28
|
+
});
|
|
29
|
+
}, [
|
|
30
|
+
subscribeForValues
|
|
31
|
+
]);
|
|
32
|
+
return {
|
|
33
|
+
totalSlides,
|
|
34
|
+
appearance,
|
|
35
|
+
renderNavButton: props.children,
|
|
36
|
+
components: {
|
|
37
|
+
root: 'div'
|
|
38
|
+
},
|
|
39
|
+
root: slot.always(getIntrinsicElementProps('div', {
|
|
40
|
+
ref,
|
|
41
|
+
role: 'tablist',
|
|
42
|
+
...props,
|
|
43
|
+
...focusableGroupAttr,
|
|
44
|
+
children: null
|
|
45
|
+
}), {
|
|
46
|
+
elementType: 'div'
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useCarouselNav.ts"],"sourcesContent":["import { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { getIntrinsicElementProps, slot, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useCarouselContext_unstable as useCarouselContext } from '../CarouselContext';\nimport type { CarouselNavProps, CarouselNavState } from './CarouselNav.types';\n\n/**\n * Create the state required to render CarouselNav.\n *\n * The returned state can be modified with hooks such as useCarouselNavStyles_unstable,\n * before being passed to renderCarouselNav_unstable.\n *\n * @param props - props from this instance of CarouselNav\n * @param ref - reference to root HTMLDivElement of CarouselNav\n */\nexport const useCarouselNav_unstable = (props: CarouselNavProps, ref: React.Ref<HTMLDivElement>): CarouselNavState => {\n const { appearance } = props;\n\n const focusableGroupAttr = useArrowNavigationGroup({\n circular: false,\n axis: 'horizontal',\n memorizeCurrent: false,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_hasDefault: true,\n });\n\n const [totalSlides, setTotalSlides] = React.useState(props.totalSlides ?? 0);\n const subscribeForValues = useCarouselContext(ctx => ctx.subscribeForValues);\n\n useIsomorphicLayoutEffect(() => {\n return subscribeForValues(data => {\n setTotalSlides(data.navItemsCount);\n });\n }, [subscribeForValues]);\n\n return {\n totalSlides,\n appearance,\n renderNavButton: props.children,\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref,\n role: 'tablist',\n ...props,\n ...focusableGroupAttr,\n children: null,\n }),\n { elementType: 'div' },\n ),\n };\n};\n"],"names":["useArrowNavigationGroup","getIntrinsicElementProps","slot","useIsomorphicLayoutEffect","React","useCarouselContext_unstable","useCarouselContext","useCarouselNav_unstable","props","ref","appearance","focusableGroupAttr","circular","axis","memorizeCurrent","unstable_hasDefault","totalSlides","setTotalSlides","useState","subscribeForValues","ctx","data","navItemsCount","renderNavButton","children","components","root","always","role","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,uBAAuB,QAAQ,0BAA0B;AAClE,SAASC,wBAAwB,EAAEC,IAAI,EAAEC,yBAAyB,QAAQ,4BAA4B;AACtG,YAAYC,WAAW,QAAQ;AAE/B,SAASC,+BAA+BC,kBAAkB,QAAQ,qBAAqB;AAGvF;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D,MAAM,EAAEC,UAAU,EAAE,GAAGF;IAEvB,MAAMG,qBAAqBX,wBAAwB;QACjDY,UAAU;QACVC,MAAM;QACNC,iBAAiB;QACjB,gEAAgE;QAChEC,qBAAqB;IACvB;QAEqDP;IAArD,MAAM,CAACQ,aAAaC,eAAe,GAAGb,MAAMc,QAAQ,CAACV,CAAAA,qBAAAA,MAAMQ,WAAW,cAAjBR,gCAAAA,qBAAqB;IAC1E,MAAMW,qBAAqBb,mBAAmBc,CAAAA,MAAOA,IAAID,kBAAkB;IAE3EhB,0BAA0B;QACxB,OAAOgB,mBAAmBE,CAAAA;YACxBJ,eAAeI,KAAKC,aAAa;QACnC;IACF,GAAG;QAACH;KAAmB;IAEvB,OAAO;QACLH;QACAN;QACAa,iBAAiBf,MAAMgB,QAAQ;QAC/BC,YAAY;YACVC,MAAM;QACR;QACAA,MAAMxB,KAAKyB,MAAM,CACf1B,yBAAyB,OAAO;YAC9BQ;YACAmB,MAAM;YACN,GAAGpB,KAAK;YACR,GAAGG,kBAAkB;YACrBa,UAAU;QACZ,IACA;YAAEK,aAAa;QAAM;IAEzB;AACF,EAAE"}
|