@wonderflow/react-components 12.1.4 → 12.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.
Files changed (90) hide show
  1. package/dist/components/icon-button/icon-button.module.css +1 -1
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/components/index.d.ts.map +1 -1
  4. package/dist/components/index.js +1 -0
  5. package/dist/components/menu/menu-item/menu-item.d.ts +2 -2
  6. package/dist/components/menu/menu-item/menu-item.d.ts.map +1 -1
  7. package/dist/components/menu/menu-item/menu-item.js +1 -1
  8. package/dist/components/menu/menu-item/menu-item.stories.d.ts +43 -3
  9. package/dist/components/menu/menu-item/menu-item.stories.d.ts.map +1 -1
  10. package/dist/components/menu/menu.stories.d.ts +140 -10
  11. package/dist/components/menu/menu.stories.d.ts.map +1 -1
  12. package/dist/components/product-card/index.d.ts +3 -0
  13. package/dist/components/product-card/index.d.ts.map +1 -0
  14. package/dist/components/product-card/index.js +16 -0
  15. package/dist/components/product-card/product-card-footer/product-card-footer.d.ts +10 -0
  16. package/dist/components/product-card/product-card-footer/product-card-footer.d.ts.map +1 -0
  17. package/dist/components/product-card/product-card-footer/product-card-footer.js +20 -0
  18. package/dist/components/product-card/product-card-footer/product-card-footer.test.d.ts +2 -0
  19. package/dist/components/product-card/product-card-footer/product-card-footer.test.d.ts.map +1 -0
  20. package/dist/components/product-card/product-card-footer/product-card-footer.test.js +13 -0
  21. package/dist/components/product-card/product-card-header/product-card-header.d.ts +34 -0
  22. package/dist/components/product-card/product-card-header/product-card-header.d.ts.map +1 -0
  23. package/dist/components/product-card/product-card-header/product-card-header.js +32 -0
  24. package/dist/components/product-card/product-card-header/product-card-header.module.css +1 -0
  25. package/dist/components/product-card/product-card-header/product-card-header.test.d.ts +2 -0
  26. package/dist/components/product-card/product-card-header/product-card-header.test.d.ts.map +1 -0
  27. package/dist/components/product-card/product-card-header/product-card-header.test.js +17 -0
  28. package/dist/components/product-card/product-card-kpis/product-card-kpis.d.ts +84 -0
  29. package/dist/components/product-card/product-card-kpis/product-card-kpis.d.ts.map +1 -0
  30. package/dist/components/product-card/product-card-kpis/product-card-kpis.js +98 -0
  31. package/dist/components/product-card/product-card-kpis/product-card-kpis.module.css +1 -0
  32. package/dist/components/product-card/product-card-kpis/product-card.kpis.test.d.ts +2 -0
  33. package/dist/components/product-card/product-card-kpis/product-card.kpis.test.d.ts.map +1 -0
  34. package/dist/components/product-card/product-card-kpis/product-card.kpis.test.js +17 -0
  35. package/dist/components/product-card/product-card-media/product-card-media.d.ts +18 -0
  36. package/dist/components/product-card/product-card-media/product-card-media.d.ts.map +1 -0
  37. package/dist/components/product-card/product-card-media/product-card-media.js +53 -0
  38. package/dist/components/product-card/product-card-media/product-card-media.module.css +1 -0
  39. package/dist/components/product-card/product-card-media/product-card-media.test.d.ts +2 -0
  40. package/dist/components/product-card/product-card-media/product-card-media.test.d.ts.map +1 -0
  41. package/dist/components/product-card/product-card-media/product-card-media.test.js +29 -0
  42. package/dist/components/product-card/product-card.d.ts +43 -0
  43. package/dist/components/product-card/product-card.d.ts.map +1 -0
  44. package/dist/components/product-card/product-card.js +43 -0
  45. package/dist/components/product-card/product-card.module.css +1 -0
  46. package/dist/components/product-card/product-card.stories.d.ts +12 -0
  47. package/dist/components/product-card/product-card.stories.d.ts.map +1 -0
  48. package/dist/components/product-card/product-card.stories.js +118 -0
  49. package/dist/components/product-card/product-card.test.d.ts +2 -0
  50. package/dist/components/product-card/product-card.test.d.ts.map +1 -0
  51. package/dist/components/product-card/product-card.test.js +36 -0
  52. package/dist/components/select/select.d.ts +8 -0
  53. package/dist/components/select/select.d.ts.map +1 -1
  54. package/dist/components/select/select.js +2 -2
  55. package/dist/components/select/select.module.css +1 -1
  56. package/dist/components/select/select.stories.d.ts +3 -0
  57. package/dist/components/select/select.stories.d.ts.map +1 -1
  58. package/dist/components/select/select.stories.js +4 -0
  59. package/dist/components/snackbar/snackbar.module.css +1 -1
  60. package/dist/components/symbol/symbol.d.ts.map +1 -1
  61. package/dist/components/symbol/symbol.js +3 -1
  62. package/dist/components/symbol/symbol.module.css +1 -1
  63. package/dist/components/text/text.stories.js +1 -1
  64. package/dist/components/textfield/base-field/base-field.module.css +1 -1
  65. package/dist/components/textfield/textfield.d.ts +8 -0
  66. package/dist/components/textfield/textfield.d.ts.map +1 -1
  67. package/dist/components/textfield/textfield.js +15 -4
  68. package/dist/components/textfield/textfield.module.css +1 -1
  69. package/dist/components/textfield/textfield.stories.d.ts.map +1 -1
  70. package/dist/components/textfield/textfield.stories.js +6 -2
  71. package/dist/components/tooltip/tooltip.module.css +1 -1
  72. package/dist/examples/shell.stories.d.ts.map +1 -1
  73. package/dist/examples/shell.stories.js +2 -2
  74. package/dist/index.d.ts +1 -0
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +1 -0
  77. package/dist/utils/browser.d.ts +1 -1
  78. package/dist/utils/browser.d.ts.map +1 -1
  79. package/dist/utils/browser.js +1 -1
  80. package/dist/utils/browser.test.js +2 -2
  81. package/dist/utils/formatting.d.ts +16 -0
  82. package/dist/utils/formatting.d.ts.map +1 -0
  83. package/dist/utils/formatting.js +76 -0
  84. package/dist/utils/formatting.test.d.ts +2 -0
  85. package/dist/utils/formatting.test.d.ts.map +1 -0
  86. package/dist/utils/formatting.test.js +151 -0
  87. package/dist/utils/index.d.ts +5 -0
  88. package/dist/utils/index.d.ts.map +1 -0
  89. package/dist/utils/index.js +19 -0
  90. package/package.json +3 -3
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
3
+ import clsx from 'clsx';
4
+ import { forwardRef, useMemo, } from 'react';
5
+ import { Skeleton, Stack, Symbol, Text, } from '../../..';
6
+ import { formatKpiValue, formatPriceRangeValues, isGreaterThan, isValueOverCap, } from '../../../utils/formatting';
7
+ import * as styles from './product-card-kpis.module.css';
8
+ export const ProductCardKpis = forwardRef(({ rating, feedbackCount, votesCount, votesRating, sentiment, nps, groups, tgw, priceMin, priceMax, currency = 'EUR', currencyDecimals = 0, users, usersCap, skus, skusCap, kpiItems = 3, kpisRowGap = 8, isLoading = false, className, style, }, forwardedRef) => {
9
+ const config = useMemo(() => ([
10
+ {
11
+ property: 'feedback-rating',
12
+ value: formatKpiValue(rating, { decimal: 2, minRange: 0, maxRange: 5 }),
13
+ icon: 'feedback-rating',
14
+ iconColor: isGreaterThan(3.99, rating) ? `hsl(${tkns.color.yellow['30']})` : undefined,
15
+ },
16
+ {
17
+ property: 'sentiment',
18
+ value: formatKpiValue(sentiment, { decimal: 2, minRange: -1, maxRange: 1 }),
19
+ icon: 'hearts-suit',
20
+ iconColor: isGreaterThan(0.5, sentiment) ? 'var(--highlight-red-foreground)' : undefined,
21
+ },
22
+ {
23
+ property: 'feedback-count',
24
+ value: formatKpiValue(feedbackCount),
25
+ icon: 'message',
26
+ },
27
+ {
28
+ property: 'votes-rating',
29
+ value: formatKpiValue(votesRating, { decimal: 2, minRange: 0, maxRange: 5 }),
30
+ icon: 'star',
31
+ iconColor: isGreaterThan(3.99, votesRating) ? `hsl(${tkns.color.yellow['20']})` : undefined,
32
+ },
33
+ {
34
+ property: 'votes-count',
35
+ value: formatKpiValue(votesCount),
36
+ icon: 'votes-count',
37
+ },
38
+ {
39
+ property: 'nps',
40
+ value: formatKpiValue(nps, { decimal: 0, minRange: 0, maxRange: 100 }),
41
+ icon: 'nps',
42
+ },
43
+ {
44
+ property: 'groups',
45
+ value: formatKpiValue(groups),
46
+ icon: 'grid',
47
+ },
48
+ {
49
+ property: 'tgw',
50
+ value: formatKpiValue(tgw, { decimal: 2, minRange: 0 }),
51
+ icon: 'frown',
52
+ },
53
+ {
54
+ property: 'price',
55
+ value: formatPriceRangeValues(priceMin, priceMax, { currency, decimals: currencyDecimals }),
56
+ icon: 'tags',
57
+ },
58
+ {
59
+ property: 'users',
60
+ value: formatKpiValue(users, { decimal: 0, minRange: 0, cap: usersCap }),
61
+ icon: 'users',
62
+ iconColor: isValueOverCap(users, usersCap) ? 'var(--highlight-red-foreground)' : undefined,
63
+ },
64
+ {
65
+ property: 'skus',
66
+ value: formatKpiValue(skus, { decimal: 0, minRange: 0, cap: skusCap }),
67
+ icon: 'rectangle-barcode',
68
+ iconColor: isValueOverCap(skus, skusCap) ? 'var(--highlight-red-foreground)' : undefined,
69
+ },
70
+ ]), [
71
+ rating,
72
+ sentiment,
73
+ feedbackCount,
74
+ votesCount,
75
+ votesRating,
76
+ nps,
77
+ groups,
78
+ tgw,
79
+ priceMin,
80
+ priceMax,
81
+ currency,
82
+ currencyDecimals,
83
+ users,
84
+ usersCap,
85
+ skus,
86
+ skusCap
87
+ ]);
88
+ const itemHeight = 20;
89
+ const dynamicStyle = {
90
+ '--kpis-height': `${kpiItems * itemHeight + ((kpiItems - 1) * (+kpisRowGap))}px`,
91
+ };
92
+ return (_jsx("div", { className: clsx(styles.Kpis, className), style: { ...dynamicStyle, ...style }, ref: forwardedRef, children: isLoading
93
+ ? (_jsx(Stack, { hPadding: 24, children: _jsx(Skeleton, { height: "20px", width: "50%", count: kpiItems }) }))
94
+ : (_jsx(Stack, { rowGap: kpisRowGap, hPadding: 24, children: config
95
+ .filter(el => el.value)
96
+ .map(el => (_jsx(Text, { variant: "body-2", decoratorStart: _jsx(Symbol, { source: el.icon, color: el.iconColor, weight: "solid" }), decoratorSize: "small", children: _jsx("b", { children: el.value }) }, el.property))) })) }));
97
+ });
98
+ ProductCardKpis.displayName = 'ProductCardKpis';
@@ -0,0 +1 @@
1
+ @layer components{.Kpis{height:var(--kpis-height);margin:.5rem 0;overflow:hidden}}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=product-card.kpis.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-card.kpis.test.d.ts","sourceRoot":"","sources":["../../../../src/components/product-card/product-card-kpis/product-card.kpis.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render } from '@testing-library/react';
3
+ import { ProductCardKpis } from './product-card-kpis';
4
+ describe('<ProductCardKpis>', () => {
5
+ test('it should render properly', () => {
6
+ const { container } = render(_jsx(ProductCardKpis, {}));
7
+ expect(container).not.toBeNull();
8
+ });
9
+ test('it should render properly with props', () => {
10
+ const { container } = render(_jsx(ProductCardKpis, { rating: 1.2, feedbackCount: 1.2, votesCount: 1.2, votesRating: 1.2, sentiment: 1.2, nps: 1.2, tgw: 1, groups: 1.2, priceMin: 1.2, priceMax: 1.2, users: 1.2, skus: 1.2 }));
11
+ expect(container).not.toBeNull();
12
+ });
13
+ test('it should render skeleton properly', () => {
14
+ const { container } = render(_jsx(ProductCardKpis, { isLoading: true }));
15
+ expect(container).not.toBeNull();
16
+ });
17
+ });
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ export declare type ProductCardMediaProps = PropsWithClass<{
3
+ /**
4
+ * Set an array of paths to the images.
5
+ */
6
+ source?: string[];
7
+ /**
8
+ * Set the ratio following the CSS syntax.
9
+ */
10
+ ratio?: string;
11
+ /**
12
+ * Set the loading state showing a skeleton.
13
+ */
14
+ isLoading?: boolean;
15
+ }>;
16
+ export declare type ProductCardMediaComponent = React.ForwardRefExoticComponent<ProductCardMediaProps>;
17
+ export declare const ProductCardMedia: ProductCardMediaComponent;
18
+ //# sourceMappingURL=product-card-media.d.ts.map
@@ -0,0 +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,2BAiFE,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { forwardRef, useEffect, useState, } from 'react';
18
+ import { AspectRatio, Grid, Skeleton, } from '../../..';
19
+ import * as styles from './product-card-media.module.css';
20
+ export const ProductCardMedia = forwardRef(({ source = [], ratio = '1', isLoading = false, className, style, ...otherProps }, forwardedRef) => {
21
+ const [imgs, setImgs] = useState([]);
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
+ });
31
+ const images = source.slice(0, 4).map(async (s) => preloadImage(s));
32
+ Promise.all(images)
33
+ .then((urls) => {
34
+ const t = urls.map((el, i) => ({
35
+ row: i < 2 ? '1' : '2',
36
+ col: i % 2 === 0 ? '1' : '2',
37
+ val: el,
38
+ }));
39
+ if (t.length === 3)
40
+ t[1].row = '1 / 3';
41
+ setImgs(t);
42
+ })
43
+ // eslint-disable-next-line no-console
44
+ .catch(err => console.error(err));
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ }, []);
47
+ if (source.length === 0)
48
+ return null;
49
+ return (_jsx("div", { ref: forwardedRef, className: className, style: { ...style }, ...otherProps, children: _jsx(AspectRatio, { ratio: ratio, children: isLoading
50
+ ? (_jsx(Skeleton, { style: { borderRadius: '0', lineHeight: '2rem' }, width: "inherit", height: "inherit" }))
51
+ : (_jsx(Grid, { "aria-label": "", rows: imgs.length > 2 ? 2 : 1, rowMinHeight: "1fr", columns: imgs.length > 2 ? 2 : 1, colMinWidth: "1fr", children: imgs.map((el) => (_jsx(Grid.Item, { className: styles.Image, row: el.row, column: el.col, style: { backgroundImage: `url("${el.val}")` } }, `${el.val}-${el.row}-${el.col}`))) })) }) }));
52
+ });
53
+ ProductCardMedia.displayName = 'ProductCardMedia';
@@ -0,0 +1 @@
1
+ @layer components{.Image{background-position:50%;background-repeat:no-repeat;background-size:contain;margin:.25rem}}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=product-card-media.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-card-media.test.d.ts","sourceRoot":"","sources":["../../../../src/components/product-card/product-card-media/product-card-media.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render } from '@testing-library/react';
3
+ import { ProductCardMedia } from './product-card-media';
4
+ describe('<ProductCardMedia>', () => {
5
+ const SourceImages = [
6
+ 'https://products.gumlet.io/image-1675779605803.jpeg',
7
+ 'https://storage.googleapis.com/wonderflow-product-images/KITCHENAID%205KSM15%20SERIES.png',
8
+ 'https://storage.googleapis.com/wonderflow-product-images/CLASSIC%204.5%20QT.png',
9
+ 'https://broken-link.png',
10
+ ];
11
+ test('it should render properly', () => {
12
+ const { container } = render(_jsx(ProductCardMedia, { source: SourceImages }));
13
+ expect(container).not.toBeNull();
14
+ });
15
+ test('it should render properly with props', () => {
16
+ const { container } = render(_jsx(ProductCardMedia, { source: SourceImages, isLoading: true, ratio: "1" }));
17
+ expect(container).not.toBeNull();
18
+ });
19
+ test('it should render properly with 1 image', () => {
20
+ const s = SourceImages.slice(0, 1);
21
+ const { container } = render(_jsx(ProductCardMedia, { source: s, isLoading: true, ratio: "1" }));
22
+ expect(container).not.toBeNull();
23
+ });
24
+ test('it should render properly with 3 image', () => {
25
+ const s = SourceImages.slice(0, 3);
26
+ const { container } = render(_jsx(ProductCardMedia, { source: s, isLoading: true, ratio: "1" }));
27
+ expect(container).not.toBeNull();
28
+ });
29
+ });
@@ -0,0 +1,43 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { ProductCardFooterComponent } from './product-card-footer/product-card-footer';
3
+ import { ProductCardHeaderComponent, ProductCardHeaderProps } from './product-card-header/product-card-header';
4
+ import { ProductCardKpisComponent, ProductCardKpisProps } from './product-card-kpis/product-card-kpis';
5
+ import { ProductCardMediaComponent, ProductCardMediaProps } from './product-card-media/product-card-media';
6
+ export declare type ProductCardProps = PropsWithClass<PropsWithChildren<{
7
+ /**
8
+ * Change the product card layout.
9
+ */
10
+ direction?: 'vertical' | 'horizontal';
11
+ /**
12
+ * Add a border to the card to increase its visual weight and contrast.
13
+ */
14
+ bordered?: boolean;
15
+ /**
16
+ * Change the style of the card when it is hovered.
17
+ */
18
+ highlightOnHover?: boolean;
19
+ /**
20
+ * Set the content to be displayed on the overlay layer.
21
+ */
22
+ overlayActions?: React.ReactNode;
23
+ /**
24
+ * Add content to the footer.
25
+ */
26
+ footer?: React.ReactNode;
27
+ /**
28
+ * Set the loading state showing a skeleton.
29
+ */
30
+ isLoading?: boolean;
31
+ /**
32
+ * Set an action to be performed when clicked.
33
+ */
34
+ onClick?: () => void;
35
+ }>> & Pick<ProductCardMediaProps, 'ratio' | 'source'> & Pick<ProductCardHeaderProps, 'title' | 'titleRows' | 'subtitle' | 'menuActions'> & Pick<ProductCardKpisProps, 'rating' | 'feedbackCount' | 'votesCount' | 'votesRating' | 'users' | 'skus' | 'sentiment' | 'priceMin' | 'priceMax' | 'nps' | 'kpisRowGap' | 'kpiItems' | 'groups' | 'tgw' | 'skusCap' | 'usersCap' | 'currency' | 'currencyDecimals'>;
36
+ export declare type ProductCardComponent = React.ForwardRefExoticComponent<ProductCardProps> & {
37
+ Media: ProductCardMediaComponent;
38
+ Kpis: ProductCardKpisComponent;
39
+ Header: ProductCardHeaderComponent;
40
+ Footer: ProductCardFooterComponent;
41
+ };
42
+ export declare const ProductCard: ProductCardComponent;
43
+ //# sourceMappingURL=product-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EACA,iBAAiB,EAE9B,MAAM,OAAO,CAAC;AAQf,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,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;AAEnB,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,sBAwKE,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useDebounce } from 'ahooks';
3
+ import clsx from 'clsx';
4
+ import { forwardRef, useRef, } from 'react';
5
+ import { Elevator, Stack, } from '../..';
6
+ import * as styles from './product-card.module.css';
7
+ import { ProductCardFooter } from './product-card-footer/product-card-footer';
8
+ import { ProductCardHeader } from './product-card-header/product-card-header';
9
+ import { ProductCardKpis } from './product-card-kpis/product-card-kpis';
10
+ import { ProductCardMedia } from './product-card-media/product-card-media';
11
+ export const ProductCard = forwardRef(({ direction = 'vertical', bordered = false, highlightOnHover = false, title, titleRows = 3, subtitle, menuActions, rating, feedbackCount, votesCount, votesRating, sentiment, nps, groups, tgw, priceMin, priceMax, currency, currencyDecimals, users, usersCap, skus, skusCap, kpiItems, kpisRowGap, ratio, source, footer, overlayActions, onClick, isLoading = false, className, style, children, ...otherProps }, forwardedRef) => {
12
+ const hasOverlay = !!(overlayActions && !menuActions && !onClick && !isLoading);
13
+ const hasMenu = !!(menuActions && !overlayActions && !onClick);
14
+ const hasHighlight = !!(onClick ?? highlightOnHover);
15
+ const isClickable = !!(!isLoading && onClick);
16
+ const containerRef = useRef(null);
17
+ const mediaSizeStyle = (direction) => {
18
+ if (containerRef?.current) {
19
+ // @ts-expect-error: getBoundingClientRect()
20
+ const { width, height } = containerRef.current.getBoundingClientRect();
21
+ if (direction === 'vertical') {
22
+ return ({
23
+ flexGrow: 0,
24
+ height: 'auto',
25
+ width: '100%',
26
+ });
27
+ }
28
+ return ({
29
+ flexGrow: 0,
30
+ width: `${Math.min(width, height)}px`,
31
+ height: 'auto',
32
+ });
33
+ }
34
+ return ({});
35
+ };
36
+ const deboucedStyle = useDebounce(mediaSizeStyle(direction), { wait: 500 });
37
+ 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: [_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 })] })] })] }) }) }));
38
+ });
39
+ ProductCard.displayName = 'ProductCard';
40
+ ProductCard.Media = ProductCardMedia;
41
+ ProductCard.Header = ProductCardHeader;
42
+ ProductCard.Kpis = ProductCardKpis;
43
+ ProductCard.Footer = ProductCardFooter;
@@ -0,0 +1 @@
1
+ @layer components{.Card{background-color:var(--global-background);border-radius:.5rem;overflow:hidden;padding:0;position:relative}.Card[data-card-bordered=true]{border:1px solid var(--dimmed-1)}.Card[data-card-clickable=true]{cursor:pointer}.Row{height:100%;position:relative}.Content{flex-grow:1}.OverlayActions{background-color:var(--global-background);height:100%;opacity:0;position:absolute;transition:opacity .3s;width:100%;z-index:1}.OverlayActions:hover{opacity:1}}
@@ -0,0 +1,12 @@
1
+ import { ComponentMeta, ComponentStory } from '@storybook/react';
2
+ import { ProductCard } from './product-card';
3
+ declare const story: ComponentMeta<typeof ProductCard>;
4
+ export default story;
5
+ export declare const Default: ComponentStory<import("./product-card").ProductCardComponent>;
6
+ export declare const withOverlayActions: ComponentStory<import("./product-card").ProductCardComponent>;
7
+ export declare const withMenuActions: ComponentStory<import("./product-card").ProductCardComponent>;
8
+ export declare const clickable: ComponentStory<import("./product-card").ProductCardComponent>;
9
+ export declare const withMultipleProducts: ComponentStory<import("./product-card").ProductCardComponent>;
10
+ export declare const withBrokenImage: ComponentStory<import("./product-card").ProductCardComponent>;
11
+ export declare const withNoMedia: ComponentStory<import("./product-card").ProductCardComponent>;
12
+ //# sourceMappingURL=product-card.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-card.stories.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA4C7C,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,WAAW,CAwD5C,CAAC;AAEF,eAAe,KAAK,CAAC;AAQrB,eAAO,MAAM,OAAO,+DAAoB,CAAC;AAGzC,eAAO,MAAM,kBAAkB,+DAAoB,CAAC;AAKpD,eAAO,MAAM,eAAe,+DAAoB,CAAC;AAKjD,eAAO,MAAM,SAAS,+DAAoB,CAAC;AAK3C,eAAO,MAAM,oBAAoB,+DAAoB,CAAC;AAKtD,eAAO,MAAM,eAAe,+DAAoB,CAAC;AAKjD,eAAO,MAAM,WAAW,+DAAoB,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, Menu, Stack, Text, } from '../..';
3
+ import { ProductCard } from './product-card';
4
+ const OverlayButtons = (_jsxs(Stack, { rowGap: 16, children: [_jsx(Button, { children: "Stats" }), _jsx(Button, { kind: "secondary", children: "Compare" }), _jsx(Button, { kind: "secondary", children: "Add to group" })] }));
5
+ const MenuItems = (_jsxs(Menu, { children: [_jsx(Menu.Item, { autoFocus: true, icon: "news", value: "1", children: "Stats" }), _jsx(Menu.Item, { icon: "theater", value: "1", children: "Compare" }), _jsx(Menu.Item, { icon: "grid", value: "1", placement: "right-start", description: "add product to group", children: "Add to group" })] }));
6
+ const SourceImages = [
7
+ 'https://products.gumlet.io/image-1675779605803.jpeg',
8
+ 'https://storage.googleapis.com/wonderflow-product-images/KITCHENAID%205KSM15%20SERIES.png',
9
+ 'https://storage.googleapis.com/wonderflow-product-images/CLASSIC%204.5%20QT.png',
10
+ // 'https://storage.googleapis.com/wonderflow-product-images/delonghi_coffee_MC%20NESPRESSO%20INISSIA.png',
11
+ ];
12
+ const story = {
13
+ title: 'Domain Components/Product Card',
14
+ component: ProductCard,
15
+ args: {
16
+ direction: 'vertical',
17
+ bordered: false,
18
+ highlightOnHover: false,
19
+ title: 'Product Card Title',
20
+ titleRows: 3,
21
+ subtitle: 'subtitle',
22
+ rating: 4.3,
23
+ sentiment: 0.48,
24
+ feedbackCount: 123,
25
+ votesCount: 3456,
26
+ votesRating: 2.3,
27
+ nps: 23,
28
+ groups: 4,
29
+ tgw: 0.75,
30
+ priceMin: 33,
31
+ priceMax: 45,
32
+ currency: 'EUR',
33
+ currencyDecimals: 0,
34
+ users: 789,
35
+ usersCap: 1000,
36
+ skus: 2,
37
+ skusCap: 1000,
38
+ kpiItems: 3,
39
+ kpisRowGap: 8,
40
+ isLoading: false,
41
+ ratio: '1',
42
+ overlayActions: undefined,
43
+ menuActions: undefined,
44
+ onClick: undefined,
45
+ children: undefined,
46
+ source: SourceImages.slice(0, 1),
47
+ footer: (_jsx(Text, { variant: "body-2", children: "Apr 2023" })),
48
+ },
49
+ argTypes: {
50
+ direction: {
51
+ options: ['vertical', 'horizontal'],
52
+ control: { type: 'select' },
53
+ },
54
+ currency: {
55
+ options: ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
56
+ control: { type: 'select' },
57
+ },
58
+ kpisRowGap: {
59
+ options: [2, '2', 4, '4', 8, '8', 16, '16', 24, '24', 32, '32', 40, '40', 48, '48', 56, '56', 64, '64', 72, '72', 80, '80', 88, '88', 96, '96', 104, '104', 112, '112', 120, '120', 128, '128', 136, '136', 144, '144', 152, '152', 160, '160', 168, '168', 176, '176', 184, '184', 192, '192', 200, '200'],
60
+ control: { type: 'select' },
61
+ },
62
+ children: {
63
+ table: {
64
+ disable: true,
65
+ },
66
+ },
67
+ },
68
+ };
69
+ export default story;
70
+ const Template = (args) => {
71
+ const { direction } = args;
72
+ return (_jsx("div", { style: { maxWidth: direction === 'vertical' ? '250px' : '650px' }, children: _jsx(ProductCard, { ...args }) }));
73
+ };
74
+ export const Default = Template.bind({});
75
+ Default.args = {};
76
+ export const withOverlayActions = Template.bind({});
77
+ withOverlayActions.args = {
78
+ overlayActions: OverlayButtons,
79
+ };
80
+ export const withMenuActions = Template.bind({});
81
+ withMenuActions.args = {
82
+ menuActions: MenuItems,
83
+ };
84
+ export const clickable = Template.bind({});
85
+ clickable.args = {
86
+ onClick: () => console.log('pressed'),
87
+ };
88
+ export const withMultipleProducts = Template.bind({});
89
+ withMultipleProducts.args = {
90
+ source: SourceImages,
91
+ };
92
+ export const withBrokenImage = Template.bind({});
93
+ withBrokenImage.args = {
94
+ source: [...SourceImages, 'broken'],
95
+ };
96
+ export const withNoMedia = Template.bind({});
97
+ withNoMedia.args = {
98
+ source: [],
99
+ subtitle: '',
100
+ title: 'Wonderflow Space Catalog Label',
101
+ titleRows: 2,
102
+ kpiItems: 2,
103
+ rating: undefined,
104
+ sentiment: undefined,
105
+ feedbackCount: undefined,
106
+ votesCount: undefined,
107
+ votesRating: undefined,
108
+ nps: undefined,
109
+ groups: undefined,
110
+ tgw: undefined,
111
+ priceMin: undefined,
112
+ priceMax: undefined,
113
+ users: 1789,
114
+ usersCap: 1000,
115
+ skus: 234,
116
+ skusCap: 1000,
117
+ footer: undefined,
118
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=product-card.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-card.test.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render } from '@testing-library/react';
3
+ import { ProductCard } from './product-card';
4
+ describe('<ProductCard>', () => {
5
+ const SourceImages = [
6
+ 'https://products.gumlet.io/image-1675779605803.jpeg',
7
+ 'https://storage.googleapis.com/wonderflow-product-images/KITCHENAID%205KSM15%20SERIES.png',
8
+ 'https://storage.googleapis.com/wonderflow-product-images/CLASSIC%204.5%20QT.png',
9
+ 'this-is-a-broken-link.png',
10
+ ];
11
+ test('it should render properly', () => {
12
+ const { container } = render(_jsx(ProductCard, { isLoading: true }));
13
+ expect(container).not.toBeNull();
14
+ });
15
+ test('it should render properly with props', () => {
16
+ const { container } = render(_jsx(ProductCard, { title: "title", subtitle: "subtitle", source: SourceImages, direction: "horizontal", rating: 1.2, feedbackCount: 1.2, votesCount: 1.2, votesRating: 1.2, sentiment: 1.2, nps: 1.2, groups: 1.2, priceMin: 1.2, priceMax: 1.2, users: 1.2, skus: 1.2, kpiItems: 2, kpisRowGap: 16, bordered: true, highlightOnHover: true, ratio: "1/1" }));
17
+ expect(container).not.toBeNull();
18
+ });
19
+ test('it should render properly with menu actions', () => {
20
+ const s = SourceImages.slice(0, 3);
21
+ const { container } = render(_jsx(ProductCard, { title: "title", subtitle: "subtitle", source: s, direction: "horizontal", rating: 1.2, feedbackCount: 1.2, votesCount: 1.2, menuActions: _jsx("div", { children: "some content" }) }));
22
+ expect(container).not.toBeNull();
23
+ });
24
+ test('it should render properly with overlay actions', () => {
25
+ const { container } = render(_jsx(ProductCard, { title: "title", subtitle: "subtitle", source: SourceImages, direction: "horizontal", rating: 1.2, feedbackCount: 1.2, votesCount: 1.2, overlayActions: _jsx("div", { children: "some content" }) }));
26
+ expect(container).not.toBeNull();
27
+ });
28
+ test('it should render properly with on click', () => {
29
+ const { container } = render(_jsx(ProductCard, { title: "title", subtitle: "subtitle", source: SourceImages, direction: "horizontal", rating: 1.2, feedbackCount: 1.2, votesCount: 1.2, onClick: () => console.log('clicked') }));
30
+ expect(container).not.toBeNull();
31
+ });
32
+ test('it should render properly with children', () => {
33
+ const { container } = render(_jsx(ProductCard, { title: "title", subtitle: "subtitle", source: SourceImages, direction: "horizontal", rating: 1.2, feedbackCount: 1.2, votesCount: 1.2, onClick: () => console.log('clicked'), footer: _jsx("div", { children: "some content" }), children: _jsx("div", { children: "some content" }) }));
34
+ expect(container).not.toBeNull();
35
+ });
36
+ });
@@ -29,6 +29,10 @@ export declare type SelectProps = SelectHTMLAttributes<HTMLSelectElement> & {
29
29
  * Set disabled state. The select is not interactive and grayed out.
30
30
  */
31
31
  disabled?: boolean;
32
+ /**
33
+ * Set the invalid state.
34
+ */
35
+ invalid?: boolean;
32
36
  /**
33
37
  * Callback function to be called when a new value is selected.
34
38
  */
@@ -63,6 +67,10 @@ export declare const Select: import("react").ForwardRefExoticComponent<SelectHTM
63
67
  * Set disabled state. The select is not interactive and grayed out.
64
68
  */
65
69
  disabled?: boolean | undefined;
70
+ /**
71
+ * Set the invalid state.
72
+ */
73
+ invalid?: boolean | undefined;
66
74
  /**
67
75
  * Callback function to be called when a new value is selected.
68
76
  */
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/components/select/select.tsx"],"names":[],"mappings":"AAiBA,OAAO,EACL,WAAW,EAAc,SAAS,EAAE,oBAAoB,EACzD,MAAM,OAAO,CAAC;AAGf,OAAO,EACU,WAAW,EAC3B,MAAM,cAAc,CAAC;AAItB,oBAAY,WAAW,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IAClE;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAC5D,CAAA;AAED,eAAO,MAAM,MAAM;IAlCjB;;OAEG;cACO,SAAS;IACnB;;OAEG;;IAEH;;OAEG;YACK,SAAS;IACjB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;wBACgB,YAAY,iBAAiB,CAAC,KAAK,IAAI;qDAgE1D,CAAC"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/components/select/select.tsx"],"names":[],"mappings":"AAiBA,OAAO,EACL,WAAW,EAAc,SAAS,EAAE,oBAAoB,EACzD,MAAM,OAAO,CAAC;AAGf,OAAO,EACU,WAAW,EAC3B,MAAM,cAAc,CAAC;AAItB,oBAAY,WAAW,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IAClE;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAC5D,CAAA;AAED,eAAO,MAAM,MAAM;IAtCjB;;OAEG;cACO,SAAS;IACnB;;OAEG;;IAEH;;OAEG;YACK,SAAS;IACjB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;wBACgB,YAAY,iBAAiB,CAAC,KAAK,IAAI;qDAoE1D,CAAC"}
@@ -19,13 +19,13 @@ import { forwardRef, } from 'react';
19
19
  import { useUIDSeed } from 'react-uid';
