mirror of
https://github.com/status-im/pluto.git
synced 2026-09-01 21:11:14 +00:00
771 lines
29 KiB
JavaScript
771 lines
29 KiB
JavaScript
// Compiled by ClojureScript 1.10.439 {:static-fns true, :optimize-constants true}
|
||
goog.provide('reagent.core');
|
||
goog.require('cljs.core');
|
||
goog.require('cljs.core.constants');
|
||
goog.require('reagent.impl.template');
|
||
goog.require('reagent.impl.component');
|
||
goog.require('reagent.impl.util');
|
||
goog.require('reagent.impl.batching');
|
||
goog.require('reagent.ratom');
|
||
goog.require('reagent.debug');
|
||
goog.require('reagent.interop');
|
||
goog.require('reagent.dom');
|
||
reagent.core.global$module$react = goog.global["React"];
|
||
reagent.core.is_client = reagent.impl.util.is_client;
|
||
/**
|
||
* Create a native React element, by calling React.createElement directly.
|
||
*
|
||
* That means the second argument must be a javascript object (or nil), and
|
||
* that any Reagent hiccup forms must be processed with as-element. For example
|
||
* like this:
|
||
*
|
||
* (r/create-element "div" #js{:className "foo"}
|
||
* "Hi " (r/as-element [:strong "world!"])
|
||
*
|
||
* which is equivalent to
|
||
*
|
||
* [:div.foo "Hi" [:strong "world!"]]
|
||
*/
|
||
reagent.core.create_element = (function reagent$core$create_element(var_args){
|
||
var G__3935 = arguments.length;
|
||
switch (G__3935) {
|
||
case 1:
|
||
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||
|
||
break;
|
||
case 2:
|
||
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||
|
||
break;
|
||
case 3:
|
||
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||
|
||
break;
|
||
default:
|
||
var args_arr__4662__auto__ = [];
|
||
var len__4641__auto___3937 = arguments.length;
|
||
var i__4642__auto___3938 = (0);
|
||
while(true){
|
||
if((i__4642__auto___3938 < len__4641__auto___3937)){
|
||
args_arr__4662__auto__.push((arguments[i__4642__auto___3938]));
|
||
|
||
var G__3939 = (i__4642__auto___3938 + (1));
|
||
i__4642__auto___3938 = G__3939;
|
||
continue;
|
||
} else {
|
||
}
|
||
break;
|
||
}
|
||
|
||
var argseq__4663__auto__ = (new cljs.core.IndexedSeq(args_arr__4662__auto__.slice((3)),(0),null));
|
||
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),argseq__4663__auto__);
|
||
|
||
}
|
||
});
|
||
|
||
reagent.core.create_element.cljs$core$IFn$_invoke$arity$1 = (function (type){
|
||
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$2(type,null);
|
||
});
|
||
|
||
reagent.core.create_element.cljs$core$IFn$_invoke$arity$2 = (function (type,props){
|
||
if((!(cljs.core.map_QMARK_(props)))){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a JS object, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([props], 0)))].join('')),"\n","(clojure.core/not (clojure.core/map? props))"].join('')));
|
||
}
|
||
|
||
return (reagent.core.global$module$react.createElement.cljs$core$IFn$_invoke$arity$2 ? reagent.core.global$module$react.createElement.cljs$core$IFn$_invoke$arity$2(type,props) : reagent.core.global$module$react.createElement.call(null,type,props));
|
||
});
|
||
|
||
reagent.core.create_element.cljs$core$IFn$_invoke$arity$3 = (function (type,props,child){
|
||
if((!(cljs.core.map_QMARK_(props)))){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a JS object, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([props], 0)))].join('')),"\n","(clojure.core/not (clojure.core/map? props))"].join('')));
|
||
}
|
||
|
||
return (reagent.core.global$module$react.createElement.cljs$core$IFn$_invoke$arity$3 ? reagent.core.global$module$react.createElement.cljs$core$IFn$_invoke$arity$3(type,props,child) : reagent.core.global$module$react.createElement.call(null,type,props,child));
|
||
});
|
||
|
||
reagent.core.create_element.cljs$core$IFn$_invoke$arity$variadic = (function (type,props,child,children){
|
||
if((!(cljs.core.map_QMARK_(props)))){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a JS object, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([props], 0)))].join('')),"\n","(clojure.core/not (clojure.core/map? props))"].join('')));
|
||
}
|
||
|
||
return cljs.core.apply.cljs$core$IFn$_invoke$arity$5(reagent.core.global$module$react.createElement,type,props,child,children);
|
||
});
|
||
|
||
/** @this {Function} */
|
||
reagent.core.create_element.cljs$lang$applyTo = (function (seq3931){
|
||
var G__3932 = cljs.core.first(seq3931);
|
||
var seq3931__$1 = cljs.core.next(seq3931);
|
||
var G__3933 = cljs.core.first(seq3931__$1);
|
||
var seq3931__$2 = cljs.core.next(seq3931__$1);
|
||
var G__3934 = cljs.core.first(seq3931__$2);
|
||
var seq3931__$3 = cljs.core.next(seq3931__$2);
|
||
var self__4628__auto__ = this;
|
||
return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__3932,G__3933,G__3934,seq3931__$3);
|
||
});
|
||
|
||
reagent.core.create_element.cljs$lang$maxFixedArity = (3);
|
||
|
||
/**
|
||
* Turns a vector of Hiccup syntax into a React element. Returns form
|
||
* unchanged if it is not a vector.
|
||
*/
|
||
reagent.core.as_element = (function reagent$core$as_element(form){
|
||
return reagent.impl.template.as_element(form);
|
||
});
|
||
/**
|
||
* Returns an adapter for a native React class, that may be used
|
||
* just like a Reagent component function or class in Hiccup forms.
|
||
*/
|
||
reagent.core.adapt_react_class = (function reagent$core$adapt_react_class(c){
|
||
if(cljs.core.truth_(c)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Component"," must not be nil"].join('')),"\n","c"].join('')));
|
||
}
|
||
|
||
return reagent.impl.template.adapt_react_class(c);
|
||
});
|
||
/**
|
||
* Returns an adapter for a Reagent component, that may be used from
|
||
* React, for example in JSX. A single argument, props, is passed to
|
||
* the component, converted to a map.
|
||
*/
|
||
reagent.core.reactify_component = (function reagent$core$reactify_component(c){
|
||
if(cljs.core.truth_(c)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Component"," must not be nil"].join('')),"\n","c"].join('')));
|
||
}
|
||
|
||
return reagent.impl.component.reactify_component(c);
|
||
});
|
||
/**
|
||
* Render a Reagent component into the DOM. The first argument may be
|
||
* either a vector (using Reagent's Hiccup syntax), or a React element.
|
||
* The second argument should be a DOM node.
|
||
*
|
||
* Optionally takes a callback that is called when the component is in place.
|
||
*
|
||
* Returns the mounted component instance.
|
||
*/
|
||
reagent.core.render = (function reagent$core$render(var_args){
|
||
var G__3941 = arguments.length;
|
||
switch (G__3941) {
|
||
case 2:
|
||
return reagent.core.render.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||
|
||
break;
|
||
case 3:
|
||
return reagent.core.render.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||
|
||
break;
|
||
default:
|
||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||
|
||
}
|
||
});
|
||
|
||
reagent.core.render.cljs$core$IFn$_invoke$arity$2 = (function (comp,container){
|
||
return reagent.dom.render.cljs$core$IFn$_invoke$arity$2(comp,container);
|
||
});
|
||
|
||
reagent.core.render.cljs$core$IFn$_invoke$arity$3 = (function (comp,container,callback){
|
||
return reagent.dom.render.cljs$core$IFn$_invoke$arity$3(comp,container,callback);
|
||
});
|
||
|
||
reagent.core.render.cljs$lang$maxFixedArity = 3;
|
||
|
||
/**
|
||
* Remove a component from the given DOM node.
|
||
*/
|
||
reagent.core.unmount_component_at_node = (function reagent$core$unmount_component_at_node(container){
|
||
return reagent.dom.unmount_component_at_node(container);
|
||
});
|
||
reagent.core.as_component = reagent.core.as_element;
|
||
reagent.core.render_component = reagent.core.render;
|
||
/**
|
||
* Force re-rendering of all mounted Reagent components. This is
|
||
* probably only useful in a development environment, when you want to
|
||
* update components in response to some dynamic changes to code.
|
||
*
|
||
* Note that force-update-all may not update root components. This
|
||
* happens if a component 'foo' is mounted with `(render [foo])` (since
|
||
* functions are passed by value, and not by reference, in
|
||
* ClojureScript). To get around this you'll have to introduce a layer
|
||
* of indirection, for example by using `(render [#'foo])` instead.
|
||
*/
|
||
reagent.core.force_update_all = (function reagent$core$force_update_all(){
|
||
reagent.ratom.flush_BANG_();
|
||
|
||
reagent.dom.force_update_all();
|
||
|
||
return reagent.impl.batching.flush_after_render();
|
||
});
|
||
goog.exportSymbol('reagent.core.force_update_all', reagent.core.force_update_all);
|
||
/**
|
||
* Create a component, React style. Should be called with a map,
|
||
* looking like this:
|
||
*
|
||
* {:get-initial-state (fn [this])
|
||
* :component-will-receive-props (fn [this new-argv])
|
||
* :should-component-update (fn [this old-argv new-argv])
|
||
* :component-will-mount (fn [this])
|
||
* :component-did-mount (fn [this])
|
||
* :component-will-update (fn [this new-argv])
|
||
* :component-did-update (fn [this old-argv])
|
||
* :component-will-unmount (fn [this])
|
||
* :reagent-render (fn [args....])} ;; or :render (fn [this])
|
||
*
|
||
* Everything is optional, except either :reagent-render or :render.
|
||
*/
|
||
reagent.core.create_class = (function reagent$core$create_class(spec){
|
||
return reagent.impl.component.create_class(spec);
|
||
});
|
||
/**
|
||
* Returns the current React component (a.k.a this) in a component
|
||
* function.
|
||
*/
|
||
reagent.core.current_component = (function reagent$core$current_component(){
|
||
return reagent.impl.component._STAR_current_component_STAR_;
|
||
});
|
||
/**
|
||
* Returns an atom containing a components state.
|
||
*/
|
||
reagent.core.state_atom = (function reagent$core$state_atom(this$){
|
||
if(reagent.impl.component.reagent_component_QMARK_(this$)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([this$], 0)))].join('')),"\n","(comp/reagent-component? this)"].join('')));
|
||
}
|
||
|
||
return reagent.impl.component.state_atom(this$);
|
||
});
|
||
/**
|
||
* Returns the state of a component, as set with replace-state or set-state.
|
||
* Equivalent to (deref (r/state-atom this))
|
||
*/
|
||
reagent.core.state = (function reagent$core$state(this$){
|
||
if(reagent.impl.component.reagent_component_QMARK_(this$)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([this$], 0)))].join('')),"\n","(comp/reagent-component? this)"].join('')));
|
||
}
|
||
|
||
return cljs.core.deref(reagent.core.state_atom(this$));
|
||
});
|
||
/**
|
||
* Set state of a component.
|
||
* Equivalent to (reset! (state-atom this) new-state)
|
||
*/
|
||
reagent.core.replace_state = (function reagent$core$replace_state(this$,new_state){
|
||
if(reagent.impl.component.reagent_component_QMARK_(this$)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([this$], 0)))].join('')),"\n","(comp/reagent-component? this)"].join('')));
|
||
}
|
||
|
||
if((((new_state == null)) || (cljs.core.map_QMARK_(new_state)))){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a valid new state, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new_state], 0)))].join('')),"\n","(clojure.core/or (clojure.core/nil? new-state) (clojure.core/map? new-state))"].join('')));
|
||
}
|
||
|
||
return cljs.core.reset_BANG_(reagent.core.state_atom(this$),new_state);
|
||
});
|
||
/**
|
||
* Merge component state with new-state.
|
||
* Equivalent to (swap! (state-atom this) merge new-state)
|
||
*/
|
||
reagent.core.set_state = (function reagent$core$set_state(this$,new_state){
|
||
if(reagent.impl.component.reagent_component_QMARK_(this$)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([this$], 0)))].join('')),"\n","(comp/reagent-component? this)"].join('')));
|
||
}
|
||
|
||
if((((new_state == null)) || (cljs.core.map_QMARK_(new_state)))){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a valid new state, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new_state], 0)))].join('')),"\n","(clojure.core/or (clojure.core/nil? new-state) (clojure.core/map? new-state))"].join('')));
|
||
}
|
||
|
||
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(reagent.core.state_atom(this$),cljs.core.merge,new_state);
|
||
});
|
||
/**
|
||
* Force a component to re-render immediately.
|
||
*
|
||
* If the second argument is true, child components will also be
|
||
* re-rendered, even is their arguments have not changed.
|
||
*/
|
||
reagent.core.force_update = (function reagent$core$force_update(var_args){
|
||
var G__3944 = arguments.length;
|
||
switch (G__3944) {
|
||
case 1:
|
||
return reagent.core.force_update.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||
|
||
break;
|
||
case 2:
|
||
return reagent.core.force_update.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||
|
||
break;
|
||
default:
|
||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||
|
||
}
|
||
});
|
||
|
||
reagent.core.force_update.cljs$core$IFn$_invoke$arity$1 = (function (this$){
|
||
return reagent.core.force_update.cljs$core$IFn$_invoke$arity$2(this$,false);
|
||
});
|
||
|
||
reagent.core.force_update.cljs$core$IFn$_invoke$arity$2 = (function (this$,deep){
|
||
reagent.ratom.flush_BANG_();
|
||
|
||
reagent.impl.util.force_update(this$,deep);
|
||
|
||
return reagent.impl.batching.flush_after_render();
|
||
});
|
||
|
||
reagent.core.force_update.cljs$lang$maxFixedArity = 2;
|
||
|
||
/**
|
||
* Returns the props passed to a component.
|
||
*/
|
||
reagent.core.props = (function reagent$core$props(this$){
|
||
if(reagent.impl.component.reagent_component_QMARK_(this$)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([this$], 0)))].join('')),"\n","(comp/reagent-component? this)"].join('')));
|
||
}
|
||
|
||
return reagent.impl.component.get_props(this$);
|
||
});
|
||
/**
|
||
* Returns the children passed to a component.
|
||
*/
|
||
reagent.core.children = (function reagent$core$children(this$){
|
||
if(reagent.impl.component.reagent_component_QMARK_(this$)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([this$], 0)))].join('')),"\n","(comp/reagent-component? this)"].join('')));
|
||
}
|
||
|
||
return reagent.impl.component.get_children(this$);
|
||
});
|
||
/**
|
||
* Returns the entire Hiccup form passed to the component.
|
||
*/
|
||
reagent.core.argv = (function reagent$core$argv(this$){
|
||
if(reagent.impl.component.reagent_component_QMARK_(this$)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([this$], 0)))].join('')),"\n","(comp/reagent-component? this)"].join('')));
|
||
}
|
||
|
||
return reagent.impl.component.get_argv(this$);
|
||
});
|
||
/**
|
||
* Returns the root DOM node of a mounted component.
|
||
*/
|
||
reagent.core.dom_node = (function reagent$core$dom_node(this$){
|
||
return reagent.dom.dom_node(this$);
|
||
});
|
||
/**
|
||
* Utility function that merges two maps, handling :class and :style
|
||
* specially, like React's transferPropsTo.
|
||
*/
|
||
reagent.core.merge_props = (function reagent$core$merge_props(defaults,props){
|
||
return reagent.impl.util.merge_props(defaults,props);
|
||
});
|
||
/**
|
||
* Render dirty components immediately to the DOM.
|
||
*
|
||
* Note that this may not work in event handlers, since React.js does
|
||
* batching of updates there.
|
||
*/
|
||
reagent.core.flush = (function reagent$core$flush(){
|
||
return reagent.impl.batching.flush();
|
||
});
|
||
/**
|
||
* Like clojure.core/atom, except that it keeps track of derefs.
|
||
* Reagent components that derefs one of these are automatically
|
||
* re-rendered.
|
||
*/
|
||
reagent.core.atom = (function reagent$core$atom(var_args){
|
||
var G__3949 = arguments.length;
|
||
switch (G__3949) {
|
||
case 1:
|
||
return reagent.core.atom.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||
|
||
break;
|
||
default:
|
||
var args_arr__4662__auto__ = [];
|
||
var len__4641__auto___3951 = arguments.length;
|
||
var i__4642__auto___3952 = (0);
|
||
while(true){
|
||
if((i__4642__auto___3952 < len__4641__auto___3951)){
|
||
args_arr__4662__auto__.push((arguments[i__4642__auto___3952]));
|
||
|
||
var G__3953 = (i__4642__auto___3952 + (1));
|
||
i__4642__auto___3952 = G__3953;
|
||
continue;
|
||
} else {
|
||
}
|
||
break;
|
||
}
|
||
|
||
var argseq__4663__auto__ = (new cljs.core.IndexedSeq(args_arr__4662__auto__.slice((1)),(0),null));
|
||
return reagent.core.atom.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4663__auto__);
|
||
|
||
}
|
||
});
|
||
|
||
reagent.core.atom.cljs$core$IFn$_invoke$arity$1 = (function (x){
|
||
return reagent.ratom.atom.cljs$core$IFn$_invoke$arity$1(x);
|
||
});
|
||
|
||
reagent.core.atom.cljs$core$IFn$_invoke$arity$variadic = (function (x,rest){
|
||
return cljs.core.apply.cljs$core$IFn$_invoke$arity$3(reagent.ratom.atom,x,rest);
|
||
});
|
||
|
||
/** @this {Function} */
|
||
reagent.core.atom.cljs$lang$applyTo = (function (seq3947){
|
||
var G__3948 = cljs.core.first(seq3947);
|
||
var seq3947__$1 = cljs.core.next(seq3947);
|
||
var self__4628__auto__ = this;
|
||
return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__3948,seq3947__$1);
|
||
});
|
||
|
||
reagent.core.atom.cljs$lang$maxFixedArity = (1);
|
||
|
||
/**
|
||
* Takes a function and optional arguments, and returns a derefable
|
||
* containing the output of that function. If the function derefs
|
||
* Reagent atoms (or track, etc), the value will be updated whenever
|
||
* the atom changes.
|
||
*
|
||
* In other words, @(track foo bar) will produce the same result
|
||
* as (foo bar), but foo will only be called again when the atoms it
|
||
* depends on changes, and will only trigger updates of components when
|
||
* its result changes.
|
||
*
|
||
* track is lazy, i.e the function is only evaluated on deref.
|
||
*/
|
||
reagent.core.track = (function reagent$core$track(var_args){
|
||
var args__4647__auto__ = [];
|
||
var len__4641__auto___3956 = arguments.length;
|
||
var i__4642__auto___3957 = (0);
|
||
while(true){
|
||
if((i__4642__auto___3957 < len__4641__auto___3956)){
|
||
args__4647__auto__.push((arguments[i__4642__auto___3957]));
|
||
|
||
var G__3958 = (i__4642__auto___3957 + (1));
|
||
i__4642__auto___3957 = G__3958;
|
||
continue;
|
||
} else {
|
||
}
|
||
break;
|
||
}
|
||
|
||
var argseq__4648__auto__ = ((((1) < args__4647__auto__.length))?(new cljs.core.IndexedSeq(args__4647__auto__.slice((1)),(0),null)):null);
|
||
return reagent.core.track.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4648__auto__);
|
||
});
|
||
|
||
reagent.core.track.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
|
||
if(cljs.core.ifn_QMARK_(f)){
|
||
} else {
|
||
throw (new Error("Assert failed: (ifn? f)"));
|
||
}
|
||
|
||
return reagent.ratom.make_track(f,args);
|
||
});
|
||
|
||
reagent.core.track.cljs$lang$maxFixedArity = (1);
|
||
|
||
/** @this {Function} */
|
||
reagent.core.track.cljs$lang$applyTo = (function (seq3954){
|
||
var G__3955 = cljs.core.first(seq3954);
|
||
var seq3954__$1 = cljs.core.next(seq3954);
|
||
var self__4628__auto__ = this;
|
||
return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__3955,seq3954__$1);
|
||
});
|
||
|
||
/**
|
||
* An eager version of track. The function passed is called
|
||
* immediately, and continues to be called when needed, until stopped
|
||
* with dispose!.
|
||
*/
|
||
reagent.core.track_BANG_ = (function reagent$core$track_BANG_(var_args){
|
||
var args__4647__auto__ = [];
|
||
var len__4641__auto___3961 = arguments.length;
|
||
var i__4642__auto___3962 = (0);
|
||
while(true){
|
||
if((i__4642__auto___3962 < len__4641__auto___3961)){
|
||
args__4647__auto__.push((arguments[i__4642__auto___3962]));
|
||
|
||
var G__3963 = (i__4642__auto___3962 + (1));
|
||
i__4642__auto___3962 = G__3963;
|
||
continue;
|
||
} else {
|
||
}
|
||
break;
|
||
}
|
||
|
||
var argseq__4648__auto__ = ((((1) < args__4647__auto__.length))?(new cljs.core.IndexedSeq(args__4647__auto__.slice((1)),(0),null)):null);
|
||
return reagent.core.track_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4648__auto__);
|
||
});
|
||
|
||
reagent.core.track_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
|
||
if(cljs.core.ifn_QMARK_(f)){
|
||
} else {
|
||
throw (new Error("Assert failed: (ifn? f)"));
|
||
}
|
||
|
||
return reagent.ratom.make_track_BANG_(f,args);
|
||
});
|
||
|
||
reagent.core.track_BANG_.cljs$lang$maxFixedArity = (1);
|
||
|
||
/** @this {Function} */
|
||
reagent.core.track_BANG_.cljs$lang$applyTo = (function (seq3959){
|
||
var G__3960 = cljs.core.first(seq3959);
|
||
var seq3959__$1 = cljs.core.next(seq3959);
|
||
var self__4628__auto__ = this;
|
||
return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__3960,seq3959__$1);
|
||
});
|
||
|
||
/**
|
||
* Stop the result of track! from updating.
|
||
*/
|
||
reagent.core.dispose_BANG_ = (function reagent$core$dispose_BANG_(x){
|
||
return reagent.ratom.dispose_BANG_(x);
|
||
});
|
||
/**
|
||
* Provide a combination of value and callback, that looks like an atom.
|
||
*
|
||
* The first argument can be any value, that will be returned when the
|
||
* result is deref'ed.
|
||
*
|
||
* The second argument should be a function, that is called with the
|
||
* optional extra arguments provided to wrap, and the new value of the
|
||
* resulting 'atom'.
|
||
*
|
||
* Use for example like this:
|
||
*
|
||
* (wrap (:foo @state)
|
||
* swap! state assoc :foo)
|
||
*
|
||
* Probably useful only for passing to child components.
|
||
*/
|
||
reagent.core.wrap = (function reagent$core$wrap(var_args){
|
||
var args__4647__auto__ = [];
|
||
var len__4641__auto___3967 = arguments.length;
|
||
var i__4642__auto___3968 = (0);
|
||
while(true){
|
||
if((i__4642__auto___3968 < len__4641__auto___3967)){
|
||
args__4647__auto__.push((arguments[i__4642__auto___3968]));
|
||
|
||
var G__3969 = (i__4642__auto___3968 + (1));
|
||
i__4642__auto___3968 = G__3969;
|
||
continue;
|
||
} else {
|
||
}
|
||
break;
|
||
}
|
||
|
||
var argseq__4648__auto__ = ((((2) < args__4647__auto__.length))?(new cljs.core.IndexedSeq(args__4647__auto__.slice((2)),(0),null)):null);
|
||
return reagent.core.wrap.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4648__auto__);
|
||
});
|
||
|
||
reagent.core.wrap.cljs$core$IFn$_invoke$arity$variadic = (function (value,reset_fn,args){
|
||
if(cljs.core.ifn_QMARK_(reset_fn)){
|
||
} else {
|
||
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected something callable, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([reset_fn], 0)))].join('')),"\n","(clojure.core/ifn? reset-fn)"].join('')));
|
||
}
|
||
|
||
return reagent.ratom.make_wrapper(value,reset_fn,args);
|
||
});
|
||
|
||
reagent.core.wrap.cljs$lang$maxFixedArity = (2);
|
||
|
||
/** @this {Function} */
|
||
reagent.core.wrap.cljs$lang$applyTo = (function (seq3964){
|
||
var G__3965 = cljs.core.first(seq3964);
|
||
var seq3964__$1 = cljs.core.next(seq3964);
|
||
var G__3966 = cljs.core.first(seq3964__$1);
|
||
var seq3964__$2 = cljs.core.next(seq3964__$1);
|
||
var self__4628__auto__ = this;
|
||
return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__3965,G__3966,seq3964__$2);
|
||
});
|
||
|
||
/**
|
||
* Provide a cursor into a Reagent atom.
|
||
*
|
||
* Behaves like a Reagent atom but focuses updates and derefs to
|
||
* the specified path within the wrapped Reagent atom. e.g.,
|
||
* (let [c (cursor ra [:nested :content])]
|
||
* ... @c ;; equivalent to (get-in @ra [:nested :content])
|
||
* ... (reset! c 42) ;; equivalent to (swap! ra assoc-in [:nested :content] 42)
|
||
* ... (swap! c inc) ;; equivalence to (swap! ra update-in [:nested :content] inc)
|
||
* )
|
||
*
|
||
* The first parameter can also be a function, that should look
|
||
* something like this:
|
||
*
|
||
* (defn set-get
|
||
* ([k] (get-in @state k))
|
||
* ([k v] (swap! state assoc-in k v)))
|
||
*
|
||
* The function will be called with one argument – the path passed to
|
||
* cursor – when the cursor is deref'ed, and two arguments (path and
|
||
* new value) when the cursor is modified.
|
||
*
|
||
* Given that set-get function, (and that state is a Reagent atom, or
|
||
* another cursor) these cursors are equivalent:
|
||
* (cursor state [:foo]) and (cursor set-get [:foo]).
|
||
*
|
||
* Note that a cursor is lazy: its value will not change until it is
|
||
* used. This may be noticed with add-watch.
|
||
*/
|
||
reagent.core.cursor = (function reagent$core$cursor(src,path){
|
||
return reagent.ratom.cursor(src,path);
|
||
});
|
||
/**
|
||
* Swaps the value of a to be (apply f current-value-of-atom args).
|
||
*
|
||
* rswap! works like swap!, except that recursive calls to rswap! on
|
||
* the same atom are allowed – and it always returns nil.
|
||
*/
|
||
reagent.core.rswap_BANG_ = (function reagent$core$rswap_BANG_(var_args){
|
||
var args__4647__auto__ = [];
|
||
var len__4641__auto___3976 = arguments.length;
|
||
var i__4642__auto___3977 = (0);
|
||
while(true){
|
||
if((i__4642__auto___3977 < len__4641__auto___3976)){
|
||
args__4647__auto__.push((arguments[i__4642__auto___3977]));
|
||
|
||
var G__3978 = (i__4642__auto___3977 + (1));
|
||
i__4642__auto___3977 = G__3978;
|
||
continue;
|
||
} else {
|
||
}
|
||
break;
|
||
}
|
||
|
||
var argseq__4648__auto__ = ((((2) < args__4647__auto__.length))?(new cljs.core.IndexedSeq(args__4647__auto__.slice((2)),(0),null)):null);
|
||
return reagent.core.rswap_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4648__auto__);
|
||
});
|
||
|
||
reagent.core.rswap_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (a,f,args){
|
||
if((((!((a == null))))?(((((a.cljs$lang$protocol_mask$partition1$ & (16384))) || ((cljs.core.PROTOCOL_SENTINEL === a.cljs$core$IAtom$))))?true:(((!a.cljs$lang$protocol_mask$partition1$))?cljs.core.native_satisfies_QMARK_(cljs.core.IAtom,a):false)):cljs.core.native_satisfies_QMARK_(cljs.core.IAtom,a))){
|
||
} else {
|
||
throw (new Error("Assert failed: (satisfies? IAtom a)"));
|
||
}
|
||
|
||
if(cljs.core.ifn_QMARK_(f)){
|
||
} else {
|
||
throw (new Error("Assert failed: (ifn? f)"));
|
||
}
|
||
|
||
if(cljs.core.truth_(a.rswapping)){
|
||
(function (){var or__4047__auto__ = a.rswapfs;
|
||
if(cljs.core.truth_(or__4047__auto__)){
|
||
return or__4047__auto__;
|
||
} else {
|
||
return a.rswapfs = [];
|
||
}
|
||
})().push((function (p1__3970_SHARP_){
|
||
return cljs.core.apply.cljs$core$IFn$_invoke$arity$3(f,p1__3970_SHARP_,args);
|
||
}));
|
||
} else {
|
||
a.rswapping = true;
|
||
|
||
try{cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(a,(function (state){
|
||
var s = cljs.core.apply.cljs$core$IFn$_invoke$arity$3(f,state,args);
|
||
while(true){
|
||
var temp__5459__auto__ = (function (){var G__3975 = a.rswapfs;
|
||
if((G__3975 == null)){
|
||
return null;
|
||
} else {
|
||
return G__3975.shift();
|
||
}
|
||
})();
|
||
if((temp__5459__auto__ == null)){
|
||
return s;
|
||
} else {
|
||
var sf = temp__5459__auto__;
|
||
var G__3979 = (sf.cljs$core$IFn$_invoke$arity$1 ? sf.cljs$core$IFn$_invoke$arity$1(s) : sf.call(null,s));
|
||
s = G__3979;
|
||
continue;
|
||
}
|
||
break;
|
||
}
|
||
}));
|
||
}finally {a.rswapping = false;
|
||
}}
|
||
|
||
return null;
|
||
});
|
||
|
||
reagent.core.rswap_BANG_.cljs$lang$maxFixedArity = (2);
|
||
|
||
/** @this {Function} */
|
||
reagent.core.rswap_BANG_.cljs$lang$applyTo = (function (seq3971){
|
||
var G__3972 = cljs.core.first(seq3971);
|
||
var seq3971__$1 = cljs.core.next(seq3971);
|
||
var G__3973 = cljs.core.first(seq3971__$1);
|
||
var seq3971__$2 = cljs.core.next(seq3971__$1);
|
||
var self__4628__auto__ = this;
|
||
return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__3972,G__3973,seq3971__$2);
|
||
});
|
||
|
||
/**
|
||
* Run f using requestAnimationFrame or equivalent.
|
||
*
|
||
* f will be called just before components are rendered.
|
||
*/
|
||
reagent.core.next_tick = (function reagent$core$next_tick(f){
|
||
return reagent.impl.batching.do_before_flush(f);
|
||
});
|
||
/**
|
||
* Run f using requestAnimationFrame or equivalent.
|
||
*
|
||
* f will be called just after any queued renders in the next animation
|
||
* frame (and even if no renders actually occur).
|
||
*/
|
||
reagent.core.after_render = (function reagent$core$after_render(f){
|
||
return reagent.impl.batching.do_after_render(f);
|
||
});
|
||
/**
|
||
* Works just like clojure.core/partial, but the result can be compared with =
|
||
*/
|
||
reagent.core.partial = (function reagent$core$partial(var_args){
|
||
var args__4647__auto__ = [];
|
||
var len__4641__auto___3982 = arguments.length;
|
||
var i__4642__auto___3983 = (0);
|
||
while(true){
|
||
if((i__4642__auto___3983 < len__4641__auto___3982)){
|
||
args__4647__auto__.push((arguments[i__4642__auto___3983]));
|
||
|
||
var G__3984 = (i__4642__auto___3983 + (1));
|
||
i__4642__auto___3983 = G__3984;
|
||
continue;
|
||
} else {
|
||
}
|
||
break;
|
||
}
|
||
|
||
var argseq__4648__auto__ = ((((1) < args__4647__auto__.length))?(new cljs.core.IndexedSeq(args__4647__auto__.slice((1)),(0),null)):null);
|
||
return reagent.core.partial.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4648__auto__);
|
||
});
|
||
|
||
reagent.core.partial.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
|
||
return reagent.impl.util.make_partial_fn(f,args);
|
||
});
|
||
|
||
reagent.core.partial.cljs$lang$maxFixedArity = (1);
|
||
|
||
/** @this {Function} */
|
||
reagent.core.partial.cljs$lang$applyTo = (function (seq3980){
|
||
var G__3981 = cljs.core.first(seq3980);
|
||
var seq3980__$1 = cljs.core.next(seq3980);
|
||
var self__4628__auto__ = this;
|
||
return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__3981,seq3980__$1);
|
||
});
|
||
|
||
reagent.core.component_path = (function reagent$core$component_path(c){
|
||
return reagent.impl.component.component_path(c);
|
||
});
|