@yahoo/uds 3.100.0-beta.2 → 3.100.0-beta.4
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 +1 -0
- package/dist/automated-config/dist/generated/autoVariants.d.cts +1 -0
- package/dist/automated-config/dist/generated/autoVariants.d.ts +1 -0
- package/dist/automated-config/dist/generated/autoVariants.js +1 -0
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +58 -3
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +16 -2
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +16 -2
- package/dist/automated-config/dist/generated/generatedConfigs.js +58 -3
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +5 -0
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +5 -0
- package/dist/automated-config/dist/properties.cjs +6 -1
- package/dist/automated-config/dist/properties.d.cts +2 -2
- package/dist/automated-config/dist/properties.d.ts +2 -2
- package/dist/automated-config/dist/properties.js +6 -1
- package/dist/automated-config/dist/utils/index.cjs +4 -4
- package/dist/automated-config/dist/utils/index.d.cts +1 -1
- package/dist/automated-config/dist/utils/index.d.ts +1 -1
- package/dist/automated-config/dist/utils/index.js +4 -4
- 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 +29 -1
- package/dist/components/client/Tooltip/Tooltip.d.cts +30 -1
- package/dist/components/client/Tooltip/Tooltip.d.ts +30 -1
- package/dist/components/client/Tooltip/Tooltip.js +29 -1
- package/dist/components/client/Tooltip/TooltipContent.cjs +49 -35
- package/dist/components/client/Tooltip/TooltipContent.js +49 -35
- package/dist/components/client/Tooltip/TooltipTrigger.d.cts +2 -1
- package/dist/components/client/Tooltip/TooltipTrigger.d.ts +2 -1
- package/dist/components/client/Tooltip/UDSTooltipConfigProvider.cjs +3 -4
- package/dist/components/client/Tooltip/UDSTooltipConfigProvider.d.cts +3 -4
- package/dist/components/client/Tooltip/UDSTooltipConfigProvider.d.ts +3 -4
- package/dist/components/client/Tooltip/UDSTooltipConfigProvider.js +3 -4
- package/dist/components/client/Tooltip/useTooltipContent.cjs +3 -16
- package/dist/components/client/Tooltip/useTooltipContent.d.cts +4 -3
- package/dist/components/client/Tooltip/useTooltipContent.d.ts +4 -3
- package/dist/components/client/Tooltip/useTooltipContent.js +3 -16
- package/dist/config/dist/index.cjs +5 -0
- package/dist/config/dist/index.d.cts +9 -0
- package/dist/config/dist/index.d.ts +9 -0
- package/dist/config/dist/index.js +5 -0
- package/dist/runtime/tooltipConfig.cjs +3 -20
- package/dist/runtime/tooltipConfig.d.cts +3 -4
- package/dist/runtime/tooltipConfig.d.ts +3 -4
- package/dist/runtime/tooltipConfig.js +3 -20
- package/dist/styles/styler.d.cts +44 -43
- package/dist/styles/styler.d.ts +44 -43
- package/dist/styles/variants.d.cts +3 -0
- package/dist/styles/variants.d.ts +3 -0
- package/dist/tailwind/utils/getTailwindAsUdsColors.d.cts +1 -1
- package/dist/tailwind/utils/getTailwindAsUdsColors.d.ts +1 -1
- package/dist/types/dist/index.d.cts +12 -0
- package/dist/types/dist/index.d.ts +12 -0
- package/dist/uds/generated/tailwindPurge.cjs +4 -3
- package/dist/uds/generated/tailwindPurge.js +4 -3
- package/package.json +1 -1
|
@@ -6,7 +6,35 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { TooltipProvider } from "@ariakit/react";
|
|
7
7
|
|
|
8
8
|
//#region src/components/client/Tooltip/Tooltip.tsx
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* **⚙️️ A Tooltip component that anchors to a trigger element
|
|
11
|
+
*
|
|
12
|
+
* @componentType Client component
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Tooltips provide short, contextual help for UI elements. They appear on hover, focus, or long-press, and should clarify meaning—not introduce new concepts.
|
|
16
|
+
*
|
|
17
|
+
* Tooltips are not meant for critical information or required actions. If the user must take action, use a Dialog, Popover, or Inline messaging instead.
|
|
18
|
+
*
|
|
19
|
+
* @see
|
|
20
|
+
* Check out the {@link https://uds.build/docs/components/tooltip Tooltip Docs} for more info
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* 'use client';
|
|
25
|
+
* import { Tooltip, TooltipTrigger, TooltipContent, Button } from "@yahoo/uds";
|
|
26
|
+
*
|
|
27
|
+
* <Tooltip>
|
|
28
|
+
* <TooltipTrigger>
|
|
29
|
+
* <Button>Tooltip Trigger</Button>
|
|
30
|
+
* </TooltipTrigger>
|
|
31
|
+
* <TooltipContent>basic tooltip content</TooltipContent>
|
|
32
|
+
* </Tooltip>
|
|
33
|
+
*```
|
|
34
|
+
*
|
|
35
|
+
* @related [Toast](https://uds.build/docs/components/toast), Popover (coming soon).
|
|
36
|
+
**/
|
|
37
|
+
function Tooltip({ children, placement, open, portal = true }) {
|
|
10
38
|
const hideOnHoverOutside = open === void 0;
|
|
11
39
|
const controlledProps = open !== void 0 ? {
|
|
12
40
|
showTimeout: 0,
|
|
@@ -23,17 +23,17 @@ const TooltipContent = (0, react.forwardRef)(function TooltipContent({ children,
|
|
|
23
23
|
const currentPlacement = (0, _ariakit_react.useStoreState)(store, "currentPlacement");
|
|
24
24
|
const placement = (0, _ariakit_react.useStoreState)(store, "placement");
|
|
25
25
|
const effectivePlacement = currentPlacement ?? placement ?? "top";
|
|
26
|
-
const {
|
|
26
|
+
const { borderRadius, animationDuration } = require_components_client_Tooltip_UDSTooltipConfigProvider.useTooltipConfig();
|
|
27
27
|
const defaultBorderRadius = borderRadius["default"];
|
|
28
28
|
const arrowRef = (0, react.useRef)(null);
|
|
29
|
-
const { internalRef, shadowFilterId, maxWidthClass, dimensions, shadows, shadowPadding, svgPath, blurStyle, childTransitionStyle,
|
|
29
|
+
const { internalRef, shadowFilterId, maxWidthClass, dimensions, shadows, shadowPadding, svgPath, blurStyle, childTransitionStyle, tooltipShift, onPositionUpdate } = require_components_client_Tooltip_useTooltipContent.useTooltipContent({
|
|
30
30
|
open: open ?? false,
|
|
31
31
|
effectivePlacement,
|
|
32
32
|
maxWidth,
|
|
33
33
|
borderRadius: defaultBorderRadius,
|
|
34
|
-
arrowRef
|
|
34
|
+
arrowRef,
|
|
35
|
+
animationDuration
|
|
35
36
|
});
|
|
36
|
-
const defaultBackdropBlur = backdropBlur["default"][colorScheme];
|
|
37
37
|
const mergedRef = require_hooks_useForkRef.useForkRef(ref, internalRef);
|
|
38
38
|
const classNames = {
|
|
39
39
|
root: require_styles_styler.getStyles({
|
|
@@ -51,10 +51,11 @@ const TooltipContent = (0, react.forwardRef)(function TooltipContent({ children,
|
|
|
51
51
|
position: "absolute",
|
|
52
52
|
width: "full",
|
|
53
53
|
height: "full",
|
|
54
|
-
className: require_styles_styler.cx("uds-bgBlurFallback", "top-0", "left-0", "z-[1]", "transition-opacity",
|
|
54
|
+
className: require_styles_styler.cx("uds-bgBlurFallback", "top-0", "left-0", "z-[1]", "transition-opacity", `duration-[${animationDuration}ms]`, "ease-in-out")
|
|
55
55
|
}),
|
|
56
56
|
title: require_styles_styler.getStyles({ tooltipSizeTitle: "default" }),
|
|
57
57
|
body: require_styles_styler.getStyles({ tooltipSizeBody: "default" }),
|
|
58
|
+
endContent: require_styles_styler.getStyles({ tooltipSizeEndContent: "default" }),
|
|
58
59
|
icon: require_styles_styler.getStyles({
|
|
59
60
|
tooltipSizeIcon: "default",
|
|
60
61
|
tooltipVariantIcon: "default"
|
|
@@ -69,7 +70,7 @@ const TooltipContent = (0, react.forwardRef)(function TooltipContent({ children,
|
|
|
69
70
|
updatePosition: onPositionUpdate,
|
|
70
71
|
style: tooltipShift.x !== 0 || tooltipShift.y !== 0 ? { transform: `translate(${tooltipShift.x}px, ${tooltipShift.y}px)` } : void 0,
|
|
71
72
|
children: [
|
|
72
|
-
|
|
73
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Box.Box, {
|
|
73
74
|
className: classNames.blur,
|
|
74
75
|
style: {
|
|
75
76
|
...blurStyle,
|
|
@@ -90,35 +91,46 @@ const TooltipContent = (0, react.forwardRef)(function TooltipContent({ children,
|
|
|
90
91
|
width: dimensions.width + 2 * (shadowPadding + require_components_client_Tooltip_util.ARROW_HEIGHT),
|
|
91
92
|
height: dimensions.height + 2 * (shadowPadding + require_components_client_Tooltip_util.ARROW_HEIGHT),
|
|
92
93
|
colorInterpolationFilters: "sRGB",
|
|
93
|
-
children: [
|
|
94
|
-
shadow
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
94
|
+
children: [
|
|
95
|
+
shadows.map((shadow, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [
|
|
96
|
+
shadow.spread !== 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("feMorphology", {
|
|
97
|
+
in: "SourceAlpha",
|
|
98
|
+
operator: shadow.spread > 0 ? "dilate" : "erode",
|
|
99
|
+
radius: Math.abs(shadow.spread),
|
|
100
|
+
result: `spread${i}`
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("feGaussianBlur", {
|
|
103
|
+
in: shadow.spread !== 0 ? `spread${i}` : "SourceAlpha",
|
|
104
|
+
stdDeviation: shadow.blur / 2,
|
|
105
|
+
result: `blurred${i}`
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("feOffset", {
|
|
108
|
+
in: `blurred${i}`,
|
|
109
|
+
dx: shadow.x,
|
|
110
|
+
dy: shadow.y,
|
|
111
|
+
result: `offset${i}`
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("feFlood", {
|
|
114
|
+
floodColor: shadow.color,
|
|
115
|
+
result: `color${i}`
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("feComposite", {
|
|
118
|
+
in: `color${i}`,
|
|
119
|
+
in2: `offset${i}`,
|
|
120
|
+
operator: "in",
|
|
121
|
+
result: `shadow${i}`
|
|
122
|
+
})
|
|
123
|
+
] }, i)),
|
|
124
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("feMerge", {
|
|
125
|
+
result: "mergedShadows",
|
|
126
|
+
children: shadows.map((_, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("feMergeNode", { in: `shadow${i}` }, i))
|
|
114
127
|
}),
|
|
115
128
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("feComposite", {
|
|
116
|
-
in:
|
|
117
|
-
in2:
|
|
118
|
-
operator: "
|
|
119
|
-
result: `shadow${i}`
|
|
129
|
+
in: "mergedShadows",
|
|
130
|
+
in2: "SourceAlpha",
|
|
131
|
+
operator: "out"
|
|
120
132
|
})
|
|
121
|
-
]
|
|
133
|
+
]
|
|
122
134
|
}) }),
|
|
123
135
|
shadows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
124
136
|
d: svgPath,
|
|
@@ -134,8 +146,7 @@ const TooltipContent = (0, react.forwardRef)(function TooltipContent({ children,
|
|
|
134
146
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_Box.Box, {
|
|
135
147
|
position: "relative",
|
|
136
148
|
flexDirection: "column",
|
|
137
|
-
|
|
138
|
-
className: "z-[3]",
|
|
149
|
+
className: "z-[3] gap-[inherit]",
|
|
139
150
|
style: childTransitionStyle,
|
|
140
151
|
id,
|
|
141
152
|
children: [title && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_Box.Box, {
|
|
@@ -147,6 +158,7 @@ const TooltipContent = (0, react.forwardRef)(function TooltipContent({ children,
|
|
|
147
158
|
className: classNames.icon
|
|
148
159
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
149
160
|
className: classNames.title,
|
|
161
|
+
color: "inherit",
|
|
150
162
|
children: title
|
|
151
163
|
})]
|
|
152
164
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_Box.Box, {
|
|
@@ -154,9 +166,11 @@ const TooltipContent = (0, react.forwardRef)(function TooltipContent({ children,
|
|
|
154
166
|
columnGap: "1.5",
|
|
155
167
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
156
168
|
className: classNames.body,
|
|
169
|
+
color: "inherit",
|
|
157
170
|
children
|
|
158
171
|
}), endContent && !(0, react.isValidElement)(endContent) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
159
|
-
|
|
172
|
+
className: classNames.endContent,
|
|
173
|
+
color: "inherit",
|
|
160
174
|
children: endContent
|
|
161
175
|
}) : endContent]
|
|
162
176
|
})]
|
|
@@ -21,17 +21,17 @@ const TooltipContent = forwardRef(function TooltipContent({ children, maxWidth,
|
|
|
21
21
|
const currentPlacement = useStoreState(store, "currentPlacement");
|
|
22
22
|
const placement = useStoreState(store, "placement");
|
|
23
23
|
const effectivePlacement = currentPlacement ?? placement ?? "top";
|
|
24
|
-
const {
|
|
24
|
+
const { borderRadius, animationDuration } = useTooltipConfig();
|
|
25
25
|
const defaultBorderRadius = borderRadius["default"];
|
|
26
26
|
const arrowRef = useRef(null);
|
|
27
|
-
const { internalRef, shadowFilterId, maxWidthClass, dimensions, shadows, shadowPadding, svgPath, blurStyle, childTransitionStyle,
|
|
27
|
+
const { internalRef, shadowFilterId, maxWidthClass, dimensions, shadows, shadowPadding, svgPath, blurStyle, childTransitionStyle, tooltipShift, onPositionUpdate } = useTooltipContent({
|
|
28
28
|
open: open ?? false,
|
|
29
29
|
effectivePlacement,
|
|
30
30
|
maxWidth,
|
|
31
31
|
borderRadius: defaultBorderRadius,
|
|
32
|
-
arrowRef
|
|
32
|
+
arrowRef,
|
|
33
|
+
animationDuration
|
|
33
34
|
});
|
|
34
|
-
const defaultBackdropBlur = backdropBlur["default"][colorScheme];
|
|
35
35
|
const mergedRef = useForkRef(ref, internalRef);
|
|
36
36
|
const classNames = {
|
|
37
37
|
root: getStyles({
|
|
@@ -49,10 +49,11 @@ const TooltipContent = forwardRef(function TooltipContent({ children, maxWidth,
|
|
|
49
49
|
position: "absolute",
|
|
50
50
|
width: "full",
|
|
51
51
|
height: "full",
|
|
52
|
-
className: cx("uds-bgBlurFallback", "top-0", "left-0", "z-[1]", "transition-opacity",
|
|
52
|
+
className: cx("uds-bgBlurFallback", "top-0", "left-0", "z-[1]", "transition-opacity", `duration-[${animationDuration}ms]`, "ease-in-out")
|
|
53
53
|
}),
|
|
54
54
|
title: getStyles({ tooltipSizeTitle: "default" }),
|
|
55
55
|
body: getStyles({ tooltipSizeBody: "default" }),
|
|
56
|
+
endContent: getStyles({ tooltipSizeEndContent: "default" }),
|
|
56
57
|
icon: getStyles({
|
|
57
58
|
tooltipSizeIcon: "default",
|
|
58
59
|
tooltipVariantIcon: "default"
|
|
@@ -67,7 +68,7 @@ const TooltipContent = forwardRef(function TooltipContent({ children, maxWidth,
|
|
|
67
68
|
updatePosition: onPositionUpdate,
|
|
68
69
|
style: tooltipShift.x !== 0 || tooltipShift.y !== 0 ? { transform: `translate(${tooltipShift.x}px, ${tooltipShift.y}px)` } : void 0,
|
|
69
70
|
children: [
|
|
70
|
-
|
|
71
|
+
/* @__PURE__ */ jsx(Box, {
|
|
71
72
|
className: classNames.blur,
|
|
72
73
|
style: {
|
|
73
74
|
...blurStyle,
|
|
@@ -88,35 +89,46 @@ const TooltipContent = forwardRef(function TooltipContent({ children, maxWidth,
|
|
|
88
89
|
width: dimensions.width + 2 * (shadowPadding + ARROW_HEIGHT),
|
|
89
90
|
height: dimensions.height + 2 * (shadowPadding + ARROW_HEIGHT),
|
|
90
91
|
colorInterpolationFilters: "sRGB",
|
|
91
|
-
children: [
|
|
92
|
-
shadow
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
children: [
|
|
93
|
+
shadows.map((shadow, i) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
94
|
+
shadow.spread !== 0 && /* @__PURE__ */ jsx("feMorphology", {
|
|
95
|
+
in: "SourceAlpha",
|
|
96
|
+
operator: shadow.spread > 0 ? "dilate" : "erode",
|
|
97
|
+
radius: Math.abs(shadow.spread),
|
|
98
|
+
result: `spread${i}`
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ jsx("feGaussianBlur", {
|
|
101
|
+
in: shadow.spread !== 0 ? `spread${i}` : "SourceAlpha",
|
|
102
|
+
stdDeviation: shadow.blur / 2,
|
|
103
|
+
result: `blurred${i}`
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ jsx("feOffset", {
|
|
106
|
+
in: `blurred${i}`,
|
|
107
|
+
dx: shadow.x,
|
|
108
|
+
dy: shadow.y,
|
|
109
|
+
result: `offset${i}`
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx("feFlood", {
|
|
112
|
+
floodColor: shadow.color,
|
|
113
|
+
result: `color${i}`
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsx("feComposite", {
|
|
116
|
+
in: `color${i}`,
|
|
117
|
+
in2: `offset${i}`,
|
|
118
|
+
operator: "in",
|
|
119
|
+
result: `shadow${i}`
|
|
120
|
+
})
|
|
121
|
+
] }, i)),
|
|
122
|
+
/* @__PURE__ */ jsx("feMerge", {
|
|
123
|
+
result: "mergedShadows",
|
|
124
|
+
children: shadows.map((_, i) => /* @__PURE__ */ jsx("feMergeNode", { in: `shadow${i}` }, i))
|
|
112
125
|
}),
|
|
113
126
|
/* @__PURE__ */ jsx("feComposite", {
|
|
114
|
-
in:
|
|
115
|
-
in2:
|
|
116
|
-
operator: "
|
|
117
|
-
result: `shadow${i}`
|
|
127
|
+
in: "mergedShadows",
|
|
128
|
+
in2: "SourceAlpha",
|
|
129
|
+
operator: "out"
|
|
118
130
|
})
|
|
119
|
-
]
|
|
131
|
+
]
|
|
120
132
|
}) }),
|
|
121
133
|
shadows.length > 0 && /* @__PURE__ */ jsx("path", {
|
|
122
134
|
d: svgPath,
|
|
@@ -132,8 +144,7 @@ const TooltipContent = forwardRef(function TooltipContent({ children, maxWidth,
|
|
|
132
144
|
/* @__PURE__ */ jsxs(Box, {
|
|
133
145
|
position: "relative",
|
|
134
146
|
flexDirection: "column",
|
|
135
|
-
|
|
136
|
-
className: "z-[3]",
|
|
147
|
+
className: "z-[3] gap-[inherit]",
|
|
137
148
|
style: childTransitionStyle,
|
|
138
149
|
id,
|
|
139
150
|
children: [title && /* @__PURE__ */ jsxs(Box, {
|
|
@@ -145,6 +156,7 @@ const TooltipContent = forwardRef(function TooltipContent({ children, maxWidth,
|
|
|
145
156
|
className: classNames.icon
|
|
146
157
|
}), /* @__PURE__ */ jsx(Text, {
|
|
147
158
|
className: classNames.title,
|
|
159
|
+
color: "inherit",
|
|
148
160
|
children: title
|
|
149
161
|
})]
|
|
150
162
|
}), /* @__PURE__ */ jsxs(Box, {
|
|
@@ -152,9 +164,11 @@ const TooltipContent = forwardRef(function TooltipContent({ children, maxWidth,
|
|
|
152
164
|
columnGap: "1.5",
|
|
153
165
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
154
166
|
className: classNames.body,
|
|
167
|
+
color: "inherit",
|
|
155
168
|
children
|
|
156
169
|
}), endContent && !isValidElement(endContent) ? /* @__PURE__ */ jsx(Text, {
|
|
157
|
-
|
|
170
|
+
className: classNames.endContent,
|
|
171
|
+
color: "inherit",
|
|
158
172
|
children: endContent
|
|
159
173
|
}) : endContent]
|
|
160
174
|
})]
|
|
@@ -3,9 +3,10 @@ import { UniversalTooltipTriggerProps } from "../../../types/dist/index.cjs";
|
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/components/client/Tooltip/TooltipTrigger.d.ts
|
|
6
|
+
type TooltipTriggerProps = UniversalTooltipTriggerProps;
|
|
6
7
|
declare function TooltipTrigger({
|
|
7
8
|
children
|
|
8
|
-
}:
|
|
9
|
+
}: TooltipTriggerProps): react_jsx_runtime0.JSX.Element;
|
|
9
10
|
declare namespace TooltipTrigger {
|
|
10
11
|
var displayName: string;
|
|
11
12
|
}
|
|
@@ -3,9 +3,10 @@ import { UniversalTooltipTriggerProps } from "../../../types/dist/index.js";
|
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/components/client/Tooltip/TooltipTrigger.d.ts
|
|
6
|
+
type TooltipTriggerProps = UniversalTooltipTriggerProps;
|
|
6
7
|
declare function TooltipTrigger({
|
|
7
8
|
children
|
|
8
|
-
}:
|
|
9
|
+
}: TooltipTriggerProps): react_jsx_runtime0.JSX.Element;
|
|
9
10
|
declare namespace TooltipTrigger {
|
|
10
11
|
var displayName: string;
|
|
11
12
|
}
|
|
@@ -28,12 +28,11 @@ UDSTooltipConfigProvider.displayName = "UDSTooltipConfigProvider";
|
|
|
28
28
|
function useTooltipConfig(options) {
|
|
29
29
|
const context = (0, react.useContext)(TooltipContext);
|
|
30
30
|
if (!context) throw new Error("useTooltipConfig must be used within a UDSConfigProvider or UDSTooltipConfigProvider");
|
|
31
|
-
const { placementMap, ...contextRest } = context;
|
|
32
|
-
|
|
31
|
+
const { placementMap, placement, ...contextRest } = context;
|
|
32
|
+
return {
|
|
33
33
|
...contextRest,
|
|
34
|
-
ariaKitPlacement: placementMap[options
|
|
34
|
+
ariaKitPlacement: placementMap[options?.placement ?? placement]
|
|
35
35
|
};
|
|
36
|
-
return contextRest;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
//#endregion
|
|
@@ -19,10 +19,9 @@ declare const UDSTooltipConfigProvider: {
|
|
|
19
19
|
}: UDSTooltipConfigProviderProps): react_jsx_runtime0.JSX.Element;
|
|
20
20
|
displayName: string;
|
|
21
21
|
};
|
|
22
|
-
declare function useTooltipConfig(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}): Omit<UDSTooltipConfigContextType, 'placementMap'> & {
|
|
22
|
+
declare function useTooltipConfig(options?: {
|
|
23
|
+
placement?: TooltipPlacement;
|
|
24
|
+
}): Omit<UDSTooltipConfigContextType, 'placementMap' | 'placement'> & {
|
|
26
25
|
ariaKitPlacement: TooltipProviderProps['placement'];
|
|
27
26
|
};
|
|
28
27
|
//#endregion
|
|
@@ -19,10 +19,9 @@ declare const UDSTooltipConfigProvider: {
|
|
|
19
19
|
}: UDSTooltipConfigProviderProps): react_jsx_runtime0.JSX.Element;
|
|
20
20
|
displayName: string;
|
|
21
21
|
};
|
|
22
|
-
declare function useTooltipConfig(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}): Omit<UDSTooltipConfigContextType, 'placementMap'> & {
|
|
22
|
+
declare function useTooltipConfig(options?: {
|
|
23
|
+
placement?: TooltipPlacement;
|
|
24
|
+
}): Omit<UDSTooltipConfigContextType, 'placementMap' | 'placement'> & {
|
|
26
25
|
ariaKitPlacement: TooltipProviderProps['placement'];
|
|
27
26
|
};
|
|
28
27
|
//#endregion
|
|
@@ -26,12 +26,11 @@ UDSTooltipConfigProvider.displayName = "UDSTooltipConfigProvider";
|
|
|
26
26
|
function useTooltipConfig(options) {
|
|
27
27
|
const context = useContext(TooltipContext);
|
|
28
28
|
if (!context) throw new Error("useTooltipConfig must be used within a UDSConfigProvider or UDSTooltipConfigProvider");
|
|
29
|
-
const { placementMap, ...contextRest } = context;
|
|
30
|
-
|
|
29
|
+
const { placementMap, placement, ...contextRest } = context;
|
|
30
|
+
return {
|
|
31
31
|
...contextRest,
|
|
32
|
-
ariaKitPlacement: placementMap[options
|
|
32
|
+
ariaKitPlacement: placementMap[options?.placement ?? placement]
|
|
33
33
|
};
|
|
34
|
-
return contextRest;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
//#endregion
|
|
@@ -7,7 +7,7 @@ const require_components_client_Tooltip_util = require('./util.cjs');
|
|
|
7
7
|
let react = require("react");
|
|
8
8
|
|
|
9
9
|
//#region src/components/client/Tooltip/useTooltipContent.ts
|
|
10
|
-
function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, arrowRef }) {
|
|
10
|
+
function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, arrowRef, animationDuration }) {
|
|
11
11
|
const internalRef = (0, react.useRef)(null);
|
|
12
12
|
const shadowFilterId = (0, react.useId)();
|
|
13
13
|
const [dimensions, setDimensions] = (0, react.useState)({
|
|
@@ -48,13 +48,6 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
48
48
|
return Math.max(max, extentX, extentY);
|
|
49
49
|
}, 0);
|
|
50
50
|
}, [shadows]);
|
|
51
|
-
const [colorScheme, setColorScheme] = (0, react.useState)("light");
|
|
52
|
-
const readColorScheme = (0, react.useCallback)(() => {
|
|
53
|
-
const el = internalRef.current;
|
|
54
|
-
if (!el) return;
|
|
55
|
-
const scheme = getComputedStyle(el).colorScheme;
|
|
56
|
-
setColorScheme(scheme === "dark" ? "dark" : "light");
|
|
57
|
-
}, []);
|
|
58
51
|
const [arrowCenter, setArrowCenter] = (0, react.useState)(void 0);
|
|
59
52
|
const computeArrowCenter = (0, react.useCallback)(() => {
|
|
60
53
|
const arrowEl = arrowRef.current;
|
|
@@ -79,15 +72,10 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
79
72
|
};
|
|
80
73
|
});
|
|
81
74
|
readShadows();
|
|
82
|
-
readColorScheme();
|
|
83
75
|
}
|
|
84
76
|
const next = computeArrowCenter();
|
|
85
77
|
if (next !== void 0) setArrowCenter((prev) => prev === next ? prev : next);
|
|
86
|
-
}, [
|
|
87
|
-
computeArrowCenter,
|
|
88
|
-
readShadows,
|
|
89
|
-
readColorScheme
|
|
90
|
-
]);
|
|
78
|
+
}, [computeArrowCenter, readShadows]);
|
|
91
79
|
const svgPath = (0, react.useMemo)(() => {
|
|
92
80
|
return dimensions.width > 0 && dimensions.height > 0 ? require_components_client_Tooltip_util.generateTooltipPath({
|
|
93
81
|
width: dimensions.width,
|
|
@@ -169,9 +157,8 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
169
157
|
visible,
|
|
170
158
|
childTransitionStyle: {
|
|
171
159
|
opacity: visible ? 1 : 0,
|
|
172
|
-
transition:
|
|
160
|
+
transition: `opacity ${animationDuration}ms ease-in-out`
|
|
173
161
|
},
|
|
174
|
-
colorScheme,
|
|
175
162
|
tooltipShift: (0, react.useMemo)(() => {
|
|
176
163
|
if (arrowCenter === void 0 || dimensions.width <= 0 || dimensions.height <= 0) return {
|
|
177
164
|
x: 0,
|
|
@@ -18,6 +18,8 @@ interface UseTooltipContentOptions {
|
|
|
18
18
|
* SVG arrow always mirrors where floating-ui places the native arrow.
|
|
19
19
|
*/
|
|
20
20
|
arrowRef: RefObject<HTMLDivElement | null>;
|
|
21
|
+
/** Animation duration from the tooltip config (ms). */
|
|
22
|
+
animationDuration: number;
|
|
21
23
|
}
|
|
22
24
|
interface UseTooltipContentReturn {
|
|
23
25
|
internalRef: RefObject<HTMLElement | null>;
|
|
@@ -34,8 +36,6 @@ interface UseTooltipContentReturn {
|
|
|
34
36
|
blurStyle: CSSProperties;
|
|
35
37
|
visible: boolean;
|
|
36
38
|
childTransitionStyle: CSSProperties;
|
|
37
|
-
/** Resolved CSS `color-scheme` of the tooltip element: `'light'` or `'dark'`. */
|
|
38
|
-
colorScheme: 'light' | 'dark';
|
|
39
39
|
/**
|
|
40
40
|
* Pixel offset to apply as a CSS transform on the tooltip element so that
|
|
41
41
|
* the (clamped) SVG arrow aligns with the trigger center even when the
|
|
@@ -59,7 +59,8 @@ declare function useTooltipContent({
|
|
|
59
59
|
effectivePlacement,
|
|
60
60
|
maxWidth,
|
|
61
61
|
borderRadius,
|
|
62
|
-
arrowRef
|
|
62
|
+
arrowRef,
|
|
63
|
+
animationDuration
|
|
63
64
|
}: UseTooltipContentOptions): UseTooltipContentReturn;
|
|
64
65
|
//#endregion
|
|
65
66
|
export { type UseTooltipContentOptions, type UseTooltipContentReturn, useTooltipContent };
|
|
@@ -18,6 +18,8 @@ interface UseTooltipContentOptions {
|
|
|
18
18
|
* SVG arrow always mirrors where floating-ui places the native arrow.
|
|
19
19
|
*/
|
|
20
20
|
arrowRef: RefObject<HTMLDivElement | null>;
|
|
21
|
+
/** Animation duration from the tooltip config (ms). */
|
|
22
|
+
animationDuration: number;
|
|
21
23
|
}
|
|
22
24
|
interface UseTooltipContentReturn {
|
|
23
25
|
internalRef: RefObject<HTMLElement | null>;
|
|
@@ -34,8 +36,6 @@ interface UseTooltipContentReturn {
|
|
|
34
36
|
blurStyle: CSSProperties;
|
|
35
37
|
visible: boolean;
|
|
36
38
|
childTransitionStyle: CSSProperties;
|
|
37
|
-
/** Resolved CSS `color-scheme` of the tooltip element: `'light'` or `'dark'`. */
|
|
38
|
-
colorScheme: 'light' | 'dark';
|
|
39
39
|
/**
|
|
40
40
|
* Pixel offset to apply as a CSS transform on the tooltip element so that
|
|
41
41
|
* the (clamped) SVG arrow aligns with the trigger center even when the
|
|
@@ -59,7 +59,8 @@ declare function useTooltipContent({
|
|
|
59
59
|
effectivePlacement,
|
|
60
60
|
maxWidth,
|
|
61
61
|
borderRadius,
|
|
62
|
-
arrowRef
|
|
62
|
+
arrowRef,
|
|
63
|
+
animationDuration
|
|
63
64
|
}: UseTooltipContentOptions): UseTooltipContentReturn;
|
|
64
65
|
//#endregion
|
|
65
66
|
export { type UseTooltipContentOptions, type UseTooltipContentReturn, useTooltipContent };
|
|
@@ -5,7 +5,7 @@ import { ARROW_HEIGHT, generateTooltipPath, getArrowClampDelta, getArrowSide, pa
|
|
|
5
5
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
6
6
|
|
|
7
7
|
//#region src/components/client/Tooltip/useTooltipContent.ts
|
|
8
|
-
function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, arrowRef }) {
|
|
8
|
+
function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, arrowRef, animationDuration }) {
|
|
9
9
|
const internalRef = useRef(null);
|
|
10
10
|
const shadowFilterId = useId();
|
|
11
11
|
const [dimensions, setDimensions] = useState({
|
|
@@ -46,13 +46,6 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
46
46
|
return Math.max(max, extentX, extentY);
|
|
47
47
|
}, 0);
|
|
48
48
|
}, [shadows]);
|
|
49
|
-
const [colorScheme, setColorScheme] = useState("light");
|
|
50
|
-
const readColorScheme = useCallback(() => {
|
|
51
|
-
const el = internalRef.current;
|
|
52
|
-
if (!el) return;
|
|
53
|
-
const scheme = getComputedStyle(el).colorScheme;
|
|
54
|
-
setColorScheme(scheme === "dark" ? "dark" : "light");
|
|
55
|
-
}, []);
|
|
56
49
|
const [arrowCenter, setArrowCenter] = useState(void 0);
|
|
57
50
|
const computeArrowCenter = useCallback(() => {
|
|
58
51
|
const arrowEl = arrowRef.current;
|
|
@@ -77,15 +70,10 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
77
70
|
};
|
|
78
71
|
});
|
|
79
72
|
readShadows();
|
|
80
|
-
readColorScheme();
|
|
81
73
|
}
|
|
82
74
|
const next = computeArrowCenter();
|
|
83
75
|
if (next !== void 0) setArrowCenter((prev) => prev === next ? prev : next);
|
|
84
|
-
}, [
|
|
85
|
-
computeArrowCenter,
|
|
86
|
-
readShadows,
|
|
87
|
-
readColorScheme
|
|
88
|
-
]);
|
|
76
|
+
}, [computeArrowCenter, readShadows]);
|
|
89
77
|
const svgPath = useMemo(() => {
|
|
90
78
|
return dimensions.width > 0 && dimensions.height > 0 ? generateTooltipPath({
|
|
91
79
|
width: dimensions.width,
|
|
@@ -167,9 +155,8 @@ function useTooltipContent({ open, effectivePlacement, maxWidth, borderRadius, a
|
|
|
167
155
|
visible,
|
|
168
156
|
childTransitionStyle: {
|
|
169
157
|
opacity: visible ? 1 : 0,
|
|
170
|
-
transition:
|
|
158
|
+
transition: `opacity ${animationDuration}ms ease-in-out`
|
|
171
159
|
},
|
|
172
|
-
colorScheme,
|
|
173
160
|
tooltipShift: useMemo(() => {
|
|
174
161
|
if (arrowCenter === void 0 || dimensions.width <= 0 || dimensions.height <= 0) return {
|
|
175
162
|
x: 0,
|
|
@@ -49,6 +49,11 @@ const yosConfig = {
|
|
|
49
49
|
valueType: "alias",
|
|
50
50
|
value: "ui3/emphasized"
|
|
51
51
|
} } },
|
|
52
|
+
"size/default/endContent": { textVariant: { rest: {
|
|
53
|
+
type: "textVariants",
|
|
54
|
+
valueType: "alias",
|
|
55
|
+
value: "caption1"
|
|
56
|
+
} } },
|
|
52
57
|
"size/default/icon": { size: { rest: {
|
|
53
58
|
type: "iconSizes",
|
|
54
59
|
valueType: "alias",
|
|
@@ -77,6 +77,15 @@ declare const yosConfig: {
|
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
+
readonly 'size/default/endContent': {
|
|
81
|
+
readonly textVariant: {
|
|
82
|
+
readonly rest: {
|
|
83
|
+
readonly type: "textVariants";
|
|
84
|
+
readonly valueType: "alias";
|
|
85
|
+
readonly value: "caption1";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
80
89
|
readonly 'size/default/icon': {
|
|
81
90
|
readonly size: {
|
|
82
91
|
readonly rest: {
|
|
@@ -77,6 +77,15 @@ declare const yosConfig: {
|
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
+
readonly 'size/default/endContent': {
|
|
81
|
+
readonly textVariant: {
|
|
82
|
+
readonly rest: {
|
|
83
|
+
readonly type: "textVariants";
|
|
84
|
+
readonly valueType: "alias";
|
|
85
|
+
readonly value: "caption1";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
80
89
|
readonly 'size/default/icon': {
|
|
81
90
|
readonly size: {
|
|
82
91
|
readonly rest: {
|
|
@@ -48,6 +48,11 @@ const yosConfig = {
|
|
|
48
48
|
valueType: "alias",
|
|
49
49
|
value: "ui3/emphasized"
|
|
50
50
|
} } },
|
|
51
|
+
"size/default/endContent": { textVariant: { rest: {
|
|
52
|
+
type: "textVariants",
|
|
53
|
+
valueType: "alias",
|
|
54
|
+
value: "caption1"
|
|
55
|
+
} } },
|
|
51
56
|
"size/default/icon": { size: { rest: {
|
|
52
57
|
type: "iconSizes",
|
|
53
58
|
valueType: "alias",
|