20
20
  import { Stack, Symbol, Text, } from '../..';
21
21
  import * as styles from './select.module.css';
22
- export const Select = forwardRef(({ children, className, disabled = false, icon = 'chevron-down', label, message, kind = 'single', dimension = 'regular', onChange, ...otherProps }, forwardedRef) => {
22
+ export const Select = forwardRef(({ children, className, invalid = false, disabled = false, icon = 'chevron-down', label, message, kind = 'single', dimension = 'regular', onChange, ...otherProps }, forwardedRef) => {
23
23
  const seedID = useUIDSeed();
24
24
  const iconSizes = {
25
25
  small: 12,
26
26
  regular: 16,
27
27
  big: 24,
28
28
  };
29
- return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Select, className), "data-select-is-multiple": kind === 'multiple', "data-select-has-label": Boolean(label), "data-select-dimension": dimension, "aria-disabled": disabled, hAlign: "start", vAlign: "start", inline: true, tabIndex: disabled ? 0 : undefined, children: [label && _jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, variant: dimension === 'big' ? 'body-1' : 'body-2', htmlFor: seedID('select'), children: label }), _jsxs("div", { className: styles.FieldContainer, children: [_jsx("select", { disabled: disabled, className: styles.Field, id: seedID('select'), multiple: kind === 'multiple', onChange: onChange, ref: forwardedRef, ...otherProps, children: children }), kind === 'single' && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] }), message && _jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, variant: dimension === 'big' ? 'body-2' : 'body-3', children: message })] }));
29
+ return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Select, className), "data-select-is-multiple": kind === 'multiple', "data-select-has-label": Boolean(label), "data-select-dimension": dimension, "data-select-invalid": invalid && !disabled, "aria-disabled": disabled, "aria-invalid": invalid && !disabled, hAlign: "start", vAlign: "start", inline: true, tabIndex: disabled ? 0 : undefined, children: [label && _jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, variant: dimension === 'big' ? 'body-1' : 'body-2', htmlFor: seedID('select'), children: label }), _jsxs("div", { className: styles.FieldContainer, children: [_jsx("select", { disabled: disabled, "aria-invalid": invalid && !disabled, className: styles.Field, id: seedID('select'), multiple: kind === 'multiple', onChange: onChange, ref: forwardedRef, ...otherProps, children: children }), kind === 'single' && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] }), message && _jsx(Text, { as: "label", "aria-disabled": disabled, color: (invalid && !disabled) ? 'danger' : undefined, className: styles.Label, variant: dimension === 'big' ? 'body-2' : 'body-3', children: message })] }));
30
30
  });
