|
1 | | -import { type CSSProperties, type Dispatch, type JSX, type SetStateAction, useEffect, useRef, useState } from 'react' |
| 1 | +import type React from 'react' |
| 2 | +import { useEffect, useRef, useState } from 'react' |
2 | 3 | import { Arrow, type ArrowProps, defaultArrowProps, getArrowPosition } from './arrow' |
3 | 4 | import type { FadeDirection, Props, ScrollDirection } from './types' |
4 | 5 |
|
5 | 6 | const supportsScrollTimeline = 'scrollTimeline' in document.documentElement.style |
6 | 7 |
|
7 | | -const wrapperStyles: CSSProperties = { |
| 8 | +const wrapperStyles: React.CSSProperties = { |
8 | 9 | position: 'relative', |
9 | 10 | } |
10 | 11 |
|
11 | | -const overflowStyles = (direction: ScrollDirection): CSSProperties => ({ |
| 12 | +const overflowStyles = (direction: ScrollDirection): React.CSSProperties => ({ |
12 | 13 | display: 'flex', |
13 | 14 | overflow: 'auto', |
14 | 15 | height: direction === 'vertical' ? '100%' : 'auto', |
15 | 16 | scrollTimelineName: '--indicate-scroll-element', |
16 | 17 | scrollTimelineAxis: direction === 'horizontal' ? 'x' : 'y', |
17 | 18 | }) |
18 | 19 |
|
19 | | -const fadeStyles = (direction: FadeDirection, horizontal: boolean, color: string): CSSProperties => ({ |
| 20 | +const fadeStyles = (direction: FadeDirection, horizontal: boolean, color: string): React.CSSProperties => ({ |
20 | 21 | display: 'flex', |
21 | 22 | position: 'absolute', |
22 | 23 | outline: 'none', |
@@ -74,7 +75,7 @@ function checkOverflow( |
74 | 75 | element: HTMLDivElement, |
75 | 76 | direction: ScrollDirection, |
76 | 77 | hasOverflow: boolean, |
77 | | - setHasOverflow: Dispatch<SetStateAction<boolean>>, |
| 78 | + setHasOverflow: React.Dispatch<React.SetStateAction<boolean>>, |
78 | 79 | ) { |
79 | 80 | if (element) { |
80 | 81 | if (direction === 'horizontal') { |
@@ -102,7 +103,7 @@ function getUserNodes(element: HTMLDivElement) { |
102 | 103 | return nodes |
103 | 104 | } |
104 | 105 |
|
105 | | -function Fallback<T extends keyof JSX.IntrinsicElements = 'div'>({ |
| 106 | +function Fallback<T extends keyof React.JSX.IntrinsicElements = 'div'>({ |
106 | 107 | children, |
107 | 108 | overflowStyle, |
108 | 109 | style, |
@@ -134,7 +135,7 @@ function Fade({ |
134 | 135 | arrow, |
135 | 136 | }: { |
136 | 137 | direction: FadeDirection |
137 | | - style?: CSSProperties |
| 138 | + style?: React.CSSProperties |
138 | 139 | color: string |
139 | 140 | arrow: ArrowProps | boolean |
140 | 141 | }) { |
@@ -165,7 +166,7 @@ function Fade({ |
165 | 166 | ) |
166 | 167 | } |
167 | 168 |
|
168 | | -export function Scroll<T extends keyof JSX.IntrinsicElements = 'div'>({ |
| 169 | +export function Scroll<T extends keyof React.JSX.IntrinsicElements = 'div'>({ |
169 | 170 | direction = 'horizontal', |
170 | 171 | color = '#FFF', |
171 | 172 | style = {}, |
@@ -201,7 +202,7 @@ export function Scroll<T extends keyof JSX.IntrinsicElements = 'div'>({ |
201 | 202 | observer.observe(element, { childList: true, subtree: true }) |
202 | 203 |
|
203 | 204 | // Observe if any of the children change their size. |
204 | | - if (userNodes.length) { |
| 205 | + if (userNodes.length > 0) { |
205 | 206 | for (const node of userNodes) { |
206 | 207 | resizeObserver.observe(node) |
207 | 208 | } |
|
0 commit comments