'use client'; import { codegenNativeCommands, codegenNativeComponent } from 'react-native'; import type { CodegenTypes as CT, ViewProps, ColorValue, HostComponent, } from 'react-native'; // eslint-disable-next-line @typescript-eslint/ban-types export type SearchBarEvent = Readonly<{}>; export type SearchButtonPressedEvent = Readonly<{ text?: string | undefined; }>; export type ChangeTextEvent = Readonly<{ text?: string | undefined; }>; type SearchBarPlacement = | 'automatic' | 'inline' // deprecated starting from iOS 26 | 'stacked' | 'integrated' | 'integratedButton' | 'integratedCentered'; type AutoCapitalizeType = | 'systemDefault' | 'none' | 'words' | 'sentences' | 'characters'; type OptionalBoolean = 'undefined' | 'false' | 'true'; export interface NativeProps extends ViewProps { onSearchFocus?: CT.DirectEventHandler | null | undefined; onSearchBlur?: CT.DirectEventHandler | null | undefined; onSearchButtonPress?: | CT.DirectEventHandler | null | undefined; onCancelButtonPress?: | CT.DirectEventHandler | null | undefined; onChangeText?: CT.DirectEventHandler | null | undefined; hideWhenScrolling?: CT.WithDefault; autoCapitalize?: CT.WithDefault; placeholder?: string | undefined; placement?: CT.WithDefault; allowToolbarIntegration?: CT.WithDefault; obscureBackground?: CT.WithDefault; hideNavigationBar?: CT.WithDefault; cancelButtonText?: string | undefined; // TODO: implement these on iOS barTintColor?: ColorValue | undefined; tintColor?: ColorValue | undefined; textColor?: ColorValue | undefined; // Android only autoFocus?: CT.WithDefault; disableBackButtonOverride?: boolean | undefined; // TODO: consider creating enum here inputType?: string | undefined; onClose?: CT.DirectEventHandler | null | undefined; onOpen?: CT.DirectEventHandler | null | undefined; hintTextColor?: ColorValue | undefined; headerIconColor?: ColorValue | undefined; shouldShowHintSearchIcon?: CT.WithDefault; } type ComponentType = HostComponent; interface NativeCommands { blur: (instance: React.ComponentRef) => void; focus: (instance: React.ComponentRef) => void; clearText: (instance: React.ComponentRef) => void; toggleCancelButton: ( instance: React.ComponentRef, flag: boolean, ) => void; setText: (instance: React.ComponentRef, text: string) => void; cancelSearch: (instance: React.ComponentRef) => void; } export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: [ 'blur', 'focus', 'clearText', 'toggleCancelButton', 'setText', 'cancelSearch', ], }); export default codegenNativeComponent( 'RNSSearchBar', {}, ) as HostComponent;