Input types extend over the :type
attribute
of reacl-c-basics.forms.core/input
items, giving more control
over the data types of the state value, and to some extend over the
ui controls to enter those values. The type system defined here is
also extensible.
For example, you can ask the user for an integer via
(c/isolate-state 0
(core/input {:type types/integer}))
Input types extend over the `:type` attribute of [[reacl-c-basics.forms.core/input]] items, giving more control over the data types of the state value, and to some extend over the ui controls to enter those values. The type system defined here is also extensible. For example, you can ask the user for an integer via ``` (c/isolate-state 0 (core/input {:type types/integer})) ```
(add-attributes type attrs)
Adds additional default attributes for the dom element used for the given type.
Adds additional default attributes for the dom element used for the given type.
An input for a boolean value, represented as a checkbox.
An input for a boolean value, represented as a checkbox.
(decimal decimals)
A input type for an integer, but represented and entered as (/ v (^ 10 decimals)
. E.g. 234 with 2 decimals is shown and entered as
"2.34".
A input type for an integer, but represented and entered as `(/ v (^ 10 decimals)`. E.g. 234 with 2 decimals is shown and entered as "2.34".
(enum values-labels)
An input type for one of a set of arbitrary values. The argument
values-labels
must be a a sequence of tuples [value text]
specifying the value selected and a string that represents the value
for the user.
An input type for one of a set of arbitrary values. The argument `values-labels` must be a a sequence of tuples `[value text]` specifying the value selected and a string that represents the value for the user.
(extend-type type parse unparse)
Creates an input type that can allow for more values than the given
one. The function parse
will be called with the parse function of
the given type and the string entered by the user, and the function
unparse
alike.
Creates an input type that can allow for more values than the given one. The function `parse` will be called with the parse function of the given type and the string entered by the user, and the function `unparse` alike.
(fixnum decimals)
An input type for a float, but when entered and displayed, exactly the given number of decimal places are used or shown respectively.
An input type for a float, but when entered and displayed, exactly the given number of decimal places are used or shown respectively.
An input type for a integer number.
An input type for a integer number.
An input type for a string, represented in a multiline textbox element.
An input type for a string, represented in a multiline textbox element.
(native-type type)
Creates an input type for one of the native 'types' supported by a dom/input, i.e. "text", "number", "checkbox" etc. Note that not all types are supported by all browsers.
Creates an input type for one of the native 'types' supported by a dom/input, i.e. "text", "number", "checkbox" etc. Note that not all types are supported by all browsers.
(new-type base-fn default-attrs to-optional)
Creates a new input type, given a basic dom
function (e.g. core/input), a map of default attributes (e.g. a
string value for the :type
attribute), and a function that takes
this type and returns a type that also accepts nil
as a value. The
to-optional
function may throw, if the type cannot be extended to
accept nil
.
Creates a new input type, given a basic dom function (e.g. core/input), a map of default attributes (e.g. a string value for the `:type` attribute), and a function that takes this type and returns a type that also accepts `nil` as a value. The `to-optional` function may throw, if the type cannot be extended to accept `nil`.
An input type for an optional integer
.
An input type for an optional [[integer]].
An input type for an optional, but non-empty string,
i.e. the value is never an empty string. This also trims the text
entered, so only whitespace becomed nil
as well.
An input type for an optional, but non-empty string, i.e. the value is never an empty string. This also trims the text entered, so only whitespace becomed `nil` as well.
An input type for an optional number.
An input type for an optional number.
An optional strict-integer
.
An optional [[strict-integer]].
An input type for an optional string
.
An input type for an optional [[string]].
(optional type)
Adds 'nil' as a possible value to the given input type. Note that this is may not possible for all types.
Adds 'nil' as a possible value to the given input type. Note that this is may not possible for all types.
(parsed-type base-type parse unparse)
Creates an input that requires parsing and unparsing of the native
value entered by the user (usually a
string). See parsed/input-parsed
for details on the parse and
unparse functions.
Creates an input that requires parsing and unparsing of the native value entered by the user (usually a string). See [[parsed/input-parsed]] for details on the parse and unparse functions.
(restrict-type type f)
Creates an input that allows to restrict the parsed value of the
given type further, by threading it though the given function f
,
which may throw parsed/parse-error
. Note that it can be more
intuitive for the user to set the input element attribute :invalid
in some cases.
Creates an input that allows to restrict the parsed value of the given type further, by threading it though the given function `f`, which may throw [[parsed/parse-error]]. Note that it can be more intuitive for the user to set the input element attribute `:invalid` in some cases.
An input type that requires the user to enter an integer
number. For an input type that for example just removes decimal
places, use integer
.
An input type that requires the user to enter an integer number. For an input type that for example just removes decimal places, use [[integer]].
(string-enum strings)
An input type for one of the given strings.
An input type for one of the given strings.
(update-type-base type f)
Calls f with the current base function and replaces it with the result.
Calls f with the current base function and replaces it with the result.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close