@lumx/react 3.7.6-alpha.7 → 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 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
@@ -7655,35 +7655,27 @@ Icon.displayName = COMPONENT_NAME$w;
7655
7655
  Icon.className = CLASSNAME$t;
7656
7656
  Icon.defaultProps = DEFAULT_PROPS$p;
7657
7657
 
7658
- /**
7659
- * Component display name.
7660
- */
7661
- const COMPONENT_NAME$x = 'ImageBlock';
7662
-
7663
- /**
7664
- * Component default class name and class prefix.
7665
- */
7666
- const CLASSNAME$u = getRootClassName(COMPONENT_NAME$x);
7667
-
7668
7658
  /** Internal component used to render image captions */
7669
7659
  const ImageCaption = props => {
7670
7660
  const {
7661
+ className,
7671
7662
  theme,
7672
7663
  as = 'figcaption',
7673
7664
  title,
7674
7665
  description,
7675
7666
  tags,
7676
7667
  captionStyle,
7677
- align
7668
+ align,
7669
+ truncate
7678
7670
  } = props;
7679
7671
  if (!title && !description && !tags) return null;
7680
- const titleColor = theme === 'dark' ? {
7681
- color: 'light'
7682
- } : undefined;
7683
- const descriptionColor = theme === 'dark' ? {
7684
- color: 'light',
7672
+ const titleColor = {
7673
+ color: theme === 'dark' ? 'light' : 'dark'
7674
+ };
7675
+ const descriptionColor = {
7676
+ color: theme === 'dark' ? 'light' : 'dark',
7685
7677
  colorVariant: 'L2'
7686
- } : undefined;
7678
+ };
7687
7679
 
7688
7680
  // Display description as string or HTML
7689
7681
  const descriptionContent = typeof description === 'string' ? {
@@ -7693,22 +7685,24 @@ const ImageCaption = props => {
7693
7685
  };
7694
7686
  return /*#__PURE__*/React.createElement(FlexBox, {
7695
7687
  as: as,
7696
- className: `${CLASSNAME$u}__wrapper`,
7688
+ className: className,
7697
7689
  style: captionStyle,
7698
- orientation: "horizontal",
7699
- vAlign: align
7700
- }, (title || description) && /*#__PURE__*/React.createElement("div", {
7701
- className: `${CLASSNAME$u}__caption`
7690
+ orientation: "vertical",
7691
+ vAlign: align,
7692
+ hAlign: align === 'center' ? align : undefined,
7693
+ gap: "regular"
7694
+ }, (title || description) && /*#__PURE__*/React.createElement(Text, {
7695
+ as: "p",
7696
+ truncate: truncate
7702
7697
  }, title && /*#__PURE__*/React.createElement(Text, _extends({
7703
7698
  as: "span",
7704
- className: `${CLASSNAME$u}__title`
7705
- }, titleColor), title), title && description && '\u00A0', description && /*#__PURE__*/React.createElement(Text, _extends({
7699
+ typography: "subtitle1"
7700
+ }, titleColor), title), ' ', description && /*#__PURE__*/React.createElement(Text, _extends({
7706
7701
  as: "span",
7707
- className: `${CLASSNAME$u}__description`
7702
+ typography: "body1"
7708
7703
  }, descriptionColor, descriptionContent))), tags && /*#__PURE__*/React.createElement(FlexBox, {
7709
7704
  orientation: "horizontal",
7710
- vAlign: align,
7711
- className: `${CLASSNAME$u}__tags`
7705
+ vAlign: align
7712
7706
  }, tags));
7713
7707
  };
7714
7708
 
@@ -7730,6 +7724,16 @@ const ImageBlockCaptionPosition = {
7730
7724
  * Defines the props of the component.
7731
7725
  */
7732
7726
 
7727
+ /**
7728
+ * Component display name.
7729
+ */
7730
+ const COMPONENT_NAME$x = 'ImageBlock';
7731
+
7732
+ /**
7733
+ * Component default class name and class prefix.
7734
+ */
7735
+ const CLASSNAME$u = getRootClassName(COMPONENT_NAME$x);
7736
+
7733
7737
  /**
7734
7738
  * Component default props.
7735
7739
  */
@@ -7783,11 +7787,14 @@ const ImageBlock = /*#__PURE__*/forwardRef((props, ref) => {
7783
7787
  theme: theme,
7784
7788
  alt: alt || title
7785
7789
  })), /*#__PURE__*/React.createElement(ImageCaption, {
7790
+ className: `${CLASSNAME$u}__wrapper`,
7791
+ theme: theme,
7786
7792
  title: title,
7787
7793
  description: description,
7788
7794
  tags: tags,
7789
7795
  captionStyle: captionStyle,
7790
- align: align
7796
+ align: align,
7797
+ truncate: captionPosition === 'over'
7791
7798
  }), actions && /*#__PURE__*/React.createElement("div", {
7792
7799
  className: `${CLASSNAME$u}__actions`
7793
7800
  }, actions));
@@ -8404,16 +8411,13 @@ function useImageLightbox(initialProps) {
8404
8411
  // If we find an image inside the trigger, animate it in transition with the opening image
8405
8412
  const triggerImage = ((_triggerImageRefs = triggerImageRefs[activeImageIndex]) === null || _triggerImageRefs === void 0 ? void 0 : _triggerImageRefs.current) || findImage(triggerElement);
8406
8413
 
8407
- // Inject the trigger image size as a fallback for better loading state
8414
+ // Inject the trigger image as loading placeholder for better loading state
8408
8415
  const imagesWithFallbackSize = imagesPropsRef.current.map((image, idx) => {
8409
- var _image$imgProps, _image$imgProps2;
8410
- 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)) {
8411
- const imgProps = _objectSpread2(_objectSpread2({}, image.imgProps), {}, {
8412
- height: triggerImage.naturalHeight,
8413
- width: triggerImage.naturalWidth
8414
- });
8416
+ if (triggerImage && idx === activeImageIndex && !image.loadingPlaceholderImageRef) {
8415
8417
  return _objectSpread2(_objectSpread2({}, image), {}, {
8416
- imgProps
8418
+ loadingPlaceholderImageRef: {
8419
+ current: triggerImage
8420
+ }
8417
8421
  });
8418
8422
  }
8419
8423
  return image;
@@ -13600,7 +13604,7 @@ const useFocusPointStyle = (_ref2, element, isLoaded) => {
13600
13604
  return style;
13601
13605
  };
13602
13606
 
13603
- 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"];
13604
13608
 
13605
13609
  /**
13606
13610
  * Defines the props of the component.
@@ -13633,6 +13637,7 @@ const DEFAULT_PROPS$$ = {
13633
13637
  * @return React element.
13634
13638
  */
13635
13639
  const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
13640
+ var _loadingPlaceholderIm;
13636
13641
  const {
13637
13642
  align,
13638
13643
  alt,
@@ -13651,6 +13656,7 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
13651
13656
  isLoading: isLoadingProp,
13652
13657
  objectFit,
13653
13658
  loading,
13659
+ loadingPlaceholderImageRef,
13654
13660
  size,
13655
13661
  theme,
13656
13662
  variant,
@@ -13691,6 +13697,14 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
13691
13697
  wrapperProps.type = forwardedProps.type || 'button';
13692
13698
  wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;
13693
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;
13694
13708
  return /*#__PURE__*/React.createElement(Wrapper, _extends({}, wrapperProps, {
13695
13709
  ref: ref,
13696
13710
  className: classnames(linkProps === null || linkProps === void 0 ? void 0 : linkProps.className, className, handleBasicClasses({
@@ -13711,7 +13725,7 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
13711
13725
  }), /*#__PURE__*/React.createElement("span", {
13712
13726
  className: `${CLASSNAME$1f}__background`
13713
13727
  }, /*#__PURE__*/React.createElement("img", _extends({}, imgProps, {
13714
- 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),
13715
13729
  ref: mergeRefs(setImgElement, propImgRef),
13716
13730
  className: classnames(handleBasicClasses({
13717
13731
  prefix: `${CLASSNAME$1f}__image`,