Supported form types
Moyuk automatically generates forms from your TypeScript interfaces. Here is a list of supported form field types and corresponding TypeScript types.
text
Provides a freeform text input.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types are interpreted as text fields by default:
stringstring | undefined- Empty string is converted toundefined.string | null- Empty string is converted tonull."s"(string literal) - Becomes a readonly text field with the given value.
The following types also can be used as text fields with form customizations:
string[]- Becomes a multi-line text field.
number
Provides a numeric input.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types generate number fields:
number- Does not allow empty input.number | undefined- Empty string is converted toundefined.number | null- Empty string is converted tonull.1(number literal) - Becomes a readonly text field with the given value.
Moyuk does not support bigint type yet.
checkbox
Provides a checkbox.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types generate checkbox fields:
booleanboolean | undefined- Unchecked state is interpreted asundefined.boolean | null- Unchecked state is interpreted asnull.
select
Provides a select input.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types generate select fields:
"red" | "green" | "blue"(union of string literals) - Becomes a select with the given options."red" | "green" | undefined(union of string literals or undefined) - Becomes a select with the given options and an empty option.1 | 2 | 3(union of number literals) - Becomes a select with the given options.1 | 2 | undefined(union of number literals or undefined) - Becomes a select with the given options and an empty option.
date
Provides a date input. The default date format is automatically determined by the user's locale.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types generate date fields:
Date- Does not allow empty input.Date | undefined- Empty string is converted toundefined.Date | null- Empty string is converted tonull.
The following types also can be used as date fields with form customizations:
stringstring | undefined- Empty string is converted toundefined.string | null- Empty string is converted tonull.
datetime
Provides a date and time input. The default datetime format is automatically determined by the user's locale.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types can be used as datetime fields with form customizations:
Date- Does not allow empty input.Date | undefined- Empty string is converted toundefined.Date | null- Empty string is converted tonull.stringstring | undefined- Empty string is converted toundefined.string | null- Empty string is converted tonull.
time
Provides a time input. The default time format is automatically determined by the user's locale.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types can be used as time fields with form customizations:
Date- Does not allow empty input.Date | undefined- Empty string is converted toundefined.Date | null- Empty string is converted tonull.stringstring | undefined- Empty string is converted toundefined.string | null- Empty string is converted tonull.
tags
Provides a tags input.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types generate tags fields:
Set<string>Set<string> | undefined-undefinedif no tags are entered.Set<string> | null-nullif no tags are entered.Set<number>Set<"red" | "green" | "blue">(Set of string literals) - Becomes a tags input with the given options.
record-table
Provides a spreadsheet-like data table with infinite number of rows and fixed number of columns.
| TypeScript Type | Generated Form Field |
|---|---|
|
The following types generate record-table fields by default:
{ name: string, age: number }[](array of object literals) - Becomes a table with columns for each property.[string, number][](array of tuples) - Becomes a table with columns for each tuple element.string[](Array) - Becomes a table with a single column.Set<string>(Set) - Becomes a table with a single column.Map<string, number>(Map) - Becomes a table with 2 columns: key and value.
You can also use tuples instead of arrays to specify the number of rows.
flex-table
Provides a spreadsheet-like data table with infinite number of rows and columns.
| TypeScript Type | Generated Form Field |
|---|---|
|
Any array of arrays with following types generate flex-table fields:
string(or string literal)number(or number literal)boolean(or boolean literal)undefinednullDateRegExp
You can also use tuples instead of arrays to specify the number of columns and rows.
file
Provides a file input / output.
| TypeScript Type | Generated Form Field |
|---|---|
| ![]() |
The following types generate file fields:
