diff --git a/examples/material-ui/project.clj b/examples/material-ui/project.clj index 36a5abc..6987e3d 100644 --- a/examples/material-ui/project.clj +++ b/examples/material-ui/project.clj @@ -28,7 +28,20 @@ :output-dir "target/cljsbuild/client/public/js/out" :output-to "target/cljsbuild/client/public/js/main.js" :asset-path "js/out" - :npm-deps false}} + :npm-deps false + :infer-externs true}} + + :adv + {:source-paths ["src"] + :compiler {:parallel-build true + :source-map "target/cljsbuild/adv/public/js/main.js.map" + :optimizations :advanced + :main "example.core" + :output-dir "target/cljsbuild/adv/public/js/out" + :output-to "target/cljsbuild/adv/public/js/main.js" + :asset-path "js/out" + :npm-deps false + :infer-externs true}} ;; FIXME: Doesn't work due to Closure bug with scoped npm packages :client-npm diff --git a/examples/material-ui/src/example/core.cljs b/examples/material-ui/src/example/core.cljs index ea723ce..1c8089e 100644 --- a/examples/material-ui/src/example/core.cljs +++ b/examples/material-ui/src/example/core.cljs @@ -8,6 +8,13 @@ [goog.object :as gobj] [reagent.impl.template :as rtpl])) +(set! *warn-on-infer* true) + +(defn event-value + [^js/Event e] + (let [^js/HTMLInputElement el (.-target e)] + (.-value el))) + ;; TextField cursor fix: (def ^:private input-component @@ -51,9 +58,9 @@ (def custom-theme (createMuiTheme - #js {:palette #js {:primary #js {:main (gobj/get (.-red mui-colors) 100)}}})) + #js {:palette #js {:primary #js {:main (gobj/get (.-red ^js/Mui.Colors mui-colors) 100)}}})) -(defn custom-styles [theme] +(defn custom-styles [^js/Mui.Theme theme] #js {:button #js {:margin (.spacing theme 1)} :textField #js {:width 200 :marginLeft (.spacing theme 1) @@ -97,7 +104,7 @@ :helper-text "Helper text" :class (.-textField classes) :on-change (fn [e] - (reset! text-state (.. e -target -value))) + (reset! text-state (event-value e))) :inputRef #(js/console.log "input-ref" %)}]] [:> mui/Grid {:item true} @@ -107,8 +114,8 @@ :placeholder "Placeholder" :helper-text "Helper text" :class (.-textField classes) - :on-change (fn [e] - (reset! text-state (.. e -target -value))) + :on-change (fn [^js/DomEvent e] + (reset! text-state (event-value e))) :multiline true ;; TODO: Autosize textarea is broken. :rows 10}]] @@ -121,7 +128,7 @@ :helper-text "Helper text" :class (.-textField classes) :on-change (fn [e] - (reset! text-state (.. e -target -value))) + (reset! text-state (event-value e))) :select true} [:> mui/MenuItem {:value 1}