Formless.Query
- Package
- purescript-formless-aj
- Repository
- ajnsit/purescript-formless-independent
This module exports helpers for working with Formless queries. Since many queries are used as actions and may involve injecting variants, these helpers are provided to remove any associated boilerplate. Prefer these over using data constructors from the Formless query algebra.
#loadForm Source
loadForm :: forall form. form Record InputField -> Query formReplace all form inputs with a new set of inputs, and re-initialize the form to a new state. Useful to set a new "initial state" for a form, especially when filling a form with data loaded asynchronously.
#loadForm_ Source
loadForm_ :: forall form. form Record InputField -> Query forminitialize as an action, so you don't need to specify a Unit
result. Use to skip a use of Halogen.action.
#andThen Source
andThen :: forall form. Query form -> Query form -> Query formPerform two Formless actions in sequence. Can be chained arbitrarily. Useful when a field needs to modify itself on change and also trigger validation on one or more other fields, or when a modification on one field should also modify another field.
#set Source
set :: forall o i e t0 sym inputs form. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) t0 inputs => SProxy sym -> i -> Query formSet the input value of a form field at the specified label
#setValidate Source
setValidate :: forall o i e t0 sym inputs form. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) t0 inputs => SProxy sym -> i -> Query formSet the input value of a form field at the specified label, also triggering validation to run on the field.
#asyncSetValidate Source
asyncSetValidate :: forall o i e t0 sym inputs form. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) t0 inputs => Milliseconds -> SProxy sym -> i -> Query formSet 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.
#modify Source
modify :: forall o i e t0 sym inputs form. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) t0 inputs => SProxy sym -> (i -> i) -> Query formModify the input value of a form field at the specified label with the provided function.
#modifyValidate Source
modifyValidate :: forall o i e t0 sym inputs form. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) t0 inputs => SProxy sym -> (i -> i) -> Query formModify the input value of a form field at the specified label, also triggering validation to run on the field, with the provided function.
#asyncModifyValidate Source
asyncModifyValidate :: forall o i e t0 sym inputs form. IsSymbol sym => Newtype (form Variant InputFunction) (Variant inputs) => Cons sym (InputFunction e i o) t0 inputs => Milliseconds -> SProxy sym -> (i -> i) -> Query formModify 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.
#setAll Source
setAll :: forall is' is form. Newtype (form Record InputField) (Record is') => HMap WrapField (Record is) (Record is') => Record is -> Query formProvide a record of input fields to overwrite all current
inputs. Unlike initialize, this does not otherwise reset
the form as if it were new. Similar to calling set on every
field in the form.
#validateAll Source
validateAll :: forall form. Query formValidate all fields in the form, collecting errors
#setValidateAll Source
setValidateAll :: forall is' is form. Newtype (form Record InputField) (Record is') => HMap WrapField (Record is) (Record is') => Record is -> Query formProvide a record of inputs to overwrite all current inputs without
resetting the form (as initialize does), and then validate the
entire new set of fields. Similar to calling setValidate on every
field in the form.
#modifyValidateAll Source
modifyValidateAll :: forall ifs' ifs form. Newtype (form Record InputFunction) (Record ifs') => HMap WrapField (Record ifs) (Record ifs') => Record ifs -> Query formProvide 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.