enhance: property value auto-complete

This commit is contained in:
Tienson Qin
2023-07-05 13:17:20 +08:00
parent 59ebedb6c5
commit 880ac87451
4 changed files with 63 additions and 39 deletions

View File

@@ -54,7 +54,11 @@
close-modal? true
extract-fn :value}}]
(let [input (::input state)
*selected-choices (::selected-choices state)]
*selected-choices (::selected-choices state)
search-result (cond-> (search/fuzzy-search items @input :limit limit :extract-fn extract-fn)
(fn? transform-fn)
(transform-fn @input))
input-opts' (if (fn? input-opts) (input-opts (empty? search-result)) input-opts)]
(when (fn? tap-*input-val)
(tap-*input-val input))
[:div.cp__select
@@ -69,14 +73,11 @@
(let [v (util/evalue e)]
(reset! input v)
(and (fn? on-input) (on-input v))))}
input-opts)]]
input-opts')]]
[:div.item-results-wrap
(ui/auto-complete
(cond-> (search/fuzzy-search items @input :limit limit :extract-fn extract-fn)
(fn? transform-fn)
(transform-fn @input))
search-result
{:item-render (or item-cp (fn [result chosen?]
(render-item result chosen? multiple-choices? *selected-choices)))
:class "cp__select-results"