@tangle-network/ui 11.38.2 → 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 CHANGED
@@ -1,5 +1,13 @@
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
+
3
11
  ## 11.38.2
4
12
 
5
13
  ### Patch Changes
@@ -14,6 +14,9 @@ declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.T
14
14
  * Inverse-surface label for a control whose name is otherwise only an icon.
15
15
  * It is supplementary: the trigger still needs its own accessible name.
16
16
  */
17
- declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
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>>;
18
21
  //#endregion
19
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";
@@ -34,18 +35,21 @@ const TooltipTrigger = TooltipPrimitive.Trigger;
34
35
  * Inverse-surface label for a control whose name is otherwise only an icon.
35
36
  * It is supplementary: the trigger still needs its own accessible name.
36
37
  */
37
- const TooltipContent = React.forwardRef(({ className, sideOffset = 6, asChild, children, ...props }, ref) => /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Content, {
38
- ref,
39
- sideOffset,
40
- 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),
41
- ...props,
42
- asChild: true,
43
- children: /* @__PURE__ */ jsx(SurfaceMotion, {
44
- kind: "tooltip",
45
- asChild,
46
- children
47
- })
48
- }) }));
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
+ });
49
53
  TooltipContent.displayName = TooltipPrimitive.Content.displayName;
50
54
  //#endregion
51
55
  export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/ui",
3
- "version": "11.38.2",
3
+ "version": "11.39.0",
4
4
  "description": "Generic React UI components for Tangle products — primitives, chat, run, files, editor, markdown.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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";
@@ -48,9 +49,12 @@ const TooltipTrigger = TooltipPrimitive.Trigger;
48
49
  */
49
50
  const TooltipContent = React.forwardRef<
50
51
  React.ElementRef<typeof TooltipPrimitive.Content>,
51
- React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
52
- >(({ className, sideOffset = 6, asChild, children, ...props }, ref) => (
53
- <TooltipPrimitive.Portal>
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 = (
54
58
  <TooltipPrimitive.Content
55
59
  ref={ref}
56
60
  sideOffset={sideOffset}
@@ -61,9 +65,13 @@ const TooltipContent = React.forwardRef<
61
65
  )}
62
66
  {...props}
63
67
  asChild
64
- ><SurfaceMotion kind="tooltip" asChild={asChild}>{children}</SurfaceMotion></TooltipPrimitive.Content>
65
- </TooltipPrimitive.Portal>
66
- ));
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
+ });
67
75
  TooltipContent.displayName = TooltipPrimitive.Content.displayName;
68
76
 
69
77
  export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };