@lumx/react 3.7.6-alpha.3 → 3.7.6-alpha.4
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.d.ts +7 -7
- package/index.js +17 -11
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/image-lightbox/internal/ImageSlide.tsx +12 -5
- package/src/components/image-lightbox/internal/ImageSlideshow.tsx +17 -6
- package/src/components/image-lightbox/types.ts +9 -11
- package/src/components/image-lightbox/useImageLightbox.tsx +1 -1
- package/src/hooks/useElementSizeDependentOfWindowSize.ts +2 -2
package/index.d.ts
CHANGED
|
@@ -1376,10 +1376,11 @@ interface ImageBlockProps extends GenericProps, HasTheme, ImageCaptionMetadata {
|
|
|
1376
1376
|
*/
|
|
1377
1377
|
declare const ImageBlock: Comp<ImageBlockProps, HTMLDivElement>;
|
|
1378
1378
|
|
|
1379
|
-
type InheritedSlideShowProps = Pick<SlideshowProps, '
|
|
1380
|
-
interface
|
|
1381
|
-
/** */
|
|
1379
|
+
type InheritedSlideShowProps = Pick<SlideshowProps, 'slideshowControlsProps' | 'slideGroupLabel'>;
|
|
1380
|
+
interface ZoomButtonProps {
|
|
1381
|
+
/** Zoom in button props */
|
|
1382
1382
|
zoomInButtonProps?: IconButtonProps;
|
|
1383
|
+
/** Zoom out button props */
|
|
1383
1384
|
zoomOutButtonProps?: IconButtonProps;
|
|
1384
1385
|
}
|
|
1385
1386
|
type InheritedThumbnailProps = Pick<ThumbnailProps, 'image' | 'alt' | 'imgProps' | 'imgRef'>;
|
|
@@ -1393,13 +1394,12 @@ interface ImagesProps {
|
|
|
1393
1394
|
/** Ref of the active image when the lightbox is open */
|
|
1394
1395
|
activeImageRef?: React.Ref<HTMLImageElement>;
|
|
1395
1396
|
}
|
|
1396
|
-
type InheritedLightboxProps = Pick<LightboxProps, 'isOpen' | 'parentElement' | 'onClose' | 'closeButtonProps'>;
|
|
1397
|
-
type InheritedAriaAttributes = Pick<React.AriaAttributes, 'aria-label' | 'aria-labelledby'>;
|
|
1397
|
+
type InheritedLightboxProps = Pick<LightboxProps, 'isOpen' | 'parentElement' | 'onClose' | 'closeButtonProps' | 'aria-label' | 'aria-labelledby'>;
|
|
1398
1398
|
type ForwardedProps = React.ComponentPropsWithoutRef<'div'>;
|
|
1399
1399
|
/**
|
|
1400
1400
|
* ImageLightbox component props
|
|
1401
1401
|
*/
|
|
1402
|
-
interface ImageLightboxProps extends HasClassName,
|
|
1402
|
+
interface ImageLightboxProps extends HasClassName, ZoomButtonProps, ImagesProps, InheritedSlideShowProps, InheritedLightboxProps, ForwardedProps {
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
1405
|
/** Subset of the ImageLightboxProps managed by the useImageLightbox hook */
|
|
@@ -1419,7 +1419,7 @@ declare function useImageLightbox<P extends Partial<ImageLightboxProps>>(initial
|
|
|
1419
1419
|
* Generates trigger props
|
|
1420
1420
|
* @param index Provide an index to choose which image to display when the image lightbox opens.
|
|
1421
1421
|
* */
|
|
1422
|
-
getTriggerProps: (options
|
|
1422
|
+
getTriggerProps: (options?: TriggerOptions) => {
|
|
1423
1423
|
onClick: React.MouseEventHandler;
|
|
1424
1424
|
ref: React.Ref<any>;
|
|
1425
1425
|
};
|
package/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import memoize from 'lodash/memoize';
|
|
|
17
17
|
import castArray from 'lodash/castArray';
|
|
18
18
|
import pick from 'lodash/pick';
|
|
19
19
|
import isInteger from 'lodash/isInteger';
|
|
20
|
+
import isEqual from 'lodash/isEqual';
|
|
20
21
|
import throttle from 'lodash/throttle';
|
|
21
22
|
import take from 'lodash/take';
|
|
22
23
|
import uniqueId from 'lodash/uniqueId';
|
|
@@ -7817,7 +7818,7 @@ function useElementSizeDependentOfWindowSize(elementRef) {
|
|
|
7817
7818
|
const [size, setSize] = React.useState(null);
|
|
7818
7819
|
const updateSize = React.useMemo(() => throttle(() => {
|
|
7819
7820
|
var _elementRef$current;
|
|
7820
|
-
const newSize =
|
|
7821
|
+
const newSize = (_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.getBoundingClientRect();
|
|
7821
7822
|
if (newSize) setSize(newSize);
|
|
7822
7823
|
}, 10), [elementRef]);
|
|
7823
7824
|
React.useEffect(() => {
|
|
@@ -8054,10 +8055,12 @@ const ImageSlide = /*#__PURE__*/React.memo(props => {
|
|
|
8054
8055
|
isActive,
|
|
8055
8056
|
scale,
|
|
8056
8057
|
onScaleChange,
|
|
8057
|
-
image
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8058
|
+
image: {
|
|
8059
|
+
image,
|
|
8060
|
+
imgRef: propImgRef,
|
|
8061
|
+
imgProps,
|
|
8062
|
+
alt
|
|
8063
|
+
}
|
|
8061
8064
|
} = props;
|
|
8062
8065
|
|
|
8063
8066
|
// Get scroll area size
|
|
@@ -8127,7 +8130,7 @@ const ImageSlide = /*#__PURE__*/React.memo(props => {
|
|
|
8127
8130
|
})
|
|
8128
8131
|
})
|
|
8129
8132
|
}));
|
|
8130
|
-
});
|
|
8133
|
+
}, isEqual);
|
|
8131
8134
|
|
|
8132
8135
|
const _excluded$z = ["image", "imgRef"];
|
|
8133
8136
|
/** Internal image slideshow component for ImageLightbox */
|
|
@@ -8222,6 +8225,7 @@ const ImageSlideshow = _ref => {
|
|
|
8222
8225
|
icon: mdiMagnifyMinusOutline,
|
|
8223
8226
|
onClick: zoomOut
|
|
8224
8227
|
})));
|
|
8228
|
+
const getImgRef = React.useMemo(() => memoize(index => mergeRefs(images === null || images === void 0 ? void 0 : images[index].imgRef, index === activeImageIndex ? activeImageRef : undefined)), [images, activeImageIndex, activeImageRef]);
|
|
8225
8229
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Slides, {
|
|
8226
8230
|
activeIndex: activeIndex,
|
|
8227
8231
|
theme: "dark",
|
|
@@ -8236,16 +8240,18 @@ const ImageSlideshow = _ref => {
|
|
|
8236
8240
|
image,
|
|
8237
8241
|
imgRef
|
|
8238
8242
|
} = _ref2,
|
|
8239
|
-
|
|
8243
|
+
imageProps = _objectWithoutProperties(_ref2, _excluded$z);
|
|
8240
8244
|
const isActive = index === activeIndex;
|
|
8241
|
-
return /*#__PURE__*/React.createElement(ImageSlide,
|
|
8245
|
+
return /*#__PURE__*/React.createElement(ImageSlide, {
|
|
8242
8246
|
isActive: isActive,
|
|
8243
8247
|
key: image,
|
|
8244
|
-
|
|
8245
|
-
|
|
8248
|
+
image: _objectSpread2(_objectSpread2({}, imageProps), {}, {
|
|
8249
|
+
image,
|
|
8250
|
+
imgRef: getImgRef(index)
|
|
8251
|
+
}),
|
|
8246
8252
|
scale: isActive ? scale : undefined,
|
|
8247
8253
|
onScaleChange: onScaleChange
|
|
8248
|
-
})
|
|
8254
|
+
});
|
|
8249
8255
|
})), (metadata || slideShowControls || zoomControls) && /*#__PURE__*/React.createElement(FlexBox, {
|
|
8250
8256
|
ref: footerRef,
|
|
8251
8257
|
className: `${CLASSNAME$v}__footer`,
|