@atlaskit/tooltip 17.5.11 → 17.5.14

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,29 @@
1
1
  # @atlaskit/tooltip
2
2
 
3
+ ## 17.5.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [`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
8
+ - Updated dependencies
9
+
10
+ ## 17.5.13
11
+
12
+ ### Patch Changes
13
+
14
+ - [`45ebe7af434`](https://bitbucket.org/atlassian/atlassian-frontend/commits/45ebe7af434) - Moved to using declarative entrypoints internally. Public API is unchanged.
15
+ - [`4efc76f8a72`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4efc76f8a72) - [ux] Fixes a bug where tooltip entrance and exit direction animations were not working since version 12.1.7, after upgrading `react-popper`.
16
+
17
+ This involved adding a wrapper `<div>` around the tooltip to separate the positioning and animation styles. The wrapper can be identified in tests using `testId` with the pattern `{testId}--wrapper`.
18
+
19
+ - Updated dependencies
20
+
21
+ ## 17.5.12
22
+
23
+ ### Patch Changes
24
+
25
+ - [`8a5bdb3c844`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8a5bdb3c844) - Upgrading internal dependency (bind-event-listener) for improved internal types
26
+
3
27
  ## 17.5.11
4
28
 
5
29
  ### Patch Changes
@@ -27,6 +27,8 @@ var _useCloseOnEscapePress = _interopRequireDefault(require("@atlaskit/ds-lib/us
27
27
 
28
28
  var _motion = require("@atlaskit/motion");
29
29
 
30
+ var _durations = require("@atlaskit/motion/durations");
31
+
30
32
  var _popper = require("@atlaskit/popper");
31
33
 
32
34
  var _portal = _interopRequireDefault(require("@atlaskit/portal"));
@@ -54,10 +56,28 @@ var tooltipZIndex = _constants.layers.tooltip();
54
56
  var analyticsAttributes = {
55
57
  componentName: 'tooltip',
56
58
  packageName: "@atlaskit/tooltip",
57
- packageVersion: "17.5.11"
59
+ packageVersion: "17.5.14"
58
60
  };
59
61
 
60
- function noop() {}
62
+ function noop() {} // Inverts motion direction
63
+
64
+
65
+ var invertedDirection = {
66
+ top: 'bottom',
67
+ bottom: 'top',
68
+ left: 'right',
69
+ right: 'left'
70
+ };
71
+ /**
72
+ * Converts a Popper placement to it's general direction.
73
+ *
74
+ * @param position - Popper Placement value, e.g. 'top-start'
75
+ * @returns Popper Direction, e.g. 'top'
76
+ */
77
+
78
+ var getDirectionFromPlacement = function getDirectionFromPlacement(placement) {
79
+ return placement.split('-')[0];
80
+ };
61
81
 
62
82
  function Tooltip(_ref) {
63
83
  var children = _ref.children,
@@ -203,17 +223,16 @@ function Tooltip(_ref) {
203
223
  lastHandlers.current.onShowHandler();
204
224
  }
205
225
 
206
- setState(isImmediate ? 'show-immediate' : 'show-fade-in');
226
+ setState(isImmediate ? 'show-immediate' : 'fade-in');
207
227
  },
208
228
  hide: function hide(_ref3) {
209
229
  var isImmediate = _ref3.isImmediate;
210
- setState(function (current) {
211
- if (current !== 'hide') {
212
- return isImmediate ? 'hide' : 'fade-out';
213
- }
214
230
 
215
- return current;
216
- });
231
+ if (isImmediate) {
232
+ setState('hide');
233
+ } else {
234
+ setState('before-fade-out');
235
+ }
217
236
  },
218
237
  done: done
219
238
  };
@@ -236,6 +255,10 @@ function Tooltip(_ref) {
236
255
  return noop;
237
256
  }
238
257
 
258
+ if (state === 'before-fade-out') {
259
+ setState('fade-out');
260
+ }
261
+
239
262
  var unbind = (0, _bindEventListener.bind)(window, {
240
263
  type: 'scroll',
241
264
  listener: function listener() {
@@ -348,9 +371,9 @@ function Tooltip(_ref) {
348
371
 
349
372
  var CastTargetContainer = TargetContainer;
350
373
  var shouldRenderTooltipContainer = state !== 'hide' && Boolean(content);
351
- var shouldRenderTooltipChildren = state === 'show-immediate' || state === 'show-fade-in';
374
+ var shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
352
375
 
353
- var getReferentElement = function getReferentElement() {
376
+ var getReferenceElement = function getReferenceElement() {
354
377
  // Use the initial mouse position if appropriate, or the target element
355
378
  var api = apiRef.current;
356
379
  var initialMouse = api ? api.getInitialMouse() : null;
@@ -380,17 +403,25 @@ function Tooltip(_ref) {
380
403
  zIndex: tooltipZIndex
381
404
  }, (0, _core.jsx)(_popper.Popper, {
382
405
  placement: tooltipPosition,
383
- referenceElement: getReferentElement(),
406
+ referenceElement: getReferenceElement(),
384
407
  strategy: strategy
385
408
  }, function (_ref4) {
386
409
  var ref = _ref4.ref,
387
410
  style = _ref4.style,
388
- update = _ref4.update;
411
+ update = _ref4.update,
412
+ placement = _ref4.placement;
413
+ // Invert the entrance and exit directions.
414
+ // E.g. a tooltip's position is on the 'right', it should enter from and exit to the 'left'
415
+ // This gives the effect the tooltip is appearing from the target
416
+ var direction = position === 'mouse' ? undefined : invertedDirection[getDirectionFromPlacement(placement)];
389
417
  return (0, _core.jsx)(_motion.ExitingPersistence, {
390
418
  appear: true
391
419
  }, shouldRenderTooltipChildren && (0, _core.jsx)(_motion.FadeIn, {
420
+ distance: "constant",
421
+ entranceDirection: direction,
422
+ exitDirection: direction,
392
423
  onFinish: onAnimationFinished,
393
- duration: state === 'show-immediate' ? 0 : undefined
424
+ duration: state === 'show-immediate' ? 0 : _durations.mediumDurationMs
394
425
  }, function (_ref5) {
395
426
  var className = _ref5.className;
396
427
  return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
@@ -36,20 +36,20 @@ var TooltipPrimitive = /*#__PURE__*/(0, _react.forwardRef)(function TooltipPrimi
36
36
 
37
37
  var styleWithZIndex = _objectSpread(_objectSpread({}, style), {}, (0, _defineProperty2.default)({}, VAR_PRIMITIVE_ZINDEX, _constants.layers.tooltip()));
38
38
 
39
- return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
40
- (0, _core.jsx)("div", {
41
- role: "tooltip",
42
- ref: ref,
43
- style: styleWithZIndex,
44
- className: className,
45
- onMouseOut: onMouseOut,
46
- onMouseOver: onMouseOver,
47
- css: primitiveStyles,
48
- "data-placement": placement,
49
- "data-testid": testId,
50
- id: id
51
- }, children)
52
- );
39
+ return (0, _core.jsx)("div", {
40
+ ref: ref,
41
+ style: styleWithZIndex,
42
+ "data-testid": testId ? "".concat(testId, "--wrapper") : undefined
43
+ }, (0, _core.jsx)("div", {
44
+ role: "tooltip",
45
+ className: className,
46
+ onMouseOut: onMouseOut,
47
+ onMouseOver: onMouseOver,
48
+ css: primitiveStyles,
49
+ "data-placement": placement,
50
+ "data-testid": testId,
51
+ id: id
52
+ }, children));
53
53
  });
54
54
  TooltipPrimitive.displayName = 'TooltipPrimitive';
55
55
  var _default = TooltipPrimitive;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.5.11",
3
+ "version": "17.5.14",
4
4
  "sideEffects": false
5
5
  }
@@ -7,6 +7,7 @@ import { bind } from 'bind-event-listener';
7
7
  import { usePlatformLeafSyntheticEventHandler } from '@atlaskit/analytics-next';
8
8
  import useCloseOnEscapePress from '@atlaskit/ds-lib/use-close-on-escape-press';
9
9
  import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
10
+ import { mediumDurationMs } from '@atlaskit/motion/durations';
10
11
  import { Popper } from '@atlaskit/popper';
11
12
  import Portal from '@atlaskit/portal';
12
13
  import { layers } from '@atlaskit/theme/constants';
@@ -18,10 +19,26 @@ const tooltipZIndex = layers.tooltip();
18
19
  const analyticsAttributes = {
19
20
  componentName: 'tooltip',
20
21
  packageName: "@atlaskit/tooltip",
21
- packageVersion: "17.5.11"
22
+ packageVersion: "17.5.14"
22
23
  };
23
24
 
24
- function noop() {}
25
+ function noop() {} // Inverts motion direction
26
+
27
+
28
+ const invertedDirection = {
29
+ top: 'bottom',
30
+ bottom: 'top',
31
+ left: 'right',
32
+ right: 'left'
33
+ };
34
+ /**
35
+ * Converts a Popper placement to it's general direction.
36
+ *
37
+ * @param position - Popper Placement value, e.g. 'top-start'
38
+ * @returns Popper Direction, e.g. 'top'
39
+ */
40
+
41
+ const getDirectionFromPlacement = placement => placement.split('-')[0];
25
42
 
26
43
  function Tooltip({
27
44
  children,
@@ -154,18 +171,16 @@ function Tooltip({
154
171
  lastHandlers.current.onShowHandler();
155
172
  }
156
173
 
157
- setState(isImmediate ? 'show-immediate' : 'show-fade-in');
174
+ setState(isImmediate ? 'show-immediate' : 'fade-in');
158
175
  },
159
176
  hide: ({
160
177
  isImmediate
161
178
  }) => {
162
- setState(current => {
163
- if (current !== 'hide') {
164
- return isImmediate ? 'hide' : 'fade-out';
165
- }
166
-
167
- return current;
168
- });
179
+ if (isImmediate) {
180
+ setState('hide');
181
+ } else {
182
+ setState('before-fade-out');
183
+ }
169
184
  },
170
185
  done: done
171
186
  };
@@ -188,6 +203,10 @@ function Tooltip({
188
203
  return noop;
189
204
  }
190
205
 
206
+ if (state === 'before-fade-out') {
207
+ setState('fade-out');
208
+ }
209
+
191
210
  const unbind = bind(window, {
192
211
  type: 'scroll',
193
212
  listener: () => {
@@ -300,9 +319,9 @@ function Tooltip({
300
319
 
301
320
  const CastTargetContainer = TargetContainer;
302
321
  const shouldRenderTooltipContainer = state !== 'hide' && Boolean(content);
303
- const shouldRenderTooltipChildren = state === 'show-immediate' || state === 'show-fade-in';
322
+ const shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
304
323
 
305
- const getReferentElement = () => {
324
+ const getReferenceElement = () => {
306
325
  // Use the initial mouse position if appropriate, or the target element
307
326
  const api = apiRef.current;
308
327
  const initialMouse = api ? api.getInitialMouse() : null;
@@ -332,33 +351,43 @@ function Tooltip({
332
351
  zIndex: tooltipZIndex
333
352
  }, jsx(Popper, {
334
353
  placement: tooltipPosition,
335
- referenceElement: getReferentElement(),
354
+ referenceElement: getReferenceElement(),
336
355
  strategy: strategy
337
356
  }, ({
338
357
  ref,
339
358
  style,
340
- update
341
- }) => jsx(ExitingPersistence, {
342
- appear: true
343
- }, shouldRenderTooltipChildren && jsx(FadeIn, {
344
- onFinish: onAnimationFinished,
345
- duration: state === 'show-immediate' ? 0 : undefined
346
- }, ({
347
- className
348
- }) => // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
349
- jsx(Container, {
350
- ref: ref,
351
- className: `Tooltip ${className}`,
352
- style: style,
353
- truncate: truncate,
354
- placement: tooltipPosition,
355
- testId: testId,
356
- onMouseOut: onMouseOut,
357
- onMouseOver: onMouseOverTooltip,
358
- id: tooltipId
359
- }, typeof content === 'function' ? content({
360
- update
361
- }) : content))))) : null);
359
+ update,
360
+ placement
361
+ }) => {
362
+ // Invert the entrance and exit directions.
363
+ // E.g. a tooltip's position is on the 'right', it should enter from and exit to the 'left'
364
+ // This gives the effect the tooltip is appearing from the target
365
+ const direction = position === 'mouse' ? undefined : invertedDirection[getDirectionFromPlacement(placement)];
366
+ return jsx(ExitingPersistence, {
367
+ appear: true
368
+ }, shouldRenderTooltipChildren && jsx(FadeIn, {
369
+ distance: "constant",
370
+ entranceDirection: direction,
371
+ exitDirection: direction,
372
+ onFinish: onAnimationFinished,
373
+ duration: state === 'show-immediate' ? 0 : mediumDurationMs
374
+ }, ({
375
+ className
376
+ }) => // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
377
+ jsx(Container, {
378
+ ref: ref,
379
+ className: `Tooltip ${className}`,
380
+ style: style,
381
+ truncate: truncate,
382
+ placement: tooltipPosition,
383
+ testId: testId,
384
+ onMouseOut: onMouseOut,
385
+ onMouseOver: onMouseOverTooltip,
386
+ id: tooltipId
387
+ }, typeof content === 'function' ? content({
388
+ update
389
+ }) : content)));
390
+ })) : null);
362
391
  }
363
392
 
364
393
  Tooltip.displayName = 'Tooltip';
@@ -20,20 +20,20 @@ const TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive({
20
20
  const styleWithZIndex = { ...style,
21
21
  [VAR_PRIMITIVE_ZINDEX]: layers.tooltip()
22
22
  };
23
- return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
24
- jsx("div", {
25
- role: "tooltip",
26
- ref: ref,
27
- style: styleWithZIndex,
28
- className: className,
29
- onMouseOut: onMouseOut,
30
- onMouseOver: onMouseOver,
31
- css: primitiveStyles,
32
- "data-placement": placement,
33
- "data-testid": testId,
34
- id: id
35
- }, children)
36
- );
23
+ return jsx("div", {
24
+ ref: ref,
25
+ style: styleWithZIndex,
26
+ "data-testid": testId ? `${testId}--wrapper` : undefined
27
+ }, jsx("div", {
28
+ role: "tooltip",
29
+ className: className,
30
+ onMouseOut: onMouseOut,
31
+ onMouseOver: onMouseOver,
32
+ css: primitiveStyles,
33
+ "data-placement": placement,
34
+ "data-testid": testId,
35
+ id: id
36
+ }, children));
37
37
  });
38
38
  TooltipPrimitive.displayName = 'TooltipPrimitive';
39
39
  export default TooltipPrimitive;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.5.11",
3
+ "version": "17.5.14",
4
4
  "sideEffects": false
5
5
  }
@@ -13,6 +13,7 @@ import { bind } from 'bind-event-listener';
13
13
  import { usePlatformLeafSyntheticEventHandler } from '@atlaskit/analytics-next';
14
14
  import useCloseOnEscapePress from '@atlaskit/ds-lib/use-close-on-escape-press';
15
15
  import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
16
+ import { mediumDurationMs } from '@atlaskit/motion/durations';
16
17
  import { Popper } from '@atlaskit/popper';
17
18
  import Portal from '@atlaskit/portal';
18
19
  import { layers } from '@atlaskit/theme/constants';
@@ -24,10 +25,28 @@ var tooltipZIndex = layers.tooltip();
24
25
  var analyticsAttributes = {
25
26
  componentName: 'tooltip',
26
27
  packageName: "@atlaskit/tooltip",
27
- packageVersion: "17.5.11"
28
+ packageVersion: "17.5.14"
28
29
  };
29
30
 
30
- function noop() {}
31
+ function noop() {} // Inverts motion direction
32
+
33
+
34
+ var invertedDirection = {
35
+ top: 'bottom',
36
+ bottom: 'top',
37
+ left: 'right',
38
+ right: 'left'
39
+ };
40
+ /**
41
+ * Converts a Popper placement to it's general direction.
42
+ *
43
+ * @param position - Popper Placement value, e.g. 'top-start'
44
+ * @returns Popper Direction, e.g. 'top'
45
+ */
46
+
47
+ var getDirectionFromPlacement = function getDirectionFromPlacement(placement) {
48
+ return placement.split('-')[0];
49
+ };
31
50
 
32
51
  function Tooltip(_ref) {
33
52
  var children = _ref.children,
@@ -173,17 +192,16 @@ function Tooltip(_ref) {
173
192
  lastHandlers.current.onShowHandler();
174
193
  }
175
194
 
176
- setState(isImmediate ? 'show-immediate' : 'show-fade-in');
195
+ setState(isImmediate ? 'show-immediate' : 'fade-in');
177
196
  },
178
197
  hide: function hide(_ref3) {
179
198
  var isImmediate = _ref3.isImmediate;
180
- setState(function (current) {
181
- if (current !== 'hide') {
182
- return isImmediate ? 'hide' : 'fade-out';
183
- }
184
199
 
185
- return current;
186
- });
200
+ if (isImmediate) {
201
+ setState('hide');
202
+ } else {
203
+ setState('before-fade-out');
204
+ }
187
205
  },
188
206
  done: done
189
207
  };
@@ -206,6 +224,10 @@ function Tooltip(_ref) {
206
224
  return noop;
207
225
  }
208
226
 
227
+ if (state === 'before-fade-out') {
228
+ setState('fade-out');
229
+ }
230
+
209
231
  var unbind = bind(window, {
210
232
  type: 'scroll',
211
233
  listener: function listener() {
@@ -318,9 +340,9 @@ function Tooltip(_ref) {
318
340
 
319
341
  var CastTargetContainer = TargetContainer;
320
342
  var shouldRenderTooltipContainer = state !== 'hide' && Boolean(content);
321
- var shouldRenderTooltipChildren = state === 'show-immediate' || state === 'show-fade-in';
343
+ var shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
322
344
 
323
- var getReferentElement = function getReferentElement() {
345
+ var getReferenceElement = function getReferenceElement() {
324
346
  // Use the initial mouse position if appropriate, or the target element
325
347
  var api = apiRef.current;
326
348
  var initialMouse = api ? api.getInitialMouse() : null;
@@ -350,17 +372,25 @@ function Tooltip(_ref) {
350
372
  zIndex: tooltipZIndex
351
373
  }, jsx(Popper, {
352
374
  placement: tooltipPosition,
353
- referenceElement: getReferentElement(),
375
+ referenceElement: getReferenceElement(),
354
376
  strategy: strategy
355
377
  }, function (_ref4) {
356
378
  var ref = _ref4.ref,
357
379
  style = _ref4.style,
358
- update = _ref4.update;
380
+ update = _ref4.update,
381
+ placement = _ref4.placement;
382
+ // Invert the entrance and exit directions.
383
+ // E.g. a tooltip's position is on the 'right', it should enter from and exit to the 'left'
384
+ // This gives the effect the tooltip is appearing from the target
385
+ var direction = position === 'mouse' ? undefined : invertedDirection[getDirectionFromPlacement(placement)];
359
386
  return jsx(ExitingPersistence, {
360
387
  appear: true
361
388
  }, shouldRenderTooltipChildren && jsx(FadeIn, {
389
+ distance: "constant",
390
+ entranceDirection: direction,
391
+ exitDirection: direction,
362
392
  onFinish: onAnimationFinished,
363
- duration: state === 'show-immediate' ? 0 : undefined
393
+ duration: state === 'show-immediate' ? 0 : mediumDurationMs
364
394
  }, function (_ref5) {
365
395
  var className = _ref5.className;
366
396
  return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
@@ -25,20 +25,20 @@ var TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive(_ref, r
25
25
 
26
26
  var styleWithZIndex = _objectSpread(_objectSpread({}, style), {}, _defineProperty({}, VAR_PRIMITIVE_ZINDEX, layers.tooltip()));
27
27
 
28
- return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
29
- jsx("div", {
30
- role: "tooltip",
31
- ref: ref,
32
- style: styleWithZIndex,
33
- className: className,
34
- onMouseOut: onMouseOut,
35
- onMouseOver: onMouseOver,
36
- css: primitiveStyles,
37
- "data-placement": placement,
38
- "data-testid": testId,
39
- id: id
40
- }, children)
41
- );
28
+ return jsx("div", {
29
+ ref: ref,
30
+ style: styleWithZIndex,
31
+ "data-testid": testId ? "".concat(testId, "--wrapper") : undefined
32
+ }, jsx("div", {
33
+ role: "tooltip",
34
+ className: className,
35
+ onMouseOut: onMouseOut,
36
+ onMouseOver: onMouseOver,
37
+ css: primitiveStyles,
38
+ "data-placement": placement,
39
+ "data-testid": testId,
40
+ id: id
41
+ }, children));
42
42
  });
43
43
  TooltipPrimitive.displayName = 'TooltipPrimitive';
44
44
  export default TooltipPrimitive;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.5.11",
3
+ "version": "17.5.14",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.5.11",
3
+ "version": "17.5.14",
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/"
@@ -16,24 +16,31 @@
16
16
  "atlaskit:src": "src/index.ts",
17
17
  "atlassian": {
18
18
  "team": "Design System Team",
19
- "deprecatedAutoEntryPoints": true,
20
19
  "releaseModel": "scheduled",
21
20
  "website": {
22
21
  "name": "Tooltip",
23
22
  "category": "Components"
24
23
  }
25
24
  },
25
+ "af:exports": {
26
+ ".": "./src/index.ts",
27
+ "./Tooltip": "./src/Tooltip.tsx",
28
+ "./TooltipContainer": "./src/TooltipContainer.tsx",
29
+ "./TooltipPrimitive": "./src/TooltipPrimitive.tsx",
30
+ "./types": "./src/types.tsx",
31
+ "./utilities": "./src/utilities.ts"
32
+ },
26
33
  "dependencies": {
27
34
  "@atlaskit/analytics-next": "^8.2.0",
28
- "@atlaskit/ds-lib": "^2.0.0",
29
- "@atlaskit/motion": "^1.1.0",
35
+ "@atlaskit/ds-lib": "^2.1.0",
36
+ "@atlaskit/motion": "^1.2.0",
30
37
  "@atlaskit/popper": "^5.0.0",
31
38
  "@atlaskit/portal": "^4.1.0",
32
39
  "@atlaskit/theme": "^12.1.0",
33
40
  "@atlaskit/tokens": "^0.10.0",
34
41
  "@babel/runtime": "^7.0.0",
35
42
  "@emotion/core": "^10.0.9",
36
- "bind-event-listener": "^2.1.0",
43
+ "bind-event-listener": "^2.1.1",
37
44
  "react-uid": "^2.2.0"
38
45
  },
39
46
  "peerDependencies": {
package/report.api.md ADDED
@@ -0,0 +1,171 @@
1
+ ## API Report File for "@atlaskit/tooltip"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+ /// <reference types="react" />
7
+
8
+ import { ComponentType } from 'react';
9
+ import { CSSProperties } from 'react';
10
+ import { ForwardRefExoticComponent } from 'react';
11
+ import { Placement } from '@atlaskit/popper';
12
+ import { ReactNode } from 'react';
13
+ import { RefAttributes } from 'react';
14
+ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
15
+
16
+ export declare type PositionType = PositionTypeBase | 'mouse';
17
+
18
+ declare type PositionTypeBase = Placement;
19
+
20
+ declare function Tooltip({
21
+ children,
22
+ position,
23
+ mousePosition,
24
+ content,
25
+ truncate,
26
+ component: Container,
27
+ tag: TargetContainer,
28
+ testId,
29
+ delay,
30
+ onShow,
31
+ onHide,
32
+ hideTooltipOnClick,
33
+ hideTooltipOnMouseDown,
34
+ analyticsContext,
35
+ strategy,
36
+ }: TooltipProps): JSX.Element;
37
+
38
+ declare namespace Tooltip {
39
+ var displayName: string;
40
+ }
41
+ export default Tooltip;
42
+
43
+ export declare const TooltipPrimitive: ForwardRefExoticComponent<
44
+ Pick<
45
+ TooltipPrimitiveProps,
46
+ | 'style'
47
+ | 'className'
48
+ | 'children'
49
+ | 'placement'
50
+ | 'testId'
51
+ | 'onMouseOut'
52
+ | 'onMouseOver'
53
+ | 'id'
54
+ | 'truncate'
55
+ > &
56
+ RefAttributes<HTMLDivElement>
57
+ >;
58
+
59
+ export declare interface TooltipPrimitiveProps {
60
+ truncate?: boolean;
61
+ style?: CSSProperties;
62
+ className?: string;
63
+ children: ReactNode;
64
+ testId?: string;
65
+ placement: PositionType;
66
+ ref: React.Ref<any>;
67
+ onMouseOver?: (e: React.MouseEvent<HTMLElement>) => void;
68
+ onMouseOut?: (e: React.MouseEvent<HTMLElement>) => void;
69
+ id?: string;
70
+ }
71
+
72
+ export declare interface TooltipProps {
73
+ /**
74
+ * The content of the tooltip. It can be either a:
75
+ * 1. `ReactNode`
76
+ * 2. Function which returns a `ReactNode`
77
+
78
+ * The benefit of the second approach is that it allows you to consume the `update` render prop.
79
+ * This `update` function can be called to manually recalculate the position of the tooltip.
80
+ */
81
+ content: ReactNode | (({ update }: { update: () => void }) => ReactNode);
82
+ /**
83
+ * Extend `TooltipPrimitive` to create your own tooltip and pass it as component
84
+ */
85
+ component?: ComponentType<TooltipPrimitiveProps>;
86
+ /**
87
+ * Time in milliseconds to wait before showing and hiding the tooltip. Defaults to 300.
88
+ */
89
+ delay?: number;
90
+ /**
91
+ * Hide the tooltip when the click event is triggered. This should be
92
+ * used when tooltip should be hidden if `onClick` react synthetic event
93
+ * is triggered, which happens after `onMouseDown` event
94
+ */
95
+ hideTooltipOnClick?: boolean;
96
+ /**
97
+ * Hide the tooltip when the mousedown event is triggered. This should be
98
+ * used when tooltip should be hidden if `onMouseDown` react synthetic event
99
+ * is triggered, which happens before `onClick` event
100
+ */
101
+ hideTooltipOnMouseDown?: boolean;
102
+ /**
103
+ * Where the tooltip should appear relative to the mouse pointer.
104
+ * Only used when the `position` prop is set to `"mouse"`.
105
+ * When interacting with the target element using the keyboard will use this position against the target element instead.
106
+ */
107
+ mousePosition?: PositionTypeBase;
108
+ /**
109
+ * Function to be called when the tooltip will be shown. It is called when the
110
+ * tooltip begins to animate in.
111
+ */
112
+ onShow?: (analyticsEvent: UIAnalyticsEvent) => void;
113
+ /**
114
+ * Function to be called when the tooltip will be hidden. It is called after the
115
+ * delay, when the tooltip begins to animate out.
116
+ */
117
+ onHide?: (analyticsEvent: UIAnalyticsEvent) => void;
118
+ /**
119
+ * Where the tooltip should appear relative to its target.
120
+ * If set to `"mouse"` the tooltip will display next to the mouse pointer instead.
121
+ * Make sure to utilize the `mousePosition` if you want to customize where the tooltip will show in relation to the mouse.
122
+ */
123
+ position?: PositionType;
124
+ /**
125
+ * Replace the wrapping element. This accepts the name of a html tag which will
126
+ * be used to wrap the element.
127
+ * If you provide a component it needs to support a ref prop which is used by popper for positioning
128
+ */
129
+ tag?:
130
+ | keyof JSX.IntrinsicElements
131
+ | React.ComponentType<
132
+ React.AllHTMLAttributes<HTMLElement> & {
133
+ ref: React.Ref<HTMLElement>;
134
+ }
135
+ >;
136
+ /**
137
+ * Show only one line of text, and truncate when too long
138
+ */
139
+ truncate?: boolean;
140
+ /**
141
+ * Elements to be wrapped by the tooltip.
142
+ * It can be either a:
143
+ * 1. `ReactNode`
144
+ * 2. Function which returns a `ReactNode`
145
+ */
146
+ children: ReactNode | ((props: TriggerProps) => ReactNode);
147
+ /**
148
+ * A `testId` prop is provided for specified elements, which is a unique
149
+ * string that appears as a data attribute `data-testid` in the rendered code,
150
+ * serving as a hook for automated tests */
151
+ testId?: string;
152
+ /** Analytics context metadata */
153
+ analyticsContext?: Record<string, any>;
154
+ /**
155
+ * Used to define the strategy of popper.
156
+ */
157
+ strategy?: 'absolute' | 'fixed' | undefined;
158
+ }
159
+
160
+ declare interface TriggerProps {
161
+ onMouseOver: (event: React.MouseEvent<HTMLElement>) => void;
162
+ onMouseOut: (event: React.MouseEvent<HTMLElement>) => void;
163
+ onMouseDown: (event: React.MouseEvent<HTMLElement>) => void;
164
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
165
+ onFocus: (event: React.FocusEvent<HTMLElement>) => void;
166
+ onBlur: (event: React.FocusEvent<HTMLElement>) => void;
167
+ ref: (node: HTMLElement | null) => void;
168
+ }
169
+
170
+ export {};
171
+ ```