@cloudflare/component-tooltip 2.7.94 → 2.7.98
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 +32 -0
- package/es/Tooltip.js +34 -8
- package/lib/Tooltip.js +41 -8
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.7.98](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-tooltip@2.7.97...@cloudflare/component-tooltip@2.7.98) (2021-11-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @cloudflare/component-tooltip
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.7.97](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-tooltip@2.7.96...@cloudflare/component-tooltip@2.7.97) (2021-11-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @cloudflare/component-tooltip
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [2.7.96](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-tooltip@2.7.95...@cloudflare/component-tooltip@2.7.96) (2021-11-16)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @cloudflare/component-tooltip
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [2.7.95](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-tooltip@2.7.94...@cloudflare/component-tooltip@2.7.95) (2021-11-15)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @cloudflare/component-tooltip
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [2.7.94](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-tooltip@2.7.93...@cloudflare/component-tooltip@2.7.94) (2021-11-05)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @cloudflare/component-tooltip
|
package/es/Tooltip.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { Button } from '@cloudflare/elements';
|
|
4
4
|
import { createComponent } from '@cloudflare/style-container';
|
|
5
5
|
import ReactTooltip from 'react-tooltip';
|
|
6
6
|
import uniqueId from 'lodash.uniqueid';
|
|
@@ -61,6 +61,13 @@ class Tooltip extends React.PureComponent {
|
|
|
61
61
|
constructor(props) {
|
|
62
62
|
super(props);
|
|
63
63
|
this.id = uniqueId('cf_component_tooltip_');
|
|
64
|
+
this.escFunction = this.escFunction.bind(this);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
escFunction(event) {
|
|
68
|
+
if (event.key === 'Escape') {
|
|
69
|
+
ReactTooltip.hide(this.tooltipElement);
|
|
70
|
+
}
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
componentDidUpdate() {
|
|
@@ -72,6 +79,14 @@ class Tooltip extends React.PureComponent {
|
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
|
|
82
|
+
componentDidMount() {
|
|
83
|
+
document.addEventListener('keydown', this.escFunction);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
componentWillUnmount() {
|
|
87
|
+
document.removeEventListener('keydown', this.escFunction, false);
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
render() {
|
|
76
91
|
const _this$props = this.props,
|
|
77
92
|
disable = _this$props.disable,
|
|
@@ -92,7 +107,6 @@ class Tooltip extends React.PureComponent {
|
|
|
92
107
|
disable: disable,
|
|
93
108
|
place: place,
|
|
94
109
|
type: type,
|
|
95
|
-
role: "tooltip",
|
|
96
110
|
effect: anchored ? 'solid' : 'float',
|
|
97
111
|
className: className,
|
|
98
112
|
isCapture: isCapture,
|
|
@@ -100,15 +114,27 @@ class Tooltip extends React.PureComponent {
|
|
|
100
114
|
afterShow: afterShow,
|
|
101
115
|
afterHide: afterHide,
|
|
102
116
|
getContent: [() => message || getContent()],
|
|
103
|
-
onClick: this.props.onClick
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
onClick: this.props.onClick,
|
|
118
|
+
event: "click",
|
|
119
|
+
role: "status"
|
|
120
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
121
|
+
innerRef: ref => this.tooltipElement = ref,
|
|
108
122
|
display: "flex",
|
|
109
123
|
pointerEvents: "bounding-box",
|
|
110
124
|
"data-tip": true,
|
|
111
|
-
"data-for": id
|
|
125
|
+
"data-for": id,
|
|
126
|
+
type: "button",
|
|
127
|
+
onBlur: () => ReactTooltip.hide(this.tooltipElement),
|
|
128
|
+
style: {
|
|
129
|
+
cursor: 'pointer',
|
|
130
|
+
backgroundColor: 'transparent',
|
|
131
|
+
padding: 0
|
|
132
|
+
},
|
|
133
|
+
onClick: e => {
|
|
134
|
+
e.stopPropagation();
|
|
135
|
+
},
|
|
136
|
+
"data-toggletip-content": message,
|
|
137
|
+
"aria-controls": id
|
|
112
138
|
}, children));
|
|
113
139
|
}
|
|
114
140
|
|
package/lib/Tooltip.js
CHANGED
|
@@ -29,14 +29,14 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
29
29
|
|
|
30
30
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
31
31
|
|
|
32
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
|
-
|
|
34
32
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
33
|
|
|
36
34
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
37
35
|
|
|
38
36
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
37
|
|
|
38
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
|
+
|
|
40
40
|
var getBackgroundColor = function getBackgroundColor(theme, type) {
|
|
41
41
|
if (type === 'dark') {
|
|
42
42
|
return "".concat(theme.colors.gray[2], " !important");
|
|
@@ -102,10 +102,18 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
102
102
|
|
|
103
103
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Tooltip).call(this, props));
|
|
104
104
|
_this.id = (0, _lodash.default)('cf_component_tooltip_');
|
|
105
|
+
_this.escFunction = _this.escFunction.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
105
106
|
return _this;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
_createClass(Tooltip, [{
|
|
110
|
+
key: "escFunction",
|
|
111
|
+
value: function escFunction(event) {
|
|
112
|
+
if (event.key === 'Escape') {
|
|
113
|
+
_reactTooltip.default.hide(this.tooltipElement);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
109
117
|
key: "componentDidUpdate",
|
|
110
118
|
value: function componentDidUpdate() {
|
|
111
119
|
var _this2 = this;
|
|
@@ -120,6 +128,16 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
120
128
|
}, 0);
|
|
121
129
|
}
|
|
122
130
|
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "componentDidMount",
|
|
133
|
+
value: function componentDidMount() {
|
|
134
|
+
document.addEventListener('keydown', this.escFunction);
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "componentWillUnmount",
|
|
138
|
+
value: function componentWillUnmount() {
|
|
139
|
+
document.removeEventListener('keydown', this.escFunction, false);
|
|
140
|
+
}
|
|
123
141
|
}, {
|
|
124
142
|
key: "render",
|
|
125
143
|
value: function render() {
|
|
@@ -144,7 +162,6 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
144
162
|
disable: disable,
|
|
145
163
|
place: place,
|
|
146
164
|
type: type,
|
|
147
|
-
role: "tooltip",
|
|
148
165
|
effect: anchored ? 'solid' : 'float',
|
|
149
166
|
className: className,
|
|
150
167
|
isCapture: isCapture,
|
|
@@ -154,15 +171,31 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
154
171
|
getContent: [function () {
|
|
155
172
|
return message || getContent();
|
|
156
173
|
}],
|
|
157
|
-
onClick: this.props.onClick
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
174
|
+
onClick: this.props.onClick,
|
|
175
|
+
event: "click",
|
|
176
|
+
role: "status"
|
|
177
|
+
}), /*#__PURE__*/_react.default.createElement(_elements.Button, {
|
|
178
|
+
innerRef: function innerRef(ref) {
|
|
179
|
+
return _this3.tooltipElement = ref;
|
|
161
180
|
},
|
|
162
181
|
display: "flex",
|
|
163
182
|
pointerEvents: "bounding-box",
|
|
164
183
|
"data-tip": true,
|
|
165
|
-
"data-for": id
|
|
184
|
+
"data-for": id,
|
|
185
|
+
type: "button",
|
|
186
|
+
onBlur: function onBlur() {
|
|
187
|
+
return _reactTooltip.default.hide(_this3.tooltipElement);
|
|
188
|
+
},
|
|
189
|
+
style: {
|
|
190
|
+
cursor: 'pointer',
|
|
191
|
+
backgroundColor: 'transparent',
|
|
192
|
+
padding: 0
|
|
193
|
+
},
|
|
194
|
+
onClick: function onClick(e) {
|
|
195
|
+
e.stopPropagation();
|
|
196
|
+
},
|
|
197
|
+
"data-toggletip-content": message,
|
|
198
|
+
"aria-controls": id
|
|
166
199
|
}, children));
|
|
167
200
|
}
|
|
168
201
|
}]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/component-tooltip",
|
|
3
3
|
"description": "Cloudflare Tooltip Component",
|
|
4
|
-
"version": "2.7.
|
|
4
|
+
"version": "2.7.98",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"author": "James Kyle <jkyle@cloudflare.com>",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@cloudflare/elements": "^1.11.
|
|
15
|
-
"@cloudflare/style-container": "^7.5.
|
|
14
|
+
"@cloudflare/elements": "^1.11.29",
|
|
15
|
+
"@cloudflare/style-container": "^7.5.18",
|
|
16
16
|
"lodash.uniqueid": "^4.0.1",
|
|
17
17
|
"prop-types": "^15.6.0",
|
|
18
18
|
"react-tooltip": "^3.6.0"
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"test-coverage": "stratus test --coverage",
|
|
32
32
|
"test-watch": "stratus test --watch"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "bb34cec56437707d31526523737f182760b71482"
|
|
35
35
|
}
|