Liking cljdoc? Tell your friends :D

fulcro.ui.form-state


add-form-configclj/s

(add-form-config class entity)

Add form configuration data to a denormalized entity (e.g. pre-merge). This is useful in initial state or when using merge-component!. This function will not touch an entity that already has form config but will recurse the entire form set. It can therefore be invoked on the top-level of the form set when adding, for example, an instance of a sub-form.

class - The component class entity - A denormalized (tree) of data that matches the given component class.

Returns the (possibly updated) denormalized entity, ready to merge.

Add form configuration data to a *denormalized* entity (e.g. pre-merge). This is useful in
initial state or when using `merge-component!`. This function *will not* touch an entity
that already has form config but will recurse the entire form set. It can therefore be
invoked on the top-level of the form set when adding, for example, an instance of a sub-form.

class - The component class
entity - A denormalized (tree) of data that matches the given component class.

Returns the (possibly updated) denormalized entity, ready to merge.
sourceraw docstring

add-form-config*clj/s

(add-form-config* state-map class entity-ident)

Identical to add-form-config, but works against normalized entities in the app state. This makes it ideal for composition within mutations.

state-map - The application state database (map, not atom). class - The component class. Must have declared form fields. entity-ident - The ident of the normalized entity of the given class that you wish to initialize.

Returns an updated state map with normalized form configuration in place for the entity.

Identical to `add-form-config`, but works against normalized entities in the
app state. This makes it ideal for composition within mutations.

state-map - The application state database (map, not atom).
class - The component class. Must have declared form fields.
entity-ident - The ident of the normalized entity of the given class that you wish to initialize.

Returns an updated state map with normalized form configuration in place for the entity.
sourceraw docstring

checked?clj/s

(checked? ui-form)
(checked? ui-form field)

Returns true if the field (or entire denormalized (UI) form) is ready to be checked for validation. Until this returns true validators will simply return :unchecked for a form/field.

Returns true if the field (or entire denormalized (UI) form) is ready to be checked for validation.
Until this returns true validators will simply return :unchecked for a form/field.
sourceraw docstring

clear-complete*clj/s

(clear-complete* state-map entity-ident)
(clear-complete* state-map entity-ident field)

Mark the fields incomplete so that validation checks will no longer return values. This function works on a app state database map (not atom) and is meant to be composed into mutations. See the mark-incomplete! mutation if you do not need to combine this with other operations.

Follows the subforms recursively through state, unless a specific field is given.

Mark the fields incomplete so that validation checks will no longer return values. This function works on a app state database
map (not atom) and is meant to be composed into mutations. See the `mark-incomplete!` mutation if you do not need to combine
this with other operations.

Follows the subforms recursively through state, unless a specific field is given.
sourceraw docstring

delete-form-state*clj/s

(delete-form-state* state-map entity-ident-or-idents)

Removes copies of entities used by form-state logic.

Removes copies of entities used by form-state logic.
sourceraw docstring

dirty-fieldsclj/s

(dirty-fields ui-entity as-delta?)

Obtains all of the dirty fields for the given (denormalized) ui-entity, recursively. This works against UI props because submission mutations should close over the data as parameters to a mutation. In other words, your form submission to a server should be triggered from UI with the output of this function as parameters:

