@vectara/vectara-ui 13.3.1 → 13.4.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.
|
@@ -21,6 +21,7 @@ type Props = {
|
|
|
21
21
|
tooltip?: {
|
|
22
22
|
darkTheme?: TooltipProps["darkTheme"];
|
|
23
23
|
position?: TooltipProps["position"];
|
|
24
|
+
usePortal?: TooltipProps["usePortal"];
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
export declare const VuiIconButton: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLButtonElement | null>>;
|
|
@@ -4,5 +4,6 @@ export type Props = {
|
|
|
4
4
|
tip: React.ReactNode;
|
|
5
5
|
darkTheme?: boolean;
|
|
6
6
|
position?: TooltipRefProps["place"];
|
|
7
|
+
usePortal?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare const VuiTooltip: ({ children, darkTheme, position, tip }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const VuiTooltip: ({ children, darkTheme, position, tip, usePortal }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,10 +2,11 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useState, cloneElement } from "react";
|
|
3
3
|
import { Tooltip } from "react-tooltip";
|
|
4
4
|
import { useVuiContext } from "../context/Context";
|
|
5
|
+
import { VuiPortal } from "../portal/Portal";
|
|
5
6
|
const generateTooltipId = () => {
|
|
6
7
|
return `tooltip-${Math.random().toString(36).slice(2, 9)}`;
|
|
7
8
|
};
|
|
8
|
-
export const VuiTooltip = ({ children, darkTheme, position, tip }) => {
|
|
9
|
+
export const VuiTooltip = ({ children, darkTheme, position, tip, usePortal }) => {
|
|
9
10
|
const { getThemeStyle } = useVuiContext();
|
|
10
11
|
const [id] = useState(generateTooltipId());
|
|
11
12
|
const target = cloneElement(children, {
|
|
@@ -15,7 +16,8 @@ export const VuiTooltip = ({ children, darkTheme, position, tip }) => {
|
|
|
15
16
|
// the light theme class in order to enable having a different theme than the
|
|
16
17
|
// parent.
|
|
17
18
|
const style = getThemeStyle(darkTheme ? "dark" : "light");
|
|
18
|
-
|
|
19
|
+
const tooltip = (_jsx(Tooltip, Object.assign({ id: id, offset: 10, className: "vuiTooltip", style: style, opacity: 1, place: position }, { children: tip })));
|
|
20
|
+
return (_jsxs(_Fragment, { children: [target, usePortal ? _jsx(VuiPortal, { children: tooltip }) : tooltip] }));
|
|
19
21
|
};
|
|
20
22
|
// This is a workaround for the issue with ResizeObserver in ReactTooltip.
|
|
21
23
|
// Without this, uncaught runtime errors are thrown: "ResizeObserver loop
|