@wonderflow/react-components 14.2.4 → 14.2.6

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
- }, [preloadImages, source]);
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
@@ -1 +1 @@
1
- {"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EACA,iBAAiB,EAE9B,MAAM,OAAO,CAAC;AASf,OAAO,EAAqB,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAC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EAAE,wBAAwB,CAAC;IAC/B,MAAM,EAAE,0BAA0B,CAAC;IACnC,MAAM,EAAE,0BAA0B,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,WAAW,sBAwLE,CAAC"}
1
+ {"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EACA,iBAAiB,EAE9B,MAAM,OAAO,CAAC;AASf,OAAO,EAAqB,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAC1G,OAAO,EAAqB,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAClI,OAAO,EAAmB,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AACxH,OAAO,EAAoB,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAE7H,oBAAY,gBAAgB,GAAG,cAAc,CAAC,iBAAiB,CAAC;IAC9D;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC,CAAC,GACD,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,QAAQ,CAAC,GAC/C,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,aAAa,CAAC,GAChF,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,eAAe,GAAG,YAAY,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAC9O,kBAAkB,CAAC,CAAA;AAuBnB,oBAAY,oBAAoB,GAAG,KAAK,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,GAAG;IACrF,KAAK,EAAE,yBAAyB,CAAC;IACjC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,MAAM,EAAE,0BAA0B,CAAC;IACnC,MAAM,EAAE,0BAA0B,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,WAAW,sBA0LE,CAAC"}
@@ -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
@@ -52,7 +52,7 @@ export const ProductCard = forwardRef(({ direction = 'vertical', bordered = fals
52
52
  return ({});
53
53
  };
54
54
  const deboucedStyle = useDebounce(mediaSizeStyle(direction), { wait: 500 });
55
- return (_jsx(Elevator, { resting: 1, hover: hasHighlight ? 2 : undefined, children: _jsx(Stack, { ref: forwardedRef, className: clsx(styles.Card, className), style: { ...style }, "data-card-bordered": bordered, "data-card-clickable": isClickable, onClick: isLoading ? undefined : onClick, ...otherProps, children: _jsxs(Stack, { "data-inner-element": "ProductCard-Container", direction: "row", className: styles.Row, fill: false, ref: containerRef, children: [hasOverlay && (_jsx(Stack, { direction: "row", hPadding: 24, vAlign: "center", hAlign: "center", className: styles.OverlayActions, "data-inner-element": "ProductCard-OverlayActions", children: _jsx(Stack, { children: overlayActions }) })), _jsxs(Stack, { "data-inner-element": "ProductCard-Group", direction: (direction === 'vertical') ? 'column' : 'row', className: styles.Content, children: [hasColoredCover && !source?.length && (_jsx(Stack, { className: styles.ColoredCard, style: { backgroundColor: `${getColorFromString(title ?? '')}` }, hAlign: "center", vAlign: "center", fill: false, children: _jsx(Text, { variant: "heading-1", textAlign: "center", style: { color: '#fff' }, children: title?.slice(0, 2) }) })), _jsx(ProductCard.Media, { source: source, isLoading: isLoading, ratio: ratio, "data-inner-element": "ProductCard-Media", style: deboucedStyle }), _jsxs(Stack, { direction: "column", children: [_jsx(ProductCard.Header, { "data-inner-element": "ProductCard-Header", title: title, titleRows: titleRows, subtitle: subtitle, isLoading: isLoading, menuActions: hasMenu && menuActions }), _jsx(ProductCardKpis, { "data-inner-element": "ProductCard-Kpis", rating: rating, feedbackCount: feedbackCount, votesCount: votesCount, votesRating: votesRating, sentiment: sentiment, nps: nps, groups: groups, tgw: tgw, priceMin: priceMin, priceMax: priceMax, currency: currency, currencyDecimals: currencyDecimals, users: users, usersCap: usersCap, skus: skus, skusCap: skusCap, isLoading: isLoading, kpiItems: kpiItems, kpisRowGap: kpisRowGap }), children && !isLoading && (_jsx(Stack, { hPadding: 24, "data-inner-element": "ProductCard-Children", children: children })), _jsx(ProductCard.Footer, { isLoading: isLoading, "data-inner-element": "ProductCard-Footer", children: footer })] })] })] }) }) }));
55
+ return (_jsx(Elevator, { resting: 1, hover: hasHighlight ? 2 : undefined, children: _jsx(Stack, { ref: forwardedRef, className: clsx(styles.Card, className), style: { ...style }, "data-card-bordered": bordered, "data-card-clickable": isClickable, onClick: isLoading ? undefined : onClick, ...otherProps, children: _jsxs(Stack, { "data-inner-element": "ProductCard-Container", direction: "row", className: styles.Row, fill: false, ref: containerRef, children: [hasOverlay && (_jsx(Stack, { direction: "row", hPadding: 24, vAlign: "center", hAlign: "center", className: styles.OverlayActions, "data-inner-element": "ProductCard-OverlayActions", children: _jsx(Stack, { children: overlayActions }) })), _jsxs(Stack, { "data-inner-element": "ProductCard-Group", direction: (direction === 'vertical') ? 'column' : 'row', className: styles.Content, children: [hasColoredCover && !source?.length && (_jsx(Stack, { className: styles.ColoredCard, style: { backgroundColor: `${getColorFromString(title ?? '')}` }, hAlign: "center", vAlign: "center", fill: false, children: _jsx(Text, { variant: "heading-1", textAlign: "center", style: { color: '#fff' }, children: title?.slice(0, 2) }) })), !hasColoredCover && source && (_jsx(ProductCard.Media, { source: source, isLoading: isLoading, ratio: ratio, "data-inner-element": "ProductCard-Media", style: deboucedStyle })), _jsxs(Stack, { direction: "column", children: [_jsx(ProductCard.Header, { "data-inner-element": "ProductCard-Header", title: title, titleRows: titleRows, subtitle: subtitle, isLoading: isLoading, menuActions: hasMenu && menuActions }), _jsx(ProductCardKpis, { "data-inner-element": "ProductCard-Kpis", rating: rating, feedbackCount: feedbackCount, votesCount: votesCount, votesRating: votesRating, sentiment: sentiment, nps: nps, groups: groups, tgw: tgw, priceMin: priceMin, priceMax: priceMax, currency: currency, currencyDecimals: currencyDecimals, users: users, usersCap: usersCap, skus: skus, skusCap: skusCap, isLoading: isLoading, kpiItems: kpiItems, kpisRowGap: kpisRowGap }), children && !isLoading && (_jsx(Stack, { hPadding: 24, "data-inner-element": "ProductCard-Children", children: children })), _jsx(ProductCard.Footer, { isLoading: isLoading, "data-inner-element": "ProductCard-Footer", children: footer })] })] })] }) }) }));
56
56
  });
57
57
  ProductCard.displayName = 'ProductCard';
58
58
  ProductCard.Media = ProductCardMedia;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "14.2.4",
3
+ "version": "14.2.6",
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.4",
86
- "@wonderflow/tokens": "14.2.4",
87
- "@wonderflow/charts": "14.2.4",
85
+ "@wonderflow/config": "14.2.6",
86
+ "@wonderflow/tokens": "14.2.6",
87
+ "@wonderflow/charts": "14.2.6",
88
88
  "@types/uuid": "9.0.8",
89
89
  "babel-loader": "8.2.5",
90
90
  "cpy-cli": "3.1.1",