@instructure/ui-tabs 10.16.0 → 10.16.1-pr-snapshot-1744893671793
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 +8 -0
- package/es/Tabs/Panel/__new-tests__/Panel.test.js +9 -7
- package/es/Tabs/Panel/index.js +21 -17
- package/es/Tabs/Tab/__new-tests__/Tab.test.js +49 -37
- package/es/Tabs/Tab/index.js +8 -6
- package/es/Tabs/__new-tests__/Tabs.test.js +254 -174
- package/es/Tabs/index.js +42 -38
- package/lib/Tabs/Panel/__new-tests__/Panel.test.js +11 -10
- package/lib/Tabs/Panel/index.js +20 -16
- package/lib/Tabs/Tab/__new-tests__/Tab.test.js +66 -54
- package/lib/Tabs/Tab/index.js +7 -6
- package/lib/Tabs/__new-tests__/Tabs.test.js +254 -174
- package/lib/Tabs/index.js +41 -38
- package/package.json +20 -20
- package/src/Tabs/Panel/__new-tests__/Panel.test.tsx +1 -2
- package/src/Tabs/Panel/index.tsx +1 -2
- package/src/Tabs/Tab/__new-tests__/Tab.test.tsx +0 -1
- package/src/Tabs/Tab/index.tsx +2 -3
- package/src/Tabs/__new-tests__/Tabs.test.tsx +2 -2
- package/src/Tabs/index.tsx +13 -10
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Tabs/Panel/__new-tests__/Panel.test.d.ts.map +1 -1
- package/types/Tabs/Panel/index.d.ts +1 -3
- package/types/Tabs/Panel/index.d.ts.map +1 -1
- package/types/Tabs/Tab/__new-tests__/Tab.test.d.ts.map +1 -1
- package/types/Tabs/Tab/index.d.ts +2 -4
- package/types/Tabs/Tab/index.d.ts.map +1 -1
- package/types/Tabs/index.d.ts +2 -4
- package/types/Tabs/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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-pr-snapshot-1744893671793](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-pr-snapshot-1744893671793) (2025-04-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-tabs
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [10.16.0](https://github.com/instructure/instructure-ui/compare/v10.15.2...v10.16.0) (2025-04-11)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-tabs
|
|
@@ -23,24 +23,26 @@ var _Panel, _Panel2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen } from '@testing-library/react';
|
|
28
27
|
import '@testing-library/jest-dom';
|
|
29
28
|
import { Panel } from '../index';
|
|
29
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
30
30
|
describe('<Tabs.Panel />', () => {
|
|
31
31
|
it('should render children', async () => {
|
|
32
|
-
render(_Panel || (_Panel =
|
|
32
|
+
render(_Panel || (_Panel = _jsx(Panel, {
|
|
33
33
|
isSelected: true,
|
|
34
|
-
renderTitle: "Panel Title"
|
|
35
|
-
|
|
34
|
+
renderTitle: "Panel Title",
|
|
35
|
+
children: "Panel contents"
|
|
36
|
+
})));
|
|
36
37
|
const children = screen.getByText('Panel contents');
|
|
37
38
|
expect(children).toBeInTheDocument();
|
|
38
39
|
});
|
|
39
40
|
it('should have appropriate role attribute', async () => {
|
|
40
|
-
const _render = render(_Panel2 || (_Panel2 =
|
|
41
|
+
const _render = render(_Panel2 || (_Panel2 = _jsx(Panel, {
|
|
41
42
|
isSelected: true,
|
|
42
|
-
renderTitle: "Panel Title"
|
|
43
|
-
|
|
43
|
+
renderTitle: "Panel Title",
|
|
44
|
+
children: "Panel contents"
|
|
45
|
+
}))),
|
|
44
46
|
container = _render.container;
|
|
45
47
|
const tabPanel = container.querySelector('[class$="-panel"]');
|
|
46
48
|
expect(tabPanel).toHaveAttribute('role', 'tabpanel');
|
package/es/Tabs/Panel/index.js
CHANGED
|
@@ -25,12 +25,11 @@ var _dec, _class, _Panel;
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
/** @jsx jsx */
|
|
29
28
|
import { Component } from 'react';
|
|
30
29
|
import { View } from '@instructure/ui-view';
|
|
31
30
|
import { passthroughProps } from '@instructure/ui-react-utils';
|
|
32
31
|
import { Transition } from '@instructure/ui-motion';
|
|
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';
|
|
@@ -41,6 +40,7 @@ parent: Tabs
|
|
|
41
40
|
id: Tabs.Panel
|
|
42
41
|
---
|
|
43
42
|
**/
|
|
43
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
44
44
|
let Panel = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_Panel = class Panel extends Component {
|
|
45
45
|
constructor(...args) {
|
|
46
46
|
super(...args);
|
|
@@ -88,27 +88,31 @@ let Panel = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_clas
|
|
|
88
88
|
active = _this$props4.active,
|
|
89
89
|
unmountOnExit = _this$props4.unmountOnExit,
|
|
90
90
|
props = _objectWithoutProperties(_this$props4, _excluded);
|
|
91
|
-
return
|
|
91
|
+
return _jsx("div", {
|
|
92
|
+
...passthroughProps(props),
|
|
92
93
|
css: styles === null || styles === void 0 ? void 0 : styles.panel,
|
|
93
94
|
role: "tabpanel",
|
|
94
95
|
tabIndex: 0,
|
|
95
96
|
id: id,
|
|
96
97
|
"aria-labelledby": labelledBy,
|
|
97
98
|
"aria-hidden": this.isHidden ? 'true' : void 0,
|
|
98
|
-
ref: this.handleRef
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
99
|
+
ref: this.handleRef,
|
|
100
|
+
children: _jsx(Transition, {
|
|
101
|
+
type: "fade",
|
|
102
|
+
in: !this.isHidden,
|
|
103
|
+
unmountOnExit: unmountOnExit,
|
|
104
|
+
transitionExit: false,
|
|
105
|
+
children: _jsx(View, {
|
|
106
|
+
css: styles === null || styles === void 0 ? void 0 : styles.content,
|
|
107
|
+
maxHeight: maxHeight,
|
|
108
|
+
minHeight: minHeight,
|
|
109
|
+
as: "div",
|
|
110
|
+
padding: padding,
|
|
111
|
+
textAlign: textAlign,
|
|
112
|
+
children: children
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
});
|
|
112
116
|
}
|
|
113
117
|
}, _Panel.displayName = "Panel", _Panel.componentId = 'Tabs.Panel', _Panel.allowedProps = allowedProps, _Panel.propTypes = propTypes, _Panel.defaultProps = {
|
|
114
118
|
isDisabled: false,
|
|
@@ -23,99 +23,108 @@ var _Tab, _Tab2, _Tab3, _Tab4, _Tab5, _Tab6, _Tab7, _Tab8;
|
|
|
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';
|
|
30
29
|
import '@testing-library/jest-dom';
|
|
31
30
|
import { Tab } from '../index';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
32
|
describe('<Tabs.Tab />', () => {
|
|
33
33
|
it('should render children', async () => {
|
|
34
|
-
render(_Tab || (_Tab =
|
|
34
|
+
render(_Tab || (_Tab = _jsx(Tab, {
|
|
35
35
|
id: "foo",
|
|
36
36
|
index: 0,
|
|
37
|
-
controls: "foo-panel"
|
|
38
|
-
|
|
37
|
+
controls: "foo-panel",
|
|
38
|
+
children: "Tab Label"
|
|
39
|
+
})));
|
|
39
40
|
const children = screen.getByText('Tab Label');
|
|
40
41
|
expect(children).toBeInTheDocument();
|
|
41
42
|
});
|
|
42
43
|
it('should have appropriate role attribute', async () => {
|
|
43
|
-
render(_Tab2 || (_Tab2 =
|
|
44
|
+
render(_Tab2 || (_Tab2 = _jsx(Tab, {
|
|
44
45
|
id: "foo",
|
|
45
46
|
index: 0,
|
|
46
|
-
controls: "foo-panel"
|
|
47
|
-
|
|
47
|
+
controls: "foo-panel",
|
|
48
|
+
children: "Tab Label"
|
|
49
|
+
})));
|
|
48
50
|
const tab = screen.getByRole('tab');
|
|
49
51
|
expect(tab).toBeInTheDocument();
|
|
50
52
|
});
|
|
51
53
|
it('should have appropriate aria attributes', async () => {
|
|
52
|
-
render(_Tab3 || (_Tab3 =
|
|
54
|
+
render(_Tab3 || (_Tab3 = _jsx(Tab, {
|
|
53
55
|
id: "foo",
|
|
54
56
|
index: 0,
|
|
55
|
-
controls: "foo-panel"
|
|
56
|
-
|
|
57
|
+
controls: "foo-panel",
|
|
58
|
+
children: "Tab Label"
|
|
59
|
+
})));
|
|
57
60
|
const tab = screen.getByRole('tab');
|
|
58
61
|
expect(tab).not.toHaveAttribute('aria-selected');
|
|
59
62
|
expect(tab).not.toHaveAttribute('aria-disabled');
|
|
60
63
|
});
|
|
61
64
|
it('should set the aria-selected attribute', async () => {
|
|
62
|
-
render(_Tab4 || (_Tab4 =
|
|
65
|
+
render(_Tab4 || (_Tab4 = _jsx(Tab, {
|
|
63
66
|
id: "foo",
|
|
64
67
|
index: 0,
|
|
65
68
|
controls: "foo-panel",
|
|
66
|
-
isSelected: true
|
|
67
|
-
|
|
69
|
+
isSelected: true,
|
|
70
|
+
children: "Tab Label"
|
|
71
|
+
})));
|
|
68
72
|
const tab = screen.getByRole('tab');
|
|
69
73
|
expect(tab).toHaveAttribute('aria-selected', 'true');
|
|
70
74
|
});
|
|
71
75
|
it('should set the aria-disabled attribute', async () => {
|
|
72
|
-
render(_Tab5 || (_Tab5 =
|
|
76
|
+
render(_Tab5 || (_Tab5 = _jsx(Tab, {
|
|
73
77
|
id: "foo",
|
|
74
78
|
index: 0,
|
|
75
79
|
controls: "foo-panel",
|
|
76
|
-
isDisabled: true
|
|
77
|
-
|
|
80
|
+
isDisabled: true,
|
|
81
|
+
children: "Tab Label"
|
|
82
|
+
})));
|
|
78
83
|
const tab = screen.getByRole('tab');
|
|
79
84
|
expect(tab).toHaveAttribute('aria-disabled', 'true');
|
|
80
85
|
});
|
|
81
86
|
it('should set the tabindex to 0 when selected', async () => {
|
|
82
|
-
render(_Tab6 || (_Tab6 =
|
|
87
|
+
render(_Tab6 || (_Tab6 = _jsx(Tab, {
|
|
83
88
|
id: "foo",
|
|
84
89
|
index: 0,
|
|
85
90
|
controls: "foo-panel",
|
|
86
|
-
isSelected: true
|
|
87
|
-
|
|
91
|
+
isSelected: true,
|
|
92
|
+
children: "Tab Label"
|
|
93
|
+
})));
|
|
88
94
|
const tab = screen.getByRole('tab');
|
|
89
95
|
expect(tab).toHaveAttribute('tabindex', '0');
|
|
90
96
|
});
|
|
91
97
|
it('should not set the tabindex when not selected', async () => {
|
|
92
|
-
render(_Tab7 || (_Tab7 =
|
|
98
|
+
render(_Tab7 || (_Tab7 = _jsx(Tab, {
|
|
93
99
|
id: "foo",
|
|
94
100
|
index: 0,
|
|
95
|
-
controls: "foo-panel"
|
|
96
|
-
|
|
101
|
+
controls: "foo-panel",
|
|
102
|
+
children: "Tab Label"
|
|
103
|
+
})));
|
|
97
104
|
const tab = screen.getByRole('tab');
|
|
98
105
|
expect(tab).not.toHaveAttribute('tabindex');
|
|
99
106
|
});
|
|
100
107
|
it('should remove the tabindex attribute when disabled', async () => {
|
|
101
|
-
render(_Tab8 || (_Tab8 =
|
|
108
|
+
render(_Tab8 || (_Tab8 = _jsx(Tab, {
|
|
102
109
|
id: "foo",
|
|
103
110
|
index: 0,
|
|
104
111
|
controls: "foo-panel",
|
|
105
|
-
isDisabled: true
|
|
106
|
-
|
|
112
|
+
isDisabled: true,
|
|
113
|
+
children: "Tab Label"
|
|
114
|
+
})));
|
|
107
115
|
const tab = screen.getByRole('tab');
|
|
108
116
|
expect(tab).not.toHaveAttribute('tabindex');
|
|
109
117
|
});
|
|
110
118
|
it('should call onClick when clicked', async () => {
|
|
111
119
|
const onClick = vi.fn();
|
|
112
120
|
const index = 2;
|
|
113
|
-
render(
|
|
121
|
+
render(_jsx(Tab, {
|
|
114
122
|
id: "foo",
|
|
115
123
|
index: index,
|
|
116
124
|
controls: "foo-panel",
|
|
117
|
-
onClick: onClick
|
|
118
|
-
|
|
125
|
+
onClick: onClick,
|
|
126
|
+
children: "Tab Label"
|
|
127
|
+
}));
|
|
119
128
|
const tab = screen.getByRole('tab');
|
|
120
129
|
await userEvent.click(tab);
|
|
121
130
|
await waitFor(() => {
|
|
@@ -126,13 +135,14 @@ describe('<Tabs.Tab />', () => {
|
|
|
126
135
|
});
|
|
127
136
|
it('should NOT call onClick when clicked and tab is disabled', async () => {
|
|
128
137
|
const onClick = vi.fn();
|
|
129
|
-
render(
|
|
138
|
+
render(_jsx(Tab, {
|
|
130
139
|
id: "foo",
|
|
131
140
|
index: 0,
|
|
132
141
|
controls: "foo-panel",
|
|
133
142
|
onClick: onClick,
|
|
134
|
-
isDisabled: true
|
|
135
|
-
|
|
143
|
+
isDisabled: true,
|
|
144
|
+
children: "Tab Label"
|
|
145
|
+
}));
|
|
136
146
|
const tab = screen.getByRole('tab');
|
|
137
147
|
await userEvent.click(tab);
|
|
138
148
|
await waitFor(() => {
|
|
@@ -142,13 +152,14 @@ describe('<Tabs.Tab />', () => {
|
|
|
142
152
|
it('should call onKeyDown when keys are pressed and tab is selected', async () => {
|
|
143
153
|
const onKeyDown = vi.fn();
|
|
144
154
|
const index = 2;
|
|
145
|
-
render(
|
|
155
|
+
render(_jsx(Tab, {
|
|
146
156
|
id: "foo",
|
|
147
157
|
isSelected: true,
|
|
148
158
|
index: index,
|
|
149
159
|
controls: "foo-panel",
|
|
150
|
-
onKeyDown: onKeyDown
|
|
151
|
-
|
|
160
|
+
onKeyDown: onKeyDown,
|
|
161
|
+
children: "Tab Label"
|
|
162
|
+
}));
|
|
152
163
|
const tab = screen.getByRole('tab');
|
|
153
164
|
await userEvent.type(tab, '{enter}');
|
|
154
165
|
await waitFor(() => {
|
|
@@ -159,13 +170,14 @@ describe('<Tabs.Tab />', () => {
|
|
|
159
170
|
});
|
|
160
171
|
it('should NOT call onKeyDown when keys are pressed and tab is disabled', async () => {
|
|
161
172
|
const onKeyDown = vi.fn();
|
|
162
|
-
render(
|
|
173
|
+
render(_jsx(Tab, {
|
|
163
174
|
id: "foo",
|
|
164
175
|
index: 0,
|
|
165
176
|
controls: "foo-panel",
|
|
166
177
|
onKeyDown: onKeyDown,
|
|
167
|
-
isDisabled: true
|
|
168
|
-
|
|
178
|
+
isDisabled: true,
|
|
179
|
+
children: "Tab Label"
|
|
180
|
+
}));
|
|
169
181
|
const tab = screen.getByRole('tab');
|
|
170
182
|
await userEvent.type(tab, '{enter}');
|
|
171
183
|
await waitFor(() => {
|
package/es/Tabs/Tab/index.js
CHANGED
|
@@ -25,11 +25,10 @@ var _dec, _class, _Tab;
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
import React, { Component } from 'react';
|
|
28
|
+
import { Component } from 'react';
|
|
30
29
|
import { passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
|
|
31
30
|
import { View } from '@instructure/ui-view';
|
|
32
|
-
import { withStyle
|
|
31
|
+
import { withStyle } from '@instructure/emotion';
|
|
33
32
|
import generateStyle from './styles';
|
|
34
33
|
import generateComponentTheme from './theme';
|
|
35
34
|
import { allowedProps, propTypes } from './props';
|
|
@@ -39,6 +38,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
39
38
|
category: components/utilities
|
|
40
39
|
---
|
|
41
40
|
**/
|
|
41
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
42
42
|
let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_Tab = class Tab extends Component {
|
|
43
43
|
constructor(...args) {
|
|
44
44
|
super(...args);
|
|
@@ -93,7 +93,8 @@ let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
93
93
|
children = _this$props5.children,
|
|
94
94
|
styles = _this$props5.styles,
|
|
95
95
|
props = _objectWithoutProperties(_this$props5, _excluded);
|
|
96
|
-
return
|
|
96
|
+
return _jsx(View, {
|
|
97
|
+
...passthroughProps(props),
|
|
97
98
|
as: "div",
|
|
98
99
|
role: "tab",
|
|
99
100
|
id: id,
|
|
@@ -105,8 +106,9 @@ let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
105
106
|
"aria-controls": controls,
|
|
106
107
|
tabIndex: isSelected && !isDisabled ? 0 : void 0,
|
|
107
108
|
position: "relative",
|
|
108
|
-
focusPosition: "inset"
|
|
109
|
-
|
|
109
|
+
focusPosition: "inset",
|
|
110
|
+
children: callRenderProp(children)
|
|
111
|
+
});
|
|
110
112
|
}
|
|
111
113
|
}, _Tab.displayName = "Tab", _Tab.componentId = 'Tabs.Tab', _Tab.allowedProps = allowedProps, _Tab.propTypes = propTypes, _Tab.defaultProps = {
|
|
112
114
|
variant: 'default',
|