@wonderflow/react-components 17.3.1 → 17.5.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
- @layer components{.Media{border-bottom:1px solid var(--dimmed-1)}.Image{background-position:50%;background-repeat:no-repeat;background-size:cover}}
1
+ @layer components{.Media{border-bottom:1px solid var(--dimmed-1)}.Image{background-position:50%;background-repeat:no-repeat;background-size:contain}}
@@ -1 +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,EAC9B,MAAM,OAAO,CAAC;AAcf,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;AAC7H,OAAO,EAAqB,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAEpI,oBAAY,gBAAgB,GAAG,cAAc,CAAC,iBAAiB,CAAC;IAC9D;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;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;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACpD;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IACrF,KAAK,EAAE,yBAAyB,CAAC;IACjC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,MAAM,EAAE,0BAA0B,CAAC;IACnC,MAAM,EAAE,0BAA0B,CAAC;IACnC,MAAM,EAAE,0BAA0B,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,WAAW,sBAwRE,CAAC"}
@@ -33,11 +33,27 @@ export const ProductCard = forwardRef(({ bordered = true, highlightOnHover = fal
33
33
  const cardRef = useRef(null);
34
34
  const [isExpanded, setIsExpanded] = useState(false);
35
35
  const [isPeeking, setIsPeeking] = useState(false);
36
+ const [isOverlayOpen, setIsOverlayOpen] = useState(false);
36
37
  const [lockedHeight, setLockedHeight] = useState();
37
38
  const [isLocked, setIsLocked] = useState(false);
39
+ const hasOverlay = !!(overlayActions && !onClick && !isLoading);
40
+ const hasHighlight = !!(onClick ?? highlightOnHover);
41
+ const isClickable = !!(!isLoading && onClick);
42
+ const hasTopBar = !!sourceLabel;
43
+ const hasMedia = !!source?.length;
44
+ const hasKpis = kpiItems !== 0;
45
+ const hasFooterSeparator = !!footer || isLoading;
38
46
  const isKpisExpanded = !!expandable && isExpanded && !isLoading;
39
47
  const isShowingAllKpis = isKpisExpanded && !isPeeking;
40
48
  const isKpisAvailable = !!expandable && !isLoading;
49
+ // While the overlay actions are open, the KPIs give their space back to the cover.
50
+ const isKpisHidden = hasOverlay && isOverlayOpen && hasKpis;
51
+ const lock = useCallback(() => {
52
+ if (isLocked)
53
+ return;
54
+ setLockedHeight(cardRef.current?.offsetHeight);
55
+ setIsLocked(true);
56
+ }, [isLocked]);
41
57
  const unlock = useCallback(() => {
42
58
  setIsLocked(false);
43
59
  setLockedHeight(undefined);
@@ -52,38 +68,47 @@ export const ProductCard = forwardRef(({ bordered = true, highlightOnHover = fal
52
68
  if (!isKpisExpanded)
53
69
  setIsPeeking(false);
54
70
  }, [isKpisExpanded]);
71
+ useEffect(() => {
72
+ if (!hasOverlay)
73
+ setIsOverlayOpen(false);
74
+ }, [hasOverlay]);
55
75
  // The lock is kept while the collapse animation plays, then released on transition end (or after a fallback delay).
56
76
  useEffect(() => {
57
- if (!isLocked || isKpisExpanded)
77
+ if (!isLocked || isKpisExpanded || isOverlayOpen)
58
78
  return undefined;
59
79
  const timeout = setTimeout(unlock, LOCK_RELEASE_FALLBACK_MS);
60
80
  return () => clearTimeout(timeout);
61
- }, [isLocked, isKpisExpanded, unlock]);
81
+ }, [isLocked, isKpisExpanded, isOverlayOpen, unlock]);
62
82
  const handleExpandedChange = useCallback((expanded) => {
63
- if (expanded && !isLocked) {
64
- setLockedHeight(cardRef.current?.offsetHeight);
65
- setIsLocked(true);
66
- }
83
+ if (expanded)
84
+ lock();
67
85
  setIsExpanded(expanded);
68
- }, [isLocked]);
86
+ }, [lock]);
69
87
  const handleTransitionEnd = (event) => {
70
- if (isLocked && !isKpisExpanded && event.propertyName === 'grid-template-rows')
88
+ if (isLocked && !isKpisExpanded && !isOverlayOpen && event.propertyName === 'grid-template-rows')
71
89
  unlock();
72
90
  };
73
- const handleCoverMouseEnter = isKpisExpanded ? () => setIsPeeking(true) : undefined;
74
- const handleCoverMouseLeave = isKpisExpanded ? () => setIsPeeking(false) : undefined;
75
- const hasOverlay = !!(overlayActions && !onClick && !isLoading);
76
- const hasHighlight = !!(onClick ?? highlightOnHover);
77
- const isClickable = !!(!isLoading && onClick);
78
- const hasTopBar = !!sourceLabel;
79
- const hasMedia = !!source?.length;
80
- const hasKpis = kpiItems !== 0;
81
- const hasFooterSeparator = !!footer || isLoading;
82
- return (_jsx(Elevator, { resting: 1, hover: hasHighlight ? 2 : undefined, children: _jsxs(Stack, { ref: mergeRefs([cardRef, forwardedRef]), className: clsx(styles.Card, className), style: { ...style, height: isLocked ? lockedHeight : style?.height }, fill: false, "data-card-bordered": bordered, "data-card-clickable": isClickable, "data-card-expanded": isShowingAllKpis, "data-card-locked": isLocked, onClick: isLoading ? undefined : onClick, onTransitionEnd: handleTransitionEnd, ...otherProps, children: [hasTopBar && (_jsxs(_Fragment, { children: [_jsx(ProductCard.TopBar, { "data-inner-element": "ProductCard-TopBar", sourceLabel: sourceLabel, sourceIcon: sourceIcon, isLoading: isLoading }), _jsx(Separator, {})] })), _jsxs("div", { className: styles.Cover, "data-inner-element": "ProductCard-Cover", onMouseEnter: handleCoverMouseEnter, onMouseLeave: handleCoverMouseLeave, children: [hasMedia
91
+ const handleCoverMouseEnter = () => {
92
+ if (hasOverlay) {
93
+ if (hasKpis)
94
+ lock();
95
+ setIsOverlayOpen(true);
96
+ }
97
+ else if (isKpisExpanded) {
98
+ setIsPeeking(true);
99
+ }
100
+ };
101
+ const handleCoverMouseLeave = () => {
102
+ if (hasOverlay)
103
+ setIsOverlayOpen(false);
104
+ else if (isKpisExpanded)
105
+ setIsPeeking(false);
106
+ };
107
+ return (_jsx(Elevator, { resting: 1, hover: hasHighlight ? 2 : undefined, children: _jsxs(Stack, { ref: mergeRefs([cardRef, forwardedRef]), className: clsx(styles.Card, className), style: { ...style, height: isLocked ? lockedHeight : style?.height }, fill: false, "data-card-bordered": bordered, "data-card-clickable": isClickable, "data-card-expanded": isShowingAllKpis, "data-card-locked": isLocked, "data-card-overlay-open": hasOverlay && isOverlayOpen, onClick: isLoading ? undefined : onClick, onTransitionEnd: handleTransitionEnd, ...otherProps, children: [hasTopBar && (_jsxs(_Fragment, { children: [_jsx(ProductCard.TopBar, { "data-inner-element": "ProductCard-TopBar", sourceLabel: sourceLabel, sourceIcon: sourceIcon, isLoading: isLoading }), _jsx(Separator, {})] })), _jsxs("div", { className: styles.Cover, "data-inner-element": "ProductCard-Cover", onMouseEnter: handleCoverMouseEnter, onMouseLeave: handleCoverMouseLeave, children: [hasMedia
83
108
  ? (_jsx(ProductCard.Media, { source: source, isLoading: isLoading, ratio: ratio, "data-inner-element": "ProductCard-Media" }))
84
109
  : (_jsx(AspectRatio, { ratio: ratio ?? '1', children: isLoading
85
110
  ? (_jsx(Skeleton, { style: { borderRadius: '0', lineHeight: '2rem' }, width: "inherit", height: "inherit" }))
86
- : (_jsx(Stack, { className: styles.ColoredCard, style: { backgroundColor: getColorFromString(title ?? '') }, hAlign: "center", vAlign: "center", fill: false, "data-inner-element": "ProductCard-ColoredCover", children: _jsx(Text, { variant: "heading-1", textAlign: "center", style: { color: '#fff' }, children: title?.slice(0, 2) }) })) })), badge && !isLoading && (_jsx(Chip, { color: "yellow", className: styles.Badge, "data-inner-element": "ProductCard-Badge", children: badge })), hasOverlay && (_jsx(Stack, { direction: "row", hPadding: 24, vAlign: "center", hAlign: "center", className: styles.OverlayActions, "data-inner-element": "ProductCard-OverlayActions", children: _jsx(Stack, { children: overlayActions }) }))] }), _jsx(ProductCard.Header, { "data-inner-element": "ProductCard-Header", title: title, titleRows: titleRows, subtitle: subtitle, description: description, descriptionRows: descriptionRows, isLoading: isLoading }), hasKpis && (_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, expandable: expandable, expandLabel: expandLabel, collapseLabel: collapseLabel, isExpanded: isShowingAllKpis, onExpandedChange: handleExpandedChange })), children && !isLoading && (_jsx(Stack, { hPadding: 16, "data-inner-element": "ProductCard-Children", children: children })), _jsxs("div", { className: styles.Bottom, children: [hasFooterSeparator && _jsx(Separator, {}), _jsx(ProductCard.Footer, { isLoading: isLoading, "data-inner-element": "ProductCard-Footer", children: footer })] })] }) }));
111
+ : (_jsx(Stack, { className: styles.ColoredCard, style: { backgroundColor: getColorFromString(title ?? '') }, hAlign: "center", vAlign: "center", fill: false, "data-inner-element": "ProductCard-ColoredCover", children: _jsx(Text, { variant: "heading-1", textAlign: "center", style: { color: '#fff' }, children: title?.slice(0, 2) }) })) })), badge && !isLoading && (_jsx(Chip, { color: "yellow", className: styles.Badge, "data-inner-element": "ProductCard-Badge", children: badge })), hasOverlay && (_jsx(Stack, { direction: "row", hPadding: 24, vAlign: "center", hAlign: "center", className: styles.OverlayActions, "data-inner-element": "ProductCard-OverlayActions", children: _jsx(Stack, { children: overlayActions }) }))] }), _jsx(ProductCard.Header, { "data-inner-element": "ProductCard-Header", title: title, titleRows: titleRows, subtitle: subtitle, description: description, descriptionRows: descriptionRows, isLoading: isLoading }), hasKpis && (_jsx("div", { className: styles.KpisCollapse, "data-kpis-hidden": isKpisHidden, "aria-hidden": isKpisHidden || undefined, "data-inner-element": "ProductCard-KpisCollapse", children: _jsx("div", { className: styles.KpisCollapseContent, children: _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, expandable: expandable, expandLabel: expandLabel, collapseLabel: collapseLabel, isExpanded: isShowingAllKpis, onExpandedChange: handleExpandedChange }) }) })), children && !isLoading && (_jsx(Stack, { hPadding: 16, "data-inner-element": "ProductCard-Children", children: children })), _jsxs("div", { className: styles.Bottom, children: [hasFooterSeparator && _jsx(Separator, {}), _jsx(ProductCard.Footer, { isLoading: isLoading, "data-inner-element": "ProductCard-Footer", children: footer })] })] }) }));
87
112
  });
