Another improvement
This commit is contained in:
@@ -22,14 +22,26 @@
|
||||
]
|
||||
(r/children (r/current-component))))
|
||||
|
||||
(defn select-field [{:keys [options allow-nil? class] :as props}]
|
||||
(defn select-field [{:keys [options allow-nil? class on-change keywordize?] :as props}]
|
||||
[:div.select {:class class}
|
||||
[:select (-> props
|
||||
(dissoc :allow-nil? :class :options)
|
||||
(update :value (fn [v]
|
||||
(if (str/blank? v)
|
||||
(cond (str/blank? v)
|
||||
""
|
||||
v))))
|
||||
|
||||
keywordize?
|
||||
(name v)
|
||||
|
||||
:else
|
||||
v)))
|
||||
(assoc :on-change
|
||||
(fn [e]
|
||||
(println "VALUE IS" (keyword (.. e -target -value)))
|
||||
(if keywordize?
|
||||
(on-change (keyword (.. e -target -value)))
|
||||
(on-change e))))
|
||||
(dissoc :keywordize?))
|
||||
[:<>
|
||||
(when allow-nil?
|
||||
[:option {:value nil}])
|
||||
|
||||
Reference in New Issue
Block a user