@@ -16,7 +16,6 @@ import {filterDOMProps} from '@react-aria/utils';
1616import { FlexProps } from '@react-types/layout' ;
1717import React , { forwardRef } from 'react' ;
1818import styles from './flex-gap.css' ;
19- import { useIsSSR } from '@react-aria/ssr' ;
2019
2120const flexStyleProps : StyleHandlers = {
2221 direction : [ 'flexDirection' , passthroughStyle ] ,
@@ -36,32 +35,7 @@ function Flex(props: FlexProps, ref: DOMRef<HTMLDivElement>) {
3635 let { styleProps} = useStyleProps ( otherProps ) ;
3736 let { styleProps : flexStyle } = useStyleProps ( otherProps , flexStyleProps ) ;
3837 let domRef = useDOMRef ( ref ) ;
39- let isSSR = useIsSSR ( ) ;
4038
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.
6539 let style = {
6640 ...styleProps . style ,
6741 ...flexStyle . style
@@ -113,39 +87,6 @@ function flexWrapValue(value) {
11387 return value ;
11488}
11589
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-
14990/**
15091 * A layout container using flexbox. Provides Spectrum dimension values, and supports the gap
15192 * property to define consistent spacing between items.
0 commit comments