std.dom
dom-apply
multimethod
added in 3.0
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
added in 3.0
(dom-assert props keys)dom-attach
added in 3.0
(dom-attach dom handler)attaches a handler to a dom node
(-> (dom-attach (dom-create :mock/label) (fn dom event event)) :handler) => fn?
dom-children
added in 3.0
(dom-children {:keys [tag props], :as dom})dom-compile
added in 3.0
(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”]
dom-create
added in 3.0
(dom-create tag)(dom-create tag props)(dom-create tag props children)creates an dom
(dom-create :mock/pane {} “hello”) ;; :- :label “hello” => dom?
dom-detach
added in 3.0
(dom-detach dom)detaches a handler from a dom node
(-> (dom-attach (dom-create :mock/label) (fn dom event event)) (dom-detach) :handler) => nil
dom-diff
added in 3.0
(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]]]]
dom-equal?
added in 3.0
(dom-equal? obj-a obj-b)dom-find
added in 3.0
(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”}
dom-find-all
added in 3.0
(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”}]
dom-init
added in 3.0
(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
dom-item
added in 3.0
(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
dom-item?
added in 3.0
(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
dom-match?
added in 3.0
(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
dom-metaclass
added in 3.0
(dom-metaclass dom)returns the associated metaclass
(dom-metaclass (dom-new :mock/label {})) => :mock/element
dom-metaprops
added in 3.0
(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})
dom-metatype
added in 3.0
(dom-metatype dom)returns the associated metatype
(dom-metatype (dom-new :mock/label {})) => :dom/element
dom-ops
multimethod
added in 3.0
converts a set of props into operations
(dom-ops :mock/pane {:a 1} {:b 2}) => [:set :b 2 nil :delete :a 1]
dom-remove
multimethod
added in 3.0
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”
dom-render
multimethod
added in 3.0
enables rendering of dom ui
(-> (base/dom-create :mock/pane {} “hello”) (dom-render) (base/dom-format)) => :+ :mock/pane “hello”
dom-rendered
added in 3.0
(dom-rendered form)renders the dom and returns the actual element
(dom-rendered :mock/pane) => mock/mock?
dom-replace
multimethod
added in 3.0
dom-set-local
added in 3.0
(dom-set-local dom {:keys [id new key cursor transform mute], :as m})function for setting local dom
dom-set-state
added in 3.0
(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”}
dom-split-props
added in 3.0
(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”}]
dom-state-handler
added in 3.0
(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}
dom-top
added in 3.0
(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-
dom-trigger
added in 3.0
(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}
dom-update
added in 3.0
(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}]
dom-vector?
added in 3.0
(dom-vector? obj)checks if a vector can be a dom representation
(dom-vector? :fx/label "") => true
(dom-vector? ^:data :fx/label "") => false
dom?
added in 3.0
(dom? obj)checks if object is an dom
(dom? (dom-create :mock/label {} “hello”)) => true
event-handler
added in 3.0
(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
handle-event
added in 3.0
(handle-event dom params item listener data)handles an event given all necessary inputs
item-access
added in 3.0
(item-access tag item k)accesses the actual value of the object
(item-access :test/cat (item-create :test/cat {:name “fluffy”}) :name) => “fluffy”
item-cleanup
multimethod
added in 3.0
provides an extensible interface for itement cleanup
(item-cleanup :mock/pane (item-create :mock/pane)) => mock/mock?
item-constructor
multimethod
added in 3.0
returns the given constructor for the tag
(item-constructor :test/date) => fn?
item-create
added in 3.0
(item-create tag)(item-create tag props)generic constructor for creating dom items
(item-create :test/date) => java.util.Date
item-getters
multimethod
added in 3.0
returns the getters for the given tag
(item-getters :test/cat) => (contains-in {:name {:type java.lang.String, :fn fn?}})
item-props-delete
multimethod
added in 3.0
provides an extensible interface for delete item prop calls
(item-props-delete :test/cat (item-create :test/cat {:name “hello”}) {:name “hello”}) => test.Cat
item-props-set
multimethod
added in 3.0
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})))
item-setters
multimethod
added in 3.0
returns the setters for the given tag
(item-setters :test/cat) => (contains-in {:name {:type java.lang.String, :fn fn?}})
item-update
added in 3.0
(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}
local
added in 3.0
(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
local-parent-state
added in 3.0
(local-parent-state dom)returns the local dom parent state
metaclass
added in 3.0
(metaclass)(metaclass id)returns info associated with given metaclass
(metaclass-add :test {:metatype :value :data “hello”})
(metaclass :test) => {:id :test :metatype :value :data “hello”}
metaclass-add
added in 3.0
(metaclass-add id m)adds metaclass information
(metaclass-add :test {:metatype :value})
metaclass-remove
added in 3.0
(metaclass-remove id)removes metaclass information
(metaclass-remove :test)
metaprops
added in 3.0
(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}
metaprops-add
added in 3.0
(metaprops-add id m)adds metaprops information
(metaprops-add :test {:tag :test/node})
metaprops-install
added in 3.0
(metaprops-install m)adds metaclass information
(metaprops-install {:test/a {:tag :test/a :metaclass :dom/value :metatype :dom/value}})
metaprops-remove
added in 3.0
(metaprops-remove tag)removes metaprops information
(metaprops-remove :test/node)
react
added in 3.0
(react ref)(react ref path & more)call to react, for use within component
(binding react (volatile! #{}) (react (atom {:data 1}) :data)) => 1