Developers
Start building
Themes/Theme SDK/Modules/forms/Types: FormFieldType to StoreFormCopy

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.

valuerequiredstring

The value the submission stores.

labelrequiredstring

The choice as the shopper reads it, in the page language.

StoreFormFieldView

A field of a published form, already in the page language.

idrequiredstring

The field's id; submissions and `copy.labels` key on it.

typerequiredFormFieldType

What the field asks for.

labelrequiredstring

The field's label.

placeholderrequiredstring | null

The placeholder, or null.

helpTextrequiredstring | null

The help line under the control, or null.

requiredrequiredboolean

Whether the form refuses to submit without it.

optionsrequiredreadonly FormFieldOption[]

The choices of a select, radio or multi-select field; empty otherwise.

minrequirednumber | null

The lowest number a number field takes, or null.

maxrequirednumber | null

The highest number a number field takes, or null.

steprequirednumber | null

The 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 | null

How many files a file field takes, or null for one.

maxBytesrequirednumber | null

The 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.

localIdrequiredstring

The file's id in this form, for removing it.

filenamerequiredstring

The file name.

byteSizerequirednumber

The file size in bytes.

mimeTyperequiredstring

The file's MIME type.

uploadingrequiredboolean

Whether it is still uploading.

errorrequiredstring | null

Why the file was refused, or null.

StoreFormTexts

The fixed wording of a form's buttons, in the page language.

submitrequiredstring

The send button.

submittingrequiredstring

The send button while the form is sending.

nextrequiredstring

The button to the next step.

backrequiredstring

The button back to the previous step.

StoreFormState

A published form with its values, errors and the actions that fill it in and send it.

handlerequiredstring

The form's handle.

titlerequiredstring

The form's title.

descriptionrequiredstring

The line under the title.

statusrequiredStoreFormStatus

Where the form is in its life.

previewrequiredboolean

Whether the form runs in the customizer, where sending stores nothing.

submittingrequiredboolean

Whether 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 | null

An error about the whole form, or null.

steprequirednumber

The current step, from 0.

stepCountrequirednumber

How 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.

textsrequiredStoreFormTexts

The wording of the form's buttons.

setValuerequired(fieldId: string, value: FormValue) => void

Sets one field's value.

uploadFilesrequired(fieldId: string, files: File[]) => Promise<void>

Uploads files for a file field.

removeFilerequired(fieldId: string, localId: string) => void

Removes a picked file.

submitrequired() => Promise<void>

Validates and sends the form.

nextrequired() => void

Moves to the next step after checking the current one.

backrequired() => void

Moves back a step.

resetrequired() => void

Shows the empty form again after it was sent.

StoreFormFieldState

One field of the surrounding form, with its value and error.

fieldrequiredStoreFormFieldView | null

The field, or null when the form has no field with that id.

valuerequiredFormValue | null

The field's value, or null before the form loaded.

errorrequiredstring | null

The field's error, or null.

visiblerequiredboolean

Whether the shopper sees the field; conditions can hide it.

setValuerequired(value: FormValue) => void

Sets 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.

titlestring

The title.

descriptionstring

The line under the title.

submitLabelstring

The send button.

successTitlestring

The heading after sending.

successMessagestring

The message after sending.

newSubmissionLabelstring

The 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.

Last updated