31
31
  Select.displayName = 'Select';
@@ -1 +1 @@
1
- @layer components{.Select{appearance:none;padding:0;position:relative}.Select[data-select-dimension=small]{--field-height:1.500rem;--field-padding:0.33rem;--font-size:0.875rem}.Select[data-select-dimension=regular]{--field-height:2.25rem;--field-padding:0.875rem;--font-size:0.875rem}.Select[data-select-dimension=big]{--field-height:3.000rem;--field-padding:1.000rem;--font-size:1rem}.FieldContainer{color:var(--global-vibrancy-foreground);inline-size:100%;position:relative}.Select[aria-disabled=true] .FieldContainer{color:var(--global-disabled-foreground)}.Field{appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background));block-size:var(--field-height);border:0;border-radius:.25rem;box-sizing:border-box;color:inherit;display:block;font-family:inherit;font-size:var(--font-size);margin:0;min-inline-size:100%;overflow:hidden;padding:0 calc(var(--field-padding)*3.5) 0 var(--field-padding);text-overflow:ellipsis}.Field:disabled{background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));color:var(--global-disabled-foreground);cursor:not-allowed}.Field option{color:#000}.Field optgroup{color:initial}.Field[multiple]{block-size:auto;overflow:auto;padding:.5rem 1rem}.Field[multiple] option{color:currentcolor;padding:calc(var(--field-padding)/2) var(--field-padding)}.Field[multiple] option:checked{background:#9ea5b3 linear-gradient(180deg,#9ea5b3 0,#9ea5b3);background-color:#9ea5b3;color:var(--global-background)}.Field[multiple] optgroup{color:currentcolor;font-family:inherit;font-size:inherit;line-height:inherit;margin:0 0 1rem}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;right:calc(var(--field-padding) - var(--field-padding)/3);top:calc(var(--field-height)/2);transform:translateY(-50%)}label.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}
1
+ @layer components{.Select{appearance:none;padding:0;position:relative}.Select[data-select-dimension=small]{--field-height:1.500rem;--field-padding:0.33rem;--font-size:0.875rem}.Select[data-select-dimension=regular]{--field-height:2.25rem;--field-padding:0.875rem;--font-size:0.875rem}.Select[data-select-dimension=big]{--field-height:3.000rem;--field-padding:1.000rem;--font-size:1rem}.FieldContainer{border-radius:.25rem;color:var(--global-vibrancy-foreground);inline-size:100%;position:relative}.Select[aria-disabled=true] .FieldContainer{color:var(--global-disabled-foreground)}.Field{appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background));block-size:var(--field-height);border:1px solid transparent;border-radius:.25rem;box-sizing:border-box;color:inherit;display:block;font-family:inherit;font-size:var(--font-size);margin:0;min-inline-size:100%;overflow:hidden;padding:0 calc(var(--field-padding)*3.5) 0 var(--field-padding);text-overflow:ellipsis}.Field:disabled{background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));color:var(--global-disabled-foreground);cursor:not-allowed}.Field[aria-invalid=true]{border:1px solid var(--highlight-red-foreground)}.Field option{color:#000}.Field optgroup{color:initial}.Field[multiple]{block-size:auto;overflow:auto;padding:.5rem 1rem}.Field[multiple] option{color:currentcolor;padding:calc(var(--field-padding)/2) var(--field-padding)}.Field[multiple] option:checked{background:#9ea5b3 linear-gradient(180deg,#9ea5b3 0,#9ea5b3);background-color:#9ea5b3;color:var(--global-background)}.Field[multiple] optgroup{color:currentcolor;font-family:inherit;font-size:inherit;line-height:inherit;margin:0 0 1rem}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;right:calc(var(--field-padding) - var(--field-padding)/3);top:calc(var(--field-height)/2);transform:translateY(-50%)}label.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}
@@ -11,6 +11,7 @@ export declare const Single: ComponentStory<React.ForwardRefExoticComponent<Reac
11
11
  kind?: "multiple" | "single" | undefined;
12
12
  dimension?: "small" | "regular" | "big" | undefined;
13
13
  disabled?: boolean | undefined;
14
+ invalid?: boolean | undefined;
14
15
  onChange?: ((event: React.ChangeEvent<HTMLSelectElement>) => void) | undefined;
15
16
  } & React.RefAttributes<HTMLSelectElement>>>;
