@cloudflare/component-tooltip 4.6.0 → 4.7.1

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 25bc2ee144: add aria-describedby to read tooltip content on screen readers
8
+
9
+ ## 4.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - a715507f6a: Revert tooltip changes
14
+
3
15
  ## 4.6.0
4
16
 
5
17
  ### Minor Changes
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 { Tooltip as ReactTooltip } from 'react-tooltip';
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
- variant: type,
129
- float: !anchored,
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
- content: message || getContent(),
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),
@@ -169,7 +160,8 @@ class Tooltip extends React.PureComponent {
169
160
  onMouseOver: () => ReactTooltip.show(this.tooltipElement),
170
161
  onMouseOut: () => ReactTooltip.hide(this.tooltipElement),
171
162
  "aria-controls": id,
172
- "aria-label": ariaLabel
163
+ "aria-label": ariaLabel,
164
+ "aria-describedby": id
173
165
  }, buttonProps), children));
174
166
  }
175
167
 
@@ -197,11 +189,7 @@ Tooltip.propTypes = {
197
189
  Component: PropTypes.func,
198
190
  // Allow the Component element to be referenced from a parent. innerRef
199
191
  // 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
192
+ componentRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
205
193
  };
206
194
  Tooltip.defaultProps = {
207
195
  disable: false,
@@ -209,9 +197,7 @@ Tooltip.defaultProps = {
209
197
  type: 'dark',
210
198
  anchored: true,
211
199
  isCapture: true,
212
- forceRebuild: false,
213
- clickable: true,
214
- noArrow: false
200
+ forceRebuild: false
215
201
  };
216
202
  Tooltip.displayName = 'Tooltip';
217
203
  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.Tooltip.hide(this.tooltipElement);
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.Tooltip.hide(this.tooltipElement);
132
+ _reactTooltip.default.hide(this.tooltipElement);
133
133
 
134
134
  setTimeout(function () {
135
- return _reactTooltip.Tooltip.show(_this2.tooltipElement);
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.Tooltip, {
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
- variant: type,
187
- float: !anchored,
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
- content: message || getContent(),
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,26 +210,26 @@ 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.Tooltip.show(_this3.tooltipElement);
215
+ return _reactTooltip.default.show(_this3.tooltipElement);
223
216
  },
224
217
  onBlur: function onBlur() {
225
- return _reactTooltip.Tooltip.hide(_this3.tooltipElement);
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.Tooltip.show(_this3.tooltipElement);
225
+ return _reactTooltip.default.show(_this3.tooltipElement);
233
226
  },
234
227
  onMouseOut: function onMouseOut() {
235
- return _reactTooltip.Tooltip.hide(_this3.tooltipElement);
228
+ return _reactTooltip.default.hide(_this3.tooltipElement);
236
229
  },
237
230
  "aria-controls": id,
238
- "aria-label": ariaLabel
231
+ "aria-label": ariaLabel,
232
+ "aria-describedby": id
239
233
  }, buttonProps), children));
240
234
  }
241
235
  }]);
@@ -265,11 +259,7 @@ Tooltip.propTypes = {
265
259
  Component: _propTypes.default.func,
266
260
  // Allow the Component element to be referenced from a parent. innerRef
267
261
  // 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
262
+ componentRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
273
263
  };
274
264
  Tooltip.defaultProps = {
275
265
  disable: false,
@@ -277,9 +267,7 @@ Tooltip.defaultProps = {
277
267
  type: 'dark',
278
268
  anchored: true,
279
269
  isCapture: true,
280
- forceRebuild: false,
281
- clickable: true,
282
- noArrow: false
270
+ forceRebuild: false
283
271
  };
284
272
  Tooltip.displayName = 'Tooltip';
285
273
 
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.6.0",
4
+ "version": "4.7.1",
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": "^5.26.3"
18
+ "react-tooltip": "^3.11.6"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "@cloudflare/style-const": "^5.7.2",