@trackunit/react-components 0.4.29 → 0.4.31
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 +13 -4
- package/index.esm.js +13 -4
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -3862,10 +3862,19 @@ const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label
|
|
|
3862
3862
|
// Please don't try to move this into the component body directly
|
|
3863
3863
|
// I tried and it caused infinite re-renders some places (for whatever reason)
|
|
3864
3864
|
const wrappedChildren = (jsxRuntime.jsx("div", { className: cvaTooltipFlexContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children }));
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3865
|
+
const openTooltip = React__namespace.useCallback(() => {
|
|
3866
|
+
if (disabled) {
|
|
3867
|
+
return;
|
|
3868
|
+
}
|
|
3869
|
+
setIsOpen(true);
|
|
3870
|
+
}, [disabled]);
|
|
3871
|
+
const closeTooltip = React__namespace.useCallback(() => {
|
|
3872
|
+
if (disabled) {
|
|
3873
|
+
return;
|
|
3874
|
+
}
|
|
3875
|
+
setIsOpen(false);
|
|
3876
|
+
}, [disabled]);
|
|
3877
|
+
return (jsxRuntime.jsxs(Popover, { activation: { hover: true }, className: cvaTooltipPopover(), dataTestId: dataTestId, id: id, placement: placement === "auto" ? "bottom" : placement, children: [jsxRuntime.jsx(PopoverTrigger, { className: cvaTooltipIcon({ color: mode, className }), "data-testid": dataTestId ? `${dataTestId}-trigger` : null, onMouseEnter: openTooltip, onMouseLeave: closeTooltip, ref: refs.setReference, children: children === undefined ? (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Icon, { dataTestId: 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}-content`, children: [jsxRuntime.jsx(Text, { inverted: mode === "dark", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsxRuntime.jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) })) : null] }));
|
|
3869
3878
|
};
|
|
3870
3879
|
|
|
3871
3880
|
const cvaIndicator = cssClassVarianceUtilities.cvaMerge(["flex", "items-center"]);
|
package/index.esm.js
CHANGED
|
@@ -3842,10 +3842,19 @@ const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label
|
|
|
3842
3842
|
// Please don't try to move this into the component body directly
|
|
3843
3843
|
// I tried and it caused infinite re-renders some places (for whatever reason)
|
|
3844
3844
|
const wrappedChildren = (jsx("div", { className: cvaTooltipFlexContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children }));
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3845
|
+
const openTooltip = React.useCallback(() => {
|
|
3846
|
+
if (disabled) {
|
|
3847
|
+
return;
|
|
3848
|
+
}
|
|
3849
|
+
setIsOpen(true);
|
|
3850
|
+
}, [disabled]);
|
|
3851
|
+
const closeTooltip = React.useCallback(() => {
|
|
3852
|
+
if (disabled) {
|
|
3853
|
+
return;
|
|
3854
|
+
}
|
|
3855
|
+
setIsOpen(false);
|
|
3856
|
+
}, [disabled]);
|
|
3857
|
+
return (jsxs(Popover, { activation: { hover: true }, className: cvaTooltipPopover(), dataTestId: dataTestId, id: id, placement: placement === "auto" ? "bottom" : placement, children: [jsx(PopoverTrigger, { className: cvaTooltipIcon({ color: mode, className }), "data-testid": dataTestId ? `${dataTestId}-trigger` : null, onMouseEnter: openTooltip, onMouseLeave: closeTooltip, ref: refs.setReference, children: children === undefined ? (jsx("div", { children: jsx(Icon, { dataTestId: 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}-content`, children: [jsx(Text, { inverted: mode === "dark", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) })) : null] }));
|
|
3849
3858
|
};
|
|
3850
3859
|
|
|
3851
3860
|
const cvaIndicator = cvaMerge(["flex", "items-center"]);
|