@ilo-org/react 0.9.1 → 0.10.1
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/CHANGELOG.md +25 -0
- package/lib/cjs/components/Button/Button.js +2 -2
- package/lib/cjs/components/Button/index.js +12 -3
- package/lib/cjs/components/Card/Card.js +1 -1
- package/lib/cjs/components/Checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/Checkbox/index.js +1 -1
- package/lib/cjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/cjs/components/DatePicker/index.js +1 -1
- package/lib/cjs/components/Dropdown/Dropdown.js +2 -2
- package/lib/cjs/components/Dropdown/index.js +1 -1
- package/lib/cjs/components/Fieldset/Fieldset.js +1 -1
- package/lib/cjs/components/Fieldset/index.js +1 -1
- package/lib/cjs/components/FileUpload/FileUpload.js +1 -1
- package/lib/cjs/components/FileUpload/index.js +1 -1
- package/lib/cjs/components/FormControl/FormControl.js +1 -1
- package/lib/cjs/components/FormControl/index.js +1 -1
- package/lib/cjs/components/Hero/Hero.js +1 -1
- package/lib/cjs/components/Hero/index.js +1 -1
- package/lib/cjs/components/Input/Input.js +1 -1
- package/lib/cjs/components/Input/index.js +1 -1
- package/lib/cjs/components/Navigation/Navigation.js +1 -1
- package/lib/cjs/components/Navigation/index.js +1 -1
- package/lib/cjs/components/NumberPicker/NumberPicker.js +1 -1
- package/lib/cjs/components/NumberPicker/index.js +1 -1
- package/lib/cjs/components/Profile/Profile.js +4 -2
- package/lib/cjs/components/Radio/Radio.js +1 -1
- package/lib/cjs/components/Radio/index.js +1 -1
- package/lib/cjs/components/SearchField/SearchField.js +1 -1
- package/lib/cjs/components/SearchField/index.js +1 -1
- package/lib/cjs/components/TextInput/TextInput.js +1 -1
- package/lib/cjs/components/TextInput/index.js +1 -1
- package/lib/cjs/components/Textarea/Textarea.js +1 -1
- package/lib/cjs/components/Textarea/index.js +1 -1
- package/lib/cjs/components/Toggle/Toggle.js +1 -1
- package/lib/cjs/components/Toggle/index.js +1 -1
- package/lib/cjs/components/Tooltip/Tooltip.js +42 -72
- package/lib/cjs/components/Tooltip/index.js +1 -1
- package/lib/cjs/components/index.js +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/esm/components/Button/Button.js +2 -2
- package/lib/esm/components/Button/index.js +12 -3
- package/lib/esm/components/Card/Card.js +1 -1
- package/lib/esm/components/Checkbox/Checkbox.js +1 -1
- package/lib/esm/components/Checkbox/index.js +1 -1
- package/lib/esm/components/DatePicker/DatePicker.js +1 -1
- package/lib/esm/components/DatePicker/index.js +1 -1
- package/lib/esm/components/Dropdown/Dropdown.js +2 -2
- package/lib/esm/components/Dropdown/index.js +1 -1
- package/lib/esm/components/Fieldset/Fieldset.js +1 -1
- package/lib/esm/components/Fieldset/index.js +1 -1
- package/lib/esm/components/FileUpload/FileUpload.js +1 -1
- package/lib/esm/components/FileUpload/index.js +1 -1
- package/lib/esm/components/FormControl/FormControl.js +1 -1
- package/lib/esm/components/FormControl/index.js +1 -1
- package/lib/esm/components/Hero/Hero.js +1 -1
- package/lib/esm/components/Hero/index.js +1 -1
- package/lib/esm/components/Input/Input.js +1 -1
- package/lib/esm/components/Input/index.js +1 -1
- package/lib/esm/components/Navigation/Navigation.js +1 -1
- package/lib/esm/components/Navigation/index.js +1 -1
- package/lib/esm/components/NumberPicker/NumberPicker.js +1 -1
- package/lib/esm/components/NumberPicker/index.js +1 -1
- package/lib/esm/components/Profile/Profile.js +4 -2
- package/lib/esm/components/Radio/Radio.js +1 -1
- package/lib/esm/components/Radio/index.js +1 -1
- package/lib/esm/components/SearchField/SearchField.js +1 -1
- package/lib/esm/components/SearchField/index.js +1 -1
- package/lib/esm/components/TextInput/TextInput.js +1 -1
- package/lib/esm/components/TextInput/index.js +1 -1
- package/lib/esm/components/Textarea/Textarea.js +1 -1
- package/lib/esm/components/Textarea/index.js +1 -1
- package/lib/esm/components/Toggle/Toggle.js +1 -1
- package/lib/esm/components/Toggle/index.js +1 -1
- package/lib/esm/components/Tooltip/Tooltip.js +42 -72
- package/lib/esm/components/Tooltip/index.js +1 -1
- package/lib/esm/components/index.js +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/types/react/src/components/Button/Button.props.d.ts +4 -0
- package/lib/types/react/src/components/Profile/Profile.props.d.ts +9 -0
- package/lib/types/react/src/components/Tooltip/Tooltip.props.d.ts +3 -11
- package/lib/types/react/src/types/index.d.ts +1 -0
- package/package.json +16 -16
- package/src/components/Button/Button.args.ts +12 -3
- package/src/components/Button/Button.props.ts +5 -0
- package/src/components/Button/Button.tsx +2 -0
- package/src/components/Card/Card.tsx +1 -1
- package/src/components/Dropdown/Dropdown.tsx +3 -1
- package/src/components/Profile/Profile.props.ts +12 -0
- package/src/components/Profile/Profile.tsx +19 -11
- package/src/components/Tooltip/Tooltip.args.ts +1 -1
- package/src/components/Tooltip/Tooltip.props.ts +3 -13
- package/src/components/Tooltip/Tooltip.tsx +68 -91
- package/src/types/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ilo-org/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "React components for the ILO's Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui_patterns",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
]
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
+
"@popperjs/core": "^2.11.8",
|
|
71
72
|
"classnames": "^2.3.1",
|
|
72
73
|
"dom-helpers": "^5.2.1",
|
|
73
74
|
"nanoid": "^3.3.6",
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
"@ilo-org/brand-assets": "0.2.0",
|
|
77
78
|
"@ilo-org/fonts": "0.1.2",
|
|
78
79
|
"@ilo-org/icons-react": "0.0.21",
|
|
79
|
-
"@ilo-org/styles": "0.13.
|
|
80
|
+
"@ilo-org/styles": "0.13.2",
|
|
80
81
|
"@ilo-org/themes": "0.7.0",
|
|
81
82
|
"@ilo-org/utils": "0.0.11"
|
|
82
83
|
},
|
|
@@ -84,21 +85,20 @@
|
|
|
84
85
|
"@rollup/plugin-commonjs": "^23.0.2",
|
|
85
86
|
"@rollup/plugin-json": "^5.0.1",
|
|
86
87
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
87
|
-
"@storybook/addon-a11y": "7.
|
|
88
|
-
"@storybook/addon-actions": "7.
|
|
89
|
-
"@storybook/addon-docs": "7.
|
|
90
|
-
"@storybook/addon-essentials": "7.
|
|
91
|
-
"@storybook/addon-links": "7.
|
|
88
|
+
"@storybook/addon-a11y": "7.6.6",
|
|
89
|
+
"@storybook/addon-actions": "7.6.6",
|
|
90
|
+
"@storybook/addon-docs": "7.6.6",
|
|
91
|
+
"@storybook/addon-essentials": "7.6.6",
|
|
92
|
+
"@storybook/addon-links": "7.6.6",
|
|
92
93
|
"@storybook/addon-styling": "^1.3.7",
|
|
93
|
-
"@storybook/blocks": "7.
|
|
94
|
-
"@storybook/
|
|
95
|
-
"@storybook/
|
|
96
|
-
"@storybook/
|
|
97
|
-
"@storybook/node-logger": "7.5.0-alpha.1",
|
|
94
|
+
"@storybook/blocks": "7.6.6",
|
|
95
|
+
"@storybook/client-api": "7.6.6",
|
|
96
|
+
"@storybook/manager-api": "7.6.6",
|
|
97
|
+
"@storybook/node-logger": "7.6.6",
|
|
98
98
|
"@storybook/preset-scss": "^1.0.3",
|
|
99
|
-
"@storybook/react": "7.
|
|
100
|
-
"@storybook/react-vite": "7.
|
|
101
|
-
"@storybook/theming": "7.
|
|
99
|
+
"@storybook/react": "7.6.6",
|
|
100
|
+
"@storybook/react-vite": "7.6.6",
|
|
101
|
+
"@storybook/theming": "7.6.6",
|
|
102
102
|
"@testing-library/jest-dom": "5.16.5",
|
|
103
103
|
"@testing-library/react": "^12.1.2",
|
|
104
104
|
"@testing-library/user-event": "^13.5.0",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
125
125
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
126
126
|
"screenfull": "^5.2.0",
|
|
127
|
-
"storybook": "7.
|
|
127
|
+
"storybook": "7.6.6",
|
|
128
128
|
"storybook-addon-performance": "^0.17.1",
|
|
129
129
|
"storybook-addon-rtl-direction": "^0.0.19",
|
|
130
130
|
"ts-dedent": "^2.2.0",
|
|
@@ -4,10 +4,19 @@ const primary: ButtonProps = {
|
|
|
4
4
|
type: "primary",
|
|
5
5
|
label: "Primary",
|
|
6
6
|
size: "medium",
|
|
7
|
+
name: "primary",
|
|
7
8
|
};
|
|
8
|
-
const secondary: ButtonProps = {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const secondary: ButtonProps = {
|
|
10
|
+
type: "secondary",
|
|
11
|
+
label: "Secondary",
|
|
12
|
+
name: "secondary",
|
|
13
|
+
};
|
|
14
|
+
const tertiary: ButtonProps = {
|
|
15
|
+
type: "tertiary",
|
|
16
|
+
label: "Tertiary",
|
|
17
|
+
name: "tertiary",
|
|
18
|
+
};
|
|
19
|
+
const alert: ButtonProps = { type: "alert", label: "Alert", name: "alert" };
|
|
11
20
|
const icon: ButtonProps = { type: "primary", label: "Icon", icon: "close" };
|
|
12
21
|
const disabled: ButtonProps = {
|
|
13
22
|
type: "primary",
|
|
@@ -20,6 +20,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
20
20
|
type = "primary",
|
|
21
21
|
url,
|
|
22
22
|
style,
|
|
23
|
+
name,
|
|
23
24
|
}) => {
|
|
24
25
|
const { prefix } = useGlobalSettings();
|
|
25
26
|
const baseClass = `${prefix}--button`;
|
|
@@ -63,6 +64,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
63
64
|
type={kind}
|
|
64
65
|
aria-haspopup={opensmodal ? `dialog` : false}
|
|
65
66
|
style={style}
|
|
67
|
+
name={name}
|
|
66
68
|
>
|
|
67
69
|
{label && <span className="button__label">{label}</span>}
|
|
68
70
|
{icon && <Icon name={icon} hidden={true} />}
|
|
@@ -67,7 +67,7 @@ const Card: FC<CardProps> = ({
|
|
|
67
67
|
)}
|
|
68
68
|
<div className={`${baseClass}--content`}>
|
|
69
69
|
{eyebrow && <p className={`${baseClass}--eyebrow`}>{eyebrow}</p>}
|
|
70
|
-
{title && <
|
|
70
|
+
{title && <h3 className={`${baseClass}--title`}>{title}</h3>}
|
|
71
71
|
{(variant == "multilink" || (variant == "data" && image)) && (
|
|
72
72
|
<div className={`${baseClass}--image--wrapper`}>
|
|
73
73
|
<picture>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ThemeTypes, SizeTypes } from "../../types";
|
|
2
|
+
|
|
1
3
|
interface LinkProps {
|
|
2
4
|
/**
|
|
3
5
|
* Specify the label for the the Profile's link
|
|
@@ -11,6 +13,16 @@ interface LinkProps {
|
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface ProfileProps {
|
|
16
|
+
/**
|
|
17
|
+
* Specify the theme for your profile component.
|
|
18
|
+
*/
|
|
19
|
+
theme?: ThemeTypes;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Specify the size for your profile component.
|
|
23
|
+
*/
|
|
24
|
+
size?: SizeTypes;
|
|
25
|
+
|
|
14
26
|
/**
|
|
15
27
|
* Specify an optional avatar to be added to your Profile component. Image *must* be a perfect square. CMS backend should provide a fallback if the avatar is not populated.
|
|
16
28
|
*/
|
|
@@ -10,11 +10,15 @@ const Profile: FC<ProfileProps> = ({
|
|
|
10
10
|
link,
|
|
11
11
|
name,
|
|
12
12
|
role,
|
|
13
|
+
theme = "light",
|
|
14
|
+
size = "large",
|
|
13
15
|
}) => {
|
|
14
16
|
const { prefix } = useGlobalSettings();
|
|
15
17
|
const baseClass = `${prefix}--profile`;
|
|
16
18
|
const profileClasses = classNames(className, {
|
|
17
19
|
[baseClass]: true,
|
|
20
|
+
[`${baseClass}__theme__${theme}`]: theme,
|
|
21
|
+
[`${baseClass}__size__${size}`]: size,
|
|
18
22
|
});
|
|
19
23
|
|
|
20
24
|
return (
|
|
@@ -24,18 +28,22 @@ const Profile: FC<ProfileProps> = ({
|
|
|
24
28
|
src={avatar}
|
|
25
29
|
alt={`Avatar for ${name}`}
|
|
26
30
|
/>
|
|
27
|
-
<figcaption
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)}
|
|
33
|
-
{link && (
|
|
34
|
-
<a className={`${baseClass}--link info`} href={link.url}>
|
|
35
|
-
<span>{link.label}</span>
|
|
36
|
-
</a>
|
|
37
|
-
)}
|
|
31
|
+
<figcaption>
|
|
32
|
+
<div className={`${baseClass}--figcaption--content`}>
|
|
33
|
+
<div className={`${baseClass}--name`}>{name}</div>
|
|
34
|
+
{role && <div className={`${baseClass}--role`}>{role}</div>}
|
|
35
|
+
</div>
|
|
38
36
|
</figcaption>
|
|
37
|
+
{description && (
|
|
38
|
+
<p className={`${baseClass}--description`}>{description}</p>
|
|
39
|
+
)}
|
|
40
|
+
{link && (
|
|
41
|
+
<div className={`${baseClass}--link`}>
|
|
42
|
+
<a href={link.url} target="__blank" rel="noopener noreferrer">
|
|
43
|
+
<span className={`${baseClass}--link--label`}>{link.label}</span>
|
|
44
|
+
</a>
|
|
45
|
+
</div>
|
|
46
|
+
)}
|
|
39
47
|
</figure>
|
|
40
48
|
);
|
|
41
49
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TooltipThemes } from "../../types";
|
|
1
|
+
import { TooltipThemes, TooltipIconThemes } from "../../types";
|
|
2
2
|
|
|
3
3
|
export interface TooltipProps {
|
|
4
4
|
/**
|
|
@@ -26,23 +26,13 @@ export interface TooltipProps {
|
|
|
26
26
|
*/
|
|
27
27
|
isVisible?: boolean;
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Callback fired onMouseOver
|
|
31
|
-
*/
|
|
32
|
-
onMouseOver?: (e: React.MouseEventHandler<HTMLDivElement>) => any;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Callback fired onMouseOut
|
|
36
|
-
*/
|
|
37
|
-
onMouseOut?: (e: React.MouseEventHandler<HTMLDivElement>) => any;
|
|
38
|
-
|
|
39
29
|
/**
|
|
40
30
|
* Describe the theme of the tooltip
|
|
41
31
|
*/
|
|
42
32
|
theme?: Required<TooltipThemes>;
|
|
43
33
|
|
|
44
34
|
/**
|
|
45
|
-
*
|
|
35
|
+
* Describe the background theme of the tooltip
|
|
46
36
|
*/
|
|
47
|
-
|
|
37
|
+
iconTheme?: Required<TooltipIconThemes>;
|
|
48
38
|
}
|
|
@@ -1,138 +1,115 @@
|
|
|
1
|
-
import { FC, useState, useRef } from "react";
|
|
1
|
+
import React, { FC, useState, useRef } from "react";
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import useGlobalSettings from "../../hooks/useGlobalSettings";
|
|
4
4
|
import { TooltipProps } from "./Tooltip.props";
|
|
5
|
-
import
|
|
5
|
+
import { createPopper, Instance as PopperInstance } from "@popperjs/core";
|
|
6
6
|
|
|
7
7
|
const Tooltip: FC<TooltipProps> = ({
|
|
8
8
|
className,
|
|
9
9
|
children,
|
|
10
10
|
icon,
|
|
11
11
|
label,
|
|
12
|
+
iconTheme,
|
|
12
13
|
theme,
|
|
13
14
|
id,
|
|
14
15
|
}) => {
|
|
15
16
|
const { prefix } = useGlobalSettings();
|
|
16
17
|
const baseClass = `${prefix}--tooltip`;
|
|
17
18
|
const [isVisible, setIsVisible] = useState<boolean>(false);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const tooltipRef = useRef<HTMLDivElement>(null);
|
|
20
|
+
const popperInstanceRef = useRef<PopperInstance | null>(null);
|
|
21
|
+
|
|
22
|
+
const isLongTooltip = () => {
|
|
23
|
+
const tooltipText = (
|
|
24
|
+
tooltipRef.current?.textContent ||
|
|
25
|
+
tooltipRef.current?.innerText ||
|
|
26
|
+
""
|
|
27
|
+
).trim();
|
|
28
|
+
return tooltipText.length > 50;
|
|
29
|
+
};
|
|
26
30
|
|
|
27
31
|
const tooltipClasses = classNames(className, {
|
|
28
32
|
[baseClass]: true,
|
|
29
33
|
[`${baseClass}--${theme}`]: theme,
|
|
30
|
-
[`${baseClass}--alignment-${arrowAlignment}`]: arrowAlignment,
|
|
31
34
|
[`${baseClass}--visible`]: isVisible,
|
|
35
|
+
[`${baseClass}--long`]: isLongTooltip(),
|
|
32
36
|
});
|
|
33
37
|
|
|
34
|
-
const tooltipArrowClasses = classNames(
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
const tooltipArrowClasses = classNames(
|
|
39
|
+
`${baseClass}--arrow`,
|
|
40
|
+
`${baseClass}--arrow--placement-negative`
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const iconClasses = classNames(className, `${baseClass}--wrapper`, {
|
|
44
|
+
[`${baseClass}--wrapper__icon ${baseClass}--wrapper__icon__theme__${theme}`]:
|
|
45
|
+
icon,
|
|
46
|
+
[`${baseClass}--wrapper__icon__theme__${theme}`]: iconTheme,
|
|
37
47
|
});
|
|
38
48
|
|
|
39
|
-
const handleOnMouseOver: React.MouseEventHandler<HTMLDivElement>
|
|
40
|
-
React.FocusEventHandler<HTMLDivElement> = (e) => {
|
|
41
|
-
// get hovered element reference
|
|
49
|
+
const handleOnMouseOver: React.MouseEventHandler<HTMLDivElement> = (e) => {
|
|
42
50
|
const target = e.currentTarget;
|
|
51
|
+
if (target && tooltipRef.current) {
|
|
52
|
+
const popperInstance = createPopper(target, tooltipRef.current, {
|
|
53
|
+
placement: "top",
|
|
54
|
+
modifiers: [
|
|
55
|
+
{
|
|
56
|
+
name: "offset",
|
|
57
|
+
options: {
|
|
58
|
+
offset: [0, 12], // Adjust offset as needed
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "flip",
|
|
63
|
+
enabled: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "preventOverflow",
|
|
67
|
+
enabled: true,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
popperInstanceRef.current = popperInstance;
|
|
43
73
|
|
|
44
|
-
if (target) {
|
|
45
|
-
const rect = target.getBoundingClientRect();
|
|
46
74
|
setIsVisible(true);
|
|
47
|
-
postMouseOver(rect);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const postMouseOver = (hoverRect: any) => {
|
|
52
|
-
// position the tooltip after showing it
|
|
53
|
-
let placement = "center";
|
|
54
|
-
let alignment = "left";
|
|
55
|
-
|
|
56
|
-
const ttNode = ReactDOM.findDOMNode(tooltipRef.current) as Element;
|
|
57
|
-
if (ttNode != null) {
|
|
58
|
-
let x = 0,
|
|
59
|
-
y = 0;
|
|
60
|
-
|
|
61
|
-
const docWidth = document.documentElement.clientWidth,
|
|
62
|
-
docHeight = document.documentElement.clientHeight;
|
|
63
|
-
|
|
64
|
-
const rx = hoverRect.x + hoverRect.width, // most right x
|
|
65
|
-
lx = hoverRect.x, // most left x
|
|
66
|
-
ty = hoverRect.y, // most top y
|
|
67
|
-
by = hoverRect.y + hoverRect.height; // most bottom y
|
|
68
|
-
|
|
69
|
-
// tool tip rectange
|
|
70
|
-
const ttRect = ttNode.getBoundingClientRect();
|
|
71
|
-
|
|
72
|
-
const bRight =
|
|
73
|
-
rx + ttRect.width <= window.scrollX + docWidth &&
|
|
74
|
-
ty + ttRect.height <= window.scrollY + docHeight;
|
|
75
|
-
const bLeft =
|
|
76
|
-
lx - ttRect.width >= 0 &&
|
|
77
|
-
ty + ttRect.height <= window.scrollY + docHeight;
|
|
78
|
-
const bAbove = ty - ttRect.height >= 0;
|
|
79
|
-
const bBellow = by + ttRect.height <= window.scrollY + docHeight;
|
|
80
|
-
|
|
81
|
-
// the tooltip doesn't fit to the left
|
|
82
|
-
if (bRight) {
|
|
83
|
-
x = hoverRect.width + 16;
|
|
84
|
-
y = icon ? -8 : 0;
|
|
85
|
-
placement = "negative";
|
|
86
|
-
alignment = "right";
|
|
87
|
-
} else if (bBellow) {
|
|
88
|
-
x = icon ? -8 : 0;
|
|
89
|
-
y = hoverRect.height + 16;
|
|
90
|
-
|
|
91
|
-
placement = "center";
|
|
92
|
-
alignment = "bottom";
|
|
93
|
-
} else if (bLeft) {
|
|
94
|
-
x = -ttRect.width - 16;
|
|
95
|
-
y = icon ? -8 : 0;
|
|
96
|
-
|
|
97
|
-
placement = "negative";
|
|
98
|
-
alignment = "left";
|
|
99
|
-
} else if (bAbove) {
|
|
100
|
-
x = icon ? -8 : 0;
|
|
101
|
-
y = -ttRect.height - 16;
|
|
102
|
-
|
|
103
|
-
placement = "center";
|
|
104
|
-
alignment = "top";
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
setPosition({ x: x, y: y });
|
|
108
|
-
setArrowPlacement(placement);
|
|
109
|
-
setArrowAlignment(alignment);
|
|
110
75
|
}
|
|
111
76
|
};
|
|
112
77
|
|
|
113
78
|
const handleOnMouseOut = () => {
|
|
79
|
+
if (popperInstanceRef.current) {
|
|
80
|
+
popperInstanceRef.current.destroy();
|
|
81
|
+
}
|
|
114
82
|
setIsVisible(false);
|
|
115
83
|
};
|
|
116
84
|
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
// top: ((position.y + window.scrollY) + 'px')
|
|
120
|
-
left: position.x + "px",
|
|
121
|
-
top: position.y + "px",
|
|
85
|
+
const handleOnFocus: React.FocusEventHandler<HTMLDivElement> = (e) => {
|
|
86
|
+
handleOnMouseOver(e as unknown as React.MouseEvent<HTMLDivElement>);
|
|
122
87
|
};
|
|
123
88
|
|
|
124
89
|
return (
|
|
125
90
|
<div
|
|
126
|
-
className={
|
|
91
|
+
className={iconClasses}
|
|
127
92
|
onMouseOver={handleOnMouseOver}
|
|
128
|
-
onFocus={
|
|
93
|
+
onFocus={handleOnFocus}
|
|
129
94
|
onMouseOut={handleOnMouseOut}
|
|
130
95
|
onBlur={handleOnMouseOut}
|
|
131
96
|
id={id}
|
|
132
97
|
>
|
|
133
98
|
{!icon && <>{children}</>}
|
|
134
|
-
<span
|
|
135
|
-
|
|
99
|
+
<span
|
|
100
|
+
className={tooltipClasses}
|
|
101
|
+
ref={tooltipRef}
|
|
102
|
+
data-id={id}
|
|
103
|
+
id="tooltip"
|
|
104
|
+
role="tooltip"
|
|
105
|
+
aria-hidden={!isVisible}
|
|
106
|
+
>
|
|
107
|
+
<span
|
|
108
|
+
data-popper-arrow
|
|
109
|
+
className={tooltipArrowClasses}
|
|
110
|
+
data-placement="negative"
|
|
111
|
+
role="presentation"
|
|
112
|
+
/>
|
|
136
113
|
{label}
|
|
137
114
|
</span>
|
|
138
115
|
</div>
|
package/src/types/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type LabelTypes = "default" | "actionable" | "light";
|
|
|
32
32
|
export type LinkTypes = "light" | "dark" | "footer" | "button";
|
|
33
33
|
export type LinkListThemes = "light" | "dark";
|
|
34
34
|
export type TooltipThemes = "light" | "dark";
|
|
35
|
+
export type TooltipIconThemes = "light" | "dark";
|
|
35
36
|
export type TooltipAlignment = "top" | "right" | "bottom" | "left";
|
|
36
37
|
export type TooltipPlacement = "negative" | "center" | "positive";
|
|
37
38
|
export type ListAlignment = "default" | "horizontal";
|