@instructure/ui-tooltip 10.16.1-snapshot-0 → 10.16.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 +1 -1
- package/es/Tooltip/__new-tests__/Tooltip.test.js +63 -40
- package/es/Tooltip/index.js +17 -10
- package/lib/Tooltip/__new-tests__/Tooltip.test.js +78 -55
- package/lib/Tooltip/index.js +16 -9
- package/package.json +17 -17
- package/src/Tooltip/__new-tests__/Tooltip.test.tsx +0 -1
- package/src/Tooltip/index.tsx +1 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Tooltip/__new-tests__/Tooltip.test.d.ts.map +1 -1
- package/types/Tooltip/index.d.ts +2 -4
- package/types/Tooltip/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
-
## [10.16.1
|
|
6
|
+
## [10.16.1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-tooltip
|
|
9
9
|
|
|
@@ -23,7 +23,6 @@ var _Tooltip, _Tooltip2, _Tooltip3, _a, _Tooltip4, _Tooltip5, _Tooltip6, _h;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import userEvent from '@testing-library/user-event';
|
|
@@ -34,6 +33,7 @@ import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11y
|
|
|
34
33
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
35
34
|
import { Tooltip } from '../index';
|
|
36
35
|
import TooltipExamples from '../__examples__/Tooltip.examples';
|
|
36
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
37
37
|
describe('<Tooltip />', () => {
|
|
38
38
|
let consoleErrorMock;
|
|
39
39
|
beforeEach(() => {
|
|
@@ -44,22 +44,26 @@ describe('<Tooltip />', () => {
|
|
|
44
44
|
consoleErrorMock.mockRestore();
|
|
45
45
|
});
|
|
46
46
|
it('should render', async () => {
|
|
47
|
-
render(_Tooltip || (_Tooltip =
|
|
48
|
-
renderTip: "Hello"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
render(_Tooltip || (_Tooltip = _jsx(Tooltip, {
|
|
48
|
+
renderTip: "Hello",
|
|
49
|
+
children: _jsx("a", {
|
|
50
|
+
href: "example.html",
|
|
51
|
+
children: "Hover or focus me"
|
|
52
|
+
})
|
|
53
|
+
})));
|
|
52
54
|
const tip = screen.getByRole('tooltip');
|
|
53
55
|
expect(tip).toBeInTheDocument();
|
|
54
56
|
expect(tip).toHaveTextContent('Hello');
|
|
55
57
|
});
|
|
56
58
|
it('should render children', async () => {
|
|
57
|
-
render(_Tooltip2 || (_Tooltip2 =
|
|
58
|
-
renderTip: "Hello"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
render(_Tooltip2 || (_Tooltip2 = _jsx(Tooltip, {
|
|
60
|
+
renderTip: "Hello",
|
|
61
|
+
children: _jsx("a", {
|
|
62
|
+
"data-testid": "trigger",
|
|
63
|
+
href: "example.html",
|
|
64
|
+
children: "Hover or focus me"
|
|
65
|
+
})
|
|
66
|
+
})));
|
|
63
67
|
const tip = screen.getByRole('tooltip');
|
|
64
68
|
const trigger = screen.getByTestId('trigger');
|
|
65
69
|
expect(trigger).toBeInTheDocument();
|
|
@@ -68,33 +72,42 @@ describe('<Tooltip />', () => {
|
|
|
68
72
|
expect(tip).toHaveTextContent('Hello');
|
|
69
73
|
});
|
|
70
74
|
it('should have an aria-describedby attribute', async () => {
|
|
71
|
-
render(_Tooltip3 || (_Tooltip3 =
|
|
72
|
-
renderTip:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
render(_Tooltip3 || (_Tooltip3 = _jsx(Tooltip, {
|
|
76
|
+
renderTip: _jsx("h2", {
|
|
77
|
+
children: "Hello"
|
|
78
|
+
}),
|
|
79
|
+
children: _jsx("a", {
|
|
80
|
+
"data-testid": "trigger",
|
|
81
|
+
href: "example.html",
|
|
82
|
+
children: "Hover or focus me"
|
|
83
|
+
})
|
|
84
|
+
})));
|
|
77
85
|
const trigger = screen.getByTestId('trigger');
|
|
78
86
|
const tooltip = screen.getByRole('tooltip');
|
|
79
87
|
expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
|
|
80
88
|
});
|
|
81
89
|
it('should accept a function for renderTip', async () => {
|
|
82
|
-
render(
|
|
83
|
-
renderTip: () => 'Hello'
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
render(_jsx(Tooltip, {
|
|
91
|
+
renderTip: () => 'Hello',
|
|
92
|
+
children: _a || (_a = _jsx("a", {
|
|
93
|
+
href: "example.html",
|
|
94
|
+
children: "Hover or focus me"
|
|
95
|
+
}))
|
|
96
|
+
}));
|
|
87
97
|
const content = screen.getByText('Hello');
|
|
88
98
|
expect(content).toBeInTheDocument();
|
|
89
99
|
});
|
|
90
100
|
describe('using as', () => {
|
|
91
101
|
it('should render children', async () => {
|
|
92
|
-
render(_Tooltip4 || (_Tooltip4 =
|
|
93
|
-
renderTip:
|
|
102
|
+
render(_Tooltip4 || (_Tooltip4 = _jsx(Tooltip, {
|
|
103
|
+
renderTip: _jsx("h2", {
|
|
104
|
+
children: "Hello"
|
|
105
|
+
}),
|
|
94
106
|
placement: "end",
|
|
95
107
|
as: "a",
|
|
96
|
-
href: "example.html"
|
|
97
|
-
|
|
108
|
+
href: "example.html",
|
|
109
|
+
children: "Hover or focus me"
|
|
110
|
+
})));
|
|
98
111
|
const tip = screen.getByRole('tooltip');
|
|
99
112
|
const trigger = screen.getByText('Hover or focus me');
|
|
100
113
|
expect(trigger).toBeInTheDocument();
|
|
@@ -104,23 +117,29 @@ describe('<Tooltip />', () => {
|
|
|
104
117
|
expect(tip).toHaveTextContent('Hello');
|
|
105
118
|
});
|
|
106
119
|
it('should have an aria-describedby attribute', async () => {
|
|
107
|
-
render(_Tooltip5 || (_Tooltip5 =
|
|
108
|
-
renderTip:
|
|
120
|
+
render(_Tooltip5 || (_Tooltip5 = _jsx(Tooltip, {
|
|
121
|
+
renderTip: _jsx("h2", {
|
|
122
|
+
children: "Hello"
|
|
123
|
+
}),
|
|
109
124
|
placement: "end",
|
|
110
125
|
as: "a",
|
|
111
|
-
href: "example.html"
|
|
112
|
-
|
|
126
|
+
href: "example.html",
|
|
127
|
+
children: "Hover or focus me"
|
|
128
|
+
})));
|
|
113
129
|
const trigger = screen.getByText('Hover or focus me');
|
|
114
130
|
const tooltip = screen.getByRole('tooltip');
|
|
115
131
|
expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
|
|
116
132
|
});
|
|
117
133
|
it('should pass down the href attribute', async () => {
|
|
118
|
-
render(_Tooltip6 || (_Tooltip6 =
|
|
119
|
-
renderTip:
|
|
134
|
+
render(_Tooltip6 || (_Tooltip6 = _jsx(Tooltip, {
|
|
135
|
+
renderTip: _jsx("h2", {
|
|
136
|
+
children: "Hello"
|
|
137
|
+
}),
|
|
120
138
|
placement: "end",
|
|
121
139
|
as: "a",
|
|
122
|
-
href: "example.html"
|
|
123
|
-
|
|
140
|
+
href: "example.html",
|
|
141
|
+
children: "Hover or focus me"
|
|
142
|
+
})));
|
|
124
143
|
const link = screen.getByText('Hover or focus me');
|
|
125
144
|
expect(link).toHaveAttribute('href', 'example.html');
|
|
126
145
|
});
|
|
@@ -128,11 +147,15 @@ describe('<Tooltip />', () => {
|
|
|
128
147
|
describe('using children', () => {
|
|
129
148
|
it('should call onClick of child', async () => {
|
|
130
149
|
const onClick = vi.fn();
|
|
131
|
-
render(
|
|
132
|
-
renderTip: _h || (_h =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
150
|
+
render(_jsx(Tooltip, {
|
|
151
|
+
renderTip: _h || (_h = _jsx("h2", {
|
|
152
|
+
children: "Hello"
|
|
153
|
+
})),
|
|
154
|
+
children: _jsx("button", {
|
|
155
|
+
onClick: onClick,
|
|
156
|
+
children: "Hover or focus me"
|
|
157
|
+
})
|
|
158
|
+
}));
|
|
136
159
|
const button = screen.getByText('Hover or focus me');
|
|
137
160
|
await userEvent.click(button);
|
|
138
161
|
await waitFor(() => {
|
package/es/Tooltip/index.js
CHANGED
|
@@ -25,12 +25,11 @@ var _dec, _dec2, _dec3, _class, _Tooltip;
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
/** @jsx jsx */
|
|
29
28
|
import { Component } from 'react';
|
|
30
29
|
import { getElementType, omitProps, ensureSingleChild, passthroughProps, callRenderProp, withDeterministicId } from '@instructure/ui-react-utils';
|
|
31
30
|
import { testable } from '@instructure/ui-testable';
|
|
32
31
|
import { Popover } from '@instructure/ui-popover';
|
|
33
|
-
import { withStyle
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
34
33
|
import generateStyle from './styles';
|
|
35
34
|
import generateComponentTheme from './theme';
|
|
36
35
|
import { allowedProps, propTypes } from './props';
|
|
@@ -40,6 +39,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
40
39
|
category: components
|
|
41
40
|
---
|
|
42
41
|
**/
|
|
42
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
43
43
|
let Tooltip = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_Tooltip = class Tooltip extends Component {
|
|
44
44
|
constructor(props) {
|
|
45
45
|
super(props);
|
|
@@ -85,7 +85,11 @@ let Tooltip = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, ge
|
|
|
85
85
|
if (as) {
|
|
86
86
|
const Trigger = getElementType(Tooltip, this.props);
|
|
87
87
|
const props = omitProps(this.props, Tooltip.allowedProps);
|
|
88
|
-
return
|
|
88
|
+
return _jsx(Trigger, {
|
|
89
|
+
...props,
|
|
90
|
+
...triggerProps,
|
|
91
|
+
children: children /*TODO check if it can be TooltipRenderChildren, this might cause a crash*/
|
|
92
|
+
});
|
|
89
93
|
} else if (typeof children === 'function') {
|
|
90
94
|
return children({
|
|
91
95
|
focused: hasFocus,
|
|
@@ -116,7 +120,8 @@ let Tooltip = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, ge
|
|
|
116
120
|
preventTooltip = _this$props3.preventTooltip,
|
|
117
121
|
styles = _this$props3.styles,
|
|
118
122
|
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
119
|
-
return
|
|
123
|
+
return _jsx(Popover, {
|
|
124
|
+
...passthroughProps(rest),
|
|
120
125
|
isShowingContent: !preventTooltip && isShowingContent,
|
|
121
126
|
defaultIsShowingContent: !preventTooltip && defaultIsShowingContent,
|
|
122
127
|
on: on,
|
|
@@ -137,12 +142,14 @@ let Tooltip = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, ge
|
|
|
137
142
|
onBlur: this.handleBlur,
|
|
138
143
|
elementRef: this.handleRef,
|
|
139
144
|
shouldCloseOnDocumentClick: false,
|
|
140
|
-
shouldCloseOnEscape: true
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
shouldCloseOnEscape: true,
|
|
146
|
+
children: !preventTooltip ? _jsx("span", {
|
|
147
|
+
id: this._id,
|
|
148
|
+
css: styles === null || styles === void 0 ? void 0 : styles.tooltip,
|
|
149
|
+
role: "tooltip",
|
|
150
|
+
children: callRenderProp(renderTip)
|
|
151
|
+
}) : null
|
|
152
|
+
});
|
|
146
153
|
}
|
|
147
154
|
}, _Tooltip.displayName = "Tooltip", _Tooltip.componentId = 'Tooltip', _Tooltip.allowedProps = allowedProps, _Tooltip.propTypes = propTypes, _Tooltip.defaultProps = {
|
|
148
155
|
defaultIsShowingContent: false,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _react =
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
4
|
+
var _react = require("@testing-library/react");
|
|
6
5
|
var _vitest = require("vitest");
|
|
7
6
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
7
|
require("@testing-library/jest-dom");
|
|
@@ -10,6 +9,7 @@ var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yT
|
|
|
10
9
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
11
10
|
var _index = require("../index");
|
|
12
11
|
var _Tooltip7 = _interopRequireDefault(require("../__examples__/Tooltip.examples"));
|
|
12
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
13
13
|
var _Tooltip, _Tooltip2, _Tooltip3, _a, _Tooltip4, _Tooltip5, _Tooltip6, _h;
|
|
14
14
|
/*
|
|
15
15
|
* The MIT License (MIT)
|
|
@@ -45,59 +45,72 @@ describe('<Tooltip />', () => {
|
|
|
45
45
|
consoleErrorMock.mockRestore();
|
|
46
46
|
});
|
|
47
47
|
it('should render', async () => {
|
|
48
|
-
(0,
|
|
49
|
-
renderTip: "Hello"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
(0, _react.render)(_Tooltip || (_Tooltip = (0, _jsxRuntime.jsx)(_index.Tooltip, {
|
|
49
|
+
renderTip: "Hello",
|
|
50
|
+
children: (0, _jsxRuntime.jsx)("a", {
|
|
51
|
+
href: "example.html",
|
|
52
|
+
children: "Hover or focus me"
|
|
53
|
+
})
|
|
54
|
+
})));
|
|
55
|
+
const tip = _react.screen.getByRole('tooltip');
|
|
54
56
|
expect(tip).toBeInTheDocument();
|
|
55
57
|
expect(tip).toHaveTextContent('Hello');
|
|
56
58
|
});
|
|
57
59
|
it('should render children', async () => {
|
|
58
|
-
(0,
|
|
59
|
-
renderTip: "Hello"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
(0, _react.render)(_Tooltip2 || (_Tooltip2 = (0, _jsxRuntime.jsx)(_index.Tooltip, {
|
|
61
|
+
renderTip: "Hello",
|
|
62
|
+
children: (0, _jsxRuntime.jsx)("a", {
|
|
63
|
+
"data-testid": "trigger",
|
|
64
|
+
href: "example.html",
|
|
65
|
+
children: "Hover or focus me"
|
|
66
|
+
})
|
|
67
|
+
})));
|
|
68
|
+
const tip = _react.screen.getByRole('tooltip');
|
|
69
|
+
const trigger = _react.screen.getByTestId('trigger');
|
|
66
70
|
expect(trigger).toBeInTheDocument();
|
|
67
71
|
expect(trigger).toHaveTextContent('Hover or focus me');
|
|
68
72
|
expect(trigger).toHaveAttribute('href', 'example.html');
|
|
69
73
|
expect(tip).toHaveTextContent('Hello');
|
|
70
74
|
});
|
|
71
75
|
it('should have an aria-describedby attribute', async () => {
|
|
72
|
-
(0,
|
|
73
|
-
renderTip:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
(0, _react.render)(_Tooltip3 || (_Tooltip3 = (0, _jsxRuntime.jsx)(_index.Tooltip, {
|
|
77
|
+
renderTip: (0, _jsxRuntime.jsx)("h2", {
|
|
78
|
+
children: "Hello"
|
|
79
|
+
}),
|
|
80
|
+
children: (0, _jsxRuntime.jsx)("a", {
|
|
81
|
+
"data-testid": "trigger",
|
|
82
|
+
href: "example.html",
|
|
83
|
+
children: "Hover or focus me"
|
|
84
|
+
})
|
|
85
|
+
})));
|
|
86
|
+
const trigger = _react.screen.getByTestId('trigger');
|
|
87
|
+
const tooltip = _react.screen.getByRole('tooltip');
|
|
80
88
|
expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
|
|
81
89
|
});
|
|
82
90
|
it('should accept a function for renderTip', async () => {
|
|
83
|
-
(0,
|
|
84
|
-
renderTip: () => 'Hello'
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.Tooltip, {
|
|
92
|
+
renderTip: () => 'Hello',
|
|
93
|
+
children: _a || (_a = (0, _jsxRuntime.jsx)("a", {
|
|
94
|
+
href: "example.html",
|
|
95
|
+
children: "Hover or focus me"
|
|
96
|
+
}))
|
|
97
|
+
}));
|
|
98
|
+
const content = _react.screen.getByText('Hello');
|
|
89
99
|
expect(content).toBeInTheDocument();
|
|
90
100
|
});
|
|
91
101
|
describe('using as', () => {
|
|
92
102
|
it('should render children', async () => {
|
|
93
|
-
(0,
|
|
94
|
-
renderTip:
|
|
103
|
+
(0, _react.render)(_Tooltip4 || (_Tooltip4 = (0, _jsxRuntime.jsx)(_index.Tooltip, {
|
|
104
|
+
renderTip: (0, _jsxRuntime.jsx)("h2", {
|
|
105
|
+
children: "Hello"
|
|
106
|
+
}),
|
|
95
107
|
placement: "end",
|
|
96
108
|
as: "a",
|
|
97
|
-
href: "example.html"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
109
|
+
href: "example.html",
|
|
110
|
+
children: "Hover or focus me"
|
|
111
|
+
})));
|
|
112
|
+
const tip = _react.screen.getByRole('tooltip');
|
|
113
|
+
const trigger = _react.screen.getByText('Hover or focus me');
|
|
101
114
|
expect(trigger).toBeInTheDocument();
|
|
102
115
|
expect(trigger).toHaveAttribute('href', 'example.html');
|
|
103
116
|
expect(trigger.tagName).toBe('A');
|
|
@@ -105,38 +118,48 @@ describe('<Tooltip />', () => {
|
|
|
105
118
|
expect(tip).toHaveTextContent('Hello');
|
|
106
119
|
});
|
|
107
120
|
it('should have an aria-describedby attribute', async () => {
|
|
108
|
-
(0,
|
|
109
|
-
renderTip:
|
|
121
|
+
(0, _react.render)(_Tooltip5 || (_Tooltip5 = (0, _jsxRuntime.jsx)(_index.Tooltip, {
|
|
122
|
+
renderTip: (0, _jsxRuntime.jsx)("h2", {
|
|
123
|
+
children: "Hello"
|
|
124
|
+
}),
|
|
110
125
|
placement: "end",
|
|
111
126
|
as: "a",
|
|
112
|
-
href: "example.html"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
127
|
+
href: "example.html",
|
|
128
|
+
children: "Hover or focus me"
|
|
129
|
+
})));
|
|
130
|
+
const trigger = _react.screen.getByText('Hover or focus me');
|
|
131
|
+
const tooltip = _react.screen.getByRole('tooltip');
|
|
116
132
|
expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
|
|
117
133
|
});
|
|
118
134
|
it('should pass down the href attribute', async () => {
|
|
119
|
-
(0,
|
|
120
|
-
renderTip:
|
|
135
|
+
(0, _react.render)(_Tooltip6 || (_Tooltip6 = (0, _jsxRuntime.jsx)(_index.Tooltip, {
|
|
136
|
+
renderTip: (0, _jsxRuntime.jsx)("h2", {
|
|
137
|
+
children: "Hello"
|
|
138
|
+
}),
|
|
121
139
|
placement: "end",
|
|
122
140
|
as: "a",
|
|
123
|
-
href: "example.html"
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
href: "example.html",
|
|
142
|
+
children: "Hover or focus me"
|
|
143
|
+
})));
|
|
144
|
+
const link = _react.screen.getByText('Hover or focus me');
|
|
126
145
|
expect(link).toHaveAttribute('href', 'example.html');
|
|
127
146
|
});
|
|
128
147
|
});
|
|
129
148
|
describe('using children', () => {
|
|
130
149
|
it('should call onClick of child', async () => {
|
|
131
150
|
const onClick = _vitest.vi.fn();
|
|
132
|
-
(0,
|
|
133
|
-
renderTip: _h || (_h =
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
151
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.Tooltip, {
|
|
152
|
+
renderTip: _h || (_h = (0, _jsxRuntime.jsx)("h2", {
|
|
153
|
+
children: "Hello"
|
|
154
|
+
})),
|
|
155
|
+
children: (0, _jsxRuntime.jsx)("button", {
|
|
156
|
+
onClick: onClick,
|
|
157
|
+
children: "Hover or focus me"
|
|
158
|
+
})
|
|
159
|
+
}));
|
|
160
|
+
const button = _react.screen.getByText('Hover or focus me');
|
|
138
161
|
await _userEvent.default.click(button);
|
|
139
|
-
await (0,
|
|
162
|
+
await (0, _react.waitFor)(() => {
|
|
140
163
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
141
164
|
});
|
|
142
165
|
});
|
|
@@ -145,7 +168,7 @@ describe('<Tooltip />', () => {
|
|
|
145
168
|
const generatedComponents = (0, _generateA11yTests.generateA11yTests)(_index.Tooltip, _Tooltip7.default);
|
|
146
169
|
for (const component of generatedComponents) {
|
|
147
170
|
it(component.description, async () => {
|
|
148
|
-
const _render = (0,
|
|
171
|
+
const _render = (0, _react.render)(component.content),
|
|
149
172
|
container = _render.container;
|
|
150
173
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
151
174
|
expect(axeCheck).toBe(true);
|
package/lib/Tooltip/index.js
CHANGED
|
@@ -19,6 +19,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
19
19
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
20
20
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
21
21
|
var _props = require("./props");
|
|
22
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
22
23
|
const _excluded = ["renderTip", "isShowingContent", "defaultIsShowingContent", "on", "color", "placement", "mountNode", "constrain", "offsetX", "offsetY", "positionTarget", "onShowContent", "onHideContent", "preventTooltip", "styles"];
|
|
23
24
|
var _dec, _dec2, _dec3, _class, _Tooltip;
|
|
24
25
|
/*
|
|
@@ -44,7 +45,6 @@ var _dec, _dec2, _dec3, _class, _Tooltip;
|
|
|
44
45
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
45
46
|
* SOFTWARE.
|
|
46
47
|
*/
|
|
47
|
-
/** @jsx jsx */
|
|
48
48
|
/**
|
|
49
49
|
---
|
|
50
50
|
category: components
|
|
@@ -95,7 +95,11 @@ let Tooltip = exports.Tooltip = (_dec = (0, _withDeterministicId.withDeterminist
|
|
|
95
95
|
if (as) {
|
|
96
96
|
const Trigger = (0, _getElementType.getElementType)(Tooltip, this.props);
|
|
97
97
|
const props = (0, _omitProps.omitProps)(this.props, Tooltip.allowedProps);
|
|
98
|
-
return (0,
|
|
98
|
+
return (0, _jsxRuntime.jsx)(Trigger, {
|
|
99
|
+
...props,
|
|
100
|
+
...triggerProps,
|
|
101
|
+
children: children /*TODO check if it can be TooltipRenderChildren, this might cause a crash*/
|
|
102
|
+
});
|
|
99
103
|
} else if (typeof children === 'function') {
|
|
100
104
|
return children({
|
|
101
105
|
focused: hasFocus,
|
|
@@ -126,7 +130,8 @@ let Tooltip = exports.Tooltip = (_dec = (0, _withDeterministicId.withDeterminist
|
|
|
126
130
|
preventTooltip = _this$props3.preventTooltip,
|
|
127
131
|
styles = _this$props3.styles,
|
|
128
132
|
rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
129
|
-
return (0,
|
|
133
|
+
return (0, _jsxRuntime.jsx)(_Popover.Popover, {
|
|
134
|
+
...(0, _passthroughProps.passthroughProps)(rest),
|
|
130
135
|
isShowingContent: !preventTooltip && isShowingContent,
|
|
131
136
|
defaultIsShowingContent: !preventTooltip && defaultIsShowingContent,
|
|
132
137
|
on: on,
|
|
@@ -147,12 +152,14 @@ let Tooltip = exports.Tooltip = (_dec = (0, _withDeterministicId.withDeterminist
|
|
|
147
152
|
onBlur: this.handleBlur,
|
|
148
153
|
elementRef: this.handleRef,
|
|
149
154
|
shouldCloseOnDocumentClick: false,
|
|
150
|
-
shouldCloseOnEscape: true
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
shouldCloseOnEscape: true,
|
|
156
|
+
children: !preventTooltip ? (0, _jsxRuntime.jsx)("span", {
|
|
157
|
+
id: this._id,
|
|
158
|
+
css: styles === null || styles === void 0 ? void 0 : styles.tooltip,
|
|
159
|
+
role: "tooltip",
|
|
160
|
+
children: (0, _callRenderProp.callRenderProp)(renderTip)
|
|
161
|
+
}) : null
|
|
162
|
+
});
|
|
156
163
|
}
|
|
157
164
|
}, _Tooltip.displayName = "Tooltip", _Tooltip.componentId = 'Tooltip', _Tooltip.allowedProps = _props.allowedProps, _Tooltip.propTypes = _props.propTypes, _Tooltip.defaultProps = {
|
|
158
165
|
defaultIsShowingContent: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-tooltip",
|
|
3
|
-
"version": "10.16.1
|
|
3
|
+
"version": "10.16.1",
|
|
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
|
"module": "./es/index.js",
|
|
@@ -24,25 +24,25 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.26.0",
|
|
27
|
-
"@instructure/emotion": "10.16.1
|
|
28
|
-
"@instructure/shared-types": "10.16.1
|
|
29
|
-
"@instructure/ui-popover": "10.16.1
|
|
30
|
-
"@instructure/ui-position": "10.16.1
|
|
31
|
-
"@instructure/ui-prop-types": "10.16.1
|
|
32
|
-
"@instructure/ui-react-utils": "10.16.1
|
|
33
|
-
"@instructure/ui-testable": "10.16.1
|
|
34
|
-
"@instructure/ui-utils": "10.16.1
|
|
27
|
+
"@instructure/emotion": "10.16.1",
|
|
28
|
+
"@instructure/shared-types": "10.16.1",
|
|
29
|
+
"@instructure/ui-popover": "10.16.1",
|
|
30
|
+
"@instructure/ui-position": "10.16.1",
|
|
31
|
+
"@instructure/ui-prop-types": "10.16.1",
|
|
32
|
+
"@instructure/ui-react-utils": "10.16.1",
|
|
33
|
+
"@instructure/ui-testable": "10.16.1",
|
|
34
|
+
"@instructure/ui-utils": "10.16.1",
|
|
35
35
|
"prop-types": "^15.8.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@instructure/ui-axe-check": "10.16.1
|
|
39
|
-
"@instructure/ui-babel-preset": "10.16.1
|
|
40
|
-
"@instructure/ui-color-utils": "10.16.1
|
|
41
|
-
"@instructure/ui-scripts": "10.16.1
|
|
42
|
-
"@instructure/ui-test-locator": "10.16.1
|
|
43
|
-
"@instructure/ui-test-queries": "10.16.1
|
|
44
|
-
"@instructure/ui-test-utils": "10.16.1
|
|
45
|
-
"@instructure/ui-themes": "10.16.1
|
|
38
|
+
"@instructure/ui-axe-check": "10.16.1",
|
|
39
|
+
"@instructure/ui-babel-preset": "10.16.1",
|
|
40
|
+
"@instructure/ui-color-utils": "10.16.1",
|
|
41
|
+
"@instructure/ui-scripts": "10.16.1",
|
|
42
|
+
"@instructure/ui-test-locator": "10.16.1",
|
|
43
|
+
"@instructure/ui-test-queries": "10.16.1",
|
|
44
|
+
"@instructure/ui-test-utils": "10.16.1",
|
|
45
|
+
"@instructure/ui-themes": "10.16.1",
|
|
46
46
|
"@testing-library/jest-dom": "^6.6.3",
|
|
47
47
|
"@testing-library/react": "^16.0.1",
|
|
48
48
|
"@testing-library/user-event": "^14.5.2",
|
package/src/Tooltip/index.tsx
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
/** @jsx jsx */
|
|
26
25
|
import { Component, ReactNode } from 'react'
|
|
27
26
|
|
|
28
27
|
import {
|
|
@@ -36,7 +35,7 @@ import {
|
|
|
36
35
|
import { testable } from '@instructure/ui-testable'
|
|
37
36
|
import { Popover } from '@instructure/ui-popover'
|
|
38
37
|
import type { PopoverProps } from '@instructure/ui-popover'
|
|
39
|
-
import { withStyle
|
|
38
|
+
import { withStyle } from '@instructure/emotion'
|
|
40
39
|
|
|
41
40
|
import generateStyle from './styles'
|
|
42
41
|
import generateComponentTheme from './theme'
|