@parallelworks/ui 0.83.0 → 0.83.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.
@@ -28,4 +28,4 @@ export interface TooltipProps extends Omit<BaseTooltip.Trigger.Props, 'content'
28
28
  /** A visual hint for sighted pointer and keyboard users. The anchor still needs
29
29
  * its own accessible name; `describesAnchor` also gives assistive technology the
30
30
  * hint. Use InfoTip for content everyone must reach, such as on a touch screen. */
31
- export declare function Tooltip({ content, children, side, shortcut, disabled, overflowOnly, describesAnchor, ...anchorProps }: TooltipProps): import("react").JSX.Element;
31
+ export declare function Tooltip({ content, children, side, shortcut, disabled, overflowOnly, describesAnchor, ref, ...anchorProps }: TooltipProps): import("react").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { positionerClassName, tipClassName } from "./floating.js";
2
2
  import { usePopupContainer } from "./popupContainer.js";
3
3
  import { Kbd } from "./Kbd.js";
4
- import { cloneElement, createContext, use, useEffect, useId, useState } from "react";
4
+ import { cloneElement, createContext, use, useCallback, useEffect, useId, useState } from "react";
5
5
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { Tooltip } from "@base-ui/react/tooltip";
7
7
  //#region src/components/Tooltip.tsx
@@ -82,13 +82,36 @@ function useRestAfterPopup(anchor) {
82
82
  }, [anchor]);
83
83
  return resting;
84
84
  }
85
+ /** Sets a ref and returns how to unset it: a callback ref's own cleanup, or a call with null. */
86
+ function assignRef(ref, node) {
87
+ if (typeof ref === "function") {
88
+ const cleanup = ref(node);
89
+ return typeof cleanup === "function" ? cleanup : () => ref(null);
90
+ }
91
+ if (ref) {
92
+ ref.current = node;
93
+ return () => {
94
+ ref.current = null;
95
+ };
96
+ }
97
+ return () => {};
98
+ }
85
99
  /** A visual hint for sighted pointer and keyboard users. The anchor still needs
86
100
  * its own accessible name; `describesAnchor` also gives assistive technology the
87
101
  * hint. Use InfoTip for content everyone must reach, such as on a touch screen. */
88
- function Tooltip$1({ content, children, side = "top", shortcut, disabled = false, overflowOnly = false, describesAnchor = false, ...anchorProps }) {
102
+ function Tooltip$1({ content, children, side = "top", shortcut, disabled = false, overflowOnly = false, describesAnchor = false, ref, ...anchorProps }) {
89
103
  const handle = use(TooltipHandleContext);
90
104
  const descriptionId = useId();
91
105
  const [anchorElement, setAnchorElement] = useState(null);
106
+ const anchorRef = useCallback((node) => {
107
+ if (!node) return;
108
+ setAnchorElement(node);
109
+ const unset = assignRef(ref, node);
110
+ return () => {
111
+ setAnchorElement(null);
112
+ unset();
113
+ };
114
+ }, [ref]);
92
115
  const resting = useRestAfterPopup(anchorElement);
93
116
  const payload = {
94
117
  content,
@@ -107,7 +130,7 @@ function Tooltip$1({ content, children, side = "top", shortcut, disabled = false
107
130
  ...!handle && anchorProps.delay === void 0 && { delay: OPEN_DELAY },
108
131
  handle: handle ?? void 0,
109
132
  payload,
110
- ref: setAnchorElement,
133
+ ref: anchorRef,
111
134
  disabled: disabled || !content || resting,
112
135
  "data-overflow-only": overflowOnly || void 0,
113
136
  render: described ? cloneElement(anchor, { "aria-describedby": describedBy }) : children
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/ui",
3
- "version": "0.83.0",
3
+ "version": "0.83.1",
4
4
  "description": "React UI components: a theme contract, icons, brand logos, primitives, lists, forms, a job graph, a code editor, a log viewer, a file explorer and an AI chat, each on its own subpath",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {