@toptal/picasso-tabs 2.0.3-alpha-feature-tailwind-w21-c853d19b7.47 → 2.0.3-alpha-feature-tailwind-w21-5438106d8.50
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/dist-package/src/Tabs/Tabs.d.ts +9 -6
- package/dist-package/src/Tabs/Tabs.d.ts.map +1 -1
- package/dist-package/src/Tabs/Tabs.js +2 -4
- package/dist-package/src/Tabs/Tabs.js.map +1 -1
- package/dist-package/src/Tabs/index.d.ts +3 -2
- package/dist-package/src/Tabs/index.d.ts.map +1 -1
- package/dist-package/src/TabsCompound/index.d.ts +3 -1
- package/dist-package/src/TabsCompound/index.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/Tabs/Tabs.tsx +72 -68
- package/src/Tabs/index.ts +3 -2
- package/src/Tabs/story/Default.example.tsx +1 -1
- package/src/Tabs/story/FullWidth.example.tsx +1 -1
- package/src/Tabs/story/ScrollButtons.example.tsx +1 -1
- package/src/Tabs/story/Vertical.example.tsx +1 -1
- package/src/Tabs/test.tsx +7 -4
@@ -1,17 +1,18 @@
|
|
1
|
-
import type { ReactNode } from 'react';
|
1
|
+
import type { ReactNode, ForwardedRef } from 'react';
|
2
2
|
import React from 'react';
|
3
|
+
import { Tabs as MUITabs } from '@mui/base/Tabs';
|
3
4
|
import type { BaseProps } from '@toptal/picasso-shared';
|
4
|
-
declare type
|
5
|
-
export interface Props extends BaseProps {
|
5
|
+
export declare type TabsValueType = string | number | null;
|
6
|
+
export interface Props<V extends TabsValueType> extends BaseProps {
|
6
7
|
/** Tabs content containing Tab components */
|
7
8
|
children: ReactNode;
|
8
9
|
/** Callback fired when the value changes. */
|
9
|
-
onChange?: (event: React.ChangeEvent<{}> | null, value:
|
10
|
+
onChange?: (event: React.ChangeEvent<{}> | null, value: V) => void;
|
10
11
|
/**
|
11
12
|
* The value of the currently selected Tab.
|
12
13
|
* If you don't want any selected Tab, you can set this property to null.
|
13
14
|
*/
|
14
|
-
value:
|
15
|
+
value: V;
|
15
16
|
/** The tabs orientation (layout flow direction). */
|
16
17
|
orientation?: 'horizontal' | 'vertical';
|
17
18
|
/** Determines additional display behavior of the tabs */
|
@@ -21,6 +22,8 @@ export declare const TabsContext: React.Context<{
|
|
21
22
|
orientation: 'horizontal' | 'vertical';
|
22
23
|
variant: 'scrollable' | 'fullWidth';
|
23
24
|
}>;
|
24
|
-
|
25
|
+
declare const Tabs: <V extends TabsValueType = TabsValueType>(props: Props<V> & {
|
26
|
+
ref?: ForwardedRef<HTMLDivElement> | undefined;
|
27
|
+
}) => ReturnType<typeof MUITabs>;
|
25
28
|
export default Tabs;
|
26
29
|
//# sourceMappingURL=Tabs.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAGvD,oBAAY,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAElD,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS,aAAa,CAAE,SAAQ,SAAS;IAC/D,6CAA6C;IAC7C,QAAQ,EAAE,SAAS,CAAA;IAEnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IAElE;;;OAGG;IACH,KAAK,EAAE,CAAC,CAAA;IAER,oDAAoD;IACpD,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAEvC,yDAAyD;IACzD,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,CAAA;CACrC;AAED,eAAO,MAAM,WAAW;iBACT,YAAY,GAAG,UAAU;aAC7B,YAAY,GAAG,WAAW;EACmB,CAAA;AAmCxD,QAAA,MAAM,IAAI;;MAgEL,WAAW,cAAc,CAAC,CAAA;AAE/B,eAAe,IAAI,CAAA"}
|
@@ -44,9 +44,8 @@ const classesByVariant = {
|
|
44
44
|
scroller: 'w-full overflow-hidden',
|
45
45
|
},
|
46
46
|
};
|
47
|
-
|
48
|
-
|
49
|
-
const { children, orientation = 'horizontal', onChange, value, variant = 'scrollable', className } = props, rest = __rest(props, ["children", "orientation", "onChange", "value", "variant", "className"]);
|
47
|
+
const Tabs = forwardRef((_a, ref) => {
|
48
|
+
var { children, orientation = 'horizontal', onChange, value, variant = 'scrollable', className } = _a, rest = __rest(_a, ["children", "orientation", "onChange", "value", "variant", "className"]);
|
50
49
|
const contextValue = useMemo(() => ({
|
51
50
|
orientation,
|
52
51
|
variant,
|
@@ -62,6 +61,5 @@ export const Tabs = forwardRef(function Tabs(props, ref) {
|
|
62
61
|
React.createElement("div", { className: twJoin(classesByVariant[variant].scroller, classesByOrientation[orientation].scroller, 'flex-auto inline-block relative whitespace-nowrap') },
|
63
62
|
React.createElement(TabsList, { className: twJoin('flex', isVertical && 'flex-col') }, children)))));
|
64
63
|
});
|
65
|
-
Tabs.displayName = 'Tabs';
|
66
64
|
export default Tabs;
|
67
65
|
//# sourceMappingURL=Tabs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/Tabs/Tabs.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,E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AC,CAAC,QAAQ,EAClC,oBAAoB,CAAC,WAAW,CAAC,CAAC,QAAQ,EAC1C,mDAAmD,CACpD;gBAED,oBAAC,QAAQ,IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,IAAI,UAAU,CAAC,IAC1D,QAAQ,CACA,CACP,CACE,CACW,CACxB,CAAA;AACH,CAAC,CAG4B,CAAA;AAE/B,eAAe,IAAI,CAAA"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { OmitInternalProps } from '@toptal/picasso-shared';
|
2
|
-
import type { Props } from './Tabs';
|
2
|
+
import type { Props, TabsValueType } from './Tabs';
|
3
3
|
export { default as Tabs } from './Tabs';
|
4
|
-
export declare type TabsProps = OmitInternalProps<Props
|
4
|
+
export declare type TabsProps = OmitInternalProps<Props<TabsValueType>>;
|
5
|
+
export type { TabsValueType } from './Tabs';
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA;AACxC,oBAAY,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAA;AAC/D,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA"}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
export declare const TabsCompound: import("
|
2
|
+
export declare const TabsCompound: (<V extends import("../Tabs").TabsValueType = import("../Tabs").TabsValueType>(props: import("../Tabs/Tabs").Props<V> & {
|
3
|
+
ref?: import("react").ForwardedRef<HTMLDivElement> | undefined;
|
4
|
+
}) => JSX.Element | null) & {
|
3
5
|
Tab: import("react").ForwardRefExoticComponent<import("../Tab/Tab").Props & import("react").RefAttributes<HTMLButtonElement>>;
|
4
6
|
};
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TabsCompound/index.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TabsCompound/index.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;;;;CAEvB,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@toptal/picasso-tabs",
|
3
|
-
"version": "2.0.3-alpha-feature-tailwind-w21-
|
3
|
+
"version": "2.0.3-alpha-feature-tailwind-w21-5438106d8.50+5438106d8",
|
4
4
|
"description": "Toptal UI components library - Tabs",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -23,13 +23,13 @@
|
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
24
24
|
"dependencies": {
|
25
25
|
"@mui/base": "5.0.0-beta.40",
|
26
|
-
"@toptal/picasso-container": "1.0.4-alpha-feature-tailwind-w21-
|
27
|
-
"@toptal/picasso-icons": "1.1.2-alpha-feature-tailwind-w21-
|
28
|
-
"@toptal/picasso-shared": "15.0.1-alpha-feature-tailwind-w21-
|
29
|
-
"@toptal/picasso-typography": "2.0.2-alpha-feature-tailwind-w21-
|
30
|
-
"@toptal/picasso-typography-overflow": "2.0.2-alpha-feature-tailwind-w21-
|
31
|
-
"@toptal/picasso-user-badge": "2.0.3-alpha-feature-tailwind-w21-
|
32
|
-
"@toptal/picasso-utils": "1.0.4-alpha-feature-tailwind-w21-
|
26
|
+
"@toptal/picasso-container": "1.0.4-alpha-feature-tailwind-w21-5438106d8.50+5438106d8",
|
27
|
+
"@toptal/picasso-icons": "1.1.2-alpha-feature-tailwind-w21-5438106d8.50+5438106d8",
|
28
|
+
"@toptal/picasso-shared": "15.0.1-alpha-feature-tailwind-w21-5438106d8.50+5438106d8",
|
29
|
+
"@toptal/picasso-typography": "2.0.2-alpha-feature-tailwind-w21-5438106d8.50+5438106d8",
|
30
|
+
"@toptal/picasso-typography-overflow": "2.0.2-alpha-feature-tailwind-w21-5438106d8.50+5438106d8",
|
31
|
+
"@toptal/picasso-user-badge": "2.0.3-alpha-feature-tailwind-w21-5438106d8.50+5438106d8",
|
32
|
+
"@toptal/picasso-utils": "1.0.4-alpha-feature-tailwind-w21-5438106d8.50+5438106d8",
|
33
33
|
"ap-style-title-case": "^1.1.2",
|
34
34
|
"classnames": "^2.5.1"
|
35
35
|
},
|
@@ -47,14 +47,14 @@
|
|
47
47
|
".": "./dist-package/src/index.js"
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
|
-
"@toptal/picasso-provider": "4.2.2-alpha-feature-tailwind-w21-
|
51
|
-
"@toptal/picasso-tailwind-merge": "1.1.1-alpha-feature-tailwind-w21-
|
52
|
-
"@toptal/picasso-test-utils": "1.1.2-alpha-feature-tailwind-w21-
|
50
|
+
"@toptal/picasso-provider": "4.2.2-alpha-feature-tailwind-w21-5438106d8.58+5438106d8",
|
51
|
+
"@toptal/picasso-tailwind-merge": "1.1.1-alpha-feature-tailwind-w21-5438106d8.4269+5438106d8",
|
52
|
+
"@toptal/picasso-test-utils": "1.1.2-alpha-feature-tailwind-w21-5438106d8.50+5438106d8"
|
53
53
|
},
|
54
54
|
"files": [
|
55
55
|
"dist-package/**",
|
56
56
|
"!dist-package/tsconfig.tsbuildinfo",
|
57
57
|
"src"
|
58
58
|
],
|
59
|
-
"gitHead": "
|
59
|
+
"gitHead": "5438106d866ac55337e99db14c41fa58a140abce"
|
60
60
|
}
|
package/src/Tabs/Tabs.tsx
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
import type { ReactNode } from 'react'
|
1
|
+
import type { ReactNode, ForwardedRef } from 'react'
|
2
2
|
import React, { forwardRef, useMemo } from 'react'
|
3
3
|
import { Tabs as MUITabs } from '@mui/base/Tabs'
|
4
4
|
import { TabsList } from '@mui/base/TabsList'
|
5
5
|
import type { BaseProps } from '@toptal/picasso-shared'
|
6
6
|
import { twJoin, twMerge } from '@toptal/picasso-tailwind-merge'
|
7
7
|
|
8
|
-
type
|
8
|
+
export type TabsValueType = string | number | null
|
9
9
|
|
10
|
-
export interface Props extends BaseProps {
|
10
|
+
export interface Props<V extends TabsValueType> extends BaseProps {
|
11
11
|
/** Tabs content containing Tab components */
|
12
12
|
children: ReactNode
|
13
13
|
|
14
14
|
/** Callback fired when the value changes. */
|
15
|
-
onChange?: (event: React.ChangeEvent<{}> | null, value:
|
15
|
+
onChange?: (event: React.ChangeEvent<{}> | null, value: V) => void
|
16
16
|
|
17
17
|
/**
|
18
18
|
* The value of the currently selected Tab.
|
19
19
|
* If you don't want any selected Tab, you can set this property to null.
|
20
20
|
*/
|
21
|
-
value:
|
21
|
+
value: V
|
22
22
|
|
23
23
|
/** The tabs orientation (layout flow direction). */
|
24
24
|
orientation?: 'horizontal' | 'vertical'
|
@@ -52,7 +52,7 @@ const classesByOrientation = {
|
|
52
52
|
root: '',
|
53
53
|
scroller: indicatorClasses,
|
54
54
|
},
|
55
|
-
}
|
55
|
+
} as const
|
56
56
|
|
57
57
|
const classesByVariant = {
|
58
58
|
scrollable: {
|
@@ -63,68 +63,72 @@ const classesByVariant = {
|
|
63
63
|
root: '',
|
64
64
|
scroller: 'w-full overflow-hidden',
|
65
65
|
},
|
66
|
-
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
variant
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
classesByVariant[variant].scroller,
|
115
|
-
classesByOrientation[orientation].scroller,
|
116
|
-
'flex-auto inline-block relative whitespace-nowrap'
|
117
|
-
)}
|
66
|
+
} as const
|
67
|
+
|
68
|
+
const Tabs = forwardRef(
|
69
|
+
<V extends TabsValueType = TabsValueType>(
|
70
|
+
{
|
71
|
+
children,
|
72
|
+
orientation = 'horizontal',
|
73
|
+
onChange,
|
74
|
+
value,
|
75
|
+
variant = 'scrollable',
|
76
|
+
className,
|
77
|
+
...rest
|
78
|
+
}: Props<V>,
|
79
|
+
ref: ForwardedRef<HTMLDivElement>
|
80
|
+
) => {
|
81
|
+
const contextValue = useMemo(
|
82
|
+
() => ({
|
83
|
+
orientation,
|
84
|
+
variant,
|
85
|
+
}),
|
86
|
+
[orientation, variant]
|
87
|
+
)
|
88
|
+
|
89
|
+
const isVertical = orientation === 'vertical'
|
90
|
+
|
91
|
+
return (
|
92
|
+
<TabsContext.Provider value={contextValue}>
|
93
|
+
<MUITabs
|
94
|
+
{...rest}
|
95
|
+
slotProps={{
|
96
|
+
root: {
|
97
|
+
ref,
|
98
|
+
className: twMerge(
|
99
|
+
'relative min-h-0 flex overflow-hidden',
|
100
|
+
classesByOrientation[orientation].root,
|
101
|
+
classesByVariant[variant].root,
|
102
|
+
className
|
103
|
+
),
|
104
|
+
},
|
105
|
+
}}
|
106
|
+
onChange={
|
107
|
+
onChange as (
|
108
|
+
event: React.ChangeEvent<{}> | null,
|
109
|
+
value: TabsValueType
|
110
|
+
) => void
|
111
|
+
}
|
112
|
+
value={value}
|
113
|
+
orientation={orientation}
|
118
114
|
>
|
119
|
-
<
|
120
|
-
{
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
}
|
127
|
-
|
128
|
-
|
115
|
+
<div
|
116
|
+
className={twJoin(
|
117
|
+
classesByVariant[variant].scroller,
|
118
|
+
classesByOrientation[orientation].scroller,
|
119
|
+
'flex-auto inline-block relative whitespace-nowrap'
|
120
|
+
)}
|
121
|
+
>
|
122
|
+
<TabsList className={twJoin('flex', isVertical && 'flex-col')}>
|
123
|
+
{children}
|
124
|
+
</TabsList>
|
125
|
+
</div>
|
126
|
+
</MUITabs>
|
127
|
+
</TabsContext.Provider>
|
128
|
+
)
|
129
|
+
}
|
130
|
+
) as <V extends TabsValueType = TabsValueType>(
|
131
|
+
props: Props<V> & { ref?: ForwardedRef<HTMLDivElement> }
|
132
|
+
) => ReturnType<typeof MUITabs>
|
129
133
|
|
130
134
|
export default Tabs
|
package/src/Tabs/index.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { OmitInternalProps } from '@toptal/picasso-shared'
|
2
2
|
|
3
|
-
import type { Props } from './Tabs'
|
3
|
+
import type { Props, TabsValueType } from './Tabs'
|
4
4
|
|
5
5
|
export { default as Tabs } from './Tabs'
|
6
|
-
export type TabsProps = OmitInternalProps<Props
|
6
|
+
export type TabsProps = OmitInternalProps<Props<TabsValueType>>
|
7
|
+
export type { TabsValueType } from './Tabs'
|
@@ -5,7 +5,7 @@ import { SPACING_4 } from '@toptal/picasso-utils'
|
|
5
5
|
const Example = () => {
|
6
6
|
const [value, setValue] = React.useState(0)
|
7
7
|
|
8
|
-
const handleChange = (_: React.ChangeEvent<{}
|
8
|
+
const handleChange = (_: React.ChangeEvent<{}> | null, newValue: number) => {
|
9
9
|
setValue(newValue)
|
10
10
|
}
|
11
11
|
|
@@ -8,7 +8,7 @@ const TAB_COUNT = 2
|
|
8
8
|
const Example = () => {
|
9
9
|
const [value, setValue] = React.useState(0)
|
10
10
|
|
11
|
-
const handleChange = (_: React.ChangeEvent<{}
|
11
|
+
const handleChange = (_: React.ChangeEvent<{}> | null, newValue: number) => {
|
12
12
|
setValue(newValue)
|
13
13
|
}
|
14
14
|
|
@@ -8,7 +8,7 @@ const TAB_COUNT = 10
|
|
8
8
|
const Example = () => {
|
9
9
|
const [value, setValue] = React.useState(0)
|
10
10
|
|
11
|
-
const handleChange = (_: React.ChangeEvent<{}
|
11
|
+
const handleChange = (_: React.ChangeEvent<{}> | null, newValue: number) => {
|
12
12
|
setValue(newValue)
|
13
13
|
}
|
14
14
|
|
@@ -33,7 +33,7 @@ const TabsContent = ({ children }: { children: React.ReactNode }) => {
|
|
33
33
|
const Example = () => {
|
34
34
|
const [value, setValue] = React.useState(0)
|
35
35
|
|
36
|
-
const handleChange = (_: React.ChangeEvent<{}
|
36
|
+
const handleChange = (_: React.ChangeEvent<{}> | null, newValue: number) => {
|
37
37
|
setValue(newValue)
|
38
38
|
}
|
39
39
|
|
package/src/Tabs/test.tsx
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
/* eslint-disable react/no-array-index-key */
|
2
2
|
import React from 'react'
|
3
3
|
import { render, fireEvent } from '@testing-library/react'
|
4
|
-
import type { OmitInternalProps } from '@toptal/picasso-shared'
|
5
4
|
import { TestingPicasso } from '@toptal/picasso-test-utils'
|
6
5
|
|
7
6
|
import type { TabProps } from '../Tab'
|
8
|
-
import type { Props } from './Tabs'
|
7
|
+
import type { Props, TabsValueType } from './Tabs'
|
9
8
|
import { TabsCompound as Tabs } from '../TabsCompound'
|
10
9
|
|
11
|
-
const renderTabContent = (
|
10
|
+
const renderTabContent = (
|
11
|
+
tab: TabProps,
|
12
|
+
index: number,
|
13
|
+
value: TabsValueType
|
14
|
+
) => {
|
12
15
|
const isTabActive = index + 1 === value || tab.value === value
|
13
16
|
const testId = `tab-${index + 1}-content`
|
14
17
|
|
@@ -25,7 +28,7 @@ const renderTabContent = (tab: TabProps, index: number, value: any) => {
|
|
25
28
|
|
26
29
|
const renderTabs = (
|
27
30
|
tabs: TabProps[],
|
28
|
-
{ value, onChange, variant }:
|
31
|
+
{ value, onChange, variant }: Omit<Props<TabsValueType>, 'children'>,
|
29
32
|
orientation: 'horizontal' | 'vertical' = 'horizontal'
|
30
33
|
) => {
|
31
34
|
return render(
|