@tangle-network/ui 11.38.1 → 11.39.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 +14 -0
- package/dist/primitives/tooltip.d.ts +8 -2
- package/dist/primitives/tooltip.js +28 -13
- package/package.json +1 -1
- package/src/primitives/tooltip.tsx +29 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @tangle-network/ui
|
|
2
2
|
|
|
3
|
+
## 11.39.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f10bf8a: Support TooltipContent portal={false} for content that belongs to its local container. Keep the default portal, shared Content/SurfaceMotion owner, positioning, forwarded refs, asChild and Root state APIs.
|
|
8
|
+
|
|
9
|
+
Preserve the caller as the asChild slot target when Radix adds accessibility content.
|
|
10
|
+
|
|
11
|
+
## 11.38.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- b33914e: Keep accepted Tooltip reopens open while exit content is retained. Preserve controlled/defaultOpen APIs, native disabled-trigger descriptions and sibling-tooltip dismissal through the shared Root owner.
|
|
16
|
+
|
|
3
17
|
## 11.38.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -5,12 +5,18 @@ declare function TooltipProvider({ delayDuration, skipDelayDuration, ...props }:
|
|
|
5
5
|
declare namespace TooltipProvider {
|
|
6
6
|
var displayName: string;
|
|
7
7
|
}
|
|
8
|
-
declare
|
|
8
|
+
declare function Tooltip({ open, defaultOpen, onOpenChange, ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): React.JSX.Element;
|
|
9
|
+
declare namespace Tooltip {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
9
12
|
declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
10
13
|
/**
|
|
11
14
|
* Inverse-surface label for a control whose name is otherwise only an icon.
|
|
12
15
|
* It is supplementary: the trigger still needs its own accessible name.
|
|
13
16
|
*/
|
|
14
|
-
declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> &
|
|
17
|
+
declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
18
|
+
/** Render through a portal; use false to keep content in its local owner. */
|
|
19
|
+
portal?: boolean;
|
|
20
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
15
21
|
//#endregion
|
|
16
22
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { surfaceMotion } from "../lib/motion.js";
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
4
|
import { SurfaceMotion } from "../lib/surface-motion.js";
|
|
5
|
+
import { Slottable } from "@radix-ui/react-slot";
|
|
5
6
|
import * as React from "react";
|
|
6
7
|
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
@@ -17,24 +18,38 @@ const TooltipProvider = ({ delayDuration = 400, skipDelayDuration = 300, ...prop
|
|
|
17
18
|
...props
|
|
18
19
|
});
|
|
19
20
|
TooltipProvider.displayName = "TooltipProvider";
|
|
20
|
-
const Tooltip =
|
|
21
|
+
const Tooltip = ({ open, defaultOpen = false, onOpenChange, ...props }) => {
|
|
22
|
+
const [localOpen, setLocalOpen] = React.useState(defaultOpen);
|
|
23
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Root, {
|
|
24
|
+
...props,
|
|
25
|
+
open: open ?? localOpen,
|
|
26
|
+
onOpenChange: (next) => {
|
|
27
|
+
if (open === void 0) setLocalOpen(next);
|
|
28
|
+
onOpenChange?.(next);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
Tooltip.displayName = "Tooltip";
|
|
21
33
|
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
22
34
|
/**
|
|
23
35
|
* Inverse-surface label for a control whose name is otherwise only an icon.
|
|
24
36
|
* It is supplementary: the trigger still needs its own accessible name.
|
|
25
37
|
*/
|
|
26
|
-
const TooltipContent = React.forwardRef(({ className, sideOffset = 6, asChild, children, ...props }, ref) =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
+
const TooltipContent = React.forwardRef(({ className, sideOffset = 6, asChild, children, portal = true, ...props }, ref) => {
|
|
39
|
+
const content = /* @__PURE__ */ jsx(TooltipPrimitive.Content, {
|
|
40
|
+
ref,
|
|
41
|
+
sideOffset,
|
|
42
|
+
className: cn("z-50 max-w-xs origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-2.5 py-1.5 text-background text-xs leading-snug shadow-md", surfaceMotion, className),
|
|
43
|
+
...props,
|
|
44
|
+
asChild: true,
|
|
45
|
+
children: /* @__PURE__ */ jsx(SurfaceMotion, {
|
|
46
|
+
kind: "tooltip",
|
|
47
|
+
asChild,
|
|
48
|
+
children: asChild ? /* @__PURE__ */ jsx(Slottable, { children }) : children
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
return portal ? /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: content }) : content;
|
|
52
|
+
});
|
|
38
53
|
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
39
54
|
//#endregion
|
|
40
55
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
4
|
+
import { Slottable } from "@radix-ui/react-slot";
|
|
4
5
|
import * as React from "react";
|
|
5
6
|
import { SurfaceMotion } from "../lib/surface-motion";
|
|
6
7
|
import { surfaceMotion } from "../lib/motion";
|
|
@@ -24,7 +25,21 @@ const TooltipProvider = ({
|
|
|
24
25
|
);
|
|
25
26
|
TooltipProvider.displayName = "TooltipProvider";
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
// Keep Radix on its controlled path even for the public uncontrolled API.
|
|
29
|
+
// Its global tooltip.open event then runs before the new open state commits:
|
|
30
|
+
// a retained content listener cannot turn its own accepted reopen into Close.
|
|
31
|
+
const Tooltip = ({ open, defaultOpen = false, onOpenChange, ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>) => {
|
|
32
|
+
const [localOpen, setLocalOpen] = React.useState(defaultOpen);
|
|
33
|
+
return <TooltipPrimitive.Root
|
|
34
|
+
{...props}
|
|
35
|
+
open={open ?? localOpen}
|
|
36
|
+
onOpenChange={(next) => {
|
|
37
|
+
if (open === undefined) setLocalOpen(next);
|
|
38
|
+
onOpenChange?.(next);
|
|
39
|
+
}}
|
|
40
|
+
/>;
|
|
41
|
+
};
|
|
42
|
+
Tooltip.displayName = "Tooltip";
|
|
28
43
|
|
|
29
44
|
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
30
45
|
|
|
@@ -34,9 +49,12 @@ const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
|
34
49
|
*/
|
|
35
50
|
const TooltipContent = React.forwardRef<
|
|
36
51
|
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
37
|
-
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {
|
|
53
|
+
/** Render through a portal; use false to keep content in its local owner. */
|
|
54
|
+
portal?: boolean;
|
|
55
|
+
}
|
|
56
|
+
>(({ className, sideOffset = 6, asChild, children, portal = true, ...props }, ref) => {
|
|
57
|
+
const content = (
|
|
40
58
|
<TooltipPrimitive.Content
|
|
41
59
|
ref={ref}
|
|
42
60
|
sideOffset={sideOffset}
|
|
@@ -47,9 +65,13 @@ const TooltipContent = React.forwardRef<
|
|
|
47
65
|
)}
|
|
48
66
|
{...props}
|
|
49
67
|
asChild
|
|
50
|
-
><SurfaceMotion kind="tooltip" asChild={asChild}>
|
|
51
|
-
|
|
52
|
-
|
|
68
|
+
><SurfaceMotion kind="tooltip" asChild={asChild}>
|
|
69
|
+
{/* Keep the caller as the slot target when Radix adds accessibility children. */}
|
|
70
|
+
{asChild ? <Slottable>{children}</Slottable> : children}
|
|
71
|
+
</SurfaceMotion></TooltipPrimitive.Content>
|
|
72
|
+
);
|
|
73
|
+
return portal ? <TooltipPrimitive.Portal>{content}</TooltipPrimitive.Portal> : content;
|
|
74
|
+
});
|
|
53
75
|
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
54
76
|
|
|
55
77
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|