@cloudflare/component-tooltip 4.3.2 → 4.4.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0aee17e0c6: Add Component prop to enable elements to be used in place of a button, display tooltip on focus
8
+
3
9
  ## 4.3.2
4
10
 
5
11
  ### Patch Changes
package/es/Tooltip.js CHANGED
@@ -112,7 +112,8 @@ class Tooltip extends React.PureComponent {
112
112
  buttonProps,
113
113
  isCapture,
114
114
  display,
115
- ariaLabel
115
+ ariaLabel,
116
+ Component = Button
116
117
  } = this.props;
117
118
  var id = this.props.id ? this.props.id : this.id;
118
119
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReactTooltip, {
@@ -130,7 +131,7 @@ class Tooltip extends React.PureComponent {
130
131
  onClick: this.props.onClick,
131
132
  event: "click",
132
133
  role: "status"
133
- }), /*#__PURE__*/React.createElement(Button, _extends({
134
+ }), /*#__PURE__*/React.createElement(Component, _extends({
134
135
  innerRef: ref => this.tooltipElement = ref,
135
136
  display: display ? display : 'flex',
136
137
  pointerEvents: "bounding-box",
@@ -141,6 +142,7 @@ class Tooltip extends React.PureComponent {
141
142
  "data-tip": true,
142
143
  "data-for": id,
143
144
  type: "button",
145
+ onFocus: () => ReactTooltip.show(this.tooltipElement),
144
146
  onBlur: () => ReactTooltip.hide(this.tooltipElement),
145
147
  color: "gray.1",
146
148
  onClick: e => {
@@ -173,7 +175,8 @@ Tooltip.propTypes = {
173
175
  forceRebuild: PropTypes.bool,
174
176
  onClick: PropTypes.func,
175
177
  display: PropTypes.string,
176
- ariaLabel: PropTypes.string
178
+ ariaLabel: PropTypes.string,
179
+ Component: PropTypes.func
177
180
  };
178
181
  Tooltip.defaultProps = {
179
182
  disable: false,
package/index.d.ts CHANGED
@@ -18,6 +18,7 @@ interface TooltipProps extends React.CSSProperties, TfelaMProps {
18
18
  onClick?: (...args: any[]) => void;
19
19
  ariaLabel?: string;
20
20
  buttonProps?: React.ComponentProps<typeof Button>;
21
+ Component?: React.ComponentType<any>;
21
22
  }
22
23
 
23
24
  export const Tooltip: React.FC<TooltipProps>;
package/lib/Tooltip.js CHANGED
@@ -170,7 +170,9 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
170
170
  buttonProps = _this$props.buttonProps,
171
171
  isCapture = _this$props.isCapture,
172
172
  display = _this$props.display,
173
- ariaLabel = _this$props.ariaLabel;
173
+ ariaLabel = _this$props.ariaLabel,
174
+ _this$props$Component = _this$props.Component,
175
+ Component = _this$props$Component === void 0 ? _elements.Button : _this$props$Component;
174
176
  var id = this.props.id ? this.props.id : this.id;
175
177
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactTooltip.default, {
176
178
  id: id,
@@ -189,7 +191,7 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
189
191
  onClick: this.props.onClick,
190
192
  event: "click",
191
193
  role: "status"
192
- }), /*#__PURE__*/_react.default.createElement(_elements.Button, _extends({
194
+ }), /*#__PURE__*/_react.default.createElement(Component, _extends({
193
195
  innerRef: function innerRef(ref) {
194
196
  return _this3.tooltipElement = ref;
195
197
  },
@@ -202,6 +204,9 @@ var Tooltip = /*#__PURE__*/function (_React$PureComponent) {
202
204
  "data-tip": true,
203
205
  "data-for": id,
204
206
  type: "button",
207
+ onFocus: function onFocus() {
208
+ return _reactTooltip.default.show(_this3.tooltipElement);
209
+ },
205
210
  onBlur: function onBlur() {
206
211
  return _reactTooltip.default.hide(_this3.tooltipElement);
207
212
  },
@@ -242,7 +247,8 @@ Tooltip.propTypes = {
242
247
  forceRebuild: _propTypes.default.bool,
243
248
  onClick: _propTypes.default.func,
244
249
  display: _propTypes.default.string,
245
- ariaLabel: _propTypes.default.string
250
+ ariaLabel: _propTypes.default.string,
251
+ Component: _propTypes.default.func
246
252
  };
247
253
  Tooltip.defaultProps = {
248
254
  disable: false,
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.3.2",
4
+ "version": "4.4.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
7
7
  "author": "James Kyle <jkyle@cloudflare.com>",