Module
Formless.Component
- Package
- purescript-halogen-formless
- Repository
- thomashoneyman/purescript-halogen-formless
#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 }
#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 )
#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.
#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
#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)
- 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