From 2fbdc2206edd6ce5e55ec20b7068a66c4cfd2517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jirka=20Ba=C5=BEant?= Date: Tue, 28 Jan 2025 09:01:33 +0100 Subject: [PATCH] fixup! feat(suite-native): Create generic picker header component --- .../src/components/general/PickerHeader.tsx | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/suite-native/module-trading/src/components/general/PickerHeader.tsx b/suite-native/module-trading/src/components/general/PickerHeader.tsx index 369d3b6eb72..bfd2ca6ef14 100644 --- a/suite-native/module-trading/src/components/general/PickerHeader.tsx +++ b/suite-native/module-trading/src/components/general/PickerHeader.tsx @@ -2,34 +2,40 @@ import { ReactNode } from 'react'; import { HStack, SearchInput, Text, VStack } from '@suite-native/atoms'; +type PickerHeaderSearchInputProps = { + onSearchInputChange: (value: string) => void; + searchInputPlaceholder?: string; + isSearchInputDisabled?: boolean; + maxSearchInputLength?: number; +}; + export type PickerHeaderProps = { title: ReactNode; children?: ReactNode; } & ( - | { - isSearchInputVisible?: false; - onSearchInputChange?: never; - searchInputPlaceholder?: never; - isSearchInputDisabled?: never; - maxSearchInputLength?: never; - } - | { - isSearchInputVisible: true; - onSearchInputChange: (value: string) => void; - searchInputPlaceholder?: string; - isSearchInputDisabled?: boolean; - maxSearchInputLength?: number; - } + | { isSearchInputVisible?: false } + | ({ isSearchInputVisible: true } & PickerHeaderSearchInputProps) +); + +const PickerHeaderSearchInput = ({ + onSearchInputChange, + searchInputPlaceholder, + isSearchInputDisabled, + maxSearchInputLength, +}: PickerHeaderSearchInputProps) => ( + ); export const PickerHeader = ({ title, isSearchInputVisible, children, - maxSearchInputLength, - searchInputPlaceholder, - isSearchInputDisabled, - onSearchInputChange, + ...searchInputProps }: PickerHeaderProps) => ( @@ -39,12 +45,7 @@ export const PickerHeader = ({ {children} {isSearchInputVisible && ( - + )} );