From 141f5afa30d99058d047a16d19e5594a1adba620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Sun, 17 Aug 2025 00:27:53 +0200 Subject: [PATCH] Work --- packages/example/src/lib/TextFieldInput.tsx | 29 ++++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/example/src/lib/TextFieldInput.tsx b/packages/example/src/lib/TextFieldInput.tsx index 6c867fb..c61265a 100644 --- a/packages/example/src/lib/TextFieldInput.tsx +++ b/packages/example/src/lib/TextFieldInput.tsx @@ -10,24 +10,27 @@ export type TextFieldInputProps = Omit, "schema"> & export type TextFieldOptionalInputProps = Omit, "schema"> & Omit export const TextFieldInput: { - ( - schema: Schema.Schema - ): Component.Component, React.JSX.Element, ParseResult.ParseError, R> -} = ( - schema: Schema.Schema + (options: { + readonly optional: true + readonly schema: Schema.Schema + }): Component.Component, React.JSX.Element, ParseResult.ParseError, R> + (options: { + readonly optional?: false + readonly schema: Schema.Schema + }): Component.Component, React.JSX.Element, ParseResult.ParseError, R> +} = (options: + { + readonly optional: true + } ): Component.Component< - TextFieldInputProps, + TextFieldOptionalInputProps | TextFieldInputProps, 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,