0.1.3 #4

Merged
Thilawyn merged 90 commits from next into master 2025-08-23 03:07:28 +02:00
Showing only changes of commit 141f5afa30 - Show all commits

View File

@@ -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,