diff --git a/.eslintrc.json b/.eslintrc.json index cee1b80913..6feaf7d986 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,7 +16,7 @@ "project": ["./tsconfig.json"] }, "env": { "browser": true, "node": true, "jest/globals": true }, - "plugins": ["react", "jest"], + "plugins": ["react", "jest", "simple-import-sort"], "ignorePatterns": [ "packages/react-native-gesture-handler/lib/**/*", "**/*.config.js", @@ -88,6 +88,7 @@ "curly": "error", "spaced-comment": "error", "no-alert": "warn", - "sort-imports": "error" + "simple-import-sort/imports": "error", + "simple-import-sort/exports": "error" } } diff --git a/apps/basic-example/src/App.tsx b/apps/basic-example/src/App.tsx index cf47d67f49..d22c7a5017 100644 --- a/apps/basic-example/src/App.tsx +++ b/apps/basic-example/src/App.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; import { Platform, SafeAreaView } from 'react-native'; -import ContentsButton from './ContentsButton'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; + +import ContentsButton from './ContentsButton'; import NativeDetector from './NativeDetector'; import Navigator from './Navigator'; import RuntimeDecoration from './RuntimeDecoration'; diff --git a/apps/basic-example/src/ContentsButton.tsx b/apps/basic-example/src/ContentsButton.tsx index f32bd408dd..67d8878227 100644 --- a/apps/basic-example/src/ContentsButton.tsx +++ b/apps/basic-example/src/ContentsButton.tsx @@ -1,10 +1,10 @@ +import React from 'react'; +import { SafeAreaView, StyleSheet, Text, View } from 'react-native'; import { GestureHandlerRootView, RectButton, ScrollView, } from 'react-native-gesture-handler'; -import { SafeAreaView, StyleSheet, Text, View } from 'react-native'; -import React from 'react'; export default function ComplexUI() { return ( diff --git a/apps/basic-example/src/Navigator.tsx b/apps/basic-example/src/Navigator.tsx index adeff35183..3bdba01e3e 100644 --- a/apps/basic-example/src/Navigator.tsx +++ b/apps/basic-example/src/Navigator.tsx @@ -1,5 +1,5 @@ -import { BackHandler, Pressable, Text, View } from 'react-native'; import React, { useEffect, useState } from 'react'; +import { BackHandler, Pressable, Text, View } from 'react-native'; export interface RouteInfo { component: React.ComponentType; diff --git a/apps/basic-example/src/RuntimeDecoration.tsx b/apps/basic-example/src/RuntimeDecoration.tsx index 14290c13f4..0cba1c8e2a 100644 --- a/apps/basic-example/src/RuntimeDecoration.tsx +++ b/apps/basic-example/src/RuntimeDecoration.tsx @@ -1,13 +1,14 @@ import * as React from 'react'; +import { useState } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { runOnJS, useAnimatedStyle, useSharedValue, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { StyleSheet, Text, View } from 'react-native'; + import { COLORS } from './colors'; -import { useState } from 'react'; export function RuntimeChecker({ runGestureOnJS, diff --git a/apps/basic-example/src/Text.tsx b/apps/basic-example/src/Text.tsx index 683b853876..f6c7c191bb 100644 --- a/apps/basic-example/src/Text.tsx +++ b/apps/basic-example/src/Text.tsx @@ -1,12 +1,13 @@ import * as React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { Gesture, GestureDetector, InterceptingGestureDetector, - VirtualGestureDetector, useTapGesture, + VirtualGestureDetector, } from 'react-native-gesture-handler'; -import { StyleSheet, Text, View } from 'react-native'; + import { COLORS } from './colors'; function NativeDetectorExample() { diff --git a/apps/common-app/src/ListWithHeader/Header.tsx b/apps/common-app/src/ListWithHeader/Header.tsx index 40217f16d3..a2861da061 100644 --- a/apps/common-app/src/ListWithHeader/Header.tsx +++ b/apps/common-app/src/ListWithHeader/Header.tsx @@ -1,3 +1,6 @@ +import React, { useEffect } from 'react'; +import { Platform, StyleSheet } from 'react-native'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { Easing, interpolate, @@ -8,15 +11,10 @@ import Animated, { useSharedValue, withTiming, } from 'react-native-reanimated'; -import { Platform, StyleSheet } from 'react-native'; -import React, { useEffect } from 'react'; -import { COLORS } from '../common'; -import type { SharedValue } from 'react-native-reanimated'; -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const SIGNET = require('./signet.png'); -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const TEXT = require('./text.png'); +import { COLORS } from '../common'; +import SIGNET from './signet.png'; +import TEXT from './text.png'; export const HEADER_HEIGHT = Platform.OS === 'web' || Platform.OS === 'macos' ? 64 : 192; diff --git a/apps/common-app/src/ListWithHeader/ListWithHeader.tsx b/apps/common-app/src/ListWithHeader/ListWithHeader.tsx index 1ad87ef807..385a8efc3c 100644 --- a/apps/common-app/src/ListWithHeader/ListWithHeader.tsx +++ b/apps/common-app/src/ListWithHeader/ListWithHeader.tsx @@ -1,3 +1,9 @@ +import React, { useEffect } from 'react'; +import type { ScrollViewProps, SectionListProps } from 'react-native'; +import { Platform, SectionList, StyleSheet } from 'react-native'; +import type { GestureType } from 'react-native-gesture-handler'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import type { AnimatedRef, SharedValue } from 'react-native-reanimated'; import Animated, { runOnJS, useAnimatedProps, @@ -8,13 +14,8 @@ import Animated, { useSharedValue, withSpring, } from 'react-native-reanimated'; -import type { AnimatedRef, SharedValue } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; + import Header, { HEADER_HEIGHT } from './Header'; -import { Platform, SectionList, StyleSheet } from 'react-native'; -import React, { useEffect } from 'react'; -import type { ScrollViewProps, SectionListProps } from 'react-native'; -import type { GestureType } from 'react-native-gesture-handler'; const IS_ANDROID = Platform.OS === 'android'; diff --git a/apps/common-app/src/ListWithHeader/index.ts b/apps/common-app/src/ListWithHeader/index.ts index ec20a9a229..b8a964412d 100644 --- a/apps/common-app/src/ListWithHeader/index.ts +++ b/apps/common-app/src/ListWithHeader/index.ts @@ -1,2 +1,2 @@ +export { COLLAPSED_HEADER_HEIGHT, HEADER_HEIGHT } from './Header'; export { ListWithHeader } from './ListWithHeader'; -export { HEADER_HEIGHT, COLLAPSED_HEADER_HEIGHT } from './Header'; diff --git a/apps/common-app/src/common.tsx b/apps/common-app/src/common.tsx index 29ee0e6f61..8cdc3e8d5d 100644 --- a/apps/common-app/src/common.tsx +++ b/apps/common-app/src/common.tsx @@ -1,10 +1,4 @@ -import Animated, { - Easing, - useAnimatedStyle, - useSharedValue, - withTiming, -} from 'react-native-reanimated'; -import type { Platform, StyleProp, ViewStyle } from 'react-native'; +import type { RefObject } from 'react'; import React, { useCallback, useEffect, @@ -12,8 +6,14 @@ import React, { useRef, useState, } from 'react'; +import type { Platform, StyleProp, ViewStyle } from 'react-native'; import { StyleSheet, Text, View } from 'react-native'; -import type { RefObject } from 'react'; +import Animated, { + Easing, + useAnimatedStyle, + useSharedValue, + withTiming, +} from 'react-native-reanimated'; export interface Example { name: string; diff --git a/apps/common-app/src/common_assets/AnimatedCameraView/AnimatedCameraView.tsx b/apps/common-app/src/common_assets/AnimatedCameraView/AnimatedCameraView.tsx index ff164f5b4d..908b09b36f 100644 --- a/apps/common-app/src/common_assets/AnimatedCameraView/AnimatedCameraView.tsx +++ b/apps/common-app/src/common_assets/AnimatedCameraView/AnimatedCameraView.tsx @@ -1,9 +1,9 @@ -import Animated, { useAnimatedProps } from 'react-native-reanimated'; -import type { AnimatedRef, SharedValue } from 'react-native-reanimated'; -import { Button, StyleSheet, Text, View } from 'react-native'; -import { CameraView, useCameraPermissions } from 'expo-camera'; import type { CameraViewProps } from 'expo-camera'; +import { CameraView, useCameraPermissions } from 'expo-camera'; import React from 'react'; +import { Button, StyleSheet, Text, View } from 'react-native'; +import type { AnimatedRef, SharedValue } from 'react-native-reanimated'; +import Animated, { useAnimatedProps } from 'react-native-reanimated'; const AnimatedCameraView = Animated.createAnimatedComponent(CameraView); diff --git a/apps/common-app/src/empty/index.tsx b/apps/common-app/src/empty/index.tsx index 3cf9895e97..900460d6a6 100644 --- a/apps/common-app/src/empty/index.tsx +++ b/apps/common-app/src/empty/index.tsx @@ -1,5 +1,5 @@ -import { StyleSheet, Text, View } from 'react-native'; import React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; export default function EmptyExample() { return ( diff --git a/apps/common-app/src/legacy/basic/bouncing/index.tsx b/apps/common-app/src/legacy/basic/bouncing/index.tsx index e8a74a0f10..9fe02e837e 100644 --- a/apps/common-app/src/legacy/basic/bouncing/index.tsx +++ b/apps/common-app/src/legacy/basic/bouncing/index.tsx @@ -1,17 +1,18 @@ +import type { PropsWithChildren } from 'react'; +import React, { Component } from 'react'; import { Animated, StyleSheet, View } from 'react-native'; -import { - PanGestureHandler, - RotationGestureHandler, - State, -} from 'react-native-gesture-handler'; import type { PanGestureHandlerGestureEvent, PanGestureHandlerStateChangeEvent, RotationGestureHandlerGestureEvent, RotationGestureHandlerStateChangeEvent, } from 'react-native-gesture-handler'; -import React, { Component } from 'react'; -import type { PropsWithChildren } from 'react'; +import { + PanGestureHandler, + RotationGestureHandler, + State, +} from 'react-native-gesture-handler'; + import { USE_NATIVE_DRIVER } from '../../../config'; class Snappable extends Component>> { diff --git a/apps/common-app/src/legacy/basic/draggable/index.tsx b/apps/common-app/src/legacy/basic/draggable/index.tsx index ead6b76bcf..95dc4b9ef0 100644 --- a/apps/common-app/src/legacy/basic/draggable/index.tsx +++ b/apps/common-app/src/legacy/basic/draggable/index.tsx @@ -1,15 +1,16 @@ +import React, { Component } from 'react'; +import type { StyleProp, ViewStyle } from 'react-native'; import { Animated, StyleSheet } from 'react-native'; +import type { + PanGestureHandlerGestureEvent, + PanGestureHandlerStateChangeEvent, +} from 'react-native-gesture-handler'; import { PanGestureHandler, ScrollView, State, } from 'react-native-gesture-handler'; -import type { - PanGestureHandlerGestureEvent, - PanGestureHandlerStateChangeEvent, -} from 'react-native-gesture-handler'; -import React, { Component } from 'react'; -import type { StyleProp, ViewStyle } from 'react-native'; + import { LoremIpsum } from '../../../common'; import { USE_NATIVE_DRIVER } from '../../../config'; diff --git a/apps/common-app/src/legacy/basic/fling/index.tsx b/apps/common-app/src/legacy/basic/fling/index.tsx index 2af6618b03..972746570b 100644 --- a/apps/common-app/src/legacy/basic/fling/index.tsx +++ b/apps/common-app/src/legacy/basic/fling/index.tsx @@ -1,16 +1,16 @@ +import React from 'react'; +import { StyleSheet, View } from 'react-native'; +import { + Directions, + Gesture, + GestureDetector, +} from 'react-native-gesture-handler'; import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { - Directions, - Gesture, - GestureDetector, -} from 'react-native-gesture-handler'; -import { StyleSheet, View } from 'react-native'; -import React from 'react'; export default function Example() { const position = useSharedValue(0); diff --git a/apps/common-app/src/legacy/basic/forcetouch/index.tsx b/apps/common-app/src/legacy/basic/forcetouch/index.tsx index 6f1421e18b..cffd720cc8 100644 --- a/apps/common-app/src/legacy/basic/forcetouch/index.tsx +++ b/apps/common-app/src/legacy/basic/forcetouch/index.tsx @@ -1,7 +1,8 @@ -import { Animated, StyleSheet, Text, View } from 'react-native'; -import { ForceTouchGestureHandler, State } from 'react-native-gesture-handler'; import React, { Component } from 'react'; +import { Animated, StyleSheet, Text, View } from 'react-native'; import type { ForceTouchGestureHandlerStateChangeEvent } from 'react-native-gesture-handler'; +import { ForceTouchGestureHandler, State } from 'react-native-gesture-handler'; + import { USE_NATIVE_DRIVER } from '../../../config'; export default class Example extends Component { diff --git a/apps/common-app/src/legacy/basic/multitap/index.tsx b/apps/common-app/src/legacy/basic/multitap/index.tsx index 4370c1b717..d5817fae96 100644 --- a/apps/common-app/src/legacy/basic/multitap/index.tsx +++ b/apps/common-app/src/legacy/basic/multitap/index.tsx @@ -1,15 +1,16 @@ +import React, { Component } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import type { + LongPressGestureHandlerStateChangeEvent, + TapGestureHandlerStateChangeEvent, +} from 'react-native-gesture-handler'; import { LongPressGestureHandler, ScrollView, State, TapGestureHandler, } from 'react-native-gesture-handler'; -import type { - LongPressGestureHandlerStateChangeEvent, - TapGestureHandlerStateChangeEvent, -} from 'react-native-gesture-handler'; -import React, { Component } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; + import { LoremIpsum } from '../../../common'; interface PressBoxProps { diff --git a/apps/common-app/src/legacy/basic/pagerAndDrawer/index.android.tsx b/apps/common-app/src/legacy/basic/pagerAndDrawer/index.android.tsx index c812066675..ad80c8a707 100644 --- a/apps/common-app/src/legacy/basic/pagerAndDrawer/index.android.tsx +++ b/apps/common-app/src/legacy/basic/pagerAndDrawer/index.android.tsx @@ -1,10 +1,10 @@ +import ViewPagerAndroid from '@react-native-community/viewpager'; +import React, { Component } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { - LegacyDrawerLayoutAndroid, legacy_createNativeWrapper, + LegacyDrawerLayoutAndroid, } from 'react-native-gesture-handler'; -import React, { Component } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; -import ViewPagerAndroid from '@react-native-community/viewpager'; const WrappedViewPagerAndroid = legacy_createNativeWrapper(ViewPagerAndroid, { disallowInterruption: true, diff --git a/apps/common-app/src/legacy/basic/panResponder/index.tsx b/apps/common-app/src/legacy/basic/panResponder/index.tsx index 685d3ee3c5..671f24c833 100644 --- a/apps/common-app/src/legacy/basic/panResponder/index.tsx +++ b/apps/common-app/src/legacy/basic/panResponder/index.tsx @@ -1,14 +1,15 @@ +import React, { Component } from 'react'; import type { GestureResponderEvent, GestureResponderHandlers, PanResponderGestureState, } from 'react-native'; import { I18nManager, PanResponder, StyleSheet, View } from 'react-native'; -import React, { Component } from 'react'; -import { DraggableBox } from '../draggable'; -import { LoremIpsum } from '../../../common'; import { ScrollView } from 'react-native-gesture-handler'; +import { LoremIpsum } from '../../../common'; +import { DraggableBox } from '../draggable'; + const CIRCLE_SIZE = 80; type CircleStyles = { diff --git a/apps/common-app/src/legacy/index.tsx b/apps/common-app/src/legacy/index.tsx index a388a970c1..f20a906037 100644 --- a/apps/common-app/src/legacy/index.tsx +++ b/apps/common-app/src/legacy/index.tsx @@ -1,29 +1,20 @@ -import { BottomSheet } from './showcase/bottomSheet'; -import BottomSheetNewApi from './v2_api/bottom_sheet'; +import type { ExamplesSection } from '../common'; +import EmptyExample from '../empty'; import BouncingBox from './basic/bouncing'; -import Calculator from './v2_api/calculator'; -import Camera from './v2_api/camera'; -import ChatHeads from './showcase/chatHeads'; -import ChatHeadsNewApi from './v2_api/chat_heads'; +import Draggable from './basic/draggable'; +import Fling from './basic/fling'; +import ForceTouch from './basic/forcetouch'; +import MultiTap from './basic/multitap'; +import PagerAndDrawer from './basic/pagerAndDrawer'; +import PanResponder from './basic/panResponder'; +import PanAndScroll from './recipes/panAndScroll'; +import { PinchableBox } from './recipes/scaleAndRotate'; import { ComboWithGHScroll } from './release_tests/combo'; import ContextMenu from './release_tests/contextMenu'; import DoubleDraggable from './release_tests/doubleDraggable'; import DoublePinchRotate from './release_tests/doubleScalePinchAndRotate'; -import DragNDrop from './v2_api/drag_n_drop'; -import Draggable from './basic/draggable'; -import EmptyExample from '../empty'; -import type { ExamplesSection } from '../common'; -import Fling from './basic/fling'; -import ForceTouch from './basic/forcetouch'; import GesturizedPressable from './release_tests/gesturizedPressable'; -import Hover from './v2_api/hover'; -import HoverableIcons from './v2_api/hoverable_icons'; -import LongPressExample from './simple/longPress'; -import MacosDraggable from './simple/draggable'; -import ManualExample from './simple/manual'; -import ManualGestures from './v2_api/manualGestures/index'; import MouseButtons from './release_tests/mouseButtons'; -import MultiTap from './basic/multitap'; import NestedButtons from './release_tests/nestedButtons'; import NestedFling from './release_tests/nestedFling'; import NestedGestureHandlerRootViewWithModal from './release_tests/nestedGHRootViewWithModal'; @@ -31,23 +22,32 @@ import NestedPressables from './release_tests/nestedPressables'; import NestedText from './release_tests/nestedText'; import NestedTouchables from './release_tests/nestedTouchables'; import OverflowParent from './release_tests/overflowParent'; -import Overlap from './v2_api/overlap'; -import PagerAndDrawer from './basic/pagerAndDrawer'; -import PanAndScroll from './recipes/panAndScroll'; -import PanResponder from './basic/panResponder'; -import { PinchableBox } from './recipes/scaleAndRotate'; import PointerType from './release_tests/pointerType'; -import Pressable from './v2_api/pressable'; import RectButtonBorders from './release_tests/rectButton'; -import SimpleFling from './simple/fling'; import StylusData from './release_tests/StylusData'; import SvgCompatibility from './release_tests/svg'; -import Tap from './simple/tap'; import { TouchablesIndex } from './release_tests/touchables'; -import Transformations from './v2_api/transformations'; import TwoFingerPan from './release_tests/twoFingerPan'; -import VelocityTest from './v2_api/velocityTest'; import WebStylesResetExample from './release_tests/webStylesReset'; +import { BottomSheet } from './showcase/bottomSheet'; +import ChatHeads from './showcase/chatHeads'; +import MacosDraggable from './simple/draggable'; +import SimpleFling from './simple/fling'; +import LongPressExample from './simple/longPress'; +import ManualExample from './simple/manual'; +import Tap from './simple/tap'; +import BottomSheetNewApi from './v2_api/bottom_sheet'; +import Calculator from './v2_api/calculator'; +import Camera from './v2_api/camera'; +import ChatHeadsNewApi from './v2_api/chat_heads'; +import DragNDrop from './v2_api/drag_n_drop'; +import Hover from './v2_api/hover'; +import HoverableIcons from './v2_api/hoverable_icons'; +import ManualGestures from './v2_api/manualGestures/index'; +import Overlap from './v2_api/overlap'; +import Pressable from './v2_api/pressable'; +import Transformations from './v2_api/transformations'; +import VelocityTest from './v2_api/velocityTest'; export const OLD_EXAMPLES: ExamplesSection[] = [ { sectionTitle: 'Empty', diff --git a/apps/common-app/src/legacy/recipes/panAndScroll/index.tsx b/apps/common-app/src/legacy/recipes/panAndScroll/index.tsx index b3425acd7d..3585c4af2f 100644 --- a/apps/common-app/src/legacy/recipes/panAndScroll/index.tsx +++ b/apps/common-app/src/legacy/recipes/panAndScroll/index.tsx @@ -1,15 +1,16 @@ +import React, { Component } from 'react'; import { Animated, Dimensions, StyleSheet } from 'react-native'; +import type { + PanGestureHandlerGestureEvent, + TapGestureHandlerStateChangeEvent, +} from 'react-native-gesture-handler'; import { LegacyScrollView, PanGestureHandler, State, TapGestureHandler, } from 'react-native-gesture-handler'; -import type { - PanGestureHandlerGestureEvent, - TapGestureHandlerStateChangeEvent, -} from 'react-native-gesture-handler'; -import React, { Component } from 'react'; + import { LoremIpsum } from '../../../common'; import { USE_NATIVE_DRIVER } from '../../../config'; diff --git a/apps/common-app/src/legacy/recipes/scaleAndRotate/index.tsx b/apps/common-app/src/legacy/recipes/scaleAndRotate/index.tsx index ac7792c8e4..500df65fb4 100644 --- a/apps/common-app/src/legacy/recipes/scaleAndRotate/index.tsx +++ b/apps/common-app/src/legacy/recipes/scaleAndRotate/index.tsx @@ -1,10 +1,5 @@ +import React from 'react'; import { Animated, Platform, StyleSheet } from 'react-native'; -import { - PanGestureHandler, - PinchGestureHandler, - RotationGestureHandler, - State, -} from 'react-native-gesture-handler'; import type { PanGestureHandlerGestureEvent, PanGestureHandlerStateChangeEvent, @@ -13,7 +8,13 @@ import type { RotationGestureHandlerGestureEvent, RotationGestureHandlerStateChangeEvent, } from 'react-native-gesture-handler'; -import React from 'react'; +import { + PanGestureHandler, + PinchGestureHandler, + RotationGestureHandler, + State, +} from 'react-native-gesture-handler'; + import { USE_NATIVE_DRIVER } from '../../../config'; export class PinchableBox extends React.Component { diff --git a/apps/common-app/src/legacy/release_tests/StylusData/index.tsx b/apps/common-app/src/legacy/release_tests/StylusData/index.tsx index 1e5a71a28d..f90af07438 100644 --- a/apps/common-app/src/legacy/release_tests/StylusData/index.tsx +++ b/apps/common-app/src/legacy/release_tests/StylusData/index.tsx @@ -1,14 +1,13 @@ +import React from 'react'; +import { Image, StyleSheet, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { Image, StyleSheet, View } from 'react-native'; -import React from 'react'; -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const GH = require('../../../common_assets/hoverable_icons/gh.png'); +import GH from '../../../common_assets/hoverable_icons/gh.png'; export default function StylusData() { const scaleFactor = useSharedValue(0); diff --git a/apps/common-app/src/legacy/release_tests/combo/InfoButton.tsx b/apps/common-app/src/legacy/release_tests/combo/InfoButton.tsx index 857543cde6..d6aab5df3e 100644 --- a/apps/common-app/src/legacy/release_tests/combo/InfoButton.tsx +++ b/apps/common-app/src/legacy/release_tests/combo/InfoButton.tsx @@ -1,7 +1,7 @@ +import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { BorderlessButton } from 'react-native-gesture-handler'; import type { BorderlessButtonProps } from 'react-native-gesture-handler'; -import React from 'react'; +import { BorderlessButton } from 'react-native-gesture-handler'; export const InfoButton = (props: BorderlessButtonProps & { name: string }) => ( void; diff --git a/apps/common-app/src/legacy/release_tests/contextMenu/index.tsx b/apps/common-app/src/legacy/release_tests/contextMenu/index.tsx index f6dbdd8dfa..d89ed1a007 100644 --- a/apps/common-app/src/legacy/release_tests/contextMenu/index.tsx +++ b/apps/common-app/src/legacy/release_tests/contextMenu/index.tsx @@ -1,10 +1,10 @@ +import React from 'react'; +import { StyleSheet, View } from 'react-native'; import { Gesture, GestureDetector, MouseButton, } from 'react-native-gesture-handler'; -import { StyleSheet, View } from 'react-native'; -import React from 'react'; export default function ContextMenuExample() { const p1 = Gesture.Pan().mouseButton(MouseButton.RIGHT); diff --git a/apps/common-app/src/legacy/release_tests/doubleDraggable/index.tsx b/apps/common-app/src/legacy/release_tests/doubleDraggable/index.tsx index b29af82148..a51d76356d 100644 --- a/apps/common-app/src/legacy/release_tests/doubleDraggable/index.tsx +++ b/apps/common-app/src/legacy/release_tests/doubleDraggable/index.tsx @@ -1,7 +1,8 @@ import React, { Component } from 'react'; import { StyleSheet, View } from 'react-native'; -import { DraggableBox } from '../../basic/draggable/index'; + import { LoremIpsum } from '../../../common'; +import { DraggableBox } from '../../basic/draggable/index'; export default class Example extends Component { render() { diff --git a/apps/common-app/src/legacy/release_tests/gesturizedPressable/androidRippleExample.tsx b/apps/common-app/src/legacy/release_tests/gesturizedPressable/androidRippleExample.tsx index b080d94ef5..5440191da0 100644 --- a/apps/common-app/src/legacy/release_tests/gesturizedPressable/androidRippleExample.tsx +++ b/apps/common-app/src/legacy/release_tests/gesturizedPressable/androidRippleExample.tsx @@ -1,5 +1,6 @@ -import { Platform, StyleSheet, View } from 'react-native'; import React from 'react'; +import { Platform, StyleSheet, View } from 'react-native'; + import TestingBase from './testingBase'; export function RippleExample() { diff --git a/apps/common-app/src/legacy/release_tests/gesturizedPressable/delayedPressExample.tsx b/apps/common-app/src/legacy/release_tests/gesturizedPressable/delayedPressExample.tsx index c1bf844743..de45b113c1 100644 --- a/apps/common-app/src/legacy/release_tests/gesturizedPressable/delayedPressExample.tsx +++ b/apps/common-app/src/legacy/release_tests/gesturizedPressable/delayedPressExample.tsx @@ -1,11 +1,12 @@ +import React from 'react'; +import { StyleSheet, View } from 'react-native'; import Animated, { useAnimatedStyle, useSharedValue, withSequence, withSpring, } from 'react-native-reanimated'; -import { StyleSheet, View } from 'react-native'; -import React from 'react'; + import TestingBase from './testingBase'; const signalerConfig = { diff --git a/apps/common-app/src/legacy/release_tests/gesturizedPressable/functionalStylesExample.tsx b/apps/common-app/src/legacy/release_tests/gesturizedPressable/functionalStylesExample.tsx index 39f1be8791..b982d4a0d4 100644 --- a/apps/common-app/src/legacy/release_tests/gesturizedPressable/functionalStylesExample.tsx +++ b/apps/common-app/src/legacy/release_tests/gesturizedPressable/functionalStylesExample.tsx @@ -1,6 +1,7 @@ -import { StyleSheet, View } from 'react-native'; -import type { PressableStateCallbackType } from 'react-native'; import React from 'react'; +import type { PressableStateCallbackType } from 'react-native'; +import { StyleSheet, View } from 'react-native'; + import TestingBase from './testingBase'; export function FunctionalStyleExample() { diff --git a/apps/common-app/src/legacy/release_tests/gesturizedPressable/hitSlopExample.tsx b/apps/common-app/src/legacy/release_tests/gesturizedPressable/hitSlopExample.tsx index c0d589e0dd..cb1528a418 100644 --- a/apps/common-app/src/legacy/release_tests/gesturizedPressable/hitSlopExample.tsx +++ b/apps/common-app/src/legacy/release_tests/gesturizedPressable/hitSlopExample.tsx @@ -1,5 +1,6 @@ -import { StyleSheet, Text, View } from 'react-native'; import React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; + import TestingBase from './testingBase'; const HIT_SLOP = 40; diff --git a/apps/common-app/src/legacy/release_tests/gesturizedPressable/hoverDelayExample.tsx b/apps/common-app/src/legacy/release_tests/gesturizedPressable/hoverDelayExample.tsx index 3cbbf6bfa2..14e17b403a 100644 --- a/apps/common-app/src/legacy/release_tests/gesturizedPressable/hoverDelayExample.tsx +++ b/apps/common-app/src/legacy/release_tests/gesturizedPressable/hoverDelayExample.tsx @@ -1,5 +1,6 @@ -import { StyleSheet, View } from 'react-native'; import React from 'react'; +import { StyleSheet, View } from 'react-native'; + import TestingBase from './testingBase'; export function DelayHoverExample() { diff --git a/apps/common-app/src/legacy/release_tests/gesturizedPressable/index.tsx b/apps/common-app/src/legacy/release_tests/gesturizedPressable/index.tsx index a3e96d2ab7..4548222e1d 100644 --- a/apps/common-app/src/legacy/release_tests/gesturizedPressable/index.tsx +++ b/apps/common-app/src/legacy/release_tests/gesturizedPressable/index.tsx @@ -1,13 +1,14 @@ +import type { ReactNode } from 'react'; +import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { BACKGROUND_COLOR } from './testingBase'; -import { DelayHoverExample } from './hoverDelayExample'; +import { ScrollView } from 'react-native-gesture-handler'; + +import { RippleExample } from './androidRippleExample'; import { DelayedPressExample } from './delayedPressExample'; import { FunctionalStyleExample } from './functionalStylesExample'; import { HitSlopExample } from './hitSlopExample'; -import React from 'react'; -import type { ReactNode } from 'react'; -import { RippleExample } from './androidRippleExample'; -import { ScrollView } from 'react-native-gesture-handler'; +import { DelayHoverExample } from './hoverDelayExample'; +import { BACKGROUND_COLOR } from './testingBase'; type TestingEntryProps = { title: string; diff --git a/apps/common-app/src/legacy/release_tests/gesturizedPressable/testingBase.tsx b/apps/common-app/src/legacy/release_tests/gesturizedPressable/testingBase.tsx index 0cf497497e..9737050236 100644 --- a/apps/common-app/src/legacy/release_tests/gesturizedPressable/testingBase.tsx +++ b/apps/common-app/src/legacy/release_tests/gesturizedPressable/testingBase.tsx @@ -1,8 +1,8 @@ +import React from 'react'; +import type { PressableProps as RNPressableProps } from 'react-native'; import { Pressable as RNPressable, StyleSheet, Text, View } from 'react-native'; -import { LegacyPressable as GHPressable } from 'react-native-gesture-handler'; import type { LegacyPressableProps as GHPressableProps } from 'react-native-gesture-handler'; -import type { PressableProps as RNPressableProps } from 'react-native'; -import React from 'react'; +import { LegacyPressable as GHPressable } from 'react-native-gesture-handler'; const TestingBase = (props: GHPressableProps & RNPressableProps) => ( <> diff --git a/apps/common-app/src/legacy/release_tests/mouseButtons/index.tsx b/apps/common-app/src/legacy/release_tests/mouseButtons/index.tsx index d5f03ff844..198d0aa939 100644 --- a/apps/common-app/src/legacy/release_tests/mouseButtons/index.tsx +++ b/apps/common-app/src/legacy/release_tests/mouseButtons/index.tsx @@ -1,3 +1,6 @@ +import React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import type { GestureType } from 'react-native-gesture-handler'; import { Directions, Gesture, @@ -5,9 +8,6 @@ import { MouseButton, ScrollView, } from 'react-native-gesture-handler'; -import { StyleSheet, Text, View } from 'react-native'; -import type { GestureType } from 'react-native-gesture-handler'; -import React from 'react'; const COLORS = ['darkmagenta', 'darkgreen', 'darkblue', 'crimson', 'pink']; diff --git a/apps/common-app/src/legacy/release_tests/nestedButtons/index.tsx b/apps/common-app/src/legacy/release_tests/nestedButtons/index.tsx index 41940d57cc..2935f9bf91 100644 --- a/apps/common-app/src/legacy/release_tests/nestedButtons/index.tsx +++ b/apps/common-app/src/legacy/release_tests/nestedButtons/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { RectButton } from 'react-native-gesture-handler'; import { View } from 'react-native'; +import { RectButton } from 'react-native-gesture-handler'; export default function Example() { return ( diff --git a/apps/common-app/src/legacy/release_tests/nestedFling/index.tsx b/apps/common-app/src/legacy/release_tests/nestedFling/index.tsx index 694f9fb541..902d9aa0e2 100644 --- a/apps/common-app/src/legacy/release_tests/nestedFling/index.tsx +++ b/apps/common-app/src/legacy/release_tests/nestedFling/index.tsx @@ -1,11 +1,12 @@ +import React, { Component } from 'react'; import { Animated, Dimensions, StyleSheet, Text, View } from 'react-native'; +import type { FlingGestureHandlerStateChangeEvent } from 'react-native-gesture-handler'; import { Directions, FlingGestureHandler, State, } from 'react-native-gesture-handler'; -import React, { Component } from 'react'; -import type { FlingGestureHandlerStateChangeEvent } from 'react-native-gesture-handler'; + import { USE_NATIVE_DRIVER } from '../../../config'; const windowWidth = Dimensions.get('window').width; diff --git a/apps/common-app/src/legacy/release_tests/nestedGHRootViewWithModal/index.tsx b/apps/common-app/src/legacy/release_tests/nestedGHRootViewWithModal/index.tsx index 22f90df7d8..e2f016452a 100644 --- a/apps/common-app/src/legacy/release_tests/nestedGHRootViewWithModal/index.tsx +++ b/apps/common-app/src/legacy/release_tests/nestedGHRootViewWithModal/index.tsx @@ -1,11 +1,12 @@ import * as React from 'react'; +import { useState } from 'react'; +import { Modal, StyleSheet, Text, View } from 'react-native'; import { GestureHandlerRootView, TouchableOpacity, } from 'react-native-gesture-handler'; -import { Modal, StyleSheet, Text, View } from 'react-native'; + import { DraggableBox } from '../../basic/draggable'; -import { useState } from 'react'; export default function App() { const [isModalVisible, setIsModalVisible] = useState(false); diff --git a/apps/common-app/src/legacy/release_tests/nestedPressables/index.tsx b/apps/common-app/src/legacy/release_tests/nestedPressables/index.tsx index 0cfc07eb1a..d19edf7f10 100644 --- a/apps/common-app/src/legacy/release_tests/nestedPressables/index.tsx +++ b/apps/common-app/src/legacy/release_tests/nestedPressables/index.tsx @@ -1,7 +1,7 @@ -import { LegacyPressable, ScrollView } from 'react-native-gesture-handler'; -import { Pressable as RNPressable, StyleSheet, Text, View } from 'react-native'; -import type { PressableStateCallbackType } from 'react-native'; import React from 'react'; +import type { PressableStateCallbackType } from 'react-native'; +import { Pressable as RNPressable, StyleSheet, Text, View } from 'react-native'; +import { LegacyPressable, ScrollView } from 'react-native-gesture-handler'; export default function Example() { return ( diff --git a/apps/common-app/src/legacy/release_tests/nestedText/index.tsx b/apps/common-app/src/legacy/release_tests/nestedText/index.tsx index 19bdcb7c8e..7804f17f76 100644 --- a/apps/common-app/src/legacy/release_tests/nestedText/index.tsx +++ b/apps/common-app/src/legacy/release_tests/nestedText/index.tsx @@ -1,10 +1,10 @@ +import { useState } from 'react'; +import { StyleSheet } from 'react-native'; import { GestureHandlerRootView, LegacyText, TouchableOpacity, } from 'react-native-gesture-handler'; -import { StyleSheet } from 'react-native'; -import { useState } from 'react'; export default function NestedText() { const [counter, setCounter] = useState(0); diff --git a/apps/common-app/src/legacy/release_tests/nestedTouchables/index.tsx b/apps/common-app/src/legacy/release_tests/nestedTouchables/index.tsx index 9b2074e66c..8a158a53c6 100644 --- a/apps/common-app/src/legacy/release_tests/nestedTouchables/index.tsx +++ b/apps/common-app/src/legacy/release_tests/nestedTouchables/index.tsx @@ -1,7 +1,8 @@ -import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler'; +import React from 'react'; import { StyleSheet, Text } from 'react-native'; +import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler'; + import { LoremIpsum } from '../../../common'; -import React from 'react'; export default function Example() { return ( diff --git a/apps/common-app/src/legacy/release_tests/overflowParent/index.tsx b/apps/common-app/src/legacy/release_tests/overflowParent/index.tsx index d00a0e0b6f..784bc7df25 100644 --- a/apps/common-app/src/legacy/release_tests/overflowParent/index.tsx +++ b/apps/common-app/src/legacy/release_tests/overflowParent/index.tsx @@ -1,11 +1,12 @@ +import React, { useRef } from 'react'; import { Animated, StyleSheet, Text, View } from 'react-native'; +import type { PanGestureHandlerStateChangeEvent } from 'react-native-gesture-handler'; import { PanGestureHandler, State, TapGestureHandler, } from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; -import type { PanGestureHandlerStateChangeEvent } from 'react-native-gesture-handler'; + import { USE_NATIVE_DRIVER } from '../../../config'; export default function Example() { diff --git a/apps/common-app/src/legacy/release_tests/pointerType/index.tsx b/apps/common-app/src/legacy/release_tests/pointerType/index.tsx index 2fe903f5db..83278d0705 100644 --- a/apps/common-app/src/legacy/release_tests/pointerType/index.tsx +++ b/apps/common-app/src/legacy/release_tests/pointerType/index.tsx @@ -1,16 +1,16 @@ +import React, { useState } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import { + Gesture, + GestureDetector, + PointerType, +} from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { - Gesture, - GestureDetector, - PointerType, -} from 'react-native-gesture-handler'; -import React, { useState } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; const Colors = { Touch: '#7bbf98', diff --git a/apps/common-app/src/legacy/release_tests/rectButton/index.tsx b/apps/common-app/src/legacy/release_tests/rectButton/index.tsx index 55fe2193b7..e1633959d2 100644 --- a/apps/common-app/src/legacy/release_tests/rectButton/index.tsx +++ b/apps/common-app/src/legacy/release_tests/rectButton/index.tsx @@ -1,5 +1,5 @@ -import { StyleSheet, Text, View } from 'react-native'; import React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { RectButton } from 'react-native-gesture-handler'; export default function RectButtonBorders() { diff --git a/apps/common-app/src/legacy/release_tests/svg/index.tsx b/apps/common-app/src/legacy/release_tests/svg/index.tsx index 43640df6d4..8f2049bc67 100644 --- a/apps/common-app/src/legacy/release_tests/svg/index.tsx +++ b/apps/common-app/src/legacy/release_tests/svg/index.tsx @@ -1,7 +1,7 @@ -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Svg, { Circle, Rect } from 'react-native-svg'; -import React from 'react'; export default function SvgExample() { const circleElementTap = Gesture.Tap().onStart(() => diff --git a/apps/common-app/src/legacy/release_tests/touchables/index.tsx b/apps/common-app/src/legacy/release_tests/touchables/index.tsx index e94bd8f203..56e6a4f6b3 100644 --- a/apps/common-app/src/legacy/release_tests/touchables/index.tsx +++ b/apps/common-app/src/legacy/release_tests/touchables/index.tsx @@ -1,14 +1,16 @@ +import type { StackScreenProps } from '@react-navigation/stack'; +import React, { Component } from 'react'; +import type { BackgroundPropType } from 'react-native'; import { FlatList, + StyleSheet, + Text, TouchableHighlight as RNTouchableHighlight, TouchableNativeFeedback as RNTouchableNativeFeedback, TouchableOpacity as RNTouchableOpacity, TouchableWithoutFeedback as RNTouchableWithoutFeedback, - StyleSheet, - Text, View, } from 'react-native'; -import React, { Component } from 'react'; import { RectButton, ScrollView, @@ -17,8 +19,6 @@ import { TouchableOpacity, TouchableWithoutFeedback, } from 'react-native-gesture-handler'; -import type { BackgroundPropType } from 'react-native'; -import type { StackScreenProps } from '@react-navigation/stack'; const BOX_SIZE = 80; diff --git a/apps/common-app/src/legacy/release_tests/twoFingerPan/index.tsx b/apps/common-app/src/legacy/release_tests/twoFingerPan/index.tsx index 52b3d49b25..88e285caaf 100644 --- a/apps/common-app/src/legacy/release_tests/twoFingerPan/index.tsx +++ b/apps/common-app/src/legacy/release_tests/twoFingerPan/index.tsx @@ -1,10 +1,10 @@ +import React from 'react'; +import { StyleSheet, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { useAnimatedStyle, useSharedValue, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { StyleSheet, View } from 'react-native'; -import React from 'react'; const BOX_SIZE = 270; diff --git a/apps/common-app/src/legacy/release_tests/webStylesReset/index.tsx b/apps/common-app/src/legacy/release_tests/webStylesReset/index.tsx index c7b7949886..b14bfac396 100644 --- a/apps/common-app/src/legacy/release_tests/webStylesReset/index.tsx +++ b/apps/common-app/src/legacy/release_tests/webStylesReset/index.tsx @@ -1,16 +1,16 @@ +import React, { useState } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import { + Gesture, + GestureDetector, + Pressable, +} from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { - Gesture, - GestureDetector, - Pressable, -} from 'react-native-gesture-handler'; -import React, { useState } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; const Colors = { enabled: '#32a852', diff --git a/apps/common-app/src/legacy/showcase/bottomSheet/index.tsx b/apps/common-app/src/legacy/showcase/bottomSheet/index.tsx index 14067fb096..b21a38e9b5 100644 --- a/apps/common-app/src/legacy/showcase/bottomSheet/index.tsx +++ b/apps/common-app/src/legacy/showcase/bottomSheet/index.tsx @@ -1,16 +1,17 @@ -import { Animated, Dimensions, StyleSheet, View } from 'react-native'; +import React, { Component } from 'react'; import type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native'; +import { Animated, Dimensions, StyleSheet, View } from 'react-native'; +import type { + PanGestureHandlerGestureEvent, + PanGestureHandlerStateChangeEvent, +} from 'react-native-gesture-handler'; import { NativeViewGestureHandler, PanGestureHandler, State, TapGestureHandler, } from 'react-native-gesture-handler'; -import type { - PanGestureHandlerGestureEvent, - PanGestureHandlerStateChangeEvent, -} from 'react-native-gesture-handler'; -import React, { Component } from 'react'; + import { LoremIpsum } from '../../../common'; import { USE_NATIVE_DRIVER } from '../../../config'; diff --git a/apps/common-app/src/legacy/showcase/chatHeads/index.tsx b/apps/common-app/src/legacy/showcase/chatHeads/index.tsx index 3307b73ff6..6b6f0bf3cf 100644 --- a/apps/common-app/src/legacy/showcase/chatHeads/index.tsx +++ b/apps/common-app/src/legacy/showcase/chatHeads/index.tsx @@ -1,11 +1,11 @@ +import React, { Component } from 'react'; +import type { LayoutChangeEvent } from 'react-native'; import { Animated, StyleSheet, View } from 'react-native'; -import { PanGestureHandler, State } from 'react-native-gesture-handler'; import type { PanGestureHandlerGestureEvent, PanGestureHandlerStateChangeEvent, } from 'react-native-gesture-handler'; -import React, { Component } from 'react'; -import type { LayoutChangeEvent } from 'react-native'; +import { PanGestureHandler, State } from 'react-native-gesture-handler'; const USE_NATIVE_DRIVER = false; diff --git a/apps/common-app/src/legacy/simple/draggable/index.tsx b/apps/common-app/src/legacy/simple/draggable/index.tsx index f7765bf58a..567987079d 100644 --- a/apps/common-app/src/legacy/simple/draggable/index.tsx +++ b/apps/common-app/src/legacy/simple/draggable/index.tsx @@ -1,9 +1,9 @@ -import Animated, { useSharedValue } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { ScrollView, StyleSheet } from 'react-native'; -import type { StyleProp, ViewStyle } from 'react-native'; import type { FC } from 'react'; import React from 'react'; +import type { StyleProp, ViewStyle } from 'react-native'; +import { ScrollView, StyleSheet } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import Animated, { useSharedValue } from 'react-native-reanimated'; type DraggableBoxProps = { minDist?: number; diff --git a/apps/common-app/src/legacy/simple/fling/index.tsx b/apps/common-app/src/legacy/simple/fling/index.tsx index e9156b67c4..09af8c6dd7 100644 --- a/apps/common-app/src/legacy/simple/fling/index.tsx +++ b/apps/common-app/src/legacy/simple/fling/index.tsx @@ -1,16 +1,16 @@ +import React from 'react'; +import { StyleSheet, View } from 'react-native'; +import { + Directions, + Gesture, + GestureDetector, +} from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { - Directions, - Gesture, - GestureDetector, -} from 'react-native-gesture-handler'; -import { StyleSheet, View } from 'react-native'; -import React from 'react'; const AnimationDuration = 100; diff --git a/apps/common-app/src/legacy/simple/longPress/index.tsx b/apps/common-app/src/legacy/simple/longPress/index.tsx index 9846e62fdb..fcb4099fe0 100644 --- a/apps/common-app/src/legacy/simple/longPress/index.tsx +++ b/apps/common-app/src/legacy/simple/longPress/index.tsx @@ -1,11 +1,11 @@ +import { StyleSheet, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { StyleSheet, View } from 'react-native'; const Durations = { LongPress: 750, diff --git a/apps/common-app/src/legacy/simple/manual/index.tsx b/apps/common-app/src/legacy/simple/manual/index.tsx index e28083c52f..e1ec007b79 100644 --- a/apps/common-app/src/legacy/simple/manual/index.tsx +++ b/apps/common-app/src/legacy/simple/manual/index.tsx @@ -1,11 +1,11 @@ +import { StyleSheet, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { StyleSheet, View } from 'react-native'; export default function ManualExample() { const isPressed = useSharedValue(false); diff --git a/apps/common-app/src/legacy/simple/tap/index.tsx b/apps/common-app/src/legacy/simple/tap/index.tsx index d8b7bd1080..c6a47211eb 100644 --- a/apps/common-app/src/legacy/simple/tap/index.tsx +++ b/apps/common-app/src/legacy/simple/tap/index.tsx @@ -1,7 +1,7 @@ import React, { Component } from 'react'; -import { State, TapGestureHandler } from 'react-native-gesture-handler'; import { StyleSheet, View } from 'react-native'; import type { TapGestureHandlerStateChangeEvent } from 'react-native-gesture-handler'; +import { State, TapGestureHandler } from 'react-native-gesture-handler'; interface PressBoxProps { setDuration?: (duration: number) => void; diff --git a/apps/common-app/src/legacy/v2_api/bottom_sheet/index.tsx b/apps/common-app/src/legacy/v2_api/bottom_sheet/index.tsx index fa8770af63..2bfa9f6f8b 100644 --- a/apps/common-app/src/legacy/v2_api/bottom_sheet/index.tsx +++ b/apps/common-app/src/legacy/v2_api/bottom_sheet/index.tsx @@ -1,15 +1,16 @@ +import React, { useRef, useState } from 'react'; +import type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native'; +import { Dimensions, StyleSheet, View } from 'react-native'; +import type { PanGestureHandlerEventPayload } from 'react-native-gesture-handler'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withSpring, } from 'react-native-reanimated'; -import { Dimensions, StyleSheet, View } from 'react-native'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native'; -import React, { useRef, useState } from 'react'; + import { LoremIpsum } from '../../../common'; -import type { PanGestureHandlerEventPayload } from 'react-native-gesture-handler'; const HEADER_HEIGTH = 50; const windowHeight = Dimensions.get('window').height; diff --git a/apps/common-app/src/legacy/v2_api/calculator/index.tsx b/apps/common-app/src/legacy/v2_api/calculator/index.tsx index 78a5269069..5298fa3125 100644 --- a/apps/common-app/src/legacy/v2_api/calculator/index.tsx +++ b/apps/common-app/src/legacy/v2_api/calculator/index.tsx @@ -1,19 +1,19 @@ -import Animated, { - runOnJS, - useAnimatedStyle, - useSharedValue, - withTiming, -} from 'react-native-reanimated'; -import { Dimensions, StyleSheet, Text, View } from 'react-native'; import type { Dispatch, SetStateAction } from 'react'; +import React, { useRef, useState } from 'react'; +import type { LayoutChangeEvent, LayoutRectangle } from 'react-native'; +import { Dimensions, StyleSheet, Text, View } from 'react-native'; import { Gesture, GestureDetector, LegacyScrollView, } from 'react-native-gesture-handler'; -import type { LayoutChangeEvent, LayoutRectangle } from 'react-native'; -import React, { useRef, useState } from 'react'; import type { SharedValue } from 'react-native-reanimated'; +import Animated, { + runOnJS, + useAnimatedStyle, + useSharedValue, + withTiming, +} from 'react-native-reanimated'; const DRAG_ANIMATION_DURATION = 300; const TAP_ANIMATION_DURATION = 100; diff --git a/apps/common-app/src/legacy/v2_api/camera/index.tsx b/apps/common-app/src/legacy/v2_api/camera/index.tsx index a66e1ca3e7..70e65322ab 100644 --- a/apps/common-app/src/legacy/v2_api/camera/index.tsx +++ b/apps/common-app/src/legacy/v2_api/camera/index.tsx @@ -1,3 +1,7 @@ +import React, { useState } from 'react'; +import { StyleSheet, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { runOnJS, useAnimatedProps, @@ -6,11 +10,8 @@ import Animated, { withTiming, } from 'react-native-reanimated'; import { Circle, Svg } from 'react-native-svg'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import React, { useState } from 'react'; -import { StyleSheet, View } from 'react-native'; + import AnimatedCameraView from '../../../common_assets/AnimatedCameraView/AnimatedCameraView'; -import type { SharedValue } from 'react-native-reanimated'; const FILTERS = ['red', 'green', 'blue', 'yellow', 'orange', 'cyan']; const CAROUSEL_SIZE = 100; diff --git a/apps/common-app/src/legacy/v2_api/chat_heads/index.tsx b/apps/common-app/src/legacy/v2_api/chat_heads/index.tsx index 4bd335d165..988c1e672a 100644 --- a/apps/common-app/src/legacy/v2_api/chat_heads/index.tsx +++ b/apps/common-app/src/legacy/v2_api/chat_heads/index.tsx @@ -1,16 +1,16 @@ +import { useHeaderHeight } from '@react-navigation/elements'; +import React, { useState } from 'react'; +import type { ImageStyle, LayoutChangeEvent } from 'react-native'; +import { StyleSheet } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { useAnimatedStyle, useDerivedValue, useSharedValue, withSpring, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import type { ImageStyle, LayoutChangeEvent } from 'react-native'; -import React, { useState } from 'react'; import { SafeAreaView } from 'react-native-safe-area-context'; -import type { SharedValue } from 'react-native-reanimated'; -import { StyleSheet } from 'react-native'; -import { useHeaderHeight } from '@react-navigation/elements'; const CHAT_HEADS = [ { imageUrl: 'https://avatars0.githubusercontent.com/u/379606?v=4&s=460' }, diff --git a/apps/common-app/src/legacy/v2_api/drag_n_drop/DragAndDrop.tsx b/apps/common-app/src/legacy/v2_api/drag_n_drop/DragAndDrop.tsx index 96b07ee207..a262ea65db 100644 --- a/apps/common-app/src/legacy/v2_api/drag_n_drop/DragAndDrop.tsx +++ b/apps/common-app/src/legacy/v2_api/drag_n_drop/DragAndDrop.tsx @@ -1,5 +1,4 @@ -import { ANIMATE_TO_NEW_PLACE_DURATION, getSizeConstants } from './constants'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import React, { useEffect, useState } from 'react'; import { LayoutAnimation, Platform, @@ -7,14 +6,16 @@ import { UIManager, View, } from 'react-native'; -import React, { useEffect, useState } from 'react'; +import type { PanGestureHandlerEventPayload } from 'react-native-gesture-handler'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import { useSharedValue, withSpring, withTiming, } from 'react-native-reanimated'; + +import { ANIMATE_TO_NEW_PLACE_DURATION, getSizeConstants } from './constants'; import Draggable from './Draggable'; -import type { PanGestureHandlerEventPayload } from 'react-native-gesture-handler'; if ( Platform.OS === 'android' && diff --git a/apps/common-app/src/legacy/v2_api/drag_n_drop/Draggable.tsx b/apps/common-app/src/legacy/v2_api/drag_n_drop/Draggable.tsx index 59a1cca4ef..ec920a5fa5 100644 --- a/apps/common-app/src/legacy/v2_api/drag_n_drop/Draggable.tsx +++ b/apps/common-app/src/legacy/v2_api/drag_n_drop/Draggable.tsx @@ -1,13 +1,13 @@ -import Animated, { runOnJS, useAnimatedStyle } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import React from 'react'; +import { StyleSheet } from 'react-native'; import type { LegacyPanGesture, LegacyTapGesture, PanGestureHandlerEventPayload, } from 'react-native-gesture-handler'; -import React from 'react'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import type { SharedValue } from 'react-native-reanimated'; -import { StyleSheet } from 'react-native'; +import Animated, { runOnJS, useAnimatedStyle } from 'react-native-reanimated'; type AnimatedPostion = { x: SharedValue; diff --git a/apps/common-app/src/legacy/v2_api/drag_n_drop/Tile.tsx b/apps/common-app/src/legacy/v2_api/drag_n_drop/Tile.tsx index 739951e310..0a7d83e059 100644 --- a/apps/common-app/src/legacy/v2_api/drag_n_drop/Tile.tsx +++ b/apps/common-app/src/legacy/v2_api/drag_n_drop/Tile.tsx @@ -1,3 +1,5 @@ +import React, { useEffect, useRef } from 'react'; +import { StyleSheet } from 'react-native'; import Animated, { Easing, interpolate, @@ -6,8 +8,6 @@ import Animated, { withRepeat, withTiming, } from 'react-native-reanimated'; -import React, { useEffect, useRef } from 'react'; -import { StyleSheet } from 'react-native'; export interface ColorTile { id: string; diff --git a/apps/common-app/src/legacy/v2_api/drag_n_drop/index.tsx b/apps/common-app/src/legacy/v2_api/drag_n_drop/index.tsx index 08c02c4d82..febe5a9269 100644 --- a/apps/common-app/src/legacy/v2_api/drag_n_drop/index.tsx +++ b/apps/common-app/src/legacy/v2_api/drag_n_drop/index.tsx @@ -1,7 +1,8 @@ -import type { ColorTile } from './Tile'; -import DragAndDrop from './DragAndDrop'; -import type { DraggableItemData } from './DragAndDrop'; import React from 'react'; + +import type { DraggableItemData } from './DragAndDrop'; +import DragAndDrop from './DragAndDrop'; +import type { ColorTile } from './Tile'; import Tile from './Tile'; const COLORS = [ diff --git a/apps/common-app/src/legacy/v2_api/hover/index.tsx b/apps/common-app/src/legacy/v2_api/hover/index.tsx index 4d36888f6b..0fccecfa94 100644 --- a/apps/common-app/src/legacy/v2_api/hover/index.tsx +++ b/apps/common-app/src/legacy/v2_api/hover/index.tsx @@ -1,15 +1,15 @@ -import Animated, { - useAnimatedStyle, - useSharedValue, -} from 'react-native-reanimated'; +import React from 'react'; +import { Text, View } from 'react-native'; +import type { GestureType } from 'react-native-gesture-handler'; import { Gesture, GestureDetector, HoverEffect, } from 'react-native-gesture-handler'; -import { Text, View } from 'react-native'; -import type { GestureType } from 'react-native-gesture-handler'; -import React from 'react'; +import Animated, { + useAnimatedStyle, + useSharedValue, +} from 'react-native-reanimated'; function useHover(color: string): [GestureType, any] { const hovered = useSharedValue(false); diff --git a/apps/common-app/src/legacy/v2_api/hoverable_icons/index.tsx b/apps/common-app/src/legacy/v2_api/hoverable_icons/index.tsx index 9da84e1f5b..d859b89c16 100644 --- a/apps/common-app/src/legacy/v2_api/hoverable_icons/index.tsx +++ b/apps/common-app/src/legacy/v2_api/hoverable_icons/index.tsx @@ -1,27 +1,22 @@ +import React from 'react'; +import { Platform, StyleSheet } from 'react-native'; +import { + Gesture, + GestureDetector, + HoverEffect, +} from 'react-native-gesture-handler'; import Animated, { useAnimatedStyle, useFrameCallback, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { - Gesture, - GestureDetector, - HoverEffect, -} from 'react-native-gesture-handler'; -import { Platform, StyleSheet } from 'react-native'; -import React from 'react'; -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const SVG = require('../../../common_assets/hoverable_icons/svg.png'); -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const FREEZE = require('../../../common_assets/hoverable_icons/freeze.png'); -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const REA = require('../../../common_assets/hoverable_icons/rea.png'); -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const GH = require('../../../common_assets/hoverable_icons/gh.png'); -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const SCREENS = require('../../../common_assets/hoverable_icons/screens.png'); +import FREEZE from '../../../common_assets/hoverable_icons/freeze.png'; +import GH from '../../../common_assets/hoverable_icons/gh.png'; +import REA from '../../../common_assets/hoverable_icons/rea.png'; +import SCREENS from '../../../common_assets/hoverable_icons/screens.png'; +import SVG from '../../../common_assets/hoverable_icons/svg.png'; const images = [GH, REA, SCREENS, SVG, FREEZE]; const SIZE = 100; diff --git a/apps/common-app/src/legacy/v2_api/manualGestures/index.tsx b/apps/common-app/src/legacy/v2_api/manualGestures/index.tsx index 53be73eb08..571e385219 100644 --- a/apps/common-app/src/legacy/v2_api/manualGestures/index.tsx +++ b/apps/common-app/src/legacy/v2_api/manualGestures/index.tsx @@ -1,11 +1,11 @@ +import React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { useAnimatedStyle, useSharedValue, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { StyleSheet, Text, View } from 'react-native'; -import React from 'react'; -import type { SharedValue } from 'react-native-reanimated'; interface Pointer { visible: boolean; diff --git a/apps/common-app/src/legacy/v2_api/overlap/index.tsx b/apps/common-app/src/legacy/v2_api/overlap/index.tsx index 34c1655aae..9c63a78545 100644 --- a/apps/common-app/src/legacy/v2_api/overlap/index.tsx +++ b/apps/common-app/src/legacy/v2_api/overlap/index.tsx @@ -1,6 +1,6 @@ -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { StyleSheet, Text, View } from 'react-native'; import React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; function Box(props: { color: string; diff --git a/apps/common-app/src/legacy/v2_api/pressable/index.tsx b/apps/common-app/src/legacy/v2_api/pressable/index.tsx index 6d784c8477..2862bb7b16 100644 --- a/apps/common-app/src/legacy/v2_api/pressable/index.tsx +++ b/apps/common-app/src/legacy/v2_api/pressable/index.tsx @@ -1,6 +1,6 @@ +import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { LegacyPressable } from 'react-native-gesture-handler'; -import React from 'react'; const SECTION_RADIUS = 40; const BASE_SIZE = 120; diff --git a/apps/common-app/src/legacy/v2_api/transformations/index.tsx b/apps/common-app/src/legacy/v2_api/transformations/index.tsx index 08ba190da3..ac4929386e 100644 --- a/apps/common-app/src/legacy/v2_api/transformations/index.tsx +++ b/apps/common-app/src/legacy/v2_api/transformations/index.tsx @@ -1,10 +1,11 @@ +import React from 'react'; +import { Image, StyleSheet, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { useAnimatedStyle, useSharedValue, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { Image, StyleSheet, View } from 'react-native'; -import React from 'react'; + import SIGNET from '../../../ListWithHeader/signet.png'; function Photo() { diff --git a/apps/common-app/src/legacy/v2_api/velocityTest/index.tsx b/apps/common-app/src/legacy/v2_api/velocityTest/index.tsx index b5435ae880..23e2aa91a1 100644 --- a/apps/common-app/src/legacy/v2_api/velocityTest/index.tsx +++ b/apps/common-app/src/legacy/v2_api/velocityTest/index.tsx @@ -1,3 +1,6 @@ +import React from 'react'; +import { StyleSheet, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { interpolateColor, measure, @@ -7,9 +10,6 @@ import Animated, { withDecay, withTiming, } from 'react-native-reanimated'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; -import { StyleSheet, View } from 'react-native'; -import React from 'react'; const BOX_SIZE = 120; diff --git a/apps/common-app/src/new_api/complicated/camera/capture.tsx b/apps/common-app/src/new_api/complicated/camera/capture.tsx index 44fbac54fc..0c6710fcb3 100644 --- a/apps/common-app/src/new_api/complicated/camera/capture.tsx +++ b/apps/common-app/src/new_api/complicated/camera/capture.tsx @@ -1,7 +1,7 @@ +import { StyleSheet } from 'react-native'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { useAnimatedProps } from 'react-native-reanimated'; import Svg, { Circle } from 'react-native-svg'; -import type { SharedValue } from 'react-native-reanimated'; -import { StyleSheet } from 'react-native'; const CAROUSEL_SIZE = 100; const RECORD_INDICATOR_STROKE = 10; diff --git a/apps/common-app/src/new_api/complicated/camera/filters.tsx b/apps/common-app/src/new_api/complicated/camera/filters.tsx index 3d334a293f..e0b8b5419a 100644 --- a/apps/common-app/src/new_api/complicated/camera/filters.tsx +++ b/apps/common-app/src/new_api/complicated/camera/filters.tsx @@ -1,6 +1,6 @@ -import Animated, { useAnimatedStyle } from 'react-native-reanimated'; import { StyleSheet, View } from 'react-native'; import type { SharedValue } from 'react-native-reanimated'; +import Animated, { useAnimatedStyle } from 'react-native-reanimated'; interface FilterCarouselProps { filters: string[]; diff --git a/apps/common-app/src/new_api/complicated/camera/index.tsx b/apps/common-app/src/new_api/complicated/camera/index.tsx index 54e2b3fcba..9afe6ddcb4 100644 --- a/apps/common-app/src/new_api/complicated/camera/index.tsx +++ b/apps/common-app/src/new_api/complicated/camera/index.tsx @@ -1,4 +1,5 @@ -import { FilterCarousel, FilterOverlay } from './filters'; +import React, { useState } from 'react'; +import { StyleSheet, View } from 'react-native'; import { GestureDetector, useCompetingGestures, @@ -9,12 +10,12 @@ import { useSimultaneousGestures, useTapGesture, } from 'react-native-gesture-handler'; -import React, { useState } from 'react'; -import { StyleSheet, View } from 'react-native'; import { runOnJS, useSharedValue, withTiming } from 'react-native-reanimated'; -import AnimatedCameraView from '../../../common_assets/AnimatedCameraView/AnimatedCameraView'; + import { COLORS } from '../../../common'; +import AnimatedCameraView from '../../../common_assets/AnimatedCameraView/AnimatedCameraView'; import { CaptureButton } from './capture'; +import { FilterCarousel, FilterOverlay } from './filters'; const FILTERS = [ COLORS.RED, diff --git a/apps/common-app/src/new_api/complicated/chat_heads/index.tsx b/apps/common-app/src/new_api/complicated/chat_heads/index.tsx index 5f31051f9c..4cbef58130 100644 --- a/apps/common-app/src/new_api/complicated/chat_heads/index.tsx +++ b/apps/common-app/src/new_api/complicated/chat_heads/index.tsx @@ -1,16 +1,16 @@ +import { useHeaderHeight } from '@react-navigation/elements'; +import React, { useState } from 'react'; +import type { ImageStyle, LayoutChangeEvent } from 'react-native'; +import { StyleSheet } from 'react-native'; +import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { useAnimatedStyle, useDerivedValue, useSharedValue, withSpring, } from 'react-native-reanimated'; -import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; -import type { ImageStyle, LayoutChangeEvent } from 'react-native'; -import React, { useState } from 'react'; import { SafeAreaView } from 'react-native-safe-area-context'; -import type { SharedValue } from 'react-native-reanimated'; -import { StyleSheet } from 'react-native'; -import { useHeaderHeight } from '@react-navigation/elements'; const CHAT_HEADS = [ { imageUrl: 'https://avatars0.githubusercontent.com/u/379606?v=4&s=460' }, diff --git a/apps/common-app/src/new_api/complicated/lock/index.tsx b/apps/common-app/src/new_api/complicated/lock/index.tsx index 46045f86b2..89bc78c199 100644 --- a/apps/common-app/src/new_api/complicated/lock/index.tsx +++ b/apps/common-app/src/new_api/complicated/lock/index.tsx @@ -1,10 +1,5 @@ -import Animated, { - runOnJS, - useAnimatedStyle, - useSharedValue, - withTiming, -} from 'react-native-reanimated'; -import { COLORS, commonStyles } from '../../../common'; +import React, { useState } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { GestureDetector, useLongPressGesture, @@ -12,8 +7,14 @@ import { useRotationGesture, useSimultaneousGestures, } from 'react-native-gesture-handler'; -import React, { useState } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; +import Animated, { + runOnJS, + useAnimatedStyle, + useSharedValue, + withTiming, +} from 'react-native-reanimated'; + +import { COLORS, commonStyles } from '../../../common'; export default function Lock() { const rotation = useSharedValue(-Math.PI / 2); diff --git a/apps/common-app/src/new_api/complicated/velocity_test/index.tsx b/apps/common-app/src/new_api/complicated/velocity_test/index.tsx index 2d6aeff2a0..84d19d502b 100644 --- a/apps/common-app/src/new_api/complicated/velocity_test/index.tsx +++ b/apps/common-app/src/new_api/complicated/velocity_test/index.tsx @@ -1,3 +1,6 @@ +import React from 'react'; +import { View } from 'react-native'; +import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; import Animated, { interpolateColor, measure, @@ -7,10 +10,8 @@ import Animated, { withDecay, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; const BOX_SIZE = 120; diff --git a/apps/common-app/src/new_api/components/button_underlay/index.tsx b/apps/common-app/src/new_api/components/button_underlay/index.tsx index 6cccb6dcb5..1145f3f765 100644 --- a/apps/common-app/src/new_api/components/button_underlay/index.tsx +++ b/apps/common-app/src/new_api/components/button_underlay/index.tsx @@ -1,10 +1,10 @@ +import React from 'react'; +import { SafeAreaView, StyleSheet, Text, View } from 'react-native'; import { GestureHandlerRootView, RawButton, ScrollView, } from 'react-native-gesture-handler'; -import { SafeAreaView, StyleSheet, Text, View } from 'react-native'; -import React from 'react'; const UNDERLAY_PROPS = { underlayColor: 'red', diff --git a/apps/common-app/src/new_api/components/buttons/index.tsx b/apps/common-app/src/new_api/components/buttons/index.tsx index 3f57e87a2e..27c1ee167d 100644 --- a/apps/common-app/src/new_api/components/buttons/index.tsx +++ b/apps/common-app/src/new_api/components/buttons/index.tsx @@ -1,3 +1,6 @@ +import type { RefObject } from 'react'; +import { useRef } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { BaseButton, BorderlessButton, @@ -5,11 +8,9 @@ import { Pressable, RectButton, } from 'react-native-gesture-handler'; -import { COLORS, Feedback } from '../../../common'; -import { StyleSheet, Text, View } from 'react-native'; + import type { FeedbackHandle } from '../../../common'; -import type { RefObject } from 'react'; -import { useRef } from 'react'; +import { COLORS, Feedback } from '../../../common'; type ButtonWrapperProps = { ButtonComponent: diff --git a/apps/common-app/src/new_api/components/drawer/index.tsx b/apps/common-app/src/new_api/components/drawer/index.tsx index 38b0e98359..e4a97feebf 100644 --- a/apps/common-app/src/new_api/components/drawer/index.tsx +++ b/apps/common-app/src/new_api/components/drawer/index.tsx @@ -1,15 +1,16 @@ -import { COLORS, LoremIpsum } from '../../../common'; -import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import React, { useRef, useState } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import { Gesture, GestureDetector } from 'react-native-gesture-handler'; +import type { DrawerLayoutMethods } from 'react-native-gesture-handler/ReanimatedDrawerLayout'; import ReanimatedDrawerLayout, { DrawerLockMode, DrawerPosition, DrawerType, } from 'react-native-gesture-handler/ReanimatedDrawerLayout'; -import { StyleSheet, Text, View } from 'react-native'; -import type { DrawerLayoutMethods } from 'react-native-gesture-handler/ReanimatedDrawerLayout'; import type { SharedValue } from 'react-native-reanimated'; +import { COLORS, LoremIpsum } from '../../../common'; + const DrawerPage = ({ progress }: { progress?: SharedValue }) => { progress && console.log('Drawer opening progress:', progress); return ( diff --git a/apps/common-app/src/new_api/components/flatlist/index.tsx b/apps/common-app/src/new_api/components/flatlist/index.tsx index 3f602d7d6e..ae7068776b 100644 --- a/apps/common-app/src/new_api/components/flatlist/index.tsx +++ b/apps/common-app/src/new_api/components/flatlist/index.tsx @@ -1,10 +1,11 @@ +import React, { useRef, useState } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { FlatList, GestureHandlerRootView, RefreshControl, } from 'react-native-gesture-handler'; -import React, { useRef, useState } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; + import { COLORS } from '../../../common'; const DATA = Array.from({ length: 20 }, (_, i) => ({ diff --git a/apps/common-app/src/new_api/components/scrollview/index.tsx b/apps/common-app/src/new_api/components/scrollview/index.tsx index 4d4235b02c..6d432d528c 100644 --- a/apps/common-app/src/new_api/components/scrollview/index.tsx +++ b/apps/common-app/src/new_api/components/scrollview/index.tsx @@ -1,6 +1,7 @@ import React, { useRef, useState } from 'react'; -import { RefreshControl, ScrollView } from 'react-native-gesture-handler'; import { StyleSheet, Text, View } from 'react-native'; +import { RefreshControl, ScrollView } from 'react-native-gesture-handler'; + import { COLORS } from '../../../common'; const DATA = Array.from({ length: 20 }, (_, i) => ({ diff --git a/apps/common-app/src/new_api/components/swipeable/AppleStyleSwipeableRow.tsx b/apps/common-app/src/new_api/components/swipeable/AppleStyleSwipeableRow.tsx index 4c6cbabdbf..9b45832634 100644 --- a/apps/common-app/src/new_api/components/swipeable/AppleStyleSwipeableRow.tsx +++ b/apps/common-app/src/new_api/components/swipeable/AppleStyleSwipeableRow.tsx @@ -1,15 +1,15 @@ +import type { ReactNode } from 'react'; +import React, { useRef } from 'react'; +import { I18nManager, StyleSheet, Text, View } from 'react-native'; +import { RectButton } from 'react-native-gesture-handler'; +import type { SwipeableMethods } from 'react-native-gesture-handler/ReanimatedSwipeable'; +import Swipeable from 'react-native-gesture-handler/ReanimatedSwipeable'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { Extrapolation, interpolate, useAnimatedStyle, } from 'react-native-reanimated'; -import { I18nManager, StyleSheet, Text, View } from 'react-native'; -import React, { useRef } from 'react'; -import type { ReactNode } from 'react'; -import { RectButton } from 'react-native-gesture-handler'; -import type { SharedValue } from 'react-native-reanimated'; -import Swipeable from 'react-native-gesture-handler/ReanimatedSwipeable'; -import type { SwipeableMethods } from 'react-native-gesture-handler/ReanimatedSwipeable'; interface AppleStyleSwipeableRowProps { children?: ReactNode; diff --git a/apps/common-app/src/new_api/components/swipeable/GmailStyleSwipeableRow.tsx b/apps/common-app/src/new_api/components/swipeable/GmailStyleSwipeableRow.tsx index 035857181e..e6276af705 100644 --- a/apps/common-app/src/new_api/components/swipeable/GmailStyleSwipeableRow.tsx +++ b/apps/common-app/src/new_api/components/swipeable/GmailStyleSwipeableRow.tsx @@ -1,15 +1,15 @@ +import type { ReactNode } from 'react'; +import React, { useRef } from 'react'; +import { I18nManager, StyleSheet } from 'react-native'; +import { RectButton } from 'react-native-gesture-handler'; +import type { SwipeableMethods } from 'react-native-gesture-handler/ReanimatedSwipeable'; +import Swipeable from 'react-native-gesture-handler/ReanimatedSwipeable'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { Extrapolation, interpolate, useAnimatedStyle, } from 'react-native-reanimated'; -import { I18nManager, StyleSheet } from 'react-native'; -import React, { useRef } from 'react'; -import type { ReactNode } from 'react'; -import { RectButton } from 'react-native-gesture-handler'; -import type { SharedValue } from 'react-native-reanimated'; -import Swipeable from 'react-native-gesture-handler/ReanimatedSwipeable'; -import type { SwipeableMethods } from 'react-native-gesture-handler/ReanimatedSwipeable'; interface LeftActionProps { dragX: SharedValue; diff --git a/apps/common-app/src/new_api/components/swipeable/index.tsx b/apps/common-app/src/new_api/components/swipeable/index.tsx index 98aee86735..a9fef782e4 100644 --- a/apps/common-app/src/new_api/components/swipeable/index.tsx +++ b/apps/common-app/src/new_api/components/swipeable/index.tsx @@ -1,12 +1,13 @@ -import { FlatList, Pressable, RectButton } from 'react-native-gesture-handler'; -import { I18nManager, StyleSheet, Text, View } from 'react-native'; import React, { useRef } from 'react'; +import { I18nManager, StyleSheet, Text, View } from 'react-native'; +import { FlatList, Pressable, RectButton } from 'react-native-gesture-handler'; +import type { SwipeableMethods } from 'react-native-gesture-handler/ReanimatedSwipeable'; +import ReanimatedSwipeable from 'react-native-gesture-handler/ReanimatedSwipeable'; +import type { SharedValue } from 'react-native-reanimated'; import Reanimated, { useAnimatedStyle } from 'react-native-reanimated'; + import AppleStyleSwipeableRow from './AppleStyleSwipeableRow'; import GmailStyleSwipeableRow from './GmailStyleSwipeableRow'; -import ReanimatedSwipeable from 'react-native-gesture-handler/ReanimatedSwipeable'; -import type { SharedValue } from 'react-native-reanimated'; -import type { SwipeableMethods } from 'react-native-gesture-handler/ReanimatedSwipeable'; // To toggle LTR/RTL change to `true` I18nManager.allowRTL(false); diff --git a/apps/common-app/src/new_api/components/switchAndInput/index.tsx b/apps/common-app/src/new_api/components/switchAndInput/index.tsx index 95d86203cd..1abb0cdd34 100644 --- a/apps/common-app/src/new_api/components/switchAndInput/index.tsx +++ b/apps/common-app/src/new_api/components/switchAndInput/index.tsx @@ -1,11 +1,11 @@ +import React, { useState } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { LegacySwitch, LegacyTextInput, Switch, TextInput, } from 'react-native-gesture-handler'; -import React, { useState } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; export default function SwitchTextInputExample() { const [switchOn, setSwitchOn] = useState(false); diff --git a/apps/common-app/src/new_api/components/touchable/index.tsx b/apps/common-app/src/new_api/components/touchable/index.tsx index 20794a26ba..2f5b9f52d1 100644 --- a/apps/common-app/src/new_api/components/touchable/index.tsx +++ b/apps/common-app/src/new_api/components/touchable/index.tsx @@ -1,11 +1,12 @@ +import React from 'react'; +import { ScrollView, StyleSheet, Text, View } from 'react-native'; +import type { TouchableProps } from 'react-native-gesture-handler'; import { GestureHandlerRootView, Touchable, } from 'react-native-gesture-handler'; -import { ScrollView, StyleSheet, Text, View } from 'react-native'; + import { COLORS } from '../../../common'; -import React from 'react'; -import type { TouchableProps } from 'react-native-gesture-handler'; type ButtonWrapperProps = TouchableProps & { name: string; diff --git a/apps/common-app/src/new_api/components/touchable_stress/index.tsx b/apps/common-app/src/new_api/components/touchable_stress/index.tsx index 383b9c1e7e..ae9eda17e0 100644 --- a/apps/common-app/src/new_api/components/touchable_stress/index.tsx +++ b/apps/common-app/src/new_api/components/touchable_stress/index.tsx @@ -1,6 +1,6 @@ import { Profiler, useCallback, useEffect, useRef, useState } from 'react'; -import { ScrollView, Touchable } from 'react-native-gesture-handler'; import { StyleSheet, Text, View } from 'react-native'; +import { ScrollView, Touchable } from 'react-native-gesture-handler'; const CLICK_COUNT = 2000; const N = 25; diff --git a/apps/common-app/src/new_api/hover_mouse/context_menu/index.tsx b/apps/common-app/src/new_api/hover_mouse/context_menu/index.tsx index 2e08a4640f..cc910bf4d8 100644 --- a/apps/common-app/src/new_api/hover_mouse/context_menu/index.tsx +++ b/apps/common-app/src/new_api/hover_mouse/context_menu/index.tsx @@ -1,11 +1,12 @@ +import React from 'react'; +import { StyleSheet, View } from 'react-native'; import { GestureDetector, MouseButton, usePanGesture, } from 'react-native-gesture-handler'; -import { StyleSheet, View } from 'react-native'; + import { COLORS } from '../../../common'; -import React from 'react'; export default function ContextMenuExample() { const p1 = usePanGesture({ mouseButton: MouseButton.RIGHT }); diff --git a/apps/common-app/src/new_api/hover_mouse/hover/index.tsx b/apps/common-app/src/new_api/hover_mouse/hover/index.tsx index fb1d589547..5bba254557 100644 --- a/apps/common-app/src/new_api/hover_mouse/hover/index.tsx +++ b/apps/common-app/src/new_api/hover_mouse/hover/index.tsx @@ -1,16 +1,17 @@ -import Animated, { - useAnimatedStyle, - useSharedValue, -} from 'react-native-reanimated'; -import { COLORS, Feedback, commonStyles } from '../../../common'; +import type { RefObject } from 'react'; +import React, { useRef } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { GestureDetector, HoverEffect, useHoverGesture, } from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; -import type { RefObject } from 'react'; +import Animated, { + useAnimatedStyle, + useSharedValue, +} from 'react-native-reanimated'; + +import { COLORS, commonStyles, Feedback } from '../../../common'; function useColoredHover( color: string, diff --git a/apps/common-app/src/new_api/hover_mouse/hoverable_icons/index.tsx b/apps/common-app/src/new_api/hover_mouse/hoverable_icons/index.tsx index a72824af06..302b3e5449 100644 --- a/apps/common-app/src/new_api/hover_mouse/hoverable_icons/index.tsx +++ b/apps/common-app/src/new_api/hover_mouse/hoverable_icons/index.tsx @@ -1,16 +1,17 @@ +import React from 'react'; +import { Platform, StyleSheet } from 'react-native'; +import { + GestureDetector, + HoverEffect, + useHoverGesture, +} from 'react-native-gesture-handler'; import Animated, { useAnimatedStyle, useFrameCallback, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { - GestureDetector, - HoverEffect, - useHoverGesture, -} from 'react-native-gesture-handler'; -import { Platform, StyleSheet } from 'react-native'; -import React from 'react'; + import { commonStyles } from '../../../common'; // eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires diff --git a/apps/common-app/src/new_api/hover_mouse/mouse_buttons/index.tsx b/apps/common-app/src/new_api/hover_mouse/mouse_buttons/index.tsx index 7f1b67830b..94f2f0cbd1 100644 --- a/apps/common-app/src/new_api/hover_mouse/mouse_buttons/index.tsx +++ b/apps/common-app/src/new_api/hover_mouse/mouse_buttons/index.tsx @@ -1,4 +1,5 @@ -import { COLORS, Feedback } from '../../../common'; +import React, { useRef } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { Directions, GestureDetector, @@ -9,8 +10,8 @@ import { usePanGesture, useTapGesture, } from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; + +import { COLORS, Feedback } from '../../../common'; export default function Buttons() { const feedbackRef = useRef<{ showMessage: (msg: string) => void }>(null); diff --git a/apps/common-app/src/new_api/hover_mouse/stylus_data/index.tsx b/apps/common-app/src/new_api/hover_mouse/stylus_data/index.tsx index f37a801376..cc738443e0 100644 --- a/apps/common-app/src/new_api/hover_mouse/stylus_data/index.tsx +++ b/apps/common-app/src/new_api/hover_mouse/stylus_data/index.tsx @@ -1,14 +1,13 @@ +import React from 'react'; +import { Image, StyleSheet, View } from 'react-native'; +import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; import Animated, { useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; -import { Image, StyleSheet, View } from 'react-native'; -import React from 'react'; -// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires -const GH = require('../../../common_assets/hoverable_icons/gh.png'); +import GH from '../../../common_assets/hoverable_icons/gh.png'; export default function StylusData() { const scaleFactor = useSharedValue(0); diff --git a/apps/common-app/src/new_api/index.tsx b/apps/common-app/src/new_api/index.tsx index 0ec788577c..65150c8d7a 100644 --- a/apps/common-app/src/new_api/index.tsx +++ b/apps/common-app/src/new_api/index.tsx @@ -1,45 +1,45 @@ -import AnimatedExample from './showcase/animated'; -import BottomSheetExample from './showcase/bottom_sheet'; -import ButtonUnderlayExample from './components/button_underlay'; -import ButtonsExample from './components/buttons'; +import type { ExamplesSection } from '../common'; +import EmptyExample from '../empty'; import CameraExample from './complicated/camera'; import ChatHeadsExample from './complicated/chat_heads'; -import ContextMenuExample from './hover_mouse/context_menu'; -import EmptyExample from '../empty'; -import type { ExamplesSection } from '../common'; +import LockExample from './complicated/lock'; +import VelocityExample from './complicated/velocity_test'; +import ButtonUnderlayExample from './components/button_underlay'; +import ButtonsExample from './components/buttons'; +import ReanimatedDrawerLayout from './components/drawer'; import FlatListExample from './components/flatlist'; -import FlingExample from './simple/fling'; -import HoverExample from './simple/hover'; +import ScrollViewExample from './components/scrollview'; +import Swipeable from './components/swipeable/index'; +import SwitchTextInputExample from './components/switchAndInput'; +import TouchableExample from './components/touchable'; +import TouchableStressExample from './components/touchable_stress'; +import ContextMenuExample from './hover_mouse/context_menu'; import HoverIconsExample from './hover_mouse/hover'; import HoverableIconsExample from './hover_mouse/hoverable_icons'; -import LockExample from './complicated/lock'; -import LongPressExample from './simple/longPress'; import MouseButtonsExample from './hover_mouse/mouse_buttons'; -import NestedPressablesExample from './tests/nestedPressables'; -import NestedRootViewExample from './tests/nestedRootView'; +import StylusDataExample from './hover_mouse/stylus_data'; +import AnimatedExample from './showcase/animated'; +import BottomSheetExample from './showcase/bottom_sheet'; import NestedTextExample from './showcase/nested_text/nested_text'; import OverlapExample from './showcase/overlap'; +import SharedValueExample from './showcase/shared_value'; +import StateManagerExample from './showcase/state_manager'; +import SvgExample from './showcase/svg'; +import TimerExample from './showcase/timer'; +import FlingExample from './simple/fling'; +import HoverExample from './simple/hover'; +import LongPressExample from './simple/longPress'; import PanExample from './simple/pan'; import PinchExample from './simple/pinch'; +import RotationExample from './simple/rotation'; +import TapExample from './simple/tap'; +import NestedPressablesExample from './tests/nestedPressables'; +import NestedRootViewExample from './tests/nestedRootView'; import PointerTypeExample from './tests/pointerType'; import PressableExample from './tests/pressable'; -import ReanimatedDrawerLayout from './components/drawer'; import ReattachingExample from './tests/reattaching'; import RectButtonExample from './tests/rectButton'; -import RotationExample from './simple/rotation'; -import ScrollViewExample from './components/scrollview'; -import SharedValueExample from './showcase/shared_value'; -import StateManagerExample from './showcase/state_manager'; -import StylusDataExample from './hover_mouse/stylus_data'; -import SvgExample from './showcase/svg'; -import Swipeable from './components/swipeable/index'; -import SwitchTextInputExample from './components/switchAndInput'; -import TapExample from './simple/tap'; -import TimerExample from './showcase/timer'; -import TouchableExample from './components/touchable'; -import TouchableStressExample from './components/touchable_stress'; import TwoFingerPanExample from './tests/twoFingerPan'; -import VelocityExample from './complicated/velocity_test'; import WebStylesResetExample from './tests/webStylesReset'; export const NEW_EXAMPLES: ExamplesSection[] = [ diff --git a/apps/common-app/src/new_api/showcase/animated/index.tsx b/apps/common-app/src/new_api/showcase/animated/index.tsx index bbd7f30a68..462b3da3b4 100644 --- a/apps/common-app/src/new_api/showcase/animated/index.tsx +++ b/apps/common-app/src/new_api/showcase/animated/index.tsx @@ -1,7 +1,8 @@ +import React, { useRef } from 'react'; import { Animated, Dimensions, StyleSheet, Text, View } from 'react-native'; -import { COLORS, commonStyles } from '../../../common'; import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; + +import { COLORS, commonStyles } from '../../../common'; const { width } = Dimensions.get('window'); diff --git a/apps/common-app/src/new_api/showcase/bottom_sheet/index.tsx b/apps/common-app/src/new_api/showcase/bottom_sheet/index.tsx index 3a6723511b..c295573fa5 100644 --- a/apps/common-app/src/new_api/showcase/bottom_sheet/index.tsx +++ b/apps/common-app/src/new_api/showcase/bottom_sheet/index.tsx @@ -1,11 +1,7 @@ -import Animated, { - runOnJS, - useAnimatedStyle, - useSharedValue, - withSpring, -} from 'react-native-reanimated'; -import { COLORS, LoremIpsum, commonStyles } from '../../../common'; +import React, { useState } from 'react'; +import type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native'; import { Dimensions, StyleSheet, View } from 'react-native'; +import type { PanGestureActiveEvent } from 'react-native-gesture-handler'; import { GestureDetector, useNativeGesture, @@ -13,9 +9,14 @@ import { useSimultaneousGestures, useTapGesture, } from 'react-native-gesture-handler'; -import type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native'; -import React, { useState } from 'react'; -import type { PanGestureActiveEvent } from 'react-native-gesture-handler'; +import Animated, { + runOnJS, + useAnimatedStyle, + useSharedValue, + withSpring, +} from 'react-native-reanimated'; + +import { COLORS, commonStyles, LoremIpsum } from '../../../common'; const HEADER_HEIGTH = 50; const windowHeight = Dimensions.get('window').height; diff --git a/apps/common-app/src/new_api/showcase/nested_text/nested_text.tsx b/apps/common-app/src/new_api/showcase/nested_text/nested_text.tsx index e199312a0d..2795916936 100644 --- a/apps/common-app/src/new_api/showcase/nested_text/nested_text.tsx +++ b/apps/common-app/src/new_api/showcase/nested_text/nested_text.tsx @@ -1,13 +1,14 @@ import * as React from 'react'; -import { COLORS, Feedback, commonStyles } from '../../../common'; +import { Text, View } from 'react-native'; import { Gesture, GestureDetector, InterceptingGestureDetector, - VirtualGestureDetector, useTapGesture, + VirtualGestureDetector, } from 'react-native-gesture-handler'; -import { Text, View } from 'react-native'; + +import { COLORS, commonStyles, Feedback } from '../../../common'; function NativeDetectorExample() { const feedbackRef = React.useRef<{ showMessage: (msg: string) => void }>( diff --git a/apps/common-app/src/new_api/showcase/overlap/index.tsx b/apps/common-app/src/new_api/showcase/overlap/index.tsx index 458a069761..b194c4a704 100644 --- a/apps/common-app/src/new_api/showcase/overlap/index.tsx +++ b/apps/common-app/src/new_api/showcase/overlap/index.tsx @@ -1,11 +1,12 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; +import React, { useRef } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; import { InterceptingGestureDetector, - VirtualGestureDetector, useTapGesture, + VirtualGestureDetector, } from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; + +import { COLORS, commonStyles, Feedback } from '../../../common'; function Box(props: { color: string; diff --git a/apps/common-app/src/new_api/showcase/shared_value/index.tsx b/apps/common-app/src/new_api/showcase/shared_value/index.tsx index f4129b363a..01f5fde635 100644 --- a/apps/common-app/src/new_api/showcase/shared_value/index.tsx +++ b/apps/common-app/src/new_api/showcase/shared_value/index.tsx @@ -1,18 +1,19 @@ +import React from 'react'; +import { Text, View } from 'react-native'; +import { + GestureDetector, + useLongPressGesture, + usePanGesture, + useSimultaneousGestures, +} from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { - GestureDetector, - useLongPressGesture, - usePanGesture, - useSimultaneousGestures, -} from 'react-native-gesture-handler'; -import { Text, View } from 'react-native'; -import React from 'react'; export default function PanExample() { const translateX = useSharedValue(0); diff --git a/apps/common-app/src/new_api/showcase/state_manager/index.tsx b/apps/common-app/src/new_api/showcase/state_manager/index.tsx index 7d020ec2b7..980550a569 100644 --- a/apps/common-app/src/new_api/showcase/state_manager/index.tsx +++ b/apps/common-app/src/new_api/showcase/state_manager/index.tsx @@ -1,18 +1,19 @@ -import Animated, { - useAnimatedStyle, - useSharedValue, - withTiming, -} from 'react-native-reanimated'; -import { COLORS, commonStyles } from '../../../common'; +import React from 'react'; +import { View } from 'react-native'; +import type { LongPressGesture } from 'react-native-gesture-handler'; import { GestureDetector, GestureHandlerRootView, GestureStateManager, useLongPressGesture, } from 'react-native-gesture-handler'; -import type { LongPressGesture } from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; +import Animated, { + useAnimatedStyle, + useSharedValue, + withTiming, +} from 'react-native-reanimated'; + +import { COLORS, commonStyles } from '../../../common'; export default function TwoPressables() { const isActivated = [ diff --git a/apps/common-app/src/new_api/showcase/svg/index.tsx b/apps/common-app/src/new_api/showcase/svg/index.tsx index 2a1b266abc..af5751156a 100644 --- a/apps/common-app/src/new_api/showcase/svg/index.tsx +++ b/apps/common-app/src/new_api/showcase/svg/index.tsx @@ -1,12 +1,13 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; +import React, { useRef } from 'react'; +import { View } from 'react-native'; import { InterceptingGestureDetector, - VirtualGestureDetector, useTapGesture, + VirtualGestureDetector, } from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; import Svg, { Circle, Rect } from 'react-native-svg'; -import { View } from 'react-native'; + +import { COLORS, commonStyles, Feedback } from '../../../common'; export default function LogicDetectorExample() { const feedbackRef = useRef<{ showMessage: (msg: string) => void }>(null); diff --git a/apps/common-app/src/new_api/showcase/timer/index.tsx b/apps/common-app/src/new_api/showcase/timer/index.tsx index 8514a85d65..1a73411963 100644 --- a/apps/common-app/src/new_api/showcase/timer/index.tsx +++ b/apps/common-app/src/new_api/showcase/timer/index.tsx @@ -1,21 +1,22 @@ +import React, { useRef } from 'react'; +import { StyleSheet, Text, TextInput, View } from 'react-native'; +import { + GestureDetector, + GestureHandlerRootView, + useLongPressGesture, +} from 'react-native-gesture-handler'; import Animated, { - Easing, cancelAnimation, + Easing, interpolateColor, useAnimatedProps, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { COLORS, Feedback, commonStyles } from '../../../common'; -import { - GestureDetector, - GestureHandlerRootView, - useLongPressGesture, -} from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; -import { StyleSheet, Text, TextInput, View } from 'react-native'; + import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; const AnimatedTextInput = Animated.createAnimatedComponent(TextInput); diff --git a/apps/common-app/src/new_api/simple/fling/index.tsx b/apps/common-app/src/new_api/simple/fling/index.tsx index 2520d99442..4229ff89d3 100644 --- a/apps/common-app/src/new_api/simple/fling/index.tsx +++ b/apps/common-app/src/new_api/simple/fling/index.tsx @@ -1,3 +1,10 @@ +import React from 'react'; +import { View } from 'react-native'; +import { + Directions, + GestureDetector, + useFlingGesture, +} from 'react-native-gesture-handler'; import Animated, { Easing, interpolateColor, @@ -5,14 +12,8 @@ import Animated, { useSharedValue, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { - Directions, - GestureDetector, - useFlingGesture, -} from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; export default function FlingExample() { const position = useSharedValue(0); diff --git a/apps/common-app/src/new_api/simple/hover/index.tsx b/apps/common-app/src/new_api/simple/hover/index.tsx index fc44ffa0cc..443cdf44dd 100644 --- a/apps/common-app/src/new_api/simple/hover/index.tsx +++ b/apps/common-app/src/new_api/simple/hover/index.tsx @@ -1,13 +1,14 @@ +import React from 'react'; +import { View } from 'react-native'; +import { GestureDetector, useHoverGesture } from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { GestureDetector, useHoverGesture } from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; export default function TapExample() { const colorProgress = useSharedValue(0); diff --git a/apps/common-app/src/new_api/simple/longPress/index.tsx b/apps/common-app/src/new_api/simple/longPress/index.tsx index b6e5a6ed1e..e0c3b56962 100644 --- a/apps/common-app/src/new_api/simple/longPress/index.tsx +++ b/apps/common-app/src/new_api/simple/longPress/index.tsx @@ -1,16 +1,17 @@ +import React from 'react'; +import { View } from 'react-native'; +import { + GestureDetector, + useLongPressGesture, +} from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { - GestureDetector, - useLongPressGesture, -} from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; export default function LongPressExample() { const colorProgress = useSharedValue(0); diff --git a/apps/common-app/src/new_api/simple/pan/index.tsx b/apps/common-app/src/new_api/simple/pan/index.tsx index fc5c5e3215..242fe17b95 100644 --- a/apps/common-app/src/new_api/simple/pan/index.tsx +++ b/apps/common-app/src/new_api/simple/pan/index.tsx @@ -1,13 +1,14 @@ +import React from 'react'; +import { View } from 'react-native'; +import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; export default function PanExample() { const translateX = useSharedValue(0); diff --git a/apps/common-app/src/new_api/simple/pinch/index.tsx b/apps/common-app/src/new_api/simple/pinch/index.tsx index 95fd78a159..49f31491fe 100644 --- a/apps/common-app/src/new_api/simple/pinch/index.tsx +++ b/apps/common-app/src/new_api/simple/pinch/index.tsx @@ -1,13 +1,14 @@ +import React from 'react'; +import { View } from 'react-native'; +import { GestureDetector, usePinchGesture } from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { GestureDetector, usePinchGesture } from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; export default function PinchExample() { const scale = useSharedValue(1); diff --git a/apps/common-app/src/new_api/simple/rotation/index.tsx b/apps/common-app/src/new_api/simple/rotation/index.tsx index e8aeac0491..8eb6360e9a 100644 --- a/apps/common-app/src/new_api/simple/rotation/index.tsx +++ b/apps/common-app/src/new_api/simple/rotation/index.tsx @@ -1,16 +1,17 @@ +import React from 'react'; +import { View } from 'react-native'; +import { + GestureDetector, + useRotationGesture, +} from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { - GestureDetector, - useRotationGesture, -} from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; export default function RotationExample() { const rotation = useSharedValue(0); diff --git a/apps/common-app/src/new_api/simple/tap/index.tsx b/apps/common-app/src/new_api/simple/tap/index.tsx index 1e96199425..37e329758c 100644 --- a/apps/common-app/src/new_api/simple/tap/index.tsx +++ b/apps/common-app/src/new_api/simple/tap/index.tsx @@ -1,13 +1,14 @@ +import React from 'react'; +import { View } from 'react-native'; +import { GestureDetector, useTapGesture } from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; + import { COLORS, commonStyles } from '../../../common'; -import { GestureDetector, useTapGesture } from 'react-native-gesture-handler'; -import React from 'react'; -import { View } from 'react-native'; export default function TapExample() { const colorProgress = useSharedValue(0); diff --git a/apps/common-app/src/new_api/tests/nestedPressables/index.tsx b/apps/common-app/src/new_api/tests/nestedPressables/index.tsx index dc85b69b7f..1094e2d98b 100644 --- a/apps/common-app/src/new_api/tests/nestedPressables/index.tsx +++ b/apps/common-app/src/new_api/tests/nestedPressables/index.tsx @@ -1,9 +1,10 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; -import { Pressable as RNPressable, StyleSheet, Text, View } from 'react-native'; import React, { useRef } from 'react'; -import type { FeedbackHandle } from '../../../common'; -import { Pressable } from 'react-native-gesture-handler'; import type { PressableStateCallbackType } from 'react-native'; +import { Pressable as RNPressable, StyleSheet, Text, View } from 'react-native'; +import { Pressable } from 'react-native-gesture-handler'; + +import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; export default function Example() { const feedbackRefRNGH = useRef(null); diff --git a/apps/common-app/src/new_api/tests/nestedRootView/index.tsx b/apps/common-app/src/new_api/tests/nestedRootView/index.tsx index 9dcb220a65..f8e7eeb7ec 100644 --- a/apps/common-app/src/new_api/tests/nestedRootView/index.tsx +++ b/apps/common-app/src/new_api/tests/nestedRootView/index.tsx @@ -1,18 +1,19 @@ import * as React from 'react'; -import Animated, { - useAnimatedStyle, - useSharedValue, -} from 'react-native-reanimated'; -import { COLORS, Feedback, commonStyles } from '../../../common'; +import { useRef, useState } from 'react'; +import { Modal, StyleSheet, Text, View } from 'react-native'; import { GestureDetector, GestureHandlerRootView, RectButton, usePanGesture, } from 'react-native-gesture-handler'; -import { Modal, StyleSheet, Text, View } from 'react-native'; -import { useRef, useState } from 'react'; +import Animated, { + useAnimatedStyle, + useSharedValue, +} from 'react-native-reanimated'; + import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; interface DraggableBoxProps { minDist?: number; diff --git a/apps/common-app/src/new_api/tests/pointerType/index.tsx b/apps/common-app/src/new_api/tests/pointerType/index.tsx index d798f317f9..f726dc3ca0 100644 --- a/apps/common-app/src/new_api/tests/pointerType/index.tsx +++ b/apps/common-app/src/new_api/tests/pointerType/index.tsx @@ -1,18 +1,19 @@ +import React, { useRef } from 'react'; +import { View } from 'react-native'; +import { + GestureDetector, + PointerType, + useLongPressGesture, +} from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { COLORS, Feedback, commonStyles } from '../../../common'; -import { - GestureDetector, - PointerType, - useLongPressGesture, -} from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; + import type { FeedbackHandle } from '../../../common'; -import { View } from 'react-native'; +import { COLORS, commonStyles, Feedback } from '../../../common'; const Colors = { Default: COLORS.NAVY, diff --git a/apps/common-app/src/new_api/tests/pressable/androidRipple.tsx b/apps/common-app/src/new_api/tests/pressable/androidRipple.tsx index 45ebf07966..8b1f20b766 100644 --- a/apps/common-app/src/new_api/tests/pressable/androidRipple.tsx +++ b/apps/common-app/src/new_api/tests/pressable/androidRipple.tsx @@ -1,7 +1,8 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; -import { Platform, View } from 'react-native'; import React, { useRef } from 'react'; +import { Platform, View } from 'react-native'; + import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; import TestingBase from './testingBase'; export function RippleExample() { diff --git a/apps/common-app/src/new_api/tests/pressable/delayedPress.tsx b/apps/common-app/src/new_api/tests/pressable/delayedPress.tsx index 2b290f24aa..94a6c545d4 100644 --- a/apps/common-app/src/new_api/tests/pressable/delayedPress.tsx +++ b/apps/common-app/src/new_api/tests/pressable/delayedPress.tsx @@ -1,13 +1,14 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; import React, { useRef } from 'react'; +import { View } from 'react-native'; import { useSharedValue, withSequence, withSpring, } from 'react-native-reanimated'; + import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; import TestingBase from './testingBase'; -import { View } from 'react-native'; const signalerConfig = { stiffness: 500, diff --git a/apps/common-app/src/new_api/tests/pressable/functionalStyles.tsx b/apps/common-app/src/new_api/tests/pressable/functionalStyles.tsx index d3e614bdbc..f7a79f8c13 100644 --- a/apps/common-app/src/new_api/tests/pressable/functionalStyles.tsx +++ b/apps/common-app/src/new_api/tests/pressable/functionalStyles.tsx @@ -1,9 +1,10 @@ -import { COLORS, commonStyles } from '../../../common'; -import type { PressableStateCallbackType } from 'react-native'; import React from 'react'; -import TestingBase from './testingBase'; +import type { PressableStateCallbackType } from 'react-native'; import { View } from 'react-native'; +import { COLORS, commonStyles } from '../../../common'; +import TestingBase from './testingBase'; + export function FunctionalStyleExample() { const functionalStyle = (state: PressableStateCallbackType) => { if (state.pressed) { diff --git a/apps/common-app/src/new_api/tests/pressable/hitSlop.tsx b/apps/common-app/src/new_api/tests/pressable/hitSlop.tsx index d2a472bc73..a17c66b7fe 100644 --- a/apps/common-app/src/new_api/tests/pressable/hitSlop.tsx +++ b/apps/common-app/src/new_api/tests/pressable/hitSlop.tsx @@ -1,7 +1,8 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; import React, { useRef } from 'react'; import { StyleSheet, Text, View } from 'react-native'; + import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; import TestingBase from './testingBase'; const HIT_SLOP = 40; diff --git a/apps/common-app/src/new_api/tests/pressable/hoverDelay.tsx b/apps/common-app/src/new_api/tests/pressable/hoverDelay.tsx index 0c44d0b0e6..178f9c6668 100644 --- a/apps/common-app/src/new_api/tests/pressable/hoverDelay.tsx +++ b/apps/common-app/src/new_api/tests/pressable/hoverDelay.tsx @@ -1,8 +1,9 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; import React, { useRef } from 'react'; +import { View } from 'react-native'; + import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; import TestingBase from './testingBase'; -import { View } from 'react-native'; export function DelayHoverExample() { const feedbackRef = useRef(null); diff --git a/apps/common-app/src/new_api/tests/pressable/index.tsx b/apps/common-app/src/new_api/tests/pressable/index.tsx index e5d4c8d2f0..6ee402356e 100644 --- a/apps/common-app/src/new_api/tests/pressable/index.tsx +++ b/apps/common-app/src/new_api/tests/pressable/index.tsx @@ -1,13 +1,14 @@ +import type { ReactNode } from 'react'; +import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { DelayHoverExample } from './hoverDelay'; +import { ScrollView } from 'react-native-gesture-handler'; + +import { commonStyles } from '../../../common'; +import { RippleExample } from './androidRipple'; import { DelayedPressExample } from './delayedPress'; import { FunctionalStyleExample } from './functionalStyles'; import { HitSlopExample } from './hitSlop'; -import React from 'react'; -import type { ReactNode } from 'react'; -import { RippleExample } from './androidRipple'; -import { ScrollView } from 'react-native-gesture-handler'; -import { commonStyles } from '../../../common'; +import { DelayHoverExample } from './hoverDelay'; type TestingEntryProps = { title: string; diff --git a/apps/common-app/src/new_api/tests/pressable/testingBase.tsx b/apps/common-app/src/new_api/tests/pressable/testingBase.tsx index 32fd855124..38efd96fb8 100644 --- a/apps/common-app/src/new_api/tests/pressable/testingBase.tsx +++ b/apps/common-app/src/new_api/tests/pressable/testingBase.tsx @@ -1,8 +1,9 @@ +import React from 'react'; +import type { PressableProps as RNPressableProps } from 'react-native'; import { Pressable, Text, View } from 'react-native'; import type { PressableProps as GHPressableProps } from 'react-native-gesture-handler'; import { Pressable as GesturizedPressable } from 'react-native-gesture-handler'; -import type { PressableProps as RNPressableProps } from 'react-native'; -import React from 'react'; + import { commonStyles } from '../../../common'; const TestingBase = (props: GHPressableProps & RNPressableProps) => ( diff --git a/apps/common-app/src/new_api/tests/reattaching/index.tsx b/apps/common-app/src/new_api/tests/reattaching/index.tsx index 7e8aa267c7..541cfc7726 100644 --- a/apps/common-app/src/new_api/tests/reattaching/index.tsx +++ b/apps/common-app/src/new_api/tests/reattaching/index.tsx @@ -1,8 +1,9 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; -import { GestureDetector, useTapGesture } from 'react-native-gesture-handler'; import React, { useRef, useState } from 'react'; import { StyleSheet, Text, View } from 'react-native'; +import { GestureDetector, useTapGesture } from 'react-native-gesture-handler'; + import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; export default function TapExample() { const [isTopActive, setIsTopActive] = useState(false); diff --git a/apps/common-app/src/new_api/tests/rectButton/index.tsx b/apps/common-app/src/new_api/tests/rectButton/index.tsx index 36ec8279b5..e7c8472495 100644 --- a/apps/common-app/src/new_api/tests/rectButton/index.tsx +++ b/apps/common-app/src/new_api/tests/rectButton/index.tsx @@ -1,10 +1,11 @@ -import { COLORS, Feedback, commonStyles } from '../../../common'; import React, { useRef } from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; import { StyleSheet, Text, View } from 'react-native'; -import type { FeedbackHandle } from '../../../common'; import { RectButton } from 'react-native-gesture-handler'; +import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; + export default function RectButtonBorders() { const feedbackRef = useRef(null); diff --git a/apps/common-app/src/new_api/tests/twoFingerPan/index.tsx b/apps/common-app/src/new_api/tests/twoFingerPan/index.tsx index 7093daf194..e5f717adb0 100644 --- a/apps/common-app/src/new_api/tests/twoFingerPan/index.tsx +++ b/apps/common-app/src/new_api/tests/twoFingerPan/index.tsx @@ -1,12 +1,13 @@ +import React, { useRef } from 'react'; +import { StyleSheet, View } from 'react-native'; +import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; import Animated, { useAnimatedStyle, useSharedValue, } from 'react-native-reanimated'; -import { Feedback, commonStyles } from '../../../common'; -import { GestureDetector, usePanGesture } from 'react-native-gesture-handler'; -import React, { useRef } from 'react'; -import { StyleSheet, View } from 'react-native'; + import type { FeedbackHandle } from '../../../common'; +import { commonStyles, Feedback } from '../../../common'; const BOX_SIZE = 270; diff --git a/apps/common-app/src/new_api/tests/webStylesReset/index.tsx b/apps/common-app/src/new_api/tests/webStylesReset/index.tsx index f0e9f590fb..74322ba3fa 100644 --- a/apps/common-app/src/new_api/tests/webStylesReset/index.tsx +++ b/apps/common-app/src/new_api/tests/webStylesReset/index.tsx @@ -1,18 +1,19 @@ +import React, { useRef, useState } from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +import { + GestureDetector, + Pressable, + usePanGesture, +} from 'react-native-gesture-handler'; import Animated, { interpolateColor, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; -import { COLORS, Feedback, commonStyles } from '../../../common'; -import { - GestureDetector, - Pressable, - usePanGesture, -} from 'react-native-gesture-handler'; -import React, { useRef, useState } from 'react'; -import { StyleSheet, Text, View } from 'react-native'; + import type { FeedbackHandle } from '../../../common'; +import { COLORS, commonStyles, Feedback } from '../../../common'; const Colors = { enabled: COLORS.GREEN, diff --git a/package.json b/package.json index 6c20730459..b3fa844676 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "eslint-plugin-jest": "27.4.3", "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-react": "^7.37.5", + "eslint-plugin-simple-import-sort": "^13.0.0", "husky": "^8.0.1", "jest": "^28.1.0", "lint-staged": "^12.3.2", diff --git a/packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts b/packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts index 9ee6253cb5..4bc5c4f3e5 100644 --- a/packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts +++ b/packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts @@ -1,11 +1,12 @@ -import type { Config, PropsRef } from './web/interfaces'; +import React from 'react'; + import type { ActionType } from './ActionType'; -import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate'; import type { GestureRelations } from './v3/types'; import { Gestures } from './web/Gestures'; +import type { Config, PropsRef } from './web/interfaces'; +import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate'; import InteractionManager from './web/tools/InteractionManager'; import NodeManager from './web/tools/NodeManager'; -import React from 'react'; // init method is called inside attachGestureHandler function. However, this function may // fail when received view is not valid HTML element. On the other hand, dropGestureHandler diff --git a/packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts b/packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts index 01f4a7a1a7..83e0bc70b5 100644 --- a/packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts +++ b/packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts @@ -1,14 +1,15 @@ +import type React from 'react'; + import type { ActionType } from './ActionType'; -import type { Config } from './web/interfaces'; import FlingGestureHandler from './web/handlers/FlingGestureHandler'; import LongPressGestureHandler from './web/handlers/LongPressGestureHandler'; import ManualGestureHandler from './web/handlers/ManualGestureHandler'; import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler'; import PanGestureHandler from './web/handlers/PanGestureHandler'; import PinchGestureHandler from './web/handlers/PinchGestureHandler'; -import type React from 'react'; import RotationGestureHandler from './web/handlers/RotationGestureHandler'; import TapGestureHandler from './web/handlers/TapGestureHandler'; +import type { Config } from './web/interfaces'; export const Gestures = { NativeViewGestureHandler, diff --git a/packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx b/packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx index 606cce5d8b..b242a8fe00 100644 --- a/packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx @@ -1,3 +1,7 @@ +import { cleanup, render } from '@testing-library/react-native'; +import React from 'react'; +import { findNodeHandle, View } from 'react-native'; + import { Gesture, GestureDetector, @@ -5,9 +9,6 @@ import { InterceptingGestureDetector, useTapGesture, } from '../index'; -import { View, findNodeHandle } from 'react-native'; -import { cleanup, render } from '@testing-library/react-native'; -import React from 'react'; import { VirtualDetector } from '../v3/detectors/VirtualDetector/VirtualDetector'; jest.mock('react-native-worklets', () => diff --git a/packages/react-native-gesture-handler/src/__tests__/Events.test.tsx b/packages/react-native-gesture-handler/src/__tests__/Events.test.tsx index e77d5c39ab..6944a92718 100644 --- a/packages/react-native-gesture-handler/src/__tests__/Events.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/Events.test.tsx @@ -1,21 +1,22 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ // Disabling lint for assymetric matchers, check proposal below // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/56937 +import { cleanup, render } from '@testing-library/react-native'; +import React from 'react'; +import { Text } from 'react-native'; + +import type { + LegacyPanGesture, + LegacyTapGesture, + PanGestureHandler, +} from '../index'; import { Gesture, GestureDetector, GestureHandlerRootView, State, } from '../index'; -import type { - LegacyPanGesture, - LegacyTapGesture, - PanGestureHandler, -} from '../index'; -import { cleanup, render } from '@testing-library/react-native'; import { fireGestureHandler, getByGestureTestId } from '../jestUtils'; -import React from 'react'; -import { Text } from 'react-native'; beforeEach(cleanup); diff --git a/packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx b/packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx index 83c8b17147..c13bc4902a 100644 --- a/packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx @@ -1,14 +1,15 @@ +import { renderHook } from '@testing-library/react-native'; + +import { tagMessage } from '../utils'; +import { configureRelations } from '../v3/detectors/utils'; import { useCompetingGestures, useExclusiveGestures, useSimultaneousGestures, } from '../v3/hooks/composition'; +import { useGesture } from '../v3/hooks/useGesture'; import type { SingleGesture } from '../v3/types'; import { SingleGestureName } from '../v3/types'; -import { configureRelations } from '../v3/detectors/utils'; -import { renderHook } from '@testing-library/react-native'; -import { tagMessage } from '../utils'; -import { useGesture } from '../v3/hooks/useGesture'; type AnySingleGesture = SingleGesture; diff --git a/packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx b/packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx index 52646749dc..5fad62018c 100644 --- a/packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx @@ -1,11 +1,12 @@ -import { RectButton, Touchable } from '../v3/components'; -import { fireGestureHandler, getByGestureTestId } from '../jestUtils'; import { render, renderHook } from '@testing-library/react-native'; +import { act } from 'react'; + import GestureHandlerRootView from '../components/GestureHandlerRootView'; -import type { SingleGesture } from '../v3/types'; +import { fireGestureHandler, getByGestureTestId } from '../jestUtils'; import { State } from '../State'; -import { act } from 'react'; +import { RectButton, Touchable } from '../v3/components'; import { usePanGesture } from '../v3/hooks/gestures'; +import type { SingleGesture } from '../v3/types'; describe('[API v3] Hooks', () => { test('Pan gesture', () => { diff --git a/packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx b/packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx index e4cf5807cf..48c5f074da 100644 --- a/packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx @@ -1,3 +1,8 @@ +import { fireEvent, render } from '@testing-library/react-native'; +import React from 'react'; +import { Text } from 'react-native'; + +import GestureHandlerRootView from '../components/GestureHandlerRootView'; import { LegacyBaseButton, LegacyBorderlessButton, @@ -12,17 +17,13 @@ import { LegacySwitch, LegacyTextInput, } from '../mocks/gestureComponents'; +import LegacyPressable from '../mocks/Pressable'; import { TouchableHighlight, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback, } from '../mocks/Touchables'; -import { fireEvent, render } from '@testing-library/react-native'; -import GestureHandlerRootView from '../components/GestureHandlerRootView'; -import LegacyPressable from '../mocks/Pressable'; -import React from 'react'; -import { Text } from 'react-native'; import { Touchable } from '../v3/components'; describe('Jest mocks – legacy components render without crashing', () => { diff --git a/packages/react-native-gesture-handler/src/components/GestureButtons.tsx b/packages/react-native-gesture-handler/src/components/GestureButtons.tsx index d47fb333cc..780ea2baad 100644 --- a/packages/react-native-gesture-handler/src/components/GestureButtons.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureButtons.tsx @@ -1,5 +1,14 @@ import * as React from 'react'; +import type { HostComponent } from 'react-native'; import { Animated, Platform, StyleSheet } from 'react-native'; + +import createNativeWrapper from '../handlers/createNativeWrapper'; +import type { + GestureEvent, + HandlerStateChangeEvent, +} from '../handlers/gestureHandlerCommon'; +import type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload'; +import { State } from '../State'; import type { BaseButtonWithRefProps, BorderlessButtonWithRefProps, @@ -9,15 +18,7 @@ import type { LegacyRectButtonProps, RectButtonWithRefProps, } from './GestureButtonsProps'; -import type { - GestureEvent, - HandlerStateChangeEvent, -} from '../handlers/gestureHandlerCommon'; import GestureHandlerButton from './GestureHandlerButton'; -import type { HostComponent } from 'react-native'; -import type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload'; -import { State } from '../State'; -import createNativeWrapper from '../handlers/createNativeWrapper'; /** * @deprecated use `RawButton` instead diff --git a/packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts b/packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts index 73502ad303..3f15a0044d 100644 --- a/packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts +++ b/packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts @@ -6,6 +6,7 @@ import type { StyleProp, ViewStyle, } from 'react-native'; + import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; /** diff --git a/packages/react-native-gesture-handler/src/components/GestureComponents.tsx b/packages/react-native-gesture-handler/src/components/GestureComponents.tsx index e35e70b0e0..91e7c8b5be 100644 --- a/packages/react-native-gesture-handler/src/components/GestureComponents.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureComponents.tsx @@ -1,10 +1,17 @@ -import * as React from 'react'; import type { ForwardedRef, PropsWithChildren, ReactElement, RefAttributes, } from 'react'; +import * as React from 'react'; +import type { + DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps, + FlatListProps as RNFlatListProps, + ScrollViewProps as RNScrollViewProps, + SwitchProps as RNSwitchProps, + TextInputProps as RNTextInputProps, +} from 'react-native'; import { DrawerLayoutAndroid as RNDrawerLayoutAndroid, FlatList as RNFlatList, @@ -13,15 +20,9 @@ import { Switch as RNSwitch, TextInput as RNTextInput, } from 'react-native'; -import type { - DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps, - FlatListProps as RNFlatListProps, - ScrollViewProps as RNScrollViewProps, - SwitchProps as RNSwitchProps, - TextInputProps as RNTextInputProps, -} from 'react-native'; -import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; + import createNativeWrapper from '../handlers/createNativeWrapper'; +import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; import { nativeViewProps } from '../handlers/NativeViewGestureHandler'; import { toArray } from '../utils'; diff --git a/packages/react-native-gesture-handler/src/components/GestureComponents.web.tsx b/packages/react-native-gesture-handler/src/components/GestureComponents.web.tsx index d986ce1f52..26a6871ed8 100644 --- a/packages/react-native-gesture-handler/src/components/GestureComponents.web.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureComponents.web.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import type { FlatListProps } from 'react-native'; import { FlatList as RNFlatList, ScrollView as RNScrollView, @@ -6,7 +7,7 @@ import { TextInput as RNTextInput, View, } from 'react-native'; -import type { FlatListProps } from 'react-native'; + import createNativeWrapper from '../handlers/createNativeWrapper'; /** diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx index f9c8008ccd..d2fa0ea62b 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx @@ -7,6 +7,7 @@ import type { ViewProps, ViewStyle, } from 'react-native'; + import RNGestureHandlerButtonNativeComponent from '../specs/RNGestureHandlerButtonNativeComponent'; export interface ButtonProps extends ViewProps, AccessibilityProps { diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.android.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.android.tsx index 4608841ce0..4871395167 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.android.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.android.tsx @@ -1,9 +1,10 @@ +import type { PropsWithChildren } from 'react'; import * as React from 'react'; +import { StyleSheet } from 'react-native'; + import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; -import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent'; -import type { PropsWithChildren } from 'react'; import type { RootViewNativeProps } from '../specs/RNGestureHandlerRootViewNativeComponent'; -import { StyleSheet } from 'react-native'; +import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent'; export interface GestureHandlerRootViewProps extends PropsWithChildren {} diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.tsx index 4ad7960544..77d1694512 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.tsx @@ -1,7 +1,8 @@ +import type { PropsWithChildren } from 'react'; import * as React from 'react'; import { StyleSheet, View } from 'react-native'; + import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; -import type { PropsWithChildren } from 'react'; import type { RootViewNativeProps } from '../specs/RNGestureHandlerRootViewNativeComponent'; export interface GestureHandlerRootViewProps diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.web.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.web.tsx index 63a13a5d00..1aeca94527 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.web.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.web.tsx @@ -1,8 +1,9 @@ +import type { PropsWithChildren } from 'react'; import * as React from 'react'; +import type { ViewProps } from 'react-native'; import { StyleSheet, View } from 'react-native'; + import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; -import type { PropsWithChildren } from 'react'; -import type { ViewProps } from 'react-native'; export interface GestureHandlerRootViewProps extends PropsWithChildren {} diff --git a/packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx b/packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx index a7e04c6b7f..cbc73c09b3 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx +++ b/packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx @@ -1,24 +1,33 @@ -import { INT32_MAX, isTestEnv } from '../../utils'; +import React, { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; import type { Insets, LayoutChangeEvent, StyleProp, ViewStyle, } from 'react-native'; +import { Platform } from 'react-native'; + +import { GestureDetector } from '../../handlers/gestures/GestureDetector'; +import { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects'; +import { PressabilityDebugView } from '../../handlers/PressabilityDebugView'; +import { useIsScreenReaderEnabled } from '../../useIsScreenReaderEnabled'; +import { INT32_MAX, isTestEnv } from '../../utils'; +import { ButtonComponent as NativeButton } from '../GestureHandlerButton'; +import type { RelationPropName, RelationPropType } from '../utils'; +import { applyRelationProp } from '../utils'; import type { LegacyPressableProps, PressableDimensions, PressableEvent, } from './PressableProps'; -import React, { - useCallback, - useEffect, - useMemo, - useRef, - useState, -} from 'react'; -import type { RelationPropName, RelationPropType } from '../utils'; -import { StateMachineEvent, getStatesConfig } from './stateDefinitions'; +import { getStatesConfig, StateMachineEvent } from './stateDefinitions'; +import { PressableStateMachine } from './StateMachine'; import { addInsets, gestureToPressableEvent, @@ -26,14 +35,6 @@ import { isTouchWithinInset, numberAsInset, } from './utils'; -import { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects'; -import { GestureDetector } from '../../handlers/gestures/GestureDetector'; -import { ButtonComponent as NativeButton } from '../GestureHandlerButton'; -import { Platform } from 'react-native'; -import { PressabilityDebugView } from '../../handlers/PressabilityDebugView'; -import { PressableStateMachine } from './StateMachine'; -import { applyRelationProp } from '../utils'; -import { useIsScreenReaderEnabled } from '../../useIsScreenReaderEnabled'; const DEFAULT_LONG_PRESS_DURATION = 500; const IS_TEST_ENV = isTestEnv(); diff --git a/packages/react-native-gesture-handler/src/components/Pressable/PressableProps.tsx b/packages/react-native-gesture-handler/src/components/Pressable/PressableProps.tsx index cf207e9e46..b47d29150a 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/PressableProps.tsx +++ b/packages/react-native-gesture-handler/src/components/Pressable/PressableProps.tsx @@ -8,6 +8,7 @@ import type { ViewProps, ViewStyle, } from 'react-native'; + import type { AnyGesture } from '../../v3/types'; import type { RelationPropType } from '../utils'; diff --git a/packages/react-native-gesture-handler/src/components/Pressable/index.ts b/packages/react-native-gesture-handler/src/components/Pressable/index.ts index 806a3719da..e7529bfd66 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/index.ts +++ b/packages/react-native-gesture-handler/src/components/Pressable/index.ts @@ -1,6 +1,6 @@ +export { default } from './Pressable'; export type { LegacyPressableProps, PressableProps, PressableStateCallbackType, } from './PressableProps'; -export { default } from './Pressable'; diff --git a/packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts b/packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts index e8e22d5525..47d75606cc 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts +++ b/packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts @@ -1,4 +1,5 @@ import { Platform } from 'react-native'; + import type { PressableEvent } from './PressableProps'; import type { StateDefinition } from './StateMachine'; diff --git a/packages/react-native-gesture-handler/src/components/Pressable/utils.ts b/packages/react-native-gesture-handler/src/components/Pressable/utils.ts index 5e1981579a..ec83e8b5d8 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/utils.ts +++ b/packages/react-native-gesture-handler/src/components/Pressable/utils.ts @@ -1,20 +1,21 @@ +import type { Insets } from 'react-native'; + import type { GestureStateChangeEvent, GestureTouchEvent, TouchData, } from '../../handlers/gestureHandlerCommon'; -import type { HoverGestureEvent, LongPressGestureEvent } from '../../v3'; import type { HoverGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, } from '../../handlers/GestureHandlerEventPayload'; +import type { HoverGestureEvent, LongPressGestureEvent } from '../../v3'; +import type { HoverGestureActiveEvent } from '../../v3/hooks'; import type { InnerPressableEvent, PressableDimensions, PressableEvent, } from './PressableProps'; -import type { HoverGestureActiveEvent } from '../../v3/hooks'; -import type { Insets } from 'react-native'; const numberAsInset = (value: number): Insets => ({ left: value, @@ -142,9 +143,9 @@ const gestureTouchToPressableEvent = ( }; export { - numberAsInset, addInsets, - isTouchWithinInset, gestureToPressableEvent, gestureTouchToPressableEvent, + isTouchWithinInset, + numberAsInset, }; diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx b/packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx index 6ae41896ef..d7cf572cc3 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx +++ b/packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx @@ -2,11 +2,29 @@ // It's cross-compatible with all platforms despite // `DrawerLayoutAndroid` only being available on android +import type { ReactNode } from 'react'; +import React, { + forwardRef, + useCallback, + useEffect, + useImperativeHandle, + useMemo, + useState, +} from 'react'; import type { - ActiveCursor, - HitSlop, - UserSelect, -} from '../handlers/gestureHandlerCommon'; + LayoutChangeEvent, + StatusBarAnimation, + StyleProp, + ViewStyle, +} from 'react-native'; +import { + I18nManager, + Keyboard, + Platform, + StatusBar, + StyleSheet, +} from 'react-native'; +import type { SharedValue } from 'react-native-reanimated'; import Animated, { Extrapolation, interpolate, @@ -17,33 +35,16 @@ import Animated, { useSharedValue, withSpring, } from 'react-native-reanimated'; -import { - I18nManager, - Keyboard, - Platform, - StatusBar, - StyleSheet, -} from 'react-native'; + import type { - LayoutChangeEvent, - StatusBarAnimation, - StyleProp, - ViewStyle, -} from 'react-native'; -import React, { - forwardRef, - useCallback, - useEffect, - useImperativeHandle, - useMemo, - useState, -} from 'react'; -import { usePanGesture, useTapGesture } from '../v3/hooks/gestures'; -import { GestureDetector } from '../v3/detectors'; + ActiveCursor, + HitSlop, + UserSelect, +} from '../handlers/gestureHandlerCommon'; import { MouseButton } from '../handlers/gestureHandlerCommon'; +import { GestureDetector } from '../v3/detectors'; import type { PanGestureActiveEvent } from '../v3/hooks/gestures'; -import type { ReactNode } from 'react'; -import type { SharedValue } from 'react-native-reanimated'; +import { usePanGesture, useTapGesture } from '../v3/hooks/gestures'; const DRAG_TOSS = 0.05; diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx index ac79b3df49..b73f18063a 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +++ b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx @@ -1,7 +1,11 @@ +import type { ForwardedRef } from 'react'; +import { useCallback, useImperativeHandle, useMemo } from 'react'; +import type { LayoutChangeEvent } from 'react-native'; +import { I18nManager, StyleSheet, View } from 'react-native'; import Animated, { - ReduceMotion, interpolate, measure, + ReduceMotion, runOnJS, runOnUI, useAnimatedRef, @@ -9,17 +13,14 @@ import Animated, { useSharedValue, withSpring, } from 'react-native-reanimated'; -import { I18nManager, StyleSheet, View } from 'react-native'; + +import { GestureDetector } from '../../v3/detectors'; +import type { PanGestureActiveEvent } from '../../v3/hooks/gestures'; +import { usePanGesture, useTapGesture } from '../../v3/hooks/gestures'; import type { SwipeableMethods, SwipeableProps, } from './ReanimatedSwipeableProps'; -import { useCallback, useImperativeHandle, useMemo } from 'react'; -import { usePanGesture, useTapGesture } from '../../v3/hooks/gestures'; -import type { ForwardedRef } from 'react'; -import { GestureDetector } from '../../v3/detectors'; -import type { LayoutChangeEvent } from 'react-native'; -import type { PanGestureActiveEvent } from '../../v3/hooks/gestures'; import { SwipeDirection } from './ReanimatedSwipeableProps'; const DRAG_TOSS = 0.05; diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts index 359155741f..f12182602e 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +++ b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts @@ -1,9 +1,10 @@ -import type { StyleProp, ViewStyle } from 'react-native'; -import type { AnyGesture } from '../../v3/types'; -import type { HitSlop } from '../../handlers/gestureHandlerCommon'; import type React from 'react'; +import type { StyleProp, ViewStyle } from 'react-native'; import type { SharedValue } from 'react-native-reanimated'; +import type { HitSlop } from '../../handlers/gestureHandlerCommon'; +import type { AnyGesture } from '../../v3/types'; + export enum SwipeDirection { LEFT = 'left', RIGHT = 'right', diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/index.ts b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/index.ts index e63e6014e3..12f4e54077 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/index.ts +++ b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/index.ts @@ -1,6 +1,6 @@ +export { default } from './ReanimatedSwipeable'; export { - type SwipeableProps, type SwipeableMethods, + type SwipeableProps, SwipeDirection, } from './ReanimatedSwipeableProps'; -export { default } from './ReanimatedSwipeable'; diff --git a/packages/react-native-gesture-handler/src/components/Text.tsx b/packages/react-native-gesture-handler/src/components/Text.tsx index e3e98c0647..8a400cc319 100644 --- a/packages/react-native-gesture-handler/src/components/Text.tsx +++ b/packages/react-native-gesture-handler/src/components/Text.tsx @@ -1,9 +1,10 @@ import type { ComponentRef, Ref } from 'react'; -import { Platform, Text as RNText } from 'react-native'; import React, { useEffect, useMemo, useRef } from 'react'; -import { GestureObjects as Gesture } from '../handlers/gestures/gestureObjects'; -import { GestureDetector } from '../handlers/gestures/GestureDetector'; import type { TextProps as RNTextProps } from 'react-native'; +import { Platform, Text as RNText } from 'react-native'; + +import { GestureDetector } from '../handlers/gestures/GestureDetector'; +import { GestureObjects as Gesture } from '../handlers/gestures/gestureObjects'; type TextProps = RNTextProps & { ref?: Ref | null>; diff --git a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx index 4b73733aab..22dfd99654 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx @@ -1,14 +1,15 @@ import * as React from 'react'; +import { Component } from 'react'; import { Animated, Platform } from 'react-native'; + import type { GestureEvent, HandlerStateChangeEvent, } from '../../handlers/gestureHandlerCommon'; -import { Component } from 'react'; -import type { GenericTouchableProps } from './GenericTouchableProps'; -import { LegacyBaseButton } from '../GestureButtons'; import type { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload'; import { State } from '../../State'; +import { LegacyBaseButton } from '../GestureButtons'; +import type { GenericTouchableProps } from './GenericTouchableProps'; /** * Each touchable is a states' machine which preforms transitions. diff --git a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts index ee75e9185b..b42f51792a 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts +++ b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts @@ -4,8 +4,9 @@ import type { TouchableWithoutFeedbackProps, ViewStyle, } from 'react-native'; -import type { ExtraButtonProps } from './ExtraButtonProps'; + import type { UserSelect } from '../../handlers/gestureHandlerCommon'; +import type { ExtraButtonProps } from './ExtraButtonProps'; export interface GenericTouchableProps extends Omit { diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableHighlight.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableHighlight.tsx index 869480a9ef..9e4212aeef 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableHighlight.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableHighlight.tsx @@ -1,12 +1,13 @@ import * as React from 'react'; +import { Component } from 'react'; import type { ColorValue, TouchableHighlightProps as RNTouchableHighlightProps, ViewProps, } from 'react-native'; -import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; import { StyleSheet, View } from 'react-native'; -import { Component } from 'react'; + +import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; import type { GenericTouchableProps } from './GenericTouchableProps'; interface State { diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx index 5eb9e47e20..c7fe803743 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx @@ -1,12 +1,13 @@ import * as React from 'react'; +import { Component } from 'react'; +import type { ColorValue } from 'react-native'; +import { Platform } from 'react-native'; + +import GenericTouchable from './GenericTouchable'; import type { TouchableNativeFeedbackExtraProps, TouchableNativeFeedbackProps, } from './TouchableNativeFeedbackProps'; -import type { ColorValue } from 'react-native'; -import { Component } from 'react'; -import GenericTouchable from './GenericTouchable'; -import { Platform } from 'react-native'; /** * @deprecated TouchableNativeFeedback will be removed in the future version of Gesture Handler. Use Pressable instead. diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedbackProps.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedbackProps.tsx index 7e3801a9c7..3ac2365477 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedbackProps.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedbackProps.tsx @@ -1,6 +1,7 @@ +import type { TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps } from 'react-native'; + import type { ExtraButtonProps } from './ExtraButtonProps'; import type { GenericTouchableProps } from './GenericTouchableProps'; -import type { TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps } from 'react-native'; export type TouchableNativeFeedbackExtraProps = ExtraButtonProps; /** diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableOpacity.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableOpacity.tsx index c7615ddf54..ad82ea1b78 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableOpacity.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableOpacity.tsx @@ -1,9 +1,10 @@ import * as React from 'react'; +import { Component } from 'react'; +import type { TouchableOpacityProps as RNTouchableOpacityProps } from 'react-native'; import { Animated, Easing, StyleSheet, View } from 'react-native'; + import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; -import { Component } from 'react'; import type { GenericTouchableProps } from './GenericTouchableProps'; -import type { TouchableOpacityProps as RNTouchableOpacityProps } from 'react-native'; /** * @deprecated TouchableOpacity will be removed in the future version of Gesture Handler. Use Pressable instead. diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableWithoutFeedback.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableWithoutFeedback.tsx index 04c97b0666..6082b7537d 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableWithoutFeedback.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableWithoutFeedback.tsx @@ -1,7 +1,8 @@ +import type { PropsWithChildren } from 'react'; import * as React from 'react'; + import GenericTouchable from './GenericTouchable'; import type { GenericTouchableProps } from './GenericTouchableProps'; -import type { PropsWithChildren } from 'react'; /** * @deprecated TouchableWithoutFeedback will be removed in the future version of Gesture Handler. Use Pressable instead. diff --git a/packages/react-native-gesture-handler/src/components/touchables/index.ts b/packages/react-native-gesture-handler/src/components/touchables/index.ts index e1cc502c7e..490f484f49 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/index.ts +++ b/packages/react-native-gesture-handler/src/components/touchables/index.ts @@ -1,7 +1,7 @@ export type { TouchableHighlightProps } from './TouchableHighlight'; +export { default as TouchableHighlight } from './TouchableHighlight'; +export { default as TouchableNativeFeedback } from './TouchableNativeFeedback'; export type { TouchableOpacityProps } from './TouchableOpacity'; +export { default as TouchableOpacity } from './TouchableOpacity'; export type { TouchableWithoutFeedbackProps } from './TouchableWithoutFeedback'; -export { default as TouchableNativeFeedback } from './TouchableNativeFeedback'; export { default as TouchableWithoutFeedback } from './TouchableWithoutFeedback'; -export { default as TouchableOpacity } from './TouchableOpacity'; -export { default as TouchableHighlight } from './TouchableHighlight'; diff --git a/packages/react-native-gesture-handler/src/findNodeHandle.web.ts b/packages/react-native-gesture-handler/src/findNodeHandle.web.ts index 26b8543640..7a6c1d70b8 100644 --- a/packages/react-native-gesture-handler/src/findNodeHandle.web.ts +++ b/packages/react-native-gesture-handler/src/findNodeHandle.web.ts @@ -1,5 +1,6 @@ -import type { GestureHandlerRef, SVGRef } from './web/interfaces'; import { FlatList } from 'react-native'; + +import type { GestureHandlerRef, SVGRef } from './web/interfaces'; import { isRNSVGElement } from './web/utils'; export default function findNodeHandle( diff --git a/packages/react-native-gesture-handler/src/handlers/FlingGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/FlingGestureHandler.ts index 4cfd4cc66b..1f98ad4d59 100644 --- a/packages/react-native-gesture-handler/src/handlers/FlingGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/FlingGestureHandler.ts @@ -1,7 +1,7 @@ +import createHandler from './createHandler'; import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; -import type { FlingGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import { baseGestureHandlerProps } from './gestureHandlerCommon'; -import createHandler from './createHandler'; +import type { FlingGestureHandlerEventPayload } from './GestureHandlerEventPayload'; export const flingGestureHandlerProps = [ 'numberOfPointers', diff --git a/packages/react-native-gesture-handler/src/handlers/ForceTouchGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/ForceTouchGestureHandler.ts index 22c12297d8..0e5e091a86 100644 --- a/packages/react-native-gesture-handler/src/handlers/ForceTouchGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/ForceTouchGestureHandler.ts @@ -1,11 +1,12 @@ -import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; -import type { ForceTouchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; -import PlatformConstants from '../PlatformConstants'; import type { PropsWithChildren } from 'react'; import React from 'react'; -import { baseGestureHandlerProps } from './gestureHandlerCommon'; -import createHandler from './createHandler'; + +import PlatformConstants from '../PlatformConstants'; import { tagMessage } from '../utils'; +import createHandler from './createHandler'; +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; +import type { ForceTouchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; export const forceTouchGestureHandlerProps = [ 'minForce', diff --git a/packages/react-native-gesture-handler/src/handlers/LongPressGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/LongPressGestureHandler.ts index 79f32547d7..6a1f54b37e 100644 --- a/packages/react-native-gesture-handler/src/handlers/LongPressGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/LongPressGestureHandler.ts @@ -1,7 +1,7 @@ +import createHandler from './createHandler'; import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; -import type { LongPressGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import { baseGestureHandlerProps } from './gestureHandlerCommon'; -import createHandler from './createHandler'; +import type { LongPressGestureHandlerEventPayload } from './GestureHandlerEventPayload'; export const longPressGestureHandlerProps = [ 'minDurationMs', diff --git a/packages/react-native-gesture-handler/src/handlers/NativeViewGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/NativeViewGestureHandler.ts index dac7e67186..002b865be0 100644 --- a/packages/react-native-gesture-handler/src/handlers/NativeViewGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/NativeViewGestureHandler.ts @@ -1,7 +1,7 @@ +import createHandler from './createHandler'; import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; -import type { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload'; import { baseGestureHandlerProps } from './gestureHandlerCommon'; -import createHandler from './createHandler'; +import type { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload'; export const nativeViewGestureHandlerProps = [ 'shouldActivateOnStart', diff --git a/packages/react-native-gesture-handler/src/handlers/PanGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/PanGestureHandler.ts index 69d89164e0..19aced91d3 100644 --- a/packages/react-native-gesture-handler/src/handlers/PanGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/PanGestureHandler.ts @@ -1,7 +1,7 @@ +import createHandler from './createHandler'; import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; -import type { PanGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import { baseGestureHandlerProps } from './gestureHandlerCommon'; -import createHandler from './createHandler'; +import type { PanGestureHandlerEventPayload } from './GestureHandlerEventPayload'; export const panGestureHandlerProps = [ 'activeOffsetY', diff --git a/packages/react-native-gesture-handler/src/handlers/PinchGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/PinchGestureHandler.ts index b2dd6b00a3..6567c967d3 100644 --- a/packages/react-native-gesture-handler/src/handlers/PinchGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/PinchGestureHandler.ts @@ -1,7 +1,7 @@ +import createHandler from './createHandler'; import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; -import type { PinchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import { baseGestureHandlerProps } from './gestureHandlerCommon'; -import createHandler from './createHandler'; +import type { PinchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; /** * @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead. diff --git a/packages/react-native-gesture-handler/src/handlers/RotationGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/RotationGestureHandler.ts index 82eec4629f..6f4abdc596 100644 --- a/packages/react-native-gesture-handler/src/handlers/RotationGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/RotationGestureHandler.ts @@ -1,7 +1,7 @@ +import createHandler from './createHandler'; import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; -import type { RotationGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import { baseGestureHandlerProps } from './gestureHandlerCommon'; -import createHandler from './createHandler'; +import type { RotationGestureHandlerEventPayload } from './GestureHandlerEventPayload'; /** * @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead. diff --git a/packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts index 5234ceed47..c6816bcec9 100644 --- a/packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts @@ -1,7 +1,7 @@ +import createHandler from './createHandler'; import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; -import type { TapGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import { baseGestureHandlerProps } from './gestureHandlerCommon'; -import createHandler from './createHandler'; +import type { TapGestureHandlerEventPayload } from './GestureHandlerEventPayload'; export const tapGestureHandlerProps = [ 'maxDurationMs', diff --git a/packages/react-native-gesture-handler/src/handlers/createHandler.tsx b/packages/react-native-gesture-handler/src/handlers/createHandler.tsx index a56e089428..621e0395b0 100644 --- a/packages/react-native-gesture-handler/src/handlers/createHandler.tsx +++ b/packages/react-native-gesture-handler/src/handlers/createHandler.tsx @@ -1,30 +1,31 @@ +import type { ReactElement } from 'react'; import * as React from 'react'; +import type { EmitterSubscription } from 'react-native'; +import { DeviceEventEmitter, Platform } from 'react-native'; + +import { ActionType } from '../ActionType'; +import findNodeHandle from '../findNodeHandle'; +import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; +import { ghQueueMicrotask } from '../ghQueueMicrotask'; +import { MountRegistry } from '../mountRegistry'; +import RNGestureHandlerModule from '../RNGestureHandlerModule'; +import { State } from '../State'; +import type { ValueOf } from '../typeUtils'; +import { deepEqual, isTestEnv, tagMessage } from '../utils'; +import { customDirectEventTypes } from './customDirectEventTypes'; import type { BaseGestureHandlerProps, GestureEvent, HandlerStateChangeEvent, } from './gestureHandlerCommon'; -import { DeviceEventEmitter, Platform } from 'react-native'; -import { deepEqual, isTestEnv, tagMessage } from '../utils'; -import { filterConfig, scheduleFlushOperations } from './utils'; +import { getNextHandlerTag } from './getNextHandlerTag'; import { handlerIDToTag, registerOldGestureHandler, unregisterOldGestureHandler, } from './handlersRegistry'; -import { ActionType } from '../ActionType'; -import type { EmitterSubscription } from 'react-native'; -import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; -import { MountRegistry } from '../mountRegistry'; import { PressabilityDebugView } from './PressabilityDebugView'; -import RNGestureHandlerModule from '../RNGestureHandlerModule'; -import type { ReactElement } from 'react'; -import { State } from '../State'; -import type { ValueOf } from '../typeUtils'; -import { customDirectEventTypes } from './customDirectEventTypes'; -import findNodeHandle from '../findNodeHandle'; -import { getNextHandlerTag } from './getNextHandlerTag'; -import { ghQueueMicrotask } from '../ghQueueMicrotask'; +import { filterConfig, scheduleFlushOperations } from './utils'; customDirectEventTypes.topGestureHandlerEvent = { registrationName: 'onGestureHandlerEvent', diff --git a/packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx b/packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx index 94082ec595..c76fb63b5e 100644 --- a/packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx +++ b/packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx @@ -1,10 +1,11 @@ import * as React from 'react'; +import { useImperativeHandle, useRef } from 'react'; + +import type { NativeViewGestureHandlerProps } from './NativeViewGestureHandler'; import { NativeViewGestureHandler, nativeViewProps, } from './NativeViewGestureHandler'; -import { useImperativeHandle, useRef } from 'react'; -import type { NativeViewGestureHandlerProps } from './NativeViewGestureHandler'; /* * This array should consist of: diff --git a/packages/react-native-gesture-handler/src/handlers/gestureHandlerCommon.ts b/packages/react-native-gesture-handler/src/handlers/gestureHandlerCommon.ts index bc29bc704c..c7c0e946e9 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestureHandlerCommon.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestureHandlerCommon.ts @@ -3,6 +3,7 @@ // e.g. React.createRef -> React.createRef. // See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference. import type * as React from 'react'; + import type { PointerType } from '../PointerType'; import type { State } from '../State'; import type { TouchEventType } from '../TouchEventType'; diff --git a/packages/react-native-gesture-handler/src/handlers/gestureHandlerTypesCompat.ts b/packages/react-native-gesture-handler/src/handlers/gestureHandlerTypesCompat.ts index 022a70261d..c61d2dc52a 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestureHandlerTypesCompat.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestureHandlerTypesCompat.ts @@ -1,3 +1,17 @@ +import type { + LegacyBaseButtonProps, + LegacyBorderlessButtonProps, + LegacyRawButtonProps, + LegacyRectButtonProps, +} from '../components/GestureButtonsProps'; +import type { FlingGestureHandlerProps } from './FlingGestureHandler'; +import type { ForceTouchGestureHandlerProps } from './ForceTouchGestureHandler'; +import type { + GestureEvent, + GestureEventPayload, + HandlerStateChangeEvent, + HandlerStateChangeEventPayload, +} from './gestureHandlerCommon'; import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, @@ -8,20 +22,6 @@ import type { RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, } from './GestureHandlerEventPayload'; -import type { - GestureEvent, - GestureEventPayload, - HandlerStateChangeEvent, - HandlerStateChangeEventPayload, -} from './gestureHandlerCommon'; -import type { - LegacyBaseButtonProps, - LegacyBorderlessButtonProps, - LegacyRawButtonProps, - LegacyRectButtonProps, -} from '../components/GestureButtonsProps'; -import type { FlingGestureHandlerProps } from './FlingGestureHandler'; -import type { ForceTouchGestureHandlerProps } from './ForceTouchGestureHandler'; import type { LongPressGestureHandlerProps } from './LongPressGestureHandler'; import type { NativeViewGestureHandlerProps } from './NativeViewGestureHandler'; import type { PanGestureHandlerProps } from './PanGestureHandler'; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.tsx b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.tsx index a5a203e750..e0c151bd6f 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.tsx +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.tsx @@ -1,6 +1,7 @@ import React from 'react'; -import { Reanimated } from '../reanimatedWrapper'; + import { tagMessage } from '../../../utils'; +import { Reanimated } from '../reanimatedWrapper'; export class Wrap extends React.Component<{ onGestureHandlerEvent?: unknown; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx index 6945950d84..66604a9386 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx @@ -1,7 +1,8 @@ import type { LegacyRef, PropsWithChildren } from 'react'; import React, { forwardRef } from 'react'; -import { isRNSVGNode } from '../../../web/utils'; + import { tagMessage } from '../../../utils'; +import { isRNSVGNode } from '../../../web/utils'; export const Wrap = forwardRef>( ({ children }, ref) => { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts index 948f5034f9..6d7358726b 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts @@ -1,21 +1,22 @@ -import { - ALLOWED_PROPS, - checkGestureCallbacksForWorklets, - extractGestureRelations, -} from './utils'; -import type { GestureType, HandlerCallbacks } from '../gesture'; -import { filterConfig, scheduleFlushOperations } from '../../utils'; +import type React from 'react'; +import { Platform } from 'react-native'; + import { ActionType } from '../../../ActionType'; -import type { AttachedGestureState } from './types'; -import type { ComposedGesture } from '../gestureComposition'; +import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; import { MountRegistry } from '../../../mountRegistry'; -import { Platform } from 'react-native'; -import type { PropsRef } from '../../../web/interfaces'; import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; import type RNGestureHandlerModuleWeb from '../../../RNGestureHandlerModule.web'; -import type React from 'react'; -import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; +import type { PropsRef } from '../../../web/interfaces'; import { registerHandler } from '../../handlersRegistry'; +import { filterConfig, scheduleFlushOperations } from '../../utils'; +import type { GestureType, HandlerCallbacks } from '../gesture'; +import type { ComposedGesture } from '../gestureComposition'; +import type { AttachedGestureState } from './types'; +import { + ALLOWED_PROPS, + checkGestureCallbacksForWorklets, + extractGestureRelations, +} from './utils'; interface AttachHandlersConfig { preparedGesture: AttachedGestureState; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/dropHandlers.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/dropHandlers.ts index 29be682f96..15bf9fbf69 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/dropHandlers.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/dropHandlers.ts @@ -1,8 +1,8 @@ -import type { AttachedGestureState } from './types'; import { MountRegistry } from '../../../mountRegistry'; import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; -import { scheduleFlushOperations } from '../../utils'; import { unregisterHandler } from '../../handlersRegistry'; +import { scheduleFlushOperations } from '../../utils'; +import type { AttachedGestureState } from './types'; export function dropHandlers(preparedGesture: AttachedGestureState) { for (const handler of preparedGesture.attachedGestures) { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx index 351347f1ea..e86392146e 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx @@ -1,20 +1,21 @@ /* eslint-disable react/no-unused-prop-types */ -import { AnimatedWrap, Wrap } from './Wrap'; -import type { AttachedGestureState, GestureDetectorState } from './types'; import React, { useEffect, useMemo, useRef } from 'react'; + +import findNodeHandle from '../../../findNodeHandle'; +import { useIsomorphicLayoutEffect } from '../../../useIsomorphicLayoutEffect'; import type { TouchAction, UserSelect } from '../../gestureHandlerCommon'; -import type { ComposedGesture } from '../gestureComposition'; import type { GestureType } from '../gesture'; +import type { ComposedGesture } from '../gestureComposition'; import { attachHandlers } from './attachHandlers'; import { dropHandlers } from './dropHandlers'; -import findNodeHandle from '../../../findNodeHandle'; import { needsToReattach } from './needsToReattach'; +import type { AttachedGestureState, GestureDetectorState } from './types'; import { useAnimatedGesture } from './useAnimatedGesture'; import { useDetectorUpdater } from './useDetectorUpdater'; -import { useIsomorphicLayoutEffect } from '../../../useIsomorphicLayoutEffect'; import { useMountReactions } from './useMountReactions'; import { useViewRefHandler } from './useViewRefHandler'; import { useWebEventHandlers } from './utils'; +import { AnimatedWrap, Wrap } from './Wrap'; function propagateDetectorConfig( props: GestureDetectorProps, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/needsToReattach.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/needsToReattach.ts index 942adc3fa2..0a647709e2 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/needsToReattach.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/needsToReattach.ts @@ -1,5 +1,5 @@ -import type { AttachedGestureState } from './types'; import type { GestureType } from '../gesture'; +import type { AttachedGestureState } from './types'; // Checks whether the gesture should be reattached to the view, this will happen when: // - The number of gestures in the preparedGesture is different than the number of gestures in the gesture diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/types.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/types.ts index e887ab2551..0ed7d805d2 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/types.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/types.ts @@ -1,5 +1,5 @@ -import type { GestureType, HandlerCallbacks } from '../gesture'; import type { SharedValue } from '../../../v3/types'; +import type { GestureType, HandlerCallbacks } from '../gesture'; export interface AttachedGestureState { // Array of gestures that should be attached to the view under that gesture detector diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/updateHandlers.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/updateHandlers.ts index d435d11369..a26739a127 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/updateHandlers.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/updateHandlers.ts @@ -1,15 +1,15 @@ +import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; +import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; +import { registerHandler } from '../../handlersRegistry'; +import { filterConfig, scheduleFlushOperations } from '../../utils'; +import type { GestureType, HandlerCallbacks } from '../gesture'; +import type { ComposedGesture } from '../gestureComposition'; +import type { AttachedGestureState } from './types'; import { ALLOWED_PROPS, checkGestureCallbacksForWorklets, extractGestureRelations, } from './utils'; -import type { GestureType, HandlerCallbacks } from '../gesture'; -import { filterConfig, scheduleFlushOperations } from '../../utils'; -import type { AttachedGestureState } from './types'; -import type { ComposedGesture } from '../gestureComposition'; -import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; -import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; -import { registerHandler } from '../../handlersRegistry'; export function updateHandlers( preparedGesture: AttachedGestureState, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts index 4900b2cae3..3ebfbd4b78 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts @@ -1,17 +1,17 @@ +import { State } from '../../../State'; +import { TouchEventType } from '../../../TouchEventType'; +import { tagMessage } from '../../../utils'; import type { GestureStateChangeEvent, GestureTouchEvent, GestureUpdateEvent, } from '../../gestureHandlerCommon'; -import type { AttachedGestureState } from './types'; +import type { HandlerCallbacks } from '../gesture'; import { CALLBACK_TYPE } from '../gesture'; -import { GestureStateManager } from '../gestureStateManager'; import type { GestureStateManagerType } from '../gestureStateManager'; -import type { HandlerCallbacks } from '../gesture'; +import { GestureStateManager } from '../gestureStateManager'; import { Reanimated } from '../reanimatedWrapper'; -import { State } from '../../../State'; -import { TouchEventType } from '../../../TouchEventType'; -import { tagMessage } from '../../../utils'; +import type { AttachedGestureState } from './types'; function getHandler( type: CALLBACK_TYPE, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts index 51bdb29854..d15877fd5d 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts @@ -1,15 +1,16 @@ -import type { AttachedGestureState, GestureDetectorState } from './types'; -import { useForceRender, validateDetectorChildren } from './utils'; -import type { ComposedGesture } from '../gestureComposition'; -import type { GestureType } from '../gesture'; -import type { PropsRef } from '../../../web/interfaces'; import type React from 'react'; +import { useCallback } from 'react'; + +import findNodeHandle from '../../../findNodeHandle'; +import type { PropsRef } from '../../../web/interfaces'; +import type { GestureType } from '../gesture'; +import type { ComposedGesture } from '../gestureComposition'; import { attachHandlers } from './attachHandlers'; import { dropHandlers } from './dropHandlers'; -import findNodeHandle from '../../../findNodeHandle'; import { needsToReattach } from './needsToReattach'; +import type { AttachedGestureState, GestureDetectorState } from './types'; import { updateHandlers } from './updateHandlers'; -import { useCallback } from 'react'; +import { useForceRender, validateDetectorChildren } from './utils'; // Returns a function that's responsible for updating the attached gestures // If the view has changed, it will reattach the handlers to the new view diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts index a34c0409e0..84732ddbb1 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts @@ -1,8 +1,9 @@ -import type { AttachedGestureState } from './types'; -import type { GestureRef } from '../gesture'; +import { useEffect } from 'react'; + import { MountRegistry } from '../../../mountRegistry'; import { transformIntoHandlerTags } from '../../utils'; -import { useEffect } from 'react'; +import type { GestureRef } from '../gesture'; +import type { AttachedGestureState } from './types'; function shouldUpdateDetector( relation: GestureRef[] | undefined, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useViewRefHandler.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useViewRefHandler.ts index 1282fcc747..61db2f7427 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useViewRefHandler.ts @@ -1,9 +1,10 @@ -import type { GestureDetectorState } from './types'; import type React from 'react'; +import { useCallback } from 'react'; + import findNodeHandle from '../../../findNodeHandle'; import { getShadowNodeFromRef } from '../../../getShadowNodeFromRef'; import { tagMessage } from '../../../utils'; -import { useCallback } from 'react'; +import type { GestureDetectorState } from './types'; declare const global: { _isViewFlatteningDisabled: (node: unknown) => boolean | null; // JSI function diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts index 315abf98af..0d7ef6cd1e 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts @@ -1,27 +1,28 @@ +import { useCallback, useRef, useState } from 'react'; +import { Platform } from 'react-native'; + +import { RNRenderer } from '../../../RNRenderer'; +import { isTestEnv, tagMessage } from '../../../utils'; import type { GestureHandlerNativeEvent, PropsRef, ResultEvent, } from '../../../web/interfaces'; -import type { GestureRef, GestureType } from '../gesture'; -import { isTestEnv, tagMessage } from '../../../utils'; +import { flingGestureHandlerProps } from '../../FlingGestureHandler'; +import { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler'; +import { baseGestureHandlerWithDetectorProps } from '../../gestureHandlerCommon'; +import { longPressGestureHandlerProps } from '../../LongPressGestureHandler'; +import { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler'; import { panGestureHandlerCustomNativeProps, panGestureHandlerProps, } from '../../PanGestureHandler'; -import { useCallback, useRef, useState } from 'react'; +import { tapGestureHandlerProps } from '../../TapGestureHandler'; +import { onGestureHandlerEvent } from '../eventReceiver'; +import type { GestureRef, GestureType } from '../gesture'; import { BaseGesture } from '../gesture'; -import { Platform } from 'react-native'; -import { RNRenderer } from '../../../RNRenderer'; -import { Reanimated } from '../reanimatedWrapper'; -import { baseGestureHandlerWithDetectorProps } from '../../gestureHandlerCommon'; -import { flingGestureHandlerProps } from '../../FlingGestureHandler'; -import { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler'; import { hoverGestureHandlerProps } from '../hoverGesture'; -import { longPressGestureHandlerProps } from '../../LongPressGestureHandler'; -import { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler'; -import { onGestureHandlerEvent } from '../eventReceiver'; -import { tapGestureHandlerProps } from '../../TapGestureHandler'; +import { Reanimated } from '../reanimatedWrapper'; export const ALLOWED_PROPS = [ ...baseGestureHandlerWithDetectorProps, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/eventReceiver.ts b/packages/react-native-gesture-handler/src/handlers/gestures/eventReceiver.ts index 696a484fd9..d3bcddd748 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/eventReceiver.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/eventReceiver.ts @@ -1,3 +1,8 @@ +import type { EmitterSubscription } from 'react-native'; +import { DeviceEventEmitter } from 'react-native'; + +import { State } from '../../State'; +import { TouchEventType } from '../../TouchEventType'; import type { GestureStateChangeEvent, GestureTouchEvent, @@ -5,12 +10,8 @@ import type { } from '../gestureHandlerCommon'; import { findHandler, findOldGestureHandler } from '../handlersRegistry'; import type { BaseGesture } from './gesture'; -import { DeviceEventEmitter } from 'react-native'; -import type { EmitterSubscription } from 'react-native'; -import { GestureStateManager } from './gestureStateManager'; import type { GestureStateManagerType } from './gestureStateManager'; -import { State } from '../../State'; -import { TouchEventType } from '../../TouchEventType'; +import { GestureStateManager } from './gestureStateManager'; let gestureHandlerEventSubscription: EmitterSubscription | null = null; let gestureHandlerStateChangeEventSubscription: EmitterSubscription | null = diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts index f13c7beb8b..f44402443d 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts @@ -1,7 +1,7 @@ -import { BaseGesture } from './gesture'; -import type { BaseGestureConfig } from './gesture'; import type { FlingGestureConfig } from '../FlingGestureHandler'; import type { FlingGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { BaseGestureConfig } from './gesture'; +import { BaseGesture } from './gesture'; export class FlingGesture extends BaseGesture { public override config: BaseGestureConfig & FlingGestureConfig = {}; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts index 8bbd690736..70695f8bb4 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts @@ -1,8 +1,8 @@ -import type { BaseGestureConfig } from './gesture'; -import { ContinousBaseGesture } from './gesture'; import type { ForceTouchGestureConfig } from '../ForceTouchGestureHandler'; -import type { ForceTouchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; import type { GestureUpdateEvent } from '../gestureHandlerCommon'; +import type { ForceTouchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { BaseGestureConfig } from './gesture'; +import { ContinousBaseGesture } from './gesture'; /** * @deprecated ForceTouch gesture is deprecated and will be removed in the future. diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts index ca306e5d24..29338767a7 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts @@ -1,3 +1,4 @@ +import { isRemoteDebuggingEnabled } from '../../utils'; import type { ActiveCursor, CommonGestureConfig, @@ -18,9 +19,8 @@ import type { RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, } from '../GestureHandlerEventPayload'; -import type { GestureStateManagerType } from './gestureStateManager'; import { getNextHandlerTag } from '../getNextHandlerTag'; -import { isRemoteDebuggingEnabled } from '../../utils'; +import type { GestureStateManagerType } from './gestureStateManager'; export type GestureType = | BaseGesture> diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts b/packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts index 6e4ab7d7aa..8253aadf41 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts @@ -1,5 +1,5 @@ -import { BaseGesture, Gesture } from './gesture'; import type { GestureRef, GestureType } from './gesture'; +import { BaseGesture, Gesture } from './gesture'; function extendRelation( currentRelation: GestureRef[] | undefined, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts b/packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts index 15e277822f..4a05de9584 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts @@ -1,11 +1,11 @@ +import { FlingGesture } from './flingGesture'; +import { ForceTouchGesture } from './forceTouchGesture'; +import type { Gesture } from './gesture'; import { ComposedGesture, ExclusiveGesture, SimultaneousGesture, } from './gestureComposition'; -import { FlingGesture } from './flingGesture'; -import { ForceTouchGesture } from './forceTouchGesture'; -import type { Gesture } from './gesture'; import { HoverGesture } from './hoverGesture'; import { LongPressGesture } from './longPressGesture'; import { ManualGesture } from './manualGesture'; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.web.ts b/packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.web.ts index 9478e0f8b8..1874b3983d 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.web.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.web.ts @@ -1,6 +1,6 @@ -import type { GestureStateManagerType } from './gestureStateManager'; -import NodeManager from '../../web/tools/NodeManager'; import { State } from '../../State'; +import NodeManager from '../../web/tools/NodeManager'; +import type { GestureStateManagerType } from './gestureStateManager'; export const GestureStateManager = { create(handlerTag: number): GestureStateManagerType { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts index 39b9991afc..b8f7b15ad6 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts @@ -1,7 +1,7 @@ -import type { BaseGestureConfig } from './gesture'; -import { ContinousBaseGesture } from './gesture'; import type { GestureUpdateEvent } from '../gestureHandlerCommon'; import type { HoverGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { BaseGestureConfig } from './gesture'; +import { ContinousBaseGesture } from './gesture'; export type HoverGestureChangeEventPayload = { changeX: number; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts index 9e57c9a32f..07552b8fe1 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts @@ -1,7 +1,7 @@ -import { BaseGesture } from './gesture'; -import type { BaseGestureConfig } from './gesture'; -import type { LongPressGestureConfig } from '../LongPressGestureHandler'; import type { LongPressGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { LongPressGestureConfig } from '../LongPressGestureHandler'; +import type { BaseGestureConfig } from './gesture'; +import { BaseGesture } from './gesture'; export class LongPressGesture extends BaseGesture { public override config: BaseGestureConfig & LongPressGestureConfig = {}; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts index 27c54cadbd..e2df2f6c84 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts @@ -1,5 +1,5 @@ -import { ContinousBaseGesture } from './gesture'; import type { GestureUpdateEvent } from '../gestureHandlerCommon'; +import { ContinousBaseGesture } from './gesture'; function changeEventCalculator( current: GestureUpdateEvent>, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts index 1427220578..bc29c07348 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts @@ -1,7 +1,7 @@ -import { BaseGesture } from './gesture'; -import type { BaseGestureConfig } from './gesture'; -import type { NativeViewGestureConfig } from '../NativeViewGestureHandler'; import type { NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload'; +import type { NativeViewGestureConfig } from '../NativeViewGestureHandler'; +import type { BaseGestureConfig } from './gesture'; +import { BaseGesture } from './gesture'; export class NativeGesture extends BaseGesture { public override config: BaseGestureConfig & NativeViewGestureConfig = {}; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/panGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/panGesture.ts index 0048bdc505..81e46a72e2 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/panGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/panGesture.ts @@ -1,8 +1,8 @@ -import type { BaseGestureConfig } from './gesture'; -import { ContinousBaseGesture } from './gesture'; import type { GestureUpdateEvent } from '../gestureHandlerCommon'; -import type { PanGestureConfig } from '../PanGestureHandler'; import type { PanGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { PanGestureConfig } from '../PanGestureHandler'; +import type { BaseGestureConfig } from './gesture'; +import { ContinousBaseGesture } from './gesture'; export type PanGestureChangeEventPayload = { changeX: number; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/pinchGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/pinchGesture.ts index 6d73f6fd8d..7689c01244 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/pinchGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/pinchGesture.ts @@ -1,6 +1,6 @@ -import { ContinousBaseGesture } from './gesture'; import type { GestureUpdateEvent } from '../gestureHandlerCommon'; import type { PinchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import { ContinousBaseGesture } from './gesture'; export type PinchGestureChangeEventPayload = { scaleChange: number; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts b/packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts index 1778347a1a..5708870405 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts @@ -1,11 +1,12 @@ +import type { ComponentClass } from 'react'; + +import { tagMessage } from '../../utils'; +import { NativeProxy } from '../../v3/NativeProxy'; import type { GestureCallbacks, GestureUpdateEventWithHandlerData, SharedValue, } from '../../v3/types'; -import type { ComponentClass } from 'react'; -import { NativeProxy } from '../../v3/NativeProxy'; -import { tagMessage } from '../../utils'; export type ReanimatedContext = { lastUpdateEvent: GestureUpdateEventWithHandlerData | undefined; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/rotationGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/rotationGesture.ts index 490ffd02a2..eb4cec08df 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/rotationGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/rotationGesture.ts @@ -1,6 +1,6 @@ -import { ContinousBaseGesture } from './gesture'; import type { GestureUpdateEvent } from '../gestureHandlerCommon'; import type { RotationGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import { ContinousBaseGesture } from './gesture'; type RotationGestureChangeEventPayload = { rotationChange: number; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts index fcacc4764e..478aed8bb2 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts @@ -1,7 +1,7 @@ -import { BaseGesture } from './gesture'; -import type { BaseGestureConfig } from './gesture'; -import type { TapGestureConfig } from '../TapGestureHandler'; import type { TapGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { TapGestureConfig } from '../TapGestureHandler'; +import type { BaseGestureConfig } from './gesture'; +import { BaseGesture } from './gesture'; export class TapGesture extends BaseGesture { public override config: BaseGestureConfig & TapGestureConfig = {}; diff --git a/packages/react-native-gesture-handler/src/handlers/handlersRegistry.ts b/packages/react-native-gesture-handler/src/handlers/handlersRegistry.ts index 896fe959bd..2c4426d974 100644 --- a/packages/react-native-gesture-handler/src/handlers/handlersRegistry.ts +++ b/packages/react-native-gesture-handler/src/handlers/handlersRegistry.ts @@ -1,10 +1,10 @@ +import { isTestEnv } from '../utils'; +import type { SingleGesture } from '../v3/types'; import type { GestureEvent, HandlerStateChangeEvent, } from './gestureHandlerCommon'; import type { GestureType } from './gestures/gesture'; -import type { SingleGesture } from '../v3/types'; -import { isTestEnv } from '../utils'; export const handlerIDToTag: Record = {}; diff --git a/packages/react-native-gesture-handler/src/handlers/utils.ts b/packages/react-native-gesture-handler/src/handlers/utils.ts index 05e8b25e1c..e797fdf423 100644 --- a/packages/react-native-gesture-handler/src/handlers/utils.ts +++ b/packages/react-native-gesture-handler/src/handlers/utils.ts @@ -1,9 +1,10 @@ import type * as React from 'react'; -import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native'; -import RNGestureHandlerModule from '../RNGestureHandlerModule'; +import { findNodeHandle as findNodeHandleRN, Platform } from 'react-native'; + import { ghQueueMicrotask } from '../ghQueueMicrotask'; -import { handlerIDToTag } from './handlersRegistry'; +import RNGestureHandlerModule from '../RNGestureHandlerModule'; import { toArray } from '../utils'; +import { handlerIDToTag } from './handlersRegistry'; function isConfigParam(param: unknown, name: string) { // param !== Object(param) returns false if `param` is a function diff --git a/packages/react-native-gesture-handler/src/index.ts b/packages/react-native-gesture-handler/src/index.ts index 4d6d36450b..9f28d4bad9 100644 --- a/packages/react-native-gesture-handler/src/index.ts +++ b/packages/react-native-gesture-handler/src/index.ts @@ -2,158 +2,153 @@ import './globals'; import { initialize } from './init'; -export { Directions } from './Directions'; -export { State } from './State'; -export { PointerType } from './PointerType'; +export { + LegacyBaseButton, + LegacyBorderlessButton, + LegacyRawButton, + LegacyRectButton, +} from './components/GestureButtons'; +export type { + LegacyBaseButtonProps, + LegacyBorderlessButtonProps, + LegacyRawButtonProps, + LegacyRectButtonProps, +} from './components/GestureButtonsProps'; +export { + LegacyDrawerLayoutAndroid, + LegacyFlatList, + LegacyRefreshControl, + LegacyScrollView, + LegacySwitch, + LegacyTextInput, +} from './components/GestureComponents'; export { default as GestureHandlerRootView } from './components/GestureHandlerRootView'; export type { + LegacyPressableProps, + PressableProps, + PressableStateCallbackType, +} from './components/Pressable'; +export { default as LegacyPressable } from './components/Pressable'; +export { LegacyText } from './components/Text'; +export type { + TouchableHighlightProps, + TouchableOpacityProps, + TouchableWithoutFeedbackProps, +} from './components/touchables'; +export { + TouchableHighlight, + TouchableNativeFeedback, + TouchableOpacity, + TouchableWithoutFeedback, +} from './components/touchables'; +export { Directions } from './Directions'; +export { default as legacy_createNativeWrapper } from './handlers/createNativeWrapper'; +export type { FlingGestureHandlerProps } from './handlers/FlingGestureHandler'; +export { FlingGestureHandler } from './handlers/FlingGestureHandler'; +export type { ForceTouchGestureHandlerProps } from './handlers/ForceTouchGestureHandler'; +export { ForceTouchGestureHandler } from './handlers/ForceTouchGestureHandler'; +export type { + // Config types + ActiveCursor, // Event types GestureEvent, - HandlerStateChangeEvent, // Event payloads types GestureEventPayload, - HandlerStateChangeEventPayload, + GestureStateChangeEvent, // Pointer events GestureTouchEvent, - GestureTouchEvent as SingleGestureTouchEvent, - TouchData, // New api event types GestureUpdateEvent, - GestureStateChangeEvent, - // Config types - ActiveCursor, + HandlerStateChangeEvent, + HandlerStateChangeEventPayload, + GestureTouchEvent as SingleGestureTouchEvent, + TouchData, } from './handlers/gestureHandlerCommon'; export { MouseButton } from './handlers/gestureHandlerCommon'; -export type { GestureType } from './handlers/gestures/gesture'; export type { - TapGestureHandlerEventPayload, + FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, + NativeViewGestureHandlerPayload, PanGestureHandlerEventPayload, PinchGestureHandlerEventPayload, RotationGestureHandlerEventPayload, - NativeViewGestureHandlerPayload, - FlingGestureHandlerEventPayload, + TapGestureHandlerEventPayload, } from './handlers/GestureHandlerEventPayload'; -export type { TapGestureHandlerProps } from './handlers/TapGestureHandler'; -export type { ForceTouchGestureHandlerProps } from './handlers/ForceTouchGestureHandler'; -export type { ForceTouchGestureChangeEventPayload } from './handlers/gestures/forceTouchGesture'; -export type { LongPressGestureHandlerProps } from './handlers/LongPressGestureHandler'; -export type { PanGestureHandlerProps } from './handlers/PanGestureHandler'; -export type { PanGestureChangeEventPayload } from './handlers/gestures/panGesture'; -export type { PinchGestureHandlerProps } from './handlers/PinchGestureHandler'; -export type { PinchGestureChangeEventPayload } from './handlers/gestures/pinchGesture'; -export type { RotationGestureHandlerProps } from './handlers/RotationGestureHandler'; -export type { FlingGestureHandlerProps } from './handlers/FlingGestureHandler'; -export { TapGestureHandler } from './handlers/TapGestureHandler'; -export { ForceTouchGestureHandler } from './handlers/ForceTouchGestureHandler'; -export { LongPressGestureHandler } from './handlers/LongPressGestureHandler'; -export { PanGestureHandler } from './handlers/PanGestureHandler'; -export { PinchGestureHandler } from './handlers/PinchGestureHandler'; -export { RotationGestureHandler } from './handlers/RotationGestureHandler'; -export { FlingGestureHandler } from './handlers/FlingGestureHandler'; -export { default as legacy_createNativeWrapper } from './handlers/createNativeWrapper'; -export type { NativeViewGestureHandlerProps } from './handlers/NativeViewGestureHandler'; -export { GestureObjects as Gesture } from './handlers/gestures/gestureObjects'; -export type { TapGestureType as LegacyTapGesture } from './handlers/gestures/tapGesture'; -export type { PanGestureType as LegacyPanGesture } from './handlers/gestures/panGesture'; -export type { FlingGestureType as LegacyFlingGesture } from './handlers/gestures/flingGesture'; -export type { LongPressGestureType as LegacyLongPressGesture } from './handlers/gestures/longPressGesture'; -export type { PinchGestureType as LegacyPinchGesture } from './handlers/gestures/pinchGesture'; -export type { RotationGestureType as LegacyRotationGesture } from './handlers/gestures/rotationGesture'; -export type { ForceTouchGestureType as LegacyForceTouchGesture } from './handlers/gestures/forceTouchGesture'; -export type { ManualGestureType as LegacyManualGesture } from './handlers/gestures/manualGesture'; -export type { HoverGestureType as LegacyHoverGesture } from './handlers/gestures/hoverGesture'; -export type { - ComposedGestureType as LegacyComposedGesture, - RaceGestureType as LegacyRaceGesture, - SimultaneousGestureType as LegacySimultaneousGesture, - ExclusiveGestureType as LegacyExclusiveGesture, -} from './handlers/gestures/gestureComposition'; -export type { GestureStateManagerType as LegacyGestureStateManager } from './handlers/gestures/gestureStateManager'; -export { NativeViewGestureHandler } from './handlers/NativeViewGestureHandler'; -export type { - LegacyRawButtonProps, - LegacyBaseButtonProps, - LegacyRectButtonProps, - LegacyBorderlessButtonProps, -} from './components/GestureButtonsProps'; - -export { - LegacyRawButton, - LegacyBaseButton, - LegacyRectButton, - LegacyBorderlessButton, -} from './components/GestureButtons'; - -export type { - TouchableHighlightProps, - TouchableOpacityProps, - TouchableWithoutFeedbackProps, -} from './components/touchables'; -export { - TouchableHighlight, - TouchableNativeFeedback, - TouchableOpacity, - TouchableWithoutFeedback, -} from './components/touchables'; -export { - LegacyScrollView, - LegacySwitch, - LegacyTextInput, - LegacyDrawerLayoutAndroid, - LegacyFlatList, - LegacyRefreshControl, -} from './components/GestureComponents'; - -export { LegacyText } from './components/Text'; -export { HoverEffect } from './handlers/gestures/hoverGesture'; export type { + FlingGestureHandlerGestureEvent, + FlingGestureHandlerProperties, + FlingGestureHandlerStateChangeEvent, + ForceTouchGestureHandlerGestureEvent, + ForceTouchGestureHandlerProperties, + ForceTouchGestureHandlerStateChangeEvent, // Events GestureHandlerGestureEvent, - GestureHandlerStateChangeEvent, // Event payloads GestureHandlerGestureEventNativeEvent, + GestureHandlerStateChangeEvent, GestureHandlerStateChangeNativeEvent, - NativeViewGestureHandlerGestureEvent, - NativeViewGestureHandlerStateChangeEvent, - TapGestureHandlerGestureEvent, - TapGestureHandlerStateChangeEvent, - ForceTouchGestureHandlerGestureEvent, - ForceTouchGestureHandlerStateChangeEvent, + LegacyBaseButtonProperties, + LegacyBorderlessButtonProperties, + // Buttons props + LegacyRawButtonProperties, + LegacyRectButtonProperties, LongPressGestureHandlerGestureEvent, + LongPressGestureHandlerProperties, LongPressGestureHandlerStateChangeEvent, + NativeViewGestureHandlerGestureEvent, + // Handlers props + NativeViewGestureHandlerProperties, + NativeViewGestureHandlerStateChangeEvent, PanGestureHandlerGestureEvent, + PanGestureHandlerProperties, PanGestureHandlerStateChangeEvent, PinchGestureHandlerGestureEvent, + PinchGestureHandlerProperties, PinchGestureHandlerStateChangeEvent, RotationGestureHandlerGestureEvent, + RotationGestureHandlerProperties, RotationGestureHandlerStateChangeEvent, - FlingGestureHandlerGestureEvent, - FlingGestureHandlerStateChangeEvent, - // Handlers props - NativeViewGestureHandlerProperties, + TapGestureHandlerGestureEvent, TapGestureHandlerProperties, - LongPressGestureHandlerProperties, - PanGestureHandlerProperties, - PinchGestureHandlerProperties, - RotationGestureHandlerProperties, - FlingGestureHandlerProperties, - ForceTouchGestureHandlerProperties, - // Buttons props - LegacyRawButtonProperties, - LegacyBaseButtonProperties, - LegacyRectButtonProperties, - LegacyBorderlessButtonProperties, + TapGestureHandlerStateChangeEvent, } from './handlers/gestureHandlerTypesCompat'; - +export type { FlingGestureType as LegacyFlingGesture } from './handlers/gestures/flingGesture'; +export type { ForceTouchGestureChangeEventPayload } from './handlers/gestures/forceTouchGesture'; +export type { ForceTouchGestureType as LegacyForceTouchGesture } from './handlers/gestures/forceTouchGesture'; +export type { GestureType } from './handlers/gestures/gesture'; export type { - PressableProps, - LegacyPressableProps, - PressableStateCallbackType, -} from './components/Pressable'; -export { default as LegacyPressable } from './components/Pressable'; - + ComposedGestureType as LegacyComposedGesture, + ExclusiveGestureType as LegacyExclusiveGesture, + RaceGestureType as LegacyRaceGesture, + SimultaneousGestureType as LegacySimultaneousGesture, +} from './handlers/gestures/gestureComposition'; +export { GestureObjects as Gesture } from './handlers/gestures/gestureObjects'; +export type { GestureStateManagerType as LegacyGestureStateManager } from './handlers/gestures/gestureStateManager'; +export type { HoverGestureType as LegacyHoverGesture } from './handlers/gestures/hoverGesture'; +export { HoverEffect } from './handlers/gestures/hoverGesture'; +export type { LongPressGestureType as LegacyLongPressGesture } from './handlers/gestures/longPressGesture'; +export type { ManualGestureType as LegacyManualGesture } from './handlers/gestures/manualGesture'; +export type { PanGestureChangeEventPayload } from './handlers/gestures/panGesture'; +export type { PanGestureType as LegacyPanGesture } from './handlers/gestures/panGesture'; +export type { PinchGestureChangeEventPayload } from './handlers/gestures/pinchGesture'; +export type { PinchGestureType as LegacyPinchGesture } from './handlers/gestures/pinchGesture'; +export type { RotationGestureType as LegacyRotationGesture } from './handlers/gestures/rotationGesture'; +export type { TapGestureType as LegacyTapGesture } from './handlers/gestures/tapGesture'; +export type { LongPressGestureHandlerProps } from './handlers/LongPressGestureHandler'; +export { LongPressGestureHandler } from './handlers/LongPressGestureHandler'; +export type { NativeViewGestureHandlerProps } from './handlers/NativeViewGestureHandler'; +export { NativeViewGestureHandler } from './handlers/NativeViewGestureHandler'; +export type { PanGestureHandlerProps } from './handlers/PanGestureHandler'; +export { PanGestureHandler } from './handlers/PanGestureHandler'; +export type { PinchGestureHandlerProps } from './handlers/PinchGestureHandler'; +export { PinchGestureHandler } from './handlers/PinchGestureHandler'; +export type { RotationGestureHandlerProps } from './handlers/RotationGestureHandler'; +export { RotationGestureHandler } from './handlers/RotationGestureHandler'; +export type { TapGestureHandlerProps } from './handlers/TapGestureHandler'; +export { TapGestureHandler } from './handlers/TapGestureHandler'; +export { PointerType } from './PointerType'; +export { State } from './State'; export * from './v3'; initialize(); diff --git a/packages/react-native-gesture-handler/src/jestUtils/index.ts b/packages/react-native-gesture-handler/src/jestUtils/index.ts index 9e92b72d85..99351f2813 100644 --- a/packages/react-native-gesture-handler/src/jestUtils/index.ts +++ b/packages/react-native-gesture-handler/src/jestUtils/index.ts @@ -1 +1 @@ -export { getByGestureTestId, fireGestureHandler } from './jestUtils'; +export { fireGestureHandler, getByGestureTestId } from './jestUtils'; diff --git a/packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts b/packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts index 9297ef25f3..d40060e43f 100644 --- a/packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts +++ b/packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts @@ -1,3 +1,11 @@ +import invariant from 'invariant'; +import { DeviceEventEmitter } from 'react-native'; +import type { ReactTestInstance } from 'react-test-renderer'; + +import type { FlingGestureHandler } from '../handlers/FlingGestureHandler'; +import { flingHandlerName } from '../handlers/FlingGestureHandler'; +import type { ForceTouchGestureHandler } from '../handlers/ForceTouchGestureHandler'; +import { forceTouchHandlerName } from '../handlers/ForceTouchGestureHandler'; import type { BaseGestureHandlerProps, GestureEvent, @@ -13,40 +21,33 @@ import type { RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, } from '../handlers/GestureHandlerEventPayload'; -import { hasProperty, withPrevAndCurrent } from '../utils'; -import { BaseGesture } from '../handlers/gestures/gesture'; -import { DeviceEventEmitter } from 'react-native'; import type { FlingGesture } from '../handlers/gestures/flingGesture'; -import type { FlingGestureHandler } from '../handlers/FlingGestureHandler'; import type { ForceTouchGesture } from '../handlers/gestures/forceTouchGesture'; -import type { ForceTouchGestureHandler } from '../handlers/ForceTouchGestureHandler'; import type { GestureType } from '../handlers/gestures/gesture'; +import { BaseGesture } from '../handlers/gestures/gesture'; import type { LongPressGesture } from '../handlers/gestures/longPressGesture'; -import type { LongPressGestureHandler } from '../handlers/LongPressGestureHandler'; import type { NativeGesture } from '../handlers/gestures/nativeGesture'; -import type { NativeViewGestureHandler } from '../handlers/NativeViewGestureHandler'; import type { PanGesture } from '../handlers/gestures/panGesture'; -import type { PanGestureHandler } from '../handlers/PanGestureHandler'; import type { PinchGesture } from '../handlers/gestures/pinchGesture'; -import type { PinchGestureHandler } from '../handlers/PinchGestureHandler'; -import type { ReactTestInstance } from 'react-test-renderer'; import type { RotationGesture } from '../handlers/gestures/rotationGesture'; -import type { RotationGestureHandler } from '../handlers/RotationGestureHandler'; -import type { SingleGesture } from '../v3/types'; -import { State } from '../State'; import type { TapGesture } from '../handlers/gestures/tapGesture'; -import type { TapGestureHandler } from '../handlers/TapGestureHandler'; import { findHandlerByTestID } from '../handlers/handlersRegistry'; -import { flingHandlerName } from '../handlers/FlingGestureHandler'; -import { forceTouchHandlerName } from '../handlers/ForceTouchGestureHandler'; -import invariant from 'invariant'; +import type { LongPressGestureHandler } from '../handlers/LongPressGestureHandler'; import { longPressHandlerName } from '../handlers/LongPressGestureHandler'; -import { maybeUnpackValue } from '../v3/hooks/utils'; +import type { NativeViewGestureHandler } from '../handlers/NativeViewGestureHandler'; import { nativeViewHandlerName } from '../handlers/NativeViewGestureHandler'; +import type { PanGestureHandler } from '../handlers/PanGestureHandler'; import { panHandlerName } from '../handlers/PanGestureHandler'; +import type { PinchGestureHandler } from '../handlers/PinchGestureHandler'; import { pinchHandlerName } from '../handlers/PinchGestureHandler'; +import type { RotationGestureHandler } from '../handlers/RotationGestureHandler'; import { rotationHandlerName } from '../handlers/RotationGestureHandler'; +import type { TapGestureHandler } from '../handlers/TapGestureHandler'; import { tapHandlerName } from '../handlers/TapGestureHandler'; +import { State } from '../State'; +import { hasProperty, withPrevAndCurrent } from '../utils'; +import { maybeUnpackValue } from '../v3/hooks/utils'; +import type { SingleGesture } from '../v3/types'; // Load fireEvent conditionally, so RNGH may be used in setups without testing-library let fireEvent = ( diff --git a/packages/react-native-gesture-handler/src/mocks/GestureButtons.tsx b/packages/react-native-gesture-handler/src/mocks/GestureButtons.tsx index 20687eac4c..6facc5b9b4 100644 --- a/packages/react-native-gesture-handler/src/mocks/GestureButtons.tsx +++ b/packages/react-native-gesture-handler/src/mocks/GestureButtons.tsx @@ -1,5 +1,5 @@ -import { TouchableNativeFeedback, View } from 'react-native'; import React from 'react'; +import { TouchableNativeFeedback, View } from 'react-native'; const RawButton = ({ enabled, children, ...rest }: any) => ( diff --git a/packages/react-native-gesture-handler/src/mocks/gestureComponents.tsx b/packages/react-native-gesture-handler/src/mocks/gestureComponents.tsx index 5209afc660..4aa65844b1 100644 --- a/packages/react-native-gesture-handler/src/mocks/gestureComponents.tsx +++ b/packages/react-native-gesture-handler/src/mocks/gestureComponents.tsx @@ -1,8 +1,8 @@ export { - ScrollView as LegacyScrollView, + DrawerLayoutAndroid as LegacyDrawerLayoutAndroid, FlatList as LegacyFlatList, + RefreshControl as LegacyRefreshControl, + ScrollView as LegacyScrollView, Switch as LegacySwitch, TextInput as LegacyTextInput, - DrawerLayoutAndroid as LegacyDrawerLayoutAndroid, - RefreshControl as LegacyRefreshControl, } from 'react-native'; diff --git a/packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts b/packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts index 222f61b13a..ebc021b447 100644 --- a/packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts +++ b/packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts @@ -1,6 +1,6 @@ -import type { Double } from 'react-native/Libraries/Types/CodegenTypes'; import type { TurboModule } from 'react-native'; import { TurboModuleRegistry } from 'react-native'; +import type { Double } from 'react-native/Libraries/Types/CodegenTypes'; export interface Spec extends TurboModule { // This method returns a boolean only to force the codegen to generate diff --git a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts index 80dc00a70f..3195335427 100644 --- a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts +++ b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts @@ -1,3 +1,4 @@ +import type { ViewProps } from 'react-native'; import type { DirectEventHandler, Double, @@ -5,7 +6,6 @@ import type { UnsafeMixed, WithDefault, } from 'react-native/Libraries/Types/CodegenTypes'; -import type { ViewProps } from 'react-native'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; type GestureHandlerEvent = Readonly<{ diff --git a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts index d3ce923df0..59cb663757 100644 --- a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts +++ b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts @@ -1,5 +1,5 @@ -import type { Int32 } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from 'react-native'; +import type { Int32 } from 'react-native/Libraries/Types/CodegenTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; // Publicly accessible type, moduleId is set internally diff --git a/packages/react-native-gesture-handler/src/v3/NativeProxy.ts b/packages/react-native-gesture-handler/src/v3/NativeProxy.ts index 1201a4cbd0..ac135334cf 100644 --- a/packages/react-native-gesture-handler/src/v3/NativeProxy.ts +++ b/packages/react-native-gesture-handler/src/v3/NativeProxy.ts @@ -1,10 +1,10 @@ +import { scheduleOperationToBeFlushed } from '../handlers/utils'; +import RNGestureHandlerModule from '../RNGestureHandlerModule'; import type { BaseGestureConfig, GestureRelations, SingleGestureName, } from './types'; -import RNGestureHandlerModule from '../RNGestureHandlerModule'; -import { scheduleOperationToBeFlushed } from '../handlers/utils'; // Destructure functions that can be called on the UI thread to have // a raw HostFunction reference diff --git a/packages/react-native-gesture-handler/src/v3/NativeProxy.web.ts b/packages/react-native-gesture-handler/src/v3/NativeProxy.web.ts index 73f05ba8ae..4ee0134ec3 100644 --- a/packages/react-native-gesture-handler/src/v3/NativeProxy.web.ts +++ b/packages/react-native-gesture-handler/src/v3/NativeProxy.web.ts @@ -1,9 +1,9 @@ +import RNGestureHandlerModule from '../RNGestureHandlerModule'; import type { BaseGestureConfig, GestureRelations, SingleGestureName, } from './types'; -import RNGestureHandlerModule from '../RNGestureHandlerModule'; export const NativeProxy = { createGestureHandler: >( diff --git a/packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx b/packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx index 8183335631..6b35d72820 100644 --- a/packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx @@ -1,15 +1,16 @@ +import React, { useRef } from 'react'; import { Animated, Platform, StyleSheet } from 'react-native'; + +import GestureHandlerButton from '../../components/GestureHandlerButton'; +import createNativeWrapper from '../createNativeWrapper'; +import type { NativeHandlerData } from '../hooks/gestures/native/NativeTypes'; +import type { GestureEndEvent, GestureEvent } from '../types'; import type { BaseButtonProps, BorderlessButtonProps, RawButtonProps, RectButtonProps, } from './GestureButtonsProps'; -import type { GestureEndEvent, GestureEvent } from '../types'; -import React, { useRef } from 'react'; -import GestureHandlerButton from '../../components/GestureHandlerButton'; -import type { NativeHandlerData } from '../hooks/gestures/native/NativeTypes'; -import createNativeWrapper from '../createNativeWrapper'; type CallbackEventType = GestureEvent; type EndCallbackEventType = GestureEndEvent; diff --git a/packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts b/packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts index 5c3c472a2d..6d64c526c4 100644 --- a/packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts +++ b/packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts @@ -1,6 +1,7 @@ import type { StyleProp, ViewStyle } from 'react-native'; -import type { ButtonProps } from '../../components/GestureHandlerButton'; + import type GestureHandlerButton from '../../components/GestureHandlerButton'; +import type { ButtonProps } from '../../components/GestureHandlerButton'; import type { NativeWrapperProperties } from '../types/NativeWrapperType'; /** diff --git a/packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx b/packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx index e13764a61e..d0c01952a5 100644 --- a/packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx @@ -1,11 +1,5 @@ import type { PropsWithChildren, ReactElement } from 'react'; -import { - FlatList as RNFlatList, - RefreshControl as RNRefreshControl, - ScrollView as RNScrollView, - Switch as RNSwitch, - TextInput as RNTextInput, -} from 'react-native'; +import React, { useState } from 'react'; import type { FlatListProps as RNFlatListProps, RefreshControlProps as RNRefreshControlProps, @@ -13,13 +7,20 @@ import type { SwitchProps as RNSwitchProps, TextInputProps as RNTextInputProps, } from 'react-native'; -import React, { useState } from 'react'; +import { + FlatList as RNFlatList, + RefreshControl as RNRefreshControl, + ScrollView as RNScrollView, + Switch as RNSwitch, + TextInput as RNTextInput, +} from 'react-native'; + +import { ghQueueMicrotask } from '../../ghQueueMicrotask'; +import createNativeWrapper from '../createNativeWrapper'; import { GestureDetectorType } from '../detectors'; import type { NativeGesture } from '../hooks/gestures/native/NativeTypes'; -import type { NativeWrapperProperties } from '../types/NativeWrapperType'; import { NativeWrapperProps } from '../hooks/utils'; -import createNativeWrapper from '../createNativeWrapper'; -import { ghQueueMicrotask } from '../../ghQueueMicrotask'; +import type { NativeWrapperProperties } from '../types/NativeWrapperType'; export const RefreshControl = createNativeWrapper< RNRefreshControl, diff --git a/packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx b/packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx index 46395e6526..20d40539f4 100644 --- a/packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import type { FlatListProps } from 'react-native'; import { FlatList as RNFlatList, ScrollView as RNScrollView, @@ -6,7 +7,7 @@ import { TextInput as RNTextInput, View, } from 'react-native'; -import type { FlatListProps } from 'react-native'; + import createNativeWrapper from '../createNativeWrapper'; export const ScrollView = createNativeWrapper(RNScrollView, { diff --git a/packages/react-native-gesture-handler/src/v3/components/Pressable.tsx b/packages/react-native-gesture-handler/src/v3/components/Pressable.tsx index 187c437cbf..277e9fddcd 100644 --- a/packages/react-native-gesture-handler/src/v3/components/Pressable.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/Pressable.tsx @@ -1,26 +1,28 @@ -import { INT32_MAX, isTestEnv } from '../../utils'; +import React, { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; import type { Insets, LayoutChangeEvent, StyleProp, ViewStyle, } from 'react-native'; +import { Platform } from 'react-native'; + import type { PressableDimensions, PressableEvent, PressableProps, } from '../../components/Pressable/PressableProps'; -import React, { - useCallback, - useEffect, - useMemo, - useRef, - useState, -} from 'react'; import { - StateMachineEvent, getStatesConfig, + StateMachineEvent, } from '../../components/Pressable/stateDefinitions'; +import { PressableStateMachine } from '../../components/Pressable/StateMachine'; import { addInsets, gestureToPressableEvent, @@ -28,18 +30,17 @@ import { isTouchWithinInset, numberAsInset, } from '../../components/Pressable/utils'; +import { PressabilityDebugView } from '../../handlers/PressabilityDebugView'; +import { useIsScreenReaderEnabled } from '../../useIsScreenReaderEnabled'; +import { INT32_MAX, isTestEnv } from '../../utils'; +import { GestureDetector } from '../detectors'; import { useHoverGesture, useLongPressGesture, useNativeGesture, useSimultaneousGestures, } from '../hooks'; -import { GestureDetector } from '../detectors'; -import { Platform } from 'react-native'; -import { PressabilityDebugView } from '../../handlers/PressabilityDebugView'; -import { PressableStateMachine } from '../../components/Pressable/StateMachine'; import { PureNativeButton } from './GestureButtons'; -import { useIsScreenReaderEnabled } from '../../useIsScreenReaderEnabled'; const DEFAULT_LONG_PRESS_DURATION = 500; const IS_TEST_ENV = isTestEnv(); diff --git a/packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx b/packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx index 9f71ac8105..f11b22d35e 100644 --- a/packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx @@ -1,13 +1,14 @@ +import React, { useCallback, useRef } from 'react'; +import { Platform } from 'react-native'; + +import type { ButtonProps } from '../../../components/GestureHandlerButton'; +import GestureHandlerButton from '../../../components/GestureHandlerButton'; +import createNativeWrapper from '../../createNativeWrapper'; import type { CallbackEventType, EndCallbackEventType, TouchableProps, } from './TouchableProps'; -import React, { useCallback, useRef } from 'react'; -import type { ButtonProps } from '../../../components/GestureHandlerButton'; -import GestureHandlerButton from '../../../components/GestureHandlerButton'; -import { Platform } from 'react-native'; -import createNativeWrapper from '../../createNativeWrapper'; const TouchableButton = createNativeWrapper< React.ComponentRef, diff --git a/packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts b/packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts index eb58ccaa16..a324b01dd8 100644 --- a/packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts +++ b/packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts @@ -1,8 +1,9 @@ -import type { BaseButtonProps, RawButtonProps } from '../GestureButtonsProps'; -import type { GestureEndEvent, GestureEvent } from '../../types'; +import type { PressableAndroidRippleConfig as RNPressableAndroidRippleConfig } from 'react-native'; + import type { ButtonProps } from '../../../components/GestureHandlerButton'; import type { NativeHandlerData } from '../../hooks/gestures/native/NativeTypes'; -import type { PressableAndroidRippleConfig as RNPressableAndroidRippleConfig } from 'react-native'; +import type { GestureEndEvent, GestureEvent } from '../../types'; +import type { BaseButtonProps, RawButtonProps } from '../GestureButtonsProps'; export type CallbackEventType = GestureEvent; export type EndCallbackEventType = GestureEndEvent; diff --git a/packages/react-native-gesture-handler/src/v3/components/index.ts b/packages/react-native-gesture-handler/src/v3/components/index.ts index cc15193e1a..d4e35b56e9 100644 --- a/packages/react-native-gesture-handler/src/v3/components/index.ts +++ b/packages/react-native-gesture-handler/src/v3/components/index.ts @@ -1,27 +1,23 @@ -export type { - RawButtonProps, - BaseButtonProps, - RectButtonProps, - BorderlessButtonProps, -} from './GestureButtonsProps'; - export { - RawButton, BaseButton, - RectButton, BorderlessButton, PureNativeButton, + RawButton, + RectButton, } from './GestureButtons'; - +export type { + BaseButtonProps, + BorderlessButtonProps, + RawButtonProps, + RectButtonProps, +} from './GestureButtonsProps'; export { + FlatList, + RefreshControl, ScrollView, Switch, TextInput, - FlatList, - RefreshControl, } from './GestureComponents'; - export { default as Pressable } from './Pressable'; - export { Touchable } from './Touchable/Touchable'; export type { TouchableProps } from './Touchable/TouchableProps'; diff --git a/packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx b/packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx index e5eb0b99d2..75147f834d 100644 --- a/packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx +++ b/packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx @@ -1,13 +1,14 @@ +import React, { useEffect } from 'react'; + import { GestureDetectorType, InterceptingGestureDetector } from './detectors'; +import { NativeDetector } from './detectors/NativeDetector'; +import { VirtualDetector } from './detectors/VirtualDetector/VirtualDetector'; +import { useNativeGesture } from './hooks/gestures'; +import { NativeWrapperProps } from './hooks/utils'; import type { NativeWrapperProperties, WrapperSpecificProperties, } from './types/NativeWrapperType'; -import React, { useEffect } from 'react'; -import { NativeDetector } from './detectors/NativeDetector'; -import { NativeWrapperProps } from './hooks/utils'; -import { VirtualDetector } from './detectors/VirtualDetector/VirtualDetector'; -import { useNativeGesture } from './hooks/gestures'; export default function createNativeWrapper( Component: React.ComponentType, diff --git a/packages/react-native-gesture-handler/src/v3/detectors/GestureDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/GestureDetector.tsx index 5ccc4fd057..06a9212b74 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/GestureDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/GestureDetector.tsx @@ -1,9 +1,9 @@ import { BaseGesture } from '../../handlers/gestures/gesture'; import { ComposedGesture } from '../../handlers/gestures/gestureComposition'; -import { GestureDetector as LegacyGestureDetector } from '../../handlers/gestures/GestureDetector'; import type { GestureDetectorProps as LegacyGestureDetectorProps } from '../../handlers/gestures/GestureDetector'; -import { NativeDetector } from './NativeDetector'; +import { GestureDetector as LegacyGestureDetector } from '../../handlers/gestures/GestureDetector'; import type { NativeDetectorProps } from './common'; +import { NativeDetector } from './NativeDetector'; import { useEnsureGestureHandlerRootView } from './useEnsureGestureHandlerRootView'; export function GestureDetector< diff --git a/packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx b/packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx index 87188653a0..44ffcccc88 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx @@ -1,14 +1,15 @@ -import React, { useEffect, useMemo, useRef } from 'react'; import type { Ref, RefObject } from 'react'; +import React, { useEffect, useMemo, useRef } from 'react'; +import { View } from 'react-native'; + +import { ActionType } from '../../ActionType'; import type { TouchAction, UserSelect, } from '../../handlers/gestureHandlerCommon'; -import { ActionType } from '../../ActionType'; -import type { PropsRef } from '../../web/interfaces'; import RNGestureHandlerModule from '../../RNGestureHandlerModule.web'; -import { View } from 'react-native'; import { tagMessage } from '../../utils'; +import type { PropsRef } from '../../web/interfaces'; export interface GestureHandlerDetectorProps extends PropsRef { handlerTags: number[]; diff --git a/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx index fa2d8911bd..9a3220ddfd 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx @@ -1,11 +1,12 @@ -import { AnimatedNativeDetector, nativeDetectorStyles } from './common'; import React, { useMemo } from 'react'; -import { configureRelations, ensureNativeDetectorComponent } from './utils'; -import HostGestureDetector from './HostGestureDetector'; -import type { NativeDetectorProps } from './common'; import { Platform } from 'react-native'; -import { ReanimatedNativeDetector } from './ReanimatedNativeDetector'; + import { isComposedGesture } from '../hooks/utils/relationUtils'; +import type { NativeDetectorProps } from './common'; +import { AnimatedNativeDetector, nativeDetectorStyles } from './common'; +import HostGestureDetector from './HostGestureDetector'; +import { ReanimatedNativeDetector } from './ReanimatedNativeDetector'; +import { configureRelations, ensureNativeDetectorComponent } from './utils'; export function NativeDetector< TConfig, diff --git a/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.tsx index 56c651c702..ffcd9ffd1d 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.tsx @@ -1,10 +1,11 @@ -import HostGestureDetector, { - type RNGestureHandlerDetectorNativeComponentProps, -} from './HostGestureDetector'; import { useEffect, useMemo, useRef } from 'react'; +import { findNodeHandle } from 'react-native'; + import type { NativeEventsManager } from '../../handlers/gestures/reanimatedWrapper'; import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; -import { findNodeHandle } from 'react-native'; +import HostGestureDetector, { + type RNGestureHandlerDetectorNativeComponentProps, +} from './HostGestureDetector'; let NativeEventsManagerImpl = Reanimated?.NativeEventsManager; diff --git a/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.web.tsx b/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.web.tsx index c3a9700dfe..2036bce696 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.web.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.web.tsx @@ -1,5 +1,5 @@ -import HostGestureDetector from './HostGestureDetector'; import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; +import HostGestureDetector from './HostGestureDetector'; export const ReanimatedNativeDetector = Reanimated?.default.createAnimatedComponent(HostGestureDetector); diff --git a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx index 88c90ca115..17869440dd 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx @@ -1,28 +1,29 @@ -import { AnimatedNativeDetector, nativeDetectorStyles } from '../common'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import { Platform } from 'react-native'; + +import type { + TouchAction, + UserSelect, +} from '../../../handlers/gestureHandlerCommon'; +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import { tagMessage } from '../../../utils'; +import { isComposedGesture } from '../../hooks/utils/relationUtils'; import type { DetectorCallbacks, GestureHandlerEventWithHandlerData, VirtualChild, } from '../../types'; +import type { InterceptingGestureDetectorProps } from '../common'; +import { AnimatedNativeDetector, nativeDetectorStyles } from '../common'; +import HostGestureDetector from '../HostGestureDetector'; +import { ReanimatedNativeDetector } from '../ReanimatedNativeDetector'; +import { useEnsureGestureHandlerRootView } from '../useEnsureGestureHandlerRootView'; +import { configureRelations, ensureNativeDetectorComponent } from '../utils'; +import type { InterceptingDetectorContextValue } from './useInterceptingDetectorContext'; import { InterceptingDetectorContext, InterceptingDetectorMode, } from './useInterceptingDetectorContext'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import type { - TouchAction, - UserSelect, -} from '../../../handlers/gestureHandlerCommon'; -import { configureRelations, ensureNativeDetectorComponent } from '../utils'; -import HostGestureDetector from '../HostGestureDetector'; -import type { InterceptingDetectorContextValue } from './useInterceptingDetectorContext'; -import type { InterceptingGestureDetectorProps } from '../common'; -import { Platform } from 'react-native'; -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; -import { ReanimatedNativeDetector } from '../ReanimatedNativeDetector'; -import { isComposedGesture } from '../../hooks/utils/relationUtils'; -import { tagMessage } from '../../../utils'; -import { useEnsureGestureHandlerRootView } from '../useEnsureGestureHandlerRootView'; interface StrippedVirtualChildren { viewTag: number; diff --git a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx index e1f9d2ca47..9f2dea3f48 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx @@ -1,15 +1,16 @@ +import { useCallback, useEffect, useRef, useState } from 'react'; +import { findNodeHandle, Platform } from 'react-native'; + +import { Wrap } from '../../../handlers/gestures/GestureDetector/Wrap'; +import { tagMessage } from '../../../utils'; +import { isComposedGesture } from '../../hooks/utils/relationUtils'; import type { DetectorCallbacks, VirtualChild } from '../../types'; +import type { VirtualDetectorProps } from '../common'; +import { configureRelations } from '../utils'; import { InterceptingDetectorMode, useInterceptingDetectorContext, } from './useInterceptingDetectorContext'; -import { Platform, findNodeHandle } from 'react-native'; -import { useCallback, useEffect, useRef, useState } from 'react'; -import type { VirtualDetectorProps } from '../common'; -import { Wrap } from '../../../handlers/gestures/GestureDetector/Wrap'; -import { configureRelations } from '../utils'; -import { isComposedGesture } from '../../hooks/utils/relationUtils'; -import { tagMessage } from '../../../utils'; function useRequiredInterceptingDetectorContext() { const context = useInterceptingDetectorContext(); diff --git a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/useInterceptingDetectorContext.ts b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/useInterceptingDetectorContext.ts index 59d8855ad9..76982bfe08 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/useInterceptingDetectorContext.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/useInterceptingDetectorContext.ts @@ -1,4 +1,5 @@ import { createContext, use } from 'react'; + import type { VirtualChild } from '../../types'; export enum InterceptingDetectorMode { diff --git a/packages/react-native-gesture-handler/src/v3/detectors/common.ts b/packages/react-native-gesture-handler/src/v3/detectors/common.ts index 152faca5b6..0b9f7dca72 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/common.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/common.ts @@ -1,12 +1,13 @@ +import type React from 'react'; import { Animated, StyleSheet } from 'react-native'; + import type { TouchAction, UserSelect, } from '../../handlers/gestureHandlerCommon'; +import type { GestureDetectorProps as LegacyDetectorProps } from '../../handlers/gestures/GestureDetector'; import type { Gesture } from '../types'; import HostGestureDetector from './HostGestureDetector'; -import type { GestureDetectorProps as LegacyDetectorProps } from '../../handlers/gestures/GestureDetector'; -import type React from 'react'; export enum GestureDetectorType { Native, diff --git a/packages/react-native-gesture-handler/src/v3/detectors/index.ts b/packages/react-native-gesture-handler/src/v3/detectors/index.ts index a7d626ca75..3f7c6e162e 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/index.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/index.ts @@ -1,5 +1,5 @@ export type { GestureDetectorProps } from './common'; export { GestureDetectorType } from './common'; export { GestureDetector } from './GestureDetector'; -export { VirtualDetector as VirtualGestureDetector } from './VirtualDetector/VirtualDetector'; export { InterceptingGestureDetector } from './VirtualDetector/InterceptingGestureDetector'; +export { VirtualDetector as VirtualGestureDetector } from './VirtualDetector/VirtualDetector'; diff --git a/packages/react-native-gesture-handler/src/v3/detectors/useEnsureGestureHandlerRootView.ts b/packages/react-native-gesture-handler/src/v3/detectors/useEnsureGestureHandlerRootView.ts index e5c98b70cf..abb9c42e5c 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/useEnsureGestureHandlerRootView.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/useEnsureGestureHandlerRootView.ts @@ -1,6 +1,7 @@ -import GestureHandlerRootViewContext from '../../GestureHandlerRootViewContext'; -import { Platform } from 'react-native'; import { use } from 'react'; +import { Platform } from 'react-native'; + +import GestureHandlerRootViewContext from '../../GestureHandlerRootViewContext'; export function useEnsureGestureHandlerRootView() { const rootViewContext = use(GestureHandlerRootViewContext); diff --git a/packages/react-native-gesture-handler/src/v3/detectors/utils.ts b/packages/react-native-gesture-handler/src/v3/detectors/utils.ts index e2f01b0d4d..93b01bcb58 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/utils.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/utils.ts @@ -4,14 +4,14 @@ // For `waitFor` we need array as order of the gestures matters. // For `simultaneousHandlers` we use Set as the order doesn't matter. +import { tagMessage } from '../../utils'; import { isComposedGesture, prepareRelations, } from '../hooks/utils/relationUtils'; -import { ComposedGestureName } from '../types'; -import type { Gesture } from '../types'; import { NativeProxy } from '../NativeProxy'; -import { tagMessage } from '../../utils'; +import type { Gesture } from '../types'; +import { ComposedGestureName } from '../types'; // The tree consists of ComposedGestures and NativeGestures. NativeGestures are always leaf nodes. export const traverseAndConfigureRelations = ( diff --git a/packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts b/packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts index cc0cabee38..9370274dff 100644 --- a/packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts +++ b/packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts @@ -1,8 +1,8 @@ -import GestureHandlerOrchestrator from '../web/tools/GestureHandlerOrchestrator'; -import type { GestureStateManagerType } from './gestureStateManager'; +import { tagMessage } from '../utils'; import type IGestureHandler from '../web/handlers/IGestureHandler'; +import GestureHandlerOrchestrator from '../web/tools/GestureHandlerOrchestrator'; import NodeManager from '../web/tools/NodeManager'; -import { tagMessage } from '../utils'; +import type { GestureStateManagerType } from './gestureStateManager'; function ensureHandlerAttached(handler: IGestureHandler) { if (!handler.attached) { diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/eventHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/eventHandler.ts index 167cc746d7..82480ffe68 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/eventHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/eventHandler.ts @@ -1,3 +1,9 @@ +import type { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; +import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; +import type { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; +import { State } from '../../../State'; +import { TouchEventType } from '../../../TouchEventType'; +import { tagMessage } from '../../../utils'; import type { ChangeCalculatorType, GestureCallbacks, @@ -15,12 +21,6 @@ import { touchEventTypeToCallbackType, } from '../utils'; import { isStateChangeEvent, isTouchEvent } from '../utils/eventUtils'; -import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; -import type { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; -import type { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; -import { State } from '../../../State'; -import { TouchEventType } from '../../../TouchEventType'; -import { tagMessage } from '../../../utils'; function handleStateChangeEvent< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useGestureEventHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useGestureEventHandler.ts index 0c94138295..890be90aaf 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useGestureEventHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useGestureEventHandler.ts @@ -1,11 +1,12 @@ +import { useMemo } from 'react'; + +import type { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; import type { BaseGestureConfig, GestureCallbacks, GestureHandlerEventWithHandlerData, } from '../../types'; -import type { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; import { eventHandler } from './eventHandler'; -import { useMemo } from 'react'; export function useGestureEventHandler< TConfig, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts index 941eef0fb3..77d9b12d86 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts @@ -1,13 +1,14 @@ +import { useMemo } from 'react'; + +import type { ReanimatedHandler } from '../../../handlers/gestures/reanimatedWrapper'; +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; import type { ChangeCalculatorType, GestureCallbacks, GestureEvent, UnpackedGestureHandlerEventWithHandlerData, } from '../../types'; -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; -import type { ReanimatedHandler } from '../../../handlers/gestures/reanimatedWrapper'; import { eventHandler } from './eventHandler'; -import { useMemo } from 'react'; const workletNOOP = () => { 'worklet'; diff --git a/packages/react-native-gesture-handler/src/v3/hooks/composition/index.ts b/packages/react-native-gesture-handler/src/v3/hooks/composition/index.ts index 9cab20dfc5..ccbd54d2c7 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/composition/index.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/composition/index.ts @@ -1,3 +1,3 @@ -export { useSimultaneousGestures } from './useSimultaneousGestures'; -export { useExclusiveGestures } from './useExclusiveGestures'; export { useCompetingGestures } from './useCompetingGestures'; +export { useExclusiveGestures } from './useExclusiveGestures'; +export { useSimultaneousGestures } from './useSimultaneousGestures'; diff --git a/packages/react-native-gesture-handler/src/v3/hooks/composition/useComposedGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/composition/useComposedGesture.ts index 68baac7e07..cc21e29965 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/composition/useComposedGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/composition/useComposedGesture.ts @@ -1,3 +1,5 @@ +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import { tagMessage } from '../../../utils'; import type { AnyGesture, ComposedGesture, @@ -6,8 +8,6 @@ import type { GestureHandlerEventWithHandlerData, } from '../../types'; import { containsDuplicates, isComposedGesture } from '../utils'; -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; -import { tagMessage } from '../../../utils'; // TODO: Simplify repeated relations (Simultaneous with Simultaneous, Exclusive with Exclusive, etc.) export function useComposedGesture( diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts index 9fbe85360d..e5a72f5f3e 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts @@ -1,12 +1,12 @@ +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { useClonedAndRemappedConfig } from '../../utils'; import type { FlingGesture, FlingGestureConfig, FlingGestureProperties, FlingHandlerData, } from './FlingTypes'; -import { SingleGestureName } from '../../../types'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { useGesture } from '../../useGesture'; export function useFlingGesture(config: FlingGestureConfig): FlingGesture { const flingConfig = useClonedAndRemappedConfig< diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/HoverTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/HoverTypes.ts index 5aebc0d6d1..5bf13293cc 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/HoverTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/HoverTypes.ts @@ -1,3 +1,5 @@ +import type { StylusData } from '../../../../handlers/gestureHandlerCommon'; +import type { HoverEffect } from '../../../../handlers/gestures/hoverGesture'; import type { BaseGestureConfig, ExcludeInternalConfigProps, @@ -5,8 +7,6 @@ import type { SingleGesture, WithSharedValue, } from '../../../types'; -import type { HoverEffect } from '../../../../handlers/gestures/hoverGesture'; -import type { StylusData } from '../../../../handlers/gestureHandlerCommon'; export type HoverGestureExternalProperties = { /** diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts index 8c1287d6f1..d5f74320fb 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts @@ -1,4 +1,10 @@ import type { GestureEvent, HandlerData } from '../../../types'; +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { + getChangeEventCalculator, + useClonedAndRemappedConfig, +} from '../../utils'; import type { HoverExtendedHandlerData, HoverGesture, @@ -8,12 +14,6 @@ import type { HoverGestureProperties, HoverHandlerData, } from './HoverTypes'; -import { - getChangeEventCalculator, - useClonedAndRemappedConfig, -} from '../../utils'; -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; function diffCalculator( current: HandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/index.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/index.ts index 0e3f1c84bd..ca6c7fd015 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/index.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/index.ts @@ -55,73 +55,73 @@ import type { export type { TapGesture, - TapGestureEvent, TapGestureActiveEvent, TapGestureConfig, + TapGestureEvent, }; export { useTapGesture } from './tap/useTapGesture'; export type { FlingGesture, + FlingGestureActiveEvent, FlingGestureConfig, FlingGestureEvent, - FlingGestureActiveEvent, }; export { useFlingGesture } from './fling/useFlingGesture'; export type { LongPressGesture, - LongPressGestureEvent, - LongPressGestureConfig, LongPressGestureActiveEvent, + LongPressGestureConfig, + LongPressGestureEvent, }; export { useLongPressGesture } from './longPress/useLongPressGesture'; export type { PinchGesture, - PinchGestureEvent, PinchGestureActiveEvent, PinchGestureConfig, + PinchGestureEvent, }; export { usePinchGesture } from './pinch/usePinchGesture'; export type { RotationGesture, - RotationGestureEvent, RotationGestureActiveEvent, RotationGestureConfig, + RotationGestureEvent, }; export { useRotationGesture } from './rotation/useRotationGesture'; export type { HoverGesture, - HoverGestureEvent, - HoverGestureConfig, HoverGestureActiveEvent, + HoverGestureConfig, + HoverGestureEvent, }; export { useHoverGesture } from './hover/useHoverGesture'; export type { ManualGesture, - ManualGestureEvent, - ManualGestureConfig, ManualGestureActiveEvent, + ManualGestureConfig, + ManualGestureEvent, }; export { useManualGesture } from './manual/useManualGesture'; export type { NativeGesture, - NativeGestureEvent, NativeGestureActiveEvent, NativeGestureConfig, + NativeGestureEvent, }; export { useNativeGesture } from './native/useNativeGesture'; export type { PanGesture, - PanGestureEvent, - PanGestureConfig, PanGestureActiveEvent, + PanGestureConfig, + PanGestureEvent, }; export { usePanGesture } from './pan/usePanGesture'; diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts index 4b4846f403..4df5ce378d 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts @@ -1,3 +1,6 @@ +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { useClonedAndRemappedConfig } from '../../utils'; import type { LongPressGesture, LongPressGestureConfig, @@ -6,9 +9,6 @@ import type { LongPressGestureProperties, LongPressHandlerData, } from './LongPressTypes'; -import { SingleGestureName } from '../../../types'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { useGesture } from '../../useGesture'; const LongPressPropsMapping = new Map< keyof LongPressGestureProperties, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts index cc84bd2efe..82d045ccb7 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts @@ -1,12 +1,12 @@ +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { useClonedAndRemappedConfig } from '../../utils'; import type { ManualGesture, ManualGestureConfig, ManualGestureProperties, ManualHandlerData, } from './ManualTypes'; -import { SingleGestureName } from '../../../types'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { useGesture } from '../../useGesture'; export function useManualGesture(config: ManualGestureConfig): ManualGesture { const manualConfig = useClonedAndRemappedConfig< diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts index 756b866093..3058c145f7 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts @@ -1,12 +1,12 @@ +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { useClonedAndRemappedConfig } from '../../utils'; import type { NativeGesture, NativeGestureConfig, NativeGestureProperties, NativeHandlerData, } from './NativeTypes'; -import { SingleGestureName } from '../../../types'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { useGesture } from '../../useGesture'; export function useNativeGesture(config: NativeGestureConfig): NativeGesture { const nativeConfig = useClonedAndRemappedConfig< diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/PanTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/PanTypes.ts index 0effa3e1c2..db5b879912 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/PanTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/PanTypes.ts @@ -1,3 +1,4 @@ +import type { StylusData } from '../../../../handlers/gestureHandlerCommon'; import type { BaseGestureConfig, ExcludeInternalConfigProps, @@ -5,7 +6,6 @@ import type { SingleGesture, WithSharedValue, } from '../../../types'; -import type { StylusData } from '../../../../handlers/gestureHandlerCommon'; type CommonPanGestureProperties = { /** diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts index be1f920c47..ea189da672 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts @@ -3,6 +3,13 @@ import type { HandlerData, WithSharedValue, } from '../../../types'; +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { + getChangeEventCalculator, + maybeUnpackValue, + useClonedAndRemappedConfig, +} from '../../utils'; import type { OffsetProps, PanExtendedHandlerData, @@ -13,13 +20,6 @@ import type { PanGestureProperties, PanHandlerData, } from './PanTypes'; -import { - getChangeEventCalculator, - maybeUnpackValue, - useClonedAndRemappedConfig, -} from '../../utils'; -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; const PanPropsMapping = new Map< keyof PanGestureProperties, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts index e7013b0d11..8ea4d2ee44 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts @@ -1,4 +1,10 @@ import type { GestureEvent, HandlerData } from '../../../types'; +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { + getChangeEventCalculator, + useClonedAndRemappedConfig, +} from '../../utils'; import type { PinchExtendedHandlerData, PinchGesture, @@ -7,12 +13,6 @@ import type { PinchGestureProperties, PinchHandlerData, } from './PinchTypes'; -import { - getChangeEventCalculator, - useClonedAndRemappedConfig, -} from '../../utils'; -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; function diffCalculator( current: HandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts index b46fe11ace..2d50b9e8d5 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts @@ -1,4 +1,10 @@ import type { GestureEvent, HandlerData } from '../../../types'; +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { + getChangeEventCalculator, + useClonedAndRemappedConfig, +} from '../../utils'; import type { RotationExtendedHandlerData, RotationGesture, @@ -7,12 +13,6 @@ import type { RotationGestureProperties, RotationHandlerData, } from './RotationTypes'; -import { - getChangeEventCalculator, - useClonedAndRemappedConfig, -} from '../../utils'; -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; function diffCalculator( current: HandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts index 87985f66f5..60666db7d5 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts @@ -1,3 +1,6 @@ +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; +import { useClonedAndRemappedConfig } from '../../utils'; import type { TapGesture, TapGestureConfig, @@ -5,9 +8,6 @@ import type { TapGestureProperties, TapHandlerData, } from './TapTypes'; -import { SingleGestureName } from '../../../types'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { useGesture } from '../../useGesture'; const TapPropsMapping = new Map< keyof TapGestureProperties, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts index 124fe65394..774c979771 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts @@ -1,8 +1,19 @@ +import { useEffect, useMemo, useRef } from 'react'; + +import { getNextHandlerTag } from '../../handlers/getNextHandlerTag'; +import { + registerGesture, + unregisterGesture, +} from '../../handlers/handlersRegistry'; +import { scheduleFlushOperations } from '../../handlers/utils'; +import { tagMessage } from '../../utils'; +import { NativeProxy } from '../NativeProxy'; import type { BaseGestureConfig, SingleGesture, SingleGestureName, } from '../types'; +import { useGestureCallbacks } from './useGestureCallbacks'; import { bindSharedValues, prepareConfig, @@ -10,16 +21,6 @@ import { prepareRelations, unbindSharedValues, } from './utils'; -import { - registerGesture, - unregisterGesture, -} from '../../handlers/handlersRegistry'; -import { useEffect, useMemo, useRef } from 'react'; -import { NativeProxy } from '../NativeProxy'; -import { getNextHandlerTag } from '../../handlers/getNextHandlerTag'; -import { scheduleFlushOperations } from '../../handlers/utils'; -import { tagMessage } from '../../utils'; -import { useGestureCallbacks } from './useGestureCallbacks'; export function useGesture< TConfig, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/useGestureCallbacks.ts b/packages/react-native-gesture-handler/src/v3/hooks/useGestureCallbacks.ts index a1b0bb4643..6f58ad6e45 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/useGestureCallbacks.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/useGestureCallbacks.ts @@ -1,17 +1,17 @@ +import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; +import { tagMessage } from '../../utils'; import type { AnimatedEvent, BaseGestureConfig, GestureUpdateEventWithHandlerData, } from '../types'; +import { useGestureEventHandler } from './callbacks/useGestureEventHandler'; +import { useReanimatedEventHandler } from './callbacks/useReanimatedEventHandler'; import { checkMappingForChangeProperties, isNativeAnimatedEvent, useMemoizedGestureCallbacks, } from './utils'; -import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; -import { tagMessage } from '../../utils'; -import { useGestureEventHandler } from './callbacks/useGestureEventHandler'; -import { useReanimatedEventHandler } from './callbacks/useReanimatedEventHandler'; function guardJSAnimatedEvent(handler: (...args: unknown[]) => void) { return (...args: unknown[]) => { diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts index 5fa4b16dc5..d728407101 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts @@ -1,19 +1,20 @@ +import { useMemo } from 'react'; + +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import { tagMessage } from '../../../utils'; import type { BaseGestureConfig, ExcludeInternalConfigProps, SingleGestureName, } from '../../types'; +import { isNativeAnimatedEvent, shouldHandleTouchEvents } from './eventUtils'; import { + allowedNativeProps, EMPTY_WHITE_LIST, PropsToFilter, PropsWhiteLists, - allowedNativeProps, } from './propsWhiteList'; import { hasWorkletEventHandlers, maybeUnpackValue } from './reanimatedUtils'; -import { isNativeAnimatedEvent, shouldHandleTouchEvents } from './eventUtils'; -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; -import { tagMessage } from '../../../utils'; -import { useMemo } from 'react'; export function prepareConfig< TConfig extends object, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts index 7270edcd74..ec44f33f85 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts @@ -1,13 +1,14 @@ +import { useMemo } from 'react'; + +import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; +import { TouchEventType } from '../../../TouchEventType'; import type { GestureCallbacks, + GestureEndEventCallback, GestureEventCallback, GestureTouchEventCallback, UnpackedGestureHandlerEvent, } from '../../types'; -import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; -import type { GestureEndEventCallback } from '../../types/ConfigTypes'; -import { TouchEventType } from '../../../TouchEventType'; -import { useMemo } from 'react'; export function useMemoizedGestureCallbacks< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/eventUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/eventUtils.ts index cf736bf833..199811cf60 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/eventUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/eventUtils.ts @@ -1,3 +1,7 @@ +import type { NativeSyntheticEvent } from 'react-native'; + +import type { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; +import { tagMessage } from '../../../utils'; import type { AnimatedEvent, BaseGestureConfig, @@ -8,9 +12,6 @@ import type { GestureStateChangeEventWithHandlerData, GestureUpdateEventWithHandlerData, } from '../../types'; -import type { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; -import type { NativeSyntheticEvent } from 'react-native'; -import { tagMessage } from '../../../utils'; function isNativeEvent( event: GestureHandlerEventWithHandlerData diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/index.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/index.ts index cde49f2a1f..b35971b51a 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/index.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/index.ts @@ -3,41 +3,36 @@ export { prepareConfigForNativeSide, useClonedAndRemappedConfig, } from './configUtils'; - export { - useMemoizedGestureCallbacks, - touchEventTypeToCallbackType, runCallback, + touchEventTypeToCallbackType, + useMemoizedGestureCallbacks, } from './eventHandlersUtils'; - export { - maybeExtractNativeEvent, + checkMappingForChangeProperties, flattenAndFilterEvent, + getChangeEventCalculator, isEventForHandlerWithTag, isNativeAnimatedEvent, - checkMappingForChangeProperties, + maybeExtractNativeEvent, shouldHandleTouchEvents, - getChangeEventCalculator, } from './eventUtils'; - +export { + allowedNativeProps, + EMPTY_WHITE_LIST, + HandlerCallbacks, + NativeWrapperProps, + PropsToFilter, + PropsWhiteLists, +} from './propsWhiteList'; export { bindSharedValues, - unbindSharedValues, hasWorkletEventHandlers, maybeUnpackValue, + unbindSharedValues, } from './reanimatedUtils'; - export { + containsDuplicates, isComposedGesture, prepareRelations, - containsDuplicates, } from './relationUtils'; - -export { - allowedNativeProps, - NativeWrapperProps, - HandlerCallbacks, - PropsToFilter, - PropsWhiteLists, - EMPTY_WHITE_LIST, -} from './propsWhiteList'; diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts index a9110bd0a0..62994eb844 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts @@ -6,13 +6,13 @@ import type { HandlersPropsWhiteList, InternalConfigProps, } from '../../types'; +import { SingleGestureName } from '../../types'; +import type { NativeWrapperProperties } from '../../types/NativeWrapperType'; import { FlingNativeProperties } from '../gestures/fling/FlingTypes'; import { HoverNativeProperties } from '../gestures/hover/HoverTypes'; import { LongPressNativeProperties } from '../gestures/longPress/LongPressTypes'; import { NativeHandlerNativeProperties } from '../gestures/native/NativeTypes'; -import type { NativeWrapperProperties } from '../../types/NativeWrapperType'; import { PanNativeProperties } from '../gestures/pan/PanTypes'; -import { SingleGestureName } from '../../types'; import { TapNativeProperties } from '../gestures/tap/TapTypes'; const CommonConfig = new Set([ diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts index 6ecc7e493f..956e1b8414 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts @@ -1,3 +1,5 @@ +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import { NativeProxy } from '../../NativeProxy'; import type { BaseGestureConfig, GestureCallbacks, @@ -5,8 +7,6 @@ import type { SharedValueOrT, } from '../../types'; import { HandlerCallbacks } from './propsWhiteList'; -import { NativeProxy } from '../../NativeProxy'; -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; // Variant of djb2 hash function. // Taken from https://gist.github.com/eplawless/52813b1d8ad9af510d85?permalink_comment_id=3367765#gistcomment-3367765 diff --git a/packages/react-native-gesture-handler/src/v3/index.ts b/packages/react-native-gesture-handler/src/v3/index.ts index 0724951615..d226128862 100644 --- a/packages/react-native-gesture-handler/src/v3/index.ts +++ b/packages/react-native-gesture-handler/src/v3/index.ts @@ -1,88 +1,83 @@ +export type { + BaseButtonProps, + BorderlessButtonProps, + RawButtonProps, + RectButtonProps, + TouchableProps, +} from './components'; +export { + BaseButton, + BorderlessButton, + FlatList, + Pressable, + RawButton, + RectButton, + RefreshControl, + ScrollView, + Switch, + TextInput, + Touchable, +} from './components'; export type { GestureDetectorProps } from './detectors'; export { GestureDetector, - VirtualGestureDetector, - InterceptingGestureDetector, GestureDetectorType, + InterceptingGestureDetector, + VirtualGestureDetector, } from './detectors'; - +export { GestureStateManager } from './gestureStateManager'; export type { - TapGesture, - TapGestureConfig, - TapGestureEvent, - TapGestureActiveEvent, FlingGesture, + FlingGestureActiveEvent, FlingGestureConfig, FlingGestureEvent, - FlingGestureActiveEvent, - LongPressGesture, - LongPressGestureConfig, - LongPressGestureEvent, - LongPressGestureActiveEvent, - PinchGesture, - PinchGestureConfig, - PinchGestureEvent, - PinchGestureActiveEvent, - RotationGesture, - RotationGestureConfig, - RotationGestureEvent, - RotationGestureActiveEvent, HoverGesture, + HoverGestureActiveEvent, HoverGestureConfig, HoverGestureEvent, - HoverGestureActiveEvent, + LongPressGesture, + LongPressGestureActiveEvent, + LongPressGestureConfig, + LongPressGestureEvent, ManualGesture, + ManualGestureActiveEvent, ManualGestureConfig, ManualGestureEvent, - ManualGestureActiveEvent, NativeGesture, + NativeGestureActiveEvent, NativeGestureConfig, NativeGestureEvent, - NativeGestureActiveEvent, PanGesture, + PanGestureActiveEvent, PanGestureConfig, PanGestureEvent, - PanGestureActiveEvent, + PinchGesture, + PinchGestureActiveEvent, + PinchGestureConfig, + PinchGestureEvent, + RotationGesture, + RotationGestureActiveEvent, + RotationGestureConfig, + RotationGestureEvent, SingleGesture, SingleGestureEvent, + TapGesture, + TapGestureActiveEvent, + TapGestureConfig, + TapGestureEvent, } from './hooks'; export { - useSimultaneousGestures, - useExclusiveGestures, useCompetingGestures, - useTapGesture, + useExclusiveGestures, useFlingGesture, - useLongPressGesture, - usePinchGesture, - useRotationGesture, useHoverGesture, + useLongPressGesture, useManualGesture, useNativeGesture, usePanGesture, + usePinchGesture, + useRotationGesture, + useSimultaneousGestures, + useTapGesture, } from './hooks'; - -export type { - RawButtonProps, - BaseButtonProps, - RectButtonProps, - BorderlessButtonProps, - TouchableProps, -} from './components'; - -export { - RawButton, - BaseButton, - RectButton, - BorderlessButton, - Pressable, - ScrollView, - Switch, - TextInput, - FlatList, - RefreshControl, - Touchable, -} from './components'; - export type { ComposedGesture } from './types'; - -export { GestureStateManager } from './gestureStateManager'; diff --git a/packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts b/packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts index 87624fc789..ab3d164759 100644 --- a/packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts @@ -1,12 +1,12 @@ +import type { + TouchAction, + UserSelect, +} from '../../handlers/gestureHandlerCommon'; import type { AnimatedEvent, GestureHandlerEventWithHandlerData, GestureUpdateEventWithHandlerData, } from './EventTypes'; -import type { - TouchAction, - UserSelect, -} from '../../handlers/gestureHandlerCommon'; export type DetectorCallbacks< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/types/EventTypes.ts b/packages/react-native-gesture-handler/src/v3/types/EventTypes.ts index 542a456c0c..9fdcfe6029 100644 --- a/packages/react-native-gesture-handler/src/v3/types/EventTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/types/EventTypes.ts @@ -1,4 +1,5 @@ import type { Animated, NativeSyntheticEvent } from 'react-native'; + import type { GestureTouchEvent } from '../../handlers/gestureHandlerCommon'; import type { PointerType } from '../../PointerType'; import type { State } from '../../State'; diff --git a/packages/react-native-gesture-handler/src/v3/types/NativeWrapperType.ts b/packages/react-native-gesture-handler/src/v3/types/NativeWrapperType.ts index 2e581279b5..db30a78c32 100644 --- a/packages/react-native-gesture-handler/src/v3/types/NativeWrapperType.ts +++ b/packages/react-native-gesture-handler/src/v3/types/NativeWrapperType.ts @@ -1,14 +1,13 @@ -import type { - CommonGestureConfig, - ExternalRelations, - GestureCallbacks, -} from '.'; - import type { NativeGesture, NativeGestureNativeProperties, NativeHandlerData, } from '../hooks/gestures/native/NativeTypes'; +import type { + CommonGestureConfig, + ExternalRelations, + GestureCallbacks, +} from '.'; export type WrapperSpecificProperties = { ref?: React.Ref | undefined; diff --git a/packages/react-native-gesture-handler/src/v3/types/UtilityTypes.ts b/packages/react-native-gesture-handler/src/v3/types/UtilityTypes.ts index 617e77fa73..10d2a50d2a 100644 --- a/packages/react-native-gesture-handler/src/v3/types/UtilityTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/types/UtilityTypes.ts @@ -1,10 +1,10 @@ import type { FlingGestureNativeProperties } from '../hooks/gestures/fling/FlingTypes'; import type { HoverGestureNativeProperties } from '../hooks/gestures/hover/HoverTypes'; -import type { InternalConfigProps } from './ConfigTypes'; import type { LongPressGestureNativeProperties } from '../hooks/gestures/longPress/LongPressTypes'; import type { NativeGestureNativeProperties } from '../hooks/gestures/native/NativeTypes'; import type { PanGestureNativeProperties } from '../hooks/gestures/pan/PanTypes'; import type { TapGestureNativeConfig } from '../hooks/gestures/tap/TapTypes'; +import type { InternalConfigProps } from './ConfigTypes'; export type HandlersPropsWhiteList = | Set diff --git a/packages/react-native-gesture-handler/src/v3/types/index.ts b/packages/react-native-gesture-handler/src/v3/types/index.ts index 7f6f9ae9c6..33f2bbaf0a 100644 --- a/packages/react-native-gesture-handler/src/v3/types/index.ts +++ b/packages/react-native-gesture-handler/src/v3/types/index.ts @@ -1,52 +1,48 @@ export type { - SharedValue, - SharedValueOrT, - WithSharedValue, -} from './ReanimatedTypes'; - -export type { - HandlerData, - GestureUpdateEventWithHandlerData, - GestureStateChangeEventWithHandlerData, - GestureHandlerEventWithHandlerData, - UnpackedGestureHandlerEventWithHandlerData, - UnpackedGestureHandlerEvent, - UpdateEventWithHandlerData, - StateChangeEventWithHandlerData, - TouchEvent, - GestureEvent, - GestureEndEvent, - AnimatedEvent, - ChangeCalculatorType, - DiffCalculatorType, -} from './EventTypes'; - -export type { + CommonGestureConfig, + ComposedGestureConfig, GestureCallbacks, + GestureEndEventCallback, GestureEventCallback, - GestureTouchEventCallback, GestureRelations, + GestureTouchEventCallback, InternalConfigProps, - CommonGestureConfig, - ComposedGestureConfig, } from './ConfigTypes'; - export type { DetectorCallbacks, VirtualChild } from './DetectorTypes'; - -export { SingleGestureName, ComposedGestureName } from './GestureTypes'; export type { - ExternalRelations, + AnimatedEvent, + ChangeCalculatorType, + DiffCalculatorType, + GestureEndEvent, + GestureEvent, + GestureHandlerEventWithHandlerData, + GestureStateChangeEventWithHandlerData, + GestureUpdateEventWithHandlerData, + HandlerData, + StateChangeEventWithHandlerData, + TouchEvent, + UnpackedGestureHandlerEvent, + UnpackedGestureHandlerEventWithHandlerData, + UpdateEventWithHandlerData, +} from './EventTypes'; +export type { + AnyGesture, BaseDiscreteGestureConfig, BaseGestureConfig, - SingleGesture, - DiscreteSingleGesture, ComposedGesture, + DiscreteSingleGesture, + ExternalRelations, Gesture, - AnyGesture, + SingleGesture, } from './GestureTypes'; - +export { ComposedGestureName, SingleGestureName } from './GestureTypes'; +export type { + SharedValue, + SharedValueOrT, + WithSharedValue, +} from './ReanimatedTypes'; export type { - HandlersPropsWhiteList, - FilterNeverProperties, ExcludeInternalConfigProps, + FilterNeverProperties, + HandlersPropsWhiteList, } from './UtilityTypes'; diff --git a/packages/react-native-gesture-handler/src/web/detectors/ScaleGestureDetector.ts b/packages/react-native-gesture-handler/src/web/detectors/ScaleGestureDetector.ts index bbdd921d63..f2778bff97 100644 --- a/packages/react-native-gesture-handler/src/web/detectors/ScaleGestureDetector.ts +++ b/packages/react-native-gesture-handler/src/web/detectors/ScaleGestureDetector.ts @@ -1,5 +1,5 @@ -import type { AdaptedEvent } from '../interfaces'; import { DEFAULT_TOUCH_SLOP } from '../constants'; +import type { AdaptedEvent } from '../interfaces'; import { EventTypes } from '../interfaces'; import type PointerTracker from '../tools/PointerTracker'; diff --git a/packages/react-native-gesture-handler/src/web/handlers/FlingGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/FlingGestureHandler.ts index 1d22c73a16..8150c0a50c 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/FlingGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/FlingGestureHandler.ts @@ -1,12 +1,12 @@ -import type { AdaptedEvent, Config } from '../interfaces'; import { DiagonalDirections, Directions } from '../../Directions'; -import GestureHandler from './GestureHandler'; -import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; -import type IGestureHandler from './IGestureHandler'; -import { SingleGestureName } from '../../v3/types'; import { State } from '../../State'; +import { SingleGestureName } from '../../v3/types'; +import type { AdaptedEvent, Config } from '../interfaces'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; import Vector from '../tools/Vector'; import { coneToDeviation } from '../utils'; +import GestureHandler from './GestureHandler'; +import type IGestureHandler from './IGestureHandler'; const DEFAULT_MAX_DURATION_MS = 800; const DEFAULT_MIN_VELOCITY = 700; diff --git a/packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts index 71596acd79..d4983d237e 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts @@ -6,6 +6,16 @@ import type { TouchAction, UserSelect, } from '../../handlers/gestureHandlerCommon'; +import { MouseButton } from '../../handlers/gestureHandlerCommon'; +import { PointerType } from '../../PointerType'; +import { State } from '../../State'; +import { TouchEventType } from '../../TouchEventType'; +import { tagMessage } from '../../utils'; +import type { + GestureStateChangeEventWithHandlerData, + GestureUpdateEventWithHandlerData, + SingleGestureName, +} from '../../v3/types'; import type { AdaptedEvent, Config, @@ -15,24 +25,14 @@ import type { PropsRef, ResultEvent, } from '../interfaces'; -import type { - GestureStateChangeEventWithHandlerData, - GestureUpdateEventWithHandlerData, - SingleGestureName, -} from '../../v3/types'; -import type EventManager from '../tools/EventManager'; import { EventTypes } from '../interfaces'; +import type EventManager from '../tools/EventManager'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator'; -import type IGestureHandler from './IGestureHandler'; import InteractionManager from '../tools/InteractionManager'; -import { MouseButton } from '../../handlers/gestureHandlerCommon'; -import PointerTracker from '../tools/PointerTracker'; -import { PointerType } from '../../PointerType'; -import { State } from '../../State'; -import { TouchEventType } from '../../TouchEventType'; import type { TrackerElement } from '../tools/PointerTracker'; -import { tagMessage } from '../../utils'; +import PointerTracker from '../tools/PointerTracker'; +import type IGestureHandler from './IGestureHandler'; export default abstract class GestureHandler implements IGestureHandler { private _name!: SingleGestureName; diff --git a/packages/react-native-gesture-handler/src/web/handlers/HoverGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/HoverGestureHandler.ts index 8866511a66..7fe40f5e8d 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/HoverGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/HoverGestureHandler.ts @@ -1,11 +1,11 @@ +import type { StylusData } from '../../handlers/gestureHandlerCommon'; +import { State } from '../../State'; +import { SingleGestureName } from '../../v3/types'; import type { AdaptedEvent } from '../interfaces'; -import GestureHandler from './GestureHandler'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator'; +import GestureHandler from './GestureHandler'; import type IGestureHandler from './IGestureHandler'; -import { SingleGestureName } from '../../v3/types'; -import { State } from '../../State'; -import type { StylusData } from '../../handlers/gestureHandlerCommon'; export default class HoverGestureHandler extends GestureHandler { private stylusData: StylusData | undefined; diff --git a/packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts index b8927f3970..c736ad33a9 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts @@ -4,13 +4,13 @@ import type { TouchAction, UserSelect, } from '../../handlers/gestureHandlerCommon'; +import type { PointerType } from '../../PointerType'; +import type { State } from '../../State'; +import type { SingleGestureName } from '../../v3/types'; import type { Config } from '../interfaces'; import type EventManager from '../tools/EventManager'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; import type PointerTracker from '../tools/PointerTracker'; -import type { PointerType } from '../../PointerType'; -import type { SingleGestureName } from '../../v3/types'; -import type { State } from '../../State'; export default interface IGestureHandler { attached: boolean; diff --git a/packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts index 598fcda2dc..5044318380 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts @@ -1,10 +1,10 @@ -import type { AdaptedEvent, Config, PropsRef } from '../interfaces'; import type { ActionType } from '../../ActionType'; -import GestureHandler from './GestureHandler'; +import { State } from '../../State'; +import { SingleGestureName } from '../../v3/types'; +import type { AdaptedEvent, Config, PropsRef } from '../interfaces'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandler from './GestureHandler'; import type IGestureHandler from './IGestureHandler'; -import { SingleGestureName } from '../../v3/types'; -import { State } from '../../State'; const DEFAULT_MIN_DURATION_MS = 500; const DEFAULT_MAX_DIST_DP = 10; diff --git a/packages/react-native-gesture-handler/src/web/handlers/ManualGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/ManualGestureHandler.ts index 258f2efb67..75faefcf1f 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/ManualGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/ManualGestureHandler.ts @@ -1,8 +1,8 @@ +import { SingleGestureName } from '../../v3/types'; import type { AdaptedEvent } from '../interfaces'; -import GestureHandler from './GestureHandler'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandler from './GestureHandler'; import type IGestureHandler from './IGestureHandler'; -import { SingleGestureName } from '../../v3/types'; export default class ManualGestureHandler extends GestureHandler { public constructor( diff --git a/packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts index 8da55feb3c..c96a234818 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts @@ -1,12 +1,13 @@ -import type { AdaptedEvent, Config, PropsRef } from '../interfaces'; +import { Platform } from 'react-native'; + import type { ActionType } from '../../ActionType'; +import { State } from '../../State'; +import { SingleGestureName } from '../../v3/types'; import { DEFAULT_TOUCH_SLOP } from '../constants'; -import GestureHandler from './GestureHandler'; +import type { AdaptedEvent, Config, PropsRef } from '../interfaces'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandler from './GestureHandler'; import type IGestureHandler from './IGestureHandler'; -import { Platform } from 'react-native'; -import { SingleGestureName } from '../../v3/types'; -import { State } from '../../State'; export default class NativeViewGestureHandler extends GestureHandler { private buttonRole!: boolean; diff --git a/packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts index 30f6859a3f..1d8de177d7 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts @@ -1,12 +1,12 @@ -import type { AdaptedEvent, Config } from '../interfaces'; +import type { StylusData } from '../../handlers/gestureHandlerCommon'; +import { State } from '../../State'; +import { SingleGestureName } from '../../v3/types'; import { DEFAULT_TOUCH_SLOP } from '../constants'; -import GestureHandler from './GestureHandler'; +import type { AdaptedEvent, Config } from '../interfaces'; +import { WheelDevice } from '../interfaces'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandler from './GestureHandler'; import type IGestureHandler from './IGestureHandler'; -import { SingleGestureName } from '../../v3/types'; -import { State } from '../../State'; -import type { StylusData } from '../../handlers/gestureHandlerCommon'; -import { WheelDevice } from '../interfaces'; const DEFAULT_MIN_POINTERS = 1; const DEFAULT_MAX_POINTERS = 10; diff --git a/packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts index c5b3c847ff..3e382b3eac 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts @@ -1,13 +1,13 @@ -import type { AdaptedEvent, PropsRef } from '../interfaces'; import type { ActionType } from '../../ActionType'; +import { State } from '../../State'; +import { SingleGestureName } from '../../v3/types'; import { DEFAULT_TOUCH_SLOP } from '../constants'; -import GestureHandler from './GestureHandler'; +import type { ScaleGestureListener } from '../detectors/ScaleGestureDetector'; +import ScaleGestureDetector from '../detectors/ScaleGestureDetector'; +import type { AdaptedEvent, PropsRef } from '../interfaces'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandler from './GestureHandler'; import type IGestureHandler from './IGestureHandler'; -import ScaleGestureDetector from '../detectors/ScaleGestureDetector'; -import type { ScaleGestureListener } from '../detectors/ScaleGestureDetector'; -import { SingleGestureName } from '../../v3/types'; -import { State } from '../../State'; export default class PinchGestureHandler extends GestureHandler { private scale = 1; diff --git a/packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts index d59320f05f..8ec0a4bcb0 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts @@ -1,12 +1,12 @@ -import type { AdaptedEvent, PropsRef } from '../interfaces'; import type { ActionType } from '../../ActionType'; -import GestureHandler from './GestureHandler'; +import { State } from '../../State'; +import { SingleGestureName } from '../../v3/types'; +import type { RotationGestureListener } from '../detectors/RotationGestureDetector'; +import RotationGestureDetector from '../detectors/RotationGestureDetector'; +import type { AdaptedEvent, PropsRef } from '../interfaces'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandler from './GestureHandler'; import type IGestureHandler from './IGestureHandler'; -import RotationGestureDetector from '../detectors/RotationGestureDetector'; -import type { RotationGestureListener } from '../detectors/RotationGestureDetector'; -import { SingleGestureName } from '../../v3/types'; -import { State } from '../../State'; const ROTATION_RECOGNITION_THRESHOLD = Math.PI / 36; diff --git a/packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts index dc3b0a4267..4afe556377 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts @@ -1,10 +1,10 @@ +import { State } from '../../State'; +import { SingleGestureName } from '../../v3/types'; import type { AdaptedEvent, Config } from '../interfaces'; import { EventTypes } from '../interfaces'; -import GestureHandler from './GestureHandler'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandler from './GestureHandler'; import type IGestureHandler from './IGestureHandler'; -import { SingleGestureName } from '../../v3/types'; -import { State } from '../../State'; const DEFAULT_MAX_DURATION_MS = 500; const DEFAULT_MAX_DELAY_MS = 500; diff --git a/packages/react-native-gesture-handler/src/web/interfaces.ts b/packages/react-native-gesture-handler/src/web/interfaces.ts index 7c60f36af0..4ba42668fd 100644 --- a/packages/react-native-gesture-handler/src/web/interfaces.ts +++ b/packages/react-native-gesture-handler/src/web/interfaces.ts @@ -1,3 +1,4 @@ +import type { Directions } from '../Directions'; import type { ActiveCursor, GestureTouchEvent, @@ -6,13 +7,12 @@ import type { TouchAction, UserSelect, } from '../handlers/gestureHandlerCommon'; +import type { PointerType } from '../PointerType'; +import type { State } from '../State'; import type { GestureStateChangeEventWithHandlerData, GestureUpdateEventWithHandlerData, } from '../v3/types'; -import type { Directions } from '../Directions'; -import type { PointerType } from '../PointerType'; -import type { State } from '../State'; export interface HitSlop { left?: number | undefined; diff --git a/packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts b/packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts index 9ed5b28040..339dc3d846 100644 --- a/packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts +++ b/packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts @@ -1,7 +1,7 @@ -import type IGestureHandler from '../handlers/IGestureHandler'; -import PointerTracker from './PointerTracker'; import { PointerType } from '../../PointerType'; import { State } from '../../State'; +import type IGestureHandler from '../handlers/IGestureHandler'; +import PointerTracker from './PointerTracker'; export default class GestureHandlerOrchestrator { private static _instance: GestureHandlerOrchestrator; diff --git a/packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts b/packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts index 7aa46abfad..50e45e0b18 100644 --- a/packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts +++ b/packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts @@ -1,18 +1,18 @@ +import findNodeHandle from '../../findNodeHandle'; +import { MouseButton } from '../../handlers/gestureHandlerCommon'; +import { State } from '../../State'; +import { tagMessage } from '../../utils'; +import { SingleGestureName } from '../../v3/types'; +import type IGestureHandler from '../handlers/IGestureHandler'; +import { getEffectiveBoundingRect, isPointerInBounds } from '../utils'; +import type EventManager from './EventManager'; import type { GestureHandlerDelegate, MeasureResult, } from './GestureHandlerDelegate'; -import { getEffectiveBoundingRect, isPointerInBounds } from '../utils'; -import type EventManager from './EventManager'; -import type IGestureHandler from '../handlers/IGestureHandler'; import KeyboardEventManager from './KeyboardEventManager'; -import { MouseButton } from '../../handlers/gestureHandlerCommon'; import PointerEventManager from './PointerEventManager'; -import { SingleGestureName } from '../../v3/types'; -import { State } from '../../State'; import WheelEventManager from './WheelEventManager'; -import findNodeHandle from '../../findNodeHandle'; -import { tagMessage } from '../../utils'; interface DefaultViewStyles { userSelect: string; diff --git a/packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts b/packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts index d09b523c33..6472c1c110 100644 --- a/packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts @@ -1,7 +1,7 @@ -import type { Config, Handler } from '../interfaces'; import type { GestureRelations } from '../../v3/types'; -import type IGestureHandler from '../handlers/IGestureHandler'; import { SingleGestureName } from '../../v3/types'; +import type IGestureHandler from '../handlers/IGestureHandler'; +import type { Config, Handler } from '../interfaces'; export default class InteractionManager { private static _instance: InteractionManager; diff --git a/packages/react-native-gesture-handler/src/web/tools/KeyboardEventManager.ts b/packages/react-native-gesture-handler/src/web/tools/KeyboardEventManager.ts index 394e39b06f..f138c0a199 100644 --- a/packages/react-native-gesture-handler/src/web/tools/KeyboardEventManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/KeyboardEventManager.ts @@ -1,7 +1,7 @@ +import { PointerType } from '../../PointerType'; import type { AdaptedEvent } from '../interfaces'; -import EventManager from './EventManager'; import { EventTypes } from '../interfaces'; -import { PointerType } from '../../PointerType'; +import EventManager from './EventManager'; export default class KeyboardEventManager extends EventManager { private static activationKeys = ['Enter', ' ']; diff --git a/packages/react-native-gesture-handler/src/web/tools/NodeManager.ts b/packages/react-native-gesture-handler/src/web/tools/NodeManager.ts index 6d055a4d0d..e63777a76e 100644 --- a/packages/react-native-gesture-handler/src/web/tools/NodeManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/NodeManager.ts @@ -1,6 +1,6 @@ +import type { ValueOf } from '../../typeUtils'; import type { Gestures } from '../Gestures'; import type IGestureHandler from '../handlers/IGestureHandler'; -import type { ValueOf } from '../../typeUtils'; // eslint-disable-next-line @typescript-eslint/no-extraneous-class export default abstract class NodeManager { diff --git a/packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts b/packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts index e081c749fe..1c44cf2e9e 100644 --- a/packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts @@ -1,14 +1,14 @@ +import { PointerType } from '../../PointerType'; import type { AdaptedEvent, Point } from '../interfaces'; +import { EventTypes } from '../interfaces'; import { - PointerTypeMapping, calculateViewScale, getEffectiveBoundingRect, isPointerInBounds, + PointerTypeMapping, tryExtractStylusData, } from '../utils'; import EventManager from './EventManager'; -import { EventTypes } from '../interfaces'; -import { PointerType } from '../../PointerType'; const POINTER_CAPTURE_EXCLUDE_LIST = new Set(['SELECT', 'INPUT']); diff --git a/packages/react-native-gesture-handler/src/web/tools/WheelEventManager.ts b/packages/react-native-gesture-handler/src/web/tools/WheelEventManager.ts index fa1aff8c98..d7430c021a 100644 --- a/packages/react-native-gesture-handler/src/web/tools/WheelEventManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/WheelEventManager.ts @@ -1,7 +1,7 @@ +import { PointerType } from '../../PointerType'; import type { AdaptedEvent } from '../interfaces'; -import EventManager from './EventManager'; import { EventTypes } from '../interfaces'; -import { PointerType } from '../../PointerType'; +import EventManager from './EventManager'; export default class WheelEventManager extends EventManager { private wheelDelta = { x: 0, y: 0 }; diff --git a/packages/react-native-gesture-handler/src/web/utils.ts b/packages/react-native-gesture-handler/src/web/utils.ts index 82980756aa..4e9c5b25d2 100644 --- a/packages/react-native-gesture-handler/src/web/utils.ts +++ b/packages/react-native-gesture-handler/src/web/utils.ts @@ -1,6 +1,6 @@ -import type { GestureHandlerRef, Point, SVGRef } from './interfaces'; -import { PointerType } from '../PointerType'; import type { StylusData } from '../handlers/gestureHandlerCommon'; +import { PointerType } from '../PointerType'; +import type { GestureHandlerRef, Point, SVGRef } from './interfaces'; // For display: contents elements (like the gesture detector wrapper), getBoundingClientRect // returns all zeros since the element has no box. Compute the bounding box from children instead. diff --git a/yarn.lock b/yarn.lock index e78bdaa6a4..3591516eaf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8460,6 +8460,15 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-simple-import-sort@npm:^13.0.0": + version: 13.0.0 + resolution: "eslint-plugin-simple-import-sort@npm:13.0.0" + peerDependencies: + eslint: ">=5.0.0" + checksum: 10c0/f561f3483c1c18dfa2705326d38d62c62d4aeb5947ed6d1f028299c5dc668586b5ef144926e68fe187b3a937ee0159738dcbca8c286fe56f489de52fd8f9e678 + languageName: node + linkType: hard + "eslint-rule-composer@npm:^0.3.0": version: 0.3.0 resolution: "eslint-rule-composer@npm:0.3.0" @@ -14531,6 +14540,7 @@ __metadata: eslint-plugin-jest: "npm:27.4.3" eslint-plugin-prettier: "npm:^5.0.1" eslint-plugin-react: "npm:^7.37.5" + eslint-plugin-simple-import-sort: "npm:^13.0.0" husky: "npm:^8.0.1" jest: "npm:^28.1.0" lint-staged: "npm:^12.3.2"