This commit is contained in:
@@ -298,6 +298,32 @@ export const focusArrayAt: {
|
||||
)
|
||||
})
|
||||
|
||||
export const focusTupleAt: {
|
||||
<P extends readonly PropertyKey[], A extends readonly [any, ...any[]], I extends readonly [any, ...any[]], ER, EW, K extends number>(
|
||||
self: Form<P, A, I, ER, EW>,
|
||||
index: K,
|
||||
): Form<readonly [...P, number], A[number], I[number], ER, EW>
|
||||
<P extends readonly PropertyKey[], A extends readonly [any, ...any[]], I extends readonly [any, ...any[]], ER, EW, K extends number>(
|
||||
index: K,
|
||||
): (self: Form<P, A, I, ER, EW>) => Form<readonly [...P, number], A[number], I[number], ER, EW>
|
||||
} = Function.dual(2, <P extends readonly PropertyKey[], A extends readonly [any, ...any[]], I extends readonly [any, ...any[]], ER, EW, K extends number>(
|
||||
self: Form<P, A, I, ER, EW>,
|
||||
index: K,
|
||||
): Form<readonly [...P, K], A[number], I[number], ER, EW> => {
|
||||
const form = self as FormImpl<P, A, I, ER, EW>
|
||||
const path = [...form.path, index] as const
|
||||
|
||||
return new FormImpl(
|
||||
path,
|
||||
Subscribable.mapOption(form.value, Array.unsafeGet(index)),
|
||||
Lens.focusTupleAt(form.encodedValue, index),
|
||||
Subscribable.map(form.issues, issues => filterIssuesByPath(issues, path)),
|
||||
form.isValidating,
|
||||
form.canSubmit,
|
||||
form.isSubmitting,
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
export namespace useInput {
|
||||
export interface Options {
|
||||
|
||||
Reference in New Issue
Block a user