diff --git a/.changeset/two-crews-eat.md b/.changeset/two-crews-eat.md new file mode 100644 index 0000000..63795f9 --- /dev/null +++ b/.changeset/two-crews-eat.md @@ -0,0 +1,8 @@ +--- +"@formulier/docs": minor +"@formulier/examples-react": minor +"@formulier/core": minor +"@formulier/react": minor +--- + +Update Formulier, useFormField implementations diff --git a/docs/docs/react-components/guide-getting-started-example.jsx b/docs/docs/react-components/guide-getting-started-example.jsx index 6f510aa..7f8f496 100644 --- a/docs/docs/react-components/guide-getting-started-example.jsx +++ b/docs/docs/react-components/guide-getting-started-example.jsx @@ -37,9 +37,10 @@ function InputField({name, label, type = 'text'}) { {label} field.onChange(event.target.value)} /> diff --git a/docs/docs/react-components/guide-validation-min-length.jsx b/docs/docs/react-components/guide-validation-min-length.jsx index 67a6f71..fefba7c 100644 --- a/docs/docs/react-components/guide-validation-min-length.jsx +++ b/docs/docs/react-components/guide-validation-min-length.jsx @@ -50,9 +50,10 @@ function InputField({name, label, type = 'text', minLength}) { {label} field.onChange(event.target.value)} /> diff --git a/docs/docs/react-components/guide-validation-required.jsx b/docs/docs/react-components/guide-validation-required.jsx index 59b6a8a..36ba759 100644 --- a/docs/docs/react-components/guide-validation-required.jsx +++ b/docs/docs/react-components/guide-validation-required.jsx @@ -55,9 +55,10 @@ function InputField({name, label, type = 'text', minLength, required}) { {label} field.onChange(event.target.value)} /> diff --git a/docs/docs/react/api/use-form-field.md b/docs/docs/react/api/use-form-field.md index dbfc952..f53d4ec 100644 --- a/docs/docs/react/api/use-form-field.md +++ b/docs/docs/react/api/use-form-field.md @@ -9,8 +9,8 @@ function TextInput({name, label}) { return ( <> - - + + {meta.error && {meta.error}} ) diff --git a/docs/docs/react/guide/validation.md b/docs/docs/react/guide/validation.md index bec8dfe..873f324 100644 --- a/docs/docs/react/guide/validation.md +++ b/docs/docs/react/guide/validation.md @@ -9,7 +9,7 @@ This makes it easy to validate when the form has conditional fields or requires Let's validate that the `firstName` and `lastName` are at least 2 characters long.\ We start with the form we made on the [Getting Started](./getting-started) page. -<<< @/react-components/guide-validation-min-length.jsx{20,21,30,32-43,45,59} +<<< @/react-components/guide-validation-min-length.jsx{20,21,30,32-43,45,60} ## Example: Required diff --git a/examples/react/src/fields.tsx b/examples/react/src/fields.tsx index 16b48ba..13024a7 100644 --- a/examples/react/src/fields.tsx +++ b/examples/react/src/fields.tsx @@ -9,8 +9,15 @@ export function TextField({name, label}: {name: string; label: string}) { const {error} = meta return ( - - onChange(event.target.value)} onBlur={onBlur} /> + + onChange(event.target.value)} + onBlur={onBlur} + /> ) } @@ -23,11 +30,12 @@ export function IntegerField({name, label}: {name: string; label: string}) { const {error} = meta return ( - + onChange(parseInt(event.target.value, 10))} onBlur={onBlur} @@ -44,8 +52,8 @@ export function SelectField({name, label, children}: {name: string; label: strin const {error} = meta return ( - - onChange(event.target.value)} onBlur={onBlur}> {children} @@ -60,10 +68,11 @@ export function CheckboxField({name, label}: {name: string; label: string}) { const {error} = meta return ( - + onChange(event.target.checked)} onBlur={onBlur} @@ -73,13 +82,13 @@ export function CheckboxField({name, label}: {name: string; label: string}) { } export function Field({ - name, + id, label, error, children, displayHorizontal = false, }: { - name: string + id: string label: string error: string | null children: React.ReactNode @@ -87,7 +96,7 @@ export function Field({ }) { return (
-