react-tab-set 2.0.121 → 2.0.123

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-tab-set",
3
- "version": "2.0.121",
3
+ "version": "2.0.123",
4
4
  "description": "A React Tab Set component",
5
5
  "main": "./src/index.mjs",
6
6
  "type": "module",
@@ -26,40 +26,40 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "debug": "^4.3.5",
29
- "uuid": "^9.0.1"
29
+ "uuid": "^10.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@babel/core": "^7.24.6",
33
- "@babel/eslint-parser": "^7.24.6",
34
- "@babel/plugin-syntax-jsx": "^7.24.6",
35
- "@babel/plugin-transform-typescript": "^7.24.6",
36
- "@babel/preset-env": "^7.24.6",
37
- "@babel/preset-react": "^7.24.6",
38
- "@babel/preset-typescript": "^7.24.6",
32
+ "@babel/core": "^7.24.7",
33
+ "@babel/eslint-parser": "^7.24.7",
34
+ "@babel/plugin-syntax-jsx": "^7.24.7",
35
+ "@babel/plugin-transform-typescript": "^7.24.7",
36
+ "@babel/preset-env": "^7.24.7",
37
+ "@babel/preset-react": "^7.24.7",
38
+ "@babel/preset-typescript": "^7.24.7",
39
39
  "@babel/register": "^7.24.6",
40
- "@sequencemedia/hooks": "^1.0.494",
41
- "@storybook/addon-essentials": "^8.1.5",
42
- "@storybook/addon-links": "^8.1.5",
43
- "@storybook/react": "^8.1.5",
44
- "@storybook/react-webpack5": "^8.1.5",
40
+ "@sequencemedia/hooks": "^1.0.495",
41
+ "@storybook/addon-essentials": "^8.1.11",
42
+ "@storybook/addon-links": "^8.1.11",
43
+ "@storybook/react": "^8.1.11",
44
+ "@storybook/react-webpack5": "^8.1.11",
45
45
  "@types/debug": "^4.1.12",
46
46
  "@types/react": "^18.3.3",
47
- "@types/uuid": "^9.0.8",
48
- "@typescript-eslint/eslint-plugin": "^7.11.0",
49
- "@typescript-eslint/parser": "^7.11.0",
47
+ "@types/uuid": "^10.0.0",
48
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
49
+ "@typescript-eslint/parser": "^7.14.1",
50
50
  "core-js": "^3.37.1",
51
51
  "cross-env": "^7.0.3",
52
52
  "eslint": "8.57.0",
53
53
  "eslint-config-love": "47.0.0",
54
54
  "eslint-config-standard": "^17.1.0",
55
- "eslint-plugin-react": "^7.34.2",
55
+ "eslint-plugin-react": "^7.34.3",
56
56
  "eslint-plugin-storybook": "^0.8.0",
57
57
  "husky": "^9.0.11",
58
58
  "prop-types": "15.8.1",
59
59
  "react": "^18.3.1",
60
60
  "react-dom": "^18.3.1",
61
- "storybook": "^8.1.5",
62
- "typescript": "^5.4.5"
61
+ "storybook": "^8.1.11",
62
+ "typescript": "^5.5.2"
63
63
  },
