@instructure/ui-tooltip 8.8.1-snapshot.8 → 8.9.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/index.js +29 -121
- package/es/Tooltip/props.js +115 -0
- package/lib/Tooltip/index.js +29 -123
- package/lib/Tooltip/props.js +128 -0
- package/package.json +16 -17
- package/src/Tooltip/index.tsx +8 -91
- package/src/Tooltip/props.ts +156 -0
- package/src/index.ts +1 -1
- package/types/Tooltip/index.d.ts +35 -79
- package/types/Tooltip/index.d.ts.map +1 -1
- package/types/Tooltip/{types.d.ts → props.d.ts} +13 -6
- package/types/Tooltip/props.d.ts.map +1 -0
- package/types/index.d.ts +1 -1
- package/LICENSE.md +0 -27
- package/es/Tooltip/types.js +0 -1
- package/lib/Tooltip/types.js +0 -1
- package/src/Tooltip/types.ts +0 -49
- package/types/Tooltip/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.9.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- fix shared-types TS errors ([7b83164](https://github.com/instructure/instructure-ui/commit/7b83164f4c5872f3a217e010563f59bf584ae4fc))
|
|
11
|
+
|
|
6
12
|
# [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/es/Tooltip/index.js
CHANGED
|
@@ -29,22 +29,20 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
29
29
|
|
|
30
30
|
/** @jsx jsx */
|
|
31
31
|
import { Component } from 'react';
|
|
32
|
-
import PropTypes from 'prop-types';
|
|
33
32
|
import { getElementType, omitProps, ensureSingleChild, passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
|
|
34
|
-
import { PositionPropTypes } from '@instructure/ui-position';
|
|
35
33
|
import { uid } from '@instructure/uid';
|
|
36
34
|
import { testable } from '@instructure/ui-testable';
|
|
37
35
|
import { Popover } from '@instructure/ui-popover';
|
|
38
|
-
import { element } from '@instructure/ui-prop-types';
|
|
39
36
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
40
37
|
import generateStyle from './styles';
|
|
41
38
|
import generateComponentTheme from './theme';
|
|
42
|
-
|
|
39
|
+
import { allowedProps, propTypes } from './props';
|
|
43
40
|
/**
|
|
44
41
|
---
|
|
45
42
|
category: components
|
|
46
43
|
---
|
|
47
44
|
**/
|
|
45
|
+
|
|
48
46
|
let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Tooltip extends Component {
|
|
49
47
|
constructor(...args) {
|
|
50
48
|
super(...args);
|
|
@@ -67,17 +65,21 @@ let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
componentDidMount() {
|
|
70
|
-
|
|
68
|
+
var _this$props$makeStyle, _this$props;
|
|
69
|
+
|
|
70
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
74
|
-
|
|
74
|
+
var _this$props$makeStyle2, _this$props2;
|
|
75
|
+
|
|
76
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
renderTrigger() {
|
|
78
|
-
const _this$
|
|
79
|
-
children = _this$
|
|
80
|
-
as = _this$
|
|
80
|
+
const _this$props3 = this.props,
|
|
81
|
+
children = _this$props3.children,
|
|
82
|
+
as = _this$props3.as;
|
|
81
83
|
const hasFocus = this.state.hasFocus;
|
|
82
84
|
const triggerProps = {
|
|
83
85
|
'aria-describedby': this._id
|
|
@@ -102,22 +104,22 @@ let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
render() {
|
|
105
|
-
const _this$
|
|
106
|
-
renderTip = _this$
|
|
107
|
-
isShowingContent = _this$
|
|
108
|
-
defaultIsShowingContent = _this$
|
|
109
|
-
on = _this$
|
|
110
|
-
color = _this$
|
|
111
|
-
placement = _this$
|
|
112
|
-
mountNode = _this$
|
|
113
|
-
constrain = _this$
|
|
114
|
-
offsetX = _this$
|
|
115
|
-
offsetY = _this$
|
|
116
|
-
positionTarget = _this$
|
|
117
|
-
onShowContent = _this$
|
|
118
|
-
onHideContent = _this$
|
|
119
|
-
styles = _this$
|
|
120
|
-
rest = _objectWithoutProperties(_this$
|
|
107
|
+
const _this$props4 = this.props,
|
|
108
|
+
renderTip = _this$props4.renderTip,
|
|
109
|
+
isShowingContent = _this$props4.isShowingContent,
|
|
110
|
+
defaultIsShowingContent = _this$props4.defaultIsShowingContent,
|
|
111
|
+
on = _this$props4.on,
|
|
112
|
+
color = _this$props4.color,
|
|
113
|
+
placement = _this$props4.placement,
|
|
114
|
+
mountNode = _this$props4.mountNode,
|
|
115
|
+
constrain = _this$props4.constrain,
|
|
116
|
+
offsetX = _this$props4.offsetX,
|
|
117
|
+
offsetY = _this$props4.offsetY,
|
|
118
|
+
positionTarget = _this$props4.positionTarget,
|
|
119
|
+
onShowContent = _this$props4.onShowContent,
|
|
120
|
+
onHideContent = _this$props4.onHideContent,
|
|
121
|
+
styles = _this$props4.styles,
|
|
122
|
+
rest = _objectWithoutProperties(_this$props4, _excluded);
|
|
121
123
|
|
|
122
124
|
return jsx(Popover, Object.assign({}, passthroughProps(rest), {
|
|
123
125
|
isShowingContent: isShowingContent,
|
|
@@ -140,113 +142,19 @@ let Tooltip = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
140
142
|
onBlur: this.handleBlur
|
|
141
143
|
}), jsx("span", {
|
|
142
144
|
id: this._id,
|
|
143
|
-
css: styles.tooltip,
|
|
145
|
+
css: styles === null || styles === void 0 ? void 0 : styles.tooltip,
|
|
144
146
|
role: "tooltip"
|
|
145
147
|
}, callRenderProp(renderTip)));
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
}, _class2.displayName = "Tooltip", _class2.componentId = 'Tooltip', _class2.propTypes = {
|
|
149
|
-
// eslint-disable-next-line react/require-default-props
|
|
150
|
-
makeStyles: PropTypes.func,
|
|
151
|
-
// eslint-disable-next-line react/require-default-props
|
|
152
|
-
styles: PropTypes.object,
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @param {Object} renderProps
|
|
156
|
-
* @param {Boolean} renderProps.focused - Is the Tooltip trigger focused?
|
|
157
|
-
* @param {Function} renderProps.getTriggerProps - Props to be spread onto the trigger element
|
|
158
|
-
*/
|
|
159
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* The content to render in the tooltip
|
|
163
|
-
*/
|
|
164
|
-
renderTip: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Whether or not the tooltip content is shown, when controlled
|
|
168
|
-
*/
|
|
169
|
-
isShowingContent: PropTypes.bool,
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Whether or not to show the content by default, when uncontrolled
|
|
173
|
-
*/
|
|
174
|
-
defaultIsShowingContent: PropTypes.bool,
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* the element type to render as (assumes a single child if 'as' is undefined)
|
|
178
|
-
*/
|
|
179
|
-
as: PropTypes.elementType,
|
|
180
|
-
// eslint-disable-line react/require-default-props
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* The action that causes the Content to display (`click`, `hover`, `focus`)
|
|
184
|
-
*/
|
|
185
|
-
on: PropTypes.oneOfType([PropTypes.oneOf(['click', 'hover', 'focus']), PropTypes.arrayOf(PropTypes.oneOf(['click', 'hover', 'focus']))]),
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* The color of the tooltip content
|
|
189
|
-
*/
|
|
190
|
-
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Specifies where the Tooltip will be placed in relation to the target element.
|
|
194
|
-
* Ex. placement="bottom" will render the Tooltip below the triggering element
|
|
195
|
-
* (Note: if there is not room, it will position opposite. Ex. "top" will
|
|
196
|
-
* automatically switch to "bottom")
|
|
197
|
-
*/
|
|
198
|
-
placement: PositionPropTypes.placement,
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* An element or a function returning an element to use as the mount node
|
|
202
|
-
* for the `<Tooltip />` (defaults to `document.body`)
|
|
203
|
-
*/
|
|
204
|
-
mountNode: PositionPropTypes.mountNode,
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* The parent in which to constrain the tooltip.
|
|
208
|
-
* One of: 'window', 'scroll-parent', 'parent', 'none', an element,
|
|
209
|
-
* or a function returning an element
|
|
210
|
-
*/
|
|
211
|
-
constrain: PositionPropTypes.constrain,
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* The horizontal offset for the positioned content
|
|
215
|
-
*/
|
|
216
|
-
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* The vertical offset for the positioned content
|
|
220
|
-
*/
|
|
221
|
-
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Target element for positioning the Tooltip (if it differs from children/trigger)
|
|
225
|
-
*/
|
|
226
|
-
positionTarget: PropTypes.oneOfType([element, PropTypes.func]),
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Callback fired when content is shown. When controlled, this callback is
|
|
230
|
-
* fired when the tooltip expects to be shown
|
|
231
|
-
*/
|
|
232
|
-
onShowContent: PropTypes.func,
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Callback fired when content is hidden. When controlled, this callback is
|
|
236
|
-
* fired when the tooltip expects to be hidden
|
|
237
|
-
*/
|
|
238
|
-
onHideContent: PropTypes.func
|
|
239
|
-
}, _class2.defaultProps = {
|
|
240
|
-
isShowingContent: void 0,
|
|
150
|
+
}, _class2.displayName = "Tooltip", _class2.componentId = 'Tooltip', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
241
151
|
defaultIsShowingContent: false,
|
|
242
|
-
on: void 0,
|
|
243
152
|
color: 'primary',
|
|
244
153
|
placement: 'top',
|
|
245
154
|
mountNode: null,
|
|
246
155
|
constrain: 'window',
|
|
247
156
|
offsetX: 0,
|
|
248
157
|
offsetY: 0,
|
|
249
|
-
positionTarget: void 0,
|
|
250
158
|
onShowContent: event => {},
|
|
251
159
|
onHideContent: (event, {
|
|
252
160
|
documentClick
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
import { PositionPropTypes } from '@instructure/ui-position';
|
|
26
|
+
import { element } from '@instructure/ui-prop-types';
|
|
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
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The content to render in the tooltip
|
|
37
|
+
*/
|
|
38
|
+
renderTip: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether or not the tooltip content is shown, when controlled
|
|
42
|
+
*/
|
|
43
|
+
isShowingContent: PropTypes.bool,
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether or not to show the content by default, when uncontrolled
|
|
47
|
+
*/
|
|
48
|
+
defaultIsShowingContent: PropTypes.bool,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* the element type to render as (assumes a single child if 'as' is undefined)
|
|
52
|
+
*/
|
|
53
|
+
as: PropTypes.elementType,
|
|
54
|
+
// eslint-disable-line react/require-default-props
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The action that causes the Content to display (`click`, `hover`, `focus`)
|
|
58
|
+
*/
|
|
59
|
+
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
|
+
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
|
+
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
|
+
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
|
+
constrain: PositionPropTypes.constrain,
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The horizontal offset for the positioned content
|
|
89
|
+
*/
|
|
90
|
+
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The vertical offset for the positioned content
|
|
94
|
+
*/
|
|
95
|
+
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Target element for positioning the Tooltip (if it differs from children/trigger)
|
|
99
|
+
*/
|
|
100
|
+
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
|
+
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
|
+
onHideContent: PropTypes.func
|
|
113
|
+
};
|
|
114
|
+
const allowedProps = ['children', 'renderTip', 'isShowingContent', 'defaultIsShowingContent', 'as', 'on', 'color', 'placement', 'mountNode', 'constrain', 'offsetX', 'offsetY', 'positionTarget', 'onShowContent', 'onHideContent'];
|
|
115
|
+
export { propTypes, allowedProps };
|
package/lib/Tooltip/index.js
CHANGED
|
@@ -11,8 +11,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
11
11
|
|
|
12
12
|
var _react = require("react");
|
|
13
13
|
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
14
|
var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
|
|
17
15
|
|
|
18
16
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
@@ -23,22 +21,20 @@ var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProp
|
|
|
23
21
|
|
|
24
22
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
25
23
|
|
|
26
|
-
var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes.js");
|
|
27
|
-
|
|
28
24
|
var _uid = require("@instructure/uid");
|
|
29
25
|
|
|
30
26
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
31
27
|
|
|
32
28
|
var _Popover = require("@instructure/ui-popover/lib/Popover");
|
|
33
29
|
|
|
34
|
-
var _element = require("@instructure/ui-prop-types/lib/element.js");
|
|
35
|
-
|
|
36
30
|
var _emotion = require("@instructure/emotion");
|
|
37
31
|
|
|
38
32
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
39
33
|
|
|
40
34
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
41
35
|
|
|
36
|
+
var _props = require("./props");
|
|
37
|
+
|
|
42
38
|
const _excluded = ["renderTip", "isShowingContent", "defaultIsShowingContent", "on", "color", "placement", "mountNode", "constrain", "offsetX", "offsetY", "positionTarget", "onShowContent", "onHideContent", "styles"];
|
|
43
39
|
|
|
44
40
|
var _dec, _dec2, _class, _class2, _temp;
|
|
@@ -70,17 +66,21 @@ let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
70
66
|
}
|
|
71
67
|
|
|
72
68
|
componentDidMount() {
|
|
73
|
-
|
|
69
|
+
var _this$props$makeStyle, _this$props;
|
|
70
|
+
|
|
71
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
77
|
-
|
|
75
|
+
var _this$props$makeStyle2, _this$props2;
|
|
76
|
+
|
|
77
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
renderTrigger() {
|
|
81
|
-
const _this$
|
|
82
|
-
children = _this$
|
|
83
|
-
as = _this$
|
|
81
|
+
const _this$props3 = this.props,
|
|
82
|
+
children = _this$props3.children,
|
|
83
|
+
as = _this$props3.as;
|
|
84
84
|
const hasFocus = this.state.hasFocus;
|
|
85
85
|
const triggerProps = {
|
|
86
86
|
'aria-describedby': this._id
|
|
@@ -105,22 +105,22 @@ let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
render() {
|
|
108
|
-
const _this$
|
|
109
|
-
renderTip = _this$
|
|
110
|
-
isShowingContent = _this$
|
|
111
|
-
defaultIsShowingContent = _this$
|
|
112
|
-
on = _this$
|
|
113
|
-
color = _this$
|
|
114
|
-
placement = _this$
|
|
115
|
-
mountNode = _this$
|
|
116
|
-
constrain = _this$
|
|
117
|
-
offsetX = _this$
|
|
118
|
-
offsetY = _this$
|
|
119
|
-
positionTarget = _this$
|
|
120
|
-
onShowContent = _this$
|
|
121
|
-
onHideContent = _this$
|
|
122
|
-
styles = _this$
|
|
123
|
-
rest = (0, _objectWithoutProperties2.default)(_this$
|
|
108
|
+
const _this$props4 = this.props,
|
|
109
|
+
renderTip = _this$props4.renderTip,
|
|
110
|
+
isShowingContent = _this$props4.isShowingContent,
|
|
111
|
+
defaultIsShowingContent = _this$props4.defaultIsShowingContent,
|
|
112
|
+
on = _this$props4.on,
|
|
113
|
+
color = _this$props4.color,
|
|
114
|
+
placement = _this$props4.placement,
|
|
115
|
+
mountNode = _this$props4.mountNode,
|
|
116
|
+
constrain = _this$props4.constrain,
|
|
117
|
+
offsetX = _this$props4.offsetX,
|
|
118
|
+
offsetY = _this$props4.offsetY,
|
|
119
|
+
positionTarget = _this$props4.positionTarget,
|
|
120
|
+
onShowContent = _this$props4.onShowContent,
|
|
121
|
+
onHideContent = _this$props4.onHideContent,
|
|
122
|
+
styles = _this$props4.styles,
|
|
123
|
+
rest = (0, _objectWithoutProperties2.default)(_this$props4, _excluded);
|
|
124
124
|
return (0, _emotion.jsx)(_Popover.Popover, Object.assign({}, (0, _passthroughProps.passthroughProps)(rest), {
|
|
125
125
|
isShowingContent: isShowingContent,
|
|
126
126
|
defaultIsShowingContent: defaultIsShowingContent,
|
|
@@ -142,113 +142,19 @@ let Tooltip = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
142
142
|
onBlur: this.handleBlur
|
|
143
143
|
}), (0, _emotion.jsx)("span", {
|
|
144
144
|
id: this._id,
|
|
145
|
-
css: styles.tooltip,
|
|
145
|
+
css: styles === null || styles === void 0 ? void 0 : styles.tooltip,
|
|
146
146
|
role: "tooltip"
|
|
147
147
|
}, (0, _callRenderProp.callRenderProp)(renderTip)));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
}, _class2.displayName = "Tooltip", _class2.componentId = 'Tooltip', _class2.propTypes = {
|
|
151
|
-
// eslint-disable-next-line react/require-default-props
|
|
152
|
-
makeStyles: _propTypes.default.func,
|
|
153
|
-
// eslint-disable-next-line react/require-default-props
|
|
154
|
-
styles: _propTypes.default.object,
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* @param {Object} renderProps
|
|
158
|
-
* @param {Boolean} renderProps.focused - Is the Tooltip trigger focused?
|
|
159
|
-
* @param {Function} renderProps.getTriggerProps - Props to be spread onto the trigger element
|
|
160
|
-
*/
|
|
161
|
-
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* The content to render in the tooltip
|
|
165
|
-
*/
|
|
166
|
-
renderTip: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Whether or not the tooltip content is shown, when controlled
|
|
170
|
-
*/
|
|
171
|
-
isShowingContent: _propTypes.default.bool,
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Whether or not to show the content by default, when uncontrolled
|
|
175
|
-
*/
|
|
176
|
-
defaultIsShowingContent: _propTypes.default.bool,
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* the element type to render as (assumes a single child if 'as' is undefined)
|
|
180
|
-
*/
|
|
181
|
-
as: _propTypes.default.elementType,
|
|
182
|
-
// eslint-disable-line react/require-default-props
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The action that causes the Content to display (`click`, `hover`, `focus`)
|
|
186
|
-
*/
|
|
187
|
-
on: _propTypes.default.oneOfType([_propTypes.default.oneOf(['click', 'hover', 'focus']), _propTypes.default.arrayOf(_propTypes.default.oneOf(['click', 'hover', 'focus']))]),
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* The color of the tooltip content
|
|
191
|
-
*/
|
|
192
|
-
color: _propTypes.default.oneOf(['primary', 'primary-inverse']),
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Specifies where the Tooltip will be placed in relation to the target element.
|
|
196
|
-
* Ex. placement="bottom" will render the Tooltip below the triggering element
|
|
197
|
-
* (Note: if there is not room, it will position opposite. Ex. "top" will
|
|
198
|
-
* automatically switch to "bottom")
|
|
199
|
-
*/
|
|
200
|
-
placement: _PositionPropTypes.PositionPropTypes.placement,
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* An element or a function returning an element to use as the mount node
|
|
204
|
-
* for the `<Tooltip />` (defaults to `document.body`)
|
|
205
|
-
*/
|
|
206
|
-
mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* The parent in which to constrain the tooltip.
|
|
210
|
-
* One of: 'window', 'scroll-parent', 'parent', 'none', an element,
|
|
211
|
-
* or a function returning an element
|
|
212
|
-
*/
|
|
213
|
-
constrain: _PositionPropTypes.PositionPropTypes.constrain,
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* The horizontal offset for the positioned content
|
|
217
|
-
*/
|
|
218
|
-
offsetX: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* The vertical offset for the positioned content
|
|
222
|
-
*/
|
|
223
|
-
offsetY: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Target element for positioning the Tooltip (if it differs from children/trigger)
|
|
227
|
-
*/
|
|
228
|
-
positionTarget: _propTypes.default.oneOfType([_element.element, _propTypes.default.func]),
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Callback fired when content is shown. When controlled, this callback is
|
|
232
|
-
* fired when the tooltip expects to be shown
|
|
233
|
-
*/
|
|
234
|
-
onShowContent: _propTypes.default.func,
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Callback fired when content is hidden. When controlled, this callback is
|
|
238
|
-
* fired when the tooltip expects to be hidden
|
|
239
|
-
*/
|
|
240
|
-
onHideContent: _propTypes.default.func
|
|
241
|
-
}, _class2.defaultProps = {
|
|
242
|
-
isShowingContent: void 0,
|
|
150
|
+
}, _class2.displayName = "Tooltip", _class2.componentId = 'Tooltip', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
243
151
|
defaultIsShowingContent: false,
|
|
244
|
-
on: void 0,
|
|
245
152
|
color: 'primary',
|
|
246
153
|
placement: 'top',
|
|
247
154
|
mountNode: null,
|
|
248
155
|
constrain: 'window',
|
|
249
156
|
offsetX: 0,
|
|
250
157
|
offsetY: 0,
|
|
251
|
-
positionTarget: void 0,
|
|
252
158
|
onShowContent: event => {},
|
|
253
159
|
onHideContent: (event, {
|
|
254
160
|
documentClick
|