@@ -17,18 +17,12 @@ interface Props {
17
17
type TDisclosureGroup = {
18
18
id : string ;
19
19
label : string | React . ReactNode ;
20
- } & (
21
- | {
22
- tabs ?: {
23
- id : string ;
24
- label : string | React . ReactNode ;
25
- body ?: React . ReactNode ;
26
- } [ ] ;
27
- }
28
- | {
29
- body ?: React . ReactNode ;
30
- }
31
- ) ;
20
+ tabs ?: {
21
+ id : string ;
22
+ label ?: string | React . ReactNode ;
23
+ body ?: React . ReactNode ;
24
+ } [ ] ;
25
+ } ;
32
26
33
27
const DisclosureGroupStateContext = createContext < DisclosureGroupState | null > ( null ) ;
34
28
@@ -67,7 +61,7 @@ function DisclosureItem(props: { group: TDisclosureGroup; icon?: React.ReactNode
67
61
68
62
const panelRef = useRef < HTMLDivElement | null > ( null ) ;
69
63
const triggerRef = useRef < HTMLButtonElement | null > ( null ) ;
70
- const isDisabled = groupState ?. isDisabled || ( 'tabs' in group && ! group . tabs ?. length ) || false ;
64
+ const isDisabled = groupState ?. isDisabled || ! group . tabs ?. length || false ;
71
65
const { buttonProps : triggerProps , panelProps } = useDisclosure (
72
66
{
73
67
...props ,
@@ -80,19 +74,9 @@ function DisclosureItem(props: { group: TDisclosureGroup; icon?: React.ReactNode
80
74
const { buttonProps } = useButton ( triggerProps , triggerRef ) ;
81
75
const { isFocusVisible, focusProps } = useFocusRing ( ) ;
82
76
83
- const defaultTab =
84
- 'tabs' in group && group . tabs ?. [ 0 ]
85
- ? ( group . tabs [ 0 ] ?. id ?? '' )
86
- : 'body' in group
87
- ? 'body'
88
- : '' ;
77
+ const defaultTab = group . tabs ?. [ 0 ] ?. id || '' ;
89
78
const [ selectedTabKey , setSelectedTabKey ] = useState ( defaultTab ) ;
90
- const selectedTab =
91
- 'tabs' in group
92
- ? group . tabs ?. find ( ( tab ) => tab . id === selectedTabKey )
93
- : 'body' in group
94
- ? { id : 'body' , body : group . body }
95
- : null ;
79
+ const selectedTab = group . tabs ?. find ( ( tab ) => tab . id === selectedTabKey ) ;
96
80
97
81
return (
98
82
< div className = "openapi-disclosure-group" aria-expanded = { state . isExpanded } >
@@ -119,7 +103,7 @@ function DisclosureItem(props: { group: TDisclosureGroup; icon?: React.ReactNode
119
103
120
104
{ group . label }
121
105
</ button >
122
- { 'tabs' in group && group . tabs ? (
106
+ { group . tabs ? (
123
107
< div className = "openapi-disclosure-group-mediatype" >
124
108
{ group . tabs ?. length > 1 ? (
125
109
< select
0 commit comments