88
113
  ProductCard.displayName = 'ProductCard';
89
114
  ProductCard.Media = ProductCardMedia;
@@ -1 +1 @@
1
- @layer components{.Card{background-color:var(--global-background);border-radius:12px;overflow:hidden;padding:0;position:relative}.Card[data-card-bordered=true]{border:1px solid var(--dimmed-1)}.Card[data-card-clickable=true]{cursor:pointer}.Cover{overflow:hidden;position:relative}.Card[data-card-locked=true]>:not(.Cover){flex-shrink:0}.Card[data-card-locked=true] .Cover{flex:1 1 auto;min-height:0}.Badge{position:absolute;right:1rem;top:10px}.Bottom{margin-top:auto}.OverlayActions{background-color:var(--global-background);inset:0;opacity:0;position:absolute;transition:opacity .3s;z-index:1}.OverlayActions:hover{opacity:1}.Card[data-card-locked=true] .OverlayActions:hover{transition-delay:.3s}.ColoredCard{width:100%}}
1
+ @layer components{.Card{--kpis-fade:0.075s;--kpis-collapse:0.15s;background-color:var(--global-background);border-radius:12px;overflow:hidden;padding:0;position:relative}.Card[data-card-bordered=true]{border:1px solid var(--dimmed-1)}.Card[data-card-clickable=true]{cursor:pointer}.Cover{overflow:hidden;position:relative}.Card[data-card-locked=true]>:not(.Cover){flex-shrink:0}.Card[data-card-locked=true] .Cover{flex:1 1 auto;min-height:0}.Badge{position:absolute;right:1rem;top:10px}.Bottom{margin-top:auto}.KpisCollapse{display:grid;grid-template-rows:1fr;opacity:1;transition:grid-template-rows var(--kpis-collapse) cubic-bezier(.3,.07,.34,1),opacity var(--kpis-fade) cubic-bezier(.3,.07,.34,1) var(--kpis-collapse),visibility 0s linear;visibility:visible}.KpisCollapse[data-kpis-hidden=true]{grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--kpis-collapse) cubic-bezier(.3,.07,.34,1) var(--kpis-fade),opacity var(--kpis-fade) cubic-bezier(.3,.07,.34,1),visibility 0s linear calc(var(--kpis-fade) + var(--kpis-collapse));visibility:hidden}@media (prefers-reduced-motion:reduce){.KpisCollapse,.KpisCollapse[data-kpis-hidden=true]{transition:none}}.KpisCollapseContent{min-height:0;overflow:hidden}.OverlayActions{background-color:var(--global-background);inset:0;opacity:0;position:absolute;transition:opacity .2s;z-index:1}.Card[data-card-overlay-open=true] .OverlayActions{opacity:1}.ColoredCard{width:100%}}
@@ -1 +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,EA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C;AAKjD,eAAO,MAAM,gBAAgB,+DAAoB,CAAC;AAiBlD,eAAO,MAAM,aAAa,+DAAoB,CAAC;AAO/C,eAAO,MAAM,mBAAmB,+DAAoB,CAAC;AAQrD,eAAO,MAAM,WAAW,+DAAoB,CAAC;AAQ7C,eAAO,MAAM,eAAe,+DAAoB,CAAC;AAgBjD,eAAO,MAAM,SAAS,+DAAoB,CAAC;AAK3C,eAAO,MAAM,kBAAkB,+DAAoB,CAAC;AAKpD,eAAO,MAAM,gCAAgC,+DAAoB,CAAC;AAMlE,eAAO,MAAM,cAAc,+DAAoB,CAAC;AAkBhD,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,OAAO,WAAW,CAmCnE,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, Stack, Text, } from '../..';
2
+ import { useRef } from 'react';
3
+ import { Button, Container, Grid, Stack, Text, useBreakpointsConfig, } from '../..';
3
4
  import { ProductCard } from './product-card';
