@trackunit/react-components 1.17.37 → 1.17.39
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/index.cjs.js
CHANGED
|
@@ -4488,17 +4488,18 @@ const PopoverContent = function PopoverContent({ className, "data-testid": dataT
|
|
|
4488
4488
|
const PopoverTrigger = function PopoverTrigger({ children, renderButton = false, ref: propRef, ...props }) {
|
|
4489
4489
|
const context = usePopoverContext();
|
|
4490
4490
|
const ref = react$1.useMergeRefs([context.refs.setReference, propRef]);
|
|
4491
|
+
const dataState = context.isOpen === true ? "open" : "closed";
|
|
4491
4492
|
if (!renderButton && react.isValidElement(children)) {
|
|
4492
4493
|
const referenceProps = context.getReferenceProps({
|
|
4493
4494
|
...props,
|
|
4494
4495
|
...children.props,
|
|
4495
|
-
"data-state":
|
|
4496
|
+
"data-state": dataState,
|
|
4496
4497
|
});
|
|
4497
4498
|
const cloneProps = { ...referenceProps };
|
|
4498
4499
|
cloneProps.ref = ref;
|
|
4499
4500
|
return react.cloneElement(children, cloneProps);
|
|
4500
4501
|
}
|
|
4501
|
-
return (jsxRuntime.jsx(Button, { "data-state":
|
|
4502
|
+
return (jsxRuntime.jsx(Button, { "data-state": dataState, ref: ref, type: "button", ...context.getReferenceProps(props), children: children }));
|
|
4502
4503
|
};
|
|
4503
4504
|
|
|
4504
4505
|
const cvaTooltipIcon = cssClassVarianceUtilities.cvaMerge(["text-neutral-300", "transition", "hover:cursor-pointer", "hover:text-neutral-400"], {
|
|
@@ -4601,7 +4602,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
4601
4602
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
4602
4603
|
* @returns {ReactElement} Tooltip component
|
|
4603
4604
|
*/
|
|
4604
|
-
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label, placement = "auto", mode = "dark", iconProps, id, style, delayed = false, interactable = true, }) => {
|
|
4605
|
+
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label, placement = "auto", mode = "dark", iconProps, id, style, delayed = false, interactable = true, ref, ...rest }) => {
|
|
4605
4606
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
4606
4607
|
const arrowRef = react.useRef(null);
|
|
4607
4608
|
const { refs, floatingStyles, context } = react$1.useFloating({
|
|
@@ -4619,12 +4620,13 @@ const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label,
|
|
|
4619
4620
|
whileElementsMounted: react$1.autoUpdate,
|
|
4620
4621
|
});
|
|
4621
4622
|
const { isMounted } = react$1.useTransitionStatus(context);
|
|
4623
|
+
const mergedRef = react$1.useMergeRefs([refs.setReference, ref]);
|
|
4622
4624
|
// Please don't move this into the component body directly without testing it first
|
|
4623
4625
|
// I tried and it caused infinite re-renders some places
|
|
4624
4626
|
const wrappedChildren = react.useMemo(() => {
|
|
4625
4627
|
return jsxRuntime.jsx(reactSlot.Slot, { children: children });
|
|
4626
4628
|
}, [children]);
|
|
4627
|
-
return (jsxRuntime.jsxs(Popover, { activation: { hover: { delayed, interactable } }, className: cvaTooltipPopover(), "data-testid": dataTestId, id: id, onOpenStateChange: setIsOpen, placement: placement === "auto" ? "bottom" : placement, children: [jsxRuntime.jsx(PopoverTrigger, { "data-testid": dataTestId ? `${dataTestId}-trigger` : null, ref:
|
|
4629
|
+
return (jsxRuntime.jsxs(Popover, { activation: { click: false, hover: { delayed, interactable } }, className: cvaTooltipPopover(), "data-testid": dataTestId, id: id, onOpenStateChange: setIsOpen, placement: placement === "auto" ? "bottom" : placement, children: [jsxRuntime.jsx(PopoverTrigger, { ...rest, "data-testid": dataTestId ? `${dataTestId}-trigger` : null, ref: mergedRef, style: style, children: children === undefined ? (jsxRuntime.jsx(Icon, { className: cvaTooltipIcon({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps })) : (wrappedChildren) }), isMounted ? (jsxRuntime.jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-content` : undefined, children: [jsxRuntime.jsx(Text, { "data-testid": dataTestId ? `${dataTestId}-text` : undefined, inverted: mode === "dark", size: "small", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsxRuntime.jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) })) : null] }));
|
|
4628
4630
|
};
|
|
4629
4631
|
|
|
4630
4632
|
const cvaIndicator = cssClassVarianceUtilities.cvaMerge(["inline-flex", "items-center"]);
|
package/index.esm.js
CHANGED
|
@@ -4486,17 +4486,18 @@ const PopoverContent = function PopoverContent({ className, "data-testid": dataT
|
|
|
4486
4486
|
const PopoverTrigger = function PopoverTrigger({ children, renderButton = false, ref: propRef, ...props }) {
|
|
4487
4487
|
const context = usePopoverContext();
|
|
4488
4488
|
const ref = useMergeRefs$1([context.refs.setReference, propRef]);
|
|
4489
|
+
const dataState = context.isOpen === true ? "open" : "closed";
|
|
4489
4490
|
if (!renderButton && isValidElement(children)) {
|
|
4490
4491
|
const referenceProps = context.getReferenceProps({
|
|
4491
4492
|
...props,
|
|
4492
4493
|
...children.props,
|
|
4493
|
-
"data-state":
|
|
4494
|
+
"data-state": dataState,
|
|
4494
4495
|
});
|
|
4495
4496
|
const cloneProps = { ...referenceProps };
|
|
4496
4497
|
cloneProps.ref = ref;
|
|
4497
4498
|
return cloneElement(children, cloneProps);
|
|
4498
4499
|
}
|
|
4499
|
-
return (jsx(Button, { "data-state":
|
|
4500
|
+
return (jsx(Button, { "data-state": dataState, ref: ref, type: "button", ...context.getReferenceProps(props), children: children }));
|
|
4500
4501
|
};
|
|
4501
4502
|
|
|
4502
4503
|
const cvaTooltipIcon = cvaMerge(["text-neutral-300", "transition", "hover:cursor-pointer", "hover:text-neutral-400"], {
|
|
@@ -4599,7 +4600,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
4599
4600
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
4600
4601
|
* @returns {ReactElement} Tooltip component
|
|
4601
4602
|
*/
|
|
4602
|
-
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label, placement = "auto", mode = "dark", iconProps, id, style, delayed = false, interactable = true, }) => {
|
|
4603
|
+
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label, placement = "auto", mode = "dark", iconProps, id, style, delayed = false, interactable = true, ref, ...rest }) => {
|
|
4603
4604
|
const [isOpen, setIsOpen] = useState(false);
|
|
4604
4605
|
const arrowRef = useRef(null);
|
|
4605
4606
|
const { refs, floatingStyles, context } = useFloating({
|
|
@@ -4617,12 +4618,13 @@ const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label,
|
|
|
4617
4618
|
whileElementsMounted: autoUpdate,
|
|
4618
4619
|
});
|
|
4619
4620
|
const { isMounted } = useTransitionStatus(context);
|
|
4621
|
+
const mergedRef = useMergeRefs$1([refs.setReference, ref]);
|
|
4620
4622
|
// Please don't move this into the component body directly without testing it first
|
|
4621
4623
|
// I tried and it caused infinite re-renders some places
|
|
4622
4624
|
const wrappedChildren = useMemo(() => {
|
|
4623
4625
|
return jsx(Slot, { children: children });
|
|
4624
4626
|
}, [children]);
|
|
4625
|
-
return (jsxs(Popover, { activation: { hover: { delayed, interactable } }, className: cvaTooltipPopover(), "data-testid": dataTestId, id: id, onOpenStateChange: setIsOpen, placement: placement === "auto" ? "bottom" : placement, children: [jsx(PopoverTrigger, { "data-testid": dataTestId ? `${dataTestId}-trigger` : null, ref:
|
|
4627
|
+
return (jsxs(Popover, { activation: { click: false, hover: { delayed, interactable } }, className: cvaTooltipPopover(), "data-testid": dataTestId, id: id, onOpenStateChange: setIsOpen, placement: placement === "auto" ? "bottom" : placement, children: [jsx(PopoverTrigger, { ...rest, "data-testid": dataTestId ? `${dataTestId}-trigger` : null, ref: mergedRef, style: style, children: children === undefined ? (jsx(Icon, { className: cvaTooltipIcon({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps })) : (wrappedChildren) }), isMounted ? (jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsx(PopoverContent, { children: jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-content` : undefined, children: [jsx(Text, { "data-testid": dataTestId ? `${dataTestId}-text` : undefined, inverted: mode === "dark", size: "small", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) })) : null] }));
|
|
4626
4628
|
};
|
|
4627
4629
|
|
|
4628
4630
|
const cvaIndicator = cvaMerge(["inline-flex", "items-center"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.39",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.11.
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "1.11.
|
|
19
|
-
"@trackunit/shared-utils": "1.13.
|
|
20
|
-
"@trackunit/ui-icons": "1.11.
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.11.52",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "1.11.53",
|
|
19
|
+
"@trackunit/shared-utils": "1.13.53",
|
|
20
|
+
"@trackunit/ui-icons": "1.11.51",
|
|
21
21
|
"@tanstack/react-router": "1.114.29",
|
|
22
22
|
"es-toolkit": "^1.39.10",
|
|
23
23
|
"@tanstack/react-virtual": "3.13.12",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { HTMLProps, ReactElement, ReactNode
|
|
2
|
-
|
|
1
|
+
import { HTMLProps, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { Refable } from "../../common/Refable";
|
|
3
|
+
interface PopoverTriggerProps extends HTMLProps<HTMLElement>, Refable {
|
|
3
4
|
/**
|
|
4
5
|
* The element that acts as the trigger. Typically a Button or IconButton.
|
|
5
6
|
* When `renderButton` is false (default), the child element is cloned with popover props.
|
|
@@ -11,10 +12,6 @@ interface PopoverTriggerProps extends HTMLProps<HTMLElement> {
|
|
|
11
12
|
* your own Button or interactive element as children.
|
|
12
13
|
*/
|
|
13
14
|
renderButton?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* A ref for the component.
|
|
16
|
-
*/
|
|
17
|
-
ref?: Ref<HTMLElement>;
|
|
18
15
|
}
|
|
19
16
|
/**
|
|
20
17
|
* PopoverTrigger is the clickable element that opens or closes a Popover.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Placement } from "@floating-ui/react";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
3
|
import { CommonProps } from "../../common/CommonProps";
|
|
4
|
+
import { Refable } from "../../common/Refable";
|
|
4
5
|
import { Styleable } from "../../common/Styleable";
|
|
5
6
|
import { IconProps } from "../Icon/Icon";
|
|
6
7
|
import { PopoverHoverOptions } from "../Popover/PopoverTypes";
|
|
7
8
|
export type TooltipPlacement = Placement | "auto";
|
|
8
|
-
export interface TooltipProps extends Omit<CommonProps, "className">, Styleable {
|
|
9
|
+
export interface TooltipProps extends Omit<CommonProps, "className">, Styleable, Refable {
|
|
9
10
|
/**
|
|
10
11
|
* The text to be displayed in the tooltip.
|
|
11
12
|
*/
|
|
@@ -89,4 +90,4 @@ export interface TooltipProps extends Omit<CommonProps, "className">, Styleable
|
|
|
89
90
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
90
91
|
* @returns {ReactElement} Tooltip component
|
|
91
92
|
*/
|
|
92
|
-
export declare const Tooltip: ({ children, "data-testid": dataTestId, disabled, label, placement, mode, iconProps, id, style, delayed, interactable, }: TooltipProps) => ReactElement;
|
|
93
|
+
export declare const Tooltip: ({ children, "data-testid": dataTestId, disabled, label, placement, mode, iconProps, id, style, delayed, interactable, ref, ...rest }: TooltipProps) => ReactElement;
|