(defcomp tag doc? attr? & [bindings & body])defines a component
defines a component
applies operations to the dom (-> (base/dom-create :mock/pane {:a 1}) (impl/dom-render) (dom-apply [[:set :b 2 nil] [:delete :a 1]]) (base/dom-item) :props) => {:b 2}
applies operations to the dom
(-> (base/dom-create :mock/pane {:a 1})
(impl/dom-render)
(dom-apply [[:set :b 2 nil]
[:delete :a 1]])
(base/dom-item)
:props)
=> {:b 2}(dom-assert props keys)asserts that the props are valid (dom-assert {:a 1 :b 2} [:a])
(dom-assert {:a 1 :b 2} [:c]) => (throws)
asserts that the props are valid
(dom-assert {:a 1 :b 2} [:a])
(dom-assert {:a 1 :b 2} [:c])
=> (throws)(dom-attach dom handler)attaches a handler to a dom node
(-> (dom-attach (dom-create :mock/label) (fn [dom event] event)) :handler) => fn?
attaches a handler to a dom node
(-> (dom-attach (dom-create :mock/label)
(fn [dom event] event))
:handler)
=> fn?(dom-children {:keys [tag props] :as dom})retrieves children of dom object
(dom-children (dom-create :mock/pane {} ["hello"])) => {:key :children :children ["hello"]}
retrieves children of dom object
(dom-children (dom-create :mock/pane {} ["hello"]))
=> {:key :children
:children ["hello"]}(dom-compile form)(dom-compile [tag props? & children :as form] create-fn)compiles a tree structure into a dom
(-> (dom-compile [:mock/pane "hello"]) dom-format) => [:- :mock/pane "hello"]
(-> (dom-compile [:mock/pane [:mock/label "hello"] [:mock/label "world"]]) dom-format) => [:- :mock/pane [:- :mock/label "hello"] [:- :mock/label "world"]]
compiles a tree structure into a dom
(-> (dom-compile [:mock/pane "hello"])
dom-format)
=> [:- :mock/pane "hello"]
(-> (dom-compile [:mock/pane
[:mock/label "hello"]
[:mock/label "world"]])
dom-format)
=> [:- :mock/pane [:- :mock/label "hello"] [:- :mock/label "world"]](dom-create tag)(dom-create tag props)(dom-create tag props children)creates an dom
(dom-create :mock/pane {} ["hello"]) ;; [:- :label "hello"] => dom?
creates an dom
(dom-create :mock/pane {} ["hello"])
;; [:- :label "hello"]
=> dom?(dom-detach dom)detaches a handler from a dom node
(-> (dom-attach (dom-create :mock/label) (fn [dom event] event)) (dom-detach) :handler) => nil
detaches a handler from a dom node
(-> (dom-attach (dom-create :mock/label)
(fn [dom event] event))
(dom-detach)
:handler)
=> nil(dom-diff old new)returns ops for dom transform
(dom-diff (base/dom-create :mock/pane {:hello 1} [:a :b :c]) (base/dom-create :mock/pane {:hello 2} [:a :B :c])) => [[:set :hello 2 1] [:update :children [[:list-remove 1 1] [:list-insert 1 [:B]]]]]
returns ops for dom transform
(dom-diff (base/dom-create :mock/pane {:hello 1} [:a :b :c])
(base/dom-create :mock/pane {:hello 2} [:a :B :c]))
=> [[:set :hello 2 1]
[:update :children [[:list-remove 1 1]
[:list-insert 1 [:B]]]]](dom-equal? obj-a obj-b)checks if two dom elements are equal
(dom-equal? (dom-create :mock/label {} ["hello"]) (dom-create :mock/label {} ["hello"])) => true
checks if two dom elements are equal
(dom-equal? (dom-create :mock/label {} ["hello"])
(dom-create :mock/label {} ["hello"]))
=> true(dom-find dom key match)find dom element
(-> (dom/dom-compile [:mock/pane {:children [[:mock/pane {:tag "A"}] [:mock/pane {:tag "B"}]]}]) (dom-find :tag identity) str read-string) => [:- :mock/pane {:tag "A"}]
find dom element
(-> (dom/dom-compile [:mock/pane {:children [[:mock/pane {:tag "A"}]
[:mock/pane {:tag "B"}]]}])
(dom-find :tag identity)
str read-string)
=> [:- :mock/pane {:tag "A"}](dom-find-all dom key match)(dom-find-all dom key match state)finds all matching dom elements
(-> (dom/dom-compile [:mock/pane {:children [[:mock/pane {:tag "A"}] [:mock/pane {:tag "B"}]]}]) (dom-find-all :tag string?) str read-string) => [[:- :mock/pane {:tag "A"}] [:- :mock/pane {:tag "B"}]]
finds all matching dom elements
(-> (dom/dom-compile [:mock/pane {:children [[:mock/pane {:tag "A"}]
[:mock/pane {:tag "B"}]]}])
(dom-find-all :tag string?)
str read-string)
=> [[:- :mock/pane {:tag "A"}] [:- :mock/pane {:tag "B"}]](dom-init obj)renders the dom element if input is dom and not rendered
(dom-init 1) => 1
(base/dom-format (dom-init (base/dom-create :mock/pane))) => [:+ :mock/pane]
renders the dom element if input is dom and not rendered (dom-init 1) => 1 (base/dom-format (dom-init (base/dom-create :mock/pane))) => [:+ :mock/pane]
(dom-item dom)returns itement associated with the dom
(-> (dom-new :mock/label {:a 1}) (impl/dom-render) (dom-item)) => mock/mock?
(-> (dom-new :mock/label) (dom-item)) => nil
returns itement associated with the dom
(-> (dom-new :mock/label {:a 1})
(impl/dom-render)
(dom-item))
=> mock/mock?
(-> (dom-new :mock/label)
(dom-item))
=> nil(dom-item? dom)returns whether dom has associated itement
(dom-item? (dom-new :mock/pane)) => false
(-> (dom-new :mock/pane) impl/dom-render dom-item?) => true
returns whether dom has associated itement
(dom-item? (dom-new :mock/pane))
=> false
(-> (dom-new :mock/pane)
impl/dom-render
dom-item?)
=> true(dom-match? dom key match)tests dom to match on either function or value
(dom-match? (dom/dom-compile [:mock/pane {:hello "world"}]) :hello string?) => true
tests dom to match on either function or value
(dom-match? (dom/dom-compile [:mock/pane {:hello "world"}])
:hello
string?)
=> true(dom-metaclass dom)returns the associated metaclass
(dom-metaclass (dom-new :mock/label {})) => :mock/element
returns the associated metaclass
(dom-metaclass (dom-new :mock/label {}))
=> :mock/element(dom-metaprops dom)checks dom for ui type
(dom-metaprops (dom-new :mock/label {})) => (contains {:tag :mock/label :construct fn? :children {:key :text :single true} :metaclass :mock/element :metatype :dom/element})
checks dom for ui type
(dom-metaprops (dom-new :mock/label {}))
=> (contains {:tag :mock/label
:construct fn?
:children {:key :text :single true}
:metaclass :mock/element
:metatype :dom/element})(dom-metatype dom)returns the associated metatype
(dom-metatype (dom-new :mock/label {})) => :dom/element
returns the associated metatype
(dom-metatype (dom-new :mock/label {}))
=> :dom/elementconverts a set of props into operations
(dom-ops :mock/pane {:a 1} {:b 2}) => [[:set :b 2 nil] [:delete :a 1]]
converts a set of props into operations
(dom-ops :mock/pane
{:a 1}
{:b 2})
=> [[:set :b 2 nil]
[:delete :a 1]]provides an extensible interface removing rendered elem from dom
(-> (base/dom-create :mock/pane {} ["hello"]) (dom-render) (dom-remove) (base/dom-format)) => [:- :mock/pane "hello"]
provides an extensible interface removing rendered elem from dom
(-> (base/dom-create :mock/pane {} ["hello"])
(dom-render)
(dom-remove)
(base/dom-format))
=> [:- :mock/pane "hello"]enables rendering of dom ui
(-> (base/dom-create :mock/pane {} ["hello"]) (dom-render) (base/dom-format)) => [:+ :mock/pane "hello"]
enables rendering of dom ui
(-> (base/dom-create :mock/pane {} ["hello"])
(dom-render)
(base/dom-format))
=> [:+ :mock/pane "hello"](dom-rendered form)renders the dom and returns the actual element
(dom-rendered [:mock/pane]) => mock/mock?
renders the dom and returns the actual element (dom-rendered [:mock/pane]) => mock/mock?
replaces one dom element with another
(-> (base/dom-create :mock/pane {} ["hello"]) (dom-render) (dom-replace (base/dom-create :mock/pane {} ["world"])) (base/dom-item) :props) => {:children ["world"]}
replaces one dom element with another
(-> (base/dom-create :mock/pane {} ["hello"])
(dom-render)
(dom-replace (base/dom-create :mock/pane {} ["world"]))
(base/dom-item)
:props)
=> {:children ["world"]}(dom-send-local dom)sends events that are in :local/events
sends events that are in :local/events
(dom-set-local dom {:keys [id new key cursor transform mute] :as m})function for setting local dom
function for setting local dom
(dom-set-state {:keys [state key cursor new transform mute]
:or {transform identity}})sets a state given function params
(def -state- (atom {}))
(do (dom-set-state {:state -state- :key :hello :new 1 :transform str}) @-state-) => {:hello "1"}
sets a state given function params
(def -state- (atom {}))
(do (dom-set-state {:state -state-
:key :hello
:new 1
:transform str})
@-state-)
=> {:hello "1"}(dom-split-props props)(dom-split-props props lookup select)splits :on namespace keywords
(dom-split-props {:on/item :event/item :item "hello"}) => [{:on/item :event/item} {:item "hello"}]
splits :on namespace keywords
(dom-split-props {:on/item :event/item
:item "hello"})
=> [{:on/item :event/item} {:item "hello"}](dom-state-handler
_
{:keys [cursor state new transform] :as event :or {transform identity}})updates the state with given value
(dom-state-handler nil {:state (atom {}) :cursor [:data] :new "hello" :transform keyword}) => {:data :hello}
updates the state with given value
(dom-state-handler nil {:state (atom {})
:cursor [:data]
:new "hello"
:transform keyword})
=> {:data :hello}(dom-top dom)returns the top-most dom element
(def -a- (dom-create :mock/label)) (def -b- (dom-create :mock/pane {} [(dom-create :mock/pane {} [-a-])]))
(dom-top -a-) => -b-
returns the top-most dom element
(def -a- (dom-create :mock/label))
(def -b- (dom-create :mock/pane {} [(dom-create :mock/pane {} [-a-])]))
(dom-top -a-) => -b-(dom-trigger {:keys [parent handler] :as dom} event)triggers an event, propogating up the dom hierarchy
(def -p- (promise))
(-> (dom-create :mock/label) (dom-attach (fn [dom event] (deliver -p- event) nil)) (dom-trigger {:a 1 :b 2}))
@-p- => {:a 1, :b 2}
triggers an event, propogating up the dom hierarchy
(def -p- (promise))
(-> (dom-create :mock/label)
(dom-attach (fn [dom event] (deliver -p- event) nil))
(dom-trigger {:a 1 :b 2}))
@-p- => {:a 1, :b 2}(dom-update dom new-dom)updates current dom given new dom
(-> (doto (base/dom-compile [:mock/pane {:a 1} [:mock/pane {:b 2}] [:mock/pane {:c 3}]]) (impl/dom-render) (dom-update (base/dom-compile [:mock/pane {:a 1} [:mock/pane {:b 2}] [:mock/pane {:c 4}]]))) (base/dom-item) str read-string) => [:mock/pane {:a 1} [:mock/pane {:b 2}] [:mock/pane {:c 4}]]
updates current dom given new dom
(-> (doto (base/dom-compile [:mock/pane {:a 1}
[:mock/pane {:b 2}]
[:mock/pane {:c 3}]])
(impl/dom-render)
(dom-update (base/dom-compile [:mock/pane {:a 1}
[:mock/pane {:b 2}]
[:mock/pane {:c 4}]])))
(base/dom-item)
str read-string)
=> [:mock/pane {:a 1} [:mock/pane {:b 2}] [:mock/pane {:c 4}]](dom-vector? obj)checks if a vector can be a dom representation
(dom-vector? [:fx/label ""]) => true
(dom-vector? ^:data [:fx/label ""]) => false
checks if a vector can be a dom representation (dom-vector? [:fx/label ""]) => true (dom-vector? ^:data [:fx/label ""]) => false
(dom? obj)checks if object is an dom
(dom? (dom-create :mock/label {} ["hello"])) => true
checks if object is an dom
(dom? (dom-create :mock/label {} ["hello"]))
=> true(event-handler dom)finds the relevant handler by ancestry
(def -parent- (doto (dom/dom-create :mock/pane) (dom/dom-attach :parent-handler)))
(def -child- (doto (dom/dom-create :mock/pane) (mut/mutable:set :parent -parent-)))
(event-handler -child-) => :parent-handler
finds the relevant handler by ancestry
(def -parent- (doto (dom/dom-create :mock/pane)
(dom/dom-attach :parent-handler)))
(def -child- (doto (dom/dom-create :mock/pane)
(mut/mutable:set :parent -parent-)))
(event-handler -child-)
=> :parent-handler(handle-event dom params item listener data)handles an event given all necessary inputs
handles an event given all necessary inputs
(item-access tag item k)accesses the actual value of the object
(item-access :test/cat (item-create :test/cat {:name "fluffy"}) :name) => "fluffy"
accesses the actual value of the object
(item-access :test/cat
(item-create :test/cat {:name "fluffy"})
:name)
=> "fluffy"provides an extensible interface for itement cleanup
(item-cleanup :mock/pane (item-create :mock/pane)) => mock/mock?
provides an extensible interface for itement cleanup (item-cleanup :mock/pane (item-create :mock/pane)) => mock/mock?
returns the given constructor for the tag
(item-constructor :test/date) => fn?
returns the given constructor for the tag (item-constructor :test/date) => fn?
(item-create tag)(item-create tag props)generic constructor for creating dom items
(item-create :test/date) => java.util.Date
generic constructor for creating dom items (item-create :test/date) => java.util.Date
returns the getters for the given tag
(item-getters :test/cat) => (contains-in {:name {:type java.lang.String, :fn fn?}})
returns the getters for the given tag
(item-getters :test/cat)
=> (contains-in {:name {:type java.lang.String, :fn fn?}})provides an extensible interface for delete item prop calls
(item-props-delete :test/cat (item-create :test/cat {:name "hello"}) {:name "hello"}) => test.Cat
provides an extensible interface for delete item prop calls
(item-props-delete :test/cat
(item-create :test/cat {:name "hello"})
{:name "hello"})
=> test.Catprovides an extensible interface for set item prop calls
(.getName ^test.Cat (item-props-set :test/cat (item-create :test/cat) {:name "spike"})) => "spike"
(doto (item-create :mock/pane) (#(item-props-set :mock/pane % {:a 1 :b 2})))
provides an extensible interface for set item prop calls
(.getName ^test.Cat
(item-props-set :test/cat
(item-create :test/cat)
{:name "spike"}))
=> "spike"
(doto (item-create :mock/pane)
(#(item-props-set :mock/pane % {:a 1 :b 2})))returns the setters for the given tag
(item-setters :test/cat) => (contains-in {:name {:type java.lang.String, :fn fn?}})
returns the setters for the given tag
(item-setters :test/cat)
=> (contains-in {:name {:type java.lang.String, :fn fn?}})(item-update tag item ops)updates item given transform operations
(-> (item-update :mock/pane (item-create :mock/pane {:a 1}) [[:delete :a 1] [:set :b 2]]) :props) => {:b 2}
updates item given transform operations
(-> (item-update :mock/pane
(item-create :mock/pane {:a 1})
[[:delete :a 1]
[:set :b 2]])
:props)
=> {:b 2}(local key)(local dom key)accesses current local state
(binding [base/local-dom (doto (base/dom-create :mock/label) (mut/mutable:set :cache {:local/state (atom {:hello 1})})) react/react (volatile! #{})] (local :hello)) => 1
accesses current local state
(binding [base/*local-dom* (doto (base/dom-create :mock/label)
(mut/mutable:set :cache {:local/state (atom {:hello 1})}))
react/*react* (volatile! #{})]
(local :hello))
=> 1(local-dom-state dom)returns the local dom state
returns the local dom state
(local-parent dom)returns the local dom parent
returns the local dom parent
(local-parent-state dom)returns the local dom parent state
returns the local dom parent state
(metaclass)(metaclass id)returns info associated with given metaclass
(metaclass-add :test {:metatype :value :data "hello"})
(metaclass :test) => {:id :test :metatype :value :data "hello"}
returns info associated with given metaclass
(metaclass-add :test {:metatype :value :data "hello"})
(metaclass :test)
=> {:id :test :metatype :value :data "hello"}(metaclass-add id m)adds metaclass information
(metaclass-add :test {:metatype :value})
adds metaclass information
(metaclass-add :test {:metatype :value})(metaclass-remove id)removes metaclass information
(metaclass-remove :test)
removes metaclass information (metaclass-remove :test)
(metaprops)(metaprops tag)returns metaprops info associated with the node
(metaprops-add :test {:tag :test/node})
(metaprops :test/node) => {:tag :test/node, :metaclass :test, :metatype :value}
returns metaprops info associated with the node
(metaprops-add :test {:tag :test/node})
(metaprops :test/node)
=> {:tag :test/node,
:metaclass :test,
:metatype :value}(metaprops-add id m)adds metaprops information
(metaprops-add :test {:tag :test/node})
adds metaprops information
(metaprops-add :test {:tag :test/node})(metaprops-install m)adds metaclass information
(metaprops-install {:test/a {:tag :test/a :metaclass :dom/value :metatype :dom/value}})
adds metaclass information
(metaprops-install {:test/a {:tag :test/a
:metaclass :dom/value
:metatype :dom/value}})(metaprops-remove tag)removes metaprops information
(metaprops-remove :test/node)
removes metaprops information (metaprops-remove :test/node)
(react ref)(react ref path & more)call to react, for use within component
(binding [react (volatile! #{})] (react (atom {:data 1}) [:data])) => 1
call to react, for use within component
(binding [*react* (volatile! #{})]
(react (atom {:data 1}) [:data]))
=> 1cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |