@clayui/tabs 3.45.0 → 3.52.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/README.md +19 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -2
- package/package.json +3 -3
- package/src/__tests__/index.tsx +18 -0
- package/src/index.tsx +19 -5
- package/README.mdx +0 -38
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# `@clayui/tabs`
|
|
2
|
+
|
|
3
|
+
Tabs organize similar content together into individual sections in the same page.
|
|
4
|
+
|
|
5
|
+
- [Documentation](https://clayui.com/docs/components/tabs.html)
|
|
6
|
+
- [Changelog](./CHANGELOG.md)
|
|
7
|
+
- [Breaking change schedule](./BREAKING.md)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Run `yarn`
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
yarn add @clayui/tabs
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Contribute
|
|
18
|
+
|
|
19
|
+
We'd love to get contributions from you! Please, check our [Contributing Guidelines](https://github.com/liferay/clay/blob/master/CONTRIBUTING.md) to see how you can help us improve.
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import Content from './Content';
|
|
3
3
|
import Item from './Item';
|
|
4
4
|
import TabPane from './TabPane';
|
|
5
|
+
export declare type DisplayType = null | 'basic' | 'underline';
|
|
5
6
|
interface IProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
7
|
+
displayType?: DisplayType;
|
|
6
8
|
justified?: boolean;
|
|
7
9
|
modern?: boolean;
|
|
8
10
|
}
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var _Item = _interopRequireDefault(require("./Item"));
|
|
|
15
15
|
|
|
16
16
|
var _TabPane = _interopRequireDefault(require("./TabPane"));
|
|
17
17
|
|
|
18
|
-
var _excluded = ["children", "className", "justified", "modern"];
|
|
18
|
+
var _excluded = ["children", "className", "displayType", "justified", "modern"];
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
@@ -28,6 +28,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
28
28
|
var ClayTabs = function ClayTabs(_ref) {
|
|
29
29
|
var children = _ref.children,
|
|
30
30
|
className = _ref.className,
|
|
31
|
+
displayType = _ref.displayType,
|
|
31
32
|
justified = _ref.justified,
|
|
32
33
|
_ref$modern = _ref.modern,
|
|
33
34
|
modern = _ref$modern === void 0 ? true : _ref$modern,
|
|
@@ -35,9 +36,13 @@ var ClayTabs = function ClayTabs(_ref) {
|
|
|
35
36
|
|
|
36
37
|
return /*#__PURE__*/_react.default.createElement("ul", _extends({
|
|
37
38
|
className: (0, _classnames.default)('nav', {
|
|
38
|
-
'nav-justified': justified
|
|
39
|
+
'nav-justified': justified
|
|
40
|
+
}, !displayType ? {
|
|
39
41
|
'nav-tabs': !modern,
|
|
40
42
|
'nav-underline': modern
|
|
43
|
+
} : {
|
|
44
|
+
'nav-tabs': displayType === 'basic',
|
|
45
|
+
'nav-underline': displayType === 'underline'
|
|
41
46
|
}, className),
|
|
42
47
|
role: "tablist"
|
|
43
48
|
}, otherProps), children);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clayui/tabs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.52.0",
|
|
4
4
|
"description": "ClayTabs component",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": "https://github.com/liferay/clay",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@clayui/shared": "^3.
|
|
29
|
+
"@clayui/shared": "^3.52.0",
|
|
30
30
|
"classnames": "^2.2.6"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"browserslist": [
|
|
38
38
|
"extends browserslist-config-clay"
|
|
39
39
|
],
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "eb7c98d6c746294376f10554c68cc48c30d8bd0e"
|
|
41
41
|
}
|
package/src/__tests__/index.tsx
CHANGED
|
@@ -62,12 +62,30 @@ describe('ClayTabs', () => {
|
|
|
62
62
|
expect(container.querySelector('.nav.nav-justified')).toBeTruthy();
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
it('renders with displayType prop nav items', () => {
|
|
66
|
+
const {container} = render(<ClayTabs displayType="underline" />);
|
|
67
|
+
|
|
68
|
+
expect(container.querySelector('.nav.nav-underline')).toBeTruthy();
|
|
69
|
+
});
|
|
70
|
+
|
|
65
71
|
it('renders with modern style', () => {
|
|
66
72
|
const {container} = render(<ClayTabs modern />);
|
|
67
73
|
|
|
68
74
|
expect(container.querySelector('.nav.nav-underline')).toBeTruthy();
|
|
69
75
|
});
|
|
70
76
|
|
|
77
|
+
it('renders with modern style and displayType prop as null', () => {
|
|
78
|
+
const {container} = render(<ClayTabs displayType={null} modern />);
|
|
79
|
+
|
|
80
|
+
expect(container.querySelector('.nav.nav-underline')).toBeTruthy();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('renders with tab style using displayType prop and overrides modern prop', () => {
|
|
84
|
+
const {container} = render(<ClayTabs displayType="basic" modern />);
|
|
85
|
+
|
|
86
|
+
expect(container.querySelector('.nav.nav-tabs')).toBeTruthy();
|
|
87
|
+
});
|
|
88
|
+
|
|
71
89
|
it('renders with items', () => {
|
|
72
90
|
const {container} = render(<ClayTabsWithItems />);
|
|
73
91
|
|
package/src/index.tsx
CHANGED
|
@@ -10,7 +10,14 @@ import Content from './Content';
|
|
|
10
10
|
import Item from './Item';
|
|
11
11
|
import TabPane from './TabPane';
|
|
12
12
|
|
|
13
|
+
export type DisplayType = null | 'basic' | 'underline';
|
|
14
|
+
|
|
13
15
|
interface IProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
16
|
+
/**
|
|
17
|
+
* Determines how tab is displayed.
|
|
18
|
+
*/
|
|
19
|
+
displayType?: DisplayType;
|
|
20
|
+
|
|
14
21
|
/**
|
|
15
22
|
* Justify the nav items according the tab content.
|
|
16
23
|
*/
|
|
@@ -30,6 +37,7 @@ const ClayTabs: React.FunctionComponent<IProps> & {
|
|
|
30
37
|
} = ({
|
|
31
38
|
children,
|
|
32
39
|
className,
|
|
40
|
+
displayType,
|
|
33
41
|
justified,
|
|
34
42
|
modern = true,
|
|
35
43
|
...otherProps
|
|
@@ -38,11 +46,17 @@ const ClayTabs: React.FunctionComponent<IProps> & {
|
|
|
38
46
|
<ul
|
|
39
47
|
className={classNames(
|
|
40
48
|
'nav',
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
{'nav-justified': justified},
|
|
50
|
+
!displayType
|
|
51
|
+
? {
|
|
52
|
+
'nav-tabs': !modern,
|
|
53
|
+
'nav-underline': modern,
|
|
54
|
+
}
|
|
55
|
+
: {
|
|
56
|
+
'nav-tabs': displayType === 'basic',
|
|
57
|
+
'nav-underline': displayType === 'underline',
|
|
58
|
+
},
|
|
59
|
+
|
|
46
60
|
className
|
|
47
61
|
)}
|
|
48
62
|
role="tablist"
|
package/README.mdx
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'Tabs'
|
|
3
|
-
description: 'Tabs organize similar content together into individual sections in the same page.'
|
|
4
|
-
lexiconDefinition: 'https://liferay.design/lexicon/core-components/tabs/'
|
|
5
|
-
packageNpm: '@clayui/tabs'
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
import {Tabs, TabsDropdown} from '$packages/clay-tabs/docs/index';
|
|
9
|
-
|
|
10
|
-
<div class="nav-toc-absolute">
|
|
11
|
-
<div class="nav-toc">
|
|
12
|
-
|
|
13
|
-
- [Introduction](#introduction)
|
|
14
|
-
- [Dropdown Tabs](#dropdown-tabs)
|
|
15
|
-
- [TabPanel](#tabpanel)
|
|
16
|
-
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
|
|
20
|
-
## Introduction
|
|
21
|
-
|
|
22
|
-
`ClayTabs` is a controlled component, we left this component controlled because the user can use Dropdowns or another control to select a `TabPane` for render. Just creating states to manage it.
|
|
23
|
-
|
|
24
|
-
For the modern variant of Tabs use the `modern` property. If you need to justify the text inside the `ClayTabs.Item`, use the `justified` property.
|
|
25
|
-
|
|
26
|
-
Use `ClayTabs.Item` for defining a TabPane's trigger. For using this trigger as an `anchor` element, just define `href` property, otherwise, the trigger will be a `button`. Use `ClayTabs.TabPane` for wrapping the content that will be rendered by TabPane as the following example:
|
|
27
|
-
|
|
28
|
-
<Tabs />
|
|
29
|
-
|
|
30
|
-
## Dropdown Tabs
|
|
31
|
-
|
|
32
|
-
As a controlled component, Tabs allows you to control the `active` TabPane. Thereby, we can select the active TabPane by a Dropdown menu. For example:
|
|
33
|
-
|
|
34
|
-
<TabsDropdown />
|
|
35
|
-
|
|
36
|
-
## TabPanel
|
|
37
|
-
|
|
38
|
-
Note that `ClayTabs.TabPanel` is an alias to `ClayTabs.TabPane`. The two are interchangeable.
|