Skip to content

Core package

Here you can find a list of interfaces and types used in the core package.

Global

All types and interfaces that you have to know to use the useConfig, and the Faivform contexts.

Config

PropertyTypeDescription
fieldsContextStyles | undefinedGlobal built-in componets styles.
baseFaivBaseTheme | undefinedGlobal base CSS variables shared between light and dark themes.
lightFaivFormTheme | undefinedGlobal light theme.
darkFaivFormTheme | undefinedGlobal dark theme.
onLightFaivCSSVars | undefinedGlobal faivform CSS variables for light theme.
onDarkFaivCSSVars | undefinedGlobal faivform CSS variables for dark theme.

ContextForm

An interface that defines the form context.

PropertyTypeDescription
loadingWritable<boolean>Whether the form is loading or not.
errorsWritable<Errors<Data>>The errors of the fields.
dataWritable<Data>The values of the fields.
stylesWritable<ContextStyles>The styles of the form.
reset(clear?: boolean, starting?: Data) => voidResets the form.
setError(field: Keys, error?: string | null) => Promise<void>Sets the error of a field.
setField(field: Keys, value: Data[Keys], validate?: boolean) => Promise<void>Sets the value of a field.
check(event: UserEvent<HTMLInputElement | HTMLTextAreaElement, FocusEvent | Event>) => Promise<void>Checks the value of a field.

ContextStyles

An interface that defines the field styles.

PropertyTypeDescription
replaceboolean | undefinedWhether the styles should replace the default styles or not.
fieldFieldStyles | undefinedThe styles of the Field.
selectSelectStyles | undefinedThe styles of the Select.
optionOptionStyles | undefinedThe styles of the Option.
fileFileStyles | undefinedThe styles of the File.
errorsErrorsStyles | undefinedThe styles of the Errors.
iconsIcons | null | undefinedThe icons of the form.

FaivBaseTheme

An interface that defines the base theme.

PropertyTypeDescription
fontstring | undefinedThe font family of the fields.
spacestring | undefinedThe space of the fields.
radiusstring | undefinedThe border radius of the fields.
whitestring | undefinedWhite color used in the fields.
blackstring | undefinedBlack color used in the fields.

FaivFormTheme

An type that defines the faivform theme.

PropertyTypeDescription
primaryFaivFormThemePalette | undefinedThe primary theme.
secondaryFaivFormThemePalette | undefinedThe secondary theme.
accentFaivFormThemePalette | undefinedThe accent theme.
errorFaivFormThemePalette | undefinedThe error theme.
warningFaivFormThemePalette | undefinedThe warning theme.
successFaivFormThemePalette | undefinedThe success theme.
placeholderFaivFormThemePalette | undefinedThe placeholder theme.

FaivFormThemePalette

A type that defines the faivform theme palette.

PropertyTypeDescription
50string | undefinedThe 50 color of the theme.
100string | undefinedThe 100 color of the theme.
200string | undefinedThe 200 color of the theme.
300string | undefinedThe 300 color of the theme.
400string | undefinedThe 400 color of the theme.
500string | undefinedThe 500 color of the theme.
600string | undefinedThe 600 color of the theme.
700string | undefinedThe 700 color of the theme.
800string | undefinedThe 800 color of the theme.
900string | undefinedThe 900 color of the theme.

FaivCSSVars

A type that defines the faivform CSS variables.

PropertyTypeDescription
primaryFaivColorVars | undefinedThe primary CSS vars.
secondaryFaivColorVars | undefinedThe secondary CSS vars.
accentFaivColorVars | undefinedThe accent CSS vars.
errorFaivColorVars | undefinedThe error CSS vars.
warningFaivColorVars | undefinedThe warning CSS vars.
successFaivColorVars | undefinedThe success CSS vars.
placeholderFaivColorVars | undefinedThe placeholder CSS vars.
shadowFaivShadowVars | undefinedThe shadow CSS vars.
borderFaivBorderVars | undefinedThe border CSS vars.

FaivColorVars

An interface that defines the faivform color CSS variables.

PropertyTypeDescription
colorstring | undefinedThe color CSS variable.
opacitystring | undefinedThe opacity CSS variable.
textstring | undefinedThe text color CSS variable.
“text-opacity”string | undefinedThe text color opacity CSS variable.
fontstring | undefinedThe font CSS variable.

FaivShadowVars

An interface that defines the faivform shadow CSS variables.

PropertyTypeDescription
basestring | undefinedThe shadow CSS variable.
sizestring | undefinedThe size CSS variable.
colorstring | undefinedThe color CSS variable.
opacitystring | undefinedThe opacity color CSS variable.

FaivBorderVars

An interface that defines the faivform border CSS variables.

PropertyTypeDescription
basestring | undefinedThe border CSS variable.
widthstring | undefinedThe width CSS variable.
stylestring | undefinedThe style CSS variable.
colorstring | undefinedThe color CSS variable.
opacitystring | undefinedThe opacity color CSS variable.

Faivform

All types and interfaces that you have to know to use the core package.

FaivFormConfig

An interface that defines the config of the form.

PropertyTypeDescription
fieldsFieldsSchema | AdapterThe fields of the form.
stylesContextStyles | undefinedThe styles of the form.
contextstring | undefinedThe context of the form.

FaivFormStore

An interface that defines the store of the form.

This contains all the properties of the ContextForm interface and the following:

