@lumx/react 3.7.6-alpha.14 → 3.7.6-alpha.16

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/package.json CHANGED
@@ -6,9 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@juggle/resize-observer": "^3.2.0",
10
- "@lumx/core": "^3.7.6-alpha.14",
11
- "@lumx/icons": "^3.7.6-alpha.14",
9
+ "@lumx/core": "^3.7.6-alpha.16",
10
+ "@lumx/icons": "^3.7.6-alpha.16",
12
11
  "@popperjs/core": "^2.5.4",
13
12
  "body-scroll-lock": "^3.1.5",
14
13
  "classnames": "^2.3.2",
@@ -112,5 +111,5 @@
112
111
  "build:storybook": "storybook build"
113
112
  },
114
113
  "sideEffects": false,
115
- "version": "3.7.6-alpha.14"
114
+ "version": "3.7.6-alpha.16"
116
115
  }
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { SlideshowItem, Thumbnail } from '@lumx/react';
4
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
4
+ import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
5
5
  import { useElementSizeDependentOfWindowSize } from '@lumx/react/hooks/useElementSizeDependentOfWindowSize';
6
6
  import { useImageSize } from '@lumx/react/hooks/useImageSize';
7
- import { getPrefersReducedMotion } from '@lumx/react/utils/getPrefersReducedMotion';
7
+ import { getPrefersReducedMotion } from '@lumx/react/utils/browser/getPrefersReducedMotion';
8
8
  import { isEqual } from '@lumx/react/utils/object/isEqual';
9
9
 
10
10
  import { CLASSNAME } from '../constants';