(dom/input { :onClick #(prim/transact! this `[(some-submit-function {:diff ~(f/dirty-fields props true)})]) })

ui-entity - The entity (denormalized) from the UI. as-delta? - If false, each field's reported (new) value will just be the new value. When true, each value will be a map with :before and :after keys with the old and new values (useful for optimistic transaction semantics).

Returns a map keyed by form ID (for each form/subform) whose values are maps of key/value pairs of changes. Fields from entities that have a temporary IDs will always be included.

In other words, a change that happened for an entity with ident entity-ident on field :field:

With as-delta? true:

{entity-ident {:field {:before 1 :after 2}}}

with as-delta? false:

{entity-ident {:field 2}}
Obtains all of the dirty fields for the given (denormalized) ui-entity, recursively. This works against UI props
because submission mutations should close over the data as parameters to a mutation. In other words, your form
submission to a server should be triggered from UI with the output of this function as parameters:

```
(dom/input { :onClick #(prim/transact! this `[(some-submit-function {:diff ~(f/dirty-fields props true)})]) })
```

ui-entity - The entity (denormalized) from the UI.
as-delta? - If false, each field's reported (new) value will just be the new value. When true, each value will be a map with :before and :after keys
with the old and new values (useful for optimistic transaction semantics).

Returns a map keyed by form ID (for each form/subform) whose values are maps of key/value pairs of
changes. Fields from entities that have a temporary IDs will always be included.

In other words, a change that happened for an entity with ident `entity-ident` on field `:field`:

With `as-delta?` true:

```
{entity-ident {:field {:before 1 :after 2}}}
```

with `as-delta?` false:

```
{entity-ident {:field 2}}
```
sourceraw docstring

dirty?clj/s

(dirty? ui-entity-props)
(dirty? ui-entity-props field)

Returns true if the given ui-entity-props that are configured as a form differ from the pristine version. Recursively follows subforms if given no field. Returns true if anything doesn't match up.

If given a field, it only checks that field.

Returns true if the given ui-entity-props that are configured as a form differ from the pristine version.
Recursively follows subforms if given no field. Returns true if anything doesn't match up.

If given a field, it only checks that field.
sourceraw docstring

entity->pristine*clj/s

(entity->pristine* state-map entity-ident)

Overwrite the pristine state (form state's copy) of the entity. This is meant to be used from a mutation to update the form state tracking recursively to make the form as 'unmodified'. That is to say, as if you committed the values to the server, and the current entity state is now the pristine state.

This function does no sanity checks, so you should ensure the entity is valid!

Recursively updates all sub forms.

Returns the updated state-map (database).

Overwrite the pristine state (form state's copy) of the entity. This is meant to be used from a mutation
to update the form state tracking recursively to make the form as 'unmodified'. That is to say, as if you
committed the values to the server, and the current entity state is now the pristine state.

This function does no sanity checks, so you should ensure the entity is valid!

Recursively updates all sub forms.

Returns the updated state-map (database).
sourceraw docstring

form-configclj/s

(form-config entity-ident fields)
(form-config entity-ident fields subforms)

Generate a form config given:

entity-ident - The ident of the entity you're configuring forms for. fields - A set of keywords on the entity that is the form. subforms - An optional set of keywords on the entity that is the form, for the joins to subforms.

Generate a form config given:

entity-ident - The ident of the entity you're configuring forms for.
fields - A set of keywords on the entity that is the form.
subforms - An optional set of keywords on the entity that is the form, for the joins to subforms.
sourceraw docstring

form-config-joinclj/s

A query join to ::form-config.

A query join to ::form-config.
sourceraw docstring

form-idclj/s

(form-id entity-ident)

Returns the form database table ID for the given entity ident.

Returns the form database table ID for the given entity ident.
sourceraw docstring

FormConfigclj/s≠

clj
cljs
(FormConfig)
source

get-form-fieldsclj/s

(get-form-fields class)
source

get-spec-validityclj/s

(get-spec-validity form)
(get-spec-validity form field)

Get the validity (:valid :invalid or :unchecked) for the given form/field using Clojure specs of the field keys.

ui-entity-props : A denormalized (UI) entity, which can have subforms. field : Optional. Returns the validity of just the single field on the top-level form.

Returns :invalid if all of the fields have been interacted with, and any are invalid. Returns :unchecked if any field is not yet been interacted with.

Fields are marked as having been interacted with by programmatic action on your part via the validate* mutation helper can be used in a mutation to mark fields ready for validation.

If given a field then it checks just that field.

Get the validity (:valid :invalid or :unchecked) for the given form/field using Clojure specs of the field keys.

ui-entity-props : A denormalized (UI) entity, which can have subforms.
field : Optional. Returns the validity of just the single field on the top-level form.

Returns `:invalid` if all of the fields have been interacted with, and *any* are invalid.
Returns `:unchecked` if any field is not yet been interacted with.

Fields are marked as having been interacted with by programmatic action on your part via
the validate* mutation helper can be used in a mutation to mark fields ready for validation.

If given a field then it checks just that field.
sourceraw docstring

ident-generatorclj/s

source

IFormFieldsclj/s≠protocol

form-fieldsclj/s

(form-fields this)

Returns a set of keywords that define the form fields of interest on an entity

Returns a set of keywords that define the form fields of interest on an entity
source

immediate-subformsclj/s

(immediate-subforms entity subform-join-keys)

Get the instances of the immediate subforms that are joined into the given entity by subform-join-keys (works with to-one and to-many).

entity - a denormalized (UI) entity. subform-join-keys - The keys of the subforms of this entity, as a set.

Returns a sequence of those entities (all denormalized).

Get the instances of the immediate subforms that are joined into the given entity by
subform-join-keys (works with to-one and to-many).

entity - a denormalized (UI) entity.
subform-join-keys - The keys of the subforms of this entity, as a set.

Returns a sequence of those entities (all denormalized).
sourceraw docstring

invalid-spec?clj/s

(invalid-spec? ui-form)
(invalid-spec? ui-form field)

Returns true if the given field (or any field if only a form is given) in the denormalized (UI) form is :invalid (recursively) according to clojure specs. Returns false if the field is marked unchecked. Use checked-spec? or get-spec-validity for better detail.

Returns true if the given field (or any field if only a form is given) in the denormalized (UI) form is :invalid
(recursively) according to clojure specs. Returns false if the field is marked unchecked. Use `checked-spec?` or
`get-spec-validity` for better detail.
sourceraw docstring

make-validatorclj/s

(make-validator field-valid?)

Create a form/field validation function using a supplied field checker. The field checker will be given then entire form (denormalized) and a single field key that is to be checked. It must return a boolean indicating if that given field is valid.

During a recursive check for a form, the validation function will be in the correct context (e.g. the form supplied will contain the field. There is no need to search for it in subforms).

make-validator returns a dual arity function:

(fn [form] ...) - Calling this version will return :unchecked, :valid, or :invalid for the entire form. (fn [form field] ...) - Calling this version will return :unchecked, :valid, or :invalid for the single field.

Typical usage would be to show messages around the form fields:

(def field-valid? [form field] true) ; just say everything is valid

(def my-validator (make-validator field-valid?))

(defn valid? [form field]
   (= :valid (my-validator form field)))

(defn checked? [form field]
   (not= :unchecked (my-validator form field)))
Create a form/field validation function using a supplied field checker. The field checker will be given
then entire form (denormalized) and a single field key that is to be checked. It must return
a boolean indicating if that given field is valid.

During a recursive check for a form, the validation function will be in the correct context (e.g. the form supplied will contain
the field. There is no need to search for it in subforms).

make-validator returns a dual arity function:

(fn [form] ...) - Calling this version will return :unchecked, :valid, or :invalid for the entire form.
(fn [form field] ...) - Calling this version will return :unchecked, :valid, or :invalid for the single field.

Typical usage would be to show messages around the form fields:

```
(def field-valid? [form field] true) ; just say everything is valid

