@wonderflow/react-components 14.2.5 → 14.3.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"product-card-media.d.ts","sourceRoot":"","sources":["../../../../src/components/product-card/product-card-media/product-card-media.tsx"],"names":[],"mappings":";AA6BA,oBAAY,qBAAqB,GAAG,cAAc,CAAC;IACjD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC,CAAA;AAEF,oBAAY,yBAAyB,GAAG,KAAK,CAAC,yBAAyB,CAAC,qBAAqB,CAAC,CAAA;AAQ9F,eAAO,MAAM,gBAAgB,2BAsFE,CAAC"}
1
+ {"version":3,"file":"product-card-media.d.ts","sourceRoot":"","sources":["../../../../src/components/product-card/product-card-media/product-card-media.tsx"],"names":[],"mappings":";AA6BA,oBAAY,qBAAqB,GAAG,cAAc,CAAC;IACjD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC,CAAA;AAEF,oBAAY,yBAAyB,GAAG,KAAK,CAAC,yBAAyB,CAAC,qBAAqB,CAAC,CAAA;AAQ9F,eAAO,MAAM,gBAAgB,2BAiFE,CAAC"}
@@ -19,19 +19,18 @@ import { AspectRatio, Grid, Skeleton, } from '../../..';
19
19
  import * as styles from './product-card-media.module.css';
20
20
  export const ProductCardMedia = forwardRef(({ source = [], ratio = '1', isLoading = false, className, style, ...otherProps }, forwardedRef) => {
21
21
  const [imgs, setImgs] = useState([]);
22
- const preloadImage = async (url) => new Promise((resolve) => {
23
- const img = new Image();
24
- const placeholder = 'https://wonderimages.gumlet.io/placeholders/image-placeholder.png';
25
- img.src = url;
26
- img.onload = () => resolve(url);
27
- img.onerror = () => resolve(placeholder);
28
- img.onabort = () => resolve(placeholder);
29
- });
30
- // eslint-disable-next-line react-hooks/exhaustive-deps
31
- const preloadImages = async (source) => {
22
+ useEffect(() => {
23
+ const preloadImage = async (url) => new Promise((resolve) => {
24
+ const img = new Image();
25
+ const placeholder = 'https://wonderimages.gumlet.io/placeholders/image-placeholder.png';
26
+ img.src = url;
27
+ img.onload = () => resolve(url);
28
+ img.onerror = () => resolve(placeholder);
29
+ img.onabort = () => resolve(placeholder);
30
+ });
32
31
  const images = source.slice(0, 4).map(async (s) => preloadImage(s));
33
- try {
34
- const urls = await Promise.all(images);
32
+ Promise.all(images)
33
+ .then((urls) => {
35
34
  const t = urls.map((el, i) => ({
36
35
  row: i < 2 ? '1' : '2',
37
36
  col: i % 2 === 0 ? '1' : '2',
@@ -40,15 +39,11 @@ export const ProductCardMedia = forwardRef(({ source = [], ratio = '1', isLoadin
40
39
  if (t.length === 3)
41
40
  t[1].row = '1 / 3';
42
41
  setImgs(t);
43
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
- }
45
- catch (err) {
46
- setImgs([]);
47
- }
48
- };
49
- useEffect(() => {
50
- void preloadImages(source);
51
- }, [source, preloadImages]);
42
+ })
43
+ // eslint-disable-next-line no-console
44
+ .catch(err => console.error(err));
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ }, []);
52
47
  if (source.length === 0)
53
48
  return null;
54
49
  return (_jsx("div", { ref: forwardedRef, className: className, style: { ...style }, ...otherProps, children: _jsx(AspectRatio, { ratio: ratio, children: isLoading
@@ -18,7 +18,7 @@ const getColorFromString = (input) => {
18
18
  hash = input.charCodeAt(i) + ((hash << 5) - hash);
19
19
  }
20
20
  // Get all color keys
21
- const colorKeys = Object.keys(colorPalette);
21
+ const colorKeys = Object.keys(colorPalette).filter((color) => color !== 'support');
22
22
  // Pick a color family based on the hash
23
23
  const colorFamily = colorKeys[Math.abs(hash) % colorKeys.length];
24
24
  // Return the first shade of the selected color family
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "14.2.5",
3
+ "version": "14.3.0",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "Apache-2.0",
@@ -82,9 +82,9 @@
82
82
  "@types/react-dom": "17.0.14",
83
83
  "@types/react-table": "7.7.20",
84
84
  "@types/react-test-renderer": "18.0.7",
85
- "@wonderflow/config": "14.2.5",
86
- "@wonderflow/tokens": "14.2.5",
87
- "@wonderflow/charts": "14.2.5",
85
+ "@wonderflow/config": "14.3.0",
86
+ "@wonderflow/tokens": "14.3.0",
87
+ "@wonderflow/charts": "14.3.0",
88
88
  "@types/uuid": "9.0.8",
89
89
  "babel-loader": "8.2.5",
90
90
  "cpy-cli": "3.1.1",