enhance: select component support header

This commit is contained in:
Tienson Qin
2024-11-11 09:53:09 +08:00
parent 456825e981
commit 80c811e930
2 changed files with 33 additions and 26 deletions

View File

@@ -22,17 +22,23 @@
[result chosen? multiple-choices? *selected-choices]
(let [value (if (map? result) (or (:label result)
(:value result)) result)
selected-choices (rum/react *selected-choices)]
[:div.flex.flex-row.justify-between.w-full {:class (when chosen? "chosen")}
[:div.flex.flex-row.items-center.gap-1
(when multiple-choices?
(ui/checkbox {:checked (boolean (selected-choices (:value result)))
:on-click (fn [e]
(.preventDefault e))}))
value]
(when (and (map? result) (:id result))
[:div.tip.flex
[:code.opacity-20.bg-transparent (:id result)]])]))
header (:header result)
selected-choices (rum/react *selected-choices)
row [:div.flex.flex-row.justify-between.w-full {:class (when chosen? "chosen")}
[:div.flex.flex-row.items-center.gap-1
(when multiple-choices?
(ui/checkbox {:checked (boolean (selected-choices (:value result)))
:on-click (fn [e]
(.preventDefault e))}))
value]
(when (and (map? result) (:id result))
[:div.tip.flex
[:code.opacity-20.bg-transparent (:id result)]])]]
(if header
[:div.flex.flex-col.gap-1
header
row]
row)))
(rum/defcs ^:large-vars/cleanup-todo select
"Provides a select dropdown powered by a fuzzy search. Takes the following options:
@@ -250,4 +256,4 @@
{:id :ls-select-modal
:close-btn? false
:align :top
:content-props {:class "ls-dialog-select"}}))))
:content-props {:class "ls-dialog-select"}}))))