@@ -84,7 +84,7 @@ export const ImageSlide = React.memo((props: ImageSlideProps) => {
84
84
  className={`${CLASSNAME}__image-slide`}
85
85
  >
86
86
  <Thumbnail
87
- imgRef={mergeRefs(imgRef, propImgRef)}
87
+ imgRef={useMergeRefs(imgRef, propImgRef)}
88
88
  image={image}
89
89
  alt={alt}
90
90
  className={`${CLASSNAME}__thumbnail`}
@@ -2,8 +2,8 @@ import React from 'react';
2
2
 
3
3
  import memoize from 'lodash/memoize';
4
4
 
5
- import { startViewTransition } from '@lumx/react/utils/startViewTransition';
6
- import { findImage } from '@lumx/react/utils/findImage';
5
+ import { startViewTransition } from '@lumx/react/utils/DOM/startViewTransition';
6
+ import { findImage } from '@lumx/react/utils/DOM/findImage';
7
7
 
8
8
  import type { ImageLightboxProps } from './types';
9
9
  import { CLASSNAME } from './constants';
@@ -24,7 +24,6 @@ import { withNestedProps } from '@lumx/react/stories/decorators/withNestedProps'
24
24
  import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
25
25
  import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
26
26
 
27
-
28
27
  const aligns = [Alignment.center, Alignment.left, Alignment.right];
29
28
  const variants = [ThumbnailVariant.squared, ThumbnailVariant.rounded];
30
29
 
@@ -430,14 +429,16 @@ export const LoadingPlaceholderImage = () => {
430
429
  <FlexBox orientation="horizontal">
431
430
  <Thumbnail alt="Small image" imgRef={imgRef} image="https://picsum.photos/id/15/128/85" />
432
431
  {isShown && (
433
- <Thumbnail
434
- image={`https://picsum.photos/id/15/2500/1667?cacheBust${uniqueId()}`}
435
- alt="Large image"
436
- // Loading placeholder image
437
- loadingPlaceholderImageRef={imgRef}
438
- // Reserve space
439
- imgProps={{ width: 2500, height: 1667 }}
440
- />
432
+ <div style={{ maxHeight: 400 }}>
433
+ <Thumbnail
434
+ image={`https://picsum.photos/id/15/2500/1667?cacheBust${uniqueId()}`}
435
+ alt="Large image"
436
+ // Loading placeholder image
437
+ loadingPlaceholderImageRef={imgRef}
438
+ // Reserve space
439
+ imgProps={{ width: 2500, height: 1667 }}
440
+ />
441
+ </div>
441
442
  )}
442
443
  </FlexBox>
443
444
  </>
@@ -17,7 +17,7 @@ import { Comp, Falsy, GenericProps, HasTheme } from '@lumx/react/utils/type';
17
17
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
18
18
 
19
19
  import { mdiImageBroken } from '@lumx/icons';
20
- import { mergeRefs, useMergeRefs } from '@lumx/react/utils/mergeRefs';
20
+ import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
21
21
  import { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';
22
22
  import { useFocusPointStyle } from '@lumx/react/components/thumbnail/useFocusPointStyle';
23
23
  import { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';
@@ -199,21 +199,24 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
199
199
  >
200
200
  <span className={`${CLASSNAME}__background`}>
201
201
  <img
202
+ // Use placeholder image size
202
203
  width={loadingPlaceholderImage?.naturalWidth}
203
204
  height={loadingPlaceholderImage?.naturalHeight}
204
205
  {...imgProps}
205
206
  style={{
207
+ // Reserve space while loading (when possible)
208
+ width: isLoading ? imgProps?.width || loadingPlaceholderImage?.naturalWidth : undefined,
206
209
  ...imgProps?.style,
207
210
  ...imageErrorStyle,
208
211
  ...focusPointStyle,
209
212
  ...loadingStyle,
210
213
  }}
211
- ref={mergeRefs(setImgElement, propImgRef)}
214
+ ref={useMergeRefs(setImgElement, propImgRef)}
212
215
  className={classNames(
213
216
  handleBasicClasses({
214
217
  prefix: `${CLASSNAME}__image`,
215
218
  isLoading,
216
- hasDefinedSize: !isLoading && Boolean(imgProps?.height && imgProps.width),
219
+ hasDefinedSize: Boolean(imgProps?.height && imgProps.width),
217
220
  }),
218
221
  imgProps?.className,
219
222
  )}
@@ -1,7 +1,9 @@
1
1
  import ReactDOM from 'react-dom';
2
- import { getPrefersReducedMotion } from '@lumx/react/utils/getPrefersReducedMotion';
2
+
3
3
  import { MaybeElementOrRef } from '@lumx/react/utils/type';
4
- import { unref } from '@lumx/react/utils/unref';
4
+
5
+ import { unref } from '../react/unref';
6
+ import { getPrefersReducedMotion } from '../browser/getPrefersReducedMotion';
5
7
 
6
8
  function setTransitionViewName(elementRef: MaybeElementOrRef<HTMLElement>, name: string | null | undefined) {
7
9
  const element = unref(elementRef) as any;
@@ -1,6 +1,6 @@
1
1
  import { isEqual } from './isEqual';
2
2
 
3
- test(isEqual, () => {
3
+ test(isEqual.name, () => {
4
4
  expect(isEqual('', '')).toBe(true);
5
5
  expect(isEqual(0, 0)).toBe(true);
6
6
  expect(isEqual(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)).toBe(true);
@@ -0,0 +1,7 @@
1
+ import { MaybeElementOrRef } from '@lumx/react/utils/type';
2
+
3
+ /** Unref a react ref or element */
4
+ export function unref(maybeElement: MaybeElementOrRef<HTMLElement>) {
5
+ if (maybeElement instanceof HTMLElement) return maybeElement;
6
+ return maybeElement?.current;
7
+ }
@@ -1,6 +0,0 @@
1
- import { MaybeElementOrRef } from '@lumx/react/utils/type';
2
-
3
- export function unref(maybeElement: MaybeElementOrRef<HTMLElement>) {
4
- if (maybeElement instanceof HTMLElement) return maybeElement;
5
- return maybeElement?.current;
6
- }
File without changes