react-tab-set 2.0.213 → 2.1.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/eslint.config.mjs +84 -0
- package/package.json +12 -9
- package/src/tab-set/index.tsx +10 -12
- package/src/tab-set/is-tab-group.mts +5 -1
- package/src/tab-set/is-tab-panel.mts +5 -1
- package/src/tab-set/tab-group/index.tsx +9 -11
- package/src/tab-set/tab-group/is-tab.mts +6 -2
- package/src/tab-set/tab-panel/index.tsx +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import globals from 'globals'
|
|
2
|
+
import standard from '@sequencemedia/eslint-config-standard/merge'
|
|
3
|
+
import typescript from '@sequencemedia/eslint-config-typescript/merge'
|
|
4
|
+
import parser from '@typescript-eslint/parser'
|
|
5
|
+
import eslint from '@typescript-eslint/eslint-plugin'
|
|
6
|
+
import eslintComments from '@eslint-community/eslint-plugin-eslint-comments'
|
|
7
|
+
import n from 'eslint-plugin-n'
|
|
8
|
+
import p from 'eslint-plugin-promise'
|
|
9
|
+
import i from 'eslint-plugin-import'
|
|
10
|
+
import react from 'eslint-plugin-react'
|
|
11
|
+
|
|
12
|
+
export default [
|
|
13
|
+
...standard({
|
|
14
|
+
files: [
|
|
15
|
+
'**/*.{mjs,cjs}'
|
|
16
|
+
],
|
|
17
|
+
ignores: [
|
|
18
|
+
'src'
|
|
19
|
+
],
|
|
20
|
+
languageOptions: {
|
|
21
|
+
globals: {
|
|
22
|
+
...globals.node
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
...standard({
|
|
27
|
+
files: [
|
|
28
|
+
'src/**/*.{mjs,cjs}'
|
|
29
|
+
],
|
|
30
|
+
languageOptions: {
|
|
31
|
+
globals: {
|
|
32
|
+
...globals.browser
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
...typescript({
|
|
37
|
+
files: [
|
|
38
|
+
'**/*.{mts,cts}'
|
|
39
|
+
],
|
|
40
|
+
ignores: [
|
|
41
|
+
'src'
|
|
42
|
+
],
|
|
43
|
+
languageOptions: {
|
|
44
|
+
globals: {
|
|
45
|
+
...globals.node
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
...typescript({
|
|
50
|
+
files: [
|
|
51
|
+
'src/**/*.{mts,cts}'
|
|
52
|
+
],
|
|
53
|
+
languageOptions: {
|
|
54
|
+
globals: {
|
|
55
|
+
...globals.browser
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
...typescript({
|
|
60
|
+
files: [
|
|
61
|
+
'src/**/*.tsx'
|
|
62
|
+
],
|
|
63
|
+
plugins: {
|
|
64
|
+
'@typescript-eslint': eslint,
|
|
65
|
+
'eslint-comments': eslintComments,
|
|
66
|
+
n,
|
|
67
|
+
promise: p,
|
|
68
|
+
import: i,
|
|
69
|
+
react
|
|
70
|
+
},
|
|
71
|
+
languageOptions: {
|
|
72
|
+
parser,
|
|
73
|
+
parserOptions: {
|
|
74
|
+
project: 'tsconfig.json',
|
|
75
|
+
ecmaFeatures: {
|
|
76
|
+
jsx: true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
globals: {
|
|
80
|
+
...globals.browser
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-tab-set",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A React Tab Set component",
|
|
5
5
|
"main": "./src/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build-storybook": "storybook build",
|
|
22
|
-
"lint": "eslint .
|
|
22
|
+
"lint": "eslint .",
|
|
23
23
|
"lint:fix": "npm run lint -- --fix",
|
|
24
24
|
"prepare": "husky",
|
|
25
25
|
"storybook": "storybook dev -p 6006"
|
|
@@ -30,28 +30,31 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/core": "^7.26.0",
|
|
33
|
-
"@babel/eslint-parser": "^7.25.9",
|
|
34
33
|
"@babel/plugin-syntax-jsx": "^7.25.9",
|
|
35
34
|
"@babel/plugin-transform-typescript": "^7.26.3",
|
|
36
35
|
"@babel/preset-env": "^7.26.0",
|
|
37
36
|
"@babel/preset-react": "^7.26.3",
|
|
38
37
|
"@babel/preset-typescript": "^7.26.0",
|
|
39
38
|
"@babel/register": "^7.25.9",
|
|
39
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
40
|
+
"@sequencemedia/eslint-config-standard": "^0.1.4",
|
|
41
|
+
"@sequencemedia/eslint-config-typescript": "^0.0.2",
|
|
40
42
|
"@storybook/addon-essentials": "7.6.20",
|
|
41
43
|
"@storybook/react": "7.6.20",
|
|
42
44
|
"@storybook/react-webpack5": "7.6.20",
|
|
43
45
|
"@types/debug": "^4.1.12",
|
|
44
46
|
"@types/react": "^18.3.13",
|
|
45
47
|
"@types/uuid": "^10.0.0",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "
|
|
47
|
-
"@typescript-eslint/parser": "
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
49
|
+
"@typescript-eslint/parser": "^8.17.0",
|
|
48
50
|
"core-js": "^3.39.0",
|
|
49
|
-
"
|
|
50
|
-
"eslint": "
|
|
51
|
-
"eslint-
|
|
52
|
-
"eslint-
|
|
51
|
+
"eslint": "^9.16.0",
|
|
52
|
+
"eslint-plugin-import": "^2.31.0",
|
|
53
|
+
"eslint-plugin-n": "^17.14.0",
|
|
54
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
53
55
|
"eslint-plugin-react": "^7.37.2",
|
|
54
56
|
"eslint-plugin-storybook": "^0.11.1",
|
|
57
|
+
"globals": "^15.13.0",
|
|
55
58
|
"husky": "^9.1.7",
|
|
56
59
|
"prop-types": "^15.8.1",
|
|
57
60
|
"react": "^18.3.1",
|
package/src/tab-set/index.tsx
CHANGED
|
@@ -29,16 +29,16 @@ function mapChildren (
|
|
|
29
29
|
selectedTab: string,
|
|
30
30
|
onTabSelect: (value: React.SetStateAction<string>) => void
|
|
31
31
|
): JSX.Element[] {
|
|
32
|
-
return Children.map(children, (child) => {
|
|
33
|
-
const { type } = child
|
|
32
|
+
return Children.map(children, (child: JSX.Element) => {
|
|
33
|
+
const { type } = child // eslint-disable-line @typescript-eslint/no-unsafe-assignment -- Component
|
|
34
34
|
|
|
35
|
-
if (type) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
36
|
-
const { props } = child
|
|
35
|
+
if (type) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions -- Truthiness is good, actually
|
|
36
|
+
const { props } = child // eslint-disable-line @typescript-eslint/no-unsafe-assignment -- Props
|
|
37
37
|
|
|
38
38
|
if (isTabGroup(type)) {
|
|
39
39
|
return cloneElement(
|
|
40
40
|
child,
|
|
41
|
-
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
41
|
+
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument -- Props
|
|
42
42
|
...props,
|
|
43
43
|
selectedTab,
|
|
44
44
|
onTabSelect
|
|
@@ -49,23 +49,21 @@ function mapChildren (
|
|
|
49
49
|
if (isTabPanel(type)) {
|
|
50
50
|
return cloneElement(
|
|
51
51
|
child,
|
|
52
|
-
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
52
|
+
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument -- Props
|
|
53
53
|
...props,
|
|
54
54
|
selectedTab
|
|
55
55
|
}
|
|
56
56
|
)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const {
|
|
60
|
-
children
|
|
61
|
-
} = props
|
|
59
|
+
const { children } = props // eslint-disable-line @typescript-eslint/no-unsafe-assignment -- Children are `JSX.Element` of `JSX.Element[]`
|
|
62
60
|
|
|
63
|
-
if (children) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
61
|
+
if (children) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions -- Truthiness is good, actually
|
|
64
62
|
return cloneElement(
|
|
65
63
|
child,
|
|
66
|
-
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
64
|
+
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument -- Props
|
|
67
65
|
...props,
|
|
68
|
-
children: mapChildren(children, selectedTab, onTabSelect) // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
66
|
+
children: mapChildren(children, selectedTab, onTabSelect) // eslint-disable-line @typescript-eslint/no-unsafe-argument -- Children are `JSX.Element` of `JSX.Element[]`
|
|
69
67
|
}
|
|
70
68
|
)
|
|
71
69
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
JSX
|
|
3
|
+
} from 'react'
|
|
4
|
+
|
|
1
5
|
import TabGroup from './tab-group/index.tsx'
|
|
2
6
|
|
|
3
|
-
export default function isTabGroup (component:
|
|
7
|
+
export default function isTabGroup (component: JSX.Element['type']): boolean {
|
|
4
8
|
return component === TabGroup
|
|
5
9
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
JSX
|
|
3
|
+
} from 'react'
|
|
4
|
+
|
|
1
5
|
import TabPanel from './tab-panel/index.tsx'
|
|
2
6
|
|
|
3
|
-
export default function isTabPanel (component:
|
|
7
|
+
export default function isTabPanel (component: JSX.Element['type']): boolean {
|
|
4
8
|
return component === TabPanel
|
|
5
9
|
}
|
|
@@ -25,16 +25,16 @@ function mapChildren (
|
|
|
25
25
|
selectedTab: string,
|
|
26
26
|
onTabSelect: (value: React.SetStateAction<string>) => void
|
|
27
27
|
): JSX.Element[] {
|
|
28
|
-
return Children.map(children, (child) => {
|
|
29
|
-
const { type } = child
|
|
28
|
+
return Children.map(children, (child: JSX.Element) => {
|
|
29
|
+
const { type } = child // eslint-disable-line @typescript-eslint/no-unsafe-assignment -- Component
|
|
30
30
|
|
|
31
|
-
if (type) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
32
|
-
const { props } = child
|
|
31
|
+
if (type) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions -- Truthiness is good, actually
|
|
32
|
+
const { props } = child // eslint-disable-line @typescript-eslint/no-unsafe-assignment -- Props
|
|
33
33
|
|
|
34
34
|
if (isTab(type)) {
|
|
35
35
|
return cloneElement(
|
|
36
36
|
child,
|
|
37
|
-
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
37
|
+
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument -- Props
|
|
38
38
|
...props,
|
|
39
39
|
selectedTab,
|
|
40
40
|
onTabSelect
|
|
@@ -42,16 +42,14 @@ function mapChildren (
|
|
|
42
42
|
)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const {
|
|
46
|
-
children
|
|
47
|
-
} = props
|
|
45
|
+
const { children } = props // eslint-disable-line @typescript-eslint/no-unsafe-assignment -- Children are `JSX.Element` of `JSX.Element[]`
|
|
48
46
|
|
|
49
|
-
if (children) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
47
|
+
if (children) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions -- Truthiness is good, actually
|
|
50
48
|
return cloneElement(
|
|
51
49
|
child,
|
|
52
|
-
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
50
|
+
{ // eslint-disable-line @typescript-eslint/no-unsafe-argument -- Props
|
|
53
51
|
...props,
|
|
54
|
-
children: mapChildren(children, selectedTab, onTabSelect) // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
52
|
+
children: mapChildren(children, selectedTab, onTabSelect) // eslint-disable-line @typescript-eslint/no-unsafe-argument -- Children are `JSX.Element` of `JSX.Element[]`
|
|
55
53
|
}
|
|
56
54
|
)
|
|
57
55
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type {
|
|
2
|
+
JSX
|
|
3
|
+
} from 'react'
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
import Tab from './tab/index.tsx'
|
|
6
|
+
|
|
7
|
+
export default function isTab (component: JSX.Element['type']): boolean {
|
|
4
8
|
return component === Tab
|
|
5
9
|
}
|
|
@@ -29,7 +29,7 @@ export default function TabPanel (props: TabPanelProps): JSX.Element | null {
|
|
|
29
29
|
children = render()
|
|
30
30
|
} = props
|
|
31
31
|
|
|
32
|
-
if (children) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
32
|
+
if (children) { // eslint-disable-line @typescript-eslint/strict-boolean-expressions -- Truthiness is good, actually
|
|
33
33
|
return (
|
|
34
34
|
<div className='tab-panel'>
|
|
35
35
|
{children}
|