Liking cljdoc? Tell your friends :D

f-form.field

Functions for creating and updating a field, an immutable representation of a single element in a form. A field has a value, some history about interactions with it, and knowledge about where it fits in its f-form.form.

Conceptually, a field corresponds to a single HTML <input>, <select>, or <textarea>.

A field has a :field/value, which can be any value: a primitive string, number or boolean, or a more elaborate map or set. (It also has a :field/initial-value, the value before any changes.)

It has a :field/path, which uniquely identifies it in its form. The path is a sequence of keys as defined by clojure.core/assoc-in.

And finally, it has a :field/tracker. The tracker defines which other state and history attributes will be stored on the field. See f-form.field-tracker for more information about these attributes and how they are set.

See f-form.dom for tools to attach a field to a DOM node.

Functions for creating and updating a `field`, an immutable representation of
a single element in a form. A field has a value, some history about interactions
with it, and knowledge about where it fits in its [[f-form.form]].

Conceptually, a `field` corresponds to a single HTML `<input>`, `<select>`, or
`<textarea>`.

A field has a `:field/value`, which can be any value: a primitive string, number or
boolean, or a more elaborate map or set. (It also has a `:field/initial-value`,
the value before any changes.)

It has a `:field/path`, which uniquely identifies it in its form. The path is
a sequence of keys as defined by `clojure.core/assoc-in`.

And finally, it has a `:field/tracker`. The tracker defines which other state
and history attributes will be stored on the field. See
[[f-form.field-tracker]] for more information about these attributes and how
they are set.

See [[f-form.dom]] for tools to attach a field to a DOM node.
raw docstring

changeclj/s

(change field value)

Change the value of the field, tracking that history.

Change the `value` of the `field`, tracking that history.
sourceraw docstring

discard-historyclj/s

(discard-history field)

Discard all history established by the tracker about the field.

Discard all history established by the tracker about the `field`.
sourceraw docstring

discard-interaction-historyclj/s

(discard-interaction-history field)

Discard history established by the tracker about the field's focus state.

Discard history established by the tracker about the `field`'s focus state.
sourceraw docstring

discard-value-historyclj/s

(discard-value-history field)

Discard history established by the tracker about the field's value.

Discard history established by the tracker about the `field`'s value.
sourceraw docstring

gain-focusclj/s

(gain-focus field)

Track that the field has gained focus.

Track that the `field` has gained focus.
sourceraw docstring

initclj/s

(init path)
(init path value)
(init path value tracker)

Initialize the field, at the given path, with the provided value (default nil), and configured to track changes with the tracker (default tracker/default-tracker).

Initialize the field, at the given `path`, with the provided `value` (default
`nil`), and configured to track changes with the `tracker` (default
`tracker/default-tracker`).
sourceraw docstring

lose-focusclj/s

(lose-focus field)

Track that the field has lost focus.

Track that the `field` has lost focus.
sourceraw docstring

resetclj/s

(reset field)

Abandon all changes to a field, including any accumulated history established by its tracker.

Abandon all changes to a `field`, including any accumulated history
established by its tracker.
sourceraw docstring

reset-valueclj/s

(reset-value field)

Revert the field's :field/value "backward" to the :field/initial-value. This is a relative of snapshot-value which advances the field's value forward. Should usually be combined with discard-value-history and/or discard-history. For the later you can use reset.

Revert the field's `:field/value` "backward" to the `:field/initial-value`.
This is a relative of [[snapshot-value]] which advances the field's value
forward. Should usually be combined with [[discard-value-history]] and/or
[[discard-history]]. For the later you can use [[reset]].
sourceraw docstring

snapshotclj/sdeprecated

(snapshot field)

DEPRECATED: Prefer snapshot-value combined with one of the discard-*-history helpers.

Snapshot the field's value with snapshot-value and reset its value history with discard-value-history.

This may be useful to record that a field has been saved externally, e.g. to indicate that it has been synchronized with a backend server.

Unlike reset, snapshot does not discard history about the field's focus state.

DEPRECATED: Prefer [[snapshot-value]] combined with one of the `discard-*-history`
helpers.

Snapshot the field's value with [[snapshot-value]] and reset its value
history with [[discard-value-history]].

This may be useful to record that a field has been saved externally, e.g. to
indicate that it has been synchronized with a backend server.

Unlike [[reset]], `snapshot` does not discard history about the field's focus
state.
sourceraw docstring

snapshot-valueclj/s

(snapshot-value field)

Advance the field's :field/initial-value "forward" to the current :field/value. This is a relative of reset-value which reverts the field's value backward. From this moment onwards, the field will be :field/pristine? when it matches the the current :field/value. Thus, it should usually be combined with discard-value-history or discard-history.

Advance the field's `:field/initial-value` "forward" to the current
`:field/value`. This is a relative of [[reset-value]] which reverts the
field's value backward. From this moment onwards, the field will be
`:field/pristine?` when it matches the the current `:field/value`. Thus, it
should usually be combined with [[discard-value-history]] or
[[discard-history]].
sourceraw docstring

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

× close