@@ -17,28 +17,23 @@ import merge from 'deepmerge'
17
17
const createNestedLinks = (
18
18
children : ReactNode ,
19
19
depth : number = 0
20
- ) : ReactNode [ ] => {
21
- const links = React . Children . toArray ( children ) . reduce (
22
- ( acc : ReactNode [ ] , child ) => {
23
- if ( ! React . isValidElement ( child ) ) {
24
- return acc
25
- }
26
- const type : string = child . props && child . props . mdxType
27
- if ( ! child . props || ! child . props . children ) return acc
28
- if ( type === 'a' ) return [ ...acc , child ]
29
- if ( depth > 0 && type === 'ul' ) {
30
- const last = acc [ acc . length - 1 ]
31
- acc [ acc . length - 1 ] = React . cloneElement ( last as ReactElement , {
32
- links : createNestedLinks ( child . props . children ) ,
33
- } )
34
- return acc
35
- }
36
- return [ ...acc , ...createNestedLinks ( child . props . children , depth + 1 ) ]
37
- } ,
38
- [ ]
39
- ) as ReactNode [ ]
40
- return links
41
- }
20
+ ) : ReactNode [ ] =>
21
+ React . Children . toArray ( children ) . reduce ( ( acc : ReactNode [ ] , child ) => {
22
+ if ( ! React . isValidElement ( child ) ) {
23
+ return acc
24
+ }
25
+ const type : string = child . props && child . props . mdxType
26
+ if ( ! child . props || ! child . props . children ) return acc
27
+ if ( type === 'a' ) return [ ...acc , child ]
28
+ if ( depth > 0 && type === 'ul' ) {
29
+ const last = acc [ acc . length - 1 ]
30
+ acc [ acc . length - 1 ] = React . cloneElement ( last as ReactElement , {
31
+ links : createNestedLinks ( child . props . children ) ,
32
+ } )
33
+ return acc
34
+ }
35
+ return [ ...acc , ...createNestedLinks ( child . props . children , depth + 1 ) ]
36
+ } , [ ] )
42
37
43
38
const flattenLinks = ( children : ReactNode ) : ReactNode [ ] =>
44
39
React . Children . toArray ( children ) . reduce ( ( acc : ReactNode [ ] , child ) => {
@@ -53,7 +48,7 @@ const flattenLinks = (children: ReactNode): ReactNode[] =>
53
48
] )
54
49
}
55
50
return acc
56
- } , [ ] ) as ReactNode [ ]
51
+ } , [ ] )
57
52
58
53
const Overlay : FunctionComponent < {
59
54
onClick ?: EventHandler < MouseEvent < HTMLDivElement > >
@@ -121,24 +116,22 @@ export const Sidenav = forwardRef<
121
116
< div
122
117
{ ...props }
123
118
ref = { ref }
124
- sx = {
125
- {
126
- position : [ 'fixed' , 'sticky' ] ,
127
- top : 0 ,
128
- left : 0 ,
129
- bottom : [ 0 , 'auto' ] ,
130
- zIndex : 1 ,
131
- minWidth : 0 ,
132
- width : 256 ,
133
- maxHeight : [ '100vh' , 'none' ] ,
134
- overflowX : 'visible' ,
135
- overflowY : 'auto' ,
136
- WebkitOverflowScrolling : 'touch' ,
137
- transition : 'transform .2s ease-out' ,
138
- transform : [ open ? 'translateX(0)' : 'translate(-100%)' , 'none' ] ,
139
- bg : [ 'background' , 'transparent' ] ,
140
- } as SxStyleProp
141
- }
119
+ sx = { {
120
+ position : [ 'fixed' , 'sticky' ] ,
121
+ top : 0 ,
122
+ left : 0 ,
123
+ bottom : [ 0 , 'auto' ] ,
124
+ zIndex : 1 ,
125
+ minWidth : 0 ,
126
+ width : 256 ,
127
+ maxHeight : [ '100vh' , 'none' ] ,
128
+ overflowX : 'visible' ,
129
+ overflowY : 'auto' ,
130
+ transition : 'transform .2s ease-out' ,
131
+ transform : [ open ? 'translateX(0)' : 'translate(-100%)' , 'none' ] ,
132
+ bg : [ 'background' , 'transparent' ] ,
133
+ ...{ WebkitOverflowScrolling : 'touch' } ,
134
+ } }
142
135
/>
143
136
</ MDXProvider >
144
137
</ ThemeProvider >
@@ -259,24 +252,22 @@ export const AccordionNav = forwardRef<
259
252
< div
260
253
ref = { ref }
261
254
className = { className }
262
- sx = {
263
- {
264
- position : [ 'fixed' , 'sticky' ] ,
265
- top : 0 ,
266
- left : 0 ,
267
- bottom : [ 0 , 'auto' ] ,
268
- zIndex : 1 ,
269
- minWidth : 0 ,
270
- width : 256 ,
271
- maxHeight : [ '100vh' , 'none' ] ,
272
- overflowX : 'visible' ,
273
- overflowY : 'auto' ,
274
- WebkitOverflowScrolling : 'touch' ,
275
- transition : 'transform .2s ease-out' ,
276
- transform : [ open ? 'translateX(0)' : 'translate(-100%)' , 'none' ] ,
277
- bg : [ 'background' , 'transparent' ] ,
278
- } as SxStyleProp
279
- } >
255
+ sx = { {
256
+ position : [ 'fixed' , 'sticky' ] ,
257
+ top : 0 ,
258
+ left : 0 ,
259
+ bottom : [ 0 , 'auto' ] ,
260
+ zIndex : 1 ,
261
+ minWidth : 0 ,
262
+ width : 256 ,
263
+ maxHeight : [ '100vh' , 'none' ] ,
264
+ overflowX : 'visible' ,
265
+ overflowY : 'auto' ,
266
+ transition : 'transform .2s ease-out' ,
267
+ transform : [ open ? 'translateX(0)' : 'translate(-100%)' , 'none' ] ,
268
+ bg : [ 'background' , 'transparent' ] ,
269
+ ...{ WebkitOverflowScrolling : 'touch' } ,
270
+ } } >
280
271
< ul
281
272
sx = { {
282
273
listStyle : 'none' ,
0 commit comments