@instructure/ui-tabs 8.11.2-snapshot.7 → 8.12.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/Tabs/Tab/index.js +3 -1
- package/es/Tabs/Tab/styles.js +13 -3
- package/es/Tabs/index.js +8 -11
- package/es/package.json +1 -0
- package/lib/Tabs/Tab/index.js +3 -1
- package/lib/Tabs/Tab/styles.js +13 -3
- package/lib/Tabs/index.js +7 -10
- package/package.json +21 -22
- package/src/Tabs/Tab/index.tsx +2 -0
- package/src/Tabs/Tab/styles.ts +15 -1
- package/src/Tabs/index.tsx +38 -26
- package/types/Tabs/Tab/index.d.ts.map +1 -1
- package/types/Tabs/Tab/styles.d.ts.map +1 -1
- package/types/Tabs/index.d.ts +7 -13
- package/types/Tabs/index.d.ts.map +1 -1
- package/LICENSE.md +0 -27
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.12.0](https://github.com/instructure/instructure-ui/compare/v8.11.1...v8.12.0) (2021-11-17)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **ui-tabs:** update Tabs focus styles to inset focus ring ([3a59c3f](https://github.com/instructure/instructure-ui/commit/3a59c3f0443db81631c4f4d5dafe5778389e8dbc))
|
|
11
|
+
|
|
6
12
|
## [8.11.1](https://github.com/instructure/instructure-ui/compare/v8.11.0...v8.11.1) (2021-10-19)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @instructure/ui-tabs
|
package/es/Tabs/Tab/index.js
CHANGED
|
@@ -114,7 +114,9 @@ let Tab = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
114
114
|
"aria-selected": isSelected ? 'true' : void 0,
|
|
115
115
|
"aria-disabled": isDisabled ? 'true' : void 0,
|
|
116
116
|
"aria-controls": controls,
|
|
117
|
-
tabIndex: isSelected && !isDisabled ? '0' : void 0
|
|
117
|
+
tabIndex: isSelected && !isDisabled ? '0' : void 0,
|
|
118
|
+
position: "relative",
|
|
119
|
+
focusPosition: "inset"
|
|
118
120
|
}), callRenderProp(children));
|
|
119
121
|
}
|
|
120
122
|
|
package/es/Tabs/Tab/styles.js
CHANGED
|
@@ -102,6 +102,18 @@ const generateStyle = (componentTheme, props) => {
|
|
|
102
102
|
})
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
}; // overrides for View default focus ring
|
|
106
|
+
|
|
107
|
+
const focusRingStyles = {
|
|
108
|
+
'&:before': {
|
|
109
|
+
inset: '0.5rem',
|
|
110
|
+
borderRadius: '0.25rem'
|
|
111
|
+
},
|
|
112
|
+
'&:focus': {
|
|
113
|
+
'&:before': {
|
|
114
|
+
inset: '0.375rem'
|
|
115
|
+
}
|
|
116
|
+
}
|
|
105
117
|
};
|
|
106
118
|
return {
|
|
107
119
|
tab: {
|
|
@@ -119,9 +131,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
119
131
|
...(isDisabled && {
|
|
120
132
|
opacity: 0.5
|
|
121
133
|
}),
|
|
122
|
-
|
|
123
|
-
outline: 'none'
|
|
124
|
-
},
|
|
134
|
+
...focusRingStyles,
|
|
125
135
|
...variants[variant]
|
|
126
136
|
}
|
|
127
137
|
};
|
package/es/Tabs/index.js
CHANGED
|
@@ -39,20 +39,20 @@ import { Focusable } from '@instructure/ui-focusable';
|
|
|
39
39
|
import { getBoundingClientRect } from '@instructure/ui-dom-utils';
|
|
40
40
|
import { debounce } from '@instructure/debounce';
|
|
41
41
|
import { px } from '@instructure/ui-utils';
|
|
42
|
-
import {
|
|
42
|
+
import { textDirectionContextConsumer } from '@instructure/ui-i18n';
|
|
43
43
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
44
44
|
import generateStyle from './styles';
|
|
45
45
|
import generateComponentTheme from './theme';
|
|
46
46
|
import { Tab } from './Tab';
|
|
47
47
|
import { Panel } from './Panel';
|
|
48
48
|
import { allowedProps, propTypes } from './props';
|
|
49
|
+
|
|
49
50
|
/**
|
|
50
51
|
---
|
|
51
52
|
category: components
|
|
52
53
|
---
|
|
53
54
|
**/
|
|
54
|
-
|
|
55
|
-
let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = bidirectional(), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_temp = _class2 = class Tabs extends Component {
|
|
55
|
+
let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = textDirectionContextConsumer(), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_temp = _class2 = class Tabs extends Component {
|
|
56
56
|
constructor(props) {
|
|
57
57
|
super(props);
|
|
58
58
|
this.ref = null;
|
|
@@ -215,7 +215,7 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = bid
|
|
|
215
215
|
if (this._tabList && this._tabListPosition && typeof this._tabList.scrollTo === 'function' // test for scrollTo support
|
|
216
216
|
) {
|
|
217
217
|
const dir = this.props.dir;
|
|
218
|
-
const isRtl = dir ===
|
|
218
|
+
const isRtl = dir === textDirectionContextConsumer.DIRECTION.rtl;
|
|
219
219
|
const tabPosition = getBoundingClientRect(activeTabEl);
|
|
220
220
|
const tabListPosition = this._tabListPosition;
|
|
221
221
|
const tabListBoundStart = isRtl ? tabListPosition.left + this.getOverlayWidth() : tabListPosition.left;
|
|
@@ -293,7 +293,7 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = bid
|
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
clonePanel(
|
|
296
|
+
clonePanel(_index, generatedId, selected, panel) {
|
|
297
297
|
const id = panel.props.id || generatedId; // fixHeight can be 0, so simply `fixheight` could return falsy value
|
|
298
298
|
|
|
299
299
|
const hasFixedHeight = typeof this.props.fixHeight !== 'undefined';
|
|
@@ -305,8 +305,8 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = bid
|
|
|
305
305
|
variant: this.props.variant,
|
|
306
306
|
padding: panel.props.padding || this.props.padding,
|
|
307
307
|
textAlign: panel.props.textAlign || this.props.textAlign,
|
|
308
|
-
maxHeight:
|
|
309
|
-
minHeight:
|
|
308
|
+
maxHeight: !hasFixedHeight ? this.props.maxHeight : void 0,
|
|
309
|
+
minHeight: !hasFixedHeight ? this.props.minHeight : '100%'
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
312
|
|
|
@@ -363,13 +363,10 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = bid
|
|
|
363
363
|
css: styles === null || styles === void 0 ? void 0 : styles.container
|
|
364
364
|
}), jsx(Focusable, {
|
|
365
365
|
ref: this.handleFocusableRef
|
|
366
|
-
}, ({
|
|
367
|
-
focusVisible
|
|
368
|
-
}) => jsx(View, {
|
|
366
|
+
}, () => jsx(View, {
|
|
369
367
|
as: "div",
|
|
370
368
|
position: "relative",
|
|
371
369
|
borderRadius: "medium",
|
|
372
|
-
withFocusOutline: focusVisible,
|
|
373
370
|
shouldAnimateFocus: false,
|
|
374
371
|
css: styles === null || styles === void 0 ? void 0 : styles.tabs
|
|
375
372
|
}, jsx(View, {
|
package/es/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/lib/Tabs/Tab/index.js
CHANGED
|
@@ -106,7 +106,9 @@ let Tab = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec
|
|
|
106
106
|
"aria-selected": isSelected ? 'true' : void 0,
|
|
107
107
|
"aria-disabled": isDisabled ? 'true' : void 0,
|
|
108
108
|
"aria-controls": controls,
|
|
109
|
-
tabIndex: isSelected && !isDisabled ? '0' : void 0
|
|
109
|
+
tabIndex: isSelected && !isDisabled ? '0' : void 0,
|
|
110
|
+
position: "relative",
|
|
111
|
+
focusPosition: "inset"
|
|
110
112
|
}), (0, _callRenderProp.callRenderProp)(children));
|
|
111
113
|
}
|
|
112
114
|
|
package/lib/Tabs/Tab/styles.js
CHANGED
|
@@ -110,6 +110,18 @@ const generateStyle = (componentTheme, props) => {
|
|
|
110
110
|
})
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
}; // overrides for View default focus ring
|
|
114
|
+
|
|
115
|
+
const focusRingStyles = {
|
|
116
|
+
'&:before': {
|
|
117
|
+
inset: '0.5rem',
|
|
118
|
+
borderRadius: '0.25rem'
|
|
119
|
+
},
|
|
120
|
+
'&:focus': {
|
|
121
|
+
'&:before': {
|
|
122
|
+
inset: '0.375rem'
|
|
123
|
+
}
|
|
124
|
+
}
|
|
113
125
|
};
|
|
114
126
|
return {
|
|
115
127
|
tab: {
|
|
@@ -127,9 +139,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
127
139
|
...(isDisabled && {
|
|
128
140
|
opacity: 0.5
|
|
129
141
|
}),
|
|
130
|
-
|
|
131
|
-
outline: 'none'
|
|
132
|
-
},
|
|
142
|
+
...focusRingStyles,
|
|
133
143
|
...variants[variant]
|
|
134
144
|
}
|
|
135
145
|
};
|
package/lib/Tabs/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var _debounce = require("@instructure/debounce");
|
|
|
43
43
|
|
|
44
44
|
var _px = require("@instructure/ui-utils/lib/px.js");
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
|
|
47
47
|
|
|
48
48
|
var _emotion = require("@instructure/emotion");
|
|
49
49
|
|
|
@@ -66,7 +66,7 @@ var _dec, _dec2, _dec3, _class, _class2, _temp;
|
|
|
66
66
|
category: components
|
|
67
67
|
---
|
|
68
68
|
**/
|
|
69
|
-
let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0,
|
|
69
|
+
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
70
|
constructor(props) {
|
|
71
71
|
super(props);
|
|
72
72
|
this.ref = null;
|
|
@@ -229,7 +229,7 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
229
229
|
if (this._tabList && this._tabListPosition && typeof this._tabList.scrollTo === 'function' // test for scrollTo support
|
|
230
230
|
) {
|
|
231
231
|
const dir = this.props.dir;
|
|
232
|
-
const isRtl = dir ===
|
|
232
|
+
const isRtl = dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl;
|
|
233
233
|
const tabPosition = (0, _getBoundingClientRect.getBoundingClientRect)(activeTabEl);
|
|
234
234
|
const tabListPosition = this._tabListPosition;
|
|
235
235
|
const tabListBoundStart = isRtl ? tabListPosition.left + this.getOverlayWidth() : tabListPosition.left;
|
|
@@ -308,7 +308,7 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
clonePanel(
|
|
311
|
+
clonePanel(_index, generatedId, selected, panel) {
|
|
312
312
|
const id = panel.props.id || generatedId; // fixHeight can be 0, so simply `fixheight` could return falsy value
|
|
313
313
|
|
|
314
314
|
const hasFixedHeight = typeof this.props.fixHeight !== 'undefined';
|
|
@@ -320,8 +320,8 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
320
320
|
variant: this.props.variant,
|
|
321
321
|
padding: panel.props.padding || this.props.padding,
|
|
322
322
|
textAlign: panel.props.textAlign || this.props.textAlign,
|
|
323
|
-
maxHeight:
|
|
324
|
-
minHeight:
|
|
323
|
+
maxHeight: !hasFixedHeight ? this.props.maxHeight : void 0,
|
|
324
|
+
minHeight: !hasFixedHeight ? this.props.minHeight : '100%'
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
327
|
|
|
@@ -380,13 +380,10 @@ let Tabs = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
380
380
|
css: styles === null || styles === void 0 ? void 0 : styles.container
|
|
381
381
|
}), (0, _emotion.jsx)(_Focusable.Focusable, {
|
|
382
382
|
ref: this.handleFocusableRef
|
|
383
|
-
}, ({
|
|
384
|
-
focusVisible
|
|
385
|
-
}) => (0, _emotion.jsx)(_View.View, {
|
|
383
|
+
}, () => (0, _emotion.jsx)(_View.View, {
|
|
386
384
|
as: "div",
|
|
387
385
|
position: "relative",
|
|
388
386
|
borderRadius: "medium",
|
|
389
|
-
withFocusOutline: focusVisible,
|
|
390
387
|
shouldAnimateFocus: false,
|
|
391
388
|
css: styles === null || styles === void 0 ? void 0 : styles.tabs
|
|
392
389
|
}, (0, _emotion.jsx)(_View.View, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-tabs",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.12.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.12.0",
|
|
28
|
+
"@instructure/ui-color-utils": "8.12.0",
|
|
29
|
+
"@instructure/ui-test-locator": "8.12.0",
|
|
30
|
+
"@instructure/ui-test-utils": "8.12.0",
|
|
31
|
+
"@instructure/ui-themes": "8.12.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.12.0",
|
|
36
|
+
"@instructure/debounce": "8.12.0",
|
|
37
|
+
"@instructure/emotion": "8.12.0",
|
|
38
|
+
"@instructure/shared-types": "8.12.0",
|
|
39
|
+
"@instructure/ui-dom-utils": "8.12.0",
|
|
40
|
+
"@instructure/ui-focusable": "8.12.0",
|
|
41
|
+
"@instructure/ui-i18n": "8.12.0",
|
|
42
|
+
"@instructure/ui-motion": "8.12.0",
|
|
43
|
+
"@instructure/ui-prop-types": "8.12.0",
|
|
44
|
+
"@instructure/ui-react-utils": "8.12.0",
|
|
45
|
+
"@instructure/ui-testable": "8.12.0",
|
|
46
|
+
"@instructure/ui-utils": "8.12.0",
|
|
47
|
+
"@instructure/ui-view": "8.12.0",
|
|
48
|
+
"@instructure/uid": "8.12.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": "2681e145ad469e1396536d3e9eed75a19995eb8a"
|
|
58
|
+
"sideEffects": false
|
|
60
59
|
}
|
package/src/Tabs/Tab/index.tsx
CHANGED
|
@@ -118,6 +118,8 @@ class Tab extends Component<TabsTabProps> {
|
|
|
118
118
|
aria-controls={controls}
|
|
119
119
|
//@ts-expect-error fix this to be number
|
|
120
120
|
tabIndex={isSelected && !isDisabled ? '0' : undefined}
|
|
121
|
+
position="relative"
|
|
122
|
+
focusPosition="inset"
|
|
121
123
|
>
|
|
122
124
|
{callRenderProp(children)}
|
|
123
125
|
</View>
|
package/src/Tabs/Tab/styles.ts
CHANGED
|
@@ -115,6 +115,20 @@ const generateStyle = (
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// overrides for View default focus ring
|
|
119
|
+
const focusRingStyles = {
|
|
120
|
+
'&:before': {
|
|
121
|
+
inset: '0.5rem',
|
|
122
|
+
borderRadius: '0.25rem'
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
'&:focus': {
|
|
126
|
+
'&:before': {
|
|
127
|
+
inset: '0.375rem'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
118
132
|
return {
|
|
119
133
|
tab: {
|
|
120
134
|
label: 'tab',
|
|
@@ -129,7 +143,7 @@ const generateStyle = (
|
|
|
129
143
|
...((isSelected || isDisabled) && { cursor: 'default' }),
|
|
130
144
|
...(isDisabled && { opacity: 0.5 }),
|
|
131
145
|
|
|
132
|
-
|
|
146
|
+
...focusRingStyles,
|
|
133
147
|
|
|
134
148
|
...variants[variant!]
|
|
135
149
|
}
|
package/src/Tabs/index.tsx
CHANGED
|
@@ -23,7 +23,13 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
|
-
import React, {
|
|
26
|
+
import React, {
|
|
27
|
+
Component,
|
|
28
|
+
ComponentClass,
|
|
29
|
+
ComponentElement,
|
|
30
|
+
createElement,
|
|
31
|
+
ReactElement
|
|
32
|
+
} from 'react'
|
|
27
33
|
|
|
28
34
|
import keycode from 'keycode'
|
|
29
35
|
|
|
@@ -40,7 +46,7 @@ import { Focusable } from '@instructure/ui-focusable'
|
|
|
40
46
|
import { getBoundingClientRect } from '@instructure/ui-dom-utils'
|
|
41
47
|
import { debounce } from '@instructure/debounce'
|
|
42
48
|
import { px } from '@instructure/ui-utils'
|
|
43
|
-
import {
|
|
49
|
+
import { textDirectionContextConsumer } from '@instructure/ui-i18n'
|
|
44
50
|
|
|
45
51
|
import { withStyle, jsx } from '@instructure/emotion'
|
|
46
52
|
|
|
@@ -49,8 +55,14 @@ import generateComponentTheme from './theme'
|
|
|
49
55
|
|
|
50
56
|
import { Tab } from './Tab'
|
|
51
57
|
import { Panel } from './Panel'
|
|
52
|
-
|
|
58
|
+
|
|
53
59
|
import { allowedProps, propTypes } from './props'
|
|
60
|
+
import type { TabsProps } from './props'
|
|
61
|
+
import type { TabsTabProps } from './Tab/props'
|
|
62
|
+
import type { TabsPanelProps } from './Panel/props'
|
|
63
|
+
|
|
64
|
+
type TabChild = ReactElement & ComponentElement<TabsTabProps, any>
|
|
65
|
+
type PanelChild = ReactElement & ComponentElement<TabsPanelProps, any>
|
|
54
66
|
|
|
55
67
|
/**
|
|
56
68
|
---
|
|
@@ -58,7 +70,7 @@ category: components
|
|
|
58
70
|
---
|
|
59
71
|
**/
|
|
60
72
|
@withStyle(generateStyle, generateComponentTheme)
|
|
61
|
-
@
|
|
73
|
+
@textDirectionContextConsumer()
|
|
62
74
|
@testable()
|
|
63
75
|
class Tabs extends Component<TabsProps> {
|
|
64
76
|
static readonly componentId = 'Tabs'
|
|
@@ -235,7 +247,7 @@ class Tabs extends Component<TabsProps> {
|
|
|
235
247
|
typeof this._tabList.scrollTo === 'function' // test for scrollTo support
|
|
236
248
|
) {
|
|
237
249
|
const { dir } = this.props
|
|
238
|
-
const isRtl = dir ===
|
|
250
|
+
const isRtl = dir === textDirectionContextConsumer.DIRECTION.rtl
|
|
239
251
|
|
|
240
252
|
const tabPosition = getBoundingClientRect(activeTabEl)
|
|
241
253
|
// @ts-expect-error ts-migrate(2339) FIXME: Property '_tabListPosition' does not exist on type... Remove this comment to see the full error message
|
|
@@ -354,12 +366,15 @@ class Tabs extends Component<TabsProps> {
|
|
|
354
366
|
this.showActiveTabIfOverlayed(this._tabList.querySelector(`#tab-${id}`))
|
|
355
367
|
}
|
|
356
368
|
|
|
357
|
-
|
|
358
|
-
|
|
369
|
+
createTab(
|
|
370
|
+
index: number,
|
|
371
|
+
generatedId: string,
|
|
372
|
+
selected: boolean,
|
|
373
|
+
panel: PanelChild
|
|
374
|
+
): TabChild {
|
|
359
375
|
const id = panel.props.id || generatedId
|
|
360
376
|
|
|
361
|
-
|
|
362
|
-
return createElement(Tab, {
|
|
377
|
+
return createElement(Tab as ComponentClass<TabsTabProps>, {
|
|
363
378
|
variant: this.props.variant,
|
|
364
379
|
key: `tab-${id}`,
|
|
365
380
|
id: `tab-${id}`,
|
|
@@ -373,8 +388,12 @@ class Tabs extends Component<TabsProps> {
|
|
|
373
388
|
})
|
|
374
389
|
}
|
|
375
390
|
|
|
376
|
-
|
|
377
|
-
|
|
391
|
+
clonePanel(
|
|
392
|
+
_index: number,
|
|
393
|
+
generatedId: string,
|
|
394
|
+
selected: boolean,
|
|
395
|
+
panel: PanelChild
|
|
396
|
+
) {
|
|
378
397
|
const id = panel.props.id || generatedId
|
|
379
398
|
|
|
380
399
|
// fixHeight can be 0, so simply `fixheight` could return falsy value
|
|
@@ -388,10 +407,8 @@ class Tabs extends Component<TabsProps> {
|
|
|
388
407
|
variant: this.props.variant,
|
|
389
408
|
padding: panel.props.padding || this.props.padding,
|
|
390
409
|
textAlign: panel.props.textAlign || this.props.textAlign,
|
|
391
|
-
maxHeight:
|
|
392
|
-
|
|
393
|
-
minHeight:
|
|
394
|
-
panel.minHeight || (!hasFixedHeight ? this.props.minHeight : '100%')
|
|
410
|
+
maxHeight: !hasFixedHeight ? this.props.maxHeight : undefined,
|
|
411
|
+
minHeight: !hasFixedHeight ? this.props.minHeight : '100%'
|
|
395
412
|
})
|
|
396
413
|
}
|
|
397
414
|
|
|
@@ -419,8 +436,7 @@ class Tabs extends Component<TabsProps> {
|
|
|
419
436
|
render() {
|
|
420
437
|
// @ts-expect-error ts-migrate(7034) FIXME: Variable 'panels' implicitly has type 'any[]' in s... Remove this comment to see the full error message
|
|
421
438
|
const panels = []
|
|
422
|
-
|
|
423
|
-
const tabs = []
|
|
439
|
+
const tabs: TabChild[] = []
|
|
424
440
|
const {
|
|
425
441
|
children,
|
|
426
442
|
elementRef,
|
|
@@ -445,14 +461,12 @@ class Tabs extends Component<TabsProps> {
|
|
|
445
461
|
React.Children.forEach(children, (child) => {
|
|
446
462
|
if (matchComponentTypes(child, [Panel])) {
|
|
447
463
|
const selected =
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
// @ts-expect-error ts-migrate(2533) FIXME: Object is possibly 'null' or 'undefined'.
|
|
451
|
-
(child.props.isSelected || selectedIndex === index)
|
|
464
|
+
!(child as PanelChild).props.isDisabled &&
|
|
465
|
+
((child as PanelChild).props.isSelected || selectedIndex === index)
|
|
452
466
|
const id = uid()
|
|
453
467
|
|
|
454
|
-
tabs.push(this.createTab(index, id, selected, child))
|
|
455
|
-
panels.push(this.clonePanel(index, id, selected, child))
|
|
468
|
+
tabs.push(this.createTab(index, id, selected, child as PanelChild))
|
|
469
|
+
panels.push(this.clonePanel(index, id, selected, child as PanelChild))
|
|
456
470
|
|
|
457
471
|
index++
|
|
458
472
|
} else {
|
|
@@ -486,12 +500,11 @@ class Tabs extends Component<TabsProps> {
|
|
|
486
500
|
css={styles?.container}
|
|
487
501
|
>
|
|
488
502
|
<Focusable ref={this.handleFocusableRef}>
|
|
489
|
-
{(
|
|
503
|
+
{() => (
|
|
490
504
|
<View
|
|
491
505
|
as="div"
|
|
492
506
|
position="relative"
|
|
493
507
|
borderRadius="medium"
|
|
494
|
-
withFocusOutline={focusVisible}
|
|
495
508
|
shouldAnimateFocus={false}
|
|
496
509
|
css={styles?.tabs}
|
|
497
510
|
>
|
|
@@ -502,7 +515,6 @@ class Tabs extends Component<TabsProps> {
|
|
|
502
515
|
aria-label={screenReaderLabel}
|
|
503
516
|
elementRef={this.handleTabListRef}
|
|
504
517
|
>
|
|
505
|
-
{/* @ts-expect-error ts-migrate(7005) FIXME: Variable 'tabs' implicitly has an 'any[]' type. */}
|
|
506
518
|
{tabs}
|
|
507
519
|
{withScrollFade && scrollFadeEls}
|
|
508
520
|
</View>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tabs/Tab/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKjC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAIrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C;;;;;GAKG;AACH,cACM,GAAI,SAAQ,SAAS,CAAC,YAAY,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,WAAW,cAAa;IAExC,MAAM,CAAC,YAAY;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;;;;;;;;;MASlB;IAED,iBAAiB;IAKjB,kBAAkB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,EAAE,QAAQ,KAAA;IAKjD,WAAW,uBASV;IAGD,aAAa,uBASZ;IAED,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tabs/Tab/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKjC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAIrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C;;;;;GAKG;AACH,cACM,GAAI,SAAQ,SAAS,CAAC,YAAY,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,WAAW,cAAa;IAExC,MAAM,CAAC,YAAY;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;;;;;;;;;MASlB;IAED,iBAAiB;IAKjB,kBAAkB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,EAAE,QAAQ,KAAA;IAKjD,WAAW,uBASV;IAGD,aAAa,uBASZ;IAED,MAAM;CAiCP;AAED,eAAe,GAAG,CAAA;AAClB,OAAO,EAAE,GAAG,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Tabs/Tab/styles.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAUzD;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa,mBACD,YAAY,SACrB,YAAY,KAClB,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Tabs/Tab/styles.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAUzD;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa,mBACD,YAAY,SACrB,YAAY,KAClB,YAoGF,CAAA;AAED,eAAe,aAAa,CAAA"}
|
package/types/Tabs/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import React, { Component } from 'react';
|
|
2
|
+
import React, { Component, ComponentElement, ReactElement } from 'react';
|
|
3
3
|
import { jsx } from '@instructure/emotion';
|
|
4
4
|
import { Tab } from './Tab';
|
|
5
5
|
import { Panel } from './Panel';
|
|
6
6
|
import type { TabsProps } from './props';
|
|
7
|
+
import type { TabsTabProps } from './Tab/props';
|
|
8
|
+
import type { TabsPanelProps } from './Panel/props';
|
|
9
|
+
declare type TabChild = ReactElement & ComponentElement<TabsTabProps, any>;
|
|
10
|
+
declare type PanelChild = ReactElement & ComponentElement<TabsPanelProps, any>;
|
|
7
11
|
/**
|
|
8
12
|
---
|
|
9
13
|
category: components
|
|
@@ -82,18 +86,8 @@ declare class Tabs extends Component<TabsProps> {
|
|
|
82
86
|
index: any;
|
|
83
87
|
id: any;
|
|
84
88
|
}): void;
|
|
85
|
-
createTab(index:
|
|
86
|
-
clonePanel(
|
|
87
|
-
id: any;
|
|
88
|
-
labelledBy: string;
|
|
89
|
-
isSelected: any;
|
|
90
|
-
key: any;
|
|
91
|
-
variant: "default" | "secondary" | undefined;
|
|
92
|
-
padding: any;
|
|
93
|
-
textAlign: any;
|
|
94
|
-
maxHeight: any;
|
|
95
|
-
minHeight: any;
|
|
96
|
-
}, string | React.JSXElementConstructor<any>>;
|
|
89
|
+
createTab(index: number, generatedId: string, selected: boolean, panel: PanelChild): TabChild;
|
|
90
|
+
clonePanel(_index: number, generatedId: string, selected: boolean, panel: PanelChild): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
97
91
|
handleFocusableRef: (el: any) => void;
|
|
98
92
|
handleTabListRef: (el: any) => void;
|
|
99
93
|
focus(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Tabs/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Tabs/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,KAAK,EAAE,EACZ,SAAS,EAET,gBAAgB,EAEhB,YAAY,EACb,MAAM,OAAO,CAAA;AAmBd,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAKrD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnD,aAAK,QAAQ,GAAG,YAAY,GAAG,gBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;AAClE,aAAK,UAAU,GAAG,YAAY,GAAG,gBAAgB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;AAEtE;;;;GAIG;AACH,cAGM,IAAK,SAAQ,SAAS,CAAC,SAAS,CAAC;IACrC,MAAM,CAAC,QAAQ,CAAC,WAAW,UAAS;IAEpC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;;;;;;MAQlB;IAED,MAAM,CAAC,KAAK,eAAQ;IACpB,MAAM,CAAC,GAAG,aAAM;IAEhB,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAQ9B;gBAGW,KAAK,KAAA;IAajB,iBAAiB;IAcjB,kBAAkB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,EAAE,QAAQ,KAAA;IA+CjD,oBAAoB;IAIpB,mBAAmB;IA2BnB,oBAAoB;IAepB,eAAe;IAaf,wBAAwB,CAAC,WAAW,KAAA;IAiDpC,cAAc;;;eAGb;IAGD,gBAAgB;;eAoBf;IAED,YAAY,aAQX;IAGD,UAAU,CAAC,UAAU,KAAA,EAAE,IAAI,KAAA;;;;IA8B3B,YAAY,CAAC,KAAK,KAAA,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;;;KAAA;IAWjC,SAAS,CACP,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,UAAU,GAChB,QAAQ;IAiBX,UAAU,CACR,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,UAAU;IAqBnB,kBAAkB,oBAGjB;IAGD,gBAAgB,oBAGf;IAED,KAAK;IASL,MAAM;CAgGP;AAED,eAAe,IAAI,CAAA;AACnB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA"}
|
package/LICENSE.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: The MIT License (MIT)
|
|
3
|
-
category: Getting Started
|
|
4
|
-
order: 9
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# The MIT License (MIT)
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2015 Instructure, Inc.
|
|
10
|
-
|
|
11
|
-
**Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions.**
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|