From 10266f0f58d91c209aa2cf080cfeef267455309b Mon Sep 17 00:00:00 2001 From: aelassas Date: Wed, 18 Dec 2024 03:25:44 +0100 Subject: [PATCH] Update AutocompleteDropdown --- .../AutocompleteDropdownContext.tsx | 6 ++-- .../HOC/withFadeAnimation.tsx | 33 +++++++++---------- .../NothingFound.tsx | 1 + .../ScrollViewListItem.tsx | 2 ++ .../diacriticless.ts | 2 ++ .../types/global.d.ts | 1 + .../useKeyboardHeight.ts | 2 +- mobile/components/Booking.tsx | 2 +- 8 files changed, 27 insertions(+), 22 deletions(-) diff --git a/mobile/components/AutocompleteDropdown-v4.3.1/AutocompleteDropdownContext.tsx b/mobile/components/AutocompleteDropdown-v4.3.1/AutocompleteDropdownContext.tsx index b4a74bd55..33b16a9b3 100644 --- a/mobile/components/AutocompleteDropdown-v4.3.1/AutocompleteDropdownContext.tsx +++ b/mobile/components/AutocompleteDropdown-v4.3.1/AutocompleteDropdownContext.tsx @@ -85,9 +85,9 @@ export const AutocompleteDropdownContextProvider: FC - JSON.stringify(prev) === JSON.stringify(currentMeasurement) ? prev : currentMeasurement, - ) + setInputMeasurements((prev) => + (JSON.stringify(prev) === JSON.stringify(currentMeasurement) ? prev : currentMeasurement),) + // eslint-disable-next-line @typescript-eslint/no-unused-expressions showAfterCalculation && setShow(true) }) }) diff --git a/mobile/components/AutocompleteDropdown-v4.3.1/HOC/withFadeAnimation.tsx b/mobile/components/AutocompleteDropdown-v4.3.1/HOC/withFadeAnimation.tsx index 4897ec237..015d35ead 100644 --- a/mobile/components/AutocompleteDropdown-v4.3.1/HOC/withFadeAnimation.tsx +++ b/mobile/components/AutocompleteDropdown-v4.3.1/HOC/withFadeAnimation.tsx @@ -10,23 +10,22 @@ interface WithFadeAnimationProps { export const withFadeAnimation =

( WrappedComponent: ComponentType

, { containerStyle }: WithFadeAnimationProps = {}, -): FC

