@sproutsocial/seeds-react-tooltip 1.1.20 → 1.1.27
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +57 -0
- package/dist/esm/index.js +131 -123
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +17 -8
- package/dist/index.d.ts +17 -8
- package/dist/index.js +129 -121
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/Tooltip.stories.tsx +125 -0
- package/src/Tooltip.tsx +141 -128
- package/src/TooltipTypes.ts +32 -6
- package/src/__tests__/Tooltip.test.tsx +43 -153
- package/src/__tests__/mapPlacement.test.ts +56 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -8,14 +8,14 @@ $ tsup --dts
|
|
|
8
8
|
[34mCLI[39m Cleaning output folder
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
11
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m5.59 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m12.37 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 64ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m7.77 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m12.50 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 65ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
21
|
-
Done in
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 3813ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.03 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.03 KB[39m
|
|
21
|
+
Done in 5.10s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-tooltip
|
|
2
2
|
|
|
3
|
+
## 1.1.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [5892f44]
|
|
8
|
+
- @sproutsocial/seeds-react-system-props@3.1.1
|
|
9
|
+
- @sproutsocial/seeds-react-box@1.1.21
|
|
10
|
+
|
|
11
|
+
## 1.1.26
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [5114a32]
|
|
16
|
+
- @sproutsocial/seeds-react-theme@4.1.0
|
|
17
|
+
- @sproutsocial/seeds-react-box@1.1.20
|
|
18
|
+
|
|
19
|
+
## 1.1.25
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [132ef9d]
|
|
24
|
+
- Updated dependencies [132ef9d]
|
|
25
|
+
- @sproutsocial/seeds-react-theme@4.0.0
|
|
26
|
+
- @sproutsocial/seeds-react-system-props@3.1.0
|
|
27
|
+
- @sproutsocial/seeds-react-box@1.1.19
|
|
28
|
+
|
|
29
|
+
## 1.1.24
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [47c62b3]
|
|
34
|
+
- @sproutsocial/seeds-react-theme@3.7.1
|
|
35
|
+
- @sproutsocial/seeds-react-box@1.1.18
|
|
36
|
+
|
|
37
|
+
## 1.1.23
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [06da9c2]
|
|
42
|
+
- @sproutsocial/seeds-react-theme@3.7.0
|
|
43
|
+
- @sproutsocial/seeds-react-box@1.1.17
|
|
44
|
+
|
|
45
|
+
## 1.1.22
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- e5f4df1: Replace internal Tooltip implementation with @base-ui/react Tooltip primitives while preserving the existing public props API.
|
|
50
|
+
|
|
51
|
+
Behavioral note: the `placement` prop still accepts `auto`, `auto-start`, and `auto-end`, but these no longer perform Popper-style "best available side" selection. They now anchor to the `top` side (with the requested alignment) and rely on base-ui's runtime collision flipping to move off `top` only when there is not enough room. Since `placement` defaults to `auto`, tooltips that did not specify a placement will start at `top` and flip on collision instead of being positioned on the side with the most available space.
|
|
52
|
+
|
|
53
|
+
## 1.1.21
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies [6c3e44e]
|
|
58
|
+
- @sproutsocial/seeds-react-popout@2.5.0
|
|
59
|
+
|
|
3
60
|
## 1.1.20
|
|
4
61
|
|
|
5
62
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// src/Tooltip.tsx
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
3
|
+
import { useState, useRef, useEffect, useContext } from "react";
|
|
4
4
|
import MOTION from "@sproutsocial/seeds-motion/unitless";
|
|
5
|
-
import
|
|
5
|
+
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
6
|
+
import { DisablePortalToBodyContext } from "@sproutsocial/seeds-react-portal";
|
|
7
|
+
import Box2 from "@sproutsocial/seeds-react-box";
|
|
6
8
|
|
|
7
9
|
// src/styles.ts
|
|
8
10
|
import styled from "styled-components";
|
|
@@ -14,51 +16,38 @@ var StyledTooltipContent = styled(Box)`
|
|
|
14
16
|
`;
|
|
15
17
|
|
|
16
18
|
// src/Tooltip.tsx
|
|
17
|
-
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
20
|
var idCounter = 0;
|
|
19
21
|
var hasAttribute = (child, attribute) => {
|
|
20
22
|
return React.isValidElement(child) && child.props[attribute] !== void 0;
|
|
21
23
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
borderColor: "container.border.base",
|
|
50
|
-
...legacyMouseInteraction && {
|
|
51
|
-
onFocus: handleFocus,
|
|
52
|
-
onBlur: handleBlur,
|
|
53
|
-
onMouseEnter: handleFocus,
|
|
54
|
-
onMouseLeave: handleBlur
|
|
55
|
-
},
|
|
56
|
-
tabIndex: 0,
|
|
57
|
-
...rest,
|
|
58
|
-
children
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
};
|
|
24
|
+
function mapPlacement(placement) {
|
|
25
|
+
const parts = placement.split("-");
|
|
26
|
+
let side;
|
|
27
|
+
let align = "center";
|
|
28
|
+
switch (parts[0]) {
|
|
29
|
+
case "bottom":
|
|
30
|
+
side = "bottom";
|
|
31
|
+
break;
|
|
32
|
+
case "left":
|
|
33
|
+
side = "left";
|
|
34
|
+
break;
|
|
35
|
+
case "right":
|
|
36
|
+
side = "right";
|
|
37
|
+
break;
|
|
38
|
+
case "top":
|
|
39
|
+
case "auto":
|
|
40
|
+
default:
|
|
41
|
+
side = "top";
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
if (parts[1] === "start") {
|
|
45
|
+
align = "start";
|
|
46
|
+
} else if (parts[1] === "end") {
|
|
47
|
+
align = "end";
|
|
48
|
+
}
|
|
49
|
+
return { side, align };
|
|
50
|
+
}
|
|
62
51
|
var Tooltip = ({
|
|
63
52
|
content,
|
|
64
53
|
children,
|
|
@@ -69,101 +58,120 @@ var Tooltip = ({
|
|
|
69
58
|
zIndex = 7,
|
|
70
59
|
qa,
|
|
71
60
|
popoutProps,
|
|
61
|
+
triggerProps,
|
|
72
62
|
truncated = false,
|
|
73
63
|
onFocus,
|
|
74
64
|
onBlur,
|
|
75
65
|
legacyMouseInteraction,
|
|
76
66
|
...rest
|
|
77
67
|
}) => {
|
|
78
|
-
const [
|
|
79
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
68
|
+
const [open, setOpen] = useState(false);
|
|
80
69
|
const [id] = useState(`Racine-tooltip-${idCounter++}`);
|
|
70
|
+
const triggerRef = useRef(null);
|
|
81
71
|
const isInvalidContent = content === null || content === void 0;
|
|
72
|
+
const disablePortalToBody = useContext(DisablePortalToBodyContext);
|
|
73
|
+
const [portalContainer, setPortalContainer] = useState(void 0);
|
|
82
74
|
const resolvedExitDelay = exitDelay !== void 0 ? exitDelay : legacyMouseInteraction ? MOTION.MOTION_DURATION_FAST * 1e3 : 0;
|
|
83
|
-
const show = (e) => {
|
|
84
|
-
onFocus?.(e);
|
|
85
|
-
setShouldShow(true);
|
|
86
|
-
};
|
|
87
|
-
const hide = (e) => {
|
|
88
|
-
onBlur?.(e);
|
|
89
|
-
setShouldShow(false);
|
|
90
|
-
};
|
|
91
75
|
const defaultAppearance = appearance || (typeof content === "object" ? "box" : "pill");
|
|
76
|
+
const { side, align } = mapPlacement(placement);
|
|
77
|
+
const mergedWrapperProps = {
|
|
78
|
+
...popoutProps,
|
|
79
|
+
...triggerProps
|
|
80
|
+
};
|
|
81
|
+
const hasWrapperProps = Object.keys(mergedWrapperProps).length > 0;
|
|
92
82
|
useEffect(() => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (["Escape", "Esc"].includes(e.key)) {
|
|
97
|
-
setIsOpen(false);
|
|
98
|
-
setShouldShow(false);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
if (shouldShow) {
|
|
102
|
-
timeout = setTimeout(() => setIsOpen(true), enterDelay);
|
|
103
|
-
} else {
|
|
104
|
-
timeout = setTimeout(() => {
|
|
105
|
-
setIsOpen(false);
|
|
106
|
-
}, resolvedExitDelay);
|
|
83
|
+
if (disablePortalToBody && triggerRef.current) {
|
|
84
|
+
const dialogContent = triggerRef.current.closest("[role='dialog']");
|
|
85
|
+
setPortalContainer(dialogContent ?? void 0);
|
|
107
86
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
id,
|
|
125
|
-
...rest,
|
|
126
|
-
children: content
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
return /* @__PURE__ */ jsx(
|
|
130
|
-
Popout,
|
|
87
|
+
}, [disablePortalToBody]);
|
|
88
|
+
if (isInvalidContent) {
|
|
89
|
+
return /* @__PURE__ */ jsx(
|
|
90
|
+
"span",
|
|
91
|
+
{
|
|
92
|
+
style: truncated ? {
|
|
93
|
+
overflow: "hidden",
|
|
94
|
+
textOverflow: "ellipsis",
|
|
95
|
+
whiteSpace: "nowrap"
|
|
96
|
+
} : {},
|
|
97
|
+
children
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const tooltipTree = /* @__PURE__ */ jsxs(
|
|
102
|
+
BaseTooltip.Root,
|
|
131
103
|
{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
104
|
+
open,
|
|
105
|
+
onOpenChange: setOpen,
|
|
106
|
+
disabled: isInvalidContent,
|
|
107
|
+
disableHoverablePopup: !legacyMouseInteraction,
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
BaseTooltip.Trigger,
|
|
111
|
+
{
|
|
112
|
+
delay: enterDelay,
|
|
113
|
+
closeDelay: resolvedExitDelay,
|
|
114
|
+
render: /* @__PURE__ */ jsx(
|
|
115
|
+
"span",
|
|
116
|
+
{
|
|
117
|
+
ref: triggerRef,
|
|
118
|
+
onFocus,
|
|
119
|
+
onBlur,
|
|
120
|
+
"data-qa-popout-isopen": open ? "true" : "false",
|
|
121
|
+
"data-qa-tooltip": id,
|
|
122
|
+
...qa || {},
|
|
123
|
+
style: truncated ? {
|
|
124
|
+
overflow: "hidden",
|
|
125
|
+
textOverflow: "ellipsis",
|
|
126
|
+
whiteSpace: "nowrap",
|
|
127
|
+
display: "inline-flex"
|
|
128
|
+
} : void 0
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
children: React.isValidElement(children) ? React.cloneElement(children, {
|
|
132
|
+
"aria-expanded": hasAttribute(children, "aria-expanded") ? children.props["aria-expanded"] : void 0,
|
|
133
|
+
"aria-describedby": open ? id : void 0
|
|
134
|
+
}) : children
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ jsx(BaseTooltip.Portal, { container: portalContainer, children: /* @__PURE__ */ jsx(
|
|
138
|
+
BaseTooltip.Positioner,
|
|
139
|
+
{
|
|
140
|
+
side,
|
|
141
|
+
align,
|
|
142
|
+
sideOffset: 4,
|
|
143
|
+
style: { zIndex },
|
|
144
|
+
children: /* @__PURE__ */ jsx(
|
|
145
|
+
BaseTooltip.Popup,
|
|
146
|
+
{
|
|
147
|
+
id,
|
|
148
|
+
render: /* @__PURE__ */ jsx(
|
|
149
|
+
StyledTooltipContent,
|
|
150
|
+
{
|
|
151
|
+
role: "tooltip",
|
|
152
|
+
appearance: defaultAppearance,
|
|
153
|
+
borderRadius: defaultAppearance === "box" ? 500 : "5000em",
|
|
154
|
+
px: 400,
|
|
155
|
+
py: defaultAppearance === "box" ? 400 : 200,
|
|
156
|
+
m: 200,
|
|
157
|
+
color: "text.body",
|
|
158
|
+
bg: "container.background.base",
|
|
159
|
+
boxShadow: "medium",
|
|
160
|
+
border: 500,
|
|
161
|
+
borderColor: "container.border.base",
|
|
162
|
+
tabIndex: legacyMouseInteraction ? 0 : void 0,
|
|
163
|
+
...rest
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
children: content
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
) })
|
|
171
|
+
]
|
|
165
172
|
}
|
|
166
173
|
);
|
|
174
|
+
return hasWrapperProps ? /* @__PURE__ */ jsx(Box2, { ...mergedWrapperProps, children: tooltipTree }) : tooltipTree;
|
|
167
175
|
};
|
|
168
176
|
var Tooltip_default = Tooltip;
|
|
169
177
|
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Tooltip.tsx","../../src/styles.ts","../../src/TooltipTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useState, useEffect } from \"react\";\nimport MOTION from \"@sproutsocial/seeds-motion/unitless\";\nimport Popout from \"@sproutsocial/seeds-react-popout\";\nimport { StyledTooltipContent } from \"./styles\";\nimport type { TypeTooltipProps, TypeTooltipContent } from \"./TooltipTypes\";\n\nlet idCounter = 0;\n\nconst hasAttribute = (child: React.ReactNode, attribute: string) => {\n return React.isValidElement(child) && child.props[attribute] !== undefined;\n};\n\n/** Tooltip Styled Popout wrapper for handling events */\nconst TooltipBubble = ({\n appearance = \"pill\",\n children,\n onFocus,\n onBlur,\n legacyMouseInteraction,\n ...rest\n}: TypeTooltipContent) => {\n // @ts-ignore Will fix during refactor\n const handleFocus = (e) => {\n onFocus(e);\n };\n // @ts-ignore Will fix during refactor\n const handleBlur = (e) => {\n onBlur(e);\n };\n return (\n <StyledTooltipContent\n role=\"tooltip\"\n appearance={appearance}\n borderRadius={appearance === \"box\" ? 500 : \"5000em\"}\n px={400}\n py={appearance === \"box\" ? 400 : 200}\n m={200}\n color=\"text.body\"\n bg=\"container.background.base\"\n boxShadow=\"medium\"\n border={500}\n borderColor=\"container.border.base\"\n {...(legacyMouseInteraction && {\n onFocus: handleFocus,\n onBlur: handleBlur,\n onMouseEnter: handleFocus,\n onMouseLeave: handleBlur,\n })}\n tabIndex={0}\n {...rest}\n >\n {children}\n </StyledTooltipContent>\n );\n};\n\n/** Core component */\nconst Tooltip = ({\n content,\n children,\n enterDelay = MOTION.MOTION_DURATION_FAST * 1000,\n exitDelay,\n placement = \"auto\",\n appearance,\n zIndex = 7,\n qa,\n popoutProps,\n truncated = false,\n onFocus,\n onBlur,\n legacyMouseInteraction,\n ...rest\n}: TypeTooltipProps) => {\n const [shouldShow, setShouldShow] = useState(false);\n const [isOpen, setIsOpen] = useState(false);\n const [id] = useState(`Racine-tooltip-${idCounter++}`);\n const isInvalidContent = content === null || content === undefined;\n\n // Compute exitDelay based on legacyMouseInteraction if not explicitly provided\n const resolvedExitDelay =\n exitDelay !== undefined\n ? exitDelay\n : legacyMouseInteraction\n ? MOTION.MOTION_DURATION_FAST * 1000\n : 0;\n\n // @ts-ignore Will fix during refactor\n const show = (e) => {\n onFocus?.(e);\n setShouldShow(true);\n };\n // @ts-ignore Will fix during refactor\n const hide = (e) => {\n onBlur?.(e);\n setShouldShow(false);\n };\n\n const defaultAppearance =\n appearance || (typeof content === \"object\" ? \"box\" : \"pill\");\n\n /** Handles all the logic around whether to display/not display */\n useEffect(() => {\n const documentBody = document.body;\n let timeout;\n const onEsc = (e: KeyboardEvent): void => {\n // older browsers use \"Esc\"\n if ([\"Escape\", \"Esc\"].includes(e.key)) {\n setIsOpen(false);\n setShouldShow(false);\n }\n };\n\n if (shouldShow) {\n timeout = setTimeout(() => setIsOpen(true), enterDelay);\n } else {\n timeout = setTimeout(() => {\n setIsOpen(false);\n }, resolvedExitDelay);\n }\n\n // We only want listeners from the tooltip if its open in the first place\n if (isOpen) {\n documentBody.addEventListener(\"keydown\", onEsc, { capture: true });\n }\n return () => {\n documentBody.removeEventListener(\"keydown\", onEsc, { capture: true });\n clearTimeout(timeout);\n };\n }, [isOpen, setShouldShow, shouldShow, enterDelay, resolvedExitDelay]);\n\n /** The wrapped content of whats inside the Tooltip */\n const TooltipContent = () => (\n <TooltipBubble\n appearance={defaultAppearance}\n onFocus={show}\n onBlur={hide}\n legacyMouseInteraction={legacyMouseInteraction}\n aria-expanded={isOpen}\n id={id}\n {...rest}\n >\n {content}\n </TooltipBubble>\n );\n\n return (\n <Popout\n content={!isInvalidContent ? TooltipContent : undefined}\n isOpen={isOpen}\n placement={placement}\n qa={{\n \"data-qa-tooltip\": id,\n ...qa,\n }}\n id={id + \"-wrapper\"}\n focusOnContent={false}\n zIndex={zIndex}\n aria-haspopup=\"false\"\n display={truncated ? \"flex\" : undefined}\n disableWrapperAria={true} // required so that the child span doesnt take in redundant aria props\n {...popoutProps}\n >\n <span\n onBlur={hide}\n onFocus={show}\n onMouseEnter={show}\n onMouseLeave={hide}\n style={\n truncated\n ? {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }\n : {}\n }\n >\n {React.isValidElement(children)\n ? React.cloneElement(children as React.ReactElement, {\n //** There may be cases where the Tooltip's child needs to properly describe its role as expanding a drawer, in which case that property takes priority */\n \"aria-expanded\": hasAttribute(children, \"aria-expanded\")\n ? children.props[\"aria-expanded\"]\n : undefined,\n \"aria-describedby\": isOpen ? id : undefined,\n })\n : children}\n </span>\n </Popout>\n );\n};\n\nexport default Tooltip;\n","import styled from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport type { TypeTooltipContent } from \"./TooltipTypes\";\n\nexport const StyledTooltipContent = styled(Box)<\n Pick<TypeTooltipContent, \"appearance\">\n>`\n font-family: ${(props) => props.theme.fontFamily};\n ${(props) => props.theme.typography[200]}\n text-align: ${(props) => (props.appearance === \"box\" ? \"left\" : \"center\")};\n`;\n","import * as React from \"react\";\nimport type { TypePopoutProps } from \"@sproutsocial/seeds-react-popout\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport interface TypeTooltipProps\n extends Omit<\n TypeBoxProps,\n \"children\" | \"content\" | \"onMouseEnter\" | \"onMouseLeave\"\n > {\n /** The content that the tooltip should be attached to. Hovering or focusing this element will cause the tooltip to appear */\n children: React.ReactNode;\n\n /** The content to be displayed within the tooltip. If there is no content, just the children are rendered */\n content: React.ReactNode;\n\n /** The placement of the tooltip in relation to the children */\n placement?: TypePopoutProps[\"placement\"];\n\n /** The time (in ms) that a user has to be hovered/focused before the tooltip will appear */\n enterDelay?: number;\n\n /** The time (in ms) that a user has to leave hovered/focused before the tooltip will disappear */\n exitDelay?: number;\n\n /**\n * When true, enables mouse interaction on tooltip content and sets exitDelay\n * to MOTION_DURATION_FAST * 1000 by default (instead of 0).\n */\n legacyMouseInteraction?: boolean;\n\n /** Used to override the appearance of the Tooltip content. By default, strings will have the 'pill' appearance, and more complex content will have the 'box' appearance. You can change those defaults by setting this prop. */\n appearance?: \"pill\" | \"box\";\n qa?: object;\n zIndex?: number;\n\n /** Props to be spread onto the underlying Popout component */\n popoutProps?: Partial<TypePopoutProps>;\n\n /** Truncates text into a single line with ellipsis */\n truncated?: boolean;\n\n ariaProps?: Record<string, string>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface TypeTooltipContent\n extends Pick<TypeTooltipProps, \"appearance\" | \"children\"> {\n onFocus: (e: React.FocusEvent<HTMLDivElement, FocusEvent>) => void;\n onBlur: (e: React.FocusEvent<HTMLDivElement, FocusEvent>) => void;\n legacyMouseInteraction?: boolean;\n}\n","import Tooltip from \"./Tooltip\";\n\nexport default Tooltip;\nexport { Tooltip };\nexport * from \"./TooltipTypes\";\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,SAAS,UAAU,iBAAiB;AACpC,OAAO,YAAY;AACnB,OAAO,YAAY;;;ACHnB,OAAO,YAAY;AACnB,OAAO,SAAS;AAGT,IAAM,uBAAuB,OAAO,GAAG;AAAA,iBAG7B,CAAC,UAAU,MAAM,MAAM,UAAU;AAAA,IAC9C,CAAC,UAAU,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA,gBAC1B,CAAC,UAAW,MAAM,eAAe,QAAQ,SAAS,QAAS;AAAA;;;ADsBvE;AAxBJ,IAAI,YAAY;AAEhB,IAAM,eAAe,CAAC,OAAwB,cAAsB;AAClE,SAAa,qBAAe,KAAK,KAAK,MAAM,MAAM,SAAS,MAAM;AACnE;AAGA,IAAM,gBAAgB,CAAC;AAAA,EACrB,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA0B;AAExB,QAAM,cAAc,CAAC,MAAM;AACzB,YAAQ,CAAC;AAAA,EACX;AAEA,QAAM,aAAa,CAAC,MAAM;AACxB,WAAO,CAAC;AAAA,EACV;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL;AAAA,MACA,cAAc,eAAe,QAAQ,MAAM;AAAA,MAC3C,IAAI;AAAA,MACJ,IAAI,eAAe,QAAQ,MAAM;AAAA,MACjC,GAAG;AAAA,MACH,OAAM;AAAA,MACN,IAAG;AAAA,MACH,WAAU;AAAA,MACV,QAAQ;AAAA,MACR,aAAY;AAAA,MACX,GAAI,0BAA0B;AAAA,QAC7B,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,cAAc;AAAA,MAChB;AAAA,MACA,UAAU;AA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AACX,mBAAa,oBAAoB,WAAW,OAAO,EAAE,SAAS,KAAK,CAAC;AACpE,mBAAa,OAAO;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,QAAQ,eAAe,YAAY,YAAY,iBAAiB,CAAC;AAGrE,QAAM,iBAAiB,MACrB;AAAA,IAAC;AAAA;AAAA,MACC,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA,iBAAe;AAAA,MACf;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAGF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,CAAC,mBAAmB,iBAAiB;AAAA,MAC9C;AAAA,MACA;AAAA,MACA,IAAI;AAAA,QACF,mBAAmB;AAAA,QACnB,GAAG;AAAA,MACL;AAAA,MACA,IAAI,KAAK;AAAA,MACT,gBAAgB;AAAA,MAChB;AAAA,MACA,iBAAc;AAAA,MACd,SAAS,YAAY,SAAS;AAAA,MAC9B,oBAAoB;AAAA,MACnB,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,QAAQ;AAAA,UACR,SAAS;AAAA,UACT,cAAc;AAAA,UACd,cAAc;AAAA,UACd,OACE,YACI;AAAA,YACE,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,UACd,IACA,CAAC;AAAA,UAGN,UAAM,qBAAe,QAAQ,IACpB,mBAAa,UAAgC;AAAA;AAAA,YAEjD,iBAAiB,aAAa,UAAU,eAAe,IACnD,SAAS,MAAM,eAAe,IAC9B;AAAA,YACJ,oBAAoB,SAAS,KAAK;AAAA,UACpC,CAAC,IACD;AAAA;AAAA,MACN;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,kBAAQ;;;AEhMf,OAAuB;;;ACEvB,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/Tooltip.tsx","../../src/styles.ts","../../src/TooltipTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useState, useRef, useEffect, useContext } from \"react\";\nimport MOTION from \"@sproutsocial/seeds-motion/unitless\";\nimport { Tooltip as BaseTooltip } from \"@base-ui/react/tooltip\";\nimport { DisablePortalToBodyContext } from \"@sproutsocial/seeds-react-portal\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport { StyledTooltipContent } from \"./styles\";\nimport type { TypeTooltipProps } from \"./TooltipTypes\";\n\nlet idCounter = 0;\n\nconst hasAttribute = (child: React.ReactNode, attribute: string) => {\n return React.isValidElement(child) && child.props[attribute] !== undefined;\n};\n\ntype Side = \"top\" | \"bottom\" | \"left\" | \"right\";\ntype Align = \"start\" | \"center\" | \"end\";\n\n// `auto`, `auto-start`, and `auto-end` resolve to `side: \"top\"` (with align\n// taken from the suffix) and rely on base-ui's Positioner collision flipping at\n// runtime, rather than Popper's old best-initial-side selection. Exported for\n// unit testing of this mapping.\nexport function mapPlacement(placement: string): { side: Side; align: Align } {\n const parts = placement.split(\"-\");\n let side: Side;\n let align: Align = \"center\";\n\n switch (parts[0]) {\n case \"bottom\":\n side = \"bottom\";\n break;\n case \"left\":\n side = \"left\";\n break;\n case \"right\":\n side = \"right\";\n break;\n case \"top\":\n case \"auto\":\n default:\n side = \"top\";\n break;\n }\n\n if (parts[1] === \"start\") {\n align = \"start\";\n } else if (parts[1] === \"end\") {\n align = \"end\";\n }\n\n return { side, align };\n}\n\nconst Tooltip = ({\n content,\n children,\n enterDelay = MOTION.MOTION_DURATION_FAST * 1000,\n exitDelay,\n placement = \"auto\",\n appearance,\n zIndex = 7,\n qa,\n popoutProps,\n triggerProps,\n truncated = false,\n onFocus,\n onBlur,\n legacyMouseInteraction,\n ...rest\n}: TypeTooltipProps) => {\n const [open, setOpen] = useState(false);\n const [id] = useState(`Racine-tooltip-${idCounter++}`);\n const triggerRef = useRef<HTMLSpanElement>(null);\n const isInvalidContent = content === null || content === undefined;\n const disablePortalToBody = useContext(DisablePortalToBodyContext);\n const [portalContainer, setPortalContainer] = useState<\n HTMLElement | undefined\n >(undefined);\n\n const resolvedExitDelay =\n exitDelay !== undefined\n ? exitDelay\n : legacyMouseInteraction\n ? MOTION.MOTION_DURATION_FAST * 1000\n : 0;\n\n const defaultAppearance =\n appearance || (typeof content === \"object\" ? \"box\" : \"pill\");\n\n const { side, align } = mapPlacement(placement);\n\n const mergedWrapperProps = {\n ...popoutProps,\n ...triggerProps,\n };\n\n const hasWrapperProps = Object.keys(mergedWrapperProps).length > 0;\n\n useEffect(() => {\n if (disablePortalToBody && triggerRef.current) {\n const dialogContent =\n triggerRef.current.closest<HTMLElement>(\"[role='dialog']\");\n setPortalContainer(dialogContent ?? undefined);\n }\n }, [disablePortalToBody]);\n\n if (isInvalidContent) {\n return (\n <span\n style={\n truncated\n ? {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }\n : {}\n }\n >\n {children}\n </span>\n );\n }\n\n const tooltipTree = (\n <BaseTooltip.Root\n open={open}\n onOpenChange={setOpen}\n disabled={isInvalidContent}\n disableHoverablePopup={!legacyMouseInteraction}\n >\n <BaseTooltip.Trigger\n delay={enterDelay}\n closeDelay={resolvedExitDelay}\n render={\n <span\n ref={triggerRef}\n onFocus={onFocus}\n onBlur={onBlur}\n data-qa-popout-isopen={open ? \"true\" : \"false\"}\n data-qa-tooltip={id}\n {...(qa || {})}\n style={\n truncated\n ? {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n display: \"inline-flex\",\n }\n : undefined\n }\n />\n }\n >\n {React.isValidElement(children)\n ? React.cloneElement(children as React.ReactElement, {\n \"aria-expanded\": hasAttribute(children, \"aria-expanded\")\n ? children.props[\"aria-expanded\"]\n : undefined,\n \"aria-describedby\": open ? id : undefined,\n })\n : children}\n </BaseTooltip.Trigger>\n <BaseTooltip.Portal container={portalContainer}>\n <BaseTooltip.Positioner\n side={side}\n align={align}\n sideOffset={4}\n style={{ zIndex }}\n >\n <BaseTooltip.Popup\n id={id}\n render={\n <StyledTooltipContent\n role=\"tooltip\"\n appearance={defaultAppearance}\n borderRadius={defaultAppearance === \"box\" ? 500 : \"5000em\"}\n px={400}\n py={defaultAppearance === \"box\" ? 400 : 200}\n m={200}\n color=\"text.body\"\n bg=\"container.background.base\"\n boxShadow=\"medium\"\n border={500}\n borderColor=\"container.border.base\"\n tabIndex={legacyMouseInteraction ? 0 : undefined}\n {...rest}\n />\n }\n >\n {content}\n </BaseTooltip.Popup>\n </BaseTooltip.Positioner>\n </BaseTooltip.Portal>\n </BaseTooltip.Root>\n );\n\n return hasWrapperProps ? (\n <Box {...mergedWrapperProps}>{tooltipTree}</Box>\n ) : (\n tooltipTree\n );\n};\n\nexport default Tooltip;\n","import styled from \"styled-components\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport type { TypeTooltipContent } from \"./TooltipTypes\";\n\nexport const StyledTooltipContent = styled(Box)<\n Pick<TypeTooltipContent, \"appearance\">\n>`\n font-family: ${(props) => props.theme.fontFamily};\n ${(props) => props.theme.typography[200]}\n text-align: ${(props) => (props.appearance === \"box\" ? \"left\" : \"center\")};\n`;\n","import * as React from \"react\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport type TypeTooltipPlacement =\n | \"auto\"\n | \"auto-start\"\n | \"auto-end\"\n | \"top\"\n | \"top-start\"\n | \"top-end\"\n | \"bottom\"\n | \"bottom-start\"\n | \"bottom-end\"\n | \"left\"\n | \"left-start\"\n | \"left-end\"\n | \"right\"\n | \"right-start\"\n | \"right-end\";\n\nexport interface TypeTooltipProps\n extends Omit<\n TypeBoxProps,\n \"children\" | \"content\" | \"onMouseEnter\" | \"onMouseLeave\"\n > {\n /** The content that the tooltip should be attached to. Hovering or focusing this element will cause the tooltip to appear */\n children: React.ReactNode;\n\n /** The content to be displayed within the tooltip. If there is no content, just the children are rendered */\n content: React.ReactNode;\n\n /**\n * The placement of the tooltip in relation to the children.\n *\n * Note: `auto`, `auto-start`, and `auto-end` resolve to the `top` side (with\n * the requested alignment) and rely on base-ui's runtime collision flipping,\n * rather than the legacy Popper.js best-initial-side selection.\n */\n placement?: TypeTooltipPlacement;\n\n /** The time (in ms) that a user has to be hovered/focused before the tooltip will appear */\n enterDelay?: number;\n\n /** The time (in ms) that a user has to leave hovered/focused before the tooltip will disappear */\n exitDelay?: number;\n\n /**\n * When true, enables mouse interaction on tooltip content and sets exitDelay\n * to MOTION_DURATION_FAST * 1000 by default (instead of 0).\n */\n legacyMouseInteraction?: boolean;\n\n /** Used to override the appearance of the Tooltip content. By default, strings will have the 'pill' appearance, and more complex content will have the 'box' appearance. You can change those defaults by setting this prop. */\n appearance?: \"pill\" | \"box\";\n qa?: object;\n zIndex?: number;\n\n /**\n * @deprecated Use `triggerProps` instead. The Tooltip no longer uses Popout internally. This prop is accepted and merged with triggerProps\n */\n popoutProps?: Record<string, unknown>;\n\n /** Props spread onto an outer wrapper Box rendered around the tooltip. Use this to apply layout styles (e.g. `display`, `width`) or other Box props to the element that wraps the tooltip's children. */\n triggerProps?: TypeBoxProps;\n\n /** Truncates text into a single line with ellipsis */\n truncated?: boolean;\n\n ariaProps?: Record<string, string>;\n}\n\nexport interface TypeTooltipContent\n extends Pick<TypeTooltipProps, \"appearance\" | \"children\"> {\n onFocus: (e: React.FocusEvent<HTMLDivElement, FocusEvent>) => void;\n onBlur: (e: React.FocusEvent<HTMLDivElement, FocusEvent>) => void;\n legacyMouseInteraction?: boolean;\n}\n","import Tooltip from \"./Tooltip\";\n\nexport default Tooltip;\nexport { Tooltip };\nexport * from \"./TooltipTypes\";\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,SAAS,UAAU,QAAQ,WAAW,kBAAkB;AACxD,OAAO,YAAY;AACnB,SAAS,WAAW,mBAAmB;AACvC,SAAS,kCAAkC;AAC3C,OAAOA,UAAS;;;ACLhB,OAAO,YAAY;AACnB,OAAO,SAAS;AAGT,IAAM,uBAAuB,OAAO,GAAG;AAAA,iBAG7B,CAAC,UAAU,MAAM,MAAM,UAAU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D,SAAS,MAAM,eAAe,IAC9B;AAAA,cACJ,oBAAoB,OAAO,KAAK;AAAA,YAClC,CAAC,IACD;AAAA;AAAA,QACN;AAAA,QACA,oBAAC,YAAY,QAAZ,EAAmB,WAAW,iBAC7B;AAAA,UAAC,YAAY;AAAA,UAAZ;AAAA,YACC;AAAA,YACA;AAAA,YACA,YAAY;AAAA,YACZ,OAAO,EAAE,OAAO;AAAA,YAEhB;AAAA,cAAC,YAAY;AAAA,cAAZ;AAAA,gBACC;AAAA,gBACA,QACE;AAAA,kBAAC;AAAA;AAAA,oBACC,MAAK;AAAA,oBACL,YAAY;AAAA,oBACZ,cAAc,sBAAsB,QAAQ,MAAM;AAAA,oBAClD,IAAI;AAAA,oBACJ,IAAI,sBAAsB,QAAQ,MAAM;AAAA,oBACxC,GAAG;AAAA,oBACH,OAAM;AAAA,oBACN,IAAG;AAAA,oBACH,WAAU;AAAA,oBACV,QAAQ;AAAA,oBACR,aAAY;AAAA,oBACZ,UAAU,yBAAyB,IAAI;AAAA,oBACtC,GAAG;AAAA;AAAA,gBACN;AAAA,gBAGD;AAAA;AAAA,YACH;AAAA;AAAA,QACF,GACF;AAAA;AAAA;AAAA,EACF;AAGF,SAAO,kBACL,oBAACC,MAAA,EAAK,GAAG,oBAAqB,uBAAY,IAE1C;AAEJ;AAEA,IAAO,kBAAQ;;;AE7Mf,OAAuB;;;ACEvB,IAAO,gBAAQ;","names":["Box","Box"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { TypePopoutProps } from '@sproutsocial/seeds-react-popout';
|
|
4
3
|
import { TypeBoxProps } from '@sproutsocial/seeds-react-box';
|
|
5
4
|
|
|
5
|
+
type TypeTooltipPlacement = "auto" | "auto-start" | "auto-end" | "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end";
|
|
6
6
|
interface TypeTooltipProps extends Omit<TypeBoxProps, "children" | "content" | "onMouseEnter" | "onMouseLeave"> {
|
|
7
7
|
/** The content that the tooltip should be attached to. Hovering or focusing this element will cause the tooltip to appear */
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
/** The content to be displayed within the tooltip. If there is no content, just the children are rendered */
|
|
10
10
|
content: React.ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The placement of the tooltip in relation to the children.
|
|
13
|
+
*
|
|
14
|
+
* Note: `auto`, `auto-start`, and `auto-end` resolve to the `top` side (with
|
|
15
|
+
* the requested alignment) and rely on base-ui's runtime collision flipping,
|
|
16
|
+
* rather than the legacy Popper.js best-initial-side selection.
|
|
17
|
+
*/
|
|
18
|
+
placement?: TypeTooltipPlacement;
|
|
13
19
|
/** The time (in ms) that a user has to be hovered/focused before the tooltip will appear */
|
|
14
20
|
enterDelay?: number;
|
|
15
21
|
/** The time (in ms) that a user has to leave hovered/focused before the tooltip will disappear */
|
|
@@ -23,8 +29,12 @@ interface TypeTooltipProps extends Omit<TypeBoxProps, "children" | "content" | "
|
|
|
23
29
|
appearance?: "pill" | "box";
|
|
24
30
|
qa?: object;
|
|
25
31
|
zIndex?: number;
|
|
26
|
-
/**
|
|
27
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `triggerProps` instead. The Tooltip no longer uses Popout internally. This prop is accepted and merged with triggerProps
|
|
34
|
+
*/
|
|
35
|
+
popoutProps?: Record<string, unknown>;
|
|
36
|
+
/** Props spread onto an outer wrapper Box rendered around the tooltip. Use this to apply layout styles (e.g. `display`, `width`) or other Box props to the element that wraps the tooltip's children. */
|
|
37
|
+
triggerProps?: TypeBoxProps;
|
|
28
38
|
/** Truncates text into a single line with ellipsis */
|
|
29
39
|
truncated?: boolean;
|
|
30
40
|
ariaProps?: Record<string, string>;
|
|
@@ -35,7 +45,6 @@ interface TypeTooltipContent extends Pick<TypeTooltipProps, "appearance" | "chil
|
|
|
35
45
|
legacyMouseInteraction?: boolean;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
declare const Tooltip: ({ content, children, enterDelay, exitDelay, placement, appearance, zIndex, qa, popoutProps, truncated, onFocus, onBlur, legacyMouseInteraction, ...rest }: TypeTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
48
|
+
declare const Tooltip: ({ content, children, enterDelay, exitDelay, placement, appearance, zIndex, qa, popoutProps, triggerProps, truncated, onFocus, onBlur, legacyMouseInteraction, ...rest }: TypeTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
40
49
|
|
|
41
|
-
export { Tooltip, type TypeTooltipContent, type TypeTooltipProps, Tooltip as default };
|
|
50
|
+
export { Tooltip, type TypeTooltipContent, type TypeTooltipPlacement, type TypeTooltipProps, Tooltip as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { TypePopoutProps } from '@sproutsocial/seeds-react-popout';
|
|
4
3
|
import { TypeBoxProps } from '@sproutsocial/seeds-react-box';
|
|
5
4
|
|
|
5
|
+
type TypeTooltipPlacement = "auto" | "auto-start" | "auto-end" | "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end";
|
|
6
6
|
interface TypeTooltipProps extends Omit<TypeBoxProps, "children" | "content" | "onMouseEnter" | "onMouseLeave"> {
|
|
7
7
|
/** The content that the tooltip should be attached to. Hovering or focusing this element will cause the tooltip to appear */
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
/** The content to be displayed within the tooltip. If there is no content, just the children are rendered */
|
|
10
10
|
content: React.ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The placement of the tooltip in relation to the children.
|
|
13
|
+
*
|
|
14
|
+
* Note: `auto`, `auto-start`, and `auto-end` resolve to the `top` side (with
|
|
15
|
+
* the requested alignment) and rely on base-ui's runtime collision flipping,
|
|
16
|
+
* rather than the legacy Popper.js best-initial-side selection.
|
|
17
|
+
*/
|
|
18
|
+
placement?: TypeTooltipPlacement;
|
|
13
19
|
/** The time (in ms) that a user has to be hovered/focused before the tooltip will appear */
|
|
14
20
|
enterDelay?: number;
|
|
15
21
|
/** The time (in ms) that a user has to leave hovered/focused before the tooltip will disappear */
|
|
@@ -23,8 +29,12 @@ interface TypeTooltipProps extends Omit<TypeBoxProps, "children" | "content" | "
|
|
|
23
29
|
appearance?: "pill" | "box";
|
|
24
30
|
qa?: object;
|
|
25
31
|
zIndex?: number;
|
|
26
|
-
/**
|
|
27
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `triggerProps` instead. The Tooltip no longer uses Popout internally. This prop is accepted and merged with triggerProps
|
|
34
|
+
*/
|
|
35
|
+
popoutProps?: Record<string, unknown>;
|
|
36
|
+
/** Props spread onto an outer wrapper Box rendered around the tooltip. Use this to apply layout styles (e.g. `display`, `width`) or other Box props to the element that wraps the tooltip's children. */
|
|
37
|
+
triggerProps?: TypeBoxProps;
|
|
28
38
|
/** Truncates text into a single line with ellipsis */
|
|
29
39
|
truncated?: boolean;
|
|
30
40
|
ariaProps?: Record<string, string>;
|
|
@@ -35,7 +45,6 @@ interface TypeTooltipContent extends Pick<TypeTooltipProps, "appearance" | "chil
|
|
|
35
45
|
legacyMouseInteraction?: boolean;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
declare const Tooltip: ({ content, children, enterDelay, exitDelay, placement, appearance, zIndex, qa, popoutProps, truncated, onFocus, onBlur, legacyMouseInteraction, ...rest }: TypeTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
48
|
+
declare const Tooltip: ({ content, children, enterDelay, exitDelay, placement, appearance, zIndex, qa, popoutProps, triggerProps, truncated, onFocus, onBlur, legacyMouseInteraction, ...rest }: TypeTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
40
49
|
|
|
41
|
-
export { Tooltip, type TypeTooltipContent, type TypeTooltipProps, Tooltip as default };
|
|
50
|
+
export { Tooltip, type TypeTooltipContent, type TypeTooltipPlacement, type TypeTooltipProps, Tooltip as default };
|