@@ -16,7 +16,6 @@ import {filterDOMProps} from '@react-aria/utils';
16
16
import { FlexProps } from '@react-types/layout' ;
17
17
import React , { forwardRef } from 'react' ;
18
18
import styles from './flex-gap.css' ;
19
- import { useIsSSR } from '@react-aria/ssr' ;
20
19
21
20
const flexStyleProps : StyleHandlers = {
22
21
direction : [ 'flexDirection' , passthroughStyle ] ,
@@ -36,32 +35,7 @@ function Flex(props: FlexProps, ref: DOMRef<HTMLDivElement>) {
36
35
let { styleProps} = useStyleProps ( otherProps ) ;
37
36
let { styleProps : flexStyle } = useStyleProps ( otherProps , flexStyleProps ) ;
38
37
let domRef = useDOMRef ( ref ) ;
39
- let isSSR = useIsSSR ( ) ;
40
38
41
- // If a gap property is specified, and there is no native support or we're in SSR, use a shim.
42
- // Two divs are required for this: the outer one contains most style properties, and the inner
43
- // one is the flex container. Each item inside the flex container gets a margin around it based
44
- // on the gap, and the flex container has a negative margin to counteract this. The outer container
45
- // is necessary to allow nesting of flex containers with gaps, so that the inner CSS variable doesn't
46
- // override the outer one.
47
- if ( ( props . gap || props . rowGap || props . columnGap ) && ( isSSR || ! isFlexGapSupported ( ) ) ) {
48
- let style = {
49
- ...flexStyle . style ,
50
- '--column-gap' : props . columnGap != null ? responsiveDimensionValue ( props . columnGap , matchedBreakpoints ) : undefined ,
51
- '--row-gap' : props . rowGap != null ? responsiveDimensionValue ( props . rowGap , matchedBreakpoints ) : undefined ,
52
- '--gap' : props . gap != null ? responsiveDimensionValue ( props . gap , matchedBreakpoints ) : undefined
53
- } ;
54
-
55
- return (
56
- < div { ...filterDOMProps ( otherProps ) } { ...styleProps } className = { classNames ( styles , 'flex-container' , styleProps . className ) } ref = { domRef } >
57
- < div className = { classNames ( styles , 'flex' , 'flex-gap' ) } style = { style } >
58
- { children }
59
- </ div >
60
- </ div >
61
- ) ;
62
- }
63
-
64
- // If no gaps, or native support exists, then we only need to render a single div.
65
39
let style = {
66
40
...styleProps . style ,
67
41
...flexStyle . style
@@ -113,39 +87,6 @@ function flexWrapValue(value) {
113
87
return value ;
114
88
}
115
89
116
-
117
- // Original licensing for the following method can be found in the
118
- // NOTICE file in the root directory of this source tree.
119
- // See https://github.com/Modernizr/Modernizr/blob/7efb9d0edd66815fb115fdce95fabaf019ce8db5/feature-detects/css/flexgap.js
120
-
121
- let _isFlexGapSupported = null ;
122
- function isFlexGapSupported ( ) {
123
- if ( _isFlexGapSupported != null ) {
124
- return _isFlexGapSupported ;
125
- }
126
-
127
- if ( typeof document === 'undefined' ) {
128
- return false ;
129
- }
130
-
131
- // create flex container with row-gap set
132
- var flex = document . createElement ( 'div' ) ;
133
- flex . style . display = 'flex' ;
134
- flex . style . flexDirection = 'column' ;
135
- flex . style . rowGap = '1px' ;
136
-
137
- // create two, elements inside it
138
- flex . appendChild ( document . createElement ( 'div' ) ) ;
139
- flex . appendChild ( document . createElement ( 'div' ) ) ;
140
-
141
- // append to the DOM (needed to obtain scrollHeight)
142
- document . body . appendChild ( flex ) ;
143
- _isFlexGapSupported = flex . scrollHeight === 1 ; // flex container should be 1px high from the row-gap
144
- flex . parentNode . removeChild ( flex ) ;
145
-
146
- return _isFlexGapSupported ;
147
- }
148
-
149
90
/**
150
91
* A layout container using flexbox. Provides Spectrum dimension values, and supports the gap
151
92
* property to define consistent spacing between items.
0 commit comments