Skip to content

Commit 925124d

Browse files
committed
Rename FormError -> FieldError
1 parent de00fa6 commit 925124d

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

src/elements/Field.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type ElementProps<C extends React.FunctionComponent<any> | keyof JSX.Intr
88
? JSX.IntrinsicElements[C]
99
: never;
1010

11-
export function Field<T extends object, K extends keyof T, C extends React.FunctionComponent<any> | keyof JSX.IntrinsicElements>(
11+
export function Field<T extends object, K extends keyof T, C extends React.FunctionComponent<any> | keyof JSX.IntrinsicElements = "input">(
1212
props: {
1313
form: FormState<T>;
1414
name: K;
File renamed without changes.

src/elements/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
export * from "./FormInput";
22
export * from "./FormSelect";
33
export * from "./FormTextArea";
4-
export * from "./FormError";
4+
export * from "./Field";
5+
export * from "./FieldError";
56
export * from "./serializer";
67

78
export type StyledFix<T, Props = {}> = T | ((props: Props) => JSX.Element);
8-
9-
export * from "./Field";

testing/src/Fieldform.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22
import { useForm, Field, AnyListener, FieldError } from "typed-react-form";
33

44
function Input(props: { value?: string; onChange?: (value: string) => void; style: React.CSSProperties }) {
5-
return <input value={props.value} onChange={(ev) => props.onChange?.(ev.target.value)} style={props.style} />;
5+
return <input style={{ padding: "0.3em", ...props.style }} value={props.value} onChange={(ev) => props.onChange?.(ev.target.value)} />;
66
}
77

88
function validate(_: any) {
@@ -29,7 +29,6 @@ export function FieldForm() {
2929

3030
return (
3131
<form onSubmit={form.handleSubmit(submit)}>
32-
<Field form={form} name="email" component="textarea" />
3332
<Field form={form} name="email" component="input" />
3433
<Field form={form} name="email" component={Input} style={{ margin: "2em" }} />
3534
<FieldError form={form} name="email" component={Error} />

0 commit comments

Comments
 (0)