@lumx/react 3.8.2-alpha.0 → 3.8.2-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/index.js CHANGED
@@ -7845,7 +7845,7 @@ const CLASSNAME$v = getRootClassName(COMPONENT_NAME$y);
7845
7845
  * @param elementRef Element to observe
7846
7846
  * @return the size and a manual update callback
7847
7847
  */
7848
- function useElementSizeDependentOfWindowSize(elementRef) {
7848
+ function useSizeOnWindowResize(elementRef) {
7849
7849
  const [size, setSize] = React.useState(null);
7850
7850
  const updateSize = React.useMemo(() => throttle(() => {
7851
7851
  var _elementRef$current;
@@ -8109,7 +8109,7 @@ const ImageSlide = /*#__PURE__*/React.memo(props => {
8109
8109
 
8110
8110
  // Get scroll area size
8111
8111
  const scrollAreaRef = React.useRef(null);
8112
- const [scrollAreaSize, updateSize] = useElementSizeDependentOfWindowSize(scrollAreaRef);
8112
+ const [scrollAreaSize, updateSize] = useSizeOnWindowResize(scrollAreaRef);
8113
8113
  React.useEffect(() => {
8114
8114
  // Update size when active
8115
8115
  if (isActive) updateSize();
@@ -8519,6 +8519,14 @@ const Inner = /*#__PURE__*/forwardRef((props, ref) => {
8519
8519
  const footerRef = React.useRef(null);
8520
8520
  const imageRef = React.useRef(null);
8521
8521
  const clickAwayChildrenRefs = React.useRef([imageRef, footerRef]);
8522
+ const onClickAway = React.useCallback(evt => {
8523
+ const targetElement = evt.target;
8524
+ if (!(targetElement instanceof HTMLElement) || !(evt instanceof MouseEvent)) return;
8525
+
8526
+ // Skip click away if clicking on the scrollbar
8527
+ if (targetElement.clientWidth < evt.clientX || targetElement.clientHeight < evt.clientY) return;
8528
+ onClose === null || onClose === void 0 ? void 0 : onClose();
8529
+ }, [onClose]);
8522
8530
  return /*#__PURE__*/React.createElement(Lightbox, _extends({
8523
8531
  ref: ref,
8524
8532
  className: classnames(className, CLASSNAME$v),
@@ -8529,7 +8537,7 @@ const Inner = /*#__PURE__*/forwardRef((props, ref) => {
8529
8537
  focusElement: currentPaginationItemRef
8530
8538
  }, forwardedProps), /*#__PURE__*/React.createElement(ClickAwayProvider, {
8531
8539
  childrenRefs: clickAwayChildrenRefs,
8532
- callback: onClose
8540
+ callback: onClickAway
8533
8541
  }, /*#__PURE__*/React.createElement(ImageSlideshow, {
8534
8542
  activeImageIndex: activeImageIndex,
8535
8543
  slideGroupLabel: slideGroupLabel,
@@ -8538,7 +8546,7 @@ const Inner = /*#__PURE__*/forwardRef((props, ref) => {
8538
8546
  zoomInButtonProps: zoomInButtonProps,
8539
8547
  zoomOutButtonProps: zoomOutButtonProps,
8540
8548
  footerRef: footerRef,
8541
- activeImageRef: mergeRefs(propImageRef, imageRef),
8549
+ activeImageRef: useMergeRefs(propImageRef, imageRef),
8542
8550
  currentPaginationItemRef: currentPaginationItemRef
8543
8551
  })));
8544
8552
  });