@atlaskit/tooltip 18.1.0 → 18.1.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/tooltip
2
2
 
3
+ ## 18.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#64251](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64251) [`92b280e734a7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/92b280e734a7) - Add a hidden tooltip content when tooltip is in a modal for screen reader announcement
8
+
3
9
  ## 18.1.0
4
10
 
5
11
  ### Minor Changes
@@ -10,7 +10,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _react = _interopRequireWildcard(require("react"));
13
- var _react2 = require("@emotion/react");
14
13
  var _bindEventListener = require("bind-event-listener");
15
14
  var _analyticsNext = require("@atlaskit/analytics-next");
16
15
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
@@ -28,12 +27,12 @@ var _utilities = require("./utilities");
28
27
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
30
29
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */
30
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
31
  var tooltipZIndex = _constants.layers.tooltip();
33
32
  var analyticsAttributes = {
34
33
  componentName: 'tooltip',
35
34
  packageName: "@atlaskit/tooltip",
36
- packageVersion: "18.1.0"
35
+ packageVersion: "18.1.1"
37
36
  };
38
37
 
39
38
  // Inverts motion direction
@@ -413,19 +412,25 @@ function Tooltip(_ref) {
413
412
  target.removeAttribute('aria-describedby');
414
413
  }
415
414
  }, [shouldRenderTooltipContainer, tooltipId]);
