@atlaskit/tooltip 20.4.8 → 20.5.0
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 +12 -0
- package/dist/cjs/tooltip-container.compiled.css +4 -2
- package/dist/cjs/tooltip-container.js +12 -13
- package/dist/cjs/tooltip-primitive.js +7 -2
- package/dist/cjs/tooltip-shortcut.compiled.css +12 -0
- package/dist/cjs/tooltip-shortcut.js +33 -0
- package/dist/cjs/tooltip.js +4 -2
- package/dist/es2019/tooltip-container.compiled.css +2 -0
- package/dist/es2019/tooltip-container.js +11 -6
- package/dist/es2019/tooltip-primitive.js +7 -2
- package/dist/es2019/tooltip-shortcut.compiled.css +12 -0
- package/dist/es2019/tooltip-shortcut.js +24 -0
- package/dist/es2019/tooltip.js +4 -2
- package/dist/esm/tooltip-container.compiled.css +4 -2
- package/dist/esm/tooltip-container.js +12 -13
- package/dist/esm/tooltip-primitive.js +7 -2
- package/dist/esm/tooltip-shortcut.compiled.css +12 -0
- package/dist/esm/tooltip-shortcut.js +25 -0
- package/dist/esm/tooltip.js +4 -2
- package/dist/types/tooltip-primitive.d.ts +1 -0
- package/dist/types/tooltip-shortcut.d.ts +15 -0
- package/dist/types/tooltip.d.ts +1 -1
- package/dist/types/types.d.ts +8 -0
- package/dist/types-ts4.5/tooltip-primitive.d.ts +1 -0
- package/dist/types-ts4.5/tooltip-shortcut.d.ts +15 -0
- package/dist/types-ts4.5/tooltip.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +8 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/tooltip
|
|
2
2
|
|
|
3
|
+
## 20.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`4afb88f83d688`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4afb88f83d688) -
|
|
8
|
+
Tooltip now includes support for displaying keyboard shortcuts via the `shortcut` prop. This prop
|
|
9
|
+
is currently behind the `platform-dst-tooltip-shortcuts` feature flag. Example usage:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
<Tooltip content="Collapse sidebar" shortcut={['Ctrl', '[']}>
|
|
13
|
+
```
|
|
14
|
+
|
|
3
15
|
## 20.4.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
._1bto1l2s{text-overflow:ellipsis}
|
|
6
6
|
._1e02ze3t{inset-inline-start:var(--ds-space-0,0)}
|
|
7
7
|
._1i4q1hna{overflow-wrap:break-word}
|
|
8
|
+
._1q511b66{padding-block-start:var(--ds-space-050,4px)}
|
|
8
9
|
._1q51v77o{padding-block-start:var(--ds-space-025,2px)}
|
|
9
10
|
._1reo15vq{overflow-x:hidden}
|
|
11
|
+
._85i51b66{padding-block-end:var(--ds-space-050,4px)}
|
|
10
12
|
._85i5v77o{padding-block-end:var(--ds-space-025,2px)}
|
|
11
|
-
.
|
|
13
|
+
._bfhkgkf6{background-color:var(--ds-background-neutral-bold,#172b4d)}
|
|
12
14
|
._bozg12x7{padding-inline-start:var(--ds-space-075,6px)}
|
|
13
15
|
._o5721q9c{white-space:nowrap}
|
|
14
16
|
._p12f1pna{max-width:420px}
|
|
15
17
|
._p12fp3fh{max-width:15pc}
|
|
16
18
|
._slp31hna{word-wrap:break-word}
|
|
17
|
-
.
|
|
19
|
+
._syaz15cr{color:var(--ds-text-inverse,#fff)}
|
|
18
20
|
._vchhusvi{box-sizing:border-box}
|
|
19
21
|
._y4ti12x7{padding-inline-end:var(--ds-space-075,6px)}
|
|
@@ -11,14 +11,14 @@ require("./tooltip-container.compiled.css");
|
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var React = _react;
|
|
13
13
|
var _runtime = require("@compiled/react/runtime");
|
|
14
|
-
var
|
|
15
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
15
|
var _tooltipPrimitive = _interopRequireDefault(require("./tooltip-primitive"));
|
|
17
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
var styles = {
|
|
18
|
+
base: "_2rkofajl _11c8dcr7 _vchhusvi _p12fp3fh _bfhkgkf6 _syaz15cr _152tze3t _1e02ze3t _1i4q1hna _85i5v77o _1q51v77o _y4ti12x7 _bozg12x7 _slp31hna",
|
|
19
|
+
baseRefreshedPadding: "_1q511b66 _85i51b66",
|
|
20
|
+
truncate: "_1reo15vq _18m915vq _p12f1pna _1bto1l2s _o5721q9c"
|
|
21
|
+
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Used as the default tooltip container component for the exported `Tooltip` component.
|
|
@@ -33,23 +33,22 @@ var TooltipContainer = /*#__PURE__*/(0, _react.forwardRef)(function TooltipConta
|
|
|
33
33
|
testId = _ref.testId,
|
|
34
34
|
onMouseOut = _ref.onMouseOut,
|
|
35
35
|
onMouseOver = _ref.onMouseOver,
|
|
36
|
-
id = _ref.id
|
|
36
|
+
id = _ref.id,
|
|
37
|
+
shortcut = _ref.shortcut;
|
|
37
38
|
return /*#__PURE__*/React.createElement(_tooltipPrimitive.default, {
|
|
38
39
|
ref: ref
|
|
39
40
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
40
41
|
,
|
|
41
|
-
|
|
42
|
+
style: style
|
|
42
43
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
43
|
-
|
|
44
|
+
,
|
|
45
|
+
className: (0, _runtime.ax)([styles.base, (0, _platformFeatureFlags.fg)('platform-dst-tooltip-shortcuts') && styles.baseRefreshedPadding, truncate && styles.truncate, className]),
|
|
44
46
|
placement: placement,
|
|
45
47
|
testId: testId,
|
|
46
48
|
id: id,
|
|
47
49
|
onMouseOut: onMouseOut,
|
|
48
50
|
onMouseOver: onMouseOver,
|
|
49
|
-
|
|
50
|
-
"--_yr7xfv": (0, _runtime.ix)("var(--ds-background-neutral-bold, ".concat(_colors.N800, ")")),
|
|
51
|
-
"--_ywovvi": (0, _runtime.ix)("var(--ds-text-inverse, ".concat(_colors.N0, ")"))
|
|
52
|
-
})
|
|
51
|
+
shortcut: shortcut
|
|
53
52
|
}, children);
|
|
54
53
|
});
|
|
55
54
|
TooltipContainer.displayName = 'TooltipContainer';
|
|
@@ -10,6 +10,8 @@ require("./tooltip-primitive.compiled.css");
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var React = _react;
|
|
12
12
|
var _runtime = require("@compiled/react/runtime");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
|
+
var _tooltipShortcut = require("./tooltip-shortcut");
|
|
13
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
16
|
var primitiveStyles = null;
|
|
15
17
|
|
|
@@ -24,7 +26,8 @@ var TooltipPrimitive = /*#__PURE__*/(0, _react.forwardRef)(function TooltipPrimi
|
|
|
24
26
|
testId = _ref.testId,
|
|
25
27
|
onMouseOut = _ref.onMouseOut,
|
|
26
28
|
onMouseOver = _ref.onMouseOver,
|
|
27
|
-
id = _ref.id
|
|
29
|
+
id = _ref.id,
|
|
30
|
+
shortcut = _ref.shortcut;
|
|
28
31
|
return /*#__PURE__*/React.createElement("div", {
|
|
29
32
|
ref: ref
|
|
30
33
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
@@ -44,7 +47,9 @@ var TooltipPrimitive = /*#__PURE__*/(0, _react.forwardRef)(function TooltipPrimi
|
|
|
44
47
|
"data-placement": placement,
|
|
45
48
|
"data-testid": testId,
|
|
46
49
|
id: id
|
|
47
|
-
}, children))
|
|
50
|
+
}, children, shortcut && (0, _platformFeatureFlags.fg)('platform-dst-tooltip-shortcuts') && /*#__PURE__*/React.createElement(_tooltipShortcut.TooltipShortcut, {
|
|
51
|
+
shortcut: shortcut
|
|
52
|
+
})));
|
|
48
53
|
});
|
|
49
54
|
TooltipPrimitive.displayName = 'TooltipPrimitive';
|
|
50
55
|
var _default = exports.default = TooltipPrimitive;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
._11c81u0j{font:var(--ds-font-code,normal 400 .875em/1 ui-monospace,Menlo,"Segoe UI Mono","Ubuntu Mono",monospace)}
|
|
2
|
+
._2rkolb4i{border-radius:var(--ds-radius-xsmall,2px)}
|
|
3
|
+
._zulpv77o{gap:var(--ds-space-025,2px)}
|
|
4
|
+
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
5
|
+
._1dqonqa1{border-style:solid}
|
|
6
|
+
._1h6d7jlr{border-color:var(--ds-border-bold,#758195)}
|
|
7
|
+
._1e0c1txw{display:flex}
|
|
8
|
+
._1q511b66{padding-block-start:var(--ds-space-050,4px)}
|
|
9
|
+
._1q51v77o{padding-block-start:var(--ds-space-025,2px)}
|
|
10
|
+
._85i5v77o{padding-block-end:var(--ds-space-025,2px)}
|
|
11
|
+
._bozg12x7{padding-inline-start:var(--ds-space-075,6px)}
|
|
12
|
+
._y4ti12x7{padding-inline-end:var(--ds-space-075,6px)}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* tooltip-shortcut.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.TooltipShortcut = void 0;
|
|
9
|
+
require("./tooltip-shortcut.compiled.css");
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _runtime = require("@compiled/react/runtime");
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
13
|
+
var styles = {
|
|
14
|
+
shortcutSegmentsContainer: "_zulpv77o _1e0c1txw _1q511b66 _85i5v77o",
|
|
15
|
+
shortcutSegment: "_11c81u0j _2rkolb4i _1dqonqa1 _189ee4h9 _1h6d7jlr _1q51v77o _85i5v77o _bozg12x7 _y4ti12x7"
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* __Tooltip shortcut__
|
|
19
|
+
*
|
|
20
|
+
* An internal component that is used to display a keyboard shortcut within a tooltip, showing each key
|
|
21
|
+
* as a styled segment after the main tooltip content.
|
|
22
|
+
*/
|
|
23
|
+
var TooltipShortcut = exports.TooltipShortcut = function TooltipShortcut(_ref) {
|
|
24
|
+
var shortcut = _ref.shortcut;
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: (0, _runtime.ax)([styles.shortcutSegmentsContainer])
|
|
27
|
+
}, shortcut.map(function (segment, index) {
|
|
28
|
+
return /*#__PURE__*/React.createElement("kbd", {
|
|
29
|
+
key: "".concat(segment, "-").concat(index),
|
|
30
|
+
className: (0, _runtime.ax)([styles.shortcutSegment])
|
|
31
|
+
}, segment);
|
|
32
|
+
}));
|
|
33
|
+
};
|
package/dist/cjs/tooltip.js
CHANGED
|
@@ -89,7 +89,8 @@ function Tooltip(_ref) {
|
|
|
89
89
|
_ref$ignoreTooltipPoi = _ref.ignoreTooltipPointerEvents,
|
|
90
90
|
ignoreTooltipPointerEvents = _ref$ignoreTooltipPoi === void 0 ? false : _ref$ignoreTooltipPoi,
|
|
91
91
|
_ref$isScreenReaderAn = _ref.isScreenReaderAnnouncementDisabled,
|
|
92
|
-
isScreenReaderAnnouncementDisabled = _ref$isScreenReaderAn === void 0 ? false : _ref$isScreenReaderAn
|
|
92
|
+
isScreenReaderAnnouncementDisabled = _ref$isScreenReaderAn === void 0 ? false : _ref$isScreenReaderAn,
|
|
93
|
+
shortcut = _ref.shortcut;
|
|
93
94
|
var tooltipPosition = position === 'mouse' ? mousePosition : position;
|
|
94
95
|
var onShowHandler = (0, _analyticsNext.usePlatformLeafSyntheticEventHandler)(_objectSpread({
|
|
95
96
|
fn: onShow,
|
|
@@ -538,7 +539,8 @@ function Tooltip(_ref) {
|
|
|
538
539
|
placement: tooltipPosition,
|
|
539
540
|
testId: getReferenceElement() ? testId : testId && "".concat(testId, "--unresolved"),
|
|
540
541
|
onMouseOut: onMouseOut,
|
|
541
|
-
onMouseOver: onMouseOverTooltip
|
|
542
|
+
onMouseOver: onMouseOverTooltip,
|
|
543
|
+
shortcut: shortcut
|
|
542
544
|
}, typeof content === 'function' ? content({
|
|
543
545
|
update: update
|
|
544
546
|
}) : content);
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
._1bto1l2s{text-overflow:ellipsis}
|
|
6
6
|
._1e02ze3t{inset-inline-start:var(--ds-space-0,0)}
|
|
7
7
|
._1i4q1hna{overflow-wrap:break-word}
|
|
8
|
+
._1q511b66{padding-block-start:var(--ds-space-050,4px)}
|
|
8
9
|
._1q51v77o{padding-block-start:var(--ds-space-025,2px)}
|
|
9
10
|
._1reo15vq{overflow-x:hidden}
|
|
11
|
+
._85i51b66{padding-block-end:var(--ds-space-050,4px)}
|
|
10
12
|
._85i5v77o{padding-block-end:var(--ds-space-025,2px)}
|
|
11
13
|
._bfhkgkf6{background-color:var(--ds-background-neutral-bold,#172b4d)}
|
|
12
14
|
._bozg12x7{padding-inline-start:var(--ds-space-075,6px)}
|
|
@@ -3,10 +3,13 @@ import "./tooltip-container.compiled.css";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
5
|
import { forwardRef } from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import TooltipPrimitive from './tooltip-primitive';
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const styles = {
|
|
9
|
+
base: "_2rkofajl _11c8dcr7 _vchhusvi _p12fp3fh _bfhkgkf6 _syaz15cr _152tze3t _1e02ze3t _1i4q1hna _85i5v77o _1q51v77o _y4ti12x7 _bozg12x7 _slp31hna",
|
|
10
|
+
baseRefreshedPadding: "_1q511b66 _85i51b66",
|
|
11
|
+
truncate: "_1reo15vq _18m915vq _p12f1pna _1bto1l2s _o5721q9c"
|
|
12
|
+
};
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Used as the default tooltip container component for the exported `Tooltip` component.
|
|
@@ -21,7 +24,8 @@ const TooltipContainer = /*#__PURE__*/forwardRef(function TooltipContainer({
|
|
|
21
24
|
testId,
|
|
22
25
|
onMouseOut,
|
|
23
26
|
onMouseOver,
|
|
24
|
-
id
|
|
27
|
+
id,
|
|
28
|
+
shortcut
|
|
25
29
|
}, ref) {
|
|
26
30
|
return /*#__PURE__*/React.createElement(TooltipPrimitive, {
|
|
27
31
|
ref: ref
|
|
@@ -30,12 +34,13 @@ const TooltipContainer = /*#__PURE__*/forwardRef(function TooltipContainer({
|
|
|
30
34
|
style: style
|
|
31
35
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
32
36
|
,
|
|
33
|
-
className: ax([
|
|
37
|
+
className: ax([styles.base, fg('platform-dst-tooltip-shortcuts') && styles.baseRefreshedPadding, truncate && styles.truncate, className]),
|
|
34
38
|
placement: placement,
|
|
35
39
|
testId: testId,
|
|
36
40
|
id: id,
|
|
37
41
|
onMouseOut: onMouseOut,
|
|
38
|
-
onMouseOver: onMouseOver
|
|
42
|
+
onMouseOver: onMouseOver,
|
|
43
|
+
shortcut: shortcut
|
|
39
44
|
}, children);
|
|
40
45
|
});
|
|
41
46
|
TooltipContainer.displayName = 'TooltipContainer';
|
|
@@ -3,6 +3,8 @@ import "./tooltip-primitive.compiled.css";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
5
|
import { forwardRef } from 'react';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { TooltipShortcut } from './tooltip-shortcut';
|
|
6
8
|
const primitiveStyles = null;
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -16,7 +18,8 @@ const TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive({
|
|
|
16
18
|
testId,
|
|
17
19
|
onMouseOut,
|
|
18
20
|
onMouseOver,
|
|
19
|
-
id
|
|
21
|
+
id,
|
|
22
|
+
shortcut
|
|
20
23
|
}, ref) {
|
|
21
24
|
return /*#__PURE__*/React.createElement("div", {
|
|
22
25
|
ref: ref
|
|
@@ -37,7 +40,9 @@ const TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive({
|
|
|
37
40
|
"data-placement": placement,
|
|
38
41
|
"data-testid": testId,
|
|
39
42
|
id: id
|
|
40
|
-
}, children)
|
|
43
|
+
}, children, shortcut && fg('platform-dst-tooltip-shortcuts') && /*#__PURE__*/React.createElement(TooltipShortcut, {
|
|
44
|
+
shortcut: shortcut
|
|
45
|
+
})));
|
|
41
46
|
});
|
|
42
47
|
TooltipPrimitive.displayName = 'TooltipPrimitive';
|
|
43
48
|
export default TooltipPrimitive;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
._11c81u0j{font:var(--ds-font-code,normal 400 .875em/1 ui-monospace,Menlo,"Segoe UI Mono","Ubuntu Mono",monospace)}
|
|
2
|
+
._2rkolb4i{border-radius:var(--ds-radius-xsmall,2px)}
|
|
3
|
+
._zulpv77o{gap:var(--ds-space-025,2px)}
|
|
4
|
+
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
5
|
+
._1dqonqa1{border-style:solid}
|
|
6
|
+
._1h6d7jlr{border-color:var(--ds-border-bold,#758195)}
|
|
7
|
+
._1e0c1txw{display:flex}
|
|
8
|
+
._1q511b66{padding-block-start:var(--ds-space-050,4px)}
|
|
9
|
+
._1q51v77o{padding-block-start:var(--ds-space-025,2px)}
|
|
10
|
+
._85i5v77o{padding-block-end:var(--ds-space-025,2px)}
|
|
11
|
+
._bozg12x7{padding-inline-start:var(--ds-space-075,6px)}
|
|
12
|
+
._y4ti12x7{padding-inline-end:var(--ds-space-075,6px)}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* tooltip-shortcut.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
import "./tooltip-shortcut.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
const styles = {
|
|
6
|
+
shortcutSegmentsContainer: "_zulpv77o _1e0c1txw _1q511b66 _85i5v77o",
|
|
7
|
+
shortcutSegment: "_11c81u0j _2rkolb4i _1dqonqa1 _189ee4h9 _1h6d7jlr _1q51v77o _85i5v77o _bozg12x7 _y4ti12x7"
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* __Tooltip shortcut__
|
|
11
|
+
*
|
|
12
|
+
* An internal component that is used to display a keyboard shortcut within a tooltip, showing each key
|
|
13
|
+
* as a styled segment after the main tooltip content.
|
|
14
|
+
*/
|
|
15
|
+
export const TooltipShortcut = ({
|
|
16
|
+
shortcut
|
|
17
|
+
}) => {
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
className: ax([styles.shortcutSegmentsContainer])
|
|
20
|
+
}, shortcut.map((segment, index) => /*#__PURE__*/React.createElement("kbd", {
|
|
21
|
+
key: `${segment}-${index}`,
|
|
22
|
+
className: ax([styles.shortcutSegment])
|
|
23
|
+
}, segment)));
|
|
24
|
+
};
|
package/dist/es2019/tooltip.js
CHANGED
|
@@ -62,7 +62,8 @@ function Tooltip({
|
|
|
62
62
|
analyticsContext,
|
|
63
63
|
strategy = 'fixed',
|
|
64
64
|
ignoreTooltipPointerEvents = false,
|
|
65
|
-
isScreenReaderAnnouncementDisabled = false
|
|
65
|
+
isScreenReaderAnnouncementDisabled = false,
|
|
66
|
+
shortcut
|
|
66
67
|
}) {
|
|
67
68
|
const tooltipPosition = position === 'mouse' ? mousePosition : position;
|
|
68
69
|
const onShowHandler = usePlatformLeafSyntheticEventHandler({
|
|
@@ -519,7 +520,8 @@ function Tooltip({
|
|
|
519
520
|
placement: tooltipPosition,
|
|
520
521
|
testId: getReferenceElement() ? testId : testId && `${testId}--unresolved`,
|
|
521
522
|
onMouseOut: onMouseOut,
|
|
522
|
-
onMouseOver: onMouseOverTooltip
|
|
523
|
+
onMouseOver: onMouseOverTooltip,
|
|
524
|
+
shortcut: shortcut
|
|
523
525
|
}, typeof content === 'function' ? content({
|
|
524
526
|
update
|
|
525
527
|
}) : content)));
|
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
._1bto1l2s{text-overflow:ellipsis}
|
|
6
6
|
._1e02ze3t{inset-inline-start:var(--ds-space-0,0)}
|
|
7
7
|
._1i4q1hna{overflow-wrap:break-word}
|
|
8
|
+
._1q511b66{padding-block-start:var(--ds-space-050,4px)}
|
|
8
9
|
._1q51v77o{padding-block-start:var(--ds-space-025,2px)}
|
|
9
10
|
._1reo15vq{overflow-x:hidden}
|
|
11
|
+
._85i51b66{padding-block-end:var(--ds-space-050,4px)}
|
|
10
12
|
._85i5v77o{padding-block-end:var(--ds-space-025,2px)}
|
|
11
|
-
.
|
|
13
|
+
._bfhkgkf6{background-color:var(--ds-background-neutral-bold,#172b4d)}
|
|
12
14
|
._bozg12x7{padding-inline-start:var(--ds-space-075,6px)}
|
|
13
15
|
._o5721q9c{white-space:nowrap}
|
|
14
16
|
._p12f1pna{max-width:420px}
|
|
15
17
|
._p12fp3fh{max-width:15pc}
|
|
16
18
|
._slp31hna{word-wrap:break-word}
|
|
17
|
-
.
|
|
19
|
+
._syaz15cr{color:var(--ds-text-inverse,#fff)}
|
|
18
20
|
._vchhusvi{box-sizing:border-box}
|
|
19
21
|
._y4ti12x7{padding-inline-end:var(--ds-space-075,6px)}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/* tooltip-container.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import "./tooltip-container.compiled.css";
|
|
4
3
|
import * as React from 'react';
|
|
5
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
-
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; }
|
|
7
|
-
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; }
|
|
8
5
|
import { forwardRef } from 'react';
|
|
9
|
-
import {
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
7
|
import TooltipPrimitive from './tooltip-primitive';
|
|
11
|
-
var
|
|
12
|
-
|
|
8
|
+
var styles = {
|
|
9
|
+
base: "_2rkofajl _11c8dcr7 _vchhusvi _p12fp3fh _bfhkgkf6 _syaz15cr _152tze3t _1e02ze3t _1i4q1hna _85i5v77o _1q51v77o _y4ti12x7 _bozg12x7 _slp31hna",
|
|
10
|
+
baseRefreshedPadding: "_1q511b66 _85i51b66",
|
|
11
|
+
truncate: "_1reo15vq _18m915vq _p12f1pna _1bto1l2s _o5721q9c"
|
|
12
|
+
};
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Used as the default tooltip container component for the exported `Tooltip` component.
|
|
@@ -24,23 +24,22 @@ var TooltipContainer = /*#__PURE__*/forwardRef(function TooltipContainer(_ref, r
|
|
|
24
24
|
testId = _ref.testId,
|
|
25
25
|
onMouseOut = _ref.onMouseOut,
|
|
26
26
|
onMouseOver = _ref.onMouseOver,
|
|
27
|
-
id = _ref.id
|
|
27
|
+
id = _ref.id,
|
|
28
|
+
shortcut = _ref.shortcut;
|
|
28
29
|
return /*#__PURE__*/React.createElement(TooltipPrimitive, {
|
|
29
30
|
ref: ref
|
|
30
31
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
31
32
|
,
|
|
32
|
-
|
|
33
|
+
style: style
|
|
33
34
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
34
|
-
|
|
35
|
+
,
|
|
36
|
+
className: ax([styles.base, fg('platform-dst-tooltip-shortcuts') && styles.baseRefreshedPadding, truncate && styles.truncate, className]),
|
|
35
37
|
placement: placement,
|
|
36
38
|
testId: testId,
|
|
37
39
|
id: id,
|
|
38
40
|
onMouseOut: onMouseOut,
|
|
39
41
|
onMouseOver: onMouseOver,
|
|
40
|
-
|
|
41
|
-
"--_yr7xfv": ix("var(--ds-background-neutral-bold, ".concat(N800, ")")),
|
|
42
|
-
"--_ywovvi": ix("var(--ds-text-inverse, ".concat(N0, ")"))
|
|
43
|
-
})
|
|
42
|
+
shortcut: shortcut
|
|
44
43
|
}, children);
|
|
45
44
|
});
|
|
46
45
|
TooltipContainer.displayName = 'TooltipContainer';
|
|
@@ -3,6 +3,8 @@ import "./tooltip-primitive.compiled.css";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
5
|
import { forwardRef } from 'react';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { TooltipShortcut } from './tooltip-shortcut';
|
|
6
8
|
var primitiveStyles = null;
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -16,7 +18,8 @@ var TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive(_ref, r
|
|
|
16
18
|
testId = _ref.testId,
|
|
17
19
|
onMouseOut = _ref.onMouseOut,
|
|
18
20
|
onMouseOver = _ref.onMouseOver,
|
|
19
|
-
id = _ref.id
|
|
21
|
+
id = _ref.id,
|
|
22
|
+
shortcut = _ref.shortcut;
|
|
20
23
|
return /*#__PURE__*/React.createElement("div", {
|
|
21
24
|
ref: ref
|
|
22
25
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
@@ -36,7 +39,9 @@ var TooltipPrimitive = /*#__PURE__*/forwardRef(function TooltipPrimitive(_ref, r
|
|
|
36
39
|
"data-placement": placement,
|
|
37
40
|
"data-testid": testId,
|
|
38
41
|
id: id
|
|
39
|
-
}, children)
|
|
42
|
+
}, children, shortcut && fg('platform-dst-tooltip-shortcuts') && /*#__PURE__*/React.createElement(TooltipShortcut, {
|
|
43
|
+
shortcut: shortcut
|
|
44
|
+
})));
|
|
40
45
|
});
|
|
41
46
|
TooltipPrimitive.displayName = 'TooltipPrimitive';
|
|
42
47
|
export default TooltipPrimitive;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
._11c81u0j{font:var(--ds-font-code,normal 400 .875em/1 ui-monospace,Menlo,"Segoe UI Mono","Ubuntu Mono",monospace)}
|
|
2
|
+
._2rkolb4i{border-radius:var(--ds-radius-xsmall,2px)}
|
|
3
|
+
._zulpv77o{gap:var(--ds-space-025,2px)}
|
|
4
|
+
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
5
|
+
._1dqonqa1{border-style:solid}
|
|
6
|
+
._1h6d7jlr{border-color:var(--ds-border-bold,#758195)}
|
|
7
|
+
._1e0c1txw{display:flex}
|
|
8
|
+
._1q511b66{padding-block-start:var(--ds-space-050,4px)}
|
|
9
|
+
._1q51v77o{padding-block-start:var(--ds-space-025,2px)}
|
|
10
|
+
._85i5v77o{padding-block-end:var(--ds-space-025,2px)}
|
|
11
|
+
._bozg12x7{padding-inline-start:var(--ds-space-075,6px)}
|
|
12
|
+
._y4ti12x7{padding-inline-end:var(--ds-space-075,6px)}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* tooltip-shortcut.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
import "./tooltip-shortcut.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
var styles = {
|
|
6
|
+
shortcutSegmentsContainer: "_zulpv77o _1e0c1txw _1q511b66 _85i5v77o",
|
|
7
|
+
shortcutSegment: "_11c81u0j _2rkolb4i _1dqonqa1 _189ee4h9 _1h6d7jlr _1q51v77o _85i5v77o _bozg12x7 _y4ti12x7"
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* __Tooltip shortcut__
|
|
11
|
+
*
|
|
12
|
+
* An internal component that is used to display a keyboard shortcut within a tooltip, showing each key
|
|
13
|
+
* as a styled segment after the main tooltip content.
|
|
14
|
+
*/
|
|
15
|
+
export var TooltipShortcut = function TooltipShortcut(_ref) {
|
|
16
|
+
var shortcut = _ref.shortcut;
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: ax([styles.shortcutSegmentsContainer])
|
|
19
|
+
}, shortcut.map(function (segment, index) {
|
|
20
|
+
return /*#__PURE__*/React.createElement("kbd", {
|
|
21
|
+
key: "".concat(segment, "-").concat(index),
|
|
22
|
+
className: ax([styles.shortcutSegment])
|
|
23
|
+
}, segment);
|
|
24
|
+
}));
|
|
25
|
+
};
|
package/dist/esm/tooltip.js
CHANGED
|
@@ -80,7 +80,8 @@ function Tooltip(_ref) {
|
|
|
80
80
|
_ref$ignoreTooltipPoi = _ref.ignoreTooltipPointerEvents,
|
|
81
81
|
ignoreTooltipPointerEvents = _ref$ignoreTooltipPoi === void 0 ? false : _ref$ignoreTooltipPoi,
|
|
82
82
|
_ref$isScreenReaderAn = _ref.isScreenReaderAnnouncementDisabled,
|
|
83
|
-
isScreenReaderAnnouncementDisabled = _ref$isScreenReaderAn === void 0 ? false : _ref$isScreenReaderAn
|
|
83
|
+
isScreenReaderAnnouncementDisabled = _ref$isScreenReaderAn === void 0 ? false : _ref$isScreenReaderAn,
|
|
84
|
+
shortcut = _ref.shortcut;
|
|
84
85
|
var tooltipPosition = position === 'mouse' ? mousePosition : position;
|
|
85
86
|
var onShowHandler = usePlatformLeafSyntheticEventHandler(_objectSpread({
|
|
86
87
|
fn: onShow,
|
|
@@ -529,7 +530,8 @@ function Tooltip(_ref) {
|
|
|
529
530
|
placement: tooltipPosition,
|
|
530
531
|
testId: getReferenceElement() ? testId : testId && "".concat(testId, "--unresolved"),
|
|
531
532
|
onMouseOut: onMouseOut,
|
|
532
|
-
onMouseOver: onMouseOverTooltip
|
|
533
|
+
onMouseOver: onMouseOverTooltip,
|
|
534
|
+
shortcut: shortcut
|
|
533
535
|
}, typeof content === 'function' ? content({
|
|
534
536
|
update: update
|
|
535
537
|
}) : content);
|
|
@@ -15,6 +15,7 @@ export interface TooltipPrimitiveProps {
|
|
|
15
15
|
onMouseOver?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
16
16
|
onMouseOut?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
17
17
|
id?: string;
|
|
18
|
+
shortcut?: string[];
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* The lower level component for rendering a tooltip.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
type TooltipShortcutProps = {
|
|
6
|
+
shortcut: string[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* __Tooltip shortcut__
|
|
10
|
+
*
|
|
11
|
+
* An internal component that is used to display a keyboard shortcut within a tooltip, showing each key
|
|
12
|
+
* as a styled segment after the main tooltip content.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TooltipShortcut: ({ shortcut }: TooltipShortcutProps) => JSX.Element;
|
|
15
|
+
export {};
|
package/dist/types/tooltip.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ import { type TooltipProps } from './types';
|
|
|
5
5
|
*
|
|
6
6
|
* A tooltip is a floating, non-actionable label used to explain a user interface element or feature.
|
|
7
7
|
*/
|
|
8
|
-
declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, canAppear, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, ignoreTooltipPointerEvents, isScreenReaderAnnouncementDisabled, }: TooltipProps): React.JSX.Element;
|
|
8
|
+
declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, canAppear, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, ignoreTooltipPointerEvents, isScreenReaderAnnouncementDisabled, shortcut, }: TooltipProps): React.JSX.Element;
|
|
9
9
|
export default Tooltip;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -132,4 +132,12 @@ export interface TooltipProps {
|
|
|
132
132
|
* Use this to define the strategy of popper.
|
|
133
133
|
*/
|
|
134
134
|
strategy?: 'absolute' | 'fixed' | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Display a keyboard shortcut in the tooltip.
|
|
137
|
+
*
|
|
138
|
+
* Keys will be displayed as individual keyboard key segments after the tooltip content.
|
|
139
|
+
*
|
|
140
|
+
* This prop requires the `platform-dst-tooltip-shortcuts` feature flag to be enabled.
|
|
141
|
+
*/
|
|
142
|
+
shortcut?: string[];
|
|
135
143
|
}
|
|
@@ -15,6 +15,7 @@ export interface TooltipPrimitiveProps {
|
|
|
15
15
|
onMouseOver?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
16
16
|
onMouseOut?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
17
17
|
id?: string;
|
|
18
|
+
shortcut?: string[];
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* The lower level component for rendering a tooltip.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
type TooltipShortcutProps = {
|
|
6
|
+
shortcut: string[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* __Tooltip shortcut__
|
|
10
|
+
*
|
|
11
|
+
* An internal component that is used to display a keyboard shortcut within a tooltip, showing each key
|
|
12
|
+
* as a styled segment after the main tooltip content.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TooltipShortcut: ({ shortcut }: TooltipShortcutProps) => JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -5,5 +5,5 @@ import { type TooltipProps } from './types';
|
|
|
5
5
|
*
|
|
6
6
|
* A tooltip is a floating, non-actionable label used to explain a user interface element or feature.
|
|
7
7
|
*/
|
|
8
|
-
declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, canAppear, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, ignoreTooltipPointerEvents, isScreenReaderAnnouncementDisabled, }: TooltipProps): React.JSX.Element;
|
|
8
|
+
declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, canAppear, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, ignoreTooltipPointerEvents, isScreenReaderAnnouncementDisabled, shortcut, }: TooltipProps): React.JSX.Element;
|
|
9
9
|
export default Tooltip;
|
|
@@ -132,4 +132,12 @@ export interface TooltipProps {
|
|
|
132
132
|
* Use this to define the strategy of popper.
|
|
133
133
|
*/
|
|
134
134
|
strategy?: 'absolute' | 'fixed' | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Display a keyboard shortcut in the tooltip.
|
|
137
|
+
*
|
|
138
|
+
* Keys will be displayed as individual keyboard key segments after the tooltip content.
|
|
139
|
+
*
|
|
140
|
+
* This prop requires the `platform-dst-tooltip-shortcuts` feature flag to be enabled.
|
|
141
|
+
*/
|
|
142
|
+
shortcut?: string[];
|
|
135
143
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/tooltip",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.5.0",
|
|
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/"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@atlaskit/popper": "^7.1.0",
|
|
41
41
|
"@atlaskit/portal": "^5.1.0",
|
|
42
42
|
"@atlaskit/theme": "^21.0.0",
|
|
43
|
-
"@atlaskit/tokens": "^6.
|
|
43
|
+
"@atlaskit/tokens": "^6.4.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@compiled/react": "^0.18.3",
|
|
46
46
|
"bind-event-listener": "^3.0.0"
|
|
@@ -98,6 +98,9 @@
|
|
|
98
98
|
"type": "boolean",
|
|
99
99
|
"referenceOnly": true
|
|
100
100
|
},
|
|
101
|
+
"platform-dst-tooltip-shortcuts": {
|
|
102
|
+
"type": "boolean"
|
|
103
|
+
},
|
|
101
104
|
"should-render-to-parent-should-be-true-design-syst": {
|
|
102
105
|
"type": "boolean"
|
|
103
106
|
}
|