=> { - return (props: P) => { - const opacityAnimationValue = useRef(new Animated.Value(0)).current + // eslint-disable-next-line react/display-name +): FC

=> function (props: P) { + const opacityAnimationValue = useRef(new Animated.Value(0)).current - useEffect(() => { - Animated.timing(opacityAnimationValue, { - duration: 800, - toValue: 1, - useNativeDriver: true, - easing: Easing.bezier(0.3, 0.58, 0.25, 0.99), - }).start() - }, [opacityAnimationValue]) + useEffect(() => { + Animated.timing(opacityAnimationValue, { + duration: 800, + toValue: 1, + useNativeDriver: true, + easing: Easing.bezier(0.3, 0.58, 0.25, 0.99), + }).start() + }, [opacityAnimationValue]) - return ( - - - - ) - } + return ( + + + + ) } diff --git a/mobile/components/AutocompleteDropdown-v4.3.1/NothingFound.tsx b/mobile/components/AutocompleteDropdown-v4.3.1/NothingFound.tsx index c128f15ee..ccd27f831 100644 --- a/mobile/components/AutocompleteDropdown-v4.3.1/NothingFound.tsx +++ b/mobile/components/AutocompleteDropdown-v4.3.1/NothingFound.tsx @@ -7,6 +7,7 @@ interface NothingFoundProps { emptyResultText?: string } +// eslint-disable-next-line react/display-name export const NothingFound: FC = memo(({ ...props }) => { const EL = withFadeAnimation( () => ( diff --git a/mobile/components/AutocompleteDropdown-v4.3.1/ScrollViewListItem.tsx b/mobile/components/AutocompleteDropdown-v4.3.1/ScrollViewListItem.tsx index fc4d93c28..c6352740e 100644 --- a/mobile/components/AutocompleteDropdown-v4.3.1/ScrollViewListItem.tsx +++ b/mobile/components/AutocompleteDropdown-v4.3.1/ScrollViewListItem.tsx @@ -1,3 +1,4 @@ +/* eslint-disable no-unsafe-optional-chaining */ import type { FC } from 'react' import React, { memo, useMemo } from 'react' import type { ViewProps } from 'react-native' @@ -14,6 +15,7 @@ interface ScrollViewListItemProps { numberOfLines?: number } +// eslint-disable-next-line react/display-name export const ScrollViewListItem: FC = memo( ({ highlight, title, style, onPress, ignoreAccents, numberOfLines = 2 }) => { const themeName = useColorScheme() diff --git a/mobile/components/AutocompleteDropdown-v4.3.1/diacriticless.ts b/mobile/components/AutocompleteDropdown-v4.3.1/diacriticless.ts index 3f8448a7a..a0c0e3708 100644 --- a/mobile/components/AutocompleteDropdown-v4.3.1/diacriticless.ts +++ b/mobile/components/AutocompleteDropdown-v4.3.1/diacriticless.ts @@ -505,10 +505,12 @@ const diacritics: DiacriticsMap = { export default function removeDiacritics(text: string): string { const result: string[] = [] + // eslint-disable-next-line no-plusplus for (let i = 0; i < text.length; i++) { const searchChar = text.charAt(i) let foundChar = false + // eslint-disable-next-line guard-for-in for (const key in diacritics) { const index = diacritics[key]?.indexOf(searchChar) if (index !== -1) { diff --git a/mobile/components/AutocompleteDropdown-v4.3.1/types/global.d.ts b/mobile/components/AutocompleteDropdown-v4.3.1/types/global.d.ts index 4f6322192..59ebde488 100644 --- a/mobile/components/AutocompleteDropdown-v4.3.1/types/global.d.ts +++ b/mobile/components/AutocompleteDropdown-v4.3.1/types/global.d.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-shadow */ declare global { namespace setInterval { function setInterval(callback: () => void, ms?: number | undefined): NodeJS.Timeout diff --git a/mobile/components/AutocompleteDropdown-v4.3.1/useKeyboardHeight.ts b/mobile/components/AutocompleteDropdown-v4.3.1/useKeyboardHeight.ts index 0f5b3ab72..04d296269 100644 --- a/mobile/components/AutocompleteDropdown-v4.3.1/useKeyboardHeight.ts +++ b/mobile/components/AutocompleteDropdown-v4.3.1/useKeyboardHeight.ts @@ -5,7 +5,7 @@ export function useKeyboardHeight() { const [keyboardHeight, setKeyboardHeight] = useState(0) useEffect(() => { - const showSubscription = Keyboard.addListener('keyboardDidShow', e => setKeyboardHeight(e.endCoordinates.height)) + const showSubscription = Keyboard.addListener('keyboardDidShow', (e) => setKeyboardHeight(e.endCoordinates.height)) const hideSubscription = Keyboard.addListener('keyboardDidHide', () => setKeyboardHeight(0)) return () => { showSubscription.remove() diff --git a/mobile/components/Booking.tsx b/mobile/components/Booking.tsx index 2e71955b0..ee9dd7e96 100644 --- a/mobile/components/Booking.tsx +++ b/mobile/components/Booking.tsx @@ -71,7 +71,7 @@ const Booking = ({ } init() - }, [booking, car.additionalDriver, car.amendments, car.cancellation, car.collisionDamageWaiver, car.fullInsurance, car.theftProtection, days, language]) + }, [booking, car, days, language]) return !loading && price && (