@lumx/react 3.7.6-alpha.11 → 3.7.6-alpha.13
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 +1 -1
- package/index.js +29 -31
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/image-block/ImageBlock.stories.tsx +74 -63
- package/src/components/image-block/ImageBlock.tsx +1 -0
- package/src/components/image-block/ImageCaption.tsx +6 -6
- package/src/components/image-lightbox/ImageLightbox.test.tsx +2 -1
- package/src/components/image-lightbox/internal/ImageSlide.tsx +3 -3
- package/src/components/image-lightbox/useImageLightbox.tsx +16 -16
- package/src/components/thumbnail/Thumbnail.stories.tsx +5 -3
- package/src/components/thumbnail/Thumbnail.tsx +5 -5
package/index.d.ts
CHANGED
|
@@ -1426,7 +1426,7 @@ declare function useImageLightbox<P extends Partial<ImageLightboxProps>>(initial
|
|
|
1426
1426
|
ref: React.Ref<any>;
|
|
1427
1427
|
};
|
|
1428
1428
|
/** Props to forward to the ImageLightbox */
|
|
1429
|
-
imageLightboxProps:
|
|
1429
|
+
imageLightboxProps: ManagedProps & P;
|
|
1430
1430
|
};
|
|
1431
1431
|
|
|
1432
1432
|
/**
|
package/index.js
CHANGED
|
@@ -7672,7 +7672,7 @@ const ImageCaption = props => {
|
|
|
7672
7672
|
const titleColor = {
|
|
7673
7673
|
color: theme === 'dark' ? 'light' : 'dark'
|
|
7674
7674
|
};
|
|
7675
|
-
const
|
|
7675
|
+
const baseColor = {
|
|
7676
7676
|
color: theme === 'dark' ? 'light' : 'dark',
|
|
7677
7677
|
colorVariant: 'L2'
|
|
7678
7678
|
};
|
|
@@ -7691,16 +7691,16 @@ const ImageCaption = props => {
|
|
|
7691
7691
|
vAlign: align,
|
|
7692
7692
|
hAlign: align === 'center' ? align : undefined,
|
|
7693
7693
|
gap: "regular"
|
|
7694
|
-
}, (title || description) && /*#__PURE__*/React.createElement(Text, {
|
|
7694
|
+
}, (title || description) && /*#__PURE__*/React.createElement(Text, _extends({
|
|
7695
7695
|
as: "p",
|
|
7696
7696
|
truncate: truncate
|
|
7697
|
-
}, title && /*#__PURE__*/React.createElement(Text, _extends({
|
|
7697
|
+
}, baseColor), title && /*#__PURE__*/React.createElement(Text, _extends({
|
|
7698
7698
|
as: "span",
|
|
7699
7699
|
typography: "subtitle1"
|
|
7700
7700
|
}, titleColor), title), ' ', description && /*#__PURE__*/React.createElement(Text, _extends({
|
|
7701
7701
|
as: "span",
|
|
7702
7702
|
typography: "body1"
|
|
7703
|
-
},
|
|
7703
|
+
}, descriptionContent))), tags && /*#__PURE__*/React.createElement(FlexBox, {
|
|
7704
7704
|
orientation: "horizontal",
|
|
7705
7705
|
vAlign: align
|
|
7706
7706
|
}, tags));
|
|
@@ -7787,6 +7787,7 @@ const ImageBlock = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7787
7787
|
theme: theme,
|
|
7788
7788
|
alt: alt || title
|
|
7789
7789
|
})), /*#__PURE__*/React.createElement(ImageCaption, {
|
|
7790
|
+
as: "figcaption",
|
|
7790
7791
|
className: `${CLASSNAME$u}__wrapper`,
|
|
7791
7792
|
theme: theme,
|
|
7792
7793
|
title: title,
|
|
@@ -8082,11 +8083,11 @@ const ImageSlide = /*#__PURE__*/React.memo(props => {
|
|
|
8082
8083
|
// Get image size
|
|
8083
8084
|
const imgRef = React.useRef(null);
|
|
8084
8085
|
const imageSize = useImageSize(imgRef, () => {
|
|
8085
|
-
const
|
|
8086
|
-
const
|
|
8087
|
-
return
|
|
8088
|
-
width
|
|
8089
|
-
height
|
|
8086
|
+
const width = Number.parseInt(imgProps === null || imgProps === void 0 ? void 0 : imgProps.width, 10);
|
|
8087
|
+
const height = Number.parseInt(imgProps === null || imgProps === void 0 ? void 0 : imgProps.height, 10);
|
|
8088
|
+
return width && height ? {
|
|
8089
|
+
width,
|
|
8090
|
+
height
|
|
8090
8091
|
} : null;
|
|
8091
8092
|
});
|
|
8092
8093
|
|
|
@@ -8360,10 +8361,6 @@ function useImageLightbox(initialProps) {
|
|
|
8360
8361
|
images = []
|
|
8361
8362
|
} = initialProps,
|
|
8362
8363
|
otherProps = _objectWithoutProperties(initialProps, _excluded$A);
|
|
8363
|
-
const basePropsRef = React.useRef(EMPTY_PROPS);
|
|
8364
|
-
React.useEffect(() => {
|
|
8365
|
-
basePropsRef.current = _objectSpread2(_objectSpread2({}, EMPTY_PROPS), otherProps);
|
|
8366
|
-
}, [otherProps]);
|
|
8367
8364
|
const imagesPropsRef = React.useRef(images);
|
|
8368
8365
|
React.useEffect(() => {
|
|
8369
8366
|
imagesPropsRef.current = images.map(props => _objectSpread2({
|
|
@@ -8371,10 +8368,10 @@ function useImageLightbox(initialProps) {
|
|
|
8371
8368
|
}, props));
|
|
8372
8369
|
}, [images]);
|
|
8373
8370
|
const currentImageRef = React.useRef(null);
|
|
8374
|
-
const [imageLightboxProps, setImageLightboxProps] = React.useState(
|
|
8371
|
+
const [imageLightboxProps, setImageLightboxProps] = React.useState(() => _objectSpread2(_objectSpread2({}, EMPTY_PROPS), otherProps));
|
|
8375
8372
|
const getTriggerProps = React.useMemo(() => {
|
|
8376
8373
|
const triggerImageRefs = {};
|
|
8377
|
-
async function
|
|
8374
|
+
async function close() {
|
|
8378
8375
|
const currentImage = currentImageRef.current;
|
|
8379
8376
|
if (!currentImage) {
|
|
8380
8377
|
return;
|
|
@@ -8387,15 +8384,10 @@ function useImageLightbox(initialProps) {
|
|
|
8387
8384
|
});
|
|
8388
8385
|
await startViewTransition({
|
|
8389
8386
|
changes() {
|
|
8390
|
-
// Close lightbox
|
|
8391
|
-
setImageLightboxProps(
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
} = _ref2;
|
|
8395
|
-
return _objectSpread2(_objectSpread2({}, basePropsRef.current), {}, {
|
|
8396
|
-
parentElement
|
|
8397
|
-
});
|
|
8398
|
-
});
|
|
8387
|
+
// Close lightbox
|
|
8388
|
+
setImageLightboxProps(prevProps => _objectSpread2(_objectSpread2({}, prevProps), {}, {
|
|
8389
|
+
isOpen: false
|
|
8390
|
+
}));
|
|
8399
8391
|
},
|
|
8400
8392
|
// Morph from the image in lightbox to the image in trigger
|
|
8401
8393
|
viewTransitionName: {
|
|
@@ -8405,7 +8397,7 @@ function useImageLightbox(initialProps) {
|
|
|
8405
8397
|
}
|
|
8406
8398
|
});
|
|
8407
8399
|
}
|
|
8408
|
-
async function
|
|
8400
|
+
async function open(triggerElement) {
|
|
8409
8401
|
var _triggerImageRefs;
|
|
8410
8402
|
let {
|
|
8411
8403
|
activeImageIndex
|
|
@@ -8427,13 +8419,17 @@ function useImageLightbox(initialProps) {
|
|
|
8427
8419
|
await startViewTransition({
|
|
8428
8420
|
changes: () => {
|
|
8429
8421
|
// Open lightbox with setup props
|
|
8430
|
-
setImageLightboxProps(_objectSpread2(_objectSpread2({},
|
|
8422
|
+
setImageLightboxProps(prevProps => _objectSpread2(_objectSpread2({}, prevProps), {}, {
|
|
8431
8423
|
activeImageRef: currentImageRef,
|
|
8432
8424
|
parentElement: {
|
|
8433
8425
|
current: triggerElement
|
|
8434
8426
|
},
|
|
8435
8427
|
isOpen: true,
|
|
8436
|
-
onClose:
|
|
8428
|
+
onClose: () => {
|
|
8429
|
+
var _prevProps$onClose;
|
|
8430
|
+
close();
|
|
8431
|
+
prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$onClose = prevProps.onClose) === null || _prevProps$onClose === void 0 ? void 0 : _prevProps$onClose.call(prevProps);
|
|
8432
|
+
},
|
|
8437
8433
|
images: imagesWithFallbackSize,
|
|
8438
8434
|
activeImageIndex: activeImageIndex || 0
|
|
8439
8435
|
}));
|
|
@@ -8456,7 +8452,7 @@ function useImageLightbox(initialProps) {
|
|
|
8456
8452
|
}
|
|
8457
8453
|
},
|
|
8458
8454
|
onClick(e) {
|
|
8459
|
-
|
|
8455
|
+
open(e.target, options);
|
|
8460
8456
|
}
|
|
8461
8457
|
}));
|
|
8462
8458
|
}, []);
|
|
@@ -13702,10 +13698,10 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
13702
13698
|
|
|
13703
13699
|
// If we have a loading placeholder image that is really loaded (complete)
|
|
13704
13700
|
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;
|
|
13701
|
+
|
|
13702
|
+
// Set loading placeholder image as background
|
|
13705
13703
|
const loadingStyle = loadingPlaceholderImage ? {
|
|
13706
|
-
backgroundImage: `url(${loadingPlaceholderImage.src})
|
|
13707
|
-
minWidth: loadingPlaceholderImage.naturalWidth,
|
|
13708
|
-
minHeight: loadingPlaceholderImage.naturalHeight
|
|
13704
|
+
backgroundImage: `url(${loadingPlaceholderImage.src})`
|
|
13709
13705
|
} : undefined;
|
|
13710
13706
|
return /*#__PURE__*/React.createElement(Wrapper, _extends({}, wrapperProps, {
|
|
13711
13707
|
ref: ref,
|
|
@@ -13727,6 +13723,8 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
13727
13723
|
}), /*#__PURE__*/React.createElement("span", {
|
|
13728
13724
|
className: `${CLASSNAME$1f}__background`
|
|
13729
13725
|
}, /*#__PURE__*/React.createElement("img", _extends({}, imgProps, {
|
|
13726
|
+
width: (imgProps === null || imgProps === void 0 ? void 0 : imgProps.width) || (loadingPlaceholderImage === null || loadingPlaceholderImage === void 0 ? void 0 : loadingPlaceholderImage.naturalWidth),
|
|
13727
|
+
height: (imgProps === null || imgProps === void 0 ? void 0 : imgProps.height) || (loadingPlaceholderImage === null || loadingPlaceholderImage === void 0 ? void 0 : loadingPlaceholderImage.naturalHeight),
|
|
13730
13728
|
style: _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style), imageErrorStyle), focusPointStyle), loadingStyle),
|
|
13731
13729
|
ref: mergeRefs(setImgElement, propImgRef),
|
|
13732
13730
|
className: classnames(handleBasicClasses({
|