@instructure/ui-tabs 8.13.1-snapshot.9 → 8.14.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 +4 -0
- package/es/Tabs/Panel/index.js +3 -5
- package/es/Tabs/Panel/props.js +0 -8
- package/es/Tabs/Tab/index.js +17 -21
- package/es/Tabs/TabsLocator.js +2 -1
- package/es/Tabs/index.js +14 -13
- package/es/Tabs/props.js +0 -32
- package/lib/Tabs/Panel/index.js +3 -5
- package/lib/Tabs/Panel/props.js +0 -8
- package/lib/Tabs/Tab/index.js +19 -21
- package/lib/Tabs/TabsLocator.js +2 -1
- package/lib/Tabs/index.js +14 -13
- package/lib/Tabs/props.js +0 -32
- package/package.json +21 -22
- package/src/Tabs/Panel/index.tsx +5 -9
- package/src/Tabs/Panel/props.ts +10 -10
- package/src/Tabs/Tab/index.tsx +15 -19
- package/src/Tabs/Tab/props.ts +10 -3
- package/src/Tabs/index.tsx +55 -92
- package/src/Tabs/props.ts +41 -32
- package/tsconfig.build.json +25 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/Tabs/Panel/index.d.ts +10 -12
- package/types/Tabs/Panel/index.d.ts.map +1 -1
- package/types/Tabs/Panel/props.d.ts +10 -3
- package/types/Tabs/Panel/props.d.ts.map +1 -1
- package/types/Tabs/Tab/index.d.ts +24 -19
- package/types/Tabs/Tab/index.d.ts.map +1 -1
- package/types/Tabs/Tab/props.d.ts +10 -3
- package/types/Tabs/Tab/props.d.ts.map +1 -1
- package/types/Tabs/TabsLocator.d.ts +381 -381
- package/types/Tabs/index.d.ts +38 -35
- package/types/Tabs/index.d.ts.map +1 -1
- package/types/Tabs/props.d.ts +40 -4
- package/types/Tabs/props.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.14.0](https://github.com/instructure/instructure-ui/compare/v8.13.0...v8.14.0) (2021-12-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-tabs
|
|
9
|
+
|
|
6
10
|
# [8.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-tabs
|
package/es/Tabs/Panel/index.js
CHANGED
|
@@ -41,6 +41,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
41
41
|
parent: Tabs
|
|
42
42
|
id: Tabs.Panel
|
|
43
43
|
---
|
|
44
|
+
@tsProps
|
|
44
45
|
**/
|
|
45
46
|
|
|
46
47
|
let Panel = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Panel extends Component {
|
|
@@ -64,7 +65,7 @@ let Panel = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_clas
|
|
|
64
65
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
componentDidUpdate(
|
|
68
|
+
componentDidUpdate() {
|
|
68
69
|
var _this$props$makeStyle2, _this$props2;
|
|
69
70
|
|
|
70
71
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
@@ -110,14 +111,11 @@ let Panel = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_clas
|
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
}, _class2.displayName = "Panel", _class2.componentId = 'Tabs.Panel', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
113
|
-
children: null,
|
|
114
114
|
isDisabled: false,
|
|
115
115
|
textAlign: 'start',
|
|
116
116
|
variant: 'default',
|
|
117
|
-
labelledBy: null,
|
|
118
117
|
isSelected: false,
|
|
119
|
-
padding: 'small'
|
|
120
|
-
elementRef: el => {}
|
|
118
|
+
padding: 'small'
|
|
121
119
|
}, _temp)) || _class);
|
|
122
120
|
export default Panel;
|
|
123
121
|
export { Panel };
|
package/es/Tabs/Panel/props.js
CHANGED
|
@@ -24,10 +24,6 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* The content that will be rendered in the corresponding <Tab /> and will label
|
|
29
|
-
* this `<Tabs.Panel />` for screen readers
|
|
30
|
-
*/
|
|
31
27
|
renderTitle: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
32
28
|
children: PropTypes.node,
|
|
33
29
|
variant: PropTypes.oneOf(['default', 'secondary']),
|
|
@@ -39,10 +35,6 @@ const propTypes = {
|
|
|
39
35
|
labelledBy: PropTypes.string,
|
|
40
36
|
padding: ThemeablePropTypes.spacing,
|
|
41
37
|
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* provides a reference to the underlying html root element
|
|
45
|
-
*/
|
|
46
38
|
elementRef: PropTypes.func
|
|
47
39
|
};
|
|
48
40
|
const allowedProps = ['renderTitle', 'children', 'variant', 'isSelected', 'isDisabled', 'maxHeight', 'minHeight', 'id', 'labelledBy', 'padding', 'textAlign', 'elementRef'];
|
package/es/Tabs/Tab/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var _dec, _class, _class2, _temp;
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/** @jsx jsx */
|
|
31
|
-
import { Component } from 'react';
|
|
31
|
+
import React, { Component } from 'react';
|
|
32
32
|
import { passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
|
|
33
33
|
import { View } from '@instructure/ui-view';
|
|
34
34
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
@@ -40,6 +40,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
40
40
|
parent: Tabs
|
|
41
41
|
id: Tabs.Tab
|
|
42
42
|
---
|
|
43
|
+
@tsProps
|
|
43
44
|
**/
|
|
44
45
|
|
|
45
46
|
let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Tab extends Component {
|
|
@@ -57,10 +58,12 @@ let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
if (typeof onClick === 'function') {
|
|
62
|
+
onClick(event, {
|
|
63
|
+
index,
|
|
64
|
+
id
|
|
65
|
+
});
|
|
66
|
+
}
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
this.handleKeyDown = event => {
|
|
@@ -74,10 +77,12 @@ let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
74
77
|
return;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
if (typeof onKeyDown === 'function') {
|
|
81
|
+
onKeyDown(event, {
|
|
82
|
+
index,
|
|
83
|
+
id
|
|
84
|
+
});
|
|
85
|
+
}
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
88
|
|
|
@@ -87,7 +92,7 @@ let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
87
92
|
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
88
93
|
}
|
|
89
94
|
|
|
90
|
-
componentDidUpdate(
|
|
95
|
+
componentDidUpdate() {
|
|
91
96
|
var _this$props$makeStyle2, _this$props4;
|
|
92
97
|
|
|
93
98
|
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
@@ -114,25 +119,16 @@ let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
114
119
|
"aria-selected": isSelected ? 'true' : void 0,
|
|
115
120
|
"aria-disabled": isDisabled ? 'true' : void 0,
|
|
116
121
|
"aria-controls": controls,
|
|
117
|
-
tabIndex: isSelected && !isDisabled ?
|
|
122
|
+
tabIndex: isSelected && !isDisabled ? 0 : void 0,
|
|
118
123
|
position: "relative",
|
|
119
124
|
focusPosition: "inset"
|
|
120
125
|
}), callRenderProp(children));
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
}, _class2.displayName = "Tab", _class2.componentId = 'Tabs.Tab', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
124
|
-
children: null,
|
|
125
129
|
variant: 'default',
|
|
126
130
|
isDisabled: false,
|
|
127
|
-
isSelected: false
|
|
128
|
-
onClick: (event, _ref) => {
|
|
129
|
-
let index = _ref.index,
|
|
130
|
-
id = _ref.id;
|
|
131
|
-
},
|
|
132
|
-
onKeyDown: (event, _ref2) => {
|
|
133
|
-
let index = _ref2.index,
|
|
134
|
-
id = _ref2.id;
|
|
135
|
-
}
|
|
131
|
+
isSelected: false
|
|
136
132
|
}, _temp)) || _class);
|
|
137
133
|
export default Tab;
|
|
138
134
|
export { Tab };
|
package/es/Tabs/TabsLocator.js
CHANGED
|
@@ -25,7 +25,8 @@ import { locator } from '@instructure/ui-test-locator';
|
|
|
25
25
|
import { Tabs } from './index';
|
|
26
26
|
const TabLocator = locator('[role="tab"]');
|
|
27
27
|
const PanelLocator = locator('[role="tabpanel"]');
|
|
28
|
-
const SelectedTabLocator = locator('[role="tab"][aria-selected="true"]');
|
|
28
|
+
const SelectedTabLocator = locator('[role="tab"][aria-selected="true"]'); // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
29
|
+
|
|
29
30
|
export const TabsLocator = locator(Tabs.selector, {
|
|
30
31
|
findTab: function () {
|
|
31
32
|
return TabLocator.find(...arguments);
|
package/es/Tabs/index.js
CHANGED
|
@@ -51,10 +51,16 @@ import { allowedProps, propTypes } from './props';
|
|
|
51
51
|
---
|
|
52
52
|
category: components
|
|
53
53
|
---
|
|
54
|
+
@tsProps
|
|
54
55
|
**/
|
|
55
56
|
let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = textDirectionContextConsumer(), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_temp = _class2 = class Tabs extends Component {
|
|
56
57
|
constructor(props) {
|
|
57
58
|
super(props);
|
|
59
|
+
this._tabList = null;
|
|
60
|
+
this._focusable = null;
|
|
61
|
+
this._tabListPosition = void 0;
|
|
62
|
+
this._debounced = void 0;
|
|
63
|
+
this._resizeListener = void 0;
|
|
58
64
|
this.ref = null;
|
|
59
65
|
|
|
60
66
|
this.handleRef = el => {
|
|
@@ -67,8 +73,7 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tex
|
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
this.handleTabClick = (event, _ref) => {
|
|
70
|
-
let index = _ref.index
|
|
71
|
-
id = _ref.id;
|
|
76
|
+
let index = _ref.index;
|
|
72
77
|
const nextTab = this.getNextTab(index, 0);
|
|
73
78
|
this.fireOnChange(event, nextTab);
|
|
74
79
|
};
|
|
@@ -106,8 +111,6 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tex
|
|
|
106
111
|
this._tabList = el;
|
|
107
112
|
};
|
|
108
113
|
|
|
109
|
-
this._tabList = null;
|
|
110
|
-
this._tabListPosition = null;
|
|
111
114
|
this.state = {
|
|
112
115
|
withTabListOverflow: false
|
|
113
116
|
};
|
|
@@ -127,7 +130,7 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tex
|
|
|
127
130
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
128
131
|
}
|
|
129
132
|
|
|
130
|
-
componentDidUpdate(prevProps, prevState
|
|
133
|
+
componentDidUpdate(prevProps, prevState) {
|
|
131
134
|
var _this$props$makeStyle2, _this$props2;
|
|
132
135
|
|
|
133
136
|
if (this.props.shouldFocusOnRender && !prevProps.shouldFocusOnRender) {
|
|
@@ -176,7 +179,9 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tex
|
|
|
176
179
|
const newWidth = entry.contentRect.width;
|
|
177
180
|
|
|
178
181
|
if (this._tabListPosition.width !== newWidth) {
|
|
179
|
-
|
|
182
|
+
var _this$_debounced;
|
|
183
|
+
|
|
184
|
+
(_this$_debounced = this._debounced) === null || _this$_debounced === void 0 ? void 0 : _this$_debounced.call(this);
|
|
180
185
|
}
|
|
181
186
|
}
|
|
182
187
|
});
|
|
@@ -200,13 +205,15 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tex
|
|
|
200
205
|
tabOverflow = _this$props3.tabOverflow,
|
|
201
206
|
styles = _this$props3.styles;
|
|
202
207
|
|
|
203
|
-
if (tabOverflow === 'scroll') {
|
|
208
|
+
if (styles && tabOverflow === 'scroll') {
|
|
204
209
|
if (variant === 'default') {
|
|
205
210
|
return px(styles === null || styles === void 0 ? void 0 : styles.scrollOverlayWidthDefault);
|
|
206
211
|
} else {
|
|
207
212
|
return px(styles === null || styles === void 0 ? void 0 : styles.scrollOverlayWidthSecondary);
|
|
208
213
|
}
|
|
209
214
|
}
|
|
215
|
+
|
|
216
|
+
return 0;
|
|
210
217
|
}
|
|
211
218
|
|
|
212
219
|
showActiveTabIfOverlayed(activeTabEl) {
|
|
@@ -380,12 +387,6 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tex
|
|
|
380
387
|
|
|
381
388
|
}, _class2.displayName = "Tabs", _class2.componentId = 'Tabs', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
382
389
|
variant: 'default',
|
|
383
|
-
onRequestTabChange: (event, _ref4) => {
|
|
384
|
-
let index = _ref4.index,
|
|
385
|
-
id = _ref4.id;
|
|
386
|
-
},
|
|
387
|
-
children: null,
|
|
388
|
-
elementRef: () => {},
|
|
389
390
|
shouldFocusOnRender: false,
|
|
390
391
|
tabOverflow: 'stack'
|
|
391
392
|
}, _class2.Panel = Panel, _class2.Tab = Tab, _temp)) || _class) || _class) || _class);
|
package/es/Tabs/props.js
CHANGED
|
@@ -26,50 +26,18 @@ import { Children } from '@instructure/ui-prop-types';
|
|
|
26
26
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
27
27
|
import { Panel } from './Panel';
|
|
28
28
|
const propTypes = {
|
|
29
|
-
/**
|
|
30
|
-
* children of type `Tabs.Panel`
|
|
31
|
-
*/
|
|
32
29
|
children: Children.oneOf([Panel, null]),
|
|
33
30
|
variant: PropTypes.oneOf(['default', 'secondary']),
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* A screen ready only label for the list of tabs
|
|
37
|
-
*/
|
|
38
31
|
screenReaderLabel: PropTypes.string,
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Called when the selected tab should change
|
|
42
|
-
*/
|
|
43
32
|
onRequestTabChange: PropTypes.func,
|
|
44
33
|
maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
45
34
|
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
46
35
|
minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
47
36
|
fixHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
51
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
52
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
53
|
-
*/
|
|
54
37
|
margin: ThemeablePropTypes.spacing,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
58
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
59
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
60
|
-
*/
|
|
61
38
|
padding: ThemeablePropTypes.spacing,
|
|
62
39
|
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* provides a reference to the underlying html root element
|
|
66
|
-
*/
|
|
67
40
|
elementRef: PropTypes.func,
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Choose whether Tabs should stack or scroll when they exceed the width of their
|
|
71
|
-
* container.
|
|
72
|
-
*/
|
|
73
41
|
tabOverflow: PropTypes.oneOf(['stack', 'scroll']),
|
|
74
42
|
shouldFocusOnRender: PropTypes.bool
|
|
75
43
|
};
|
package/lib/Tabs/Panel/index.js
CHANGED
|
@@ -34,6 +34,7 @@ var _dec, _class, _class2, _temp;
|
|
|
34
34
|
parent: Tabs
|
|
35
35
|
id: Tabs.Panel
|
|
36
36
|
---
|
|
37
|
+
@tsProps
|
|
37
38
|
**/
|
|
38
39
|
let Panel = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = class Panel extends _react.Component {
|
|
39
40
|
constructor() {
|
|
@@ -56,7 +57,7 @@ let Panel = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
56
57
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
componentDidUpdate(
|
|
60
|
+
componentDidUpdate() {
|
|
60
61
|
var _this$props$makeStyle2, _this$props2;
|
|
61
62
|
|
|
62
63
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
@@ -101,14 +102,11 @@ let Panel = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
}, _class2.displayName = "Panel", _class2.componentId = 'Tabs.Panel', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
104
|
-
children: null,
|
|
105
105
|
isDisabled: false,
|
|
106
106
|
textAlign: 'start',
|
|
107
107
|
variant: 'default',
|
|
108
|
-
labelledBy: null,
|
|
109
108
|
isSelected: false,
|
|
110
|
-
padding: 'small'
|
|
111
|
-
elementRef: el => {}
|
|
109
|
+
padding: 'small'
|
|
112
110
|
}, _temp)) || _class);
|
|
113
111
|
exports.Panel = Panel;
|
|
114
112
|
var _default = Panel;
|
package/lib/Tabs/Panel/props.js
CHANGED
|
@@ -35,10 +35,6 @@ var _emotion = require("@instructure/emotion");
|
|
|
35
35
|
* SOFTWARE.
|
|
36
36
|
*/
|
|
37
37
|
const propTypes = {
|
|
38
|
-
/**
|
|
39
|
-
* The content that will be rendered in the corresponding <Tab /> and will label
|
|
40
|
-
* this `<Tabs.Panel />` for screen readers
|
|
41
|
-
*/
|
|
42
38
|
renderTitle: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
43
39
|
children: _propTypes.default.node,
|
|
44
40
|
variant: _propTypes.default.oneOf(['default', 'secondary']),
|
|
@@ -50,10 +46,6 @@ const propTypes = {
|
|
|
50
46
|
labelledBy: _propTypes.default.string,
|
|
51
47
|
padding: _emotion.ThemeablePropTypes.spacing,
|
|
52
48
|
textAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* provides a reference to the underlying html root element
|
|
56
|
-
*/
|
|
57
49
|
elementRef: _propTypes.default.func
|
|
58
50
|
};
|
|
59
51
|
exports.propTypes = propTypes;
|
package/lib/Tabs/Tab/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
@@ -9,7 +11,7 @@ exports.default = exports.Tab = void 0;
|
|
|
9
11
|
|
|
10
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
13
|
|
|
12
|
-
var _react = require("react");
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
15
|
|
|
14
16
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
15
17
|
|
|
@@ -34,6 +36,7 @@ var _dec, _class, _class2, _temp;
|
|
|
34
36
|
parent: Tabs
|
|
35
37
|
id: Tabs.Tab
|
|
36
38
|
---
|
|
39
|
+
@tsProps
|
|
37
40
|
**/
|
|
38
41
|
let Tab = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = class Tab extends _react.Component {
|
|
39
42
|
constructor() {
|
|
@@ -50,10 +53,12 @@ let Tab = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec
|
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
if (typeof onClick === 'function') {
|
|
57
|
+
onClick(event, {
|
|
58
|
+
index,
|
|
59
|
+
id
|
|
60
|
+
});
|
|
61
|
+
}
|
|
57
62
|
};
|
|
58
63
|
|
|
59
64
|
this.handleKeyDown = event => {
|
|
@@ -67,10 +72,12 @@ let Tab = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec
|
|
|
67
72
|
return;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if (typeof onKeyDown === 'function') {
|
|
76
|
+
onKeyDown(event, {
|
|
77
|
+
index,
|
|
78
|
+
id
|
|
79
|
+
});
|
|
80
|
+
}
|
|
74
81
|
};
|
|
75
82
|
}
|
|
76
83
|
|
|
@@ -80,7 +87,7 @@ let Tab = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec
|
|
|
80
87
|
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
81
88
|
}
|
|
82
89
|
|
|
83
|
-
componentDidUpdate(
|
|
90
|
+
componentDidUpdate() {
|
|
84
91
|
var _this$props$makeStyle2, _this$props4;
|
|
85
92
|
|
|
86
93
|
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
@@ -106,25 +113,16 @@ let Tab = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec
|
|
|
106
113
|
"aria-selected": isSelected ? 'true' : void 0,
|
|
107
114
|
"aria-disabled": isDisabled ? 'true' : void 0,
|
|
108
115
|
"aria-controls": controls,
|
|
109
|
-
tabIndex: isSelected && !isDisabled ?
|
|
116
|
+
tabIndex: isSelected && !isDisabled ? 0 : void 0,
|
|
110
117
|
position: "relative",
|
|
111
118
|
focusPosition: "inset"
|
|
112
119
|
}), (0, _callRenderProp.callRenderProp)(children));
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
}, _class2.displayName = "Tab", _class2.componentId = 'Tabs.Tab', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
116
|
-
children: null,
|
|
117
123
|
variant: 'default',
|
|
118
124
|
isDisabled: false,
|
|
119
|
-
isSelected: false
|
|
120
|
-
onClick: (event, _ref) => {
|
|
121
|
-
let index = _ref.index,
|
|
122
|
-
id = _ref.id;
|
|
123
|
-
},
|
|
124
|
-
onKeyDown: (event, _ref2) => {
|
|
125
|
-
let index = _ref2.index,
|
|
126
|
-
id = _ref2.id;
|
|
127
|
-
}
|
|
125
|
+
isSelected: false
|
|
128
126
|
}, _temp)) || _class);
|
|
129
127
|
exports.Tab = Tab;
|
|
130
128
|
var _default = Tab;
|
package/lib/Tabs/TabsLocator.js
CHANGED
|
@@ -34,7 +34,8 @@ var _index = require("./index");
|
|
|
34
34
|
*/
|
|
35
35
|
const TabLocator = (0, _locator.locator)('[role="tab"]');
|
|
36
36
|
const PanelLocator = (0, _locator.locator)('[role="tabpanel"]');
|
|
37
|
-
const SelectedTabLocator = (0, _locator.locator)('[role="tab"][aria-selected="true"]');
|
|
37
|
+
const SelectedTabLocator = (0, _locator.locator)('[role="tab"][aria-selected="true"]'); // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
38
|
+
|
|
38
39
|
const TabsLocator = (0, _locator.locator)(_index.Tabs.selector, {
|
|
39
40
|
findTab: function () {
|
|
40
41
|
return TabLocator.find(...arguments);
|
package/lib/Tabs/index.js
CHANGED
|
@@ -65,10 +65,16 @@ var _dec, _dec2, _dec3, _class, _class2, _temp;
|
|
|
65
65
|
---
|
|
66
66
|
category: components
|
|
67
67
|
---
|
|
68
|
+
@tsProps
|
|
68
69
|
**/
|
|
69
70
|
let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_temp = _class2 = class Tabs extends _react.Component {
|
|
70
71
|
constructor(props) {
|
|
71
72
|
super(props);
|
|
73
|
+
this._tabList = null;
|
|
74
|
+
this._focusable = null;
|
|
75
|
+
this._tabListPosition = void 0;
|
|
76
|
+
this._debounced = void 0;
|
|
77
|
+
this._resizeListener = void 0;
|
|
72
78
|
this.ref = null;
|
|
73
79
|
|
|
74
80
|
this.handleRef = el => {
|
|
@@ -81,8 +87,7 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
81
87
|
};
|
|
82
88
|
|
|
83
89
|
this.handleTabClick = (event, _ref) => {
|
|
84
|
-
let index = _ref.index
|
|
85
|
-
id = _ref.id;
|
|
90
|
+
let index = _ref.index;
|
|
86
91
|
const nextTab = this.getNextTab(index, 0);
|
|
87
92
|
this.fireOnChange(event, nextTab);
|
|
88
93
|
};
|
|
@@ -120,8 +125,6 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
120
125
|
this._tabList = el;
|
|
121
126
|
};
|
|
122
127
|
|
|
123
|
-
this._tabList = null;
|
|
124
|
-
this._tabListPosition = null;
|
|
125
128
|
this.state = {
|
|
126
129
|
withTabListOverflow: false
|
|
127
130
|
};
|
|
@@ -141,7 +144,7 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
141
144
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
142
145
|
}
|
|
143
146
|
|
|
144
|
-
componentDidUpdate(prevProps, prevState
|
|
147
|
+
componentDidUpdate(prevProps, prevState) {
|
|
145
148
|
var _this$props$makeStyle2, _this$props2;
|
|
146
149
|
|
|
147
150
|
if (this.props.shouldFocusOnRender && !prevProps.shouldFocusOnRender) {
|
|
@@ -190,7 +193,9 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
190
193
|
const newWidth = entry.contentRect.width;
|
|
191
194
|
|
|
192
195
|
if (this._tabListPosition.width !== newWidth) {
|
|
193
|
-
|
|
196
|
+
var _this$_debounced;
|
|
197
|
+
|
|
198
|
+
(_this$_debounced = this._debounced) === null || _this$_debounced === void 0 ? void 0 : _this$_debounced.call(this);
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
});
|
|
@@ -214,13 +219,15 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
214
219
|
tabOverflow = _this$props3.tabOverflow,
|
|
215
220
|
styles = _this$props3.styles;
|
|
216
221
|
|
|
217
|
-
if (tabOverflow === 'scroll') {
|
|
222
|
+
if (styles && tabOverflow === 'scroll') {
|
|
218
223
|
if (variant === 'default') {
|
|
219
224
|
return (0, _px.px)(styles === null || styles === void 0 ? void 0 : styles.scrollOverlayWidthDefault);
|
|
220
225
|
} else {
|
|
221
226
|
return (0, _px.px)(styles === null || styles === void 0 ? void 0 : styles.scrollOverlayWidthSecondary);
|
|
222
227
|
}
|
|
223
228
|
}
|
|
229
|
+
|
|
230
|
+
return 0;
|
|
224
231
|
}
|
|
225
232
|
|
|
226
233
|
showActiveTabIfOverlayed(activeTabEl) {
|
|
@@ -397,12 +404,6 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
397
404
|
|
|
398
405
|
}, _class2.displayName = "Tabs", _class2.componentId = 'Tabs', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
399
406
|
variant: 'default',
|
|
400
|
-
onRequestTabChange: (event, _ref4) => {
|
|
401
|
-
let index = _ref4.index,
|
|
402
|
-
id = _ref4.id;
|
|
403
|
-
},
|
|
404
|
-
children: null,
|
|
405
|
-
elementRef: () => {},
|
|
406
407
|
shouldFocusOnRender: false,
|
|
407
408
|
tabOverflow: 'stack'
|
|
408
409
|
}, _class2.Panel = _Panel.Panel, _class2.Tab = _Tab.Tab, _temp)) || _class) || _class) || _class);
|
package/lib/Tabs/props.js
CHANGED
|
@@ -39,50 +39,18 @@ var _Panel = require("./Panel");
|
|
|
39
39
|
* SOFTWARE.
|
|
40
40
|
*/
|
|
41
41
|
const propTypes = {
|
|
42
|
-
/**
|
|
43
|
-
* children of type `Tabs.Panel`
|
|
44
|
-
*/
|
|
45
42
|
children: _Children.Children.oneOf([_Panel.Panel, null]),
|
|
46
43
|
variant: _propTypes.default.oneOf(['default', 'secondary']),
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A screen ready only label for the list of tabs
|
|
50
|
-
*/
|
|
51
44
|
screenReaderLabel: _propTypes.default.string,
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Called when the selected tab should change
|
|
55
|
-
*/
|
|
56
45
|
onRequestTabChange: _propTypes.default.func,
|
|
57
46
|
maxWidth: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
58
47
|
maxHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
59
48
|
minHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
60
49
|
fixHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
64
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
65
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
66
|
-
*/
|
|
67
50
|
margin: _emotion.ThemeablePropTypes.spacing,
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
71
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
72
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
73
|
-
*/
|
|
74
51
|
padding: _emotion.ThemeablePropTypes.spacing,
|
|
75
52
|
textAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* provides a reference to the underlying html root element
|
|
79
|
-
*/
|
|
80
53
|
elementRef: _propTypes.default.func,
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Choose whether Tabs should stack or scroll when they exceed the width of their
|
|
84
|
-
* container.
|
|
85
|
-
*/
|
|
86
54
|
tabOverflow: _propTypes.default.oneOf(['stack', 'scroll']),
|
|
87
55
|
shouldFocusOnRender: _propTypes.default.bool
|
|
88
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-tabs",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.14.0",
|
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -24,28 +24,28 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@instructure/ui-babel-preset": "8.
|
|
28
|
-
"@instructure/ui-color-utils": "8.
|
|
29
|
-
"@instructure/ui-test-locator": "8.
|
|
30
|
-
"@instructure/ui-test-utils": "8.
|
|
31
|
-
"@instructure/ui-themes": "8.
|
|
27
|
+
"@instructure/ui-babel-preset": "8.14.0",
|
|
28
|
+
"@instructure/ui-color-utils": "8.14.0",
|
|
29
|
+
"@instructure/ui-test-locator": "8.14.0",
|
|
30
|
+
"@instructure/ui-test-utils": "8.14.0",
|
|
31
|
+
"@instructure/ui-themes": "8.14.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.13.10",
|
|
35
|
-
"@instructure/console": "8.
|
|
36
|
-
"@instructure/debounce": "8.
|
|
37
|
-
"@instructure/emotion": "8.
|
|
38
|
-
"@instructure/shared-types": "8.
|
|
39
|
-
"@instructure/ui-dom-utils": "8.
|
|
40
|
-
"@instructure/ui-focusable": "8.
|
|
41
|
-
"@instructure/ui-i18n": "8.
|
|
42
|
-
"@instructure/ui-motion": "8.
|
|
43
|
-
"@instructure/ui-prop-types": "8.
|
|
44
|
-
"@instructure/ui-react-utils": "8.
|
|
45
|
-
"@instructure/ui-testable": "8.
|
|
46
|
-
"@instructure/ui-utils": "8.
|
|
47
|
-
"@instructure/ui-view": "8.
|
|
48
|
-
"@instructure/uid": "8.
|
|
35
|
+
"@instructure/console": "8.14.0",
|
|
36
|
+
"@instructure/debounce": "8.14.0",
|
|
37
|
+
"@instructure/emotion": "8.14.0",
|
|
38
|
+
"@instructure/shared-types": "8.14.0",
|
|
39
|
+
"@instructure/ui-dom-utils": "8.14.0",
|
|
40
|
+
"@instructure/ui-focusable": "8.14.0",
|
|
41
|
+
"@instructure/ui-i18n": "8.14.0",
|
|
42
|
+
"@instructure/ui-motion": "8.14.0",
|
|
43
|
+
"@instructure/ui-prop-types": "8.14.0",
|
|
44
|
+
"@instructure/ui-react-utils": "8.14.0",
|
|
45
|
+
"@instructure/ui-testable": "8.14.0",
|
|
46
|
+
"@instructure/ui-utils": "8.14.0",
|
|
47
|
+
"@instructure/ui-view": "8.14.0",
|
|
48
|
+
"@instructure/uid": "8.14.0",
|
|
49
49
|
"keycode": "^2",
|
|
50
50
|
"prop-types": "^15"
|
|
51
51
|
},
|
|
@@ -55,6 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
-
"sideEffects": false
|
|
59
|
-
"gitHead": "f32ba918e4d3ce76c6ee95c856584d00a9d80958"
|
|
58
|
+
"sideEffects": false
|
|
60
59
|
}
|