@instructure/ui-tooltip 8.14.0 → 8.14.1-snapshot.7

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/LICENSE.md ADDED
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: The MIT License (MIT)
3
+ category: Getting Started
4
+ order: 9
5
+ ---
6
+
7
+ # The MIT License (MIT)
8
+
9
+ Copyright (c) 2015 Instructure, Inc.
10
+
11
+ **Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions.**
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -22,7 +22,8 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import { locator } from '@instructure/ui-test-locator';
25
- import { parseQueryArguments } from '@instructure/ui-test-queries'; // eslint-disable-next-line no-restricted-imports
25
+ import { parseQueryArguments } from '@instructure/ui-test-queries'; // @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
26
+ // eslint-disable-next-line no-restricted-imports
26
27
 
27
28
  import { PopoverLocator } from '@instructure/ui-popover/es/Popover/PopoverLocator';
28
29
  import { Tooltip } from './index';
@@ -41,5 +42,6 @@ export const customMethods = {
41
42
 
42
43
  return PopoverLocator.findContent(element, '[role="tooltip"]', options);
43
44
  }
44
- };
45
+ }; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
46
+
45
47
  export const TooltipLocator = locator(Tooltip.selector, customMethods);
@@ -41,32 +41,35 @@ import { allowedProps, propTypes } from './props';
41
41
  ---
42
42
  category: components
43
43
  ---
44
+ @tsProps
44
45
  **/
45
46
 
