Skip to content

Commit

Permalink
[dropdown] Add :chosen-single part
Browse files Browse the repository at this point in the history
  • Loading branch information
kimo-k committed Nov 18, 2024
1 parent 99fb64b commit 021f274
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/re_com/dropdown.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,19 @@
[]
(let [ignore-click (atom false)]
(fn
[internal-model choices id-fn label-fn tab-index placeholder dropdown-click key-handler filter-box? drop-showing? title? disabled?]
[internal-model choices id-fn label-fn tab-index placeholder dropdown-click key-handler filter-box? drop-showing? title? disabled? parts]
(let [_ (reagent/set-state (reagent/current-component) {:filter-box? filter-box?})
text (if (some? @internal-model)
(label-fn (item-for-id @internal-model choices :id-fn id-fn))
placeholder)]
[:a.chosen-single.chosen-default
{:style (merge {:display "flex"
:justify-content :space-between
:width "100%"}
(when disabled?
{:background-color "#EEE"}))
[:a.chosen-single.chosen-default.rc-dropddown-chosen-single
{:style (merge {:display "flex"
:justify-content :space-between
:width "100%"}
(when disabled?
{:background-color "#EEE"})
(get-in parts [:chosen-single :style]))
:class (get-in parts [:chosen-single :class])
:tab-index (or tab-index 0)
:on-click (handler-fn
(if @ignore-click
Expand All @@ -655,7 +657,7 @@
(when (not disabled?)
[re-com.dropdown/indicator
{:style {:margin-right "8px"
:margin-top "0.5px"}
:margin-top "0.5px"}
:state {:openable (if @drop-showing? :open :closed)}}])]))))

(defn handle-free-text-insertion
Expand Down Expand Up @@ -789,6 +791,7 @@
(def single-dropdown-parts-desc (when include-args-desc?
[{:name :tooltip :level 0 :class "rc-dropdown-tooltip" :impl "[popover-tooltip]" :notes "Tooltip for the dropdown, if enabled."}
{:type :legacy :level 1 :class "rc-dropdown" :impl "[:div]" :notes "The container for the rest of the dropdown."}
{:name :chosen-single :level 1 :class "rc-dropdown-chosen-single" :impl "[:div]"}
{:name :chosen-drop :level 2 :class "rc-dropdown-chosen-drop" :impl "[:div]"}
{:name :chosen-results :level 3 :class "rc-dropdown-chosen-results" :impl "[:ul]"}
{:name :choices-loading :level 4 :class "rc-dropdown-choices-loading" :impl "[:li]"}
Expand Down Expand Up @@ -1037,7 +1040,7 @@
"End" (press-end)
(or filter-box? free-text?))) ;; Use this boolean to allow/prevent the key from being processed by the text box
anchor [dropdown-top internal-model choices id-fn label-fn tab-index placeholder dropdown-click key-handler
filter-box? drop-showing? title? disabled?]
filter-box? drop-showing? title? disabled? parts]
dropdown [:div
(merge
{:class (str "rc-dropdown chosen-container "
Expand Down

0 comments on commit 021f274

Please sign in to comment.