416
- return (0, _react2.jsx)(_react.default.Fragment, null, typeof children === 'function' ?
415
+ var hiddenContent = /*#__PURE__*/_react.default.createElement("span", {
416
+ "data-testid": testId ? "".concat(testId, "-hidden") : undefined,
417
+ hidden: true,
418
+ id: tooltipId
419
+ }, typeof content === 'function' ? content({}) : content);
420
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, typeof children === 'function' ?
421
+ /*#__PURE__*/
417
422
  // once we deprecate the wrapped approach, we can put the aria
418
423
  // attribute back into the tooltipTriggerProps and make it required
419
424
  // instead of optional in `types`
420
- children(_objectSpread(_objectSpread({}, tooltipTriggerProps), {}, {
425
+ _react.default.createElement(_react.default.Fragment, null, children(_objectSpread(_objectSpread({}, tooltipTriggerProps), {}, {
421
426
  'aria-describedby': tooltipId,
422
427
  ref: setDirectRef
423
- })) : (0, _react2.jsx)(CastTargetContainer, (0, _extends2.default)({}, tooltipTriggerProps, {
428
+ })), shouldRenderTooltipContainer && hiddenContent) : /*#__PURE__*/_react.default.createElement(CastTargetContainer, (0, _extends2.default)({}, tooltipTriggerProps, {
424
429
  ref: setImplicitRefFromChildren,
425
430
  role: "presentation"
426
- }), children), shouldRenderTooltipContainer ? (0, _react2.jsx)(_portal.default, {
431
+ }), children, shouldRenderTooltipContainer && hiddenContent), shouldRenderTooltipContainer ? /*#__PURE__*/_react.default.createElement(_portal.default, {
427
432
  zIndex: tooltipZIndex
428
- }, (0, _react2.jsx)(_popper.Popper, {
433
+ }, /*#__PURE__*/_react.default.createElement(_popper.Popper, {
429
434
  placement: tooltipPosition,
430
435
  referenceElement: getReferenceElement(),
431
436
  strategy: strategy
@@ -438,9 +443,9 @@ function Tooltip(_ref) {
438
443
  // E.g. a tooltip's position is on the 'right', it should enter from and exit to the 'left'
439
444
  // This gives the effect the tooltip is appearing from the target
440
445
  var direction = position === 'mouse' ? undefined : invertedDirection[getDirectionFromPlacement(placement)];
441
- return (0, _react2.jsx)(_motion.ExitingPersistence, {
446
+ return /*#__PURE__*/_react.default.createElement(_motion.ExitingPersistence, {
442
447
  appear: true
443
- }, shouldRenderTooltipChildren && (0, _react2.jsx)(_motion.FadeIn, {
448
+ }, shouldRenderTooltipChildren && /*#__PURE__*/_react.default.createElement(_motion.FadeIn, {
444
449
  distance: "constant",
445
450
  entranceDirection: direction,
446
451
  exitDirection: direction,
@@ -448,7 +453,7 @@ function Tooltip(_ref) {
448
453
  duration: state === 'show-immediate' ? 0 : _durations.mediumDurationMs
449
454
  }, function (_ref6) {
450
455
  var className = _ref6.className;
451
- return (0, _react2.jsx)(Container, {
456
+ return /*#__PURE__*/_react.default.createElement(Container, {
452
457
  ref: ref
453
458
  /**
454
459
  * "Tooltip" classname is a hook used by tests to manipulate
@@ -460,8 +465,7 @@ function Tooltip(_ref) {
460
465
  placement: tooltipPosition,
461
466
  testId: getReferenceElement() ? testId : testId && "".concat(testId, "--unresolved"),
462
467
  onMouseOut: onMouseOut,
463
- onMouseOver: onMouseOverTooltip,
464
- id: tooltipId
468
+ onMouseOver: onMouseOverTooltip
465
469
  }, typeof content === 'function' ? content({
466
470
  update: update
467
471
  }) : content);
@@ -1,8 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- /** @jsx jsx */
3
-
4
2
  import React, { useCallback, useEffect, useRef, useState } from 'react';
5
- import { jsx } from '@emotion/react';
6
3
  import { bind } from 'bind-event-listener';
7
4
  import { usePlatformLeafSyntheticEventHandler } from '@atlaskit/analytics-next';
8
5
  import noop from '@atlaskit/ds-lib/noop';
@@ -21,7 +18,7 @@ const tooltipZIndex = layers.tooltip();
21
18
  const analyticsAttributes = {
22
19
  componentName: 'tooltip',
23
20
  packageName: "@atlaskit/tooltip",
24
- packageVersion: "18.1.0"
21
+ packageVersion: "18.1.1"
25
22
  };
26
23
 
27
24
  // Inverts motion direction
@@ -391,20 +388,26 @@ function Tooltip({
391
388
  target.removeAttribute('aria-describedby');
392
389
  }
393
390
  }, [shouldRenderTooltipContainer, tooltipId]);
394
- return jsx(React.Fragment, null, typeof children === 'function' ?
391
+ const hiddenContent = /*#__PURE__*/React.createElement("span", {
392
+ "data-testid": testId ? `${testId}-hidden` : undefined,
393
+ hidden: true,
394
+ id: tooltipId
395
+ }, typeof content === 'function' ? content({}) : content);
396
+ return /*#__PURE__*/React.createElement(React.Fragment, null, typeof children === 'function' ?
397
+ /*#__PURE__*/
395
398
  // once we deprecate the wrapped approach, we can put the aria
396
399
  // attribute back into the tooltipTriggerProps and make it required
397
400
  // instead of optional in `types`
398
- children({
401
+ React.createElement(React.Fragment, null, children({
399
402
  ...tooltipTriggerProps,
400
403
  'aria-describedby': tooltipId,
401
404
  ref: setDirectRef
402
- }) : jsx(CastTargetContainer, _extends({}, tooltipTriggerProps, {
405
+ }), shouldRenderTooltipContainer && hiddenContent) : /*#__PURE__*/React.createElement(CastTargetContainer, _extends({}, tooltipTriggerProps, {
403
406
  ref: setImplicitRefFromChildren,
404
407
  role: "presentation"
405
- }), children), shouldRenderTooltipContainer ? jsx(Portal, {
408
+ }), children, shouldRenderTooltipContainer && hiddenContent), shouldRenderTooltipContainer ? /*#__PURE__*/React.createElement(Portal, {
406
409
  zIndex: tooltipZIndex
407
- }, jsx(Popper, {
410
+ }, /*#__PURE__*/React.createElement(Popper, {
408
411
  placement: tooltipPosition,
409
412
  referenceElement: getReferenceElement(),
410
413
  strategy: strategy
@@ -418,9 +421,9 @@ function Tooltip({
418
421
  // E.g. a tooltip's position is on the 'right', it should enter from and exit to the 'left'
419
422
  // This gives the effect the tooltip is appearing from the target
420
423
  const direction = position === 'mouse' ? undefined : invertedDirection[getDirectionFromPlacement(placement)];
421
- return jsx(ExitingPersistence, {
424
+ return /*#__PURE__*/React.createElement(ExitingPersistence, {
422
425
  appear: true
423
- }, shouldRenderTooltipChildren && jsx(FadeIn, {
426
+ }, shouldRenderTooltipChildren && /*#__PURE__*/React.createElement(FadeIn, {
424
427
  distance: "constant",
425
428
  entranceDirection: direction,
426
429
  exitDirection: direction,
@@ -428,7 +431,7 @@ function Tooltip({
428
431
  duration: state === 'show-immediate' ? 0 : mediumDurationMs
429
432
  }, ({
430
433
  className
431
- }) => jsx(Container, {
434
+ }) => /*#__PURE__*/React.createElement(Container, {
432
435
  ref: ref
433
436
  /**
434
437
  * "Tooltip" classname is a hook used by tests to manipulate
@@ -440,8 +443,7 @@ function Tooltip({
440
443
  placement: tooltipPosition,
441
444
  testId: getReferenceElement() ? testId : testId && `${testId}--unresolved`,
442
445
  onMouseOut: onMouseOut,
443
- onMouseOver: onMouseOverTooltip,
444
- id: tooltipId
446
+ onMouseOver: onMouseOverTooltip
445
447
  }, typeof content === 'function' ? content({
446
448
  update
447
449
  }) : content)));
@@ -3,10 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- /** @jsx jsx */
7
-
8
6
  import React, { useCallback, useEffect, useRef, useState } from 'react';
9
- import { jsx } from '@emotion/react';
10
7
  import { bind } from 'bind-event-listener';
11
8
  import { usePlatformLeafSyntheticEventHandler } from '@atlaskit/analytics-next';
12
9
  import noop from '@atlaskit/ds-lib/noop';
@@ -25,7 +22,7 @@ var tooltipZIndex = layers.tooltip();
25
22
  var analyticsAttributes = {
26
23
  componentName: 'tooltip',
27
24
  packageName: "@atlaskit/tooltip",
28
- packageVersion: "18.1.0"
25
+ packageVersion: "18.1.1"
29
26
  };
30
27
 
31
28
  // Inverts motion direction
@@ -405,19 +402,25 @@ function Tooltip(_ref) {
405
402
  target.removeAttribute('aria-describedby');
406
403
  }
407
404
  }, [shouldRenderTooltipContainer, tooltipId]);
408
- return jsx(React.Fragment, null, typeof children === 'function' ?
405
+ var hiddenContent = /*#__PURE__*/React.createElement("span", {
406
+ "data-testid": testId ? "".concat(testId, "-hidden") : undefined,
407
+ hidden: true,
408
+ id: tooltipId
409
+ }, typeof content === 'function' ? content({}) : content);
410
+ return /*#__PURE__*/React.createElement(React.Fragment, null, typeof children === 'function' ?
411
+ /*#__PURE__*/
409
412
  // once we deprecate the wrapped approach, we can put the aria
410
413
  // attribute back into the tooltipTriggerProps and make it required
411
414
  // instead of optional in `types`
412
- children(_objectSpread(_objectSpread({}, tooltipTriggerProps), {}, {
415
+ React.createElement(React.Fragment, null, children(_objectSpread(_objectSpread({}, tooltipTriggerProps), {}, {
413
416
  'aria-describedby': tooltipId,
414
417
  ref: setDirectRef
415
- })) : jsx(CastTargetContainer, _extends({}, tooltipTriggerProps, {
418
+ })), shouldRenderTooltipContainer && hiddenContent) : /*#__PURE__*/React.createElement(CastTargetContainer, _extends({}, tooltipTriggerProps, {
416
419
  ref: setImplicitRefFromChildren,
417
420
  role: "presentation"
418
- }), children), shouldRenderTooltipContainer ? jsx(Portal, {
421
+ }), children, shouldRenderTooltipContainer && hiddenContent), shouldRenderTooltipContainer ? /*#__PURE__*/React.createElement(Portal, {
419
422
  zIndex: tooltipZIndex
420
- }, jsx(Popper, {
423
+ }, /*#__PURE__*/React.createElement(Popper, {
421
424
  placement: tooltipPosition,
422
425
  referenceElement: getReferenceElement(),
423
426
  strategy: strategy
@@ -430,9 +433,9 @@ function Tooltip(_ref) {
430
433
  // E.g. a tooltip's position is on the 'right', it should enter from and exit to the 'left'
431
434
  // This gives the effect the tooltip is appearing from the target
432
435
  var direction = position === 'mouse' ? undefined : invertedDirection[getDirectionFromPlacement(placement)];
433
- return jsx(ExitingPersistence, {
436
+ return /*#__PURE__*/React.createElement(ExitingPersistence, {
434
437
  appear: true
435
- }, shouldRenderTooltipChildren && jsx(FadeIn, {
438
+ }, shouldRenderTooltipChildren && /*#__PURE__*/React.createElement(FadeIn, {
436
439
  distance: "constant",
437
440
  entranceDirection: direction,
438
441
  exitDirection: direction,
@@ -440,7 +443,7 @@ function Tooltip(_ref) {
440
443
  duration: state === 'show-immediate' ? 0 : mediumDurationMs
441
444
  }, function (_ref6) {
442
445
  var className = _ref6.className;
443
- return jsx(Container, {
446
+ return /*#__PURE__*/React.createElement(Container, {
444
447
  ref: ref
445
448
  /**
446
449
  * "Tooltip" classname is a hook used by tests to manipulate
@@ -452,8 +455,7 @@ function Tooltip(_ref) {
452
455
  placement: tooltipPosition,
453
456
  testId: getReferenceElement() ? testId : testId && "".concat(testId, "--unresolved"),
454
457
  onMouseOut: onMouseOut,
455
- onMouseOver: onMouseOverTooltip,
456
- id: tooltipId
458
+ onMouseOver: onMouseOverTooltip
457
459
  }, typeof content === 'function' ? content({
458
460
  update: update
459
461
  }) : content);
@@ -1,7 +1,6 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
1
+ /// <reference types="react" />
3
2
  import { TooltipProps } from './types';
4
- declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, }: TooltipProps): jsx.JSX.Element;
3
+ declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, }: TooltipProps): JSX.Element;
5
4
  declare namespace Tooltip {
6
5
  var displayName: string;
7
6
  }
@@ -25,7 +25,7 @@ export interface TooltipProps {
25
25
  * This `update` function can be called to manually recalculate the position of the tooltip.
26
26
  */
27
27
  content: ReactNode | (({ update }: {
28
- update: () => void;
28
+ update?: () => void;
29
29
  }) => ReactNode);
30
30
  /**
31
31
  * Extend `TooltipPrimitive` to create your own tooltip and pass it as component
@@ -1,7 +1,6 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
1
+ /// <reference types="react" />
3
2
  import { TooltipProps } from './types';
4
- declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, }: TooltipProps): jsx.JSX.Element;
3
+ declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, }: TooltipProps): JSX.Element;
5
4
  declare namespace Tooltip {
6
5
  var displayName: string;
7
6
  }
@@ -25,7 +25,7 @@ export interface TooltipProps {
25
25
  * This `update` function can be called to manually recalculate the position of the tooltip.
26
26
  */
27
27
  content: ReactNode | (({ update }: {
28
- update: () => void;
28
+ update?: () => void;
29
29
  }) => ReactNode);
30
30
  /**
31
31
  * Extend `TooltipPrimitive` to create your own tooltip and pass it as component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "18.1.0",
3
+ "version": "18.1.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/"
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/popper": "^5.5.0",
49
49
  "@atlaskit/portal": "^4.4.0",
50
50
  "@atlaskit/theme": "^12.6.0",
51
- "@atlaskit/tokens": "^1.30.0",
51
+ "@atlaskit/tokens": "^1.33.0",
52
52
  "@babel/runtime": "^7.0.0",
53
53
  "@emotion/react": "^11.7.1",
54
54
  "bind-event-listener": "^2.1.1",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@af/accessibility-testing": "*",
63
- "@atlaskit/button": "^17.1.0",
63
+ "@atlaskit/button": "^17.2.0",
64
64
  "@atlaskit/ssr": "*",
65
65
  "@atlaskit/visual-regression": "*",
66
66
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",