Another improvement

This commit is contained in:
2022-07-22 06:59:37 -07:00
parent ccbe63456a
commit 3c11891c45
5 changed files with 87 additions and 77 deletions

View File

@@ -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}])