46
47
  let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Tooltip extends Component {
47
- constructor() {
48
- super(...arguments);
49
- this._id = uid('Tooltip');
50
- this.state = {
51
- hasFocus: false
52
- };
48
+ constructor(props) {
49
+ super(props);
50
+ this._id = void 0;
53
51
  this.ref = null;
54
52
 
55
53
  this.handleRef = el => {
56
54
  this.ref = el;
57
55
  };
58
56
 
59
- this.handleFocus = event => {
57
+ this.handleFocus = () => {
60
58
  this.setState({
61
59
  hasFocus: true
62
60
  });
63
61
  };
64
62
 
65
- this.handleBlur = event => {
63
+ this.handleBlur = () => {
66
64
  this.setState({
67
65
  hasFocus: false
68
66
  });
69
67
  };
68
+
69
+ this._id = uid('Tooltip');
70
+ this.state = {
71
+ hasFocus: false
72
+ };
70
73
  }
71
74
 
72
75
  componentDidMount() {
@@ -75,16 +78,16 @@ let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
75
78
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
76
79
  }
77
80
 
78
- componentDidUpdate(prevProps, prevState, snapshot) {
81
+ componentDidUpdate() {
79
82
  var _this$props$makeStyle2, _this$props2;
80
83
 
81
84
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
82
85
  }
83
86
 
84
87
  renderTrigger() {
85
- const _this$props3 = this.props,
86
- children = _this$props3.children,
87
- as = _this$props3.as;
88
+ const _ref = this.props,
89
+ children = _ref.children,
90
+ as = _ref.as;
88
91
  const hasFocus = this.state.hasFocus;
89
92
  const triggerProps = {
90
93
  'aria-describedby': this._id
@@ -95,7 +98,6 @@ let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
95
98
  const props = omitProps(this.props, Tooltip.allowedProps);
96
99
  return jsx(Trigger, Object.assign({}, props, triggerProps), children);
97
100
  } else if (typeof children === 'function') {
98
- // TODO: try to remove cast when typing Tooltip (React children types are badly calculated)
99
101
  return children({
100
102
  focused: hasFocus,
101
103
  getTriggerProps: props => ({ ...triggerProps,
@@ -103,27 +105,27 @@ let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
103
105
  })
104
106
  });
105
107
  } else {
106
- return ensureSingleChild(this.props.children, triggerProps);
108
+ return ensureSingleChild(children, triggerProps);
107
109
  }
108
110
  }
109
111
 
110
112
  render() {
111
- const _this$props4 = this.props,
112
- renderTip = _this$props4.renderTip,
113
- isShowingContent = _this$props4.isShowingContent,
114
- defaultIsShowingContent = _this$props4.defaultIsShowingContent,
115
- on = _this$props4.on,
116
- color = _this$props4.color,
117
- placement = _this$props4.placement,
118
- mountNode = _this$props4.mountNode,
119
- constrain = _this$props4.constrain,
120
- offsetX = _this$props4.offsetX,
121
- offsetY = _this$props4.offsetY,
122
- positionTarget = _this$props4.positionTarget,
123
- onShowContent = _this$props4.onShowContent,
124
- onHideContent = _this$props4.onHideContent,
125
- styles = _this$props4.styles,
126
- rest = _objectWithoutProperties(_this$props4, _excluded);
113
+ const _this$props3 = this.props,
114
+ renderTip = _this$props3.renderTip,
115
+ isShowingContent = _this$props3.isShowingContent,
116
+ defaultIsShowingContent = _this$props3.defaultIsShowingContent,
117
+ on = _this$props3.on,
118
+ color = _this$props3.color,
119
+ placement = _this$props3.placement,
120
+ mountNode = _this$props3.mountNode,
121
+ constrain = _this$props3.constrain,
122
+ offsetX = _this$props3.offsetX,
123
+ offsetY = _this$props3.offsetY,
124
+ positionTarget = _this$props3.positionTarget,
125
+ onShowContent = _this$props3.onShowContent,
126
+ onHideContent = _this$props3.onHideContent,
127
+ styles = _this$props3.styles,
128
+ rest = _objectWithoutProperties(_this$props3, _excluded);
127
129
 
128
130
  return jsx(Popover, Object.assign({}, passthroughProps(rest), {
129
131
  isShowingContent: isShowingContent,
@@ -156,14 +158,9 @@ let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
156
158
  defaultIsShowingContent: false,
157
159
  color: 'primary',
158
160
  placement: 'top',
159
- mountNode: null,
160
161
  constrain: 'window',
161
162
  offsetX: 0,
162
- offsetY: 0,
163
- onShowContent: event => {},
164
- onHideContent: (event, _ref) => {
165
- let documentClick = _ref.documentClick;
166
- }
163
+ offsetY: 0
167
164
  }, _temp)) || _class) || _class);
168
165
  export default Tooltip;
169
166
  export { Tooltip };
@@ -25,90 +25,21 @@ import PropTypes from 'prop-types';
25
25
  import { PositionPropTypes } from '@instructure/ui-position';
26
26
  import { element } from '@instructure/ui-prop-types';
27
27
  const propTypes = {
28
- /**
29
- * @param {Object} renderProps
30
- * @param {Boolean} renderProps.focused - Is the Tooltip trigger focused?
31
- * @param {Function} renderProps.getTriggerProps - Props to be spread onto the trigger element
32
- */
33
28
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
34
-
35
- /**
36
- * The content to render in the tooltip
37
- */
38
29
  renderTip: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
39
-
40
- /**
41
- * Whether or not the tooltip content is shown, when controlled
42
- */
43
30
  isShowingContent: PropTypes.bool,
44
-
45
- /**
46
- * Whether or not to show the content by default, when uncontrolled
47
- */
48
31
  defaultIsShowingContent: PropTypes.bool,
49
-
50
- /**
51
- * the element type to render as (assumes a single child if 'as' is undefined)
52
- */
53
32
  as: PropTypes.elementType,
54
33
  // eslint-disable-line react/require-default-props
55
-
56
- /**
57
- * The action that causes the Content to display (`click`, `hover`, `focus`)
58
- */
59
34
  on: PropTypes.oneOfType([PropTypes.oneOf(['click', 'hover', 'focus']), PropTypes.arrayOf(PropTypes.oneOf(['click', 'hover', 'focus']))]),
60
-
61
- /**
62
- * The color of the tooltip content
63
- */
64
35
  color: PropTypes.oneOf(['primary', 'primary-inverse']),
65
-
66
- /**
67
- * Specifies where the Tooltip will be placed in relation to the target element.
68
- * Ex. placement="bottom" will render the Tooltip below the triggering element
69
- * (Note: if there is not room, it will position opposite. Ex. "top" will
70
- * automatically switch to "bottom")
71
- */
72
36
  placement: PositionPropTypes.placement,
73
-
74
- /**
75
- * An element or a function returning an element to use as the mount node
76
- * for the `<Tooltip />` (defaults to `document.body`)
77
- */
78
37
  mountNode: PositionPropTypes.mountNode,
79
-
80
- /**
81
- * The parent in which to constrain the tooltip.
82
- * One of: 'window', 'scroll-parent', 'parent', 'none', an element,
83
- * or a function returning an element
84
- */
85
38
  constrain: PositionPropTypes.constrain,
86
-
87
- /**
88
- * The horizontal offset for the positioned content
89
- */
90
39
  offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
91
-
92
- /**
93
- * The vertical offset for the positioned content
94
- */
95
40
  offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
96
-
97
- /**
98
- * Target element for positioning the Tooltip (if it differs from children/trigger)
99
- */
100
41
  positionTarget: PropTypes.oneOfType([element, PropTypes.func]),
101
-
102
- /**
103
- * Callback fired when content is shown. When controlled, this callback is
104
- * fired when the tooltip expects to be shown
105
- */
106
42
  onShowContent: PropTypes.func,
107
-
108
- /**
109
- * Callback fired when content is hidden. When controlled, this callback is
110
- * fired when the tooltip expects to be hidden
111
- */
112
43
  onHideContent: PropTypes.func
113
44
  };
114
45
  const allowedProps = ['children', 'renderTip', 'isShowingContent', 'defaultIsShowingContent', 'as', 'on', 'color', 'placement', 'mountNode', 'constrain', 'offsetX', 'offsetY', 'positionTarget', 'onShowContent', 'onHideContent'];
@@ -36,6 +36,7 @@ var _index = require("./index");
36
36
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
37
  * SOFTWARE.
38
38
  */
39
+ // @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
39
40
  // eslint-disable-next-line no-restricted-imports
40
41
  const customMethods = {
41
42
  findTrigger: function () {
@@ -52,7 +53,8 @@ const customMethods = {
52
53
 
53
54
  return _PopoverLocator.PopoverLocator.findContent(element, '[role="tooltip"]', options);
54
55
  }
55
- };
56
+ }; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
57
+
56
58
  exports.customMethods = customMethods;
57
59
  const TooltipLocator = (0, _locator.locator)(_index.Tooltip.selector, customMethods);
58
60
  exports.TooltipLocator = TooltipLocator;
@@ -43,31 +43,34 @@ var _dec, _dec2, _class, _class2, _temp;
43
43
  ---
44
44
  category: components
45
45
  ---
46
+ @tsProps
46
47
  **/
47
48
  let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class Tooltip extends _react.Component {
48
- constructor() {
49
- super(...arguments);
50
- this._id = (0, _uid.uid)('Tooltip');
51
- this.state = {
52
- hasFocus: false
53
- };
49
+ constructor(props) {
50
+ super(props);
51
+ this._id = void 0;
54
52
  this.ref = null;
55
53
 
56
54
  this.handleRef = el => {
57
55
  this.ref = el;
58
56
  };
59
57
 
60
- this.handleFocus = event => {
58
+ this.handleFocus = () => {
61
59
  this.setState({
62
60
  hasFocus: true
63
61
  });
64
62
  };
65
63
 
66
- this.handleBlur = event => {
64
+ this.handleBlur = () => {
67
65
  this.setState({
68
66
  hasFocus: false
69
67
  });
70
68
  };
69
+
70
+ this._id = (0, _uid.uid)('Tooltip');
71
+ this.state = {
72
+ hasFocus: false
73
+ };
71
74
  }
72
75
 
73
76
  componentDidMount() {
@@ -76,16 +79,16 @@ let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
76
79
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
77
80
  }
78
81
 
79
- componentDidUpdate(prevProps, prevState, snapshot) {
82
+ componentDidUpdate() {
80
83
  var _this$props$makeStyle2, _this$props2;
81
84
 
82
85
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
83
86
  }
84
87
 
85
88
  renderTrigger() {
86
- const _this$props3 = this.props,
87
- children = _this$props3.children,
88
- as = _this$props3.as;
89
+ const _ref = this.props,
90
+ children = _ref.children,
91
+ as = _ref.as;
89
92
  const hasFocus = this.state.hasFocus;
90
93
  const triggerProps = {
91
94
  'aria-describedby': this._id
@@ -96,7 +99,6 @@ let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
96
99
  const props = (0, _omitProps.omitProps)(this.props, Tooltip.allowedProps);
97
100
  return (0, _emotion.jsx)(Trigger, Object.assign({}, props, triggerProps), children);
98
101
  } else if (typeof children === 'function') {
99
- // TODO: try to remove cast when typing Tooltip (React children types are badly calculated)
100
102
  return children({
101
103
  focused: hasFocus,
102
104
  getTriggerProps: props => ({ ...triggerProps,
@@ -104,27 +106,27 @@ let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
104
106
  })
105
107
  });
106
108
  } else {
107
- return (0, _ensureSingleChild.ensureSingleChild)(this.props.children, triggerProps);
109
+ return (0, _ensureSingleChild.ensureSingleChild)(children, triggerProps);
108
110
  }
109
111
  }
110
112
 
111
113
  render() {
112
- const _this$props4 = this.props,
113
- renderTip = _this$props4.renderTip,
114
- isShowingContent = _this$props4.isShowingContent,
115
- defaultIsShowingContent = _this$props4.defaultIsShowingContent,
116
- on = _this$props4.on,
117
- color = _this$props4.color,
118
- placement = _this$props4.placement,
119
- mountNode = _this$props4.mountNode,
120
- constrain = _this$props4.constrain,
121
- offsetX = _this$props4.offsetX,
122
- offsetY = _this$props4.offsetY,
123
- positionTarget = _this$props4.positionTarget,
124
- onShowContent = _this$props4.onShowContent,
125
- onHideContent = _this$props4.onHideContent,
126
- styles = _this$props4.styles,
127
- rest = (0, _objectWithoutProperties2.default)(_this$props4, _excluded);
114
+ const _this$props3 = this.props,
115
+ renderTip = _this$props3.renderTip,
116
+ isShowingContent = _this$props3.isShowingContent,
117
+ defaultIsShowingContent = _this$props3.defaultIsShowingContent,
118
+ on = _this$props3.on,
119
+ color = _this$props3.color,
120
+ placement = _this$props3.placement,
121
+ mountNode = _this$props3.mountNode,
122
+ constrain = _this$props3.constrain,
123
+ offsetX = _this$props3.offsetX,
124
+ offsetY = _this$props3.offsetY,
125
+ positionTarget = _this$props3.positionTarget,
126
+ onShowContent = _this$props3.onShowContent,
127
+ onHideContent = _this$props3.onHideContent,
128
+ styles = _this$props3.styles,
129
+ rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
128
130
  return (0, _emotion.jsx)(_Popover.Popover, Object.assign({}, (0, _passthroughProps.passthroughProps)(rest), {
129
131
  isShowingContent: isShowingContent,
130
132
  defaultIsShowingContent: defaultIsShowingContent,
@@ -156,14 +158,9 @@ let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
156
158
  defaultIsShowingContent: false,
157
159
  color: 'primary',
158
160
  placement: 'top',
159
- mountNode: null,
160
161
  constrain: 'window',
161
162
  offsetX: 0,
162
- offsetY: 0,
163
- onShowContent: event => {},
164
- onHideContent: (event, _ref) => {
165
- let documentClick = _ref.documentClick;
166
- }
163
+ offsetY: 0
167
164
  }, _temp)) || _class) || _class);
168
165
  exports.Tooltip = Tooltip;
169
166
  var _default = Tooltip;
@@ -37,90 +37,21 @@ var _element = require("@instructure/ui-prop-types/lib/element.js");
37
37
  * SOFTWARE.
38
38
  */
39
39
  const propTypes = {
40
- /**
41
- * @param {Object} renderProps
42
- * @param {Boolean} renderProps.focused - Is the Tooltip trigger focused?
43
- * @param {Function} renderProps.getTriggerProps - Props to be spread onto the trigger element
44
- */
45
40
  children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
46
-
47
- /**
48
- * The content to render in the tooltip
49
- */
50
41
  renderTip: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
51
-
52
- /**
53
- * Whether or not the tooltip content is shown, when controlled
54
- */
55
42
  isShowingContent: _propTypes.default.bool,
56
-
57
- /**
58
- * Whether or not to show the content by default, when uncontrolled
59
- */
60
43
  defaultIsShowingContent: _propTypes.default.bool,
61
-
62
- /**
63
- * the element type to render as (assumes a single child if 'as' is undefined)
64
- */
65
44
  as: _propTypes.default.elementType,
66
45
  // eslint-disable-line react/require-default-props
67
-
68
- /**
69
- * The action that causes the Content to display (`click`, `hover`, `focus`)
70
- */
71
46
  on: _propTypes.default.oneOfType([_propTypes.default.oneOf(['click', 'hover', 'focus']), _propTypes.default.arrayOf(_propTypes.default.oneOf(['click', 'hover', 'focus']))]),
72
-
73
- /**
74
- * The color of the tooltip content
75
- */
76
47
  color: _propTypes.default.oneOf(['primary', 'primary-inverse']),
77
-
78
- /**
79
- * Specifies where the Tooltip will be placed in relation to the target element.
80
- * Ex. placement="bottom" will render the Tooltip below the triggering element
81
- * (Note: if there is not room, it will position opposite. Ex. "top" will
82
- * automatically switch to "bottom")
83
- */
84
48
  placement: _PositionPropTypes.PositionPropTypes.placement,
85
-
86
- /**
87
- * An element or a function returning an element to use as the mount node
88
- * for the `<Tooltip />` (defaults to `document.body`)
89
- */
90
49
  mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
91
-
92
- /**
93
- * The parent in which to constrain the tooltip.
94
- * One of: 'window', 'scroll-parent', 'parent', 'none', an element,
95
- * or a function returning an element
96
- */
97
50
  constrain: _PositionPropTypes.PositionPropTypes.constrain,
98
-
99
- /**
100
- * The horizontal offset for the positioned content
101
- */
102
51
  offsetX: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
103
-
104
- /**
105
- * The vertical offset for the positioned content
106
- */
107
52
  offsetY: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
108
-
109
- /**
110
- * Target element for positioning the Tooltip (if it differs from children/trigger)
111
- */
112
53
  positionTarget: _propTypes.default.oneOfType([_element.element, _propTypes.default.func]),
113
-
114
- /**
115
- * Callback fired when content is shown. When controlled, this callback is
116
- * fired when the tooltip expects to be shown
117
- */
118
54
  onShowContent: _propTypes.default.func,
119
-
120
- /**
121
- * Callback fired when content is hidden. When controlled, this callback is
122
- * fired when the tooltip expects to be hidden
123
- */
124
55
  onHideContent: _propTypes.default.func
125
56
  };
126
57
  exports.propTypes = propTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-tooltip",
3
- "version": "8.14.0",
3
+ "version": "8.14.1-snapshot.7+845d7ec6c",
4
4
  "description": "A component for showing small text-only overlays on hover/focus.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,23 +25,23 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/emotion": "8.14.0",
29
- "@instructure/shared-types": "8.14.0",
30
- "@instructure/ui-popover": "8.14.0",
31
- "@instructure/ui-position": "8.14.0",
32
- "@instructure/ui-prop-types": "8.14.0",
33
- "@instructure/ui-react-utils": "8.14.0",
34
- "@instructure/ui-testable": "8.14.0",
35
- "@instructure/uid": "8.14.0",
28
+ "@instructure/emotion": "8.14.1-snapshot.7+845d7ec6c",
29
+ "@instructure/shared-types": "8.14.1-snapshot.7+845d7ec6c",
30
+ "@instructure/ui-popover": "8.14.1-snapshot.7+845d7ec6c",
31
+ "@instructure/ui-position": "8.14.1-snapshot.7+845d7ec6c",
32
+ "@instructure/ui-prop-types": "8.14.1-snapshot.7+845d7ec6c",
33
+ "@instructure/ui-react-utils": "8.14.1-snapshot.7+845d7ec6c",
34
+ "@instructure/ui-testable": "8.14.1-snapshot.7+845d7ec6c",
35
+ "@instructure/uid": "8.14.1-snapshot.7+845d7ec6c",
36
36
  "prop-types": "^15"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "8.14.0",
40
- "@instructure/ui-color-utils": "8.14.0",
41
- "@instructure/ui-test-locator": "8.14.0",
42
- "@instructure/ui-test-queries": "8.14.0",
43
- "@instructure/ui-test-utils": "8.14.0",
44
- "@instructure/ui-themes": "8.14.0"
39
+ "@instructure/ui-babel-preset": "8.14.1-snapshot.7+845d7ec6c",
40
+ "@instructure/ui-color-utils": "8.14.1-snapshot.7+845d7ec6c",
41
+ "@instructure/ui-test-locator": "8.14.1-snapshot.7+845d7ec6c",
42
+ "@instructure/ui-test-queries": "8.14.1-snapshot.7+845d7ec6c",
43
+ "@instructure/ui-test-utils": "8.14.1-snapshot.7+845d7ec6c",
44
+ "@instructure/ui-themes": "8.14.1-snapshot.7+845d7ec6c"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=16.8 <=17"
@@ -49,5 +49,6 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "sideEffects": false
52
+ "sideEffects": false,
53
+ "gitHead": "845d7ec6c159d8946b22caa9d8fb3d0175167a6f"
53
54
  }
@@ -35,22 +35,24 @@ import {
35
35
  import { uid } from '@instructure/uid'
36
36
  import { testable } from '@instructure/ui-testable'
37
37
  import { Popover } from '@instructure/ui-popover'
38
+ import type { PopoverProps } from '@instructure/ui-popover'
38
39
  import { withStyle, jsx } from '@instructure/emotion'
39
40
 
40
41
  import generateStyle from './styles'
41
42
  import generateComponentTheme from './theme'
42
43
 
43
- import type { TooltipProps, TooltipRenderChildren } from './props'
44
+ import type { TooltipProps, TooltipState } from './props'
44
45
  import { allowedProps, propTypes } from './props'
45
46
 
46
47
  /**
47
48
  ---
48
49
  category: components
49
50
  ---
51
+ @tsProps
50
52
  **/
51
53
  @withStyle(generateStyle, generateComponentTheme)
52
54
  @testable()
53
- class Tooltip extends Component<TooltipProps> {
55
+ class Tooltip extends Component<TooltipProps, TooltipState> {
54
56
  static readonly componentId = 'Tooltip'
55
57
 
56
58
  static allowedProps = allowedProps
@@ -60,18 +62,12 @@ class Tooltip extends Component<TooltipProps> {
60
62
  defaultIsShowingContent: false,
61
63
  color: 'primary',
62
64
  placement: 'top',
63
- mountNode: null,
64
65
  constrain: 'window',
65
66
  offsetX: 0,
66
- offsetY: 0,
67
- // @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
68
- onShowContent: (event) => {},
69
- // @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
70
- onHideContent: (event, { documentClick }) => {}
67
+ offsetY: 0
71
68
  } as const
72
69
 
73
- _id = uid('Tooltip')
74
- state = { hasFocus: false }
70
+ private readonly _id: string
75
71
 
76
72
  ref: Element | null = null
77
73
 
@@ -79,28 +75,34 @@ class Tooltip extends Component<TooltipProps> {
79
75
  this.ref = el
80
76
  }
81
77
 
78
+ constructor(props: TooltipProps) {
79
+ super(props)
80
+
81
+ this._id = uid('Tooltip')
82
+
83
+ this.state = { hasFocus: false }
84
+ }
85
+
82
86
  componentDidMount() {
83
87
  this.props.makeStyles?.()
84
88
  }
85
89
 
86
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
87
- componentDidUpdate(prevProps, prevState, snapshot) {
90
+ componentDidUpdate() {
88
91
  this.props.makeStyles?.()
89
92
  }
90
93
 
91
- // @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
92
- handleFocus = (event) => {
94
+ handleFocus: PopoverProps['onFocus'] = () => {
93
95
  this.setState({ hasFocus: true })
94
96
  }
95
97
 
96
- // @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
97
- handleBlur = (event) => {
98
+ handleBlur: PopoverProps['onBlur'] = () => {
98
99
  this.setState({ hasFocus: false })
99
100
  }
100
101
 
101
102
  renderTrigger() {
102
- const { children, as } = this.props
103
+ const { children, as } = this.props as TooltipProps
103
104
  const { hasFocus } = this.state
105
+
104
106
  const triggerProps = {
105
107
  'aria-describedby': this._id
106
108
  }
@@ -114,8 +116,7 @@ class Tooltip extends Component<TooltipProps> {
114
116
  </Trigger>
115
117
  )
116
118
  } else if (typeof children === 'function') {
117
- // TODO: try to remove cast when typing Tooltip (React children types are badly calculated)
118
- return (children as TooltipRenderChildren)({
119
+ return children({
119
120
  focused: hasFocus,
120
121
  getTriggerProps: (props) => ({
121
122
  ...triggerProps,
@@ -123,7 +124,7 @@ class Tooltip extends Component<TooltipProps> {
123
124
  })
124
125
  })
125
126
  } else {
126
- return ensureSingleChild(this.props.children, triggerProps)
127
+ return ensureSingleChild(children, triggerProps)
127
128
  }
128
129
  }
129
130