0.1.3 #4
@@ -10,24 +10,27 @@ export type TextFieldInputProps<A, R> = Omit<useInput.Options<A, R>, "schema"> &
|
||||
export type TextFieldOptionalInputProps<A, R> = Omit<useOptionalInput.Options<A, R>, "schema"> & Omit<TextField.RootProps, "ref">
|
||||
|
||||
export const TextFieldInput: {
|
||||
<A, R>(
|
||||
schema: Schema.Schema<A, string, R>
|
||||
): Component.Component<TextFieldInputProps<A, R>, React.JSX.Element, ParseResult.ParseError, R>
|
||||
} = <A, R>(
|
||||
schema: Schema.Schema<A, string, R>
|
||||
<A, R>(options: {
|
||||
readonly optional: true
|
||||
readonly schema: Schema.Schema<A, string, R>
|
||||
}): Component.Component<TextFieldOptionalInputProps<A, R>, React.JSX.Element, ParseResult.ParseError, R>
|
||||
<A, R>(options: {
|
||||
readonly optional?: false
|
||||
readonly schema: Schema.Schema<A, string, R>
|
||||
}): Component.Component<TextFieldInputProps<A, R>, React.JSX.Element, ParseResult.ParseError, R>
|
||||
} = <A, R>(options:
|
||||
{
|
||||
readonly optional: true
|
||||
}
|
||||
): Component.Component<
|
||||
TextFieldInputProps<A, R>,
|
||||
TextFieldOptionalInputProps<A, R> | TextFieldInputProps<A, R>,
|
||||
React.JSX.Element,
|
||||
ParseResult.ParseError,
|
||||
R
|
||||
> => Component.makeUntraced(function* TextFieldInput(props) {
|
||||
const ref = React.useMemo(() => props.optional
|
||||
? SubscriptionSubRef.makeFromGetSet(props.ref, {
|
||||
|
||||
})
|
||||
: props.ref,
|
||||
[props.optional, props.ref])
|
||||
const input = yield* useInput({ schema, ...props })
|
||||
const input = options.optional
|
||||
? yield* useOptionalInput({ schema, ...props })
|
||||
: yield* useInput({ schema, ...props })
|
||||
|
||||
const issues = React.useMemo(() => Option.map(
|
||||
input.error,
|
||||
|
||||
Reference in New Issue
Block a user