Types: FormFieldType to StoreFormCopy
The types of @poltura/theme-sdk/forms, FormFieldType to StoreFormCopy.
On this page
import { … } from '@poltura/theme-sdk/forms';FormFieldType
What a form field asks for, which decides the control it draws.
type FormFieldType = 'text' | 'email' | 'tel' | 'textarea' | 'select' | 'radio' | 'checkbox' | 'multiselect' | 'number' | 'date' | 'file'FormFieldOption
One choice of a select, radio or multi-select field.
valuerequiredstringThe value the submission stores.
labelrequiredstringThe choice as the shopper reads it, in the page language.
StoreFormFieldView
A field of a published form, already in the page language.
idrequiredstringThe field's id; submissions and `copy.labels` key on it.
typerequiredFormFieldTypeWhat the field asks for.
labelrequiredstringThe field's label.
placeholderrequiredstring | nullThe placeholder, or null.
helpTextrequiredstring | nullThe help line under the control, or null.
requiredrequiredbooleanWhether the form refuses to submit without it.
optionsrequiredreadonly FormFieldOption[]The choices of a select, radio or multi-select field; empty otherwise.
minrequirednumber | nullThe lowest number a number field takes, or null.
maxrequirednumber | nullThe highest number a number field takes, or null.
steprequirednumber | nullThe step of a number field, or null.
acceptrequiredreadonly string[]The extensions and MIME types a file field takes, for a file input's `accept`; empty otherwise.
maxFilesrequirednumber | nullHow many files a file field takes, or null for one.
maxBytesrequirednumber | nullThe largest file a file field takes, in bytes, or null.
FormValue
The value of one field: text, a number, a ticked box or the picked choices.
type FormValue = string | number | boolean | string[]StoreFormStatus
Where a form is in its life: loading, ready to fill in, missing, or sent.
type StoreFormStatus = 'loading' | 'ready' | 'unavailable' | 'success'StoreFormFile
A file the shopper picked for a file field.
localIdrequiredstringThe file's id in this form, for removing it.
filenamerequiredstringThe file name.
byteSizerequirednumberThe file size in bytes.
mimeTyperequiredstringThe file's MIME type.
uploadingrequiredbooleanWhether it is still uploading.
errorrequiredstring | nullWhy the file was refused, or null.
StoreFormTexts
The fixed wording of a form's buttons, in the page language.
submitrequiredstringThe send button.
submittingrequiredstringThe send button while the form is sending.
nextrequiredstringThe button to the next step.
backrequiredstringThe button back to the previous step.
StoreFormState
A published form with its values, errors and the actions that fill it in and send it.
handlerequiredstringThe form's handle.
titlerequiredstringThe form's title.
descriptionrequiredstringThe line under the title.
statusrequiredStoreFormStatusWhere the form is in its life.
previewrequiredbooleanWhether the form runs in the customizer, where sending stores nothing.
submittingrequiredbooleanWhether the form is sending.
valuesrequiredReadonly<Record<string, FormValue>>The current values by field id.
errorsrequiredReadonly<Record<string, string>>The error of each field that has one, by field id.
formErrorrequiredstring | nullAn error about the whole form, or null.
steprequirednumberThe current step, from 0.
stepCountrequirednumberHow many steps the form has; 1 for a single page.
fieldsrequiredreadonly StoreFormFieldView[]The fields of the current step the shopper sees, in order.
filesrequiredReadonly<Record<string, readonly StoreFormFile[]>>The picked files of each file field, by field id.
textsrequiredStoreFormTextsThe wording of the form's buttons.
setValuerequired(fieldId: string, value: FormValue) => voidSets one field's value.
uploadFilesrequired(fieldId: string, files: File[]) => Promise<void>Uploads files for a file field.
removeFilerequired(fieldId: string, localId: string) => voidRemoves a picked file.
submitrequired() => Promise<void>Validates and sends the form.
nextrequired() => voidMoves to the next step after checking the current one.
backrequired() => voidMoves back a step.
resetrequired() => voidShows the empty form again after it was sent.
StoreFormFieldState
One field of the surrounding form, with its value and error.
fieldrequiredStoreFormFieldView | nullThe field, or null when the form has no field with that id.
valuerequiredFormValue | nullThe field's value, or null before the form loaded.
errorrequiredstring | nullThe field's error, or null.
visiblerequiredbooleanWhether the shopper sees the field; conditions can hide it.
setValuerequired(value: FormValue) => voidSets the field's value.
StoreFormLayout
How a form's fields sit: one under another, or two per row on wide screens.
type StoreFormLayout = 'stacked' | 'compact'StoreFormAppearance
The surface a form draws on.
type StoreFormAppearance = 'default' | 'muted' | 'outline' | 'inverse'StoreFormChrome
Whether a form draws its title, description and card, or only its fields.
type StoreFormChrome = 'full' | 'fields'StoreFormCopy
The theme's own wording for a form; empty values keep the merchant's.
titlestringThe title.
descriptionstringThe line under the title.
submitLabelstringThe send button.
successTitlestringThe heading after sending.
successMessagestringThe message after sending.
newSubmissionLabelstringThe button that shows the empty form again.
labelsReadonly<Record<string, string>>Field labels by field id.
placeholdersReadonly<Record<string, string>>Field placeholders by field id.