16
17
  export declare const Multiple: ComponentStory<React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & {
@@ -21,6 +22,7 @@ export declare const Multiple: ComponentStory<React.ForwardRefExoticComponent<Re
21
22
  kind?: "multiple" | "single" | undefined;
22
23
  dimension?: "small" | "regular" | "big" | undefined;
23
24
  disabled?: boolean | undefined;
25
+ invalid?: boolean | undefined;
24
26
  onChange?: ((event: React.ChangeEvent<HTMLSelectElement>) => void) | undefined;
25
27
  } & React.RefAttributes<HTMLSelectElement>>>;
26
28
  export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & {
@@ -31,6 +33,7 @@ export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<R
31
33
  kind?: "multiple" | "single" | undefined;
32
34
  dimension?: "small" | "regular" | "big" | undefined;
33
35
  disabled?: boolean | undefined;
36
+ invalid?: boolean | undefined;
34
37
  onChange?: ((event: React.ChangeEvent<HTMLSelectElement>) => void) | undefined;
35
38
  } & React.RefAttributes<HTMLSelectElement>>>;
36
39
  //# sourceMappingURL=select.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.stories.d.ts","sourceRoot":"","sources":["../../../src/components/select/select.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,MAAM,CA4BvC,CAAC;AAEF,eAAe,KAAK,CAAC;AAgCrB,eAAO,MAAM,MAAM;;;;;;;;;4CAA0B,CAAC;AAM9C,eAAO,MAAM,QAAQ;;;;;;;;;4CAA4B,CAAC;AAKlD,eAAO,MAAM,SAAS;;;;;;;;;4CAA0B,CAAC"}
1
+ {"version":3,"file":"select.stories.d.ts","sourceRoot":"","sources":["../../../src/components/select/select.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,MAAM,CAgCvC,CAAC;AAEF,eAAe,KAAK,CAAC;AAgCrB,eAAO,MAAM,MAAM;;;;;;;;;;4CAA0B,CAAC;AAM9C,eAAO,MAAM,QAAQ;;;;;;;;;;4CAA4B,CAAC;AAKlD,eAAO,MAAM,SAAS;;;;;;;;;;4CAA0B,CAAC"}