@atlaskit/tooltip 17.5.13 → 17.5.16

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/tooltip
2
2
 
3
+ ## 17.5.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
8
+
9
+ ## 17.5.15
10
+
11
+ ### Patch Changes
12
+
13
+ - [`338ba1a1500`](https://bitbucket.org/atlassian/atlassian-frontend/commits/338ba1a1500) - [ux] Improves accuracy of Tooltip placement relative to the mouse when using `position="mouse"`
14
+
15
+ ## 17.5.14
16
+
17
+ ### Patch Changes
18
+
19
+ - [`13a202fde6b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/13a202fde6b) - Fixes a bug where undefined test IDs were being added to Tooltip wrappers when no test ID was set
20
+ - Updated dependencies
21
+
3
22
  ## 17.5.13
4
23
 
5
24
  ### Patch Changes
@@ -23,6 +23,8 @@ var _bindEventListener = require("bind-event-listener");
23
23
 
24
24
  var _analyticsNext = require("@atlaskit/analytics-next");
25
25
 
26
+ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
27
+
26
28
  var _useCloseOnEscapePress = _interopRequireDefault(require("@atlaskit/ds-lib/use-close-on-escape-press"));
27
29
 
28
30
  var _motion = require("@atlaskit/motion");
@@ -56,11 +58,8 @@ var tooltipZIndex = _constants.layers.tooltip();
56
58
  var analyticsAttributes = {
57
59
  componentName: 'tooltip',
58
60
  packageName: "@atlaskit/tooltip",
59
- packageVersion: "17.5.13"
60
- };
61
-
62
- function noop() {} // Inverts motion direction
63
-
61
+ packageVersion: "17.5.16"
62
+ }; // Inverts motion direction
64
63
 
65
64
  var invertedDirection = {
66
65
  top: 'bottom',
@@ -96,9 +95,9 @@ function Tooltip(_ref) {
96
95
  _ref$delay = _ref.delay,
97
96
  delay = _ref$delay === void 0 ? 300 : _ref$delay,
98
97
  _ref$onShow = _ref.onShow,
99
- onShow = _ref$onShow === void 0 ? noop : _ref$onShow,
98
+ onShow = _ref$onShow === void 0 ? _noop.default : _ref$onShow,
100
99
  _ref$onHide = _ref.onHide,
101
- onHide = _ref$onHide === void 0 ? noop : _ref$onHide,
100
+ onHide = _ref$onHide === void 0 ? _noop.default : _ref$onHide,
102
101
  _ref$hideTooltipOnCli = _ref.hideTooltipOnClick,
103
102
  hideTooltipOnClick = _ref$hideTooltipOnCli === void 0 ? false : _ref$hideTooltipOnCli,
104
103
  _ref$hideTooltipOnMou = _ref.hideTooltipOnMouseDown,
@@ -252,7 +251,7 @@ function Tooltip(_ref) {
252
251
  });
253
252
  (0, _react.useEffect)(function () {
254
253
  if (state === 'hide') {
255
- return noop;
254
+ return _noop.default;
256
255
  }
257
256
 
258
257
  if (state === 'before-fade-out') {
@@ -343,6 +342,16 @@ function Tooltip(_ref) {
343
342
  });
344
343
  }
345
344
  }, []);
345
+ var onMouseMove = position === 'mouse' ? function (event) {
346
+ var _apiRef$current2;
347
+
348
+ if ((_apiRef$current2 = apiRef.current) !== null && _apiRef$current2 !== void 0 && _apiRef$current2.isActive()) {
349
+ apiRef.current.mousePosition = (0, _utilities.getMousePosition)({
350
+ left: event.clientX,
351
+ top: event.clientY
352
+ });
353
+ }
354
+ } : undefined;
346
355
  var onMouseOverTooltip = (0, _react.useCallback)(function () {
347
356
  if (apiRef.current && apiRef.current.isActive()) {
348
357
  apiRef.current.keep();
@@ -374,12 +383,12 @@ function Tooltip(_ref) {
374
383
  var shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
375
384
 
376
385
  var getReferenceElement = function getReferenceElement() {
377
- // Use the initial mouse position if appropriate, or the target element
378
- var api = apiRef.current;
379
- var initialMouse = api ? api.getInitialMouse() : null;
386
+ var _apiRef$current3;
387
+
388
+ if (position === 'mouse' && (_apiRef$current3 = apiRef.current) !== null && _apiRef$current3 !== void 0 && _apiRef$current3.mousePosition) {
389
+ var _apiRef$current4;
380
390
 
381
- if (position === 'mouse' && initialMouse) {
382
- return initialMouse;
391
+ return (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 ? void 0 : _apiRef$current4.mousePosition;
383
392
  }
384
393
 
385
394
  return targetRef.current || undefined;
@@ -389,6 +398,7 @@ function Tooltip(_ref) {
389
398
  var tooltipTriggerProps = {
390
399
  onMouseOver: onMouseOver,
391
400
  onMouseOut: onMouseOut,
401
+ onMouseMove: onMouseMove,
392
402
  onClick: onClick,
393
403
  onMouseDown: onMouseDown,
394
404
  onFocus: onFocus,
@@ -39,7 +39,7 @@ var TooltipPrimitive = /*#__PURE__*/(0, _react.forwardRef)(function TooltipPrimi
39
39
  return (0, _core.jsx)("div", {
40
40
  ref: ref,
41
41
  style: styleWithZIndex,
42
- "data-testid": "".concat(testId, "--wrapper")
42
+ "data-testid": testId ? "".concat(testId, "--wrapper") : undefined
43
43
  }, (0, _core.jsx)("div", {
44
44
  role: "tooltip",
45
45
  className: className,
@@ -157,7 +157,7 @@ function show(entry) {
157
157
  isActive: isActive,
158
158
  requestHide: requestHide,
159
159
  finishHideAnimation: finishHideAnimation,
160
- getInitialMouse: getInitialMouse
160
+ mousePosition: getInitialMouse()
161
161
  };
162
162
  return result;
163
163
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.5.13",
3
+ "version": "17.5.16",
4
4
  "sideEffects": false
5
5
  }
@@ -5,6 +5,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
5
5
  import { jsx } from '@emotion/core';
6
6
  import { bind } from 'bind-event-listener';
7
7
  import { usePlatformLeafSyntheticEventHandler } from '@atlaskit/analytics-next';
8
+ import noop from '@atlaskit/ds-lib/noop';
8
9
  import useCloseOnEscapePress from '@atlaskit/ds-lib/use-close-on-escape-press';
9
10
  import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
10
11
  import { mediumDurationMs } from '@atlaskit/motion/durations';
@@ -19,11 +20,8 @@ const tooltipZIndex = layers.tooltip();
19
20
  const analyticsAttributes = {
20
21
  componentName: 'tooltip',
21
22
  packageName: "@atlaskit/tooltip",
22
- packageVersion: "17.5.13"
23
- };
24
-
25
- function noop() {} // Inverts motion direction
26
-
23
+ packageVersion: "17.5.16"
24
+ }; // Inverts motion direction
27
25
 
28
26
  const invertedDirection = {
29
27
  top: 'bottom',
@@ -291,6 +289,16 @@ function Tooltip({
291
289
  });
292
290
  }
293
291
  }, []);
292
+ const onMouseMove = position === 'mouse' ? event => {
293
+ var _apiRef$current2;
294
+
295
+ if ((_apiRef$current2 = apiRef.current) !== null && _apiRef$current2 !== void 0 && _apiRef$current2.isActive()) {
296
+ apiRef.current.mousePosition = getMousePosition({
297
+ left: event.clientX,
298
+ top: event.clientY
299
+ });
300
+ }
301
+ } : undefined;
294
302
  const onMouseOverTooltip = useCallback(() => {
295
303
  if (apiRef.current && apiRef.current.isActive()) {
296
304
  apiRef.current.keep();
@@ -322,12 +330,12 @@ function Tooltip({
322
330
  const shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
323
331
 
324
332
  const getReferenceElement = () => {
325
- // Use the initial mouse position if appropriate, or the target element
326
- const api = apiRef.current;
327
- const initialMouse = api ? api.getInitialMouse() : null;
333
+ var _apiRef$current3;
334
+
335
+ if (position === 'mouse' && (_apiRef$current3 = apiRef.current) !== null && _apiRef$current3 !== void 0 && _apiRef$current3.mousePosition) {
336
+ var _apiRef$current4;
328
337
 
329
- if (position === 'mouse' && initialMouse) {
330
- return initialMouse;
338
+ return (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 ? void 0 : _apiRef$current4.mousePosition;
331
339
  }
332
340
 
333
341
  return targetRef.current || undefined;
@@ -337,6 +345,7 @@ function Tooltip({
337
345
  const tooltipTriggerProps = {
338
346
  onMouseOver,
339
347
  onMouseOut,
348
+ onMouseMove,
340
349
  onClick,
341
350
  onMouseDown,
342
351
  onFocus,
@@ -23,7 +23,7 @@ const TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive({
23
23
  return jsx("div", {
24
24
  ref: ref,
25
25
  style: styleWithZIndex,
26
- "data-testid": `${testId}--wrapper`
26
+ "data-testid": testId ? `${testId}--wrapper` : undefined
27
27
  }, jsx("div", {
28
28
  role: "tooltip",
29
29
  className: className,
@@ -149,7 +149,7 @@ export function show(entry) {
149
149
  isActive,
150
150
  requestHide,
151
151
  finishHideAnimation,
152
- getInitialMouse
152
+ mousePosition: getInitialMouse()
153
153
  };
154
154
  return result;
155
155
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.5.13",
3
+ "version": "17.5.16",
4
4
  "sideEffects": false
5
5
  }
@@ -11,6 +11,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
11
11
  import { jsx } from '@emotion/core';
12
12
  import { bind } from 'bind-event-listener';
13
13
  import { usePlatformLeafSyntheticEventHandler } from '@atlaskit/analytics-next';
14
+ import noop from '@atlaskit/ds-lib/noop';
14
15
  import useCloseOnEscapePress from '@atlaskit/ds-lib/use-close-on-escape-press';
15
16
  import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
16
17
  import { mediumDurationMs } from '@atlaskit/motion/durations';
@@ -25,11 +26,8 @@ var tooltipZIndex = layers.tooltip();
25
26
  var analyticsAttributes = {
26
27
  componentName: 'tooltip',
27
28
  packageName: "@atlaskit/tooltip",
28
- packageVersion: "17.5.13"
29
- };
30
-
31
- function noop() {} // Inverts motion direction
32
-
29
+ packageVersion: "17.5.16"
30
+ }; // Inverts motion direction
33
31
 
34
32
  var invertedDirection = {
35
33
  top: 'bottom',
@@ -312,6 +310,16 @@ function Tooltip(_ref) {
312
310
  });
313
311
  }
314
312
  }, []);
313
+ var onMouseMove = position === 'mouse' ? function (event) {
314
+ var _apiRef$current2;
315
+
316
+ if ((_apiRef$current2 = apiRef.current) !== null && _apiRef$current2 !== void 0 && _apiRef$current2.isActive()) {
317
+ apiRef.current.mousePosition = getMousePosition({
318
+ left: event.clientX,
319
+ top: event.clientY
320
+ });
321
+ }
322
+ } : undefined;
315
323
  var onMouseOverTooltip = useCallback(function () {
316
324
  if (apiRef.current && apiRef.current.isActive()) {
317
325
  apiRef.current.keep();
@@ -343,12 +351,12 @@ function Tooltip(_ref) {
343
351
  var shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
344
352
 
345
353
  var getReferenceElement = function getReferenceElement() {
346
- // Use the initial mouse position if appropriate, or the target element
347
- var api = apiRef.current;
348
- var initialMouse = api ? api.getInitialMouse() : null;
354
+ var _apiRef$current3;
355
+
356
+ if (position === 'mouse' && (_apiRef$current3 = apiRef.current) !== null && _apiRef$current3 !== void 0 && _apiRef$current3.mousePosition) {
357
+ var _apiRef$current4;
349
358
 
350
- if (position === 'mouse' && initialMouse) {
351
- return initialMouse;
359
+ return (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 ? void 0 : _apiRef$current4.mousePosition;
352
360
  }
353
361
 
354
362
  return targetRef.current || undefined;
@@ -358,6 +366,7 @@ function Tooltip(_ref) {
358
366
  var tooltipTriggerProps = {
359
367
  onMouseOver: onMouseOver,
360
368
  onMouseOut: onMouseOut,
369
+ onMouseMove: onMouseMove,
361
370
  onClick: onClick,
362
371
  onMouseDown: onMouseDown,
363
372
  onFocus: onFocus,
@@ -28,7 +28,7 @@ var TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive(_ref, r
28
28
  return jsx("div", {
29
29
  ref: ref,
30
30
  style: styleWithZIndex,
31
- "data-testid": "".concat(testId, "--wrapper")
31
+ "data-testid": testId ? "".concat(testId, "--wrapper") : undefined
32
32
  }, jsx("div", {
33
33
  role: "tooltip",
34
34
  className: className,
@@ -149,7 +149,7 @@ export function show(entry) {
149
149
  isActive: isActive,
150
150
  requestHide: requestHide,
151
151
  finishHideAnimation: finishHideAnimation,
152
- getInitialMouse: getInitialMouse
152
+ mousePosition: getInitialMouse()
153
153
  };
154
154
  return result;
155
155
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.5.13",
3
+ "version": "17.5.16",
4
4
  "sideEffects": false
5
5
  }
@@ -18,7 +18,7 @@ export declare type Entry = {
18
18
  };
19
19
  export declare type API = {
20
20
  isActive: () => boolean;
21
- getInitialMouse: () => FakeMouseElement | null;
21
+ mousePosition: FakeMouseElement | null;
22
22
  requestHide: (value: {
23
23
  isImmediate: boolean;
24
24
  }) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.5.13",
3
+ "version": "17.5.16",
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/"
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/analytics-next": "^8.2.0",
35
- "@atlaskit/ds-lib": "^2.0.0",
35
+ "@atlaskit/ds-lib": "^2.1.0",
36
36
  "@atlaskit/motion": "^1.2.0",
37
37
  "@atlaskit/popper": "^5.0.0",
38
38
  "@atlaskit/portal": "^4.1.0",
@@ -63,7 +63,7 @@
63
63
  "react-dom": "^16.8.0",
64
64
  "react-redux": "^5.1.2",
65
65
  "storybook-addon-performance": "^0.16.0",
66
- "typescript": "4.2.4",
66
+ "typescript": "4.3.5",
67
67
  "wait-for-expect": "^1.2.0"
68
68
  },
69
69
  "keywords": [