@redis-ui/components 47.0.0 → 47.0.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.
package/dist/Badge/Badge.cjs
CHANGED
|
@@ -4,10 +4,11 @@ const require_BadgeIcon = require("./BadgeIcon.cjs");
|
|
|
4
4
|
const require_Badge_style = require("./Badge.style.cjs");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
//#region src/Badge/Badge.tsx
|
|
7
|
-
var Badge = ({ label, variant = "default", color, withIcon, icon, ...restBadgeProps }) => {
|
|
7
|
+
var Badge = (0, require("react").forwardRef)(({ label, variant = "default", color, withIcon, icon, ...restBadgeProps }, ref) => {
|
|
8
8
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Badge_style.Badge, {
|
|
9
9
|
$variant: variant,
|
|
10
10
|
$color: color,
|
|
11
|
+
ref,
|
|
11
12
|
...restBadgeProps,
|
|
12
13
|
children: [withIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_BadgeIcon.BadgeIcon, {
|
|
13
14
|
variant,
|
|
@@ -19,6 +20,6 @@ var Badge = ({ label, variant = "default", color, withIcon, icon, ...restBadgePr
|
|
|
19
20
|
children: label
|
|
20
21
|
})]
|
|
21
22
|
});
|
|
22
|
-
};
|
|
23
|
+
});
|
|
23
24
|
//#endregion
|
|
24
25
|
exports.default = Badge;
|
package/dist/Badge/Badge.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BadgeProps } from './Badge.types';
|
|
2
|
-
declare const Badge: (
|
|
2
|
+
declare const Badge: import("react").ForwardRefExoticComponent<BadgeProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
3
|
export default Badge;
|
package/dist/Badge/Badge.js
CHANGED
|
@@ -2,11 +2,13 @@ import Typography from "../Typography/Typography.js";
|
|
|
2
2
|
import { BadgeIcon } from "./BadgeIcon.js";
|
|
3
3
|
import { Badge as Badge$1 } from "./Badge.style.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { forwardRef } from "react";
|
|
5
6
|
//#region src/Badge/Badge.tsx
|
|
6
|
-
var Badge = ({ label, variant = "default", color, withIcon, icon, ...restBadgeProps }) => {
|
|
7
|
+
var Badge = forwardRef(({ label, variant = "default", color, withIcon, icon, ...restBadgeProps }, ref) => {
|
|
7
8
|
return /* @__PURE__ */ jsxs(Badge$1, {
|
|
8
9
|
$variant: variant,
|
|
9
10
|
$color: color,
|
|
11
|
+
ref,
|
|
10
12
|
...restBadgeProps,
|
|
11
13
|
children: [withIcon && /* @__PURE__ */ jsx(BadgeIcon, {
|
|
12
14
|
variant,
|
|
@@ -18,6 +20,6 @@ var Badge = ({ label, variant = "default", color, withIcon, icon, ...restBadgePr
|
|
|
18
20
|
children: label
|
|
19
21
|
})]
|
|
20
22
|
});
|
|
21
|
-
};
|
|
23
|
+
});
|
|
22
24
|
//#endregion
|
|
23
25
|
export { Badge as default };
|
package/package.json
CHANGED
|
@@ -8,6 +8,12 @@ Compact status badge with variant-based coloring and optional icons.
|
|
|
8
8
|
import { Badge } from '@redis-ui/components';
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
For tooltip examples:
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Badge, Tooltip } from '@redis-ui/components';
|
|
15
|
+
```
|
|
16
|
+
|
|
11
17
|
If you pass a custom icon in examples, import it from `@redis-ui/icons`.
|
|
12
18
|
|
|
13
19
|
## Props
|
|
@@ -41,6 +47,16 @@ import { Badge } from '@redis-ui/components';
|
|
|
41
47
|
<Badge label="Badge" withIcon color="#0366d6" />
|
|
42
48
|
```
|
|
43
49
|
|
|
50
|
+
### WithTooltip
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { Badge, Tooltip } from '@redis-ui/components';
|
|
54
|
+
|
|
55
|
+
<Tooltip content="hello world">
|
|
56
|
+
<Badge label="New" variant="informative" withIcon tabIndex={0} />
|
|
57
|
+
</Tooltip>
|
|
58
|
+
```
|
|
59
|
+
|
|
44
60
|
### Icons
|
|
45
61
|
|
|
46
62
|
> `Badge` can be rendered with or without an icon using `withIcon`. Pass `icon` to customize the icon.
|
|
@@ -75,3 +91,5 @@ import { Badge, badgeVariants } from '@redis-ui/components';
|
|
|
75
91
|
- `withIcon` uses the default icon for the selected variant when `icon` is not provided.
|
|
76
92
|
- `variant` controls both the badge surface color and the default icon choice.
|
|
77
93
|
- `color` overrides the badge accent color directly and is used instead of the theme variant color.
|
|
94
|
+
- `Badge` forwards refs to its root `HTMLDivElement`, so it can be used directly as a trigger for components such as `Tooltip`.
|
|
95
|
+
- When using `Badge` as a tooltip trigger, pass `tabIndex={0}` so keyboard users can focus the badge and open the tooltip.
|