(def my-validator (make-validator field-valid?))

(defn valid? [form field]
   (= :valid (my-validator form field)))

(defn checked? [form field]
   (not= :unchecked (my-validator form field)))
```
sourceraw docstring

mark-complete*clj/s

(mark-complete* state-map entity-ident)
(mark-complete* state-map entity-ident field)

Mark the fields complete so that validation checks will return values. This function works on a app state database map (not atom) and is meant to be composed into mutations. See the mark-complete! mutation if you do not need to combine this with other operations.

Follows the subforms recursively through state, unless a specific field is given.

Mark the fields complete so that validation checks will return values. This function works on a app state database
map (not atom) and is meant to be composed into mutations. See the `mark-complete!` mutation if you do not need to combine
this with other operations.

Follows the subforms recursively through state, unless a specific field is given.
sourceraw docstring

no-spec-or-valid?clj/s

(no-spec-or-valid? entity-props key)

Returns false if and only if the given key has a spec, and the spec is not valid for the value found in the given map of entity props (e.g. (s/valid? key (get entity-props key))).

Returns true otherwise.

Returns false if and only if the given key has a spec, and the spec is not valid for the value found in the given
map of entity props (e.g. `(s/valid? key (get entity-props key))`).

Returns true otherwise.
sourceraw docstring

pristine->entity*clj/s

(pristine->entity* state-map entity-ident)

Copy the pristine state over top of the originating entity of the given form. Meant to be used inside of a mutation. Recursively follows subforms in app state. Returns the new app state map.

state-map - The normalized state database (map, not atom) entity-ident - The ident of the entity that you wish to restore to its original pristine state

Only affects declared fields and sub-forms.

Copy the pristine state over top of the originating entity of the given form. Meant to be used inside of a
mutation. Recursively follows subforms in app state. Returns the new app state map.

state-map - The normalized state database (map, not atom)
entity-ident - The ident of the entity that you wish to restore to its original pristine state

Only affects declared fields and sub-forms.
sourceraw docstring

ui-form-configclj/s

Render form config

Render form config
sourceraw docstring

update-formsclj/s

(update-forms state-map xform starting-entity-ident)

Recursively update a form and its subforms. This function works against the state database (normalized state).

state-map : The application state map xform : A function (fn [entity form-config] [entity' form-config']) that is passed the normalized entity and form-config, and must return an updated version of them. starting-entity-ident : An ident in the state map of an entity that has been initialized as a form.

Returns the updated state map.

Recursively update a form and its subforms. This function works against the state database (normalized state).

state-map : The application state map
xform : A function (fn [entity form-config] [entity' form-config']) that is passed the normalized entity and form-config,
  and must return an updated version of them.
starting-entity-ident : An ident in the state map of an entity that has been initialized as a form.

Returns the updated state map.
sourceraw docstring

valid-spec?clj/s

(valid-spec? ui-form)
(valid-spec? ui-form field)

Returns true if the given field (or the entire denormalized (UI) form recursively) is :valid according to clojure specs. Returns false if unchecked or invalid. Use checked-spec? or get-spec-validity for better detail.

Returns true if the given field (or the entire denormalized (UI) form recursively) is :valid
according to clojure specs. Returns false if unchecked or invalid. Use `checked-spec?` or `get-spec-validity`
for better detail.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close