diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 87d0a08372..44e4dc8a70 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -10,7 +10,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context' import {useTheme, atoms as a} from '#/alf' import {Portal} from '#/components/Portal' -import {createTextInput} from '#/components/forms/InputText' +import {createInput} from '#/components/forms/TextField' import { DialogOuterProps, @@ -22,7 +22,7 @@ import {Context} from '#/components/Dialog/context' export {useDialogControl, useDialogContext} from '#/components/Dialog/context' export * from '#/components/Dialog/types' // @ts-ignore -export const InputText = createTextInput(BottomSheetTextInput) +export const Input = createInput(BottomSheetTextInput) export function Outer({ children, diff --git a/src/components/forms/TextField.tsx b/src/components/forms/TextField.tsx index 0568caaf61..bcf7dafe0d 100644 --- a/src/components/forms/TextField.tsx +++ b/src/components/forms/TextField.tsx @@ -149,79 +149,85 @@ export type InputProps = Omit & { isInvalid?: boolean } -function Input({ - label, - placeholder, - value, - onChangeText, - isInvalid, - ...rest -}: InputProps) { - const t = useTheme() - const ctx = React.useContext(Context) - const withinRoot = Boolean(ctx.inputRef) +export function createInput(Component: typeof TextInput) { + return function Input({ + label, + placeholder, + value, + onChangeText, + isInvalid, + ...rest + }: InputProps) { + const t = useTheme() + const ctx = React.useContext(Context) + const withinRoot = Boolean(ctx.inputRef) - const {chromeHover, chromeFocus, chromeError, chromeErrorHover} = - useSharedInputStyles() + const {chromeHover, chromeFocus, chromeError, chromeErrorHover} = + useSharedInputStyles() + + if (!withinRoot) { + return ( + + + + ) + } - if (!withinRoot) { return ( - - + - + + + ) } - - return ( - <> - - - - - ) } +const Input = createInput(TextInput) + function Icon({icon: Comp}: {icon: React.ComponentType}) { const t = useTheme() const ctx = React.useContext(Context) diff --git a/src/view/screens/Storybook/Dialogs.tsx b/src/view/screens/Storybook/Dialogs.tsx index 56492be325..d4dcc91938 100644 --- a/src/view/screens/Storybook/Dialogs.tsx +++ b/src/view/screens/Storybook/Dialogs.tsx @@ -18,8 +18,7 @@ export function Dialogs() { color="secondary" size="small" onPress={() => control.open()} - accessibilityLabel="Open basic dialog" - accessibilityHint="Open basic dialog"> + label="Open basic dialog"> Open basic dialog @@ -28,8 +27,7 @@ export function Dialogs() { color="primary" size="small" onPress={() => prompt.open()} - accessibilityLabel="Open prompt" - accessibilityHint="Open prompt"> + label="Open prompt"> Open prompt @@ -58,14 +56,7 @@ export function Dialogs() {

A scrollable dialog with an input within it.

- {}} - placeholder="Type here" - accessibilityLabel="Type" - accessibilityHint="Type" - /> + {}} label="Type here" />