@cloudflare/component-tooltip 4.7.4 → 5.1.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/es/Tooltip.js +19 -3
- package/index.d.ts +1 -0
- package/lib/Tooltip.js +17 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 5.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0a4b7280c9: Fix bug where multiple tooltips on one page with delay do not dismiss correctly
|
|
8
|
+
|
|
9
|
+
## 5.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- ecfb4b3712: Delays tooltip by default, adds option to show immediately
|
|
14
|
+
|
|
3
15
|
## 4.7.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/es/Tooltip.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Button } from '@cloudflare/elements';
|
|
|
6
6
|
import { createComponent } from '@cloudflare/style-container';
|
|
7
7
|
import ReactTooltip from 'react-tooltip';
|
|
8
8
|
import uniqueId from 'lodash.uniqueid';
|
|
9
|
+
var DELAY_SHOW_MILLIS = 400;
|
|
9
10
|
|
|
10
11
|
var getBackgroundColor = (theme, type) => {
|
|
11
12
|
if (type === 'dark') {
|
|
@@ -104,6 +105,7 @@ class Tooltip extends React.PureComponent {
|
|
|
104
105
|
children,
|
|
105
106
|
className,
|
|
106
107
|
delayHide,
|
|
108
|
+
delayShow,
|
|
107
109
|
afterHide,
|
|
108
110
|
afterShow,
|
|
109
111
|
getContent,
|
|
@@ -117,6 +119,7 @@ class Tooltip extends React.PureComponent {
|
|
|
117
119
|
componentRef
|
|
118
120
|
} = this.props;
|
|
119
121
|
var id = this.props.id ? this.props.id : this.id;
|
|
122
|
+
var timer;
|
|
120
123
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReactTooltip, {
|
|
121
124
|
id: id,
|
|
122
125
|
disable: disable,
|
|
@@ -157,8 +160,19 @@ class Tooltip extends React.PureComponent {
|
|
|
157
160
|
onClick: e => {
|
|
158
161
|
e.stopPropagation();
|
|
159
162
|
},
|
|
160
|
-
onMouseOver: () =>
|
|
161
|
-
|
|
163
|
+
onMouseOver: () => {
|
|
164
|
+
if (delayShow) {
|
|
165
|
+
timer = setTimeout(() => {
|
|
166
|
+
ReactTooltip.show(this.tooltipElement);
|
|
167
|
+
}, DELAY_SHOW_MILLIS);
|
|
168
|
+
} else {
|
|
169
|
+
ReactTooltip.show(this.tooltipElement);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
onMouseOut: () => {
|
|
173
|
+
clearTimeout(timer);
|
|
174
|
+
ReactTooltip.hide(this.tooltipElement);
|
|
175
|
+
},
|
|
162
176
|
"aria-controls": id,
|
|
163
177
|
"aria-label": ariaLabel,
|
|
164
178
|
"aria-describedby": id
|
|
@@ -178,6 +192,7 @@ Tooltip.propTypes = {
|
|
|
178
192
|
children: PropTypes.node,
|
|
179
193
|
disable: PropTypes.bool,
|
|
180
194
|
delayHide: PropTypes.number,
|
|
195
|
+
delayShow: PropTypes.bool,
|
|
181
196
|
afterHide: PropTypes.func,
|
|
182
197
|
afterShow: PropTypes.func,
|
|
183
198
|
buttonProps: PropTypes.object,
|
|
@@ -197,7 +212,8 @@ Tooltip.defaultProps = {
|
|
|
197
212
|
type: 'dark',
|
|
198
213
|
anchored: true,
|
|
199
214
|
isCapture: true,
|
|
200
|
-
forceRebuild: false
|
|
215
|
+
forceRebuild: false,
|
|
216
|
+
delayShow: true
|
|
201
217
|
};
|
|
202
218
|
Tooltip.displayName = 'Tooltip';
|
|
203
219
|
export default createComponent(tooltipStyles, Tooltip);
|
package/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ interface TooltipProps extends React.CSSProperties, TfelaMProps {
|
|
|
11
11
|
className?: string;
|
|
12
12
|
disable?: boolean;
|
|
13
13
|
delayHide?: number;
|
|
14
|
+
delayShow?: boolean;
|
|
14
15
|
afterHide?: (...args: any[]) => void;
|
|
15
16
|
afterShow?: (...args: any[]) => void;
|
|
16
17
|
getContent?: (...args: any[]) => void;
|
package/lib/Tooltip.js
CHANGED
|
@@ -43,6 +43,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
43
43
|
|
|
44
44
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
45
|
|
|
46
|
+
var DELAY_SHOW_MILLIS = 400;
|
|
47
|
+
|
|
46
48
|
var getBackgroundColor = function getBackgroundColor(theme, type) {
|
|
47
49
|
if (type === 'dark') {
|
|
48
50
|
return "".concat(theme.colors.gray[2], " !important");
|
|
@@ -162,6 +164,7 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
162
164
|
children = _this$props.children,
|
|
163
165
|
className = _this$props.className,
|
|
164
166
|
delayHide = _this$props.delayHide,
|
|
167
|
+
delayShow = _this$props.delayShow,
|
|
165
168
|
afterHide = _this$props.afterHide,
|
|
166
169
|
afterShow = _this$props.afterShow,
|
|
167
170
|
getContent = _this$props.getContent,
|
|
@@ -175,6 +178,7 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
175
178
|
Component = _this$props$Component === void 0 ? _elements.Button : _this$props$Component,
|
|
176
179
|
componentRef = _this$props.componentRef;
|
|
177
180
|
var id = this.props.id ? this.props.id : this.id;
|
|
181
|
+
var timer;
|
|
178
182
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactTooltip.default, {
|
|
179
183
|
id: id,
|
|
180
184
|
disable: disable,
|
|
@@ -222,10 +226,18 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
222
226
|
e.stopPropagation();
|
|
223
227
|
},
|
|
224
228
|
onMouseOver: function onMouseOver() {
|
|
225
|
-
|
|
229
|
+
if (delayShow) {
|
|
230
|
+
timer = setTimeout(function () {
|
|
231
|
+
_reactTooltip.default.show(_this3.tooltipElement);
|
|
232
|
+
}, DELAY_SHOW_MILLIS);
|
|
233
|
+
} else {
|
|
234
|
+
_reactTooltip.default.show(_this3.tooltipElement);
|
|
235
|
+
}
|
|
226
236
|
},
|
|
227
237
|
onMouseOut: function onMouseOut() {
|
|
228
|
-
|
|
238
|
+
clearTimeout(timer);
|
|
239
|
+
|
|
240
|
+
_reactTooltip.default.hide(_this3.tooltipElement);
|
|
229
241
|
},
|
|
230
242
|
"aria-controls": id,
|
|
231
243
|
"aria-label": ariaLabel,
|
|
@@ -248,6 +260,7 @@ Tooltip.propTypes = {
|
|
|
248
260
|
children: _propTypes.default.node,
|
|
249
261
|
disable: _propTypes.default.bool,
|
|
250
262
|
delayHide: _propTypes.default.number,
|
|
263
|
+
delayShow: _propTypes.default.bool,
|
|
251
264
|
afterHide: _propTypes.default.func,
|
|
252
265
|
afterShow: _propTypes.default.func,
|
|
253
266
|
buttonProps: _propTypes.default.object,
|
|
@@ -267,7 +280,8 @@ Tooltip.defaultProps = {
|
|
|
267
280
|
type: 'dark',
|
|
268
281
|
anchored: true,
|
|
269
282
|
isCapture: true,
|
|
270
|
-
forceRebuild: false
|
|
283
|
+
forceRebuild: false,
|
|
284
|
+
delayShow: true
|
|
271
285
|
};
|
|
272
286
|
Tooltip.displayName = 'Tooltip';
|
|
273
287
|
|
package/package.json
CHANGED