@cloudflare/component-tooltip 5.1.0 → 5.1.2
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 +13 -0
- package/es/Tooltip.js +27 -7
- package/index.d.ts +1 -0
- package/lib/Tooltip.js +31 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 5.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 028f888926: Updated Tooltip to support portaling to fix stacking context bug
|
|
8
|
+
|
|
9
|
+
## 5.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- db8427aad9: This changeset is in attempts to fix an issue with Tooltip KV registry where 5.1.0 didn't get the code it should have
|
|
14
|
+
|
|
3
15
|
## 5.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
6
18
|
|
|
7
19
|
- 0a4b7280c9: Fix bug where multiple tooltips on one page with delay do not dismiss correctly
|
|
20
|
+
- efc3f4a27d: Fix Tooltip to clear internal timers on unmount
|
|
8
21
|
|
|
9
22
|
## 5.0.0
|
|
10
23
|
|
package/es/Tooltip.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import { Button } from '@cloudflare/elements';
|
|
6
7
|
import { createComponent } from '@cloudflare/style-container';
|
|
@@ -68,6 +69,7 @@ class Tooltip extends React.PureComponent {
|
|
|
68
69
|
super(props);
|
|
69
70
|
this.id = uniqueId('cf_component_tooltip_');
|
|
70
71
|
this.escFunction = this.escFunction.bind(this);
|
|
72
|
+
this.delayTimer = null;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
escFunction(event) {
|
|
@@ -95,6 +97,7 @@ class Tooltip extends React.PureComponent {
|
|
|
95
97
|
document.removeEventListener('keydown', this.escFunction, {
|
|
96
98
|
capture: true
|
|
97
99
|
});
|
|
100
|
+
clearTimeout(this.delayTimer);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
render() {
|
|
@@ -116,11 +119,26 @@ class Tooltip extends React.PureComponent {
|
|
|
116
119
|
display,
|
|
117
120
|
ariaLabel,
|
|
118
121
|
Component = Button,
|
|
119
|
-
componentRef
|
|
122
|
+
componentRef,
|
|
123
|
+
portal = false
|
|
120
124
|
} = this.props;
|
|
121
125
|
var id = this.props.id ? this.props.id : this.id;
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, portal ? /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(ReactTooltip, {
|
|
127
|
+
id: id,
|
|
128
|
+
disable: disable,
|
|
129
|
+
place: place,
|
|
130
|
+
type: type,
|
|
131
|
+
effect: anchored ? 'solid' : 'float',
|
|
132
|
+
className: className,
|
|
133
|
+
isCapture: isCapture,
|
|
134
|
+
delayHide: delayHide ? delayHide : null,
|
|
135
|
+
afterShow: afterShow,
|
|
136
|
+
afterHide: afterHide,
|
|
137
|
+
getContent: [() => message || getContent()],
|
|
138
|
+
onClick: this.props.onClick,
|
|
139
|
+
event: "click",
|
|
140
|
+
role: "status"
|
|
141
|
+
}), document.body) : /*#__PURE__*/React.createElement(ReactTooltip, {
|
|
124
142
|
id: id,
|
|
125
143
|
disable: disable,
|
|
126
144
|
place: place,
|
|
@@ -162,7 +180,7 @@ class Tooltip extends React.PureComponent {
|
|
|
162
180
|
},
|
|
163
181
|
onMouseOver: () => {
|
|
164
182
|
if (delayShow) {
|
|
165
|
-
|
|
183
|
+
this.delayTimer = setTimeout(() => {
|
|
166
184
|
ReactTooltip.show(this.tooltipElement);
|
|
167
185
|
}, DELAY_SHOW_MILLIS);
|
|
168
186
|
} else {
|
|
@@ -170,7 +188,7 @@ class Tooltip extends React.PureComponent {
|
|
|
170
188
|
}
|
|
171
189
|
},
|
|
172
190
|
onMouseOut: () => {
|
|
173
|
-
clearTimeout(
|
|
191
|
+
clearTimeout(this.delayTimer);
|
|
174
192
|
ReactTooltip.hide(this.tooltipElement);
|
|
175
193
|
},
|
|
176
194
|
"aria-controls": id,
|
|
@@ -204,7 +222,8 @@ Tooltip.propTypes = {
|
|
|
204
222
|
Component: PropTypes.func,
|
|
205
223
|
// Allow the Component element to be referenced from a parent. innerRef
|
|
206
224
|
// is swallowed by createComponent.
|
|
207
|
-
componentRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
225
|
+
componentRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
226
|
+
portal: PropTypes.bool
|
|
208
227
|
};
|
|
209
228
|
Tooltip.defaultProps = {
|
|
210
229
|
disable: false,
|
|
@@ -213,7 +232,8 @@ Tooltip.defaultProps = {
|
|
|
213
232
|
anchored: true,
|
|
214
233
|
isCapture: true,
|
|
215
234
|
forceRebuild: false,
|
|
216
|
-
delayShow: true
|
|
235
|
+
delayShow: true,
|
|
236
|
+
portal: false
|
|
217
237
|
};
|
|
218
238
|
Tooltip.displayName = 'Tooltip';
|
|
219
239
|
export default createComponent(tooltipStyles, Tooltip);
|
package/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ interface TooltipProps extends React.CSSProperties, TfelaMProps {
|
|
|
21
21
|
buttonProps?: React.ComponentProps<typeof Button>;
|
|
22
22
|
Component?: React.ComponentType<any>;
|
|
23
23
|
componentRef?: React.Ref<HTMLElement>;
|
|
24
|
+
portal?: boolean;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export const Tooltip: React.FC<TooltipProps>;
|
package/lib/Tooltip.js
CHANGED
|
@@ -9,6 +9,8 @@ exports.tooltipStyles = exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
+
var _reactDom = require("react-dom");
|
|
13
|
+
|
|
12
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
15
|
|
|
14
16
|
var _elements = require("@cloudflare/elements");
|
|
@@ -113,6 +115,7 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
113
115
|
_this = _super.call(this, props);
|
|
114
116
|
_this.id = (0, _lodash.default)('cf_component_tooltip_');
|
|
115
117
|
_this.escFunction = _this.escFunction.bind(_assertThisInitialized(_this));
|
|
118
|
+
_this.delayTimer = null;
|
|
116
119
|
return _this;
|
|
117
120
|
}
|
|
118
121
|
|
|
@@ -151,6 +154,7 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
151
154
|
document.removeEventListener('keydown', this.escFunction, {
|
|
152
155
|
capture: true
|
|
153
156
|
});
|
|
157
|
+
clearTimeout(this.delayTimer);
|
|
154
158
|
}
|
|
155
159
|
}, {
|
|
156
160
|
key: "render",
|
|
@@ -176,10 +180,28 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
176
180
|
ariaLabel = _this$props.ariaLabel,
|
|
177
181
|
_this$props$Component = _this$props.Component,
|
|
178
182
|
Component = _this$props$Component === void 0 ? _elements.Button : _this$props$Component,
|
|
179
|
-
componentRef = _this$props.componentRef
|
|
183
|
+
componentRef = _this$props.componentRef,
|
|
184
|
+
_this$props$portal = _this$props.portal,
|
|
185
|
+
portal = _this$props$portal === void 0 ? false : _this$props$portal;
|
|
180
186
|
var id = this.props.id ? this.props.id : this.id;
|
|
181
|
-
|
|
182
|
-
|
|
187
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, portal ? /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react.default.createElement(_reactTooltip.default, {
|
|
188
|
+
id: id,
|
|
189
|
+
disable: disable,
|
|
190
|
+
place: place,
|
|
191
|
+
type: type,
|
|
192
|
+
effect: anchored ? 'solid' : 'float',
|
|
193
|
+
className: className,
|
|
194
|
+
isCapture: isCapture,
|
|
195
|
+
delayHide: delayHide ? delayHide : null,
|
|
196
|
+
afterShow: afterShow,
|
|
197
|
+
afterHide: afterHide,
|
|
198
|
+
getContent: [function () {
|
|
199
|
+
return message || getContent();
|
|
200
|
+
}],
|
|
201
|
+
onClick: this.props.onClick,
|
|
202
|
+
event: "click",
|
|
203
|
+
role: "status"
|
|
204
|
+
}), document.body) : /*#__PURE__*/_react.default.createElement(_reactTooltip.default, {
|
|
183
205
|
id: id,
|
|
184
206
|
disable: disable,
|
|
185
207
|
place: place,
|
|
@@ -227,7 +249,7 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
227
249
|
},
|
|
228
250
|
onMouseOver: function onMouseOver() {
|
|
229
251
|
if (delayShow) {
|
|
230
|
-
|
|
252
|
+
_this3.delayTimer = setTimeout(function () {
|
|
231
253
|
_reactTooltip.default.show(_this3.tooltipElement);
|
|
232
254
|
}, DELAY_SHOW_MILLIS);
|
|
233
255
|
} else {
|
|
@@ -235,7 +257,7 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
235
257
|
}
|
|
236
258
|
},
|
|
237
259
|
onMouseOut: function onMouseOut() {
|
|
238
|
-
clearTimeout(
|
|
260
|
+
clearTimeout(_this3.delayTimer);
|
|
239
261
|
|
|
240
262
|
_reactTooltip.default.hide(_this3.tooltipElement);
|
|
241
263
|
},
|
|
@@ -272,7 +294,8 @@ Tooltip.propTypes = {
|
|
|
272
294
|
Component: _propTypes.default.func,
|
|
273
295
|
// Allow the Component element to be referenced from a parent. innerRef
|
|
274
296
|
// is swallowed by createComponent.
|
|
275
|
-
componentRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
|
|
297
|
+
componentRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
298
|
+
portal: _propTypes.default.bool
|
|
276
299
|
};
|
|
277
300
|
Tooltip.defaultProps = {
|
|
278
301
|
disable: false,
|
|
@@ -281,7 +304,8 @@ Tooltip.defaultProps = {
|
|
|
281
304
|
anchored: true,
|
|
282
305
|
isCapture: true,
|
|
283
306
|
forceRebuild: false,
|
|
284
|
-
delayShow: true
|
|
307
|
+
delayShow: true,
|
|
308
|
+
portal: false
|
|
285
309
|
};
|
|
286
310
|
Tooltip.displayName = 'Tooltip';
|
|
287
311
|
|
package/package.json
CHANGED