4
5
  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
6
  const SourceImages = [
@@ -169,7 +170,23 @@ ExpandableKpis.args = {
169
170
  expandable: true,
170
171
  overlayActions: OverlayButtons,
171
172
  };
172
- export const ExpandableKpisInGrid = args => (_jsxs("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(2, 272px)', gap: '16px' }, children: [_jsx(ProductCard, { ...args }), _jsx(ProductCard, { ...args, expandable: false })] }));
173
+ const GridOverlayButtons = (_jsxs(Stack, { rowGap: 8, children: [_jsx(Button, { children: "Stats" }), _jsx(Button, { kind: "secondary", children: "Compare" }), _jsx(Button, { kind: "secondary", children: "Add to group" }), _jsx(Button, { kind: "secondary", children: "Share" }), _jsx(Button, { kind: "flat", children: "Remove" })] }));
174
+ // Same grid as the Wonderboard catalog (cards view): columns and gutters follow the container width.
175
+ export const ExpandableKpisInGrid = (args) => {
176
+ const containerRef = useRef(null);
177
+ const { value } = useBreakpointsConfig({
178
+ xs: { columns: 1, gutter: 16 },
179
+ sm: { columns: 2, gutter: 16 },
180
+ md: { columns: 3, gutter: 24 },
181
+ lg: { columns: 4, gutter: 24 },
182
+ xl: { columns: 6, gutter: 32 },
183
+ fallback: { columns: 1, gutter: 16 },
184
+ }, containerRef);
185
+ return (_jsx(Container, { children: _jsx(Stack, { vPadding: 32, rowGap: 32, fill: false, ref: containerRef, children: _jsx("div", { style: { paddingTop: '12px' }, children: _jsx(Grid, { rowGap: value.gutter, columnGap: value.gutter, columns: value.columns, filling: false, children: Array.from({ length: 5 }).map((_, i) => (
186
+ // eslint-disable-next-line react/no-array-index-key
187
+ _jsx(Grid.Item, { children: _jsx(ProductCard, { ...args }) }, i))) }) }) }) }));
188
+ };
173
189
  ExpandableKpisInGrid.args = {
174
190
  ...ExpandableKpis.args,
191
+ overlayActions: GridOverlayButtons,
175
192
  };
@@ -78,6 +78,33 @@ describe('<ProductCard>', () => {
78
78
  expect(cover()).not.toBeNull();
79
79
  expect(coloredCover()).toBeNull();
80
80
  });
81
+ test('it should hide the KPIs and lock the card while the overlay actions are open, only when the overlay is available', () => {
82
+ const overlayActions = _jsx("button", { type: "button", children: "Action" });
83
+ const { container, rerender } = render(_jsx(ProductCard, { title: "title", rating: 4.3, overlayActions: overlayActions }));
84
+ const card = () => container.querySelector('[data-card-locked]');
85
+ const cover = () => container.querySelector('[data-inner-element="ProductCard-Cover"]');
86
+ const kpis = () => container.querySelector('[data-inner-element="ProductCard-KpisCollapse"]');
87
+ expect(card().getAttribute('data-card-overlay-open')).toBe('false');
88
+ expect(kpis().getAttribute('data-kpis-hidden')).toBe('false');
89
+ fireEvent.mouseEnter(cover());
90
+ expect(card().getAttribute('data-card-overlay-open')).toBe('true');
91
+ expect(card().getAttribute('data-card-locked')).toBe('true');
92
+ expect(kpis().getAttribute('data-kpis-hidden')).toBe('true');
93
+ expect(kpis().getAttribute('aria-hidden')).toBe('true');
94
+ fireEvent.mouseLeave(cover());
95
+ expect(card().getAttribute('data-card-overlay-open')).toBe('false');
96
+ expect(kpis().getAttribute('data-kpis-hidden')).toBe('false');
97
+ expect(card().getAttribute('data-card-locked')).toBe('true');
98
+ const transitionEnd = createEvent.transitionEnd(kpis());
99
+ Object.defineProperty(transitionEnd, 'propertyName', { value: 'grid-template-rows' });
100
+ fireEvent(kpis(), transitionEnd);
101
+ expect(card().getAttribute('data-card-locked')).toBe('false');
102
+ rerender(_jsx(ProductCard, { title: "title", rating: 4.3, overlayActions: overlayActions, onClick: jest.fn() }));
103
+ fireEvent.mouseEnter(cover());
104
+ expect(card().getAttribute('data-card-overlay-open')).toBe('false');
105
+ expect(card().getAttribute('data-card-locked')).toBe('false');
106
+ expect(kpis().getAttribute('data-kpis-hidden')).toBe('false');
107
+ });
81
108
  test('it should render the footer separator only with a footer or while loading', () => {
82
109
  const { container, rerender } = render(_jsx(ProductCard, { title: "title" }));
83
110
  expect(container.querySelectorAll('hr')).toHaveLength(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "17.3.1",
3
+ "version": "17.5.0",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "Apache-2.0",
@@ -81,9 +81,9 @@
81
81
  "@types/react": "17.0.43",
82
82
  "@types/react-dom": "17.0.14",
83
83
  "@types/react-test-renderer": "18.0.7",
84
- "@wonderflow/config": "17.3.1",
85
- "@wonderflow/tokens": "17.3.1",
86
- "@wonderflow/charts": "17.3.1",
84
+ "@wonderflow/config": "17.5.0",
85
+ "@wonderflow/tokens": "17.5.0",
86
+ "@wonderflow/charts": "17.5.0",
87
87
  "@types/uuid": "9.0.8",
88
88
  "babel-loader": "8.2.5",
89
89
  "cpy-cli": "3.1.1",
@@ -94,7 +94,7 @@
94
94
  "storybook-addon-breakpoints": "1.0.0",
95
95
  "storybook-addon-themes": "6.1.0",
96
96
  "storybook-css-modules-preset": "1.1.1",
97
- "tsconfig": "10.0.2",
97
+ "tsconfig": "10.0.3",
98
98
  "typed-css-modules": "0.7.2",
99
99
  "typescript": "4.8.4",
100
100
  "typescript-plugin-css-modules": "3.4.0"