import * as React from "react"; import { View, TextInput, StyleSheet, StyleProp, ViewStyle, NativeSyntheticEvent, TextInputSubmitEditingEventData, } from "react-native"; import { withTheme } from "@draftbit/theme"; import type { ReadTheme } from "@draftbit/theme"; import type { IconSlot } from "../interfaces/Icon"; import Config from "../components/Config"; type Props = { showIcon: boolean; icon?: string; placeholder?: string; style?: StyleProp; theme: ReadTheme; onChange?: (text: string) => void; onSubmit?: (e: NativeSyntheticEvent) => void; value?: string; defaultValue?: string; } & IconSlot; /** * @deprecated DEPRECATED */ const FieldSearchBarFull: React.FC> = ({ showIcon, Icon, icon = "search", placeholder = "", style, theme: { colors, typography }, onChange: changeOverride, onSubmit: submitOverride, value, defaultValue, }) => { const [focused, setIsFocused] = React.useState(false); const onBlur = () => { setIsFocused(false); }; const [internalValue, setInternalValue] = React.useState( value || defaultValue ); React.useEffect(() => { if (value != null) { setInternalValue(value); } }, [value]); React.useEffect(() => { if (defaultValue != null) { setInternalValue(defaultValue); } }, [defaultValue]); const onChange = React.useCallback( (text: string) => { changeOverride && changeOverride(text); }, [changeOverride] ); const onFocus = () => { setIsFocused(true); }; const onSubmit = ( e: NativeSyntheticEvent ) => { submitOverride && submitOverride(e); }; const { lineHeight, ...typeStyles } = typography.body2; const handleChangeText = (newValue: string) => { setInternalValue(newValue); if (onChange) { onChange(newValue); } }; return ( {showIcon && ( )} ); }; const styles = StyleSheet.create({ container: { flexDirection: "row", alignItems: "center", }, }); export default withTheme(FieldSearchBarFull);