react-tab-set 2.0.0 → 2.0.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/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Content can be declared either as children or as the return of a function assign
|
|
|
47
47
|
|
|
48
48
|
If your component extends `PureComponent` or is presentational, you might prefer to declare content as children.
|
|
49
49
|
|
|
50
|
-
Otherwise, you
|
|
50
|
+
Otherwise, you can assign a function to the `render` prop, so that rendering is deferred until the tab is selected.
|
|
51
51
|
|
|
52
52
|
### Content as children
|
|
53
53
|
|
|
@@ -99,7 +99,7 @@ Similarly, they can be declared in any combination.
|
|
|
99
99
|
|
|
100
100
|
## Demonstrating _react-tab-set_
|
|
101
101
|
|
|
102
|
-
[Example `Storybooks` are available
|
|
102
|
+
[Example `Storybooks` are available](https://github.com/sequencemedia/react-tab-set).
|
|
103
103
|
|
|
104
104
|
Clone the repository, then:
|
|
105
105
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-tab-set",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A React Tab Set component",
|
|
5
5
|
"main": "./src/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"@babel/register": "^7.22.15",
|
|
40
40
|
"@sequencemedia/hooks": "^1.0.454",
|
|
41
41
|
"@storybook/addon-essentials": "^7.4.4",
|
|
42
|
+
"@storybook/addon-links": "^7.4.4",
|
|
42
43
|
"@storybook/react": "^7.4.4",
|
|
43
44
|
"@storybook/react-webpack5": "^7.4.4",
|
|
44
45
|
"@types/debug": "^4.1.9",
|
package/src/tab-set/index.tsx
CHANGED
|
@@ -23,7 +23,8 @@ export interface TabSetProps {
|
|
|
23
23
|
function mapChildren (
|
|
24
24
|
children: JSX.Element | JSX.Element[],
|
|
25
25
|
selectedTab: string,
|
|
26
|
-
onTabSelect: (value: React.SetStateAction<string>) => void
|
|
26
|
+
onTabSelect: (value: React.SetStateAction<string>) => void
|
|
27
|
+
): JSX.Element[] {
|
|
27
28
|
return Children.map(children, (child) => {
|
|
28
29
|
const { type } = child
|
|
29
30
|
|
|
@@ -2,6 +2,9 @@ import React, {
|
|
|
2
2
|
Children,
|
|
3
3
|
cloneElement
|
|
4
4
|
} from 'react'
|
|
5
|
+
import {
|
|
6
|
+
v4
|
|
7
|
+
} from 'uuid'
|
|
5
8
|
|
|
6
9
|
import isTab from './is-tab.mts'
|
|
7
10
|
|
|
@@ -11,7 +14,11 @@ export interface TabGroupProps {
|
|
|
11
14
|
onTabSelect: (value: React.SetStateAction<string>) => void
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
function mapChildren (
|
|
17
|
+
function mapChildren (
|
|
18
|
+
children: JSX.Element | JSX.Element[],
|
|
19
|
+
selectedTab: string,
|
|
20
|
+
onTabSelect: (value: React.SetStateAction<string>) => void
|
|
21
|
+
): JSX.Element[] {
|
|
15
22
|
return Children.map(children, (child) => {
|
|
16
23
|
const { type } = child
|
|
17
24
|
|
|
@@ -61,3 +68,8 @@ export default function TabGroup (props: TabGroupProps): JSX.Element {
|
|
|
61
68
|
</ul>
|
|
62
69
|
)
|
|
63
70
|
}
|
|
71
|
+
|
|
72
|
+
TabGroup.defaultProps = {
|
|
73
|
+
selectedTab: v4(),
|
|
74
|
+
onTabSelect () { }
|
|
75
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
v4
|
|
4
|
+
} from 'uuid'
|
|
2
5
|
|
|
3
6
|
export interface TabProps {
|
|
4
7
|
children: JSX.Element | JSX.Element[] | string | number | boolean
|
|
@@ -29,3 +32,8 @@ export default function Tab (props: TabProps): JSX.Element {
|
|
|
29
32
|
</li>
|
|
30
33
|
)
|
|
31
34
|
}
|
|
35
|
+
|
|
36
|
+
Tab.defaultProps = {
|
|
37
|
+
selectedTab: v4(),
|
|
38
|
+
onTabSelect () { }
|
|
39
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
v4
|
|
4
|
+
} from 'uuid'
|
|
2
5
|
|
|
3
6
|
export interface TabPanelProps {
|
|
4
7
|
children?: JSX.Element | JSX.Element[] | string | number | boolean | undefined | null
|
|
@@ -30,3 +33,7 @@ export default function TabPanel (props: TabPanelProps): JSX.Element | null {
|
|
|
30
33
|
|
|
31
34
|
return null
|
|
32
35
|
}
|
|
36
|
+
|
|
37
|
+
TabPanel.defaultProps = {
|
|
38
|
+
selectedTab: v4()
|
|
39
|
+
}
|