@lumx/react 3.9.4-alpha.1 → 3.9.4-alpha.2
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/package.json
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"url": "https://github.com/lumapps/design-system/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@lumx/core": "^3.9.4-alpha.
|
|
10
|
-
"@lumx/icons": "^3.9.4-alpha.
|
|
9
|
+
"@lumx/core": "^3.9.4-alpha.2",
|
|
10
|
+
"@lumx/icons": "^3.9.4-alpha.2",
|
|
11
11
|
"@popperjs/core": "^2.5.4",
|
|
12
12
|
"body-scroll-lock": "^3.1.5",
|
|
13
13
|
"classnames": "^2.3.2",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"build:storybook": "storybook build"
|
|
112
112
|
},
|
|
113
113
|
"sideEffects": false,
|
|
114
|
-
"version": "3.9.4-alpha.
|
|
114
|
+
"version": "3.9.4-alpha.2"
|
|
115
115
|
}
|
|
@@ -3,10 +3,11 @@ import chunk from 'lodash/chunk';
|
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
|
|
6
|
-
import { FULL_WIDTH_PERCENT } from '@lumx/react/components/slideshow/constants';
|
|
6
|
+
import { FULL_WIDTH_PERCENT, NEXT_SLIDE_EVENT } from '@lumx/react/components/slideshow/constants';
|
|
7
7
|
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
8
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
9
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
10
|
+
import { useKeyNavigate } from '@lumx/react/components/slideshow/useKeyNavigate';
|
|
10
11
|
import { buildSlideShowGroupId, SlideshowItemGroup } from './SlideshowItemGroup';
|
|
11
12
|
|
|
12
13
|
export interface SlidesProps extends GenericProps, HasTheme {
|
|
@@ -84,6 +85,11 @@ export const Slides: Comp<SlidesProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
84
85
|
|
|
85
86
|
const slidesRef = React.useRef<HTMLDivElement>(null);
|
|
86
87
|
|
|
88
|
+
const slide = slidesRef.current;
|
|
89
|
+
const onNextSlide = React.useCallback(() => slide?.dispatchEvent(new CustomEvent(NEXT_SLIDE_EVENT)), [slide]);
|
|
90
|
+
const onPrevSlide = React.useCallback(() => slide?.dispatchEvent(new CustomEvent(NEXT_SLIDE_EVENT)), [slide]);
|
|
91
|
+
useKeyNavigate(slide, onNextSlide, onPrevSlide);
|
|
92
|
+
|
|
87
93
|
return (
|
|
88
94
|
<section
|
|
89
95
|
id={id}
|
|
@@ -107,7 +113,7 @@ export const Slides: Comp<SlidesProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
107
113
|
<SlideshowItemGroup
|
|
108
114
|
key={index}
|
|
109
115
|
id={slidesId && buildSlideShowGroupId(slidesId, index)}
|
|
110
|
-
label={slideGroupLabel
|
|
116
|
+
label={slideGroupLabel?.(index + 1, groups.length)}
|
|
111
117
|
isDisplayed={index >= startIndexVisible && index < endIndexVisible}
|
|
112
118
|
slidesRef={slidesRef}
|
|
113
119
|
>
|
|
@@ -22,3 +22,7 @@ export const PAGINATION_ITEMS_MAX = 5;
|
|
|
22
22
|
* Size of a pagination item. Used to translate wrapper.
|
|
23
23
|
*/
|
|
24
24
|
export const PAGINATION_ITEM_SIZE = 12;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export const NEXT_SLIDE_EVENT = 'lumx-next-slide-event';
|
|
28
|
+
export const PREV_SLIDE_EVENT = 'lumx-prev-slide-event';
|
|
@@ -3,7 +3,7 @@ import { clamp } from '@lumx/react';
|
|
|
3
3
|
import { useInterval } from '@lumx/react/hooks/useInterval';
|
|
4
4
|
import { useId } from '@lumx/react/hooks/useId';
|
|
5
5
|
|
|
6
|
-
import { AUTOPLAY_DEFAULT_INTERVAL } from './constants';
|
|
6
|
+
import { AUTOPLAY_DEFAULT_INTERVAL, NEXT_SLIDE_EVENT, PREV_SLIDE_EVENT } from './constants';
|
|
7
7
|
|
|
8
8
|
export interface UseSlideshowControlsOptions {
|
|
9
9
|
/** default active index to be displayed */
|
|
@@ -179,6 +179,18 @@ export const useSlideshowControls = ({
|
|
|
179
179
|
[goTo, stopAutoPlay],
|
|
180
180
|
);
|
|
181
181
|
|
|
182
|
+
// Listen to custom next/prev slide events
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (!element) return undefined;
|
|
185
|
+
|
|
186
|
+
element.addEventListener(NEXT_SLIDE_EVENT, onNextClick);
|
|
187
|
+
element.addEventListener(PREV_SLIDE_EVENT, onPreviousClick);
|
|
188
|
+
return () => {
|
|
189
|
+
element.removeEventListener(NEXT_SLIDE_EVENT, onNextClick);
|
|
190
|
+
element.removeEventListener(PREV_SLIDE_EVENT, onPreviousClick);
|
|
191
|
+
};
|
|
192
|
+
}, [element, onNextClick, onPreviousClick]);
|
|
193
|
+
|
|
182
194
|
// If the activeIndex props changes, update the current slide
|
|
183
195
|
useEffect(() => {
|
|
184
196
|
setActiveIndex(activeIndex as number);
|