This commit is contained in:
@@ -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.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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 class TextFieldFormInputView extends Component.make("TextFieldFormInputView")(function*(
|
export type Signature = <P extends readonly PropertyKey[], A, ER, EW>(props: Props<P, A, ER, EW>) => React.ReactNode
|
||||||
props: TextFieldFormInputView.Props
|
}
|
||||||
|
|
||||||
|
export const TextFieldFormInputView = Component.make("TextFieldFormInputView")(function*(
|
||||||
|
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>()
|
||||||
|
)
|
||||||
|
|||||||
@@ -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 class TextFieldOptionalFormInputView extends Component.make("TextFieldOptionalFormInputView")(function*(
|
export type Signature = <P extends readonly PropertyKey[], A, ER, EW>(props: Props<P, A, ER, EW>) => React.ReactNode
|
||||||
props: TextFieldOptionalFormInputView.Props
|
}
|
||||||
|
|
||||||
|
export const TextFieldOptionalFormInputView = Component.make("TextFieldOptionalFormInputView")(function*(
|
||||||
|
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>()
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user