@lumx/react 3.9.4-alpha.1 → 3.9.4-alpha.3

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/index.js CHANGED
@@ -11806,6 +11806,8 @@ const PAGINATION_ITEMS_MAX = 5;
11806
11806
  * Size of a pagination item. Used to translate wrapper.
11807
11807
  */
11808
11808
  const PAGINATION_ITEM_SIZE = 12;
11809
+ const NEXT_SLIDE_EVENT = 'lumx-next-slide-event';
11810
+ const PREV_SLIDE_EVENT = 'lumx-prev-slide-event';
11809
11811
 
11810
11812
  const DEFAULT_OPTIONS = {
11811
11813
  activeIndex: 0,
@@ -11901,6 +11903,17 @@ const useSlideshowControls = _ref => {
11901
11903
  goTo(-1, loopBack, true);
11902
11904
  }, [goTo, stopAutoPlay]);
11903
11905
 
11906
+ // Listen to custom next/prev slide events
11907
+ useEffect(() => {
11908
+ if (!element) return undefined;
11909
+ element.addEventListener(NEXT_SLIDE_EVENT, onNextClick);
11910
+ element.addEventListener(PREV_SLIDE_EVENT, onPreviousClick);
11911
+ return () => {
11912
+ element.removeEventListener(NEXT_SLIDE_EVENT, onNextClick);
11913
+ element.removeEventListener(PREV_SLIDE_EVENT, onPreviousClick);
11914
+ };
11915
+ }, [element, onNextClick, onPreviousClick]);
11916
+
11904
11917
  // If the activeIndex props changes, update the current slide
11905
11918
  useEffect(() => {
11906
11919
  setActiveIndex(activeIndex);
@@ -12524,6 +12537,10 @@ const Slides = /*#__PURE__*/forwardRef((props, ref) => {
12524
12537
  return groupBy && groupBy > 1 ? chunk(childrenArray, groupBy) : childrenArray;
12525
12538
  }, [children, groupBy]);
12526
12539
  const slidesRef = React__default.useRef(null);
12540
+ const slide = slidesRef.current;
12541
+ const onNextSlide = React__default.useCallback(() => slide === null || slide === void 0 ? void 0 : slide.dispatchEvent(new CustomEvent(NEXT_SLIDE_EVENT)), [slide]);
12542
+ const onPrevSlide = React__default.useCallback(() => slide === null || slide === void 0 ? void 0 : slide.dispatchEvent(new CustomEvent(PREV_SLIDE_EVENT)), [slide]);
12543
+ useKeyNavigate(slide, onNextSlide, onPrevSlide);
12527
12544
  return /*#__PURE__*/React__default.createElement("section", _extends({
12528
12545
  id: id,
12529
12546
  ref: useMergeRefs(slidesRef, ref)
@@ -12548,7 +12565,7 @@ const Slides = /*#__PURE__*/forwardRef((props, ref) => {
12548
12565
  }, groups.map((group, index) => /*#__PURE__*/React__default.createElement(SlideshowItemGroup, {
12549
12566
  key: index,
12550
12567
  id: slidesId && buildSlideShowGroupId(slidesId, index),
12551
- label: slideGroupLabel ? slideGroupLabel(index + 1, groups.length) : undefined,
12568
+ label: slideGroupLabel === null || slideGroupLabel === void 0 ? void 0 : slideGroupLabel(index + 1, groups.length),
12552
12569
  isDisplayed: index >= startIndexVisible && index < endIndexVisible,
12553
12570
  slidesRef: slidesRef
12554
12571
  }, group)))), afterSlides);