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