Utility to create specialized input fields via parsing of the native value.
Utility to create specialized input fields via parsing of the native value.
(input-parsed)
(input-parsed attrs)
A core/input
element that parses the user input into a different type of value.
An attribute :parse
must be set to a function that takes the
native value of the input and parses it into something else, or it
may throw a parse-error
if that is not possible.
An attribute :unparse
must be set to a function to reverse the
parsing, and it must return a default empty value (usually an empty
string) for the input when called with nil
.
Note that the state of the returned item is always set to the parse result (unless parsing throws), but the native value of input remains unchanged until the input 'blurs' (loses focus). Only then the native value is set to the result of the unparse function. This allows the user to have an irregular intermediate value while editing, e.g. replacing the "2" in an integer input that shows "200".
The optional :restrict
attribute can be set to a function that
restricts the possible native value of the input while the user
edits it. It is called with a previous value and a new value upon a
change made by the user, and must return the actual new native
value for the input.
A [[core/input]] element that parses the user input into a different type of value. An attribute `:parse` must be set to a function that takes the native value of the input and parses it into something else, or it may throw a [[parse-error]] if that is not possible. An attribute `:unparse` must be set to a function to reverse the parsing, and it must return a default empty value (usually an empty string) for the input when called with `nil`. Note that the state of the returned item is always set to the parse result (unless parsing throws), but the native value of input remains unchanged until the input 'blurs' (loses focus). Only then the native value is set to the result of the unparse function. This allows the user to have an irregular intermediate value while editing, e.g. replacing the "2" in an integer input that shows "200". The optional `:restrict` attribute can be set to a function that restricts the possible native value of the input while the user edits it. It is called with a previous value and a new value upon a change made by the user, and must return the actual new native value for the input.
(parse-error msg & [value])
Returns the error to be thrown on parse errors.
Returns the error to be thrown on parse errors.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close