/* eslint-disable no-restricted-imports */ import { TextInput } from 'react-native' import type { CSSTransitionProperties } from 'rntwsc/tw/class-name' import { createAnimatedComponent } from 'rntwsc/tw/components/lib/create-animated-component' import { isReanimated } from 'rntwsc/tw/components/lib/is-reanimated' import { normalizePropsNative } from 'rntwsc/tw/components/lib/normalize-props-native' import { renderReanimated } from 'rntwsc/tw/components/lib/render-reanimated' import type { InputPropsWocn } from 'rntwsc/tw/components/without-class-name/input' import { useAnimatedColor } from 'rntwsc/libs/hooks' const styleProps = ['placeholderTextColor', 'caretHidden'] export const InputWocn = (props: InputPropsWocn) => { props = normalizePropsNative(props, styleProps) const Component = isReanimated(props) ? AnimatedInput : TextInput return renderReanimated(Component, props) } type Props = { wrapperStyle: CSSTransitionProperties style: { color: string | undefined } placeholderTextColor: string | undefined } // reanimated does not support text input, we need a custom wrapper view // the custom wrapper view doesnt have color, we need to manually animate color using raf const WithAnimatedColor = ({ wrapperStyle, style, ...props }: Props) => { // reanimated style and style should be guaranteed to present const color = useAnimatedColor(style.color, wrapperStyle) const ptc = useAnimatedColor(props.placeholderTextColor, wrapperStyle) return ( ) } const AnimatedInput = createAnimatedComponent(WithAnimatedColor, { passWrapperStyleToProps: true, })