@lumx/react 3.7.6-alpha.8 → 3.7.6-alpha.9
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 +3 -1
- package/index.js +18 -11
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/image-block/ImageCaption.tsx +1 -1
- package/src/components/image-lightbox/types.ts +4 -1
- package/src/components/image-lightbox/useImageLightbox.tsx +3 -8
- package/src/components/thumbnail/Thumbnail.stories.tsx +29 -0
- package/src/components/thumbnail/Thumbnail.tsx +16 -0
package/index.d.ts
CHANGED
|
@@ -1301,6 +1301,8 @@ interface ThumbnailProps extends GenericProps, HasTheme {
|
|
|
1301
1301
|
size?: ThumbnailSize;
|
|
1302
1302
|
/** Image loading mode. */
|
|
1303
1303
|
loading?: ImgHTMLProps['loading'];
|
|
1304
|
+
/** Ref of an existing placeholder image to display while loading. */
|
|
1305
|
+
loadingPlaceholderImageRef?: React.RefObject<HTMLImageElement>;
|
|
1304
1306
|
/** On click callback. */
|
|
1305
1307
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
1306
1308
|
/** On key press callback. */
|
|
@@ -1383,7 +1385,7 @@ interface ZoomButtonProps {
|
|
|
1383
1385
|
/** Zoom out button props */
|
|
1384
1386
|
zoomOutButtonProps?: IconButtonProps;
|
|
1385
1387
|
}
|
|
1386
|
-
type InheritedThumbnailProps = Pick<ThumbnailProps, 'image' | 'alt' | 'imgProps' | 'imgRef'>;
|
|
1388
|
+
type InheritedThumbnailProps = Pick<ThumbnailProps, 'image' | 'alt' | 'imgProps' | 'imgRef' | 'loadingPlaceholderImageRef'>;
|
|
1387
1389
|
type InheritedImageMetadata = Pick<ImageCaptionMetadata, 'title' | 'description' | 'tags'>;
|
|
1388
1390
|
type ImageProps = InheritedThumbnailProps & InheritedImageMetadata;
|
|
1389
1391
|
interface ImagesProps {
|
package/index.js
CHANGED
|
@@ -7687,7 +7687,7 @@ const ImageCaption = props => {
|
|
|
7687
7687
|
as: as,
|
|
7688
7688
|
className: className,
|
|
7689
7689
|
style: captionStyle,
|
|
7690
|
-
orientation: "
|
|
7690
|
+
orientation: "vertical",
|
|
7691
7691
|
vAlign: align,
|
|
7692
7692
|
hAlign: align === 'center' ? align : undefined,
|
|
7693
7693
|
gap: "regular"
|
|
@@ -8411,16 +8411,13 @@ function useImageLightbox(initialProps) {
|
|
|
8411
8411
|
// If we find an image inside the trigger, animate it in transition with the opening image
|
|
8412
8412
|
const triggerImage = ((_triggerImageRefs = triggerImageRefs[activeImageIndex]) === null || _triggerImageRefs === void 0 ? void 0 : _triggerImageRefs.current) || findImage(triggerElement);
|
|
8413
8413
|
|
|
8414
|
-
// Inject the trigger image
|
|
8414
|
+
// Inject the trigger image as loading placeholder for better loading state
|
|
8415
8415
|
const imagesWithFallbackSize = imagesPropsRef.current.map((image, idx) => {
|
|
8416
|
-
|
|
8417
|
-
if (triggerImage && idx === activeImageIndex && !((_image$imgProps = image.imgProps) !== null && _image$imgProps !== void 0 && _image$imgProps.width) && !((_image$imgProps2 = image.imgProps) !== null && _image$imgProps2 !== void 0 && _image$imgProps2.height)) {
|
|
8418
|
-
const imgProps = _objectSpread2(_objectSpread2({}, image.imgProps), {}, {
|
|
8419
|
-
height: triggerImage.naturalHeight,
|
|
8420
|
-
width: triggerImage.naturalWidth
|
|
8421
|
-
});
|
|
8416
|
+
if (triggerImage && idx === activeImageIndex && !image.loadingPlaceholderImageRef) {
|
|
8422
8417
|
return _objectSpread2(_objectSpread2({}, image), {}, {
|
|
8423
|
-
|
|
8418
|
+
loadingPlaceholderImageRef: {
|
|
8419
|
+
current: triggerImage
|
|
8420
|
+
}
|
|
8424
8421
|
});
|
|
8425
8422
|
}
|
|
8426
8423
|
return image;
|
|
@@ -13607,7 +13604,7 @@ const useFocusPointStyle = (_ref2, element, isLoaded) => {
|
|
|
13607
13604
|
return style;
|
|
13608
13605
|
};
|
|
13609
13606
|
|
|
13610
|
-
const _excluded$1p = ["align", "alt", "aspectRatio", "badge", "className", "crossOrigin", "fallback", "fillHeight", "focusPoint", "image", "imgProps", "imgRef", "isLoading", "objectFit", "loading", "size", "theme", "variant", "linkProps", "linkAs"];
|
|
13607
|
+
const _excluded$1p = ["align", "alt", "aspectRatio", "badge", "className", "crossOrigin", "fallback", "fillHeight", "focusPoint", "image", "imgProps", "imgRef", "isLoading", "objectFit", "loading", "loadingPlaceholderImageRef", "size", "theme", "variant", "linkProps", "linkAs"];
|
|
13611
13608
|
|
|
13612
13609
|
/**
|
|
13613
13610
|
* Defines the props of the component.
|
|
@@ -13640,6 +13637,7 @@ const DEFAULT_PROPS$$ = {
|
|
|
13640
13637
|
* @return React element.
|
|
13641
13638
|
*/
|
|
13642
13639
|
const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
|
|
13640
|
+
var _loadingPlaceholderIm;
|
|
13643
13641
|
const {
|
|
13644
13642
|
align,
|
|
13645
13643
|
alt,
|
|
@@ -13658,6 +13656,7 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
13658
13656
|
isLoading: isLoadingProp,
|
|
13659
13657
|
objectFit,
|
|
13660
13658
|
loading,
|
|
13659
|
+
loadingPlaceholderImageRef,
|
|
13661
13660
|
size,
|
|
13662
13661
|
theme,
|
|
13663
13662
|
variant,
|
|
@@ -13698,6 +13697,14 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
13698
13697
|
wrapperProps.type = forwardedProps.type || 'button';
|
|
13699
13698
|
wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;
|
|
13700
13699
|
}
|
|
13700
|
+
|
|
13701
|
+
// If we have a loading placeholder image that is really loaded (complete)
|
|
13702
|
+
const loadingPlaceholderImage = isLoading && (loadingPlaceholderImageRef === null || loadingPlaceholderImageRef === void 0 ? void 0 : (_loadingPlaceholderIm = loadingPlaceholderImageRef.current) === null || _loadingPlaceholderIm === void 0 ? void 0 : _loadingPlaceholderIm.complete) && (loadingPlaceholderImageRef === null || loadingPlaceholderImageRef === void 0 ? void 0 : loadingPlaceholderImageRef.current) || undefined;
|
|
13703
|
+
const loadingStyle = loadingPlaceholderImage ? {
|
|
13704
|
+
backgroundImage: `url(${loadingPlaceholderImage.src})`,
|
|
13705
|
+
minWidth: loadingPlaceholderImage.naturalWidth,
|
|
13706
|
+
minHeight: loadingPlaceholderImage.naturalHeight
|
|
13707
|
+
} : undefined;
|
|
13701
13708
|
return /*#__PURE__*/React.createElement(Wrapper, _extends({}, wrapperProps, {
|
|
13702
13709
|
ref: ref,
|
|
13703
13710
|
className: classnames(linkProps === null || linkProps === void 0 ? void 0 : linkProps.className, className, handleBasicClasses({
|
|
@@ -13718,7 +13725,7 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
13718
13725
|
}), /*#__PURE__*/React.createElement("span", {
|
|
13719
13726
|
className: `${CLASSNAME$1f}__background`
|
|
13720
13727
|
}, /*#__PURE__*/React.createElement("img", _extends({}, imgProps, {
|
|
13721
|
-
style: _objectSpread2(_objectSpread2(_objectSpread2({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style), imageErrorStyle), focusPointStyle),
|
|
13728
|
+
style: _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style), imageErrorStyle), focusPointStyle), loadingStyle),
|
|
13722
13729
|
ref: mergeRefs(setImgElement, propImgRef),
|
|
13723
13730
|
className: classnames(handleBasicClasses({
|
|
13724
13731
|
prefix: `${CLASSNAME$1f}__image`,
|