@transferwise/components 46.135.0 → 46.135.2
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/build/badge/BadgeAssets.js +2 -1
- package/build/badge/BadgeAssets.js.map +1 -1
- package/build/badge/BadgeAssets.mjs +2 -1
- package/build/badge/BadgeAssets.mjs.map +1 -1
- package/build/common/panel/Panel.js +49 -54
- package/build/common/panel/Panel.js.map +1 -1
- package/build/common/panel/Panel.mjs +54 -59
- package/build/common/panel/Panel.mjs.map +1 -1
- package/build/main.css +26 -14
- package/build/select/Select.js +1 -1
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/select/Select.mjs.map +1 -1
- package/build/styles/css/neptune.css +22 -11
- package/build/styles/less/neptune-tokens.less +3 -2
- package/build/styles/main.css +26 -14
- package/build/styles/modal/Modal.css +2 -2
- package/build/styles/props/neptune-tokens.css +2 -1
- package/build/styles/select/Select.css +2 -1
- package/build/styles/styles/less/neptune.css +22 -11
- package/build/tooltip/Tooltip.js +29 -50
- package/build/tooltip/Tooltip.js.map +1 -1
- package/build/tooltip/Tooltip.mjs +30 -51
- package/build/tooltip/Tooltip.mjs.map +1 -1
- package/build/types/badge/BadgeAssets.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/package.json +11 -13
- package/src/avatarView/AvatarView.story.tsx +1 -1
- package/src/avatarView/AvatarView.test.story.tsx +108 -1
- package/src/badge/BadgeAssets.tsx +2 -0
- package/src/common/panel/Panel.tsx +56 -49
- package/src/main.css +26 -14
- package/src/modal/Modal.css +2 -2
- package/src/modal/Modal.less +1 -1
- package/src/select/Select.css +2 -1
- package/src/select/Select.less +6 -5
- package/src/select/Select.test.story.tsx +59 -0
- package/src/select/Select.tsx +1 -1
- package/src/styles/less/neptune.css +22 -11
- package/src/tooltip/Tooltip.tsx +26 -45
package/src/tooltip/Tooltip.tsx
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
arrow as arrowMiddleware,
|
|
3
|
+
autoUpdate,
|
|
4
|
+
flip,
|
|
5
|
+
offset,
|
|
6
|
+
useFloating,
|
|
7
|
+
} from '@floating-ui/react';
|
|
2
8
|
import { clsx } from 'clsx';
|
|
3
9
|
import {
|
|
4
10
|
AriaAttributes,
|
|
11
|
+
CSSProperties,
|
|
5
12
|
PropsWithChildren,
|
|
6
13
|
ReactElement,
|
|
7
14
|
ReactNode,
|
|
8
15
|
cloneElement,
|
|
9
|
-
useEffect,
|
|
10
16
|
useId,
|
|
11
17
|
useRef,
|
|
12
18
|
useState,
|
|
13
19
|
} from 'react';
|
|
14
|
-
import { usePopper } from 'react-popper';
|
|
15
20
|
|
|
16
21
|
import { CommonProps, Position } from '../common';
|
|
17
22
|
import {
|
|
@@ -36,48 +41,30 @@ const Tooltip = ({
|
|
|
36
41
|
className,
|
|
37
42
|
}: TooltipProps) => {
|
|
38
43
|
const [open, setOpen] = useState(false);
|
|
39
|
-
const
|
|
40
|
-
const [arrowElement, setArrowElement] = useState(null);
|
|
41
|
-
const [popperElement, setPopperElement] = useState(null);
|
|
44
|
+
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
42
45
|
|
|
43
46
|
const fallbackId = useId();
|
|
44
47
|
const tooltipId = id ?? fallbackId;
|
|
45
|
-
const modifiers = [];
|
|
46
|
-
|
|
47
|
-
modifiers.push({
|
|
48
|
-
name: 'arrow',
|
|
49
|
-
options: {
|
|
50
|
-
element: arrowElement,
|
|
51
|
-
options: {
|
|
52
|
-
padding: 8, // 8px from the edges of the popper
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
// This lets you displace a popper element from its reference element.
|
|
57
|
-
modifiers.push({ name: 'offset', options: { offset: [0, 16] } });
|
|
58
|
-
modifiers.push({
|
|
59
|
-
name: 'flip',
|
|
60
|
-
options: {
|
|
61
|
-
fallbackPlacements: Position.TOP,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
48
|
|
|
65
|
-
const {
|
|
49
|
+
const { refs, floatingStyles, placement, middlewareData } = useFloating({
|
|
66
50
|
placement: position,
|
|
67
|
-
|
|
51
|
+
middleware: [
|
|
52
|
+
offset(16),
|
|
53
|
+
flip({ fallbackPlacements: [Position.TOP] }),
|
|
54
|
+
arrowMiddleware({ element: arrowRef, padding: 8 }),
|
|
55
|
+
],
|
|
56
|
+
whileElementsMounted: open ? autoUpdate : undefined,
|
|
57
|
+
open,
|
|
68
58
|
});
|
|
69
59
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
forceUpdate();
|
|
75
|
-
}
|
|
76
|
-
}, [open]);
|
|
60
|
+
const arrowStyle: CSSProperties = {
|
|
61
|
+
...(middlewareData.arrow?.x != null ? { left: middlewareData.arrow.x } : {}),
|
|
62
|
+
...(middlewareData.arrow?.y != null ? { top: middlewareData.arrow.y } : {}),
|
|
63
|
+
};
|
|
77
64
|
|
|
78
65
|
return (
|
|
79
66
|
<span
|
|
80
|
-
ref={
|
|
67
|
+
ref={refs.setReference}
|
|
81
68
|
className="tw-tooltip-container"
|
|
82
69
|
onMouseOver={() => setOpen(true)}
|
|
83
70
|
onFocus={() => setOpen(true)}
|
|
@@ -90,28 +77,22 @@ const Tooltip = ({
|
|
|
90
77
|
})
|
|
91
78
|
: null}
|
|
92
79
|
<div
|
|
93
|
-
|
|
94
|
-
ref={setPopperElement}
|
|
80
|
+
ref={refs.setFloating}
|
|
95
81
|
className={clsx(
|
|
96
82
|
'np-tooltip',
|
|
97
83
|
'np-panel',
|
|
98
84
|
open ? `np-panel--open np-tooltip--open` : null,
|
|
99
85
|
className,
|
|
100
86
|
)}
|
|
101
|
-
style={
|
|
102
|
-
{
|
|
87
|
+
style={floatingStyles}
|
|
88
|
+
data-popper-placement={placement}
|
|
103
89
|
aria-hidden={!open}
|
|
104
90
|
role="tooltip"
|
|
105
91
|
id={`${tooltipId}-tooltip`}
|
|
106
92
|
>
|
|
107
93
|
<div className="np-panel__content tooltip-inner">
|
|
108
94
|
{label}
|
|
109
|
-
<div
|
|
110
|
-
// @ts-expect-error
|
|
111
|
-
ref={setArrowElement}
|
|
112
|
-
className={clsx('np-panel__arrow')}
|
|
113
|
-
style={styles.arrow}
|
|
114
|
-
/>
|
|
95
|
+
<div ref={arrowRef} className={clsx('np-panel__arrow')} style={arrowStyle} />
|
|
115
96
|
</div>
|
|
116
97
|
</div>
|
|
117
98
|
</span>
|