0.2.6 #49

Merged
Thilawyn merged 48 commits from next into master 2026-05-04 02:10:53 +02:00
3 changed files with 45 additions and 10 deletions
Showing only changes of commit 130614c4c3 - Show all commits

View File

@@ -500,6 +500,29 @@ export const makeUntraced: (
) )
) )
export declare namespace withSignature {
export type Signature = (props: any) => React.ReactNode
export type Result<
T extends Component<any, any, any, any>,
F extends React.FC,
> = Omit<T, "use" | "asFunctionComponent"> & {
readonly use: Effect.Effect<F, never, Exclude<Component.Context<T>, Scope.Scope>>
asFunctionComponent(
runtimeRef: React.Ref<Runtime.Runtime<Exclude<Component.Context<T>, Scope.Scope>>>
): F
}
}
export const withSignature: {
<F extends withSignature.Signature>(): <T extends Component<any, any, any, any>>(
self: T
) => withSignature.Result<T, F>
<F extends withSignature.Signature, T extends Component<any, any, any, any>>(
self: T
): withSignature.Result<T, F>
} = Function.dual(1, identity)
/** /**
* Creates a new component with modified configuration options while preserving all original behavior. * Creates a new component with modified configuration options while preserving all original behavior.
* *

View File

@@ -1,16 +1,20 @@
import { Callout, Flex, Spinner, TextField } from "@radix-ui/themes" import { Callout, Flex, Spinner, TextField } from "@radix-ui/themes"
import { Array, Option, Struct } from "effect" import { Array, Option, Struct } from "effect"
import { Component, Form, Subscribable } from "effect-fc" import { Component, Form, Subscribable } from "effect-fc"
import type * as React from "react"
export declare namespace TextFieldFormInputView { export declare namespace TextFieldFormInputView {
export interface Props extends Omit<TextField.RootProps, "form">, Form.useInput.Options { export interface Props<out P extends readonly PropertyKey[], A, ER, EW>
readonly form: Form.Form<readonly PropertyKey[], any, string> extends Omit<TextField.RootProps, "form">, Form.useInput.Options {
readonly form: Form.Form<P, A, string, ER, EW>
} }
export type Signature = <P extends readonly PropertyKey[], A, ER, EW>(props: Props<P, A, ER, EW>) => React.ReactNode
} }
export class TextFieldFormInputView extends Component.make("TextFieldFormInputView")(function*( export const TextFieldFormInputView = Component.make("TextFieldFormInputView")(function*(
props: TextFieldFormInputView.Props props: TextFieldFormInputView.Props<readonly PropertyKey[], any, any, any>
) { ) {
const input = yield* Form.useInput(props.form, props) const input = yield* Form.useInput(props.form, props)
const [issues, isValidating, isCommitting] = yield* Subscribable.useAll([ const [issues, isValidating, isCommitting] = yield* Subscribable.useAll([
@@ -47,4 +51,6 @@ export class TextFieldFormInputView extends Component.make("TextFieldFormInputVi
})} })}
</Flex> </Flex>
) )
}) {} }).pipe(
Component.withSignature<TextFieldFormInputView.Signature>()
)

View File

@@ -1,16 +1,20 @@
import { Callout, Flex, Spinner, Switch, TextField } from "@radix-ui/themes" import { Callout, Flex, Spinner, Switch, TextField } from "@radix-ui/themes"
import { Array, Option, Struct } from "effect" import { Array, Option, Struct } from "effect"
import { Component, Form, Subscribable } from "effect-fc" import { Component, Form, Subscribable } from "effect-fc"
import type * as React from "react"
export declare namespace TextFieldOptionalFormInputView { export declare namespace TextFieldOptionalFormInputView {
export interface Props extends Omit<TextField.RootProps, "form" | "defaultValue">, Form.useOptionalInput.Options<string> { export interface Props<out P extends readonly PropertyKey[], A, ER, EW>
readonly form: Form.Form<readonly PropertyKey[], any, Option.Option<string>> extends Omit<TextField.RootProps, "form" | "defaultValue">, Form.useOptionalInput.Options<string> {
readonly form: Form.Form<P, A, Option.Option<string>, ER, EW>
} }
export type Signature = <P extends readonly PropertyKey[], A, ER, EW>(props: Props<P, A, ER, EW>) => React.ReactNode
} }
export class TextFieldOptionalFormInputView extends Component.make("TextFieldOptionalFormInputView")(function*( export const TextFieldOptionalFormInputView = Component.make("TextFieldOptionalFormInputView")(function*(
props: TextFieldOptionalFormInputView.Props props: TextFieldOptionalFormInputView.Props<readonly PropertyKey[], any, any, any>
) { ) {
const input = yield* Form.useOptionalInput(props.form, props) const input = yield* Form.useOptionalInput(props.form, props)
const [issues, isValidating, isCommitting] = yield* Subscribable.useAll([ const [issues, isValidating, isCommitting] = yield* Subscribable.useAll([
@@ -55,4 +59,6 @@ export class TextFieldOptionalFormInputView extends Component.make("TextFieldOpt
})} })}
</Flex> </Flex>
) )
}) {} }).pipe(
Component.withSignature<TextFieldOptionalFormInputView.Signature>()
)