Allow extension of input
This commit is contained in:
@@ -10,7 +10,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
|||||||
|
|
||||||
import {useTheme, atoms as a} from '#/alf'
|
import {useTheme, atoms as a} from '#/alf'
|
||||||
import {Portal} from '#/components/Portal'
|
import {Portal} from '#/components/Portal'
|
||||||
import {createTextInput} from '#/components/forms/InputText'
|
import {createInput} from '#/components/forms/TextField'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DialogOuterProps,
|
DialogOuterProps,
|
||||||
@@ -22,7 +22,7 @@ import {Context} from '#/components/Dialog/context'
|
|||||||
export {useDialogControl, useDialogContext} from '#/components/Dialog/context'
|
export {useDialogControl, useDialogContext} from '#/components/Dialog/context'
|
||||||
export * from '#/components/Dialog/types'
|
export * from '#/components/Dialog/types'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export const InputText = createTextInput(BottomSheetTextInput)
|
export const Input = createInput(BottomSheetTextInput)
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -149,7 +149,8 @@ export type InputProps = Omit<TextInputProps, 'value' | 'onChangeText'> & {
|
|||||||
isInvalid?: boolean
|
isInvalid?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
function Input({
|
export function createInput(Component: typeof TextInput) {
|
||||||
|
return function Input({
|
||||||
label,
|
label,
|
||||||
placeholder,
|
placeholder,
|
||||||
value,
|
value,
|
||||||
@@ -181,7 +182,7 @@ function Input({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TextInput
|
<Component
|
||||||
accessibilityHint={undefined}
|
accessibilityHint={undefined}
|
||||||
{...rest}
|
{...rest}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
@@ -215,12 +216,17 @@ function Input({
|
|||||||
ctx.hovered ? chromeHover : {},
|
ctx.hovered ? chromeHover : {},
|
||||||
ctx.focused ? chromeFocus : {},
|
ctx.focused ? chromeFocus : {},
|
||||||
ctx.isInvalid ? chromeError : {},
|
ctx.isInvalid ? chromeError : {},
|
||||||
ctx.isInvalid && (ctx.hovered || ctx.focused) ? chromeErrorHover : {},
|
ctx.isInvalid && (ctx.hovered || ctx.focused)
|
||||||
|
? chromeErrorHover
|
||||||
|
: {},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Input = createInput(TextInput)
|
||||||
|
|
||||||
function Icon({icon: Comp}: {icon: React.ComponentType<SVGIconProps>}) {
|
function Icon({icon: Comp}: {icon: React.ComponentType<SVGIconProps>}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ export function Dialogs() {
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
onPress={() => control.open()}
|
onPress={() => control.open()}
|
||||||
accessibilityLabel="Open basic dialog"
|
label="Open basic dialog">
|
||||||
accessibilityHint="Open basic dialog">
|
|
||||||
Open basic dialog
|
Open basic dialog
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
@@ -28,8 +27,7 @@ export function Dialogs() {
|
|||||||
color="primary"
|
color="primary"
|
||||||
size="small"
|
size="small"
|
||||||
onPress={() => prompt.open()}
|
onPress={() => prompt.open()}
|
||||||
accessibilityLabel="Open prompt"
|
label="Open prompt">
|
||||||
accessibilityHint="Open prompt">
|
|
||||||
Open prompt
|
Open prompt
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
@@ -58,14 +56,7 @@ export function Dialogs() {
|
|||||||
<P nativeID="dialog-description">
|
<P nativeID="dialog-description">
|
||||||
A scrollable dialog with an input within it.
|
A scrollable dialog with an input within it.
|
||||||
</P>
|
</P>
|
||||||
<Dialog.InputText
|
<Dialog.Input value="" onChangeText={() => {}} label="Type here" />
|
||||||
testID=""
|
|
||||||
value=""
|
|
||||||
onChange={() => {}}
|
|
||||||
placeholder="Type here"
|
|
||||||
accessibilityLabel="Type"
|
|
||||||
accessibilityHint="Type"
|
|
||||||
/>
|
|
||||||
<View style={{height: 1000}} />
|
<View style={{height: 1000}} />
|
||||||
<View style={[a.flex_row, a.justify_end]}>
|
<View style={[a.flex_row, a.justify_end]}>
|
||||||
<Button
|
<Button
|
||||||
@@ -73,8 +64,7 @@ export function Dialogs() {
|
|||||||
color="primary"
|
color="primary"
|
||||||
size="small"
|
size="small"
|
||||||
onPress={() => control.close()}
|
onPress={() => control.close()}
|
||||||
accessibilityLabel="Open basic dialog"
|
label="Open basic dialog">
|
||||||
accessibilityHint="Open basic dialog">
|
|
||||||
Close basic dialog
|
Close basic dialog
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user