1- import React , {
2- Fragment ,
3- useCallback ,
4- useContext ,
5- useEffect ,
6- useMemo ,
7- useRef ,
8- useState ,
9- } from 'react' ;
1+ import * as React from 'react' ;
102
113import { useUniqId } from '@gravity-ui/uikit' ;
124import debounce from 'lodash/debounce' ;
@@ -93,19 +85,19 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
9385 initialIndex = 0 ,
9486 } = props ;
9587
96- const { isServer} = useContext ( SSRContext ) ;
97- const isMobile = useContext ( MobileContext ) ;
98- const [ breakpoint , setBreakpoint ] = useState < number > ( BREAKPOINTS . xl ) ;
88+ const { isServer} = React . useContext ( SSRContext ) ;
89+ const isMobile = React . useContext ( MobileContext ) ;
90+ const [ breakpoint , setBreakpoint ] = React . useState < number > ( BREAKPOINTS . xl ) ;
9991 const sliderId = useUniqId ( ) ;
100- const disclosedChildren = useMemo < React . ReactElement [ ] > (
92+ const disclosedChildren = React . useMemo < React . ReactElement [ ] > (
10193 ( ) => discloseAllNestedChildren ( children as React . ReactElement [ ] , sliderId ) ,
10294 [ children , sliderId ] ,
10395 ) ;
10496 const childrenCount = disclosedChildren . length ;
10597 const isAutoplayEnabled = autoplaySpeed !== undefined && autoplaySpeed > 0 ;
106- const isUserInteractionRef = useRef ( false ) ;
98+ const isUserInteractionRef = React . useRef ( false ) ;
10799
108- const [ slidesToShow ] = useState < SliderBreakpointParams > (
100+ const [ slidesToShow ] = React . useState < SliderBreakpointParams > (
109101 getSlidesToShowWithDefaults ( {
110102 contentLength : childrenCount ,
111103 breakpoints : props . slidesToShow ,
@@ -118,11 +110,11 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
118110 const slidesToShowCount = getSlidesToShowCount ( slidesToShow ) ;
119111 const slidesCountByBreakpoint = getSlidesCountByBreakpoint ( breakpoint , slidesToShow ) ;
120112
121- const [ currentIndex , setCurrentIndex ] = useState < number > ( initialIndex ) ;
122- const [ childStyles , setChildStyles ] = useState < Object > ( { } ) ;
123- const [ slider , setSlider ] = useState < SlickSlider > ( ) ;
124- const prevIndexRef = useRef < number > ( 0 ) ;
125- const autoplayTimeId = useRef < Timeout > ( ) ;
113+ const [ currentIndex , setCurrentIndex ] = React . useState < number > ( initialIndex ) ;
114+ const [ childStyles , setChildStyles ] = React . useState < Object > ( { } ) ;
115+ const [ slider , setSlider ] = React . useState < SlickSlider > ( ) ;
116+ const prevIndexRef = React . useRef < number > ( 0 ) ;
117+ const autoplayTimeId = React . useRef < Timeout > ( ) ;
126118 const { hasFocus, unsetFocus} = useFocus ( slider ?. innerSlider ?. list ) ;
127119
128120 const asUserInteraction =
@@ -133,7 +125,7 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
133125 } ;
134126
135127 // eslint-disable-next-line react-hooks/exhaustive-deps
136- const onResize = useCallback (
128+ const onResize = React . useCallback (
137129 debounce ( ( ) => {
138130 if ( ! slider ) {
139131 return ;
@@ -151,7 +143,7 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
151143 [ slider , breakpoint ] ,
152144 ) ;
153145
154- const scrollLastSlide = useCallback (
146+ const scrollLastSlide = React . useCallback (
155147 ( current : number ) => {
156148 const lastSlide = childrenCount - slidesToShowCount ;
157149
@@ -173,15 +165,15 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
173165 [ autoplaySpeed , childrenCount , isAutoplayEnabled , slider , slidesToShowCount ] ,
174166 ) ;
175167
176- useEffect ( ( ) => {
168+ React . useEffect ( ( ) => {
177169 if ( hasFocus && autoplayTimeId . current ) {
178170 clearTimeout ( autoplayTimeId . current ) ;
179171 } else {
180172 scrollLastSlide ( currentIndex ) ;
181173 }
182174 } , [ currentIndex , hasFocus , scrollLastSlide ] ) ;
183175
184- useEffect ( ( ) => {
176+ React . useEffect ( ( ) => {
185177 onResize ( ) ;
186178
187179 window . addEventListener ( 'resize' , onResize , { passive : true } ) ;
@@ -205,7 +197,7 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
205197 }
206198 } ;
207199
208- const onBeforeChange = useCallback (
200+ const onBeforeChange = React . useCallback (
209201 ( current : number , next : number ) => {
210202 if ( handleBeforeChange ) {
211203 handleBeforeChange ( current , next ) ;
@@ -218,7 +210,7 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
218210 [ handleBeforeChange ] ,
219211 ) ;
220212
221- const onAfterChange = useCallback (
213+ const onAfterChange = React . useCallback (
222214 ( current : number ) => {
223215 if ( handleAfterChange ) {
224216 handleAfterChange ( current ) ;
@@ -289,7 +281,7 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
289281 const renderAccessibleBar = ( index : number ) => {
290282 return (
291283 // To have this key differ from keys used in renderDot function, added `-accessible-bar` part
292- < Fragment key = { `${ index } -accessible-bar` } >
284+ < React . Fragment key = { `${ index } -accessible-bar` } >
293285 { slidesCountByBreakpoint > 0 && (
294286 < li
295287 className = { b ( 'accessible-bar' ) }
@@ -306,7 +298,7 @@ export const SliderOldBlock = (props: React.PropsWithChildren<SliderOldProps>) =
306298 { ...getRovingItemProps ( currentIndex + 1 ) }
307299 />
308300 ) }
309- </ Fragment >
301+ </ React . Fragment >
310302 ) ;
311303 } ;
312304
0 commit comments