Module

Formless.Types.Component

Package
purescript-halogen-formless
Repository
thomashoneyman/purescript-halogen-formless

#Spec Source

type Spec form st query act slots input msg m = { finalize :: Maybe act, handleAction :: act -> HalogenM form st act slots msg m Unit, handleEvent :: Event form st -> HalogenM form st act slots msg m Unit, handleQuery :: forall a. query a -> HalogenM form st act slots msg m (Maybe a), initialize :: Maybe act, receive :: input -> Maybe act, render :: PublicState form st -> ComponentHTML form act slots m }

A type representing the various functions that can be provided to extend the Formless component. Usually only the render function is required, but you may also provide others. For example, if you have child components, you can tell Formless how to manage those child components by adding a handler action and handleAction case.

#Spec' Source

type Spec' form msg input m = Spec form () (Const Void) Void () input msg m

A simplified type when the component has only a form spec, some output, and runs in some monad m

#Action Source

type Action form act = Variant (userAction :: act | (InternalAction act) + (PublicAction form))

The component action type. While actions are typically considered internal to a component, in Formless you write the render function and will need to be able to use these directly. Many of these are shared with queries of the same name so they can be used either as queries or as actions. See Formless.Action and Formless.Query.

You can freely extend this type with your own actions using injAction.

#PublicAction Source

type PublicAction form = (loadForm :: form Record InputField, modify :: form Variant InputFunction, modifyAll :: Tuple (form Record InputFunction) Boolean, modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction), reset :: form Variant InputFunction, resetAll :: Unit, setAll :: Tuple (form Record InputField) Boolean, submit :: Unit, validate :: form Variant U, validateAll :: Unit)

#InternalAction Source

type InternalAction act r = (initialize :: Maybe act, syncFormData :: Unit | r)

#Action' Source

type Action' form = Action form Void

#QueryF Source

data QueryF form slots a

The internals of the public component query type. Many of these are shared with actions of the same name so they can be used in rendering. See Formless.Action and Formless.Query for more.

Constructors

Instances

#Query Source

type Query form query slots = VariantF (query :: QueryF form slots, userQuery :: query)

The component query type, which you can freely extend with your own queries using injQuery from Formless.Query.

#Query' Source

type Query' form = Query form (Const Void) ()

A simple query type when the component does not need extension

#Component Source

type Component form query slots input msg m = Component (Query form query slots) input msg m

The component type

#Component' Source

type Component' form input m = Component form (Const Void) () input Void m

A simple component type when the component does not need extension

#ComponentHTML Source

type ComponentHTML form act slots m = ComponentHTML (Action form act) slots m

The component's HTML type, the result of the render function.

#ComponentHTML' Source

type ComponentHTML' form m = ComponentHTML form Void () m

A simple component HTML type when the component does not need extension

#HalogenM Source

type HalogenM form st act slots msg m = HalogenM (State form st m) (Action form act) slots msg m

The component's eval type

#HalogenM' Source

type HalogenM' form msg m = HalogenM form () Void () msg m

A simple component eval type when the component does not need extension

#State Source

type State form st m = Record (StateRow form (internal :: InternalState form m | st))

The component local state

#State' Source

type State' form m = State form () m

A simple state type when the component does not need extension

#PublicState Source

type PublicState form st = Record (StateRow form st)

The component's public state

#StateRow Source

type StateRow form st = (dirty :: Boolean, errors :: Int, form :: form Record FormField, submitAttempts :: Int, submitting :: Boolean, validity :: ValidStatus | st)

The component's public state, as an extensible row

#InternalState Source

newtype InternalState form m

A newtype to make easier type errors for end users to read by hiding internal fields

Constructors

Instances

#Debouncer Source

type Debouncer = { fiber :: Fiber Unit, forkId :: ForkId, var :: AVar Unit }

A type to represent a running debouncer

#ValidStatus Source

data ValidStatus

A type to represent validation status

Constructors

Instances

#Input Source

type Input form st m = { initialInputs :: Maybe (form Record InputField), validators :: form Record (Validation form m) | st }

The component's input type. If you provide Nothing as your initialInputs then the form will fill in values based on the Initial type class for the field's input type. Otherwise, the form will contain the values you provide.

Validators can be created using the Formless.Validation module.

#Input' Source

type Input' form m = Input form () m

A simple Input type when the component does not need extension

#Event Source

data Event form st

The component tries to require as few messages to be handled as possible. You can always use the *Reply variants of queries to perform actions and receive a result out the other end, or extend these messages.

Constructors

#Event' Source

type Event' form = Event form ()

#Slot Source

type Slot form query slots msg = Slot (Query form query slots) msg

A slot type that can be used in the ChildSlots definition for your parent component

#Slot' Source

type Slot' form msg = Slot (Query' form) msg

A simple Slot type when the component does not need extension, besides a custom output message

#_formless Source

_formless :: Proxy @Symbol "formless"

A convenience export of formless as a symbol for use when mounting Formless as a child component

type ChildSlots = (formless :: F.Slot' Form FormResult)
HH.slot F._formless unit (F.component spec) input handler