@fibery/ui-kit 5.0.0 → 6.0.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.
- package/CHANGELOG.md +10 -0
- package/package.json +2 -2
- package/src/badge.tsx +6 -1
- package/src/tooltip.tsx +2 -2
- package/src/unit/index.tsx +1 -1
- package/src/unit/primitive.tsx +5 -4
- package/src/unit/unit-with-tooltip.tsx +0 -77
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @fibery/ui-kit
|
|
2
2
|
|
|
3
|
+
## 6.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 5d8dd40: Remove UnitWithTooltip — use Tooltip with title/description props and a plain wrapper element instead. Its hand-rolled hover tracking worked around a Safari mouseleave-on-scroll bug that no longer reproduces; unit tooltips now also open on keyboard focus. Tooltip's default content no longer renders empty title/description nodes when only one of the two is provided.
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- b7f6df1: updated badge component added accent state
|
|
12
|
+
|
|
3
13
|
## 5.0.0
|
|
4
14
|
|
|
5
15
|
### Major Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/ui-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"dependencies": {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"tabbable": "5.2.1",
|
|
59
59
|
"vaul": "1.1.2",
|
|
60
60
|
"virtua": "0.48.8",
|
|
61
|
-
"@fibery/helpers": "3.1.0",
|
|
62
61
|
"@fibery/emoji-data": "2.7.3",
|
|
62
|
+
"@fibery/helpers": "3.1.0",
|
|
63
63
|
"@fibery/react": "1.5.4"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
package/src/badge.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {space, textClasses, themeVars} from "./design-system";
|
|
|
6
6
|
|
|
7
7
|
type Props = {
|
|
8
8
|
children: ReactNode;
|
|
9
|
-
kind?: "success" | "error" | "default" | "warning";
|
|
9
|
+
kind?: "success" | "error" | "default" | "warning" | "accent";
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const Badge = forwardRef<HTMLSpanElement, Props>(({children, kind, ...otherProps}, ref) => {
|
|
@@ -39,6 +39,11 @@ export const Badge = forwardRef<HTMLSpanElement, Props>(({children, kind, ...oth
|
|
|
39
39
|
css`
|
|
40
40
|
color: ${themeVars.colorTextBadgeWarning};
|
|
41
41
|
background: ${themeVars.colorBgBadgeWarning};
|
|
42
|
+
`,
|
|
43
|
+
kind === "accent" &&
|
|
44
|
+
css`
|
|
45
|
+
color: ${themeVars.colorTextBadgeAccent};
|
|
46
|
+
background: ${themeVars.colorBgBadgeAccent};
|
|
42
47
|
`
|
|
43
48
|
)}
|
|
44
49
|
>
|
package/src/tooltip.tsx
CHANGED
|
@@ -158,8 +158,8 @@ export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
|
|
|
158
158
|
description,
|
|
159
159
|
content = (title || description) && (
|
|
160
160
|
<>
|
|
161
|
-
<TooltipTitle>{title}</TooltipTitle>
|
|
162
|
-
<TooltipDescription>{description}</TooltipDescription>
|
|
161
|
+
{title && <TooltipTitle>{title}</TooltipTitle>}
|
|
162
|
+
{description && <TooltipDescription>{description}</TooltipDescription>}
|
|
163
163
|
</>
|
|
164
164
|
),
|
|
165
165
|
side,
|
package/src/unit/index.tsx
CHANGED
|
@@ -27,7 +27,7 @@ export const BasicUnit = ({
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const bgColor = props.bgColor || props.readOnly ? themeVars.inputDisabledBgColor : themeVars.transparent;
|
|
30
|
+
const bgColor = props.bgColor || (props.readOnly ? themeVars.inputDisabledBgColor : themeVars.transparent);
|
|
31
31
|
return (
|
|
32
32
|
<UnitPrimitive
|
|
33
33
|
bgColor={bgColor}
|
package/src/unit/primitive.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import type {ComponentProps} from "react";
|
|
|
5
5
|
import {inputOverrides} from "../antd/styles";
|
|
6
6
|
import {border, space, themeVars} from "../design-system";
|
|
7
7
|
import {FieldIcon} from "../field-icon";
|
|
8
|
+
import {Tooltip} from "../tooltip";
|
|
8
9
|
import {useTruncated} from "../tooltip-if-overflown";
|
|
9
10
|
import {
|
|
10
11
|
basicUnitClassName,
|
|
@@ -25,7 +26,6 @@ import {
|
|
|
25
26
|
import type {UnitPrimitiveProps} from "./types";
|
|
26
27
|
import {UnitButtonGroup} from "./unit-button-group";
|
|
27
28
|
import {UnitContent} from "./unit-content";
|
|
28
|
-
import {UnitWithTooltip} from "./unit-with-tooltip";
|
|
29
29
|
|
|
30
30
|
const resetButtonStylesClassName = css`
|
|
31
31
|
all: unset;
|
|
@@ -179,9 +179,10 @@ export const UnitPrimitive = ({
|
|
|
179
179
|
|
|
180
180
|
return (
|
|
181
181
|
<div className={positionUnitClass}>
|
|
182
|
-
<
|
|
183
|
-
{
|
|
184
|
-
|
|
182
|
+
<Tooltip side="bottom" align="start" title={tooltipTitle} description={tooltipDescription}>
|
|
183
|
+
{/* The trigger needs a host element: the unit content root does not forward refs/handlers */}
|
|
184
|
+
<div>{contentWithHeader}</div>
|
|
185
|
+
</Tooltip>
|
|
185
186
|
</div>
|
|
186
187
|
);
|
|
187
188
|
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {css} from "@linaria/core";
|
|
2
|
-
import {useRef, useState} from "react";
|
|
3
|
-
|
|
4
|
-
import {space, tooltipDelay} from "../../src/design-system";
|
|
5
|
-
import {Tooltip, TooltipDescription, TooltipTitle} from "../tooltip";
|
|
6
|
-
|
|
7
|
-
const contentCss = css`
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
gap: ${space.s4}px;
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
children: React.ReactElement;
|
|
15
|
-
title: React.ReactNode;
|
|
16
|
-
description: React.ReactNode;
|
|
17
|
-
hidden?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const UnitWithTooltip = ({children, title, description, hidden}: Props) => {
|
|
21
|
-
const [shouldDisplayTooltip, setShouldDisplayTooltip] = useState(false);
|
|
22
|
-
const unitElementRef = useRef<HTMLDivElement>(null);
|
|
23
|
-
const isHoveredRef = useRef(false);
|
|
24
|
-
const checkHoveredStateTimeoutId = useRef<ReturnType<typeof setTimeout> | null>();
|
|
25
|
-
|
|
26
|
-
const onMouseEnter = () => {
|
|
27
|
-
isHoveredRef.current = true;
|
|
28
|
-
|
|
29
|
-
checkHoveredStateTimeoutId.current = setTimeout(() => {
|
|
30
|
-
checkHoveredStateTimeoutId.current = null;
|
|
31
|
-
// onMouseLeave works unreliably in Safari, IE on scroll
|
|
32
|
-
// Sometimes it was not fired leaving tooltip displayed
|
|
33
|
-
// Had to use additional way to validate if we are still over unit
|
|
34
|
-
if (isHoveredRef.current && unitElementRef.current && unitElementRef.current.matches(":hover")) {
|
|
35
|
-
setShouldDisplayTooltip(true);
|
|
36
|
-
const intervalId = window.setInterval(() => {
|
|
37
|
-
if (isHoveredRef.current && unitElementRef.current) {
|
|
38
|
-
if (!unitElementRef.current.matches(":hover")) {
|
|
39
|
-
isHoveredRef.current = false;
|
|
40
|
-
setShouldDisplayTooltip(false);
|
|
41
|
-
clearInterval(intervalId);
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
clearInterval(intervalId);
|
|
45
|
-
}
|
|
46
|
-
}, 250);
|
|
47
|
-
}
|
|
48
|
-
}, tooltipDelay.enter);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const onMouseLeave = () => {
|
|
52
|
-
isHoveredRef.current = false;
|
|
53
|
-
if (checkHoveredStateTimeoutId.current) {
|
|
54
|
-
clearTimeout(checkHoveredStateTimeoutId.current);
|
|
55
|
-
checkHoveredStateTimeoutId.current = null;
|
|
56
|
-
}
|
|
57
|
-
setShouldDisplayTooltip(false);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Tooltip
|
|
62
|
-
visible={!hidden && shouldDisplayTooltip}
|
|
63
|
-
content={
|
|
64
|
-
<div className={contentCss}>
|
|
65
|
-
<TooltipTitle>{title}</TooltipTitle>
|
|
66
|
-
{description && <TooltipDescription>{description}</TooltipDescription>}
|
|
67
|
-
</div>
|
|
68
|
-
}
|
|
69
|
-
side="bottom"
|
|
70
|
-
align="start"
|
|
71
|
-
>
|
|
72
|
-
<div ref={unitElementRef} onMouseDown={onMouseLeave} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
|
|
73
|
-
{children}
|
|
74
|
-
</div>
|
|
75
|
-
</Tooltip>
|
|
76
|
-
);
|
|
77
|
-
};
|