@yahoo/uds 3.102.0 → 3.103.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/dist/automated-config/dist/generated/autoVariants.cjs +11 -1
- package/dist/automated-config/dist/generated/autoVariants.d.cts +10 -0
- package/dist/automated-config/dist/generated/autoVariants.d.ts +10 -0
- package/dist/automated-config/dist/generated/autoVariants.js +11 -1
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +1695 -1
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +419 -189
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +419 -189
- package/dist/automated-config/dist/generated/generatedConfigs.js +1694 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +99 -0
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +2 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +2 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +99 -0
- package/dist/automated-config/dist/properties.cjs +152 -89
- package/dist/automated-config/dist/properties.d.cts +25 -4
- package/dist/automated-config/dist/properties.d.ts +25 -4
- package/dist/automated-config/dist/properties.js +153 -90
- package/dist/automated-config/dist/utils/buildConfigSchema.cjs +5 -1
- package/dist/automated-config/dist/utils/buildConfigSchema.d.cts +2 -1
- package/dist/automated-config/dist/utils/buildConfigSchema.d.ts +2 -1
- package/dist/automated-config/dist/utils/buildConfigSchema.js +5 -1
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.cts +2 -2
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.ts +2 -2
- package/dist/automated-config/dist/utils/index.cjs +4 -4
- package/dist/automated-config/dist/utils/index.d.cts +6 -1
- package/dist/automated-config/dist/utils/index.d.ts +6 -1
- package/dist/automated-config/dist/utils/index.js +4 -4
- package/dist/cli/commands/sync.cjs +5 -1
- package/dist/cli/commands/sync.js +5 -1
- package/dist/components/client/Button.js +2 -2
- package/dist/components/client/Toast/Toast.cjs +1 -1
- package/dist/components/client/Toast/Toast.d.cts +1 -1
- package/dist/components/client/Toast/Toast.d.ts +1 -1
- package/dist/components/client/Toast/Toast.js +1 -1
- package/dist/components/client/Tooltip/Tooltip.cjs +65 -0
- package/dist/components/client/Tooltip/Tooltip.d.cts +45 -0
- package/dist/components/client/Tooltip/Tooltip.d.ts +45 -0
- package/dist/components/client/Tooltip/Tooltip.js +63 -0
- package/dist/components/client/Tooltip/TooltipContent.cjs +188 -0
- package/dist/components/client/Tooltip/TooltipContent.d.cts +8 -0
- package/dist/components/client/Tooltip/TooltipContent.d.ts +8 -0
- package/dist/components/client/Tooltip/TooltipContent.js +186 -0
- package/dist/components/client/Tooltip/TooltipTrigger.cjs +20 -0
- package/dist/components/client/Tooltip/TooltipTrigger.d.cts +14 -0
- package/dist/components/client/Tooltip/TooltipTrigger.d.ts +14 -0
- package/dist/components/client/Tooltip/TooltipTrigger.js +18 -0
- package/dist/components/client/Tooltip/UDSTooltipConfigProvider.cjs +40 -0
- package/dist/components/client/Tooltip/UDSTooltipConfigProvider.d.cts +28 -0
- package/dist/components/client/Tooltip/UDSTooltipConfigProvider.d.ts +28 -0
- package/dist/components/client/Tooltip/UDSTooltipConfigProvider.js +37 -0
- package/dist/components/client/Tooltip/index.cjs +12 -0
- package/dist/components/client/Tooltip/index.d.cts +7 -0
- package/dist/components/client/Tooltip/index.d.ts +7 -0
- package/dist/components/client/Tooltip/index.js +8 -0
- package/dist/components/client/Tooltip/tooltipContext.cjs +12 -0
- package/dist/components/client/Tooltip/tooltipContext.d.cts +12 -0
- package/dist/components/client/Tooltip/tooltipContext.d.ts +12 -0
- package/dist/components/client/Tooltip/tooltipContext.js +10 -0
- package/dist/components/client/Tooltip/useTooltipContent.cjs +186 -0
- package/dist/components/client/Tooltip/useTooltipContent.d.cts +66 -0
- package/dist/components/client/Tooltip/useTooltipContent.d.ts +66 -0
- package/dist/components/client/Tooltip/useTooltipContent.js +184 -0
- package/dist/components/client/Tooltip/util.cjs +248 -0
- package/dist/components/client/Tooltip/util.d.cts +118 -0
- package/dist/components/client/Tooltip/util.d.ts +118 -0
- package/dist/components/client/Tooltip/util.js +240 -0
- package/dist/components/client/index.cjs +8 -0
- package/dist/components/client/index.d.cts +7 -1
- package/dist/components/client/index.d.ts +7 -1
- package/dist/components/client/index.js +5 -1
- package/dist/components/client/providers/UDSConfigProvider.cjs +6 -2
- package/dist/components/client/providers/UDSConfigProvider.d.cts +2 -1
- package/dist/components/client/providers/UDSConfigProvider.d.ts +2 -1
- package/dist/components/client/providers/UDSConfigProvider.js +6 -2
- package/dist/components/index.cjs +12 -0
- package/dist/components/index.d.cts +6 -1
- package/dist/components/index.d.ts +6 -1
- package/dist/components/index.js +9 -1
- package/dist/config/dist/index.cjs +18797 -18698
- package/dist/config/dist/index.js +18797 -18698
- package/dist/css-tokens/dist/index.cjs +2 -0
- package/dist/css-tokens/dist/index.d.cts +2 -1
- package/dist/css-tokens/dist/index.d.ts +2 -1
- package/dist/css-tokens/dist/index.js +2 -1
- package/dist/fixtures/dist/arbitrary.d.cts +11 -0
- package/dist/fixtures/dist/arbitrary.d.ts +11 -0
- package/dist/fixtures/dist/index.cjs +27 -1
- package/dist/fixtures/dist/index.d.cts +17 -3
- package/dist/fixtures/dist/index.d.ts +17 -3
- package/dist/fixtures/dist/index.js +26 -2
- package/dist/fixtures/index.cjs +6 -1
- package/dist/fixtures/index.d.cts +4 -2
- package/dist/fixtures/index.d.ts +4 -2
- package/dist/fixtures/index.js +3 -2
- package/dist/fixtures/src/arbitrary.cjs +23 -0
- package/dist/fixtures/src/arbitrary.d.cts +15 -0
- package/dist/fixtures/src/arbitrary.d.ts +15 -0
- package/dist/fixtures/src/arbitrary.js +18 -0
- package/dist/fixtures/src/util.cjs +26 -0
- package/dist/fixtures/src/util.d.cts +9 -0
- package/dist/fixtures/src/util.d.ts +9 -0
- package/dist/fixtures/src/util.js +25 -0
- package/dist/index.cjs +15 -3
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +11 -6
- package/dist/runtime/index.cjs +2 -0
- package/dist/runtime/index.d.cts +2 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/tooltipConfig.cjs +33 -0
- package/dist/runtime/tooltipConfig.d.cts +20 -0
- package/dist/runtime/tooltipConfig.d.ts +20 -0
- package/dist/runtime/tooltipConfig.js +32 -0
- package/dist/runtime/udsConfig.cjs +3 -1
- package/dist/runtime/udsConfig.d.cts +2 -0
- package/dist/runtime/udsConfig.d.ts +2 -0
- package/dist/runtime/udsConfig.js +3 -1
- package/dist/styles/styler.d.cts +53 -43
- package/dist/styles/styler.d.ts +53 -43
- package/dist/styles/variants.d.cts +30 -0
- package/dist/styles/variants.d.ts +30 -0
- package/dist/tailwind/dist/plugin.cjs +2 -1
- package/dist/tailwind/dist/plugin.js +2 -1
- package/dist/tailwind/dist/tailwind/plugins/blurBgFallback.cjs +30 -0
- package/dist/tailwind/dist/tailwind/plugins/blurBgFallback.js +28 -0
- package/dist/tailwind/dist/tailwind/plugins/components.cjs +1 -0
- package/dist/tailwind/dist/tailwind/plugins/components.js +2 -1
- package/dist/tailwind/dist/tailwind/utils/getShadowStyles.d.cts +4 -4
- package/dist/tailwind/dist/tailwind/utils/getShadowStyles.d.ts +4 -4
- package/dist/tokens/automation/configs/index.cjs +2 -1
- package/dist/tokens/automation/configs/index.d.cts +2 -2
- package/dist/tokens/automation/configs/index.d.ts +2 -2
- package/dist/tokens/automation/configs/index.js +2 -2
- package/dist/tokens/automation/index.cjs +1 -0
- package/dist/tokens/automation/index.d.cts +2 -2
- package/dist/tokens/automation/index.d.ts +2 -2
- package/dist/tokens/automation/index.js +2 -2
- package/dist/tokens/automation/properties.d.cts +2 -2
- package/dist/tokens/automation/properties.d.ts +2 -2
- package/dist/tokens/consts/cssTokens.cjs +1 -0
- package/dist/tokens/consts/cssTokens.d.cts +2 -2
- package/dist/tokens/consts/cssTokens.d.ts +2 -2
- package/dist/tokens/consts/cssTokens.js +2 -2
- package/dist/tokens/index.cjs +2 -0
- package/dist/tokens/index.d.cts +4 -4
- package/dist/tokens/index.d.ts +4 -4
- package/dist/tokens/index.js +3 -3
- package/dist/tokens/types.d.cts +2 -2
- package/dist/tokens/types.d.ts +2 -2
- package/dist/types/dist/index.d.cts +37 -2
- package/dist/types/dist/index.d.ts +37 -2
- package/dist/uds/generated/tailwindPurge.cjs +90 -60
- package/dist/uds/generated/tailwindPurge.js +90 -60
- package/dist/uds/package.cjs +1 -0
- package/dist/uds/package.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
import { ParsedShadow } from "./util.cjs";
|
|
3
|
+
import { CSSProperties, RefObject } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/Tooltip/useTooltipContent.d.ts
|
|
6
|
+
interface UseTooltipContentOptions {
|
|
7
|
+
/** Whether the tooltip is currently open. */
|
|
8
|
+
open: boolean;
|
|
9
|
+
/** Resolved placement after Ariakit positioning (e.g. `'top'`, `'bottom-start'`). */
|
|
10
|
+
effectivePlacement: string;
|
|
11
|
+
/** Optional max-width override (number = px, string = CSS value). */
|
|
12
|
+
maxWidth?: number | string;
|
|
13
|
+
/** Border-radius from the tooltip config (px). */
|
|
14
|
+
borderRadius: number;
|
|
15
|
+
/**
|
|
16
|
+
* Ref to the Ariakit `TooltipArrow` element. Its position (set by
|
|
17
|
+
* floating-ui) is read inside the `updatePosition` callback so the
|
|
18
|
+
* SVG arrow always mirrors where floating-ui places the native arrow.
|
|
19
|
+
*/
|
|
20
|
+
arrowRef: RefObject<HTMLDivElement | null>;
|
|
21
|
+
/** Animation duration from the tooltip config (ms). */
|
|
22
|
+
animationDuration: number;
|
|
23
|
+
}
|
|
24
|
+
interface UseTooltipContentReturn {
|
|
25
|
+
internalRef: RefObject<HTMLElement | null>;
|
|
26
|
+
shadowFilterId: string;
|
|
27
|
+
maxWidthClass: string;
|
|
28
|
+
dimensions: {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
shadows: ParsedShadow[];
|
|
33
|
+
shadowPadding: number;
|
|
34
|
+
svgPath: string | null;
|
|
35
|
+
blurClipPath: string | null;
|
|
36
|
+
blurStyle: CSSProperties;
|
|
37
|
+
visible: boolean;
|
|
38
|
+
childTransitionStyle: CSSProperties;
|
|
39
|
+
/**
|
|
40
|
+
* Pixel offset to apply as a CSS transform on the tooltip element so that
|
|
41
|
+
* the (clamped) SVG arrow aligns with the trigger center even when the
|
|
42
|
+
* trigger is too small / close to a rounded corner for the arrow to reach.
|
|
43
|
+
*/
|
|
44
|
+
tooltipShift: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Pass as the `updatePosition` prop to the Ariakit `<Tooltip>` component.
|
|
50
|
+
* This hooks into floating-ui's positioning lifecycle so the SVG arrow
|
|
51
|
+
* center is read after every `computePosition`
|
|
52
|
+
*/
|
|
53
|
+
onPositionUpdate: (props: {
|
|
54
|
+
updatePosition: () => Promise<void>;
|
|
55
|
+
}) => Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
declare function useTooltipContent({
|
|
58
|
+
open,
|
|
59
|
+
effectivePlacement,
|
|
60
|
+
maxWidth,
|
|
61
|
+
borderRadius,
|
|
62
|
+
arrowRef,
|
|
63
|
+
animationDuration
|
|
64
|
+
}: UseTooltipContentOptions): UseTooltipContentReturn;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { type UseTooltipContentOptions, type UseTooltipContentReturn, useTooltipContent };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
import { ParsedShadow } from "./util.js";
|
|
3
|
+
import { CSSProperties, RefObject } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/Tooltip/useTooltipContent.d.ts
|
|
6
|
+
interface UseTooltipContentOptions {
|
|
7
|
+
/** Whether the tooltip is currently open. */
|
|
8
|
+
open: boolean;
|
|
9
|
+
/** Resolved placement after Ariakit positioning (e.g. `'top'`, `'bottom-start'`). */
|
|
10
|
+
effectivePlacement: string;
|
|
11
|
+
/** Optional max-width override (number = px, string = CSS value). */
|
|
12
|
+
maxWidth?: number | string;
|
|
13
|
+
/** Border-radius from the tooltip config (px). */
|
|
14
|
+
borderRadius: number;
|
|
15
|
+
/**
|
|
16
|
+
* Ref to the Ariakit `TooltipArrow` element. Its position (set by
|
|
17
|
+
* floating-ui) is read inside the `updatePosition` callback so the
|
|
18
|
+
* SVG arrow always mirrors where floating-ui places the native arrow.
|
|
19
|
+
*/
|
|
20
|
+
arrowRef: RefObject<HTMLDivElement | null>;
|
|
21
|
+
/** Animation duration from the tooltip config (ms). */
|
|
22
|
+
animationDuration: number;
|
|
23
|
+
}
|
|
24
|
+
interface UseTooltipContentReturn {
|
|
25
|
+
internalRef: RefObject<HTMLElement | null>;
|
|
26
|
+
shadowFilterId: string;
|
|
27
|
+
maxWidthClass: string;
|
|
28
|
+
dimensions: {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
shadows: ParsedShadow[];
|
|
33
|
+
shadowPadding: number;
|
|
34
|
+
svgPath: string | null;
|
|
35
|
+
blurClipPath: string | null;
|
|
36
|
+
blurStyle: CSSProperties;
|
|
37
|
+
visible: boolean;
|
|
38
|
+
childTransitionStyle: CSSProperties;
|
|
39
|
+
/**
|
|
40
|
+
* Pixel offset to apply as a CSS transform on the tooltip element so that
|
|
41
|
+
* the (clamped) SVG arrow aligns with the trigger center even when the
|
|
42
|
+
* trigger is too small / close to a rounded corner for the arrow to reach.
|
|
43
|
+
*/
|
|
44
|
+
tooltipShift: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Pass as the `updatePosition` prop to the Ariakit `<Tooltip>` component.
|
|
50
|
+
* This hooks into floating-ui's positioning lifecycle so the SVG arrow
|
|
51
|
+
* center is read after every `computePosition`
|
|
52
|
+
*/
|
|
53
|
+
onPositionUpdate: (props: {
|
|
54
|
+
updatePosition: () => Promise<void>;
|
|
55
|
+
}) => Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
declare function useTooltipContent({
|
|
58
|
+
open,
|
|
59
|
+
effectivePlacement,
|
|
60
|
+
maxWidth,
|
|
61
|
+
borderRadius,
|
|
62
|
+
arrowRef,
|
|
63
|
+
animationDuration
|
|
64
|
+
}: UseTooltipContentOptions): UseTooltipContentReturn;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { type UseTooltipContentOptions, type UseTooltipContentReturn, useTooltipContent };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
import { DROP_SHADOW_PREFIX } from "../../../css-tokens/dist/index.js";
|
|
4
|
+
import { ARROW_HEIGHT, generateTooltipPath, getArrowClampDelta, getArrowSide, parseShadow } from "./util.js";
|
|
5
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
6
|
+
|
|
7
|
+
//#region src/components/client/Tooltip/useTooltipContent.ts
|
|
8
|
+
function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, arrowRef, animationDuration }) {
|
|
9
|
+
const internalRef = useRef(null);
|
|
10
|
+
const shadowFilterId = useId();
|
|
11
|
+
const [dimensions, setDimensions] = useState({
|
|
12
|
+
width: 0,
|
|
13
|
+
height: 0
|
|
14
|
+
});
|
|
15
|
+
const maxWidthClass = useMemo(() => {
|
|
16
|
+
if (maxWidth !== void 0) return typeof maxWidth === "number" ? `max-w-[${maxWidth}px]` : `max-w-[${maxWidth}]`;
|
|
17
|
+
return "max-w-lg";
|
|
18
|
+
}, [maxWidth]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const el = internalRef.current;
|
|
21
|
+
if (!el) return;
|
|
22
|
+
const observer = new ResizeObserver(() => {
|
|
23
|
+
setDimensions({
|
|
24
|
+
width: el.offsetWidth,
|
|
25
|
+
height: el.offsetHeight
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
observer.observe(el);
|
|
29
|
+
return () => observer.disconnect();
|
|
30
|
+
}, [open]);
|
|
31
|
+
const [shadows, setShadows] = useState([]);
|
|
32
|
+
const shadowValueRef = useRef("");
|
|
33
|
+
const readShadows = useCallback(() => {
|
|
34
|
+
if (!internalRef.current) return;
|
|
35
|
+
const shadowValue = getComputedStyle(internalRef.current).getPropertyValue(`--${DROP_SHADOW_PREFIX}`);
|
|
36
|
+
if (shadowValue !== shadowValueRef.current) {
|
|
37
|
+
shadowValueRef.current = shadowValue;
|
|
38
|
+
setShadows(parseShadow(shadowValue));
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
41
|
+
const shadowPadding = useMemo(() => {
|
|
42
|
+
if (shadows.length === 0) return 0;
|
|
43
|
+
return shadows.reduce((max, s) => {
|
|
44
|
+
const extentX = Math.abs(s.x) + s.blur + Math.abs(s.spread);
|
|
45
|
+
const extentY = Math.abs(s.y) + s.blur + Math.abs(s.spread);
|
|
46
|
+
return Math.max(max, extentX, extentY);
|
|
47
|
+
}, 0);
|
|
48
|
+
}, [shadows]);
|
|
49
|
+
const [arrowCenter, setArrowCenter] = useState(void 0);
|
|
50
|
+
const computeArrowCenter = useCallback(() => {
|
|
51
|
+
const arrowEl = arrowRef.current;
|
|
52
|
+
const tooltipEl = internalRef.current;
|
|
53
|
+
if (!arrowEl || !tooltipEl) return;
|
|
54
|
+
const arrowRect = arrowEl.getBoundingClientRect();
|
|
55
|
+
const tooltipRect = tooltipEl.getBoundingClientRect();
|
|
56
|
+
const side = getArrowSide(effectivePlacement);
|
|
57
|
+
const raw = side === "top" || side === "bottom" ? arrowRect.left + arrowRect.width / 2 - tooltipRect.left : arrowRect.top + arrowRect.height / 2 - tooltipRect.top;
|
|
58
|
+
return Math.round(raw);
|
|
59
|
+
}, [arrowRef, effectivePlacement]);
|
|
60
|
+
const onPositionUpdate = useCallback(async ({ updatePosition }) => {
|
|
61
|
+
await updatePosition();
|
|
62
|
+
const el = internalRef.current;
|
|
63
|
+
if (el) {
|
|
64
|
+
const { offsetWidth, offsetHeight } = el;
|
|
65
|
+
if (offsetWidth > 0 && offsetHeight > 0) setDimensions((prev) => {
|
|
66
|
+
if (prev.width === offsetWidth && prev.height === offsetHeight) return prev;
|
|
67
|
+
return {
|
|
68
|
+
width: offsetWidth,
|
|
69
|
+
height: offsetHeight
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
readShadows();
|
|
73
|
+
}
|
|
74
|
+
const next = computeArrowCenter();
|
|
75
|
+
if (next !== void 0) setArrowCenter((prev) => prev === next ? prev : next);
|
|
76
|
+
}, [computeArrowCenter, readShadows]);
|
|
77
|
+
const svgPath = useMemo(() => {
|
|
78
|
+
return dimensions.width > 0 && dimensions.height > 0 ? generateTooltipPath({
|
|
79
|
+
width: dimensions.width,
|
|
80
|
+
height: dimensions.height,
|
|
81
|
+
placement: effectivePlacement,
|
|
82
|
+
borderRadius,
|
|
83
|
+
arrowCenter
|
|
84
|
+
}) : null;
|
|
85
|
+
}, [
|
|
86
|
+
effectivePlacement,
|
|
87
|
+
dimensions.width,
|
|
88
|
+
dimensions.height,
|
|
89
|
+
borderRadius,
|
|
90
|
+
arrowCenter
|
|
91
|
+
]);
|
|
92
|
+
const blurClipPath = useMemo(() => {
|
|
93
|
+
if (dimensions.width <= 0 || dimensions.height <= 0) return null;
|
|
94
|
+
const arrowSide = getArrowSide(effectivePlacement);
|
|
95
|
+
const offsetX = arrowSide === "left" ? ARROW_HEIGHT : 0;
|
|
96
|
+
const offsetY = arrowSide === "top" ? ARROW_HEIGHT : 0;
|
|
97
|
+
return generateTooltipPath({
|
|
98
|
+
width: dimensions.width,
|
|
99
|
+
height: dimensions.height,
|
|
100
|
+
placement: effectivePlacement,
|
|
101
|
+
borderRadius,
|
|
102
|
+
arrowCenter,
|
|
103
|
+
offsetX,
|
|
104
|
+
offsetY
|
|
105
|
+
});
|
|
106
|
+
}, [
|
|
107
|
+
effectivePlacement,
|
|
108
|
+
dimensions.width,
|
|
109
|
+
dimensions.height,
|
|
110
|
+
borderRadius,
|
|
111
|
+
arrowCenter
|
|
112
|
+
]);
|
|
113
|
+
const blurStyle = useMemo(() => {
|
|
114
|
+
const style = { clipPath: blurClipPath ? `path('${blurClipPath}')` : void 0 };
|
|
115
|
+
switch (getArrowSide(effectivePlacement)) {
|
|
116
|
+
case "top":
|
|
117
|
+
style.height = `calc(100% + ${ARROW_HEIGHT}px)`;
|
|
118
|
+
style.top = "auto";
|
|
119
|
+
style.bottom = "0";
|
|
120
|
+
break;
|
|
121
|
+
case "bottom":
|
|
122
|
+
style.height = `calc(100% + ${ARROW_HEIGHT}px)`;
|
|
123
|
+
break;
|
|
124
|
+
case "left":
|
|
125
|
+
style.width = `calc(100% + ${ARROW_HEIGHT}px)`;
|
|
126
|
+
style.left = "auto";
|
|
127
|
+
style.right = "0";
|
|
128
|
+
break;
|
|
129
|
+
case "right":
|
|
130
|
+
style.width = `calc(100% + ${ARROW_HEIGHT}px)`;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
return style;
|
|
134
|
+
}, [blurClipPath, effectivePlacement]);
|
|
135
|
+
const [visible, setVisible] = useState(false);
|
|
136
|
+
if ((!open || !svgPath) && visible) setVisible(false);
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (open && svgPath) {
|
|
139
|
+
const raf = requestAnimationFrame(() => {
|
|
140
|
+
setVisible(true);
|
|
141
|
+
});
|
|
142
|
+
return () => cancelAnimationFrame(raf);
|
|
143
|
+
}
|
|
144
|
+
}, [open, svgPath]);
|
|
145
|
+
return {
|
|
146
|
+
internalRef,
|
|
147
|
+
shadowFilterId,
|
|
148
|
+
maxWidthClass,
|
|
149
|
+
dimensions,
|
|
150
|
+
shadows,
|
|
151
|
+
shadowPadding,
|
|
152
|
+
svgPath,
|
|
153
|
+
blurClipPath,
|
|
154
|
+
blurStyle,
|
|
155
|
+
visible,
|
|
156
|
+
childTransitionStyle: {
|
|
157
|
+
opacity: visible ? 1 : 0,
|
|
158
|
+
transition: `opacity ${animationDuration}ms ease-in-out`
|
|
159
|
+
},
|
|
160
|
+
tooltipShift: useMemo(() => {
|
|
161
|
+
if (arrowCenter === void 0 || dimensions.width <= 0 || dimensions.height <= 0) return {
|
|
162
|
+
x: 0,
|
|
163
|
+
y: 0
|
|
164
|
+
};
|
|
165
|
+
return getArrowClampDelta({
|
|
166
|
+
width: dimensions.width,
|
|
167
|
+
height: dimensions.height,
|
|
168
|
+
placement: effectivePlacement,
|
|
169
|
+
borderRadius,
|
|
170
|
+
arrowCenter
|
|
171
|
+
});
|
|
172
|
+
}, [
|
|
173
|
+
arrowCenter,
|
|
174
|
+
dimensions.width,
|
|
175
|
+
dimensions.height,
|
|
176
|
+
effectivePlacement,
|
|
177
|
+
borderRadius
|
|
178
|
+
]),
|
|
179
|
+
onPositionUpdate
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
export { useTooltipContent };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/Tooltip/util.ts
|
|
6
|
+
/**
|
|
7
|
+
* Splits a CSS value on whitespace, but keeps parenthesized groups
|
|
8
|
+
* (e.g. `rgb(0, 0, 0)`) together as single tokens.
|
|
9
|
+
*/
|
|
10
|
+
function tokenizeCSSValue(value) {
|
|
11
|
+
const tokens = [];
|
|
12
|
+
let current = "";
|
|
13
|
+
let depth = 0;
|
|
14
|
+
for (const char of value) {
|
|
15
|
+
if (char === "(") depth++;
|
|
16
|
+
if (char === ")") depth--;
|
|
17
|
+
if (char === " " && depth === 0) {
|
|
18
|
+
if (current) tokens.push(current);
|
|
19
|
+
current = "";
|
|
20
|
+
} else current += char;
|
|
21
|
+
}
|
|
22
|
+
if (current) tokens.push(current);
|
|
23
|
+
return tokens;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns `true` if the token is a CSS color value.
|
|
27
|
+
*
|
|
28
|
+
* In a box-shadow context (after filtering `inset`), every token is either a
|
|
29
|
+
* length or a color. Colors always start with `#` (hex), a letter (named
|
|
30
|
+
* colors like `red`, `transparent`, `currentcolor`), or are a CSS function
|
|
31
|
+
* containing `(` (e.g. `rgb(…)`, `hsl(…)`, `oklch(…)`).
|
|
32
|
+
*/
|
|
33
|
+
function isColorToken(token) {
|
|
34
|
+
const ch = token[0];
|
|
35
|
+
return ch !== "-" && ch !== "." && (ch < "0" || ch > "9");
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Splits a CSS multi-shadow value (comma-separated) into individual
|
|
39
|
+
* shadow strings, correctly handling commas nested inside color functions
|
|
40
|
+
* like `rgb()`, `rgba()`, `hsl()`, etc.
|
|
41
|
+
*/
|
|
42
|
+
function splitShadows(value) {
|
|
43
|
+
const shadows = [];
|
|
44
|
+
let current = "";
|
|
45
|
+
let depth = 0;
|
|
46
|
+
for (let i = 0; i < value.length; i++) {
|
|
47
|
+
const char = value[i];
|
|
48
|
+
if (char === "(") {
|
|
49
|
+
depth++;
|
|
50
|
+
current += char;
|
|
51
|
+
} else if (char === ")") {
|
|
52
|
+
depth--;
|
|
53
|
+
current += char;
|
|
54
|
+
} else if (char === "," && depth === 0) {
|
|
55
|
+
if (current.trim()) shadows.push(current.trim());
|
|
56
|
+
current = "";
|
|
57
|
+
} else current += char;
|
|
58
|
+
}
|
|
59
|
+
if (current.trim()) shadows.push(current.trim());
|
|
60
|
+
return shadows;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parses a single CSS shadow value string into its constituent parts.
|
|
64
|
+
*
|
|
65
|
+
* Handles all standard CSS box-shadow / drop-shadow permutations:
|
|
66
|
+
* - Color before or after length values (`red 0 4px 8px` or `0 4px 8px red`)
|
|
67
|
+
* - Optional blur and spread radii (defaults to 0)
|
|
68
|
+
* - `inset` keyword at any position (silently ignored)
|
|
69
|
+
* - All color formats: named, hex (3/4/6/8-digit), rgb/rgba, hsl/hsla, oklch,
|
|
70
|
+
* oklab, lab, lch, color(), color-mix(), light-dark(), etc.
|
|
71
|
+
* - `none` / empty values → zeroed-out result with `transparent` color
|
|
72
|
+
*/
|
|
73
|
+
function parseSingleShadow(shadow) {
|
|
74
|
+
const value = shadow.trim();
|
|
75
|
+
if (!value || value.toLowerCase() === "none") return {
|
|
76
|
+
x: 0,
|
|
77
|
+
y: 0,
|
|
78
|
+
blur: 0,
|
|
79
|
+
spread: 0,
|
|
80
|
+
color: "transparent"
|
|
81
|
+
};
|
|
82
|
+
const tokens = tokenizeCSSValue(value);
|
|
83
|
+
const lengths = [];
|
|
84
|
+
const colorParts = [];
|
|
85
|
+
for (const token of tokens) {
|
|
86
|
+
if (token.toLowerCase() === "inset") continue;
|
|
87
|
+
if (isColorToken(token)) colorParts.push(token);
|
|
88
|
+
else lengths.push(token);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
x: lengths.length > 0 ? parseFloat(lengths[0]) : 0,
|
|
92
|
+
y: lengths.length > 1 ? parseFloat(lengths[1]) : 0,
|
|
93
|
+
blur: lengths.length > 2 ? parseFloat(lengths[2]) : 0,
|
|
94
|
+
spread: lengths.length > 3 ? parseFloat(lengths[3]) : 0,
|
|
95
|
+
color: colorParts.length > 0 ? colorParts.join(" ") : "rgb(0 0 0 / 1)"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parses a CSS shadow value — which may contain multiple comma-separated
|
|
100
|
+
* layers — into an array of {@link ParsedShadow} objects.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* parseShadow('0px 4px 8px 0px rgb(0 0 0 / 0.12)')
|
|
105
|
+
* // → [{ x: 0, y: 4, blur: 8, spread: 0, color: 'rgb(0 0 0 / 0.12)' }]
|
|
106
|
+
*
|
|
107
|
+
* parseShadow('0px 4px 8px rgb(0 0 0 / 0.12), 0px 1px 2px rgba(0, 0, 0, 0.08)')
|
|
108
|
+
* // → [
|
|
109
|
+
* // { x: 0, y: 4, blur: 8, spread: 0, color: 'rgb(0 0 0 / 0.12)' },
|
|
110
|
+
* // { x: 0, y: 1, blur: 2, spread: 0, color: 'rgba(0, 0, 0, 0.08)' },
|
|
111
|
+
* // ]
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
function parseShadow(shadowValue) {
|
|
115
|
+
const trimmed = shadowValue.trim();
|
|
116
|
+
if (!trimmed || trimmed.toLowerCase() === "none") return [];
|
|
117
|
+
return splitShadows(trimmed).map(parseSingleShadow);
|
|
118
|
+
}
|
|
119
|
+
/** Base width of the arrow triangle (px). */
|
|
120
|
+
const ARROW_WIDTH = 12;
|
|
121
|
+
/** Height (protrusion) of the arrow triangle from the edge (px). */
|
|
122
|
+
const ARROW_HEIGHT = 8;
|
|
123
|
+
/**
|
|
124
|
+
* Fraction of the container border-radius applied to round the arrow tip
|
|
125
|
+
* (0 = sharp point, 1 = same radius as the container corners).
|
|
126
|
+
*/
|
|
127
|
+
const ARROW_TIP_RADIUS_FRACTION = .5;
|
|
128
|
+
/**
|
|
129
|
+
* Returns the side of the tooltip where the arrow should appear.
|
|
130
|
+
* The arrow points *toward* the trigger, so it lives on the opposite
|
|
131
|
+
* side of the placement direction.
|
|
132
|
+
*/
|
|
133
|
+
function getArrowSide(placement) {
|
|
134
|
+
switch (placement.split("-")[0]) {
|
|
135
|
+
case "bottom": return "top";
|
|
136
|
+
case "top": return "bottom";
|
|
137
|
+
case "left": return "right";
|
|
138
|
+
case "right": return "left";
|
|
139
|
+
default: return "top";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Generates an SVG `<path>` string for a rounded rectangle with an arrow
|
|
144
|
+
* pointing toward the trigger element.
|
|
145
|
+
*
|
|
146
|
+
* The path is traced clockwise, inserting the arrow triangle on the
|
|
147
|
+
* appropriate edge. The arrow extends *outside* the 0,0 → width,height
|
|
148
|
+
* rectangle so the host `<svg>` must use `overflow: visible`.
|
|
149
|
+
*/
|
|
150
|
+
function generateTooltipPath({ width, height, placement, borderRadius, arrowWidth = ARROW_WIDTH, arrowHeight = ARROW_HEIGHT, arrowCenter, offsetX: ox = 0, offsetY: oy = 0 }) {
|
|
151
|
+
const aw = arrowWidth / 2;
|
|
152
|
+
const ah = arrowHeight;
|
|
153
|
+
const arrowSide = getArrowSide(placement);
|
|
154
|
+
const arrowEdge = arrowSide === "top" || arrowSide === "bottom" ? width : height;
|
|
155
|
+
const otherEdge = arrowSide === "top" || arrowSide === "bottom" ? height : width;
|
|
156
|
+
const maxRadius = Math.min(otherEdge / 2, (arrowEdge - arrowWidth) / 2);
|
|
157
|
+
const r = Math.max(0, Math.min(borderRadius, maxRadius));
|
|
158
|
+
const minAc = r + aw;
|
|
159
|
+
const edgeLength = arrowSide === "top" || arrowSide === "bottom" ? width : height;
|
|
160
|
+
let ac = arrowCenter ?? edgeLength / 2;
|
|
161
|
+
ac = Math.max(minAc, Math.min(edgeLength - minAc, ac));
|
|
162
|
+
const edgeLen = Math.sqrt(aw * aw + ah * ah);
|
|
163
|
+
const tipR = r > 0 && edgeLen > 0 ? Math.min(r * ARROW_TIP_RADIUS_FRACTION, edgeLen / 2) : 0;
|
|
164
|
+
const daw = edgeLen > 0 ? aw / edgeLen : 0;
|
|
165
|
+
const dah = edgeLen > 0 ? ah / edgeLen : 0;
|
|
166
|
+
const d = [];
|
|
167
|
+
d.push(`M ${r + ox} ${oy}`);
|
|
168
|
+
if (arrowSide === "top") {
|
|
169
|
+
d.push(`L ${ac - aw + ox} ${oy}`);
|
|
170
|
+
if (tipR > 0) {
|
|
171
|
+
d.push(`L ${ac - tipR * daw + ox} ${-ah + tipR * dah + oy}`);
|
|
172
|
+
d.push(`Q ${ac + ox} ${-ah + oy} ${ac + tipR * daw + ox} ${-ah + tipR * dah + oy}`);
|
|
173
|
+
} else d.push(`L ${ac + ox} ${-ah + oy}`);
|
|
174
|
+
d.push(`L ${ac + aw + ox} ${oy}`);
|
|
175
|
+
}
|
|
176
|
+
d.push(`L ${width - r + ox} ${oy}`);
|
|
177
|
+
d.push(`A ${r} ${r} 0 0 1 ${width + ox} ${r + oy}`);
|
|
178
|
+
if (arrowSide === "right") {
|
|
179
|
+
d.push(`L ${width + ox} ${ac - aw + oy}`);
|
|
180
|
+
if (tipR > 0) {
|
|
181
|
+
d.push(`L ${width + ah - tipR * dah + ox} ${ac - tipR * daw + oy}`);
|
|
182
|
+
d.push(`Q ${width + ah + ox} ${ac + oy} ${width + ah - tipR * dah + ox} ${ac + tipR * daw + oy}`);
|
|
183
|
+
} else d.push(`L ${width + ah + ox} ${ac + oy}`);
|
|
184
|
+
d.push(`L ${width + ox} ${ac + aw + oy}`);
|
|
185
|
+
}
|
|
186
|
+
d.push(`L ${width + ox} ${height - r + oy}`);
|
|
187
|
+
d.push(`A ${r} ${r} 0 0 1 ${width - r + ox} ${height + oy}`);
|
|
188
|
+
if (arrowSide === "bottom") {
|
|
189
|
+
d.push(`L ${ac + aw + ox} ${height + oy}`);
|
|
190
|
+
if (tipR > 0) {
|
|
191
|
+
d.push(`L ${ac + tipR * daw + ox} ${height + ah - tipR * dah + oy}`);
|
|
192
|
+
d.push(`Q ${ac + ox} ${height + ah + oy} ${ac - tipR * daw + ox} ${height + ah - tipR * dah + oy}`);
|
|
193
|
+
} else d.push(`L ${ac + ox} ${height + ah + oy}`);
|
|
194
|
+
d.push(`L ${ac - aw + ox} ${height + oy}`);
|
|
195
|
+
}
|
|
196
|
+
d.push(`L ${r + ox} ${height + oy}`);
|
|
197
|
+
d.push(`A ${r} ${r} 0 0 1 ${ox} ${height - r + oy}`);
|
|
198
|
+
if (arrowSide === "left") {
|
|
199
|
+
d.push(`L ${ox} ${ac + aw + oy}`);
|
|
200
|
+
if (tipR > 0) {
|
|
201
|
+
d.push(`L ${-ah + tipR * dah + ox} ${ac + tipR * daw + oy}`);
|
|
202
|
+
d.push(`Q ${-ah + ox} ${ac + oy} ${-ah + tipR * dah + ox} ${ac - tipR * daw + oy}`);
|
|
203
|
+
} else d.push(`L ${-ah + ox} ${ac + oy}`);
|
|
204
|
+
d.push(`L ${ox} ${ac - aw + oy}`);
|
|
205
|
+
}
|
|
206
|
+
d.push(`L ${ox} ${r + oy}`);
|
|
207
|
+
d.push(`A ${r} ${r} 0 0 1 ${r + ox} ${oy}`);
|
|
208
|
+
d.push("Z");
|
|
209
|
+
return d.join(" ");
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Computes the pixel offset the tooltip must shift so that the SVG arrow
|
|
213
|
+
* (after clamping) visually aligns with the Ariakit arrow's actual position.
|
|
214
|
+
*
|
|
215
|
+
* When the desired `arrowCenter` falls inside the safe zone the delta is 0.
|
|
216
|
+
* When it falls outside (e.g. a tiny trigger near a rounded corner), the
|
|
217
|
+
* returned delta tells the caller how far to translate the tooltip element
|
|
218
|
+
* so the clamped arrow ends up over the trigger center.
|
|
219
|
+
*/
|
|
220
|
+
function getArrowClampDelta({ width, height, placement, borderRadius, arrowCenter, arrowWidth = ARROW_WIDTH }) {
|
|
221
|
+
const aw = arrowWidth / 2;
|
|
222
|
+
const side = getArrowSide(placement);
|
|
223
|
+
const arrowEdge = side === "top" || side === "bottom" ? width : height;
|
|
224
|
+
const otherEdge = side === "top" || side === "bottom" ? height : width;
|
|
225
|
+
const maxRadius = Math.min(otherEdge / 2, (arrowEdge - arrowWidth) / 2);
|
|
226
|
+
const minAc = Math.max(0, Math.min(borderRadius, maxRadius)) + aw;
|
|
227
|
+
const maxAc = arrowEdge - minAc;
|
|
228
|
+
let delta = 0;
|
|
229
|
+
if (arrowCenter < minAc) delta = arrowCenter - minAc;
|
|
230
|
+
else if (arrowCenter > maxAc) delta = arrowCenter - maxAc;
|
|
231
|
+
if (side === "top" || side === "bottom") return {
|
|
232
|
+
x: delta,
|
|
233
|
+
y: 0
|
|
234
|
+
};
|
|
235
|
+
return {
|
|
236
|
+
x: 0,
|
|
237
|
+
y: delta
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
//#endregion
|
|
242
|
+
exports.ARROW_HEIGHT = ARROW_HEIGHT;
|
|
243
|
+
exports.ARROW_TIP_RADIUS_FRACTION = ARROW_TIP_RADIUS_FRACTION;
|
|
244
|
+
exports.ARROW_WIDTH = ARROW_WIDTH;
|
|
245
|
+
exports.generateTooltipPath = generateTooltipPath;
|
|
246
|
+
exports.getArrowClampDelta = getArrowClampDelta;
|
|
247
|
+
exports.getArrowSide = getArrowSide;
|
|
248
|
+
exports.parseShadow = parseShadow;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/client/Tooltip/util.d.ts
|
|
3
|
+
interface ParsedShadow {
|
|
4
|
+
/** Horizontal offset in px. */
|
|
5
|
+
x: number;
|
|
6
|
+
/** Vertical offset in px. */
|
|
7
|
+
y: number;
|
|
8
|
+
/** Blur radius in px. */
|
|
9
|
+
blur: number;
|
|
10
|
+
/** Spread radius in px (always 0 for drop-shadow filter functions). */
|
|
11
|
+
spread: number;
|
|
12
|
+
/** The raw CSS color string (e.g. `rgb(0 0 0 / 0.12)`, `#ff0000`, `red`). */
|
|
13
|
+
color: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parses a CSS shadow value — which may contain multiple comma-separated
|
|
17
|
+
* layers — into an array of {@link ParsedShadow} objects.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* parseShadow('0px 4px 8px 0px rgb(0 0 0 / 0.12)')
|
|
22
|
+
* // → [{ x: 0, y: 4, blur: 8, spread: 0, color: 'rgb(0 0 0 / 0.12)' }]
|
|
23
|
+
*
|
|
24
|
+
* parseShadow('0px 4px 8px rgb(0 0 0 / 0.12), 0px 1px 2px rgba(0, 0, 0, 0.08)')
|
|
25
|
+
* // → [
|
|
26
|
+
* // { x: 0, y: 4, blur: 8, spread: 0, color: 'rgb(0 0 0 / 0.12)' },
|
|
27
|
+
* // { x: 0, y: 1, blur: 2, spread: 0, color: 'rgba(0, 0, 0, 0.08)' },
|
|
28
|
+
* // ]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function parseShadow(shadowValue: string): ParsedShadow[];
|
|
32
|
+
/** Base width of the arrow triangle (px). */
|
|
33
|
+
declare const ARROW_WIDTH = 12;
|
|
34
|
+
/** Height (protrusion) of the arrow triangle from the edge (px). */
|
|
35
|
+
declare const ARROW_HEIGHT = 8;
|
|
36
|
+
/**
|
|
37
|
+
* Fraction of the container border-radius applied to round the arrow tip
|
|
38
|
+
* (0 = sharp point, 1 = same radius as the container corners).
|
|
39
|
+
*/
|
|
40
|
+
declare const ARROW_TIP_RADIUS_FRACTION = 0.5;
|
|
41
|
+
type ArrowSide = 'top' | 'bottom' | 'left' | 'right';
|
|
42
|
+
/**
|
|
43
|
+
* Returns the side of the tooltip where the arrow should appear.
|
|
44
|
+
* The arrow points *toward* the trigger, so it lives on the opposite
|
|
45
|
+
* side of the placement direction.
|
|
46
|
+
*/
|
|
47
|
+
declare function getArrowSide(placement: string): ArrowSide;
|
|
48
|
+
interface TooltipPathOptions {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
placement: string;
|
|
52
|
+
borderRadius: number;
|
|
53
|
+
arrowWidth?: number;
|
|
54
|
+
arrowHeight?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Position of the arrow center along the arrow's edge (px), measured from
|
|
57
|
+
* the start of that edge (left for top/bottom sides, top for left/right).
|
|
58
|
+
* Typically derived from the Ariakit `TooltipArrow` element's position
|
|
59
|
+
* within the tooltip.
|
|
60
|
+
*
|
|
61
|
+
* Clamped so the arrow never collides with the border-radius curve
|
|
62
|
+
* Falls back to the midpoint of the edge when omitted.
|
|
63
|
+
*/
|
|
64
|
+
arrowCenter?: number;
|
|
65
|
+
/** Shift every coordinate in the path by this many pixels on the x-axis. */
|
|
66
|
+
offsetX?: number;
|
|
67
|
+
/** Shift every coordinate in the path by this many pixels on the y-axis. */
|
|
68
|
+
offsetY?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generates an SVG `<path>` string for a rounded rectangle with an arrow
|
|
72
|
+
* pointing toward the trigger element.
|
|
73
|
+
*
|
|
74
|
+
* The path is traced clockwise, inserting the arrow triangle on the
|
|
75
|
+
* appropriate edge. The arrow extends *outside* the 0,0 → width,height
|
|
76
|
+
* rectangle so the host `<svg>` must use `overflow: visible`.
|
|
77
|
+
*/
|
|
78
|
+
declare function generateTooltipPath({
|
|
79
|
+
width,
|
|
80
|
+
height,
|
|
81
|
+
placement,
|
|
82
|
+
borderRadius,
|
|
83
|
+
arrowWidth,
|
|
84
|
+
arrowHeight,
|
|
85
|
+
arrowCenter,
|
|
86
|
+
offsetX: ox,
|
|
87
|
+
offsetY: oy
|
|
88
|
+
}: TooltipPathOptions): string;
|
|
89
|
+
interface ArrowClampDeltaOptions {
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
placement: string;
|
|
93
|
+
borderRadius: number;
|
|
94
|
+
arrowCenter: number;
|
|
95
|
+
arrowWidth?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Computes the pixel offset the tooltip must shift so that the SVG arrow
|
|
99
|
+
* (after clamping) visually aligns with the Ariakit arrow's actual position.
|
|
100
|
+
*
|
|
101
|
+
* When the desired `arrowCenter` falls inside the safe zone the delta is 0.
|
|
102
|
+
* When it falls outside (e.g. a tiny trigger near a rounded corner), the
|
|
103
|
+
* returned delta tells the caller how far to translate the tooltip element
|
|
104
|
+
* so the clamped arrow ends up over the trigger center.
|
|
105
|
+
*/
|
|
106
|
+
declare function getArrowClampDelta({
|
|
107
|
+
width,
|
|
108
|
+
height,
|
|
109
|
+
placement,
|
|
110
|
+
borderRadius,
|
|
111
|
+
arrowCenter,
|
|
112
|
+
arrowWidth
|
|
113
|
+
}: ArrowClampDeltaOptions): {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
export { ARROW_HEIGHT, ARROW_TIP_RADIUS_FRACTION, ARROW_WIDTH, type ArrowClampDeltaOptions, type ArrowSide, type ParsedShadow, type TooltipPathOptions, generateTooltipPath, getArrowClampDelta, getArrowSide, parseShadow };
|