mirror of
https://github.com/status-im/pluto.git
synced 2026-08-31 12:31:08 +00:00
737 lines
30 KiB
JavaScript
737 lines
30 KiB
JavaScript
// Compiled by ClojureScript 1.10.439 {:static-fns true, :optimize-constants true}
|
|
goog.provide('reagent.impl.template');
|
|
goog.require('cljs.core');
|
|
goog.require('cljs.core.constants');
|
|
goog.require('clojure.string');
|
|
goog.require('clojure.walk');
|
|
goog.require('reagent.impl.util');
|
|
goog.require('reagent.impl.component');
|
|
goog.require('reagent.impl.batching');
|
|
goog.require('reagent.ratom');
|
|
goog.require('reagent.interop');
|
|
goog.require('reagent.debug');
|
|
reagent.impl.template.global$module$react = goog.global["React"];
|
|
/**
|
|
* Regular expression that parses a CSS-style id and class
|
|
* from a tag name.
|
|
*/
|
|
reagent.impl.template.re_tag = /([^\s\.#]+)(?:#([^\s\.#]+))?(?:\.([^\s#]+))?/;
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
reagent.impl.template.NativeWrapper = (function (){
|
|
});
|
|
|
|
reagent.impl.template.NativeWrapper.getBasis = (function (){
|
|
return cljs.core.PersistentVector.EMPTY;
|
|
});
|
|
|
|
reagent.impl.template.NativeWrapper.cljs$lang$type = true;
|
|
|
|
reagent.impl.template.NativeWrapper.cljs$lang$ctorStr = "reagent.impl.template/NativeWrapper";
|
|
|
|
reagent.impl.template.NativeWrapper.cljs$lang$ctorPrWriter = (function (this__4290__auto__,writer__4291__auto__,opt__4292__auto__){
|
|
return cljs.core._write(writer__4291__auto__,"reagent.impl.template/NativeWrapper");
|
|
});
|
|
|
|
/**
|
|
* Positional factory function for reagent.impl.template/NativeWrapper.
|
|
*/
|
|
reagent.impl.template.__GT_NativeWrapper = (function reagent$impl$template$__GT_NativeWrapper(){
|
|
return (new reagent.impl.template.NativeWrapper());
|
|
});
|
|
|
|
reagent.impl.template.named_QMARK_ = (function reagent$impl$template$named_QMARK_(x){
|
|
return (((x instanceof cljs.core.Keyword)) || ((x instanceof cljs.core.Symbol)));
|
|
});
|
|
reagent.impl.template.hiccup_tag_QMARK_ = (function reagent$impl$template$hiccup_tag_QMARK_(x){
|
|
return ((reagent.impl.template.named_QMARK_(x)) || (typeof x === 'string'));
|
|
});
|
|
reagent.impl.template.valid_tag_QMARK_ = (function reagent$impl$template$valid_tag_QMARK_(x){
|
|
return ((reagent.impl.template.hiccup_tag_QMARK_(x)) || (cljs.core.ifn_QMARK_(x)) || ((x instanceof reagent.impl.template.NativeWrapper)));
|
|
});
|
|
reagent.impl.template.prop_name_cache = ({"class": "className", "for": "htmlFor", "charset": "charSet"});
|
|
reagent.impl.template.cache_get = (function reagent$impl$template$cache_get(o,k){
|
|
if(o.hasOwnProperty(k)){
|
|
return (o[k]);
|
|
} else {
|
|
return null;
|
|
}
|
|
});
|
|
reagent.impl.template.cached_prop_name = (function reagent$impl$template$cached_prop_name(k){
|
|
if(reagent.impl.template.named_QMARK_(k)){
|
|
var temp__5459__auto__ = reagent.impl.template.cache_get(reagent.impl.template.prop_name_cache,cljs.core.name(k));
|
|
if((temp__5459__auto__ == null)){
|
|
return (reagent.impl.template.prop_name_cache[cljs.core.name(k)] = reagent.impl.util.dash_to_camel(k));
|
|
} else {
|
|
var k_SINGLEQUOTE_ = temp__5459__auto__;
|
|
return k_SINGLEQUOTE_;
|
|
}
|
|
} else {
|
|
return k;
|
|
}
|
|
});
|
|
reagent.impl.template.js_val_QMARK_ = (function reagent$impl$template$js_val_QMARK_(x){
|
|
return (!(("object" === goog.typeOf(x))));
|
|
});
|
|
reagent.impl.template.kv_conv = (function reagent$impl$template$kv_conv(o,k,v){
|
|
var G__3820 = o;
|
|
(G__3820[reagent.impl.template.cached_prop_name(k)] = (reagent.impl.template.convert_prop_value.cljs$core$IFn$_invoke$arity$1 ? reagent.impl.template.convert_prop_value.cljs$core$IFn$_invoke$arity$1(v) : reagent.impl.template.convert_prop_value.call(null,v)));
|
|
|
|
return G__3820;
|
|
});
|
|
reagent.impl.template.convert_prop_value = (function reagent$impl$template$convert_prop_value(x){
|
|
if(reagent.impl.template.js_val_QMARK_(x)){
|
|
return x;
|
|
} else {
|
|
if(reagent.impl.template.named_QMARK_(x)){
|
|
return cljs.core.name(x);
|
|
} else {
|
|
if(cljs.core.map_QMARK_(x)){
|
|
return cljs.core.reduce_kv(reagent.impl.template.kv_conv,({}),x);
|
|
} else {
|
|
if(cljs.core.coll_QMARK_(x)){
|
|
return cljs.core.clj__GT_js(x);
|
|
} else {
|
|
if(cljs.core.ifn_QMARK_(x)){
|
|
return (function() {
|
|
var G__3821__delegate = function (args){
|
|
return cljs.core.apply.cljs$core$IFn$_invoke$arity$2(x,args);
|
|
};
|
|
var G__3821 = function (var_args){
|
|
var args = null;
|
|
if (arguments.length > 0) {
|
|
var G__3822__i = 0, G__3822__a = new Array(arguments.length - 0);
|
|
while (G__3822__i < G__3822__a.length) {G__3822__a[G__3822__i] = arguments[G__3822__i + 0]; ++G__3822__i;}
|
|
args = new cljs.core.IndexedSeq(G__3822__a,0,null);
|
|
}
|
|
return G__3821__delegate.call(this,args);};
|
|
G__3821.cljs$lang$maxFixedArity = 0;
|
|
G__3821.cljs$lang$applyTo = (function (arglist__3823){
|
|
var args = cljs.core.seq(arglist__3823);
|
|
return G__3821__delegate(args);
|
|
});
|
|
G__3821.cljs$core$IFn$_invoke$arity$variadic = G__3821__delegate;
|
|
return G__3821;
|
|
})()
|
|
;
|
|
} else {
|
|
return cljs.core.clj__GT_js(x);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
reagent.impl.template.custom_prop_name_cache = ({});
|
|
reagent.impl.template.cached_custom_prop_name = (function reagent$impl$template$cached_custom_prop_name(k){
|
|
if(reagent.impl.template.named_QMARK_(k)){
|
|
var temp__5459__auto__ = reagent.impl.template.cache_get(reagent.impl.template.custom_prop_name_cache,cljs.core.name(k));
|
|
if((temp__5459__auto__ == null)){
|
|
return (reagent.impl.template.custom_prop_name_cache[cljs.core.name(k)] = reagent.impl.util.dash_to_camel(k));
|
|
} else {
|
|
var k_SINGLEQUOTE_ = temp__5459__auto__;
|
|
return k_SINGLEQUOTE_;
|
|
}
|
|
} else {
|
|
return k;
|
|
}
|
|
});
|
|
reagent.impl.template.custom_kv_conv = (function reagent$impl$template$custom_kv_conv(o,k,v){
|
|
var G__3824 = o;
|
|
(G__3824[reagent.impl.template.cached_custom_prop_name(k)] = reagent.impl.template.convert_prop_value(v));
|
|
|
|
return G__3824;
|
|
});
|
|
reagent.impl.template.convert_custom_prop_value = (function reagent$impl$template$convert_custom_prop_value(x){
|
|
if(reagent.impl.template.js_val_QMARK_(x)){
|
|
return x;
|
|
} else {
|
|
if(reagent.impl.template.named_QMARK_(x)){
|
|
return cljs.core.name(x);
|
|
} else {
|
|
if(cljs.core.map_QMARK_(x)){
|
|
return cljs.core.reduce_kv(reagent.impl.template.custom_kv_conv,({}),x);
|
|
} else {
|
|
if(cljs.core.coll_QMARK_(x)){
|
|
return cljs.core.clj__GT_js(x);
|
|
} else {
|
|
if(cljs.core.ifn_QMARK_(x)){
|
|
return (function() {
|
|
var G__3825__delegate = function (args){
|
|
return cljs.core.apply.cljs$core$IFn$_invoke$arity$2(x,args);
|
|
};
|
|
var G__3825 = function (var_args){
|
|
var args = null;
|
|
if (arguments.length > 0) {
|
|
var G__3826__i = 0, G__3826__a = new Array(arguments.length - 0);
|
|
while (G__3826__i < G__3826__a.length) {G__3826__a[G__3826__i] = arguments[G__3826__i + 0]; ++G__3826__i;}
|
|
args = new cljs.core.IndexedSeq(G__3826__a,0,null);
|
|
}
|
|
return G__3825__delegate.call(this,args);};
|
|
G__3825.cljs$lang$maxFixedArity = 0;
|
|
G__3825.cljs$lang$applyTo = (function (arglist__3827){
|
|
var args = cljs.core.seq(arglist__3827);
|
|
return G__3825__delegate(args);
|
|
});
|
|
G__3825.cljs$core$IFn$_invoke$arity$variadic = G__3825__delegate;
|
|
return G__3825;
|
|
})()
|
|
;
|
|
} else {
|
|
return cljs.core.clj__GT_js(x);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
reagent.impl.template.oset = (function reagent$impl$template$oset(o,k,v){
|
|
var G__3828 = (((o == null))?({}):o);
|
|
(G__3828[k] = v);
|
|
|
|
return G__3828;
|
|
});
|
|
reagent.impl.template.oget = (function reagent$impl$template$oget(o,k){
|
|
if((o == null)){
|
|
return null;
|
|
} else {
|
|
return (o[k]);
|
|
}
|
|
});
|
|
/**
|
|
* Takes the id and class from tag keyword, and adds them to the
|
|
* other props. Parsed tag is JS object with :id and :class properties.
|
|
*/
|
|
reagent.impl.template.set_id_class = (function reagent$impl$template$set_id_class(props,id_class){
|
|
var id = (id_class["id"]);
|
|
var class$ = (id_class["class"]);
|
|
var G__3829 = props;
|
|
var G__3829__$1 = (((((!((id == null)))) && ((cljs.core.cst$kw$id.cljs$core$IFn$_invoke$arity$1(props) == null))))?cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__3829,cljs.core.cst$kw$id,id):G__3829);
|
|
if(cljs.core.truth_(class$)){
|
|
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__3829__$1,cljs.core.cst$kw$class,(function (){var old_class = cljs.core.cst$kw$class.cljs$core$IFn$_invoke$arity$1(props);
|
|
if((old_class == null)){
|
|
return class$;
|
|
} else {
|
|
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(class$)," ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(((reagent.impl.template.named_QMARK_(old_class))?cljs.core.name(old_class):old_class))].join('');
|
|
}
|
|
})());
|
|
} else {
|
|
return G__3829__$1;
|
|
}
|
|
});
|
|
reagent.impl.template.stringify_class = (function reagent$impl$template$stringify_class(p__3830){
|
|
var map__3831 = p__3830;
|
|
var map__3831__$1 = (((((!((map__3831 == null))))?(((((map__3831.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__3831.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__3831):map__3831);
|
|
var props = map__3831__$1;
|
|
var class$ = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__3831__$1,cljs.core.cst$kw$class);
|
|
if(cljs.core.coll_QMARK_(class$)){
|
|
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(props,cljs.core.cst$kw$class,clojure.string.join.cljs$core$IFn$_invoke$arity$2(" ",cljs.core.keep.cljs$core$IFn$_invoke$arity$2(((function (map__3831,map__3831__$1,props,class$){
|
|
return (function (c){
|
|
if(cljs.core.truth_(c)){
|
|
if(reagent.impl.template.named_QMARK_(c)){
|
|
return cljs.core.name(c);
|
|
} else {
|
|
return c;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
});})(map__3831,map__3831__$1,props,class$))
|
|
,class$)));
|
|
} else {
|
|
return props;
|
|
}
|
|
});
|
|
reagent.impl.template.convert_props = (function reagent$impl$template$convert_props(props,id_class){
|
|
var props__$1 = reagent.impl.template.set_id_class(reagent.impl.template.stringify_class(props),id_class);
|
|
if(cljs.core.truth_((id_class["custom"]))){
|
|
return reagent.impl.template.convert_custom_prop_value(props__$1);
|
|
} else {
|
|
return reagent.impl.template.convert_prop_value(props__$1);
|
|
}
|
|
});
|
|
if((typeof reagent !== 'undefined') && (typeof reagent.impl !== 'undefined') && (typeof reagent.impl.template !== 'undefined') && (typeof reagent.impl.template.find_dom_node !== 'undefined')){
|
|
} else {
|
|
reagent.impl.template.find_dom_node = null;
|
|
}
|
|
reagent.impl.template.these_inputs_have_selection_api = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 6, ["url",null,"tel",null,"text",null,"textarea",null,"password",null,"search",null], null), null);
|
|
reagent.impl.template.has_selection_api_QMARK_ = (function reagent$impl$template$has_selection_api_QMARK_(input_type){
|
|
return cljs.core.contains_QMARK_(reagent.impl.template.these_inputs_have_selection_api,input_type);
|
|
});
|
|
reagent.impl.template.input_node_set_value = (function reagent$impl$template$input_node_set_value(node,rendered_value,dom_value,component,p__3833){
|
|
var map__3834 = p__3833;
|
|
var map__3834__$1 = (((((!((map__3834 == null))))?(((((map__3834.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__3834.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__3834):map__3834);
|
|
var on_write = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__3834__$1,cljs.core.cst$kw$on_DASH_write);
|
|
if((!((((node === (document["activeElement"]))) && (reagent.impl.template.has_selection_api_QMARK_((node["type"]))) && (typeof rendered_value === 'string') && (typeof dom_value === 'string'))))){
|
|
(component["cljsDOMValue"] = rendered_value);
|
|
|
|
(node["value"] = rendered_value);
|
|
|
|
if(cljs.core.fn_QMARK_(on_write)){
|
|
return (on_write.cljs$core$IFn$_invoke$arity$1 ? on_write.cljs$core$IFn$_invoke$arity$1(rendered_value) : on_write.call(null,rendered_value));
|
|
} else {
|
|
return null;
|
|
}
|
|
} else {
|
|
var node_value = (node["value"]);
|
|
if(cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(node_value,dom_value)){
|
|
return reagent.impl.batching.do_after_render(((function (node_value,map__3834,map__3834__$1,on_write){
|
|
return (function (){
|
|
return (reagent.impl.template.input_component_set_value.cljs$core$IFn$_invoke$arity$1 ? reagent.impl.template.input_component_set_value.cljs$core$IFn$_invoke$arity$1(component) : reagent.impl.template.input_component_set_value.call(null,component));
|
|
});})(node_value,map__3834,map__3834__$1,on_write))
|
|
);
|
|
} else {
|
|
var existing_offset_from_end = (cljs.core.count(node_value) - (node["selectionStart"]));
|
|
var new_cursor_offset = (cljs.core.count(rendered_value) - existing_offset_from_end);
|
|
(component["cljsDOMValue"] = rendered_value);
|
|
|
|
(node["value"] = rendered_value);
|
|
|
|
if(cljs.core.fn_QMARK_(on_write)){
|
|
(on_write.cljs$core$IFn$_invoke$arity$1 ? on_write.cljs$core$IFn$_invoke$arity$1(rendered_value) : on_write.call(null,rendered_value));
|
|
} else {
|
|
}
|
|
|
|
(node["selectionStart"] = new_cursor_offset);
|
|
|
|
return (node["selectionEnd"] = new_cursor_offset);
|
|
}
|
|
}
|
|
});
|
|
reagent.impl.template.input_component_set_value = (function reagent$impl$template$input_component_set_value(this$){
|
|
if(cljs.core.truth_((this$["cljsInputLive"]))){
|
|
(this$["cljsInputDirty"] = false);
|
|
|
|
var rendered_value = (this$["cljsRenderedValue"]);
|
|
var dom_value = (this$["cljsDOMValue"]);
|
|
var node = (reagent.impl.template.find_dom_node.cljs$core$IFn$_invoke$arity$1 ? reagent.impl.template.find_dom_node.cljs$core$IFn$_invoke$arity$1(this$) : reagent.impl.template.find_dom_node.call(null,this$));
|
|
if(cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(rendered_value,dom_value)){
|
|
return reagent.impl.template.input_node_set_value(node,rendered_value,dom_value,this$,cljs.core.PersistentArrayMap.EMPTY);
|
|
} else {
|
|
return null;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
});
|
|
reagent.impl.template.input_handle_change = (function reagent$impl$template$input_handle_change(this$,on_change,e){
|
|
(this$["cljsDOMValue"] = e.target.value);
|
|
|
|
if(cljs.core.truth_((this$["cljsInputDirty"]))){
|
|
} else {
|
|
(this$["cljsInputDirty"] = true);
|
|
|
|
reagent.impl.batching.do_after_render((function (){
|
|
return reagent.impl.template.input_component_set_value(this$);
|
|
}));
|
|
}
|
|
|
|
return (on_change.cljs$core$IFn$_invoke$arity$1 ? on_change.cljs$core$IFn$_invoke$arity$1(e) : on_change.call(null,e));
|
|
});
|
|
reagent.impl.template.input_render_setup = (function reagent$impl$template$input_render_setup(this$,jsprops){
|
|
if(cljs.core.truth_((function (){var and__4036__auto__ = (!((jsprops == null)));
|
|
if(and__4036__auto__){
|
|
var and__4036__auto____$1 = jsprops.hasOwnProperty("onChange");
|
|
if(cljs.core.truth_(and__4036__auto____$1)){
|
|
return jsprops.hasOwnProperty("value");
|
|
} else {
|
|
return and__4036__auto____$1;
|
|
}
|
|
} else {
|
|
return and__4036__auto__;
|
|
}
|
|
})())){
|
|
if(cljs.core.truth_(reagent.impl.template.find_dom_node)){
|
|
} else {
|
|
throw (new Error(["Assert failed: ","reagent.dom needs to be loaded for controlled input to work","\n","find-dom-node"].join('')));
|
|
}
|
|
|
|
var v = (jsprops["value"]);
|
|
var value = (((v == null))?"":v);
|
|
var on_change = (jsprops["onChange"]);
|
|
if(cljs.core.truth_((this$["cljsInputLive"]))){
|
|
} else {
|
|
(this$["cljsInputLive"] = true);
|
|
|
|
(this$["cljsDOMValue"] = value);
|
|
}
|
|
|
|
(this$["cljsRenderedValue"] = value);
|
|
|
|
delete jsprops["value"];
|
|
|
|
var G__3837 = jsprops;
|
|
(G__3837["defaultValue"] = value);
|
|
|
|
(G__3837["onChange"] = ((function (G__3837,v,value,on_change){
|
|
return (function (p1__3836_SHARP_){
|
|
return reagent.impl.template.input_handle_change(this$,on_change,p1__3836_SHARP_);
|
|
});})(G__3837,v,value,on_change))
|
|
);
|
|
|
|
return G__3837;
|
|
} else {
|
|
return null;
|
|
}
|
|
});
|
|
reagent.impl.template.input_unmount = (function reagent$impl$template$input_unmount(this$){
|
|
return (this$["cljsInputLive"] = null);
|
|
});
|
|
reagent.impl.template.input_component_QMARK_ = (function reagent$impl$template$input_component_QMARK_(x){
|
|
var G__3838 = x;
|
|
switch (G__3838) {
|
|
case "input":
|
|
case "textarea":
|
|
return true;
|
|
|
|
break;
|
|
default:
|
|
return false;
|
|
|
|
}
|
|
});
|
|
reagent.impl.template.reagent_input_class = null;
|
|
reagent.impl.template.input_spec = new cljs.core.PersistentArrayMap(null, 4, [cljs.core.cst$kw$display_DASH_name,"ReagentInput",cljs.core.cst$kw$component_DASH_did_DASH_update,reagent.impl.template.input_component_set_value,cljs.core.cst$kw$component_DASH_will_DASH_unmount,reagent.impl.template.input_unmount,cljs.core.cst$kw$reagent_DASH_render,(function (argv,comp,jsprops,first_child){
|
|
var this$ = reagent.impl.component._STAR_current_component_STAR_;
|
|
reagent.impl.template.input_render_setup(this$,jsprops);
|
|
|
|
return (reagent.impl.template.make_element.cljs$core$IFn$_invoke$arity$4 ? reagent.impl.template.make_element.cljs$core$IFn$_invoke$arity$4(argv,comp,jsprops,first_child) : reagent.impl.template.make_element.call(null,argv,comp,jsprops,first_child));
|
|
})], null);
|
|
reagent.impl.template.reagent_input = (function reagent$impl$template$reagent_input(){
|
|
if((reagent.impl.template.reagent_input_class == null)){
|
|
reagent.impl.template.reagent_input_class = reagent.impl.component.create_class(reagent.impl.template.input_spec);
|
|
} else {
|
|
}
|
|
|
|
return reagent.impl.template.reagent_input_class;
|
|
});
|
|
reagent.impl.template.parse_tag = (function reagent$impl$template$parse_tag(hiccup_tag){
|
|
var vec__3840 = cljs.core.next(cljs.core.re_matches(reagent.impl.template.re_tag,cljs.core.name(hiccup_tag)));
|
|
var tag = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__3840,(0),null);
|
|
var id = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__3840,(1),null);
|
|
var class$ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__3840,(2),null);
|
|
var class$__$1 = (((class$ == null))?null:clojure.string.replace(class$,/\./," "));
|
|
if(cljs.core.truth_(tag)){
|
|
} else {
|
|
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Invalid tag: '",cljs.core.str.cljs$core$IFn$_invoke$arity$1(hiccup_tag),"'",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.component.comp_name())].join('')),"\n","tag"].join('')));
|
|
}
|
|
|
|
return ({"name": tag, "id": id, "class": class$__$1, "custom": cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2((-1),tag.indexOf("-"))});
|
|
});
|
|
reagent.impl.template.try_get_key = (function reagent$impl$template$try_get_key(x){
|
|
try{return cljs.core.get.cljs$core$IFn$_invoke$arity$2(x,cljs.core.cst$kw$key);
|
|
}catch (e3843){var e = e3843;
|
|
return null;
|
|
}});
|
|
reagent.impl.template.get_key = (function reagent$impl$template$get_key(x){
|
|
if(cljs.core.map_QMARK_(x)){
|
|
return reagent.impl.template.try_get_key(x);
|
|
} else {
|
|
return null;
|
|
}
|
|
});
|
|
reagent.impl.template.key_from_vec = (function reagent$impl$template$key_from_vec(v){
|
|
var temp__5459__auto__ = reagent.impl.template.get_key(cljs.core.meta(v));
|
|
if((temp__5459__auto__ == null)){
|
|
return reagent.impl.template.get_key(cljs.core.nth.cljs$core$IFn$_invoke$arity$3(v,(1),null));
|
|
} else {
|
|
var k = temp__5459__auto__;
|
|
return k;
|
|
}
|
|
});
|
|
reagent.impl.template.reag_element = (function reagent$impl$template$reag_element(tag,v){
|
|
var c = reagent.impl.component.as_class(tag);
|
|
var jsprops = ({"argv": v});
|
|
var temp__5461__auto___3844 = reagent.impl.template.key_from_vec(v);
|
|
if((temp__5461__auto___3844 == null)){
|
|
} else {
|
|
var key_3845 = temp__5461__auto___3844;
|
|
(jsprops["key"] = key_3845);
|
|
}
|
|
|
|
return (reagent.impl.template.global$module$react.createElement.cljs$core$IFn$_invoke$arity$2 ? reagent.impl.template.global$module$react.createElement.cljs$core$IFn$_invoke$arity$2(c,jsprops) : reagent.impl.template.global$module$react.createElement.call(null,c,jsprops));
|
|
});
|
|
reagent.impl.template.fragment_element = (function reagent$impl$template$fragment_element(argv){
|
|
var props = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(argv,(1),null);
|
|
var hasprops = (((props == null)) || (cljs.core.map_QMARK_(props)));
|
|
var jsprops = reagent.impl.template.convert_prop_value(((hasprops)?props:null));
|
|
var first_child = ((1) + ((hasprops)?(1):(0)));
|
|
var temp__5461__auto___3846 = reagent.impl.template.key_from_vec(argv);
|
|
if((temp__5461__auto___3846 == null)){
|
|
} else {
|
|
var key_3847 = temp__5461__auto___3846;
|
|
reagent.impl.template.oset(jsprops,"key",key_3847);
|
|
}
|
|
|
|
return (reagent.impl.template.make_element.cljs$core$IFn$_invoke$arity$4 ? reagent.impl.template.make_element.cljs$core$IFn$_invoke$arity$4(argv,reagent.impl.template.global$module$react.Fragment,jsprops,first_child) : reagent.impl.template.make_element.call(null,argv,reagent.impl.template.global$module$react.Fragment,jsprops,first_child));
|
|
});
|
|
reagent.impl.template.adapt_react_class = (function reagent$impl$template$adapt_react_class(c){
|
|
var G__3848 = reagent.impl.template.__GT_NativeWrapper();
|
|
(G__3848["name"] = c);
|
|
|
|
(G__3848["id"] = null);
|
|
|
|
(G__3848["class"] = null);
|
|
|
|
return G__3848;
|
|
});
|
|
reagent.impl.template.tag_name_cache = ({});
|
|
reagent.impl.template.cached_parse = (function reagent$impl$template$cached_parse(x){
|
|
var temp__5459__auto__ = reagent.impl.template.cache_get(reagent.impl.template.tag_name_cache,x);
|
|
if((temp__5459__auto__ == null)){
|
|
return (reagent.impl.template.tag_name_cache[x] = reagent.impl.template.parse_tag(x));
|
|
} else {
|
|
var s = temp__5459__auto__;
|
|
return s;
|
|
}
|
|
});
|
|
reagent.impl.template.native_element = (function reagent$impl$template$native_element(parsed,argv,first){
|
|
var comp = (parsed["name"]);
|
|
var props = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(argv,first,null);
|
|
var hasprops = (((props == null)) || (cljs.core.map_QMARK_(props)));
|
|
var jsprops = reagent.impl.template.convert_props(((hasprops)?props:null),parsed);
|
|
var first_child = (first + ((hasprops)?(1):(0)));
|
|
if(reagent.impl.template.input_component_QMARK_(comp)){
|
|
var G__3849 = cljs.core.with_meta(new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [reagent.impl.template.reagent_input(),argv,comp,jsprops,first_child], null),cljs.core.meta(argv));
|
|
return (reagent.impl.template.as_element.cljs$core$IFn$_invoke$arity$1 ? reagent.impl.template.as_element.cljs$core$IFn$_invoke$arity$1(G__3849) : reagent.impl.template.as_element.call(null,G__3849));
|
|
} else {
|
|
var key = reagent.impl.template.get_key(cljs.core.meta(argv));
|
|
var p = (((key == null))?jsprops:reagent.impl.template.oset(jsprops,"key",key));
|
|
return (reagent.impl.template.make_element.cljs$core$IFn$_invoke$arity$4 ? reagent.impl.template.make_element.cljs$core$IFn$_invoke$arity$4(argv,comp,p,first_child) : reagent.impl.template.make_element.call(null,argv,comp,p,first_child));
|
|
}
|
|
});
|
|
reagent.impl.template.str_coll = (function reagent$impl$template$str_coll(coll){
|
|
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure.walk.prewalk((function (x){
|
|
if(cljs.core.fn_QMARK_(x)){
|
|
var n = reagent.impl.util.fun_name(x);
|
|
var G__3850 = n;
|
|
switch (G__3850) {
|
|
case "":
|
|
return x;
|
|
|
|
break;
|
|
default:
|
|
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(n);
|
|
|
|
}
|
|
} else {
|
|
return x;
|
|
}
|
|
}),coll));
|
|
|
|
});
|
|
reagent.impl.template.hiccup_err = (function reagent$impl$template$hiccup_err(var_args){
|
|
var args__4647__auto__ = [];
|
|
var len__4641__auto___3854 = arguments.length;
|
|
var i__4642__auto___3855 = (0);
|
|
while(true){
|
|
if((i__4642__auto___3855 < len__4641__auto___3854)){
|
|
args__4647__auto__.push((arguments[i__4642__auto___3855]));
|
|
|
|
var G__3856 = (i__4642__auto___3855 + (1));
|
|
i__4642__auto___3855 = G__3856;
|
|
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.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4648__auto__);
|
|
});
|
|
|
|
reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic = (function (v,msg){
|
|
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,msg)),": ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.str_coll(v)),"\n",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.component.comp_name())].join('');
|
|
});
|
|
|
|
reagent.impl.template.hiccup_err.cljs$lang$maxFixedArity = (1);
|
|
|
|
/** @this {Function} */
|
|
reagent.impl.template.hiccup_err.cljs$lang$applyTo = (function (seq3852){
|
|
var G__3853 = cljs.core.first(seq3852);
|
|
var seq3852__$1 = cljs.core.next(seq3852);
|
|
var self__4628__auto__ = this;
|
|
return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__3853,seq3852__$1);
|
|
});
|
|
|
|
reagent.impl.template.vec_to_elem = (function reagent$impl$template$vec_to_elem(v){
|
|
while(true){
|
|
if((cljs.core.count(v) > (0))){
|
|
} else {
|
|
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic(v,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Hiccup form should not be empty"], 0))),"\n","(pos? (count v))"].join('')));
|
|
}
|
|
|
|
var tag = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(v,(0),null);
|
|
if(reagent.impl.template.valid_tag_QMARK_(tag)){
|
|
} else {
|
|
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic(v,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid Hiccup form"], 0))),"\n","(valid-tag? tag)"].join('')));
|
|
}
|
|
|
|
if(cljs.core.keyword_identical_QMARK_(cljs.core.cst$kw$_LT__GT_,tag)){
|
|
return reagent.impl.template.fragment_element(v);
|
|
} else {
|
|
if(reagent.impl.template.hiccup_tag_QMARK_(tag)){
|
|
var n = cljs.core.name(tag);
|
|
var pos = n.indexOf(">");
|
|
var G__3857 = pos;
|
|
switch (G__3857) {
|
|
case (-1):
|
|
return reagent.impl.template.native_element(reagent.impl.template.cached_parse(n),v,(1));
|
|
|
|
break;
|
|
case (0):
|
|
var comp = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(v,(1),null);
|
|
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(">",n)){
|
|
} else {
|
|
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic(v,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid Hiccup tag"], 0))),"\n","(= \">\" n)"].join('')));
|
|
}
|
|
|
|
return reagent.impl.template.native_element(({"name": comp}),v,(2));
|
|
|
|
break;
|
|
default:
|
|
var G__3859 = cljs.core.with_meta(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.subs.cljs$core$IFn$_invoke$arity$3(n,(0),pos),cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(cljs.core.with_meta(v,null),(0),cljs.core.subs.cljs$core$IFn$_invoke$arity$2(n,(pos + (1))))], null),cljs.core.meta(v));
|
|
v = G__3859;
|
|
continue;
|
|
|
|
}
|
|
} else {
|
|
if((tag instanceof reagent.impl.template.NativeWrapper)){
|
|
return reagent.impl.template.native_element(tag,v,(1));
|
|
} else {
|
|
return reagent.impl.template.reag_element(tag,v);
|
|
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
reagent.impl.template.as_element = (function reagent$impl$template$as_element(x){
|
|
if(reagent.impl.template.js_val_QMARK_(x)){
|
|
return x;
|
|
} else {
|
|
if(cljs.core.vector_QMARK_(x)){
|
|
return reagent.impl.template.vec_to_elem(x);
|
|
} else {
|
|
if(cljs.core.seq_QMARK_(x)){
|
|
return (reagent.impl.template.expand_seq_check.cljs$core$IFn$_invoke$arity$1 ? reagent.impl.template.expand_seq_check.cljs$core$IFn$_invoke$arity$1(x) : reagent.impl.template.expand_seq_check.call(null,x));
|
|
|
|
} else {
|
|
if(reagent.impl.template.named_QMARK_(x)){
|
|
return cljs.core.name(x);
|
|
} else {
|
|
if((((!((x == null))))?(((((x.cljs$lang$protocol_mask$partition0$ & (2147483648))) || ((cljs.core.PROTOCOL_SENTINEL === x.cljs$core$IPrintWithWriter$))))?true:(((!x.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_(cljs.core.IPrintWithWriter,x):false)):cljs.core.native_satisfies_QMARK_(cljs.core.IPrintWithWriter,x))){
|
|
return cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([x], 0));
|
|
} else {
|
|
return x;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
reagent.impl.component.as_element = reagent.impl.template.as_element;
|
|
reagent.impl.template.expand_seq = (function reagent$impl$template$expand_seq(s){
|
|
var a = cljs.core.into_array.cljs$core$IFn$_invoke$arity$1(s);
|
|
var n__4518__auto___3861 = a.length;
|
|
var i_3862 = (0);
|
|
while(true){
|
|
if((i_3862 < n__4518__auto___3861)){
|
|
(a[i_3862] = reagent.impl.template.as_element((a[i_3862])));
|
|
|
|
var G__3863 = (i_3862 + (1));
|
|
i_3862 = G__3863;
|
|
continue;
|
|
} else {
|
|
}
|
|
break;
|
|
}
|
|
|
|
return a;
|
|
});
|
|
reagent.impl.template.expand_seq_dev = (function reagent$impl$template$expand_seq_dev(s,o){
|
|
var a = cljs.core.into_array.cljs$core$IFn$_invoke$arity$1(s);
|
|
var n__4518__auto___3864 = a.length;
|
|
var i_3865 = (0);
|
|
while(true){
|
|
if((i_3865 < n__4518__auto___3864)){
|
|
var val_3866 = (a[i_3865]);
|
|
if(((cljs.core.vector_QMARK_(val_3866)) && ((reagent.impl.template.key_from_vec(val_3866) == null)))){
|
|
(o["no-key"] = true);
|
|
} else {
|
|
}
|
|
|
|
(a[i_3865] = reagent.impl.template.as_element(val_3866));
|
|
|
|
var G__3867 = (i_3865 + (1));
|
|
i_3865 = G__3867;
|
|
continue;
|
|
} else {
|
|
}
|
|
break;
|
|
}
|
|
|
|
return a;
|
|
});
|
|
reagent.impl.template.expand_seq_check = (function reagent$impl$template$expand_seq_check(x){
|
|
var ctx = ({});
|
|
var vec__3868 = reagent.ratom.check_derefs(((function (ctx){
|
|
return (function (){
|
|
return reagent.impl.template.expand_seq_dev(x,ctx);
|
|
});})(ctx))
|
|
);
|
|
var res = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__3868,(0),null);
|
|
var derefed = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__3868,(1),null);
|
|
if(cljs.core.truth_(derefed)){
|
|
if(cljs.core.truth_(reagent.debug.has_console)){
|
|
(cljs.core.truth_(reagent.debug.tracking)?reagent.debug.track_console:console).warn(["Warning: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic(x,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Reactive deref not supported in lazy seq, ","it should be wrapped in doall"], 0)))].join(''));
|
|
} else {
|
|
}
|
|
} else {
|
|
}
|
|
|
|
if(cljs.core.truth_((ctx["no-key"]))){
|
|
if(cljs.core.truth_(reagent.debug.has_console)){
|
|
(cljs.core.truth_(reagent.debug.tracking)?reagent.debug.track_console:console).warn(["Warning: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic(x,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Every element in a seq should have a unique :key"], 0)))].join(''));
|
|
} else {
|
|
}
|
|
} else {
|
|
}
|
|
|
|
return res;
|
|
});
|
|
reagent.impl.template.make_element = (function reagent$impl$template$make_element(argv,comp,jsprops,first_child){
|
|
var G__3871 = (cljs.core.count(argv) - first_child);
|
|
switch (G__3871) {
|
|
case (0):
|
|
return (reagent.impl.template.global$module$react.createElement.cljs$core$IFn$_invoke$arity$2 ? reagent.impl.template.global$module$react.createElement.cljs$core$IFn$_invoke$arity$2(comp,jsprops) : reagent.impl.template.global$module$react.createElement.call(null,comp,jsprops));
|
|
|
|
break;
|
|
case (1):
|
|
var G__3872 = comp;
|
|
var G__3873 = jsprops;
|
|
var G__3874 = reagent.impl.template.as_element(cljs.core.nth.cljs$core$IFn$_invoke$arity$3(argv,first_child,null));
|
|
return (reagent.impl.template.global$module$react.createElement.cljs$core$IFn$_invoke$arity$3 ? reagent.impl.template.global$module$react.createElement.cljs$core$IFn$_invoke$arity$3(G__3872,G__3873,G__3874) : reagent.impl.template.global$module$react.createElement.call(null,G__3872,G__3873,G__3874));
|
|
|
|
break;
|
|
default:
|
|
return reagent.impl.template.global$module$react.createElement.apply(null,cljs.core.reduce_kv(((function (G__3871){
|
|
return (function (a,k,v){
|
|
if((k >= first_child)){
|
|
a.push(reagent.impl.template.as_element(v));
|
|
} else {
|
|
}
|
|
|
|
return a;
|
|
});})(G__3871))
|
|
,[comp,jsprops],argv));
|
|
|
|
}
|
|
});
|