Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds deprecation warnings to enum, updates docs to indicate they're d…
…eprecated
- Loading branch information
Showing
6 changed files
with
157 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Example Fields | ||
|
||
These can be a good starting points for how to implement certain types of fields. | ||
|
||
1. [Select](#select) | ||
|
||
## Select | ||
|
||
```tsx | ||
function Select({ | ||
options | ||
} : { | ||
options: { | ||
label: string, | ||
id: string, | ||
}[] | ||
}) { | ||
const {field, error} = useTsController<string>(); | ||
return ( | ||
<> | ||
<select | ||
value={field.value?field.value:'none'} | ||
onChange={(e)=>{ | ||
field.onChange(e.target.value); | ||
}} | ||
> | ||
{!field.value && <option value="none">Please select...</option>} | ||
{options.map((e) => ( | ||
<option value={e.id}>{e.label}</option> | ||
))} | ||
</select> | ||
<span> | ||
{error?.errorMessage && error.errorMessage} | ||
</span> | ||
<> | ||
); | ||
} | ||
|
||
const mapping = [ | ||
// z.number() is also viable. You may have to use "createUniqueFieldSchema" (since you probably already have a Text Field) | ||
[z.string(), DropDownSelect], | ||
] as const; | ||
|
||
const MyForm = z.object({ | ||
eyeColor: z.enum(["blue", "brown", "green", "hazel"]), | ||
favoritePants: z.enum(["jeans", "khakis", "none"]), | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.