@cloudflare/component-tooltip 4.6.0 → 4.7.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 +6 -0
- package/es/Tooltip.js +8 -23
- package/index.d.ts +0 -4
- package/lib/Tooltip.js +18 -31
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/es/Tooltip.js
CHANGED
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { Button } from '@cloudflare/elements';
|
|
6
6
|
import { createComponent } from '@cloudflare/style-container';
|
|
7
|
-
import
|
|
7
|
+
import ReactTooltip from 'react-tooltip';
|
|
8
8
|
import uniqueId from 'lodash.uniqueid';
|
|
9
9
|
|
|
10
10
|
var getBackgroundColor = (theme, type) => {
|
|
@@ -114,32 +114,24 @@ class Tooltip extends React.PureComponent {
|
|
|
114
114
|
display,
|
|
115
115
|
ariaLabel,
|
|
116
116
|
Component = Button,
|
|
117
|
-
componentRef
|
|
118
|
-
clickable,
|
|
119
|
-
noArrow,
|
|
120
|
-
border,
|
|
121
|
-
style
|
|
117
|
+
componentRef
|
|
122
118
|
} = this.props;
|
|
123
119
|
var id = this.props.id ? this.props.id : this.id;
|
|
124
120
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReactTooltip, {
|
|
125
121
|
id: id,
|
|
126
122
|
disable: disable,
|
|
127
123
|
place: place,
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
type: type,
|
|
125
|
+
effect: anchored ? 'solid' : 'float',
|
|
130
126
|
className: className,
|
|
131
|
-
border: border,
|
|
132
|
-
style: style,
|
|
133
127
|
isCapture: isCapture,
|
|
134
128
|
delayHide: delayHide ? delayHide : null,
|
|
135
129
|
afterShow: afterShow,
|
|
136
130
|
afterHide: afterHide,
|
|
137
|
-
|
|
131
|
+
getContent: [() => message || getContent()],
|
|
138
132
|
onClick: this.props.onClick,
|
|
139
133
|
event: "click",
|
|
140
|
-
role: "status"
|
|
141
|
-
clickable: clickable,
|
|
142
|
-
noArrow: noArrow
|
|
134
|
+
role: "status"
|
|
143
135
|
}), /*#__PURE__*/React.createElement(Component, _extends({
|
|
144
136
|
innerRef: ref => {
|
|
145
137
|
this.tooltipElement = ref;
|
|
@@ -158,7 +150,6 @@ class Tooltip extends React.PureComponent {
|
|
|
158
150
|
borderWidth: 0,
|
|
159
151
|
"data-tip": true,
|
|
160
152
|
"data-for": id,
|
|
161
|
-
"data-tooltip-id": id,
|
|
162
153
|
type: "button",
|
|
163
154
|
onFocus: () => ReactTooltip.show(this.tooltipElement),
|
|
164
155
|
onBlur: () => ReactTooltip.hide(this.tooltipElement),
|
|
@@ -197,11 +188,7 @@ Tooltip.propTypes = {
|
|
|
197
188
|
Component: PropTypes.func,
|
|
198
189
|
// Allow the Component element to be referenced from a parent. innerRef
|
|
199
190
|
// is swallowed by createComponent.
|
|
200
|
-
componentRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
201
|
-
clickable: PropTypes.bool,
|
|
202
|
-
noArrow: PropTypes.bool,
|
|
203
|
-
border: PropTypes.string,
|
|
204
|
-
style: PropTypes.any
|
|
191
|
+
componentRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
205
192
|
};
|
|
206
193
|
Tooltip.defaultProps = {
|
|
207
194
|
disable: false,
|
|
@@ -209,9 +196,7 @@ Tooltip.defaultProps = {
|
|
|
209
196
|
type: 'dark',
|
|
210
197
|
anchored: true,
|
|
211
198
|
isCapture: true,
|
|
212
|
-
forceRebuild: false
|
|
213
|
-
clickable: true,
|
|
214
|
-
noArrow: false
|
|
199
|
+
forceRebuild: false
|
|
215
200
|
};
|
|
216
201
|
Tooltip.displayName = 'Tooltip';
|
|
217
202
|
export default createComponent(tooltipStyles, Tooltip);
|
package/index.d.ts
CHANGED
|
@@ -20,10 +20,6 @@ interface TooltipProps extends React.CSSProperties, TfelaMProps {
|
|
|
20
20
|
buttonProps?: React.ComponentProps<typeof Button>;
|
|
21
21
|
Component?: React.ComponentType<any>;
|
|
22
22
|
componentRef?: React.Ref<HTMLElement>;
|
|
23
|
-
clickable?: boolean;
|
|
24
|
-
noArrow?: boolean;
|
|
25
|
-
border?: string;
|
|
26
|
-
style?: any;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
export const Tooltip: React.FC<TooltipProps>;
|
package/lib/Tooltip.js
CHANGED
|
@@ -15,7 +15,7 @@ var _elements = require("@cloudflare/elements");
|
|
|
15
15
|
|
|
16
16
|
var _styleContainer = require("@cloudflare/style-container");
|
|
17
17
|
|
|
18
|
-
var _reactTooltip = require("react-tooltip");
|
|
18
|
+
var _reactTooltip = _interopRequireDefault(require("react-tooltip"));
|
|
19
19
|
|
|
20
20
|
var _lodash = _interopRequireDefault(require("lodash.uniqueid"));
|
|
21
21
|
|
|
@@ -118,7 +118,7 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
118
118
|
key: "escFunction",
|
|
119
119
|
value: function escFunction(event) {
|
|
120
120
|
if (event.key === 'Escape') {
|
|
121
|
-
_reactTooltip.
|
|
121
|
+
_reactTooltip.default.hide(this.tooltipElement);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}, {
|
|
@@ -129,10 +129,10 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
129
129
|
// full rebuild is required when tooltip is already displayed
|
|
130
130
|
// but we changed type of position of the tooltip
|
|
131
131
|
if (this.props.forceRebuild) {
|
|
132
|
-
_reactTooltip.
|
|
132
|
+
_reactTooltip.default.hide(this.tooltipElement);
|
|
133
133
|
|
|
134
134
|
setTimeout(function () {
|
|
135
|
-
return _reactTooltip.
|
|
135
|
+
return _reactTooltip.default.show(_this2.tooltipElement);
|
|
136
136
|
}, 0);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -173,31 +173,25 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
173
173
|
ariaLabel = _this$props.ariaLabel,
|
|
174
174
|
_this$props$Component = _this$props.Component,
|
|
175
175
|
Component = _this$props$Component === void 0 ? _elements.Button : _this$props$Component,
|
|
176
|
-
componentRef = _this$props.componentRef
|
|
177
|
-
clickable = _this$props.clickable,
|
|
178
|
-
noArrow = _this$props.noArrow,
|
|
179
|
-
border = _this$props.border,
|
|
180
|
-
style = _this$props.style;
|
|
176
|
+
componentRef = _this$props.componentRef;
|
|
181
177
|
var id = this.props.id ? this.props.id : this.id;
|
|
182
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactTooltip.
|
|
178
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactTooltip.default, {
|
|
183
179
|
id: id,
|
|
184
180
|
disable: disable,
|
|
185
181
|
place: place,
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
type: type,
|
|
183
|
+
effect: anchored ? 'solid' : 'float',
|
|
188
184
|
className: className,
|
|
189
|
-
border: border,
|
|
190
|
-
style: style,
|
|
191
185
|
isCapture: isCapture,
|
|
192
186
|
delayHide: delayHide ? delayHide : null,
|
|
193
187
|
afterShow: afterShow,
|
|
194
188
|
afterHide: afterHide,
|
|
195
|
-
|
|
189
|
+
getContent: [function () {
|
|
190
|
+
return message || getContent();
|
|
191
|
+
}],
|
|
196
192
|
onClick: this.props.onClick,
|
|
197
193
|
event: "click",
|
|
198
|
-
role: "status"
|
|
199
|
-
clickable: clickable,
|
|
200
|
-
noArrow: noArrow
|
|
194
|
+
role: "status"
|
|
201
195
|
}), /*#__PURE__*/_react.default.createElement(Component, _extends({
|
|
202
196
|
innerRef: function innerRef(ref) {
|
|
203
197
|
_this3.tooltipElement = ref;
|
|
@@ -216,23 +210,22 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
216
210
|
borderWidth: 0,
|
|
217
211
|
"data-tip": true,
|
|
218
212
|
"data-for": id,
|
|
219
|
-
"data-tooltip-id": id,
|
|
220
213
|
type: "button",
|
|
221
214
|
onFocus: function onFocus() {
|
|
222
|
-
return _reactTooltip.
|
|
215
|
+
return _reactTooltip.default.show(_this3.tooltipElement);
|
|
223
216
|
},
|
|
224
217
|
onBlur: function onBlur() {
|
|
225
|
-
return _reactTooltip.
|
|
218
|
+
return _reactTooltip.default.hide(_this3.tooltipElement);
|
|
226
219
|
},
|
|
227
220
|
color: "gray.1",
|
|
228
221
|
onClick: function onClick(e) {
|
|
229
222
|
e.stopPropagation();
|
|
230
223
|
},
|
|
231
224
|
onMouseOver: function onMouseOver() {
|
|
232
|
-
return _reactTooltip.
|
|
225
|
+
return _reactTooltip.default.show(_this3.tooltipElement);
|
|
233
226
|
},
|
|
234
227
|
onMouseOut: function onMouseOut() {
|
|
235
|
-
return _reactTooltip.
|
|
228
|
+
return _reactTooltip.default.hide(_this3.tooltipElement);
|
|
236
229
|
},
|
|
237
230
|
"aria-controls": id,
|
|
238
231
|
"aria-label": ariaLabel
|
|
@@ -265,11 +258,7 @@ Tooltip.propTypes = {
|
|
|
265
258
|
Component: _propTypes.default.func,
|
|
266
259
|
// Allow the Component element to be referenced from a parent. innerRef
|
|
267
260
|
// is swallowed by createComponent.
|
|
268
|
-
componentRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
|
|
269
|
-
clickable: _propTypes.default.bool,
|
|
270
|
-
noArrow: _propTypes.default.bool,
|
|
271
|
-
border: _propTypes.default.string,
|
|
272
|
-
style: _propTypes.default.any
|
|
261
|
+
componentRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
|
|
273
262
|
};
|
|
274
263
|
Tooltip.defaultProps = {
|
|
275
264
|
disable: false,
|
|
@@ -277,9 +266,7 @@ Tooltip.defaultProps = {
|
|
|
277
266
|
type: 'dark',
|
|
278
267
|
anchored: true,
|
|
279
268
|
isCapture: true,
|
|
280
|
-
forceRebuild: false
|
|
281
|
-
clickable: true,
|
|
282
|
-
noArrow: false
|
|
269
|
+
forceRebuild: false
|
|
283
270
|
};
|
|
284
271
|
Tooltip.displayName = 'Tooltip';
|
|
285
272
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/component-tooltip",
|
|
3
3
|
"description": "Cloudflare Tooltip Component",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.7.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"author": "James Kyle <jkyle@cloudflare.com>",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@cloudflare/elements": "^3.0.5",
|
|
16
16
|
"lodash.uniqueid": "^4.0.1",
|
|
17
17
|
"prop-types": "^15.6.0",
|
|
18
|
-
"react-tooltip": "^
|
|
18
|
+
"react-tooltip": "^3.11.6"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"@cloudflare/style-const": "^5.7.2",
|