@purpurds/tooltip 7.6.1 → 7.7.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/.rush/temp/chunked-rush-logs/tooltip.test_unit.chunks.jsonl +4 -4
- package/.rush/temp/ci_build/@purpurds/tooltip/{e53969c1b0b0038edeecbaae9709b0cec2724cfe.untar.log → 56e2c4a58123de97ef646ba6b7c93c03d2203269.untar.log} +2 -2
- package/.rush/temp/operation/ci_build/all.log +4 -4
- package/.rush/temp/operation/ci_build/log-chunks.jsonl +4 -4
- package/.rush/temp/operation/ci_build/state.json +1 -1
- package/.rush/temp/operation/test_unit/all.log +4 -4
- package/.rush/temp/operation/test_unit/log-chunks.jsonl +4 -4
- package/.rush/temp/operation/test_unit/state.json +1 -1
- package/.rush/temp/shrinkwrap-deps.json +1 -1
- package/dist/LICENSE.txt +4 -4
- package/dist/tooltip.cjs.js +6 -6
- package/dist/tooltip.cjs.js.map +1 -1
- package/dist/tooltip.d.ts +26 -4
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.es.js +691 -713
- package/dist/tooltip.es.js.map +1 -1
- package/package.json +7 -6
- package/src/tooltip.stories.tsx +1 -1
- package/src/tooltip.tsx +17 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/tooltip",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.7.0",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/tooltip.cjs.js",
|
|
6
6
|
"types": "./dist/tooltip.d.ts",
|
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@radix-ui/react-tooltip": "~1.1.8",
|
|
19
19
|
"classnames": "~2.5.0",
|
|
20
|
-
"@purpurds/
|
|
21
|
-
"@purpurds/
|
|
22
|
-
"@purpurds/
|
|
23
|
-
"@purpurds/
|
|
24
|
-
"@purpurds/
|
|
20
|
+
"@purpurds/action": "7.7.0",
|
|
21
|
+
"@purpurds/button": "7.7.0",
|
|
22
|
+
"@purpurds/common-types": "7.7.0",
|
|
23
|
+
"@purpurds/icon": "7.7.0",
|
|
24
|
+
"@purpurds/paragraph": "7.7.0",
|
|
25
|
+
"@purpurds/tokens": "7.7.0"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"eslint": "9.24.0",
|
package/src/tooltip.stories.tsx
CHANGED
|
@@ -23,7 +23,7 @@ const meta = {
|
|
|
23
23
|
align: "center",
|
|
24
24
|
position: "top",
|
|
25
25
|
triggerElement: undefined,
|
|
26
|
-
triggerAriaLabel: "Tooltip
|
|
26
|
+
triggerAriaLabel: "Tooltip about the text that is about to be shown",
|
|
27
27
|
negative: false,
|
|
28
28
|
children: "Some tooltip content",
|
|
29
29
|
},
|
package/src/tooltip.tsx
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
Children,
|
|
3
|
-
type ForwardedRef,
|
|
4
|
-
forwardRef,
|
|
5
|
-
type HTMLAttributes,
|
|
6
|
-
type ReactNode,
|
|
7
|
-
useState,
|
|
8
|
-
} from "react";
|
|
1
|
+
import React, { Children, forwardRef, type ReactNode, useState } from "react";
|
|
9
2
|
import { type Size } from "@purpurds/action";
|
|
10
3
|
import { Button, BUTTON_VARIANT } from "@purpurds/button";
|
|
4
|
+
import type { BaseProps } from "@purpurds/common-types";
|
|
11
5
|
import { IconInfo } from "@purpurds/icon/info";
|
|
12
6
|
import { Paragraph, ParagraphVariant } from "@purpurds/paragraph";
|
|
13
7
|
import { purpurMotionDuration400 } from "@purpurds/tokens";
|
|
@@ -24,6 +18,7 @@ export const TOOLTIP_POSITION = {
|
|
|
24
18
|
LEFT: "left",
|
|
25
19
|
RIGHT: "right",
|
|
26
20
|
} as const;
|
|
21
|
+
|
|
27
22
|
export type TooltipPosition = (typeof TOOLTIP_POSITION)[keyof typeof TOOLTIP_POSITION];
|
|
28
23
|
|
|
29
24
|
export const TOOLTIP_ALIGN = {
|
|
@@ -43,13 +38,12 @@ type WithoutTriggeElement = {
|
|
|
43
38
|
triggerAriaLabel: string;
|
|
44
39
|
};
|
|
45
40
|
|
|
46
|
-
export type TooltipProps =
|
|
41
|
+
export type TooltipProps = Omit<BaseProps, "children"> & {
|
|
47
42
|
align?: TooltipAlign;
|
|
48
43
|
buttonSize?: Size;
|
|
49
44
|
children: ReactNode;
|
|
50
45
|
negative?: boolean;
|
|
51
46
|
position?: TooltipPosition;
|
|
52
|
-
["data-testid"]?: string;
|
|
53
47
|
triggerAriaLabel?: string;
|
|
54
48
|
triggerElement?: ReactNode;
|
|
55
49
|
contentClassName?: string;
|
|
@@ -57,7 +51,7 @@ export type TooltipProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
57
51
|
|
|
58
52
|
const rootClassName = "purpur-tooltip";
|
|
59
53
|
|
|
60
|
-
export const Tooltip = forwardRef(
|
|
54
|
+
export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
|
|
61
55
|
(
|
|
62
56
|
{
|
|
63
57
|
["data-testid"]: dataTestId,
|
|
@@ -71,19 +65,20 @@ export const Tooltip = forwardRef(
|
|
|
71
65
|
triggerAriaLabel,
|
|
72
66
|
triggerElement,
|
|
73
67
|
...props
|
|
74
|
-
}
|
|
75
|
-
ref
|
|
68
|
+
},
|
|
69
|
+
ref
|
|
76
70
|
) => {
|
|
77
71
|
const [isOpen, setIsOpen] = useState(false);
|
|
78
|
-
const classes = cx(
|
|
72
|
+
const classes = cx(
|
|
79
73
|
className,
|
|
80
74
|
rootClassName,
|
|
81
|
-
`${rootClassName}--primary${negative ? "-negative" : ""}
|
|
82
|
-
|
|
75
|
+
`${rootClassName}--primary${negative ? "-negative" : ""}`
|
|
76
|
+
);
|
|
83
77
|
const tooltipButton = (
|
|
84
78
|
<Button
|
|
85
79
|
ref={ref}
|
|
86
80
|
aria-label={triggerAriaLabel}
|
|
81
|
+
aria-expanded={isOpen}
|
|
87
82
|
variant={BUTTON_VARIANT.TERTIARY_PURPLE}
|
|
88
83
|
negative={negative}
|
|
89
84
|
iconOnly
|
|
@@ -111,11 +106,11 @@ export const Tooltip = forwardRef(
|
|
|
111
106
|
<RadixTooltip.Content
|
|
112
107
|
side={position}
|
|
113
108
|
align={align}
|
|
114
|
-
className={cx(
|
|
109
|
+
className={cx(
|
|
115
110
|
contentClassName,
|
|
116
111
|
`${rootClassName}__content`,
|
|
117
|
-
`${rootClassName}__content--primary${negative ? "-negative" : ""}
|
|
118
|
-
|
|
112
|
+
`${rootClassName}__content--primary${negative ? "-negative" : ""}`
|
|
113
|
+
)}
|
|
119
114
|
sideOffset={-5}
|
|
120
115
|
data-testid={`${dataTestId}-content`}
|
|
121
116
|
>
|
|
@@ -131,10 +126,10 @@ export const Tooltip = forwardRef(
|
|
|
131
126
|
children
|
|
132
127
|
)}
|
|
133
128
|
<RadixTooltip.Arrow
|
|
134
|
-
className={cx(
|
|
129
|
+
className={cx(
|
|
135
130
|
`${rootClassName}__arrow`,
|
|
136
|
-
`${rootClassName}__arrow--primary${negative ? "-negative" : ""}
|
|
137
|
-
|
|
131
|
+
`${rootClassName}__arrow--primary${negative ? "-negative" : ""}`
|
|
132
|
+
)}
|
|
138
133
|
/>
|
|
139
134
|
</RadixTooltip.Content>
|
|
140
135
|
</RadixTooltip.Portal>
|