64
64
  "exports": {
65
65
  ".": {
@@ -15,7 +15,8 @@ import debug from 'debug'
15
15
  import isTabPanel from './is-tab-panel.mts'
16
16
  import isTabGroup from './is-tab-group.mts'
17
17
 
18
- const error = debug('react-tab-set/tab-set')
18
+ const log = debug('react-tab-set/tab-set')
19
+ const error = debug('react-tab-set/tab-set:error')
19
20
 
20
21
  export interface TabSetProps {
21
22
  children: JSX.Element | JSX.Element[]
@@ -74,23 +75,35 @@ function mapChildren (
74
75
  })
75
76
  }
76
77
 
78
+ function DEFAULT_HANDLE_CHANGE (selectedTab: string): void {
79
+ log(selectedTab)
80
+ }
81
+
77
82
  export default function TabSet (props: TabSetProps): JSX.Element {
78
83
  const {
79
84
  children,
80
- selectedTab: tab
85
+ selectedTab: tab = v4()
81
86
  } = props
82
87
 
83
88
  const [selectedTab, setSelectedTab] = useState(tab)
84
89
 
85
- useEffect(() => { setSelectedTab(tab) }, [tab])
90
+ useEffect(() => {
91
+ if (selectedTab !== tab) {
92
+ setSelectedTab(tab)
93
+ }
94
+ }, [tab])
86
95
 
87
96
  useEffect(() => {
88
- const { onChange } = props
97
+ if (selectedTab !== tab) {
98
+ const {
99
+ onChange = DEFAULT_HANDLE_CHANGE
100
+ } = props
89
101
 
90
- try {
91
- onChange(selectedTab)
92
- } catch {
93
- error('Error `onChange`')
102
+ try {
103
+ onChange(selectedTab)
104
+ } catch {
105
+ error('Error `onChange`')
106
+ }
94
107
  }
95
108
  }, [selectedTab])
96
109
 
@@ -100,7 +113,3 @@ export default function TabSet (props: TabSetProps): JSX.Element {
100
113
  </div>
101
114
  )
102
115
  }
103
-
104
- TabSet.defaultProps = {
105
- selectedTab: v4()
106
- }
@@ -8,9 +8,12 @@ import React, {
8
8
  import {
9
9
  v4
10
10
  } from 'uuid'
11
+ import debug from 'debug'
11
12
 
12
13
  import isTab from './is-tab.mts'
13
14
 
15
+ const log = debug('react-tab-set/tab-set/tab-group')
16
+
14
17
  export interface TabGroupProps {
15
18
  children: JSX.Element | JSX.Element[]
16
19
  selectedTab: string
@@ -58,11 +61,15 @@ function mapChildren (
58
61
  })
59
62
  }
60
63
 
64
+ function DEFAULT_HANDLE_TAB_SELECT (value: React.SetStateAction<string>): void {
65
+ log(value)
66
+ }
67
+
61
68
  export default function TabGroup (props: TabGroupProps): JSX.Element {
62
69
  const {
63
70
  children,
64
- selectedTab,
65
- onTabSelect
71
+ selectedTab = v4(),
72
+ onTabSelect = DEFAULT_HANDLE_TAB_SELECT
66
73
  } = props
67
74
 
68
75
  return (
@@ -71,8 +78,3 @@ export default function TabGroup (props: TabGroupProps): JSX.Element {
71
78
  </ul>
72
79
  )
73
80
  }
74
-
75
- TabGroup.defaultProps = {
76
- selectedTab: v4(),
77
- onTabSelect () { }
78
- }
@@ -7,6 +7,9 @@ import React, {
7
7
  import {
8
8
  v4
9
9
  } from 'uuid'
10
+ import debug from 'debug'
11
+
12
+ const log = debug('react-tab-set/tab-set/tab-group/tab')
10
13
 
11
14
  export interface TabProps {
12
15
  children: JSX.Element | JSX.Element[] | string | number | boolean
@@ -15,12 +18,16 @@ export interface TabProps {
15
18
  onTabSelect: (value: React.SetStateAction<string>) => void
16
19
  }
17
20
 
21
+ function DEFAULT_HANDLE_TAB_SELECT (value: React.SetStateAction<string>): void {
22
+ log(value)
23
+ }
24
+
18
25
  export default function Tab (props: TabProps): JSX.Element {
19
26
  const {
20
27
  children,
21
28
  tab,
22
- selectedTab,
23
- onTabSelect
29
+ selectedTab = v4(),
30
+ onTabSelect = DEFAULT_HANDLE_TAB_SELECT
24
31
  } = props
25
32
 
26
33
  const className = (tab === selectedTab)
@@ -39,8 +46,3 @@ export default function Tab (props: TabProps): JSX.Element {
39
46
  </li>
40
47
  )
41
48
  }
42
-
43
- Tab.defaultProps = {
44
- selectedTab: v4(),
45
- onTabSelect () { }
46
- }
@@ -13,15 +13,19 @@ export interface TabPanelProps {
13
13
  render?: () => JSX.Element | JSX.Element[] | string | number | boolean | undefined | null
14
14
  }
15
15
 
16
+ function DEFAULT_RENDER (): null {
17
+ return null
18
+ }
19
+
16
20
  export default function TabPanel (props: TabPanelProps): JSX.Element | null {
17
21
  const {
18
22
  tab,
19
- selectedTab
23
+ selectedTab = v4()
20
24
  } = props
21
25
 
22
26
  if (tab === selectedTab) {
23
27
  const {
24
- render = () => null,
28
+ render = DEFAULT_RENDER,
25
29
  children = render()
26
30
  } = props
27
31
 
@@ -36,7 +40,3 @@ export default function TabPanel (props: TabPanelProps): JSX.Element | null {
36
40
 
37
41
  return null
38
42
  }
39
-
40
- TabPanel.defaultProps = {
41
- selectedTab: v4()
42
- }