@mrshmllw/smores-react 9.25.0-crumbs-feature-add-rightSideComponent-in-SupportMessage.1 → 9.26.0-crumbs-feature-improve-tooltip.1
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.
@@ -30,7 +30,7 @@ export const RowActions = ({ rowData, rowActions, expandable, isExpanded, toggle
|
|
30
30
|
await handleAction(e, action.onClick);
|
31
31
|
} }, action.genericButton.children)),
|
32
32
|
!("element" in action) && action.iconButton &&
|
33
|
-
(action.iconButton?.tooltipText ? (React.createElement(Tooltip, { content: action.iconButton.tooltipText, position: 'bottom',
|
33
|
+
(action.iconButton?.tooltipText ? (React.createElement(Tooltip, { content: action.iconButton.tooltipText, position: 'bottom', bgColor: 'bubblegum' },
|
34
34
|
React.createElement(IconStrict, { ...action.iconButton, handleClick: async (e) => {
|
35
35
|
await handleAction(e, action.onClick);
|
36
36
|
} }))) : (React.createElement(IconStrict, { ...action.iconButton, handleClick: async (e) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RowActions.js","sourceRoot":"","sources":["../../../src/Table/components/RowActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAmB,EAC3C,OAAO,EACP,UAAU,EACV,UAAU,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AM,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;wCACvC,CAAC,GACD,CACM,CACX,CAAC,CAAC,CAAC,CACF,oBAAC,UAAU,OACL,MAAM,CAAC,UAAU,EACrB,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;wCACvB,MAAM,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;oCACvC,CAAC,GACD,CACH,CAAC,CACI,CACX,CAAA;oBACH,CAAC;oBACD,OAAO,IAAI,CAAA;gBACb,CAAC,CAAC;YACH,UAAU,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CACpC,oBAAC,SAAS,IACR,MAAM,EAAC,OAAO,EACd,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE;oBACjB,CAAC,CAAC,eAAe,EAAE,CAAA;oBACnB,eAAe,EAAE,CAAA;gBACnB,CAAC,EACD,IAAI,EAAE,EAAE,aACC,UAAU,EACnB,eAAe,EAAC,OAAO,GACvB,CACH,CACG,CACK,CACd,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;;;;;;;;MAUrB,iBAAiB;;CAEtB,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAClC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;iBACF,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc;;GAExD,CACF,CAAA"}
|
@@ -1,28 +1,41 @@
|
|
1
1
|
import React, { FC, ReactNode } from 'react';
|
2
2
|
import { Color } from '../theme';
|
3
|
-
|
4
|
-
type ArrowPosition = Position | 'center';
|
3
|
+
import { type Placement } from '@floating-ui/react';
|
5
4
|
export interface TooltipProps {
|
6
5
|
children: ReactNode;
|
7
6
|
content: string | ReactNode;
|
8
|
-
position:
|
7
|
+
position: Placement;
|
9
8
|
maxWidth?: number;
|
10
9
|
title?: string;
|
11
10
|
underline?: boolean;
|
12
|
-
|
11
|
+
variant?: TooltipVariant;
|
13
12
|
zIndex?: number;
|
14
|
-
portalContainer?:
|
15
|
-
|
13
|
+
portalContainer?: HTMLElement | null | React.MutableRefObject<HTMLElement | null>;
|
14
|
+
bgColor?: Color;
|
15
|
+
/**
|
16
|
+
* If true, the tooltip will position itself inline its children
|
17
|
+
*
|
18
|
+
* Used for inline content like blocks of text that span multiple lines
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* ```tsx
|
22
|
+
* <Text>
|
23
|
+
* Marshmallow car insurance, the best insurance in town.
|
24
|
+
* <Tooltip inline content="Tooltip content">Hover here</Tooltip>
|
25
|
+
* to learn more as the Policy Holder
|
26
|
+
* </Text>
|
27
|
+
* ```
|
28
|
+
*/
|
29
|
+
inline?: boolean;
|
30
|
+
}
|
31
|
+
export declare enum TooltipVariant {
|
32
|
+
PRIMARY = "PRIMARY",
|
33
|
+
FALLBACK = "FALLBACK"
|
16
34
|
}
|
17
35
|
export declare const Tooltip: FC<TooltipProps>;
|
18
|
-
export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
19
36
|
export declare const Tip: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
20
37
|
$showTip: boolean;
|
21
|
-
$position: Position;
|
22
|
-
$arrowPosition: ArrowPosition;
|
23
38
|
$maxWidth?: number;
|
24
|
-
$fallbackStyle?: boolean;
|
25
39
|
$zIndex: number;
|
26
|
-
$background
|
40
|
+
$background: string;
|
27
41
|
}>> & string;
|
28
|
-
export {};
|
package/dist/Tooltip/Tooltip.js
CHANGED
@@ -1,228 +1,81 @@
|
|
1
|
-
import React, {
|
2
|
-
import { createPortal } from 'react-dom';
|
1
|
+
import React, { useRef, useState } from 'react';
|
3
2
|
import styled, { css } from 'styled-components';
|
4
3
|
import { Box } from '../Box';
|
5
4
|
import { Text } from '../Text';
|
6
|
-
import { useEventListener } from '../hooks';
|
7
5
|
import { theme } from '../theme';
|
8
|
-
import {
|
9
|
-
export
|
10
|
-
|
11
|
-
|
6
|
+
import { autoUpdate, flip, FloatingPortal, offset, shift, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole, arrow, FloatingArrow, inline, } from '@floating-ui/react';
|
7
|
+
export var TooltipVariant;
|
8
|
+
(function (TooltipVariant) {
|
9
|
+
TooltipVariant["PRIMARY"] = "PRIMARY";
|
10
|
+
TooltipVariant["FALLBACK"] = "FALLBACK";
|
11
|
+
})(TooltipVariant || (TooltipVariant = {}));
|
12
|
+
const tooltipVariants = {
|
13
|
+
[TooltipVariant.PRIMARY]: {
|
14
|
+
textColor: 'liquorice',
|
15
|
+
},
|
16
|
+
[TooltipVariant.FALLBACK]: {
|
17
|
+
textColor: 'cream',
|
18
|
+
},
|
19
|
+
};
|
20
|
+
const ARROW_HEIGHT = 8;
|
21
|
+
const GAP = 4;
|
22
|
+
export const Tooltip = ({ children, title, content, position, maxWidth = 500, underline = false, zIndex = 10, portalContainer, bgColor: bgColorProp, inline: inlineProp, variant = TooltipVariant.PRIMARY, }) => {
|
12
23
|
const [showTip, setShowTip] = useState(false);
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const
|
24
|
+
const arrowRef = useRef(null);
|
25
|
+
const variantValue = tooltipVariants[variant];
|
26
|
+
const bgColor = bgColorProp ? theme.colors[bgColorProp] : theme.colors.custard;
|
16
27
|
const randomId = crypto.randomUUID();
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
setTooltipPosition('top');
|
30
|
-
return;
|
31
|
-
}
|
32
|
-
// if top out of bounds
|
33
|
-
if (dimensions.top < 0) {
|
34
|
-
setTooltipPosition('bottom');
|
35
|
-
return;
|
36
|
-
}
|
37
|
-
// if right out of bounds
|
38
|
-
if (dimensions.right > window.innerWidth) {
|
39
|
-
setTooltipPosition('left');
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
// if left out of bounds
|
43
|
-
if (dimensions.left < 0) {
|
44
|
-
setTooltipPosition('right');
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
// If bottom out of bounds
|
48
|
-
if (dimensions.bottom > window.innerHeight) {
|
49
|
-
setTooltipPosition('top');
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
}, [tipContainer, tooltipPosition]);
|
53
|
-
useEffect(() => {
|
54
|
-
handleTipViewport();
|
55
|
-
setChildEl(document.getElementById(randomId));
|
56
|
-
}, []);
|
57
|
-
useEffect(() => {
|
58
|
-
setTooltipPosition(position);
|
59
|
-
}, [position]);
|
60
|
-
const arrowSize = 18;
|
61
|
-
const calculateTooltipPosition = () => {
|
62
|
-
if (!childEl)
|
63
|
-
return { top: 0, left: 0 };
|
64
|
-
if (!tipContainer.current)
|
65
|
-
return { top: 0, left: 0 };
|
66
|
-
const childPosition = childEl.getBoundingClientRect();
|
67
|
-
const tipDimensions = tipContainer.current.getBoundingClientRect();
|
68
|
-
let top = 0;
|
69
|
-
let left = 0;
|
70
|
-
switch (tooltipPosition) {
|
71
|
-
case 'top':
|
72
|
-
top =
|
73
|
-
childPosition.top + window.scrollY - tipDimensions.height - arrowSize;
|
74
|
-
left =
|
75
|
-
childPosition.left +
|
76
|
-
window.scrollX +
|
77
|
-
childPosition.width / 2 -
|
78
|
-
tipDimensions.width / 2;
|
79
|
-
break;
|
80
|
-
case 'bottom':
|
81
|
-
top = childPosition.bottom + window.scrollY + arrowSize;
|
82
|
-
left =
|
83
|
-
childPosition.left +
|
84
|
-
window.scrollX +
|
85
|
-
childPosition.width / 2 -
|
86
|
-
tipDimensions.width / 2;
|
87
|
-
break;
|
88
|
-
case 'left':
|
89
|
-
left =
|
90
|
-
childPosition.left + window.scrollX - tipDimensions.width - arrowSize;
|
91
|
-
top =
|
92
|
-
childPosition.top +
|
93
|
-
window.scrollY +
|
94
|
-
childPosition.height / 2 -
|
95
|
-
tipDimensions.height / 2;
|
96
|
-
break;
|
97
|
-
case 'right':
|
98
|
-
left = childPosition.right + window.scrollX + arrowSize;
|
99
|
-
top =
|
100
|
-
childPosition.top +
|
101
|
-
window.scrollY +
|
102
|
-
childPosition.height / 2 -
|
103
|
-
tipDimensions.height / 2;
|
104
|
-
break;
|
105
|
-
default:
|
106
|
-
break;
|
107
|
-
}
|
108
|
-
return { top, left };
|
109
|
-
};
|
110
|
-
useEffect(() => {
|
111
|
-
if (childEl) {
|
112
|
-
setTooltipCoords(calculateTooltipPosition());
|
113
|
-
}
|
114
|
-
}, [
|
115
|
-
position,
|
116
|
-
window.scrollY,
|
117
|
-
tipContainer.current,
|
118
|
-
childEl,
|
119
|
-
childEl?.getBoundingClientRect().top,
|
120
|
-
childEl?.getBoundingClientRect().left,
|
121
|
-
]);
|
122
|
-
useEventListener({
|
123
|
-
eventName: 'resize',
|
124
|
-
callback: debounce(handleTipViewport, 100),
|
125
|
-
ref: documentRef,
|
126
|
-
});
|
127
|
-
useEventListener({
|
128
|
-
eventName: 'scroll',
|
129
|
-
callback: debounce(handleTipViewport, 100),
|
130
|
-
ref: documentRef,
|
28
|
+
const { refs, floatingStyles, context } = useFloating({
|
29
|
+
open: showTip,
|
30
|
+
placement: position,
|
31
|
+
onOpenChange: setShowTip,
|
32
|
+
middleware: [
|
33
|
+
offset(ARROW_HEIGHT + GAP),
|
34
|
+
flip(),
|
35
|
+
shift(),
|
36
|
+
inlineProp ? inline() : undefined,
|
37
|
+
arrow({ element: arrowRef, padding: 14 }),
|
38
|
+
],
|
39
|
+
whileElementsMounted: autoUpdate,
|
131
40
|
});
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
41
|
+
const hover = useHover(context, { move: false });
|
42
|
+
const focus = useFocus(context);
|
43
|
+
const dismiss = useDismiss(context);
|
44
|
+
const role = useRole(context, { role: 'tooltip' });
|
45
|
+
// Merge all the interactions into prop getters
|
46
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
47
|
+
hover,
|
48
|
+
focus,
|
49
|
+
dismiss,
|
50
|
+
role,
|
51
|
+
]);
|
52
|
+
return (React.createElement(React.Fragment, null,
|
53
|
+
React.createElement(UnderlinedChild, { id: randomId, "$inline": inlineProp, "$underline": underline, ref: refs.setReference, ...getReferenceProps() }, children),
|
54
|
+
showTip && (React.createElement(FloatingPortal, { root: portalContainer },
|
55
|
+
React.createElement(Tip, { ref: refs.setFloating, className: "tooltip", "$showTip": showTip, "$maxWidth": maxWidth, "$zIndex": zIndex, "$background": bgColor, style: floatingStyles, ...getFloatingProps() },
|
56
|
+
React.createElement(FloatingArrow, { ref: arrowRef, context: context, fill: bgColor }),
|
57
|
+
title && (React.createElement(Text, { tag: "h5", typo: "desc-medium", color: variantValue.textColor }, title)),
|
58
|
+
(typeof content === 'string' && (React.createElement(Text, { typo: "desc-light", color: variantValue.textColor }, content))) ||
|
59
|
+
content)))));
|
143
60
|
};
|
144
|
-
export const Container = styled.div `
|
145
|
-
display: flex;
|
146
|
-
align-items: center;
|
147
|
-
justify-content: center;
|
148
|
-
|
149
|
-
> span:hover + .tooltip {
|
150
|
-
opacity: 1;
|
151
|
-
}
|
152
|
-
`;
|
153
61
|
const UnderlinedChild = styled(Box) `
|
154
62
|
cursor: pointer;
|
63
|
+
width: fit-content;
|
64
|
+
|
65
|
+
${({ $inline }) => $inline &&
|
66
|
+
css `
|
67
|
+
display: inline;
|
68
|
+
`}
|
69
|
+
|
155
70
|
${({ $underline }) => $underline &&
|
156
71
|
css `
|
157
72
|
border-bottom: 1px dashed ${theme.colors.marshmallowPink};
|
158
73
|
`}
|
159
74
|
`;
|
160
|
-
const arrowInset = 26;
|
161
|
-
const arrowCenterPosition = 'calc(50% - 6px)';
|
162
|
-
const arrowVerticalCenter = 'calc(50% - 12px)';
|
163
|
-
const handleHorizontalArrowPosition = (arrowPosition) => {
|
164
|
-
switch (arrowPosition) {
|
165
|
-
case 'left':
|
166
|
-
return css `
|
167
|
-
left: ${arrowInset}px;
|
168
|
-
`;
|
169
|
-
case 'right':
|
170
|
-
return css `
|
171
|
-
right: ${arrowInset}px;
|
172
|
-
`;
|
173
|
-
default:
|
174
|
-
return css `
|
175
|
-
left: ${arrowCenterPosition};
|
176
|
-
`;
|
177
|
-
}
|
178
|
-
};
|
179
|
-
const handleVerticalArrowPosition = (arrowPosition) => {
|
180
|
-
switch (arrowPosition) {
|
181
|
-
case 'top':
|
182
|
-
return css `
|
183
|
-
top: ${arrowInset}px;
|
184
|
-
`;
|
185
|
-
case 'bottom':
|
186
|
-
return css `
|
187
|
-
bottom: ${arrowInset}px;
|
188
|
-
`;
|
189
|
-
default:
|
190
|
-
return css `
|
191
|
-
top: ${arrowVerticalCenter};
|
192
|
-
`;
|
193
|
-
}
|
194
|
-
};
|
195
|
-
const top = css `
|
196
|
-
&:before {
|
197
|
-
bottom: -15px;
|
198
|
-
transform: rotate(-90deg);
|
199
|
-
${({ $arrowPosition }) => handleHorizontalArrowPosition($arrowPosition)}
|
200
|
-
}
|
201
|
-
`;
|
202
|
-
const bottom = css `
|
203
|
-
&:before {
|
204
|
-
top: -15px;
|
205
|
-
transform: rotate(90deg);
|
206
|
-
${({ $arrowPosition }) => handleHorizontalArrowPosition($arrowPosition)}
|
207
|
-
}
|
208
|
-
`;
|
209
|
-
const left = css `
|
210
|
-
&:before {
|
211
|
-
right: -11px;
|
212
|
-
transform: rotate(180deg);
|
213
|
-
${({ $arrowPosition }) => handleVerticalArrowPosition($arrowPosition)}
|
214
|
-
}
|
215
|
-
`;
|
216
|
-
const right = css `
|
217
|
-
&:before {
|
218
|
-
left: -11px;
|
219
|
-
${({ $arrowPosition }) => handleVerticalArrowPosition($arrowPosition)}
|
220
|
-
}
|
221
|
-
`;
|
222
75
|
export const Tip = styled.div `
|
223
76
|
position: absolute;
|
224
77
|
margin: auto;
|
225
|
-
background: ${({ $background }) => $background
|
78
|
+
background: ${({ $background }) => $background};
|
226
79
|
padding: 16px 12px 20px;
|
227
80
|
border-radius: 16px;
|
228
81
|
max-width: 450px;
|
@@ -235,28 +88,5 @@ export const Tip = styled.div `
|
|
235
88
|
// this is the trick that will make sure the content can go up to maxWidth
|
236
89
|
margin-right: ${({ $maxWidth }) => $maxWidth && -$maxWidth / 2 + 'px'};
|
237
90
|
max-width: ${({ $maxWidth }) => $maxWidth && $maxWidth + 'px'};
|
238
|
-
|
239
|
-
${({ $arrowPosition }) => $arrowPosition === 'top' && top}
|
240
|
-
${({ $arrowPosition }) => $arrowPosition === 'bottom' && bottom}
|
241
|
-
${({ $arrowPosition }) => $arrowPosition === 'left' && left}
|
242
|
-
${({ $arrowPosition }) => $arrowPosition === 'right' && right}
|
243
|
-
|
244
|
-
&:before {
|
245
|
-
content: '';
|
246
|
-
border-style: solid;
|
247
|
-
border-width: 12px 12px 12px 0;
|
248
|
-
border-color: transparent
|
249
|
-
${({ $background }) => $background ? theme.colors[$background] : theme.colors.custard}
|
250
|
-
transparent transparent;
|
251
|
-
position: absolute;
|
252
|
-
}
|
253
|
-
|
254
|
-
${({ $fallbackStyle }) => $fallbackStyle &&
|
255
|
-
css `
|
256
|
-
background: ${theme.colors.feijoa};
|
257
|
-
&:before {
|
258
|
-
border-color: transparent ${theme.colors.feijoa} transparent transparent;
|
259
|
-
}
|
260
|
-
`};
|
261
91
|
`;
|
262
92
|
//# sourceMappingURL=Tooltip.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK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AG,CAAC,CAAC,CAAC,GAAG,CAAC;;;;aAIxC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;;;kBAGtC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,IAAI;eACxD,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,IAAI,SAAS,GAAG,IAAI;CAC9D,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mrshmllw/smores-react",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.26.0-crumbs-feature-improve-tooltip.1",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"description": "Collection of React components used by Marshmallow Technology",
|
6
6
|
"keywords": [
|
@@ -33,12 +33,12 @@
|
|
33
33
|
"fix-package-lock-conflicts": "echo \"Make sure conflicts in package.json are resolved before running this script\" && npm i --package-lock-only"
|
34
34
|
},
|
35
35
|
"devDependencies": {
|
36
|
-
"@babel/core": "^7.
|
37
|
-
"@babel/eslint-parser": "^7.25.
|
38
|
-
"@babel/plugin-transform-class-properties": "^7.25.
|
39
|
-
"@babel/preset-env": "^7.
|
40
|
-
"@babel/preset-react": "^7.25.
|
41
|
-
"@babel/preset-typescript": "^7.
|
36
|
+
"@babel/core": "^7.26.0",
|
37
|
+
"@babel/eslint-parser": "^7.25.9",
|
38
|
+
"@babel/plugin-transform-class-properties": "^7.25.9",
|
39
|
+
"@babel/preset-env": "^7.26.0",
|
40
|
+
"@babel/preset-react": "^7.25.9",
|
41
|
+
"@babel/preset-typescript": "^7.26.0",
|
42
42
|
"@commitlint/cli": "^19.5.0",
|
43
43
|
"@commitlint/types": "^19.5.0",
|
44
44
|
"@semantic-release/changelog": "^6.0.3",
|
@@ -76,7 +76,7 @@
|
|
76
76
|
"react": "^18.2.0",
|
77
77
|
"react-dom": "^18.2.0",
|
78
78
|
"rimraf": "^6.0.1",
|
79
|
-
"semantic-release": "^24.
|
79
|
+
"semantic-release": "^24.2.0",
|
80
80
|
"storybook": "^8.0.4",
|
81
81
|
"styled-components": "^6.1.13",
|
82
82
|
"typescript": "^5.6.3",
|
@@ -84,6 +84,7 @@
|
|
84
84
|
"vitest": "^2.1.4"
|
85
85
|
},
|
86
86
|
"dependencies": {
|
87
|
+
"@floating-ui/react": "0.26.27",
|
87
88
|
"@lexical/react": "^0.18.0",
|
88
89
|
"body-scroll-lock": "^4.0.0-beta.0",
|
89
90
|
"date-fns": "^4.1.0",
|