@atlaskit/tooltip 17.3.1 → 17.5.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 +34 -0
- package/dist/cjs/Tooltip.js +27 -13
- package/dist/cjs/TooltipContainer.js +6 -2
- package/dist/cjs/TooltipPrimitive.js +4 -2
- package/dist/cjs/internal/use-unique-id.js +13 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/Tooltip.js +32 -19
- package/dist/es2019/TooltipContainer.js +6 -3
- package/dist/es2019/TooltipPrimitive.js +4 -2
- package/dist/es2019/internal/use-unique-id.js +5 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/Tooltip.js +25 -13
- package/dist/esm/TooltipContainer.js +5 -2
- package/dist/esm/TooltipPrimitive.js +4 -2
- package/dist/esm/internal/use-unique-id.js +5 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/TooltipContainer.d.ts +1 -1
- package/dist/types/TooltipPrimitive.d.ts +2 -1
- package/dist/types/internal/use-unique-id.d.ts +1 -0
- package/dist/types/types.d.ts +15 -3
- package/package.json +13 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @atlaskit/tooltip
|
|
2
2
|
|
|
3
|
+
## 17.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 17.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`cf853e39278`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cf853e39278) - Added the render props support to the Tooltip component. Linked the tooltip text to the trigger using aria-describedby for users with assistive technologies.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
19
|
+
## 17.4.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
25
|
+
## 17.4.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- [`45e06ed2420`](https://bitbucket.org/atlassian/atlassian-frontend/commits/45e06ed2420) - Instrumented Tooltip with the new theming package, `@atlaskit/tokens`.
|
|
30
|
+
Tokens will be visible only in applications configured to use the new Tokens API (currently in alpha).
|
|
31
|
+
These changes are intended to be interoperable with the legacy theme implementation. Legacy dark mode users should expect no visual or breaking changes.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies
|
|
36
|
+
|
|
3
37
|
## 17.3.1
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/dist/cjs/Tooltip.js
CHANGED
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
15
|
|
|
14
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -33,6 +35,8 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
33
35
|
|
|
34
36
|
var _tooltipManager = require("./internal/tooltip-manager");
|
|
35
37
|
|
|
38
|
+
var _useUniqueId = _interopRequireDefault(require("./internal/use-unique-id"));
|
|
39
|
+
|
|
36
40
|
var _TooltipContainer = _interopRequireDefault(require("./TooltipContainer"));
|
|
37
41
|
|
|
38
42
|
var _utilities = require("./utilities");
|
|
@@ -50,7 +54,7 @@ var tooltipZIndex = _constants.layers.tooltip();
|
|
|
50
54
|
var analyticsAttributes = {
|
|
51
55
|
componentName: 'tooltip',
|
|
52
56
|
packageName: "@atlaskit/tooltip",
|
|
53
|
-
packageVersion: "17.
|
|
57
|
+
packageVersion: "17.5.1"
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
function noop() {}
|
|
@@ -103,15 +107,20 @@ function Tooltip(_ref) {
|
|
|
103
107
|
var targetRef = (0, _react.useRef)(null);
|
|
104
108
|
var containerRef = (0, _react.useRef)(null);
|
|
105
109
|
var setRef = (0, _react.useCallback)(function (node) {
|
|
106
|
-
if (!node
|
|
110
|
+
if (!node) {
|
|
107
111
|
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
112
|
+
}
|
|
110
113
|
|
|
111
|
-
|
|
114
|
+
if (typeof children === 'function') {
|
|
115
|
+
// @ts-ignore - React Ref typing is too strict for this use case
|
|
116
|
+
targetRef.current = node;
|
|
117
|
+
} else {
|
|
118
|
+
// @ts-ignore - React Ref typing is too strict for this use case
|
|
119
|
+
containerRef.current = node; // @ts-ignore - React Ref typing is too strict for this use case
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
121
|
+
targetRef.current = node.firstChild;
|
|
122
|
+
}
|
|
123
|
+
}, [children]); // Putting a few things into refs so that we don't have to break memoization
|
|
115
124
|
|
|
116
125
|
var lastState = (0, _react.useRef)(state);
|
|
117
126
|
var lastDelay = (0, _react.useRef)(delay);
|
|
@@ -265,7 +274,7 @@ function Tooltip(_ref) {
|
|
|
265
274
|
|
|
266
275
|
var onMouseOver = (0, _react.useCallback)(function (event) {
|
|
267
276
|
// Ignoring events from the container ref
|
|
268
|
-
if (event.target === containerRef.current) {
|
|
277
|
+
if (containerRef.current && event.target === containerRef.current) {
|
|
269
278
|
return;
|
|
270
279
|
} // Using prevent default as a signal that parent tooltips
|
|
271
280
|
|
|
@@ -294,7 +303,7 @@ function Tooltip(_ref) {
|
|
|
294
303
|
|
|
295
304
|
var onMouseOut = (0, _react.useCallback)(function (event) {
|
|
296
305
|
// Ignoring events from the container ref
|
|
297
|
-
if (event.target === containerRef.current) {
|
|
306
|
+
if (containerRef.current && event.target === containerRef.current) {
|
|
298
307
|
return;
|
|
299
308
|
} // Using prevent default as a signal that parent tooltips
|
|
300
309
|
|
|
@@ -353,7 +362,8 @@ function Tooltip(_ref) {
|
|
|
353
362
|
return targetRef.current || undefined;
|
|
354
363
|
};
|
|
355
364
|
|
|
356
|
-
|
|
365
|
+
var tooltipId = (0, _useUniqueId.default)('tooltip', shouldRenderTooltipContainer);
|
|
366
|
+
var tooltipTriggerProps = {
|
|
357
367
|
onMouseOver: onMouseOver,
|
|
358
368
|
onMouseOut: onMouseOut,
|
|
359
369
|
onClick: onClick,
|
|
@@ -361,9 +371,12 @@ function Tooltip(_ref) {
|
|
|
361
371
|
onFocus: onFocus,
|
|
362
372
|
onBlur: onBlur,
|
|
363
373
|
ref: setRef,
|
|
364
|
-
|
|
374
|
+
'aria-describedby': tooltipId,
|
|
375
|
+
'data-testid': testId ? "".concat(testId, "--container") : undefined
|
|
376
|
+
};
|
|
377
|
+
return (0, _core.jsx)(_react.default.Fragment, null, typeof children === 'function' ? children(tooltipTriggerProps) : (0, _core.jsx)(CastTargetContainer, (0, _extends2.default)({}, tooltipTriggerProps, {
|
|
365
378
|
role: "presentation"
|
|
366
|
-
}, children), shouldRenderTooltipContainer ? (0, _core.jsx)(_portal.default, {
|
|
379
|
+
}), children), shouldRenderTooltipContainer ? (0, _core.jsx)(_portal.default, {
|
|
367
380
|
zIndex: tooltipZIndex
|
|
368
381
|
}, (0, _core.jsx)(_popper.Popper, {
|
|
369
382
|
placement: tooltipPosition,
|
|
@@ -389,7 +402,8 @@ function Tooltip(_ref) {
|
|
|
389
402
|
placement: tooltipPosition,
|
|
390
403
|
testId: testId,
|
|
391
404
|
onMouseOut: onMouseOut,
|
|
392
|
-
onMouseOver: onMouseOverTooltip
|
|
405
|
+
onMouseOver: onMouseOverTooltip,
|
|
406
|
+
id: tooltipId
|
|
393
407
|
}, typeof content === 'function' ? content({
|
|
394
408
|
update: update
|
|
395
409
|
}) : content)
|
|
@@ -19,6 +19,8 @@ var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
|
|
|
19
19
|
|
|
20
20
|
var _constants = require("@atlaskit/theme/constants");
|
|
21
21
|
|
|
22
|
+
var _tokens = require("@atlaskit/tokens");
|
|
23
|
+
|
|
22
24
|
var _TooltipPrimitive = _interopRequireDefault(require("./TooltipPrimitive"));
|
|
23
25
|
|
|
24
26
|
var _templateObject, _templateObject2, _templateObject3;
|
|
@@ -33,7 +35,8 @@ var TooltipContainer = /*#__PURE__*/(0, _react.forwardRef)(function TooltipConta
|
|
|
33
35
|
placement = _ref.placement,
|
|
34
36
|
testId = _ref.testId,
|
|
35
37
|
onMouseOut = _ref.onMouseOut,
|
|
36
|
-
onMouseOver = _ref.onMouseOver
|
|
38
|
+
onMouseOver = _ref.onMouseOver,
|
|
39
|
+
id = _ref.id;
|
|
37
40
|
return (0, _core.jsx)(_components.default.Consumer, null, function (_ref2) {
|
|
38
41
|
var mode = _ref2.mode;
|
|
39
42
|
return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
@@ -43,9 +46,10 @@ var TooltipContainer = /*#__PURE__*/(0, _react.forwardRef)(function TooltipConta
|
|
|
43
46
|
className: className,
|
|
44
47
|
placement: placement,
|
|
45
48
|
testId: testId,
|
|
49
|
+
id: id,
|
|
46
50
|
onMouseOut: onMouseOut,
|
|
47
51
|
onMouseOver: onMouseOver,
|
|
48
|
-
css: [baseCss, truncate ? truncateCss : null, (0, _core.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n background-color: ", ";\n color: ", ";\n "])), mode === 'light' ? _colors.N800 : _colors.DN0, mode === 'light' ? _colors.N0 : _colors.DN600)]
|
|
52
|
+
css: [baseCss, truncate ? truncateCss : null, (0, _core.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n background-color: ", ";\n color: ", ";\n "])), mode === 'light' ? (0, _tokens.token)('color.background.boldNeutral.resting', _colors.N800) : (0, _tokens.token)('color.background.boldNeutral.resting', _colors.DN0), mode === 'light' ? (0, _tokens.token)('color.text.onBold', _colors.N0) : (0, _tokens.token)('color.text.onBold', _colors.DN600))]
|
|
49
53
|
}, children)
|
|
50
54
|
);
|
|
51
55
|
});
|
|
@@ -25,7 +25,8 @@ var TooltipPrimitive = /*#__PURE__*/(0, _react.forwardRef)(function TooltipPrimi
|
|
|
25
25
|
placement = _ref.placement,
|
|
26
26
|
testId = _ref.testId,
|
|
27
27
|
onMouseOut = _ref.onMouseOut,
|
|
28
|
-
onMouseOver = _ref.onMouseOver
|
|
28
|
+
onMouseOver = _ref.onMouseOver,
|
|
29
|
+
id = _ref.id;
|
|
29
30
|
return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
30
31
|
(0, _core.jsx)("div", {
|
|
31
32
|
role: "tooltip",
|
|
@@ -36,7 +37,8 @@ var TooltipPrimitive = /*#__PURE__*/(0, _react.forwardRef)(function TooltipPrimi
|
|
|
36
37
|
onMouseOver: onMouseOver,
|
|
37
38
|
css: primitiveCss,
|
|
38
39
|
"data-placement": placement,
|
|
39
|
-
"data-testid": testId
|
|
40
|
+
"data-testid": testId,
|
|
41
|
+
id: id
|
|
40
42
|
}, children)
|
|
41
43
|
);
|
|
42
44
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useUniqueId;
|
|
7
|
+
|
|
8
|
+
var _reactUid = require("react-uid");
|
|
9
|
+
|
|
10
|
+
function useUniqueId(prefix, shouldRenderId) {
|
|
11
|
+
var seed = (0, _reactUid.useUIDSeed)();
|
|
12
|
+
return shouldRenderId ? "".concat(seed(prefix)) : undefined;
|
|
13
|
+
}
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/Tooltip.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
|
|
1
3
|
/** @jsx jsx */
|
|
2
4
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
5
|
import { jsx } from '@emotion/core';
|
|
@@ -9,13 +11,14 @@ import { Popper } from '@atlaskit/popper';
|
|
|
9
11
|
import Portal from '@atlaskit/portal';
|
|
10
12
|
import { layers } from '@atlaskit/theme/constants';
|
|
11
13
|
import { show } from './internal/tooltip-manager';
|
|
14
|
+
import useUniqueId from './internal/use-unique-id';
|
|
12
15
|
import TooltipContainer from './TooltipContainer';
|
|
13
16
|
import { getMousePosition } from './utilities';
|
|
14
17
|
const tooltipZIndex = layers.tooltip();
|
|
15
18
|
const analyticsAttributes = {
|
|
16
19
|
componentName: 'tooltip',
|
|
17
20
|
packageName: "@atlaskit/tooltip",
|
|
18
|
-
packageVersion: "17.
|
|
21
|
+
packageVersion: "17.5.1"
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
function noop() {}
|
|
@@ -55,15 +58,20 @@ function Tooltip({
|
|
|
55
58
|
const targetRef = useRef(null);
|
|
56
59
|
const containerRef = useRef(null);
|
|
57
60
|
const setRef = useCallback(node => {
|
|
58
|
-
if (!node
|
|
61
|
+
if (!node) {
|
|
59
62
|
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
63
|
+
}
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
if (typeof children === 'function') {
|
|
66
|
+
// @ts-ignore - React Ref typing is too strict for this use case
|
|
67
|
+
targetRef.current = node;
|
|
68
|
+
} else {
|
|
69
|
+
// @ts-ignore - React Ref typing is too strict for this use case
|
|
70
|
+
containerRef.current = node; // @ts-ignore - React Ref typing is too strict for this use case
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
targetRef.current = node.firstChild;
|
|
73
|
+
}
|
|
74
|
+
}, [children]); // Putting a few things into refs so that we don't have to break memoization
|
|
67
75
|
|
|
68
76
|
const lastState = useRef(state);
|
|
69
77
|
const lastDelay = useRef(delay);
|
|
@@ -218,7 +226,7 @@ function Tooltip({
|
|
|
218
226
|
|
|
219
227
|
const onMouseOver = useCallback(event => {
|
|
220
228
|
// Ignoring events from the container ref
|
|
221
|
-
if (event.target === containerRef.current) {
|
|
229
|
+
if (containerRef.current && event.target === containerRef.current) {
|
|
222
230
|
return;
|
|
223
231
|
} // Using prevent default as a signal that parent tooltips
|
|
224
232
|
|
|
@@ -247,7 +255,7 @@ function Tooltip({
|
|
|
247
255
|
|
|
248
256
|
const onMouseOut = useCallback(event => {
|
|
249
257
|
// Ignoring events from the container ref
|
|
250
|
-
if (event.target === containerRef.current) {
|
|
258
|
+
if (containerRef.current && event.target === containerRef.current) {
|
|
251
259
|
return;
|
|
252
260
|
} // Using prevent default as a signal that parent tooltips
|
|
253
261
|
|
|
@@ -306,17 +314,21 @@ function Tooltip({
|
|
|
306
314
|
return targetRef.current || undefined;
|
|
307
315
|
};
|
|
308
316
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
317
|
+
const tooltipId = useUniqueId('tooltip', shouldRenderTooltipContainer);
|
|
318
|
+
const tooltipTriggerProps = {
|
|
319
|
+
onMouseOver,
|
|
320
|
+
onMouseOut,
|
|
321
|
+
onClick,
|
|
322
|
+
onMouseDown,
|
|
323
|
+
onFocus,
|
|
324
|
+
onBlur,
|
|
316
325
|
ref: setRef,
|
|
317
|
-
|
|
326
|
+
'aria-describedby': tooltipId,
|
|
327
|
+
'data-testid': testId ? `${testId}--container` : undefined
|
|
328
|
+
};
|
|
329
|
+
return jsx(React.Fragment, null, typeof children === 'function' ? children(tooltipTriggerProps) : jsx(CastTargetContainer, _extends({}, tooltipTriggerProps, {
|
|
318
330
|
role: "presentation"
|
|
319
|
-
}, children), shouldRenderTooltipContainer ? jsx(Portal, {
|
|
331
|
+
}), children), shouldRenderTooltipContainer ? jsx(Portal, {
|
|
320
332
|
zIndex: tooltipZIndex
|
|
321
333
|
}, jsx(Popper, {
|
|
322
334
|
placement: tooltipPosition,
|
|
@@ -342,7 +354,8 @@ function Tooltip({
|
|
|
342
354
|
placement: tooltipPosition,
|
|
343
355
|
testId: testId,
|
|
344
356
|
onMouseOut: onMouseOut,
|
|
345
|
-
onMouseOver: onMouseOverTooltip
|
|
357
|
+
onMouseOver: onMouseOverTooltip,
|
|
358
|
+
id: tooltipId
|
|
346
359
|
}, typeof content === 'function' ? content({
|
|
347
360
|
update
|
|
348
361
|
}) : content))))) : null);
|
|
@@ -4,6 +4,7 @@ import { css, jsx } from '@emotion/core';
|
|
|
4
4
|
import { DN0, DN600, N0, N800 } from '@atlaskit/theme/colors';
|
|
5
5
|
import GlobalTheme from '@atlaskit/theme/components';
|
|
6
6
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
7
|
+
import { token } from '@atlaskit/tokens';
|
|
7
8
|
import TooltipPrimitive from './TooltipPrimitive';
|
|
8
9
|
const baseCss = css`
|
|
9
10
|
border-radius: ${borderRadius()}px;
|
|
@@ -31,7 +32,8 @@ const TooltipContainer = /*#__PURE__*/forwardRef(function TooltipContainer({
|
|
|
31
32
|
placement,
|
|
32
33
|
testId,
|
|
33
34
|
onMouseOut,
|
|
34
|
-
onMouseOver
|
|
35
|
+
onMouseOver,
|
|
36
|
+
id
|
|
35
37
|
}, ref) {
|
|
36
38
|
return jsx(GlobalTheme.Consumer, null, ({
|
|
37
39
|
mode
|
|
@@ -42,11 +44,12 @@ const TooltipContainer = /*#__PURE__*/forwardRef(function TooltipContainer({
|
|
|
42
44
|
className: className,
|
|
43
45
|
placement: placement,
|
|
44
46
|
testId: testId,
|
|
47
|
+
id: id,
|
|
45
48
|
onMouseOut: onMouseOut,
|
|
46
49
|
onMouseOver: onMouseOver,
|
|
47
50
|
css: [baseCss, truncate ? truncateCss : null, css`
|
|
48
|
-
background-color: ${mode === 'light' ? N800 : DN0};
|
|
49
|
-
color: ${mode === 'light' ? N0 : DN600};
|
|
51
|
+
background-color: ${mode === 'light' ? token('color.background.boldNeutral.resting', N800) : token('color.background.boldNeutral.resting', DN0)};
|
|
52
|
+
color: ${mode === 'light' ? token('color.text.onBold', N0) : token('color.text.onBold', DN600)};
|
|
50
53
|
`]
|
|
51
54
|
}, children));
|
|
52
55
|
});
|
|
@@ -13,7 +13,8 @@ const TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive({
|
|
|
13
13
|
placement,
|
|
14
14
|
testId,
|
|
15
15
|
onMouseOut,
|
|
16
|
-
onMouseOver
|
|
16
|
+
onMouseOver,
|
|
17
|
+
id
|
|
17
18
|
}, ref) {
|
|
18
19
|
return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
19
20
|
jsx("div", {
|
|
@@ -25,7 +26,8 @@ const TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive({
|
|
|
25
26
|
onMouseOver: onMouseOver,
|
|
26
27
|
css: primitiveCss,
|
|
27
28
|
"data-placement": placement,
|
|
28
|
-
"data-testid": testId
|
|
29
|
+
"data-testid": testId,
|
|
30
|
+
id: id
|
|
29
31
|
}, children)
|
|
30
32
|
);
|
|
31
33
|
});
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/Tooltip.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
4
|
|
|
@@ -16,13 +17,14 @@ import { Popper } from '@atlaskit/popper';
|
|
|
16
17
|
import Portal from '@atlaskit/portal';
|
|
17
18
|
import { layers } from '@atlaskit/theme/constants';
|
|
18
19
|
import { show } from './internal/tooltip-manager';
|
|
20
|
+
import useUniqueId from './internal/use-unique-id';
|
|
19
21
|
import TooltipContainer from './TooltipContainer';
|
|
20
22
|
import { getMousePosition } from './utilities';
|
|
21
23
|
var tooltipZIndex = layers.tooltip();
|
|
22
24
|
var analyticsAttributes = {
|
|
23
25
|
componentName: 'tooltip',
|
|
24
26
|
packageName: "@atlaskit/tooltip",
|
|
25
|
-
packageVersion: "17.
|
|
27
|
+
packageVersion: "17.5.1"
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
function noop() {}
|
|
@@ -75,15 +77,20 @@ function Tooltip(_ref) {
|
|
|
75
77
|
var targetRef = useRef(null);
|
|
76
78
|
var containerRef = useRef(null);
|
|
77
79
|
var setRef = useCallback(function (node) {
|
|
78
|
-
if (!node
|
|
80
|
+
if (!node) {
|
|
79
81
|
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
+
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
if (typeof children === 'function') {
|
|
85
|
+
// @ts-ignore - React Ref typing is too strict for this use case
|
|
86
|
+
targetRef.current = node;
|
|
87
|
+
} else {
|
|
88
|
+
// @ts-ignore - React Ref typing is too strict for this use case
|
|
89
|
+
containerRef.current = node; // @ts-ignore - React Ref typing is too strict for this use case
|
|
84
90
|
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
targetRef.current = node.firstChild;
|
|
92
|
+
}
|
|
93
|
+
}, [children]); // Putting a few things into refs so that we don't have to break memoization
|
|
87
94
|
|
|
88
95
|
var lastState = useRef(state);
|
|
89
96
|
var lastDelay = useRef(delay);
|
|
@@ -237,7 +244,7 @@ function Tooltip(_ref) {
|
|
|
237
244
|
|
|
238
245
|
var onMouseOver = useCallback(function (event) {
|
|
239
246
|
// Ignoring events from the container ref
|
|
240
|
-
if (event.target === containerRef.current) {
|
|
247
|
+
if (containerRef.current && event.target === containerRef.current) {
|
|
241
248
|
return;
|
|
242
249
|
} // Using prevent default as a signal that parent tooltips
|
|
243
250
|
|
|
@@ -266,7 +273,7 @@ function Tooltip(_ref) {
|
|
|
266
273
|
|
|
267
274
|
var onMouseOut = useCallback(function (event) {
|
|
268
275
|
// Ignoring events from the container ref
|
|
269
|
-
if (event.target === containerRef.current) {
|
|
276
|
+
if (containerRef.current && event.target === containerRef.current) {
|
|
270
277
|
return;
|
|
271
278
|
} // Using prevent default as a signal that parent tooltips
|
|
272
279
|
|
|
@@ -325,7 +332,8 @@ function Tooltip(_ref) {
|
|
|
325
332
|
return targetRef.current || undefined;
|
|
326
333
|
};
|
|
327
334
|
|
|
328
|
-
|
|
335
|
+
var tooltipId = useUniqueId('tooltip', shouldRenderTooltipContainer);
|
|
336
|
+
var tooltipTriggerProps = {
|
|
329
337
|
onMouseOver: onMouseOver,
|
|
330
338
|
onMouseOut: onMouseOut,
|
|
331
339
|
onClick: onClick,
|
|
@@ -333,9 +341,12 @@ function Tooltip(_ref) {
|
|
|
333
341
|
onFocus: onFocus,
|
|
334
342
|
onBlur: onBlur,
|
|
335
343
|
ref: setRef,
|
|
336
|
-
|
|
344
|
+
'aria-describedby': tooltipId,
|
|
345
|
+
'data-testid': testId ? "".concat(testId, "--container") : undefined
|
|
346
|
+
};
|
|
347
|
+
return jsx(React.Fragment, null, typeof children === 'function' ? children(tooltipTriggerProps) : jsx(CastTargetContainer, _extends({}, tooltipTriggerProps, {
|
|
337
348
|
role: "presentation"
|
|
338
|
-
}, children), shouldRenderTooltipContainer ? jsx(Portal, {
|
|
349
|
+
}), children), shouldRenderTooltipContainer ? jsx(Portal, {
|
|
339
350
|
zIndex: tooltipZIndex
|
|
340
351
|
}, jsx(Popper, {
|
|
341
352
|
placement: tooltipPosition,
|
|
@@ -361,7 +372,8 @@ function Tooltip(_ref) {
|
|
|
361
372
|
placement: tooltipPosition,
|
|
362
373
|
testId: testId,
|
|
363
374
|
onMouseOut: onMouseOut,
|
|
364
|
-
onMouseOver: onMouseOverTooltip
|
|
375
|
+
onMouseOver: onMouseOverTooltip,
|
|
376
|
+
id: tooltipId
|
|
365
377
|
}, typeof content === 'function' ? content({
|
|
366
378
|
update: update
|
|
367
379
|
}) : content)
|
|
@@ -8,6 +8,7 @@ import { css, jsx } from '@emotion/core';
|
|
|
8
8
|
import { DN0, DN600, N0, N800 } from '@atlaskit/theme/colors';
|
|
9
9
|
import GlobalTheme from '@atlaskit/theme/components';
|
|
10
10
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
11
|
+
import { token } from '@atlaskit/tokens';
|
|
11
12
|
import TooltipPrimitive from './TooltipPrimitive';
|
|
12
13
|
var baseCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-radius: ", "px;\n box-sizing: border-box;\n font-size: 12px;\n left: 0;\n line-height: 1.3;\n max-width: 240px;\n padding: 2px 6px;\n top: 0;\n word-wrap: break-word;\n overflow-wrap: break-word;\n"])), borderRadius());
|
|
13
14
|
var truncateCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n max-width: 420px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
@@ -19,7 +20,8 @@ var TooltipContainer = /*#__PURE__*/forwardRef(function TooltipContainer(_ref, r
|
|
|
19
20
|
placement = _ref.placement,
|
|
20
21
|
testId = _ref.testId,
|
|
21
22
|
onMouseOut = _ref.onMouseOut,
|
|
22
|
-
onMouseOver = _ref.onMouseOver
|
|
23
|
+
onMouseOver = _ref.onMouseOver,
|
|
24
|
+
id = _ref.id;
|
|
23
25
|
return jsx(GlobalTheme.Consumer, null, function (_ref2) {
|
|
24
26
|
var mode = _ref2.mode;
|
|
25
27
|
return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
@@ -29,9 +31,10 @@ var TooltipContainer = /*#__PURE__*/forwardRef(function TooltipContainer(_ref, r
|
|
|
29
31
|
className: className,
|
|
30
32
|
placement: placement,
|
|
31
33
|
testId: testId,
|
|
34
|
+
id: id,
|
|
32
35
|
onMouseOut: onMouseOut,
|
|
33
36
|
onMouseOver: onMouseOver,
|
|
34
|
-
css: [baseCss, truncate ? truncateCss : null, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background-color: ", ";\n color: ", ";\n "])), mode === 'light' ? N800 : DN0, mode === 'light' ? N0 : DN600)]
|
|
37
|
+
css: [baseCss, truncate ? truncateCss : null, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background-color: ", ";\n color: ", ";\n "])), mode === 'light' ? token('color.background.boldNeutral.resting', N800) : token('color.background.boldNeutral.resting', DN0), mode === 'light' ? token('color.text.onBold', N0) : token('color.text.onBold', DN600))]
|
|
35
38
|
}, children)
|
|
36
39
|
);
|
|
37
40
|
});
|
|
@@ -14,7 +14,8 @@ var TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive(_ref, r
|
|
|
14
14
|
placement = _ref.placement,
|
|
15
15
|
testId = _ref.testId,
|
|
16
16
|
onMouseOut = _ref.onMouseOut,
|
|
17
|
-
onMouseOver = _ref.onMouseOver
|
|
17
|
+
onMouseOver = _ref.onMouseOver,
|
|
18
|
+
id = _ref.id;
|
|
18
19
|
return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
19
20
|
jsx("div", {
|
|
20
21
|
role: "tooltip",
|
|
@@ -25,7 +26,8 @@ var TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive(_ref, r
|
|
|
25
26
|
onMouseOver: onMouseOver,
|
|
26
27
|
css: primitiveCss,
|
|
27
28
|
"data-placement": placement,
|
|
28
|
-
"data-testid": testId
|
|
29
|
+
"data-testid": testId,
|
|
30
|
+
id: id
|
|
29
31
|
}, children)
|
|
30
32
|
);
|
|
31
33
|
});
|
package/dist/esm/version.json
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { TooltipPrimitiveProps } from './TooltipPrimitive';
|
|
3
3
|
export interface TooltipContainerProps extends TooltipPrimitiveProps {
|
|
4
4
|
}
|
|
5
|
-
declare const TooltipContainer: import("react").ForwardRefExoticComponent<Pick<TooltipContainerProps, "style" | "className" | "children" | "placement" | "testId" | "onMouseOut" | "onMouseOver" | "truncate"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
5
|
+
declare const TooltipContainer: import("react").ForwardRefExoticComponent<Pick<TooltipContainerProps, "style" | "className" | "children" | "placement" | "testId" | "onMouseOut" | "onMouseOver" | "id" | "truncate"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
6
|
export default TooltipContainer;
|
|
@@ -11,6 +11,7 @@ export interface TooltipPrimitiveProps {
|
|
|
11
11
|
ref: React.Ref<any>;
|
|
12
12
|
onMouseOver?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
13
13
|
onMouseOut?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
14
|
+
id?: string;
|
|
14
15
|
}
|
|
15
|
-
declare const TooltipPrimitive: import("react").ForwardRefExoticComponent<Pick<TooltipPrimitiveProps, "style" | "className" | "children" | "placement" | "testId" | "onMouseOut" | "onMouseOver" | "truncate"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
|
+
declare const TooltipPrimitive: import("react").ForwardRefExoticComponent<Pick<TooltipPrimitiveProps, "style" | "className" | "children" | "placement" | "testId" | "onMouseOut" | "onMouseOver" | "id" | "truncate"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
17
|
export default TooltipPrimitive;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useUniqueId(prefix: string, shouldRenderId: boolean): string | undefined;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -4,12 +4,21 @@ import { Placement } from '@atlaskit/popper';
|
|
|
4
4
|
import { TooltipPrimitiveProps } from './TooltipPrimitive';
|
|
5
5
|
export declare type PositionTypeBase = Placement;
|
|
6
6
|
export declare type PositionType = PositionTypeBase | 'mouse';
|
|
7
|
+
export interface TriggerProps {
|
|
8
|
+
onMouseOver: (event: React.MouseEvent<HTMLElement>) => void;
|
|
9
|
+
onMouseOut: (event: React.MouseEvent<HTMLElement>) => void;
|
|
10
|
+
onMouseDown: (event: React.MouseEvent<HTMLElement>) => void;
|
|
11
|
+
onClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
12
|
+
onFocus: (event: React.FocusEvent<HTMLElement>) => void;
|
|
13
|
+
onBlur: (event: React.FocusEvent<HTMLElement>) => void;
|
|
14
|
+
ref: (node: HTMLElement | null) => void;
|
|
15
|
+
}
|
|
7
16
|
export interface TooltipProps {
|
|
8
17
|
/**
|
|
9
18
|
* The content of the tooltip. It can be either a:
|
|
10
19
|
* 1. `ReactNode`
|
|
11
20
|
* 2. Function which returns a `ReactNode`
|
|
12
|
-
|
|
21
|
+
|
|
13
22
|
* The benefit of the second approach is that it allows you to consume the `update` render prop.
|
|
14
23
|
* This `update` function can be called to manually recalculate the position of the tooltip.
|
|
15
24
|
*/
|
|
@@ -71,9 +80,12 @@ export interface TooltipProps {
|
|
|
71
80
|
*/
|
|
72
81
|
truncate?: boolean;
|
|
73
82
|
/**
|
|
74
|
-
* Elements to be wrapped by the tooltip
|
|
83
|
+
* Elements to be wrapped by the tooltip.
|
|
84
|
+
* It can be either a:
|
|
85
|
+
* 1. `ReactNode`
|
|
86
|
+
* 2. Function which returns a `ReactNode`
|
|
75
87
|
*/
|
|
76
|
-
children: ReactNode;
|
|
88
|
+
children: ReactNode | ((props: TriggerProps) => ReactNode);
|
|
77
89
|
/**
|
|
78
90
|
* A `testId` prop is provided for specified elements, which is a unique
|
|
79
91
|
* string that appears as a data attribute `data-testid` in the rendered code,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/tooltip",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.5.1",
|
|
4
4
|
"description": "A tooltip is a floating, non-actionable label used to explain a user interface element or feature.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,14 +25,16 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
28
|
-
"@atlaskit/ds-lib": "^1.
|
|
28
|
+
"@atlaskit/ds-lib": "^1.3.0",
|
|
29
29
|
"@atlaskit/motion": "^1.0.0",
|
|
30
30
|
"@atlaskit/popper": "^5.0.0",
|
|
31
31
|
"@atlaskit/portal": "^4.1.0",
|
|
32
|
-
"@atlaskit/theme": "^
|
|
32
|
+
"@atlaskit/theme": "^12.0.0",
|
|
33
|
+
"@atlaskit/tokens": "^0.3.0",
|
|
33
34
|
"@babel/runtime": "^7.0.0",
|
|
34
35
|
"@emotion/core": "^10.0.9",
|
|
35
|
-
"bind-event-listener": "^1.0.2"
|
|
36
|
+
"bind-event-listener": "^1.0.2",
|
|
37
|
+
"react-uid": "^2.2.0"
|
|
36
38
|
},
|
|
37
39
|
"peerDependencies": {
|
|
38
40
|
"react": "^16.8.0",
|
|
@@ -40,9 +42,10 @@
|
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@atlaskit/build-utils": "*",
|
|
43
|
-
"@atlaskit/button": "^
|
|
45
|
+
"@atlaskit/button": "^16.1.0",
|
|
44
46
|
"@atlaskit/docs": "*",
|
|
45
|
-
"@atlaskit/icon": "^21.
|
|
47
|
+
"@atlaskit/icon": "^21.9.0",
|
|
48
|
+
"@atlaskit/section-message": "^6.1.0",
|
|
46
49
|
"@atlaskit/ssr": "*",
|
|
47
50
|
"@atlaskit/visual-regression": "*",
|
|
48
51
|
"@atlaskit/webdriver-runner": "*",
|
|
@@ -67,18 +70,10 @@
|
|
|
67
70
|
"import-structure": "atlassian-conventions"
|
|
68
71
|
},
|
|
69
72
|
"@repo/internal": {
|
|
70
|
-
"ui-components":
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
"analytics-next"
|
|
75
|
-
],
|
|
76
|
-
"theming": [
|
|
77
|
-
"new-theming-api"
|
|
78
|
-
],
|
|
79
|
-
"deprecation": [
|
|
80
|
-
"no-deprecated-imports"
|
|
81
|
-
]
|
|
73
|
+
"ui-components": "lite-mode",
|
|
74
|
+
"analytics": "analytics-next",
|
|
75
|
+
"theming": "tokens",
|
|
76
|
+
"deprecation": "no-deprecated-imports"
|
|
82
77
|
}
|
|
83
78
|
},
|
|
84
79
|
"homepage": "https://atlassian.design/components/tooltip/",
|