1
- import { RefObject , forwardRef , useRef , ReactNode } from 'react' ;
1
+ import { RefObject , forwardRef , useRef , ReactNode , useMemo } from 'react' ;
2
2
import { useFocusableRef } from '@react-spectrum/utils' ;
3
3
import { FocusableRef } from '@react-types/shared' ;
4
4
import { useSliderState } from 'react-stately' ;
@@ -7,7 +7,6 @@ import { useSlider, useNumberFormatter } from 'react-aria';
7
7
import { extractStyles , OUTER_STYLES , tasty } from '../../../tasty' ;
8
8
import { useFieldProps , useFormProps , wrapWithField } from '../../form' ;
9
9
import { Text } from '../../content/Text' ;
10
- import { mergeProps } from '../../../utils/react' ;
11
10
12
11
import { SliderControlsElement , SliderElement } from './elements' ;
13
12
@@ -186,22 +185,17 @@ function SliderBase(
186
185
</ LabelValueElement >
187
186
) ;
188
187
188
+ const mods = useMemo (
189
+ ( ) => ( {
190
+ 'side-label' : labelPosition === 'side' ,
191
+ horizontal : orientation === 'horizontal' ,
192
+ } ) ,
193
+ [ labelPosition , orientation ] ,
194
+ ) ;
195
+
189
196
const sliderField = (
190
- < SliderElement
191
- ref = { domRef }
192
- { ...groupProps }
193
- mods = { {
194
- 'side-label' : labelPosition === 'side' ,
195
- horizontal : orientation === 'horizontal' ,
196
- } }
197
- >
198
- < SliderControlsElement
199
- { ...trackProps }
200
- ref = { trackRef }
201
- mods = { {
202
- horizontal : orientation === 'horizontal' ,
203
- } }
204
- >
197
+ < SliderElement ref = { domRef } { ...groupProps } mods = { mods } >
198
+ < SliderControlsElement { ...trackProps } ref = { trackRef } mods = { mods } >
205
199
{ children ( {
206
200
trackRef,
207
201
inputRef,
@@ -213,18 +207,13 @@ function SliderBase(
213
207
214
208
styles = extractStyles ( otherProps , OUTER_STYLES , styles ) ;
215
209
216
- return wrapWithField (
217
- sliderField ,
218
- ref ,
219
- mergeProps (
220
- {
221
- ...props ,
222
- styles,
223
- extra,
224
- } ,
225
- { labelProps } ,
226
- ) ,
227
- ) ;
210
+ return wrapWithField ( sliderField , ref , {
211
+ ...props ,
212
+ children : undefined ,
213
+ styles,
214
+ extra,
215
+ labelProps,
216
+ } ) ;
228
217
}
229
218
230
219
const _SliderBase = forwardRef ( SliderBase ) ;
0 commit comments