Formless
- Package
- purescript-halogen-formless
- Repository
- thomashoneyman/purescript-halogen-formless
Formless is a renderless component to help you build forms in Halogen. This module re-exports all public functions and types from the library, and can be used as the single import for most use cases.
import Formless as F
Re-exports from Formless.Action
#validateAll Source
validateAll :: forall v. Variant (validateAll :: Unit | v)
Validate all fields in the form, collecting errors
[ HE.onClick \_ -> Just F.validateAll ]
#setValidateAll Source
setValidateAll :: forall form v is' is. Newtype (form Record InputField) (Record is') => HMap WrapField (Record is) (Record is') => Record is -> Variant (setAll :: Tuple (form Record InputField) Boolean | v)
Provide a record of inputs to overwrite all current inputs without
resetting the form (as loadForm
does), and then validate the
entire new set of fields. Similar to calling setValidate
on every
field in the form.
[ HE.onClick \_ -> Just $ F.setValidateAll
{ name: "Default Name"
, enabled: false
}
]
#setValidate Source
setValidate :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> i -> Variant (modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction) | v)
Set the input value of a form field at the specified label, also triggering validation to run on the field.
[ HE.onValueInput $ Just <<< F.setValidate _name ]
#setAll Source
setAll :: forall form v is is'. Newtype (form Record InputField) (Record is') => HMap WrapField (Record is) (Record is') => Record is -> Variant (setAll :: Tuple (form Record InputField) Boolean | v)
Provide a record of input fields to overwrite all current
inputs. Unlike loadForm
, this does not otherwise reset
the form as if it were new. Similar to calling set
on every
field in the form. Does not run validation.
[ HE.onClick \_ -> Just $ F.setAll
{ name: "Default Name"
, enabled: false
}
]
#set Source
set :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> i -> Variant (modify :: form Variant InputFunction | v)
Set the input value of a form field at the specified label.
[ HE.onValueInput $ Just <<< F.set _name ]
#reset Source
reset :: forall form v sym inputs r e i o. IsSymbol sym => Initial i => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> Variant (reset :: form Variant InputFunction | v)
Reset the value of the specified form field to its default value
according to the Initial
type class.
[ HE.onClick \_ -> Just $ F.reset _name ]
#modifyValidateAll Source
modifyValidateAll :: forall form v ifs' ifs. Newtype (form Record InputFunction) (Record ifs') => HMap WrapField (Record ifs) (Record ifs') => Record ifs -> Variant (modifyAll :: Tuple (form Record InputFunction) Boolean | v)
Provide a record of input functions to modify all current
inputs, and then validate all fields. Similar to calling
modifyValidate
on every field in the form.
[ HE.onClick \_ -> Just $ F.modifyValidateAll
{ name: \str -> "User: " <> str
, enabled: \bool -> not bool
}
]
#modifyValidate Source
modifyValidate :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> (i -> i) -> Variant (modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction) | v)
Modify the input value of a form field at the specified label, also triggering validation to run on the field, with the provided function.
[ HE.onChange \_ -> Just $ F.modifyValidate _enabled not ]
#modifyAll Source
modifyAll :: forall form v ifs' ifs. Newtype (form Record InputFunction) (Record ifs') => HMap WrapField (Record ifs) (Record ifs') => Record ifs -> Variant (modifyAll :: Tuple (form Record InputFunction) Boolean | v)
Provide a record of input functions to modify all current
inputs. Similar to calling modify
on every field in the form.
Does not run validation.
[ HE.onClick \_ -> Just $ F.modifyAll
{ name: \str -> "User: " <> str
, enabled: \bool -> not bool
}
]
#modify Source
modify :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Proxy sym -> (i -> i) -> Variant (modify :: form Variant InputFunction | v)
Modify the input value of a form field at the specified label with the provided function.
[ HE.onChange \_ -> Just $ F.modify _enabled not ]
#loadForm Source
loadForm :: forall form v. form Record InputField -> Variant (loadForm :: form Record InputField | v)
Load a form from a set of existing inputs. Useful for when you need to mount Formless, perform some other actions like request data from the server, and then load an existing set of inputs.
[ HE.onClick \_ -> Just $ F.loadForm $ F.wrapInputFields
{ name: ""
, enabled: false
}
]
#asyncSetValidate Source
asyncSetValidate :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Milliseconds -> Proxy sym -> i -> Variant (modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction) | v)
Set the input value of a form field at the specified label, while debouncing validation so that it only runs after the specified amount of time has elapsed since the last modification. Useful when you need to avoid expensive validation but do not want to wait for a blur event to validate.
[ HE.onValueInput $ Just <<< F.asncSetValidate (Milliseconds 300.0) _name ]
#asyncModifyValidate Source
asyncModifyValidate :: forall form v sym inputs r e i o. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) r inputs => Milliseconds -> Proxy sym -> (i -> i) -> Variant (modifyValidate :: Tuple (Maybe Milliseconds) (form Variant InputFunction) | v)
Modify the input value of a form field at the specified label, while debouncing validation so that it only runs after the specified amount of time has elapsed since the last modification. Useful when you need to avoid expensive validation but do not want to wait for a blur event to validate.
[ HE.onChange \_ -> Just $ F.asncModifyValidate (Milliseconds 300.0) _enabled not ]
Re-exports from Formless.Class.Initial
#Initial Source
class Initial v where
A type class that provides initial values for form fields. While superficially similar to
Haskell's Default
type class, this class is only meant for the purposes of defining
initial form values. If you need a default value for a field in your form, you are better
off defining it as a Maybe
field and providing a default as part of validation.
In general, if you find yourself reaching for this type class without defining your form as a row and generating your form spec from it, then you are probably not doing what you intend.
Members
initial :: v
Instances
Initial Unit
Initial Boolean
Initial Int
Initial Number
Initial String
Initial Ordering
Initial (Maybe a)
Initial (Array a)
Initial (List a)
(Ord k) => Initial (Map k v)
(Ord a) => Initial (Set a)
(Monoid b) => Initial (a -> b)
(Initial a, Initial b) => Initial (Tuple a b)
(RowToList row list, MonoidRecord list row row) => Initial (Record row)
Re-exports from Formless.Component
#raiseResult Source
raiseResult :: forall form st act slots wrappedOutput output m. Newtype (form Record OutputField) (Record wrappedOutput) => HMap UnwrapField (Record wrappedOutput) (Record output) => Event form st -> HalogenM form st act slots (Record output) m Unit
A convenience function for raising a form's validated and unwrapped outputs as its only message to a parent component. Useful when you only want to be notified with a form's successfully-parsed data. For example:
type User = { name :: String, email :: Email }
newtype UserForm r f = UserForm (r
( name :: f Void String String
, email :: f EmailError String Email
))
derive instance newtypeUserForm :: Newtype (UserForm r f) _
-- we only want to handle our `User` type on successful submission; we can
-- use `raiseResult` as our `handleEvent` function to do this conveniently.
formSpec = F.defaultSpec { handleEvent = raiseResult }
-- the parent can now just handle the `User` output
data ParentAction = HandleForm User
type ChildSlots = ( formless :: F.Slot' UserForm User Unit )
#handleQuery Source
handleQuery :: forall form st query act slots msg m a is ixs ivs fs fxs us vs os ifs ivfs. MonadAff m => RowToList is ixs => RowToList fs fxs => EqRecord ixs is => InputFieldsToFormFields ixs is fs => FormFieldsToInputFields fxs fs is => CountErrors fxs fs => AllTouched fxs fs => SetFormFieldsTouched fxs fs fs => ReplaceFormFieldInputs is fxs fs fs => ModifyAll ifs fxs fs fs => ValidateAll vs fxs fs fs m => FormFieldToMaybeOutput fxs fs os => Newtype (form Record InputField) (Record is) => Newtype (form Record InputFunction) (Record ifs) => Newtype (form Record FormField) (Record fs) => Newtype (form Record OutputField) (Record os) => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Variant InputField) (Variant ivs) => Newtype (form Variant InputFunction) (Variant ivfs) => Newtype (form Variant U) (Variant us) => Lacks "internal" st => (forall b. query b -> HalogenM form st act slots msg m (Maybe b)) -> (Event form st -> HalogenM form st act slots msg m Unit) -> Query form query slots a -> HalogenM form st act slots msg m (Maybe a)
#handleAction Source
handleAction :: forall form st act slots msg m is ixs ivs fs fxs us vs os ifs ivfs. MonadAff m => RowToList is ixs => RowToList fs fxs => EqRecord ixs is => InputFieldsToFormFields ixs is fs => FormFieldsToInputFields fxs fs is => CountErrors fxs fs => AllTouched fxs fs => SetFormFieldsTouched fxs fs fs => ReplaceFormFieldInputs is fxs fs fs => ModifyAll ifs fxs fs fs => ValidateAll vs fxs fs fs m => FormFieldToMaybeOutput fxs fs os => Newtype (form Record InputField) (Record is) => Newtype (form Record InputFunction) (Record ifs) => Newtype (form Record FormField) (Record fs) => Newtype (form Record OutputField) (Record os) => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Variant InputField) (Variant ivs) => Newtype (form Variant InputFunction) (Variant ivfs) => Newtype (form Variant U) (Variant us) => Lacks "internal" st => (act -> HalogenM form st act slots msg m Unit) -> (Event form st -> HalogenM form st act slots msg m Unit) -> Action form act -> HalogenM form st act slots msg m Unit
#defaultSpec Source
defaultSpec :: forall form st query act slots input msg m. Spec form st query act slots input msg m
The default spec, which can be overridden by whatever functions you need to extend the component. For example:
mySpec = F.defaultSpec { render = myRender }
#component Source
component :: forall form st query act slots input msg m is ixs ivs fs fxs us vs os ifs ivfs. MonadAff m => RowToList is ixs => RowToList fs fxs => EqRecord ixs is => InputFieldsToFormFields ixs is fs => FormFieldsToInputFields fxs fs is => CountErrors fxs fs => AllTouched fxs fs => SetFormFieldsTouched fxs fs fs => ReplaceFormFieldInputs is fxs fs fs => ModifyAll ifs fxs fs fs => ValidateAll vs fxs fs fs m => FormFieldToMaybeOutput fxs fs os => MakeInputFieldsFromRow ixs is is => Newtype (form Record InputField) (Record is) => Newtype (form Record InputFunction) (Record ifs) => Newtype (form Record FormField) (Record fs) => Newtype (form Record OutputField) (Record os) => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Variant InputField) (Variant ivs) => Newtype (form Variant InputFunction) (Variant ivfs) => Newtype (form Variant U) (Variant us) => Lacks "validators" st => Lacks "initialInputs" st => Lacks "validity" st => Lacks "dirty" st => Lacks "errors" st => Lacks "submitAttempts" st => Lacks "submitting" st => Lacks "form" st => Lacks "internal" st => (input -> Input form st m) -> Spec form st query act slots input msg m -> Component form query slots input msg m
The Formless component, which takes a spec
and provides a running form
component from it.
Re-exports from Formless.Data.FormFieldResult
#FormFieldResult Source
data FormFieldResult error output
A data type which represents the possible output states of the field. Use
the helpers in Retrieve
to easily manipulate this type.
Constructors
NotValidated
Validating
Error error
Success output
Instances
(Eq e, Eq o) => Eq (FormFieldResult e o)
Functor (FormFieldResult e)
Apply (FormFieldResult e)
Applicative (FormFieldResult e)
Bind (FormFieldResult e)
Monad (FormFieldResult e)
#toMaybe Source
toMaybe :: forall e o. FormFieldResult e o -> Maybe o
#fromEither Source
fromEither :: forall e o. Either e o -> FormFieldResult e o
#_Success Source
_Success :: forall e o. Prism' (FormFieldResult e o) o
#_Error Source
_Error :: forall e o. Prism' (FormFieldResult e o) e
Re-exports from Formless.Query
#submitReply Source
submitReply :: forall form query ps a. (Maybe (form Record OutputField) -> a) -> Query form query ps a
Submit the form, returning the output of validation if successful
and Nothing
otherwise.
#sendQuery Source
sendQuery :: forall outS outL inS inL form msg q ps cq cm pps r0 r1 st pmsg act m a. IsSymbol outL => IsSymbol inL => Cons outL (Slot (Query form q ps) msg outS) r0 pps => Cons inL (Slot cq cm inS) r1 ps => Ord outS => Ord inS => Proxy outL -> outS -> Proxy inL -> inS -> cq a -> HalogenM st act pps pmsg m (Maybe a)
When you have specified a child component within Formless and need to query it, you can do so in two ways.
First, you can use H.query
as usual within the handleExtraQuery
function
you provide to Formless as input. You can, for example, write your own query
which manages the child component, write it into the render function you
supply Formless, and then when that query is triggered, query the child
component.
Second, you can use the sendQuery
function within your parent component's
handleAction
or handleQuery
functions. Given the slot for Formless, the
slot for the child component within Formless, and the query you'd like to
send the child component, sendQuery
will run through Formless and return
the query result to the parent.
For example, this is how you would query a dropdown component being run within a Formless form from the parent component.
-- in the parent component which mounts Formless
handleAction = case _ of
SendDropdown (dropdownQuery -> do
result <- F.sendQuery _formless unit _dropdown 10 dropdownQuery
#asQuery Source
asQuery :: forall form q ps. Variant (PublicAction form) -> Query form q ps Unit
Convert a Formless public action to an action-style query. Any action from Formless.Action will work, but no others.
Re-exports from Formless.Retrieve
#GetTouchedField Source
data GetTouchedField
Data constructor for the getTouchedField function
Constructors
Instances
Mapping GetTouchedField (FormField e i o) Boolean
#GetResultField Source
data GetResultField
Data constructor for the getResultField function
Constructors
Instances
Mapping GetResultField (FormField e i o) (FormFieldResult e o)
Heterogeneous type class for the getResultField function
#GetInputField Source
data GetInputField
Data constructor for the getInputField function
Constructors
Instances
Mapping GetInputField (FormField e i o) i
Heterogeneous type class for the getInputField function
#FormFieldGet Source
type FormFieldGet e i o x = forall sym form fields t0. IsSymbol sym => Newtype (form Record FormField) (Record fields) => Cons sym (FormField e i o) t0 fields => Proxy sym -> form Record FormField -> x
A type representing a function to produce a value from a record of
form fields given a particular symbol. The result of view
from
Data.Lens applied with a particular lens to the form.
#getTouchedAll Source
getTouchedAll :: GetAll GetTouchedField
Get the form as a record where all fields are only the touched value
#getTouched Source
getTouched :: forall e i o. FormFieldGet e i o Boolean
Given a form, get the touched field at the specified symbol
#getResultAll Source
getResultAll :: GetAll GetResultField
Get the form as a record where all fields are only the result value
#getResult Source
getResult :: forall e i o. FormFieldGet e i o (FormFieldResult e o)
Given a form, get the result at the specified symbol
#getOutputAll Source
getOutputAll :: GetAll GetOutput
Get the form as a record where all fields are only the output value
#getOutput Source
getOutput :: forall e i o. FormFieldGet e i o (Maybe o)
Given a form, get the output (if it exists) at the specified symbol
#getInputAll Source
getInputAll :: GetAll GetInputField
Get the form as a record where all fields are only the input value
#getInput Source
getInput :: forall e i o. FormFieldGet e i o i
Given a form, get the input at the specified symbol
#getField Source
getField :: forall e i o. FormFieldGet e i o (Record (FormFieldRow e i o))
Given a form, get the field at the specified symbol
#getErrorAll Source
getErrorAll :: GetAll GetError
Get the form as a record where all fields are only the error value
#getError Source
getError :: forall e i o. FormFieldGet e i o (Maybe e)
Given a form, get the error (if it exists) at the specified symbol
#_FieldTouched Source
_FieldTouched :: forall e i o. FormFieldLens e i o Boolean
A lens to operate on the 'touched' field at a given symbol in your form
#_FieldResult Source
_FieldResult :: forall e i o. FormFieldLens e i o (FormFieldResult e o)
A lens to operate on the 'result' field at a given symbol in your form
#_FieldOutput Source
_FieldOutput :: forall sym form fields t0 e i o. IsSymbol sym => Newtype (form Record FormField) (Record fields) => Cons sym (FormField e i o) t0 fields => Proxy sym -> Traversal' (form Record FormField) o
A traversal to operate on the possible output inside the 'result' field at a given symbol in your form
#_FieldInput Source
_FieldInput :: forall e i o. FormFieldLens e i o i
A lens to operate on the input at a given symbol in your form
#_FieldError Source
_FieldError :: forall sym form fields t0 e i o. IsSymbol sym => Newtype (form Record FormField) (Record fields) => Cons sym (FormField e i o) t0 fields => Proxy sym -> Traversal' (form Record FormField) e
A traversal to operate on the possible error inside the 'result' field at a given symbol in your form
#_Field Source
_Field :: forall e i o. FormFieldLens e i o (Record (FormFieldRow e i o))
A lens to operate on the field at a given symbol in your form
Re-exports from Formless.Transform.Record
#UnwrapField Source
data UnwrapField
Unwrap every newtype in a record filled with newtypes
Constructors
Instances
(Newtype wrapper x) => Mapping UnwrapField wrapper x
#wrapRecord Source
wrapRecord :: forall r0 r1. HMap WrapField r0 r1 => r0 -> r1
#wrapInputFunctions Source
wrapInputFunctions :: forall form ifs ifs'. Newtype (form Record InputFunction) (Record ifs') => HMap WrapField (Record ifs) (Record ifs') => Record ifs -> form Record InputFunction
Provided a record, where each field in the record contains
a function from input -> input
, wraps each function in
the InputField type for compatibility with Formless
#wrapInputFields Source
wrapInputFields :: forall form is is'. Newtype (form Record InputField) (Record is') => HMap WrapField (Record is) (Record is') => Record is -> form Record InputField
Provided a record, where each field in the record contains
a value of type input
, wraps each value in the InputField
type for compatibility with Formless
#unwrapRecord Source
unwrapRecord :: forall r0 r1. HMap UnwrapField r0 r1 => r0 -> r1
#unwrapOutputFields Source
unwrapOutputFields :: forall form os os'. Newtype (form Record OutputField) (Record os) => HMap UnwrapField (Record os) (Record os') => form Record OutputField -> Record os'
Provided your form type containing a record of only valid outputs from the result of validation, unwraps the form and every value in the record to provide a record of only the output values.
Re-exports from Formless.Transform.Row
#SProxies Source
type SProxies form = forall xs row inputs. RowToList inputs xs => Newtype (form Record InputField) (Record inputs) => MakeSProxies xs row => Record row
A type to collect constraints necessary to apply to prove that a record of SProxies is compatible with your form type.
#MakeInputFieldsFromRow Source
class MakeInputFieldsFromRow (xs :: RowList Type) (row :: Row Type) (to :: Row Type) | xs -> to where
The class that provides the Builder implementation to efficiently transform a row into a proper InputFields by wrapping it in newtypes and supplying initial values
Members
mkInputFieldsFromRowBuilder :: Proxy xs -> Proxy row -> FromScratch to
Instances
MakeInputFieldsFromRow Nil row ()
(IsSymbol name, Initial i, Cons name (InputField e i o) trash row, MakeInputFieldsFromRow tail row from, Row1Cons name (InputField e i o) from to) => MakeInputFieldsFromRow (Cons name (InputField e i o) tail) row to
#MakeSProxies Source
class MakeSProxies (xs :: RowList Type) (to :: Row Type) | xs -> to where
The class used to build up a new record of symbol proxies from an input row list.
Members
makeSProxiesBuilder :: Proxy xs -> FromScratch to
Instances
MakeSProxies Nil ()
(IsSymbol name, Row1Cons name (Proxy name) from to, MakeSProxies tail from) => MakeSProxies (Cons name x tail) to
#mkSProxies Source
mkSProxies :: forall form xs inputs row. RowToList inputs xs => Newtype (form Record InputField) (Record inputs) => MakeSProxies xs row => Proxy form -> Record row
A helper function to produce a record of SProxies given a form spec, to save you the boilerplate of writing them all out.
#mkInputFields Source
mkInputFields :: forall xs form inputs. RowToList inputs xs => Newtype (form Record InputField) (Record inputs) => MakeInputFieldsFromRow xs inputs inputs => form Record InputField
A function to transform a row of labels into a InputFields. This allows you
to go directly from a custom form newtype to an inputs record without having to
fill in any values. Requires that all members have an instance of the
Initial
type class (all monoidal values do by default, along with some
other primitives).
Re-exports from Formless.Types.Component
#ValidStatus Source
#State Source
type State form st m = Record (StateRow form (internal :: InternalState form m | st))
The component local state
#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.
#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
SubmitReply (Maybe (form Record OutputField) -> a)
SendQuery (ChildQueryBox slots (Maybe a))
AsQuery (Variant (PublicAction form)) a
Instances
#PublicState Source
type PublicState form st = Record (StateRow form st)
The component's public state
#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)
#InternalState Source
newtype InternalState form m
A newtype to make easier type errors for end users to read by hiding internal fields
Constructors
InternalState { allTouched :: Boolean, debounceRef :: Maybe (Ref (Maybe Debouncer)), initialInputs :: form Record InputField, validationRef :: Maybe (Ref (Maybe ForkId)), validators :: form Record (Validation form m) }
Instances
Newtype (InternalState form m) _
#InternalAction Source
type InternalAction act r = (initialize :: Maybe act, syncFormData :: Unit | r)
#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.
#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
Submitted (form Record OutputField)
Changed (PublicState form st)
#ComponentHTML' Source
type ComponentHTML' form m = ComponentHTML form Void () m
A simple component HTML 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.
#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
#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
.
Re-exports from Formless.Types.Form
#OutputType Source
type OutputType error input output = output
#OutputField Source
newtype OutputField error input output
Constructors
OutputField output
Instances
Newtype (OutputField e i o) _
(Eq o) => Eq (OutputField e i o)
(Show o) => Show (OutputField e i o)
#InputFunction Source
newtype InputFunction error input output
Constructors
InputFunction (input -> input)
Instances
Newtype (InputFunction e i o) _
#InputField Source
newtype InputField error input output
Constructors
InputField input
Instances
Newtype (InputField e i o) _
(Eq i) => Eq (InputField e i o)
#FormFieldRow Source
type FormFieldRow error input output = (input :: input, result :: FormFieldResult error output, touched :: Boolean)
The row used for the FormField newtype and in lens type signatures
Re-exports from Formless.Validation
#Validation Source
newtype Validation form m error input output
A wrapper to represent the validation function on a form field, which can itself take the form state as its first argument. Inspired in some parts by the Validation type from purescript-polyform by @paluh.
Constructors
Validation (form Record FormField -> input -> m (Either error output))
Instances
Newtype (Validation form m e i o) _
(Functor m) => Functor (Validation form m e i)
(Monad m) => Apply (Validation form m e i)
(Monad m) => Applicative (Validation form m e i)
(Monad m) => Alt (Validation form m e i)
(Semigroup (m (Either e o))) => Semigroup (Validation form m e i o)
(Applicative m, Monoid (m (Either e o)), Semigroup (m (Either e o))) => Monoid (Validation form m e i o)
(Monad m) => Semigroupoid (Validation form m e)
(Monad m) => Category (Validation form m e)
(Monad m) => Mapping EmptyValidators a (Validation form m e i i)
The heterogeneous instance the noValidation function
#EmptyValidators Source
data EmptyValidators
The data type used for the noValidation function's heterogenous instance
Constructors
Instances
(Monad m) => Mapping EmptyValidators a (Validation form m e i i)
The heterogeneous instance the noValidation function
#runValidation Source
runValidation :: forall form m e i o. Monad m => Validation form m e i o -> form Record FormField -> i -> m (Either e o)
A more verbose but clearer function for running a validation function on its inputs
#noValidators Source
noValidators :: forall form fields m vs xs. Monad m => RowToList fields xs => Newtype (form Record (Validation form m)) (Record vs) => Newtype (form Record InputField) (Record fields) => MapRecordWithIndex xs (ConstMapping EmptyValidators) fields vs => form Record InputField -> form Record (Validation form m)
A function to create a record of validators that simply pass through all inputs
for when no validation is needed. Provide this as your validators
function.
#noValidation Source
noValidation :: forall form m e i. Monad m => Validation form m e i i
A validation function which simply passes through its input value as its output value. Use on individual fields which do not need any validation.
#hoistFn_ Source
hoistFn_ :: forall form m e i o. Monad m => (i -> o) -> Validation form m e i o
Turn a function from (i -> o) into a proper Validation
#hoistFnME_ Source
hoistFnME_ :: forall form m e i o. Monad m => (i -> m (Either e o)) -> Validation form m e i o
Turn a function from (i -> m (Either e o)) into a proper Validation
#hoistFnE_ Source
hoistFnE_ :: forall form m e i o. Monad m => (i -> Either e o) -> Validation form m e i o
Turn a function from (i -> Either e o) into a proper Validation
- Modules
- Formless
- Formless.
Action - Formless.
Class. Initial - Formless.
Component - Formless.
Data. FormFieldResult - Formless.
Internal. Component - Formless.
Internal. Debounce - Formless.
Internal. Transform - Formless.
Query - Formless.
Retrieve - Formless.
Transform. Record - Formless.
Transform. Row - Formless.
Types. Component - Formless.
Types. Form - Formless.
Validation
Heterogeneous type class for the getTouchedField function