PropertyTypeDescription
submitsubmit<T = Data>(action: SubmitAction<T>, config?: SubmitConfig<T>) => Submit`Submits the form.

Adapter

An abstract class that defines the methods that an adapter must implement.

MethodDescription
initial(): { fields: Data; errors: Errors<Data>; }Returns the initial values of the fields and errors.
validate<T = Data>(data: T): Promise<void>Validates the data.
field(field: keyof Data, value: Data[keyof Data], errors: Writable<Errors<Data>>): Promise<void>Validates a field.
errors(error: unknown, errors: Writable<Errors<Data>>, handle?: (error: unknown) => (void | Promise<void>)): Promise<void>Handles an error.

SubmitAction

An type that defines the submit action.

PropertyTypeDescription
valuesDataThe values of the form.

SubmitConfig

An interface that defines the submit config.

PropertyTypeDescription
error((error: unknown) => (void | Promise<void>)) | undefinedA function that handles the error.
finishVoidFunction | undefinedA function that is called when the submit action is finished whether it was successful or not.
resetboolean | undefinedWhether the form should be reset or not.
initialData | undefinedThe initial values of the form.

Submit

An type that defines the function that is called when the form is submitted.

PropertyTypeDescription
eventUserEvent<HTMLFormElement, SubmitEvent>The submit event.

UserEvent

An object type that defines the user event. It extends the native event to safely access the current target.

PropertyTypeDescription
currentTargetEventTarget & ElementThe current target of the event.
EventAll the properties of the event used.

Errors

An object type that defines the errors of the fields.

PropertyTypeDescription
[field]string | nullThe error of a field.

Schemas

All schemas are defined using TypeScript types. This means that you can use them to define the type of your data.

FieldsSchema

A object type that defines a schema for a set of fields.

PropertyTypeDescription
[field]Schema | FieldPropSchema | ArraySchema | FieldsSchemaA field schema.

Schema

A type that defines the type of a field.

ValueDescription
RegExpA regular expression.
"string"A string.
"number"A number.
"boolean"A boolean.
"date"A date.
"file"A file.

FieldPropSchema

A object type that defines the type of a field.

PropertyTypeDescription
typeSchemaThe type of the field.
requiredboolean | undefinedWhether the field is required or not.
minnumber | undefinedThe minimum value of the field.
maxnumber | undefinedThe maximum value of the field.

ArraySchema

A object type that defines the type of an array.

PropertyTypeDescription
type"array"Indicates that the field is an array.
itemSchema | FieldPropSchema | ArraySchema | FieldsSchemaThe type of the items in the array.
requiredboolean | undefinedWhether the array is required or not.
minnumber | undefinedThe minimum length of the array.
maxnumber | undefinedThe maximum length of the array.

Styles

All types and interfaces that you have to know to use the styles.

FieldStyles

An interface that defines the field styles.

PropertyTypeDescription
containerstring | undefinedField container class
labelstring | undefinedField label class
inputstring | undefinedField input class
errorstring | undefinedField error class
areastring | undefinedField type textarea class
checkstring | undefinedField type checkbox class
actionstring | undefinedField type password action class
iconstring | undefinedField type password icon class
checkedstring | undefinedField type checkbox checked icon
hidestring | undefinedField type password hide icon.
showstring | undefinedField type password show icon.

SelectStyles

An interface that defines the select styles.

PropertyTypeDescription
containerstring | undefinedSelect container class
labelstring | undefinedSelect label class
selectstring | undefinedSelect select class
valuestring | undefinedSelect value class
itemstring | undefinedSelect item class
removestring | undefinedSelect remove class
searchablestring | undefinedSelect searchable class
nonsearchablestring | undefinedSelect nonsearchable class
errorstring | undefinedSelect error class
clearstring | undefinedSelect clear class
arrowstring | undefinedSelect arrow icon
iconstring | undefinedSelect icon class
optionsstring | undefinedSelect options class
optionstring | undefinedSelect option class
emptystring | undefinedSelect empty class

OptionStyles

An interface that defines the option styles.

PropertyTypeDescription
containerstring | undefinedOptions container class
legendstring | undefinedOptions label class
optionstring | undefinedOption class
labelstring | undefinedOption label class
inputstring | undefinedOption input class
contentstring | undefinedOption content class
errorstring | undefinedOption error class

FileStyles

An interface that defines the file styles.

PropertyTypeDescription
containerstring | undefinedFile container class
itemstring | undefinedFile item class
coverstring | undefinedFile cover class
removestring | undefinedFile remove class
itemsstring | undefinedFile items class
retrystring | undefinedFile retry class
contentstring | undefinedFile content class
labelstring | undefinedFile label class
inputstring | undefinedFile input class
errorstring | undefinedFile error class

ErrorsStyles

An interface that defines the errors styles.

PropertyTypeDescription
containerstring | undefinedErrors list class
itemstring | undefinedErrors item class

Icons

An interface that defines the icons of the fields.

PropertyTypeDescription
checkedstring | undefinedThe icon of the checkbox.
hidestring | undefinedThe icon of the password when it is hidden.
showstring | undefinedThe icon of the password when it is shown.
clearstring | undefinedThe icon of the clear button.
arrowstring | undefinedThe icon of the arrow.
removestring | undefinedThe icon of the remove button.
retrystring | undefinedThe icon of the retry button.

Built-in components

All types and interfaces that you have to know to use the built-in components.

SelectOption

An interface that defines the select option.

PropertyTypeDescription
keystring | undefinedThe key of the option.
labelstringThe label of the option.
valuestringThe value of the option.
fixedboolean | undefinedWhether the option is fixed or not.
disabledboolean | undefinedWhether the option is disabled or not.

OptionItem

An interface that defines the option item.

PropertyTypeDescription
keystring | undefinedThe key of the option.
labelstring | undefinedThe label of the option.
valuestringThe value of the option.
disabledboolean | undefinedWhether the option is disabled or not.