react-tab-set 1.2.1 → 1.2.3
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/package.json +7 -9
- package/src/index.mts +1 -23
- package/src/tab-set/index.tsx +21 -13
- package/src/tab-set/tab-group/index.tsx +1 -1
- package/src/tab-set/tab-panel/index.tsx +1 -1
- package/index.mjs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-tab-set",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "A React Tab Set component",
|
|
5
5
|
"main": "./src/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"url": "http://www.sequencemedia.net"
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18.17.0"
|
|
15
|
+
},
|
|
13
16
|
"repository": {
|
|
14
17
|
"type": "git",
|
|
15
18
|
"url": "git://github.com/sequencemedia/react-tab-set.git"
|
|
@@ -26,7 +29,6 @@
|
|
|
26
29
|
"uuid": "^9.0.1"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
|
-
"@babel/cli": "^7.22.15",
|
|
30
32
|
"@babel/core": "^7.22.20",
|
|
31
33
|
"@babel/eslint-parser": "^7.22.15",
|
|
32
34
|
"@babel/plugin-transform-typescript": "^7.22.15",
|
|
@@ -34,22 +36,18 @@
|
|
|
34
36
|
"@babel/preset-react": "^7.22.15",
|
|
35
37
|
"@babel/preset-typescript": "^7.22.15",
|
|
36
38
|
"@babel/register": "^7.22.15",
|
|
37
|
-
"@sequencemedia/hooks": "^1.0.
|
|
39
|
+
"@sequencemedia/hooks": "^1.0.454",
|
|
38
40
|
"@storybook/addon-essentials": "^7.4.4",
|
|
39
|
-
"@storybook/addon-interactions": "^7.4.4",
|
|
40
|
-
"@storybook/addon-links": "^7.4.4",
|
|
41
|
-
"@storybook/addon-onboarding": "^1.0.8",
|
|
42
|
-
"@storybook/blocks": "^7.4.4",
|
|
43
41
|
"@storybook/react": "^7.4.4",
|
|
44
42
|
"@storybook/react-webpack5": "^7.4.4",
|
|
45
|
-
"@types/debug": "^4.1.
|
|
43
|
+
"@types/debug": "^4.1.9",
|
|
46
44
|
"@types/react": "^18.2.22",
|
|
47
45
|
"@types/uuid": "^9.0.4",
|
|
48
46
|
"@typescript-eslint/eslint-plugin": "5.61.0",
|
|
49
47
|
"@typescript-eslint/parser": "5.61.0",
|
|
50
48
|
"core-js": "^3.32.2",
|
|
51
49
|
"cross-env": "^7.0.3",
|
|
52
|
-
"eslint": "^8.
|
|
50
|
+
"eslint": "^8.50.0",
|
|
53
51
|
"eslint-config-standard": "^17.1.0",
|
|
54
52
|
"eslint-config-standard-with-typescript": "35.0.0",
|
|
55
53
|
"eslint-plugin-react": "^7.33.2",
|
package/src/index.mts
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import isTab from './tab-set/tab-group/is-tab.mts'
|
|
3
|
-
import isTabPanel from './tab-set/is-tab-panel.mts'
|
|
4
|
-
|
|
5
|
-
import TabGroup from './tab-set/tab-group/index.tsx'
|
|
6
|
-
import Tab from './tab-set/tab-group/tab/index.tsx'
|
|
7
|
-
import TabPanel from './tab-set/tab-panel/index.tsx'
|
|
8
|
-
|
|
9
|
-
import TabSet from './tab-set/index.tsx'
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
isTabGroup,
|
|
13
|
-
isTab,
|
|
14
|
-
isTabPanel
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
TabGroup,
|
|
19
|
-
Tab,
|
|
20
|
-
TabPanel
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default TabSet
|
|
1
|
+
export { default } from './tab-set/index.tsx'
|
package/src/tab-set/index.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import isTabGroup from './is-tab-group.mts'
|
|
|
10
10
|
const error = debug('react-tab-set/tab-set')
|
|
11
11
|
|
|
12
12
|
export interface TabSetProps {
|
|
13
|
+
onClick: (selectedTab: string) => void
|
|
13
14
|
onChange: (selectedTab: string) => void
|
|
14
15
|
selectedTab: string
|
|
15
16
|
children: JSX.Element | JSX.Element[]
|
|
@@ -20,16 +21,8 @@ export interface TabSetState {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export default class TabSet extends Component<TabSetProps, TabSetState> {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
selectedTab
|
|
28
|
-
} = props
|
|
29
|
-
|
|
30
|
-
this.state = {
|
|
31
|
-
selectedTab
|
|
32
|
-
}
|
|
24
|
+
state = {
|
|
25
|
+
selectedTab: this.props.selectedTab
|
|
33
26
|
}
|
|
34
27
|
|
|
35
28
|
/*
|
|
@@ -38,11 +31,18 @@ export default class TabSet extends Component<TabSetProps, TabSetState> {
|
|
|
38
31
|
* an implemented tab
|
|
39
32
|
*/
|
|
40
33
|
static defaultProps = {
|
|
41
|
-
|
|
34
|
+
onClick () {},
|
|
35
|
+
onChange () {},
|
|
42
36
|
selectedTab: v4(),
|
|
43
37
|
children: []
|
|
44
38
|
}
|
|
45
39
|
|
|
40
|
+
static getDerivedStateFromProps ({ selectedTab }: TabSetState): TabSetState {
|
|
41
|
+
return {
|
|
42
|
+
selectedTab
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
46
|
shouldComponentUpdate (props: TabSetProps, state: TabSetState): boolean {
|
|
47
47
|
return (
|
|
48
48
|
props.children !== this.props.children ||
|
|
@@ -51,10 +51,18 @@ export default class TabSet extends Component<TabSetProps, TabSetState> {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
handleTabSelect = (selectedTab: string): void => {
|
|
54
|
-
|
|
55
|
-
const { onChange } = this.props
|
|
54
|
+
const { onClick } = this.props
|
|
56
55
|
|
|
56
|
+
try {
|
|
57
|
+
onClick(selectedTab)
|
|
58
|
+
} catch {
|
|
59
|
+
error('Error `onClick`')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (selectedTab !== this.state.selectedTab) {
|
|
57
63
|
this.setState({ selectedTab }, () => {
|
|
64
|
+
const { onChange } = this.props
|
|
65
|
+
|
|
58
66
|
try {
|
|
59
67
|
onChange(selectedTab)
|
|
60
68
|
} catch {
|
package/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/index.cjs'
|