|
55 | 55 | :level 2} |
56 | 56 | {:name :dropdown-body |
57 | 57 | :impl "user-defined" |
58 | | - :level 2}]))) |
| 58 | + :level 2} |
| 59 | + {:name :only-button |
| 60 | + :impl 're-com.tree-select/only-button |
| 61 | + :level 3 |
| 62 | + :notes [:span "Appears when hovering a choice or group, and when " |
| 63 | + [:code ":show-only-button?"] " is true. " |
| 64 | + "When clicked, selects only the single choice or group."]}]))) |
59 | 65 |
|
60 | 66 | (def tree-select-dropdown-parts |
61 | 67 | (when include-args-desc? |
|
309 | 315 | :attr (get-in parts [:offset :attr]) |
310 | 316 | :child (apply str (repeat level "⯈"))]) |
311 | 317 |
|
312 | | -(defn solo-button [{:keys [solo!]}] |
313 | | - [:a {:href "#" :on-click solo!} "only"]) |
| 318 | +(defn only-button [{:keys [solo! style class attr]}] |
| 319 | + [:a (merge {:style style :class class :href "#" :on-click solo!} attr) "only"]) |
314 | 320 |
|
315 | 321 | (defn choice [{:keys [parts checked? toggle! label disabled? attr]}] |
316 | 322 | [h-box |
|
329 | 335 |
|
330 | 336 | (defn choice-wrapper [_] |
331 | 337 | (let [hover? (r/atom nil)] |
332 | | - (fn [{:keys [choice level showing? show-only-button?] :as props}] |
| 338 | + (fn [{:keys [choice level showing? show-only-button? theme parts] :as props}] |
333 | 339 | (when showing? |
334 | 340 | [h-box |
335 | 341 | :align :center |
|
341 | 347 | (vec (repeat level [gap :size "10px"])) |
342 | 348 | [(u/part choice |
343 | 349 | {:props props |
| 350 | + :part ::choice |
| 351 | + :theme theme |
344 | 352 | :impl re-com.tree-select/choice}) |
345 | 353 | [gap :size "1"] |
346 | | - (when (and show-only-button? @hover?) [solo-button props])])])))) |
| 354 | + (when (and show-only-button? @hover?) |
| 355 | + (u/part (:only-button parts) |
| 356 | + {:props props |
| 357 | + :part ::only-button |
| 358 | + :theme theme |
| 359 | + :impl re-com.tree-select/only-button}))])])))) |
347 | 360 |
|
348 | 361 | (defn group-item [& {:keys [checked? hide-show! showing? open? parts] :as props}] |
349 | 362 | (when showing? |
|
361 | 374 |
|
362 | 375 | (defn group-wrapper [_] |
363 | 376 | (let [hover? (r/atom nil)] |
364 | | - (fn [{:keys [level hide-show! parts open? showing? show-only-button?] :as props}] |
| 377 | + (fn [{:keys [level hide-show! parts open? showing? show-only-button? theme] :as props}] |
365 | 378 | (when showing? |
366 | 379 | [h-box |
367 | 380 | :attr {:on-mouse-enter #(reset! hover? true) |
|
385 | 398 | {:props props |
386 | 399 | :impl re-com.tree-select/group-item}) |
387 | 400 | [gap :size "1"] |
388 | | - (when (and show-only-button? @hover?) [solo-button props])])])))) |
| 401 | + (when (and show-only-button? @hover?) |
| 402 | + (u/part (:only-button parts) |
| 403 | + {:props props |
| 404 | + :part ::only-button |
| 405 | + :theme theme |
| 406 | + :impl re-com.tree-select/only-button}))])])))) |
389 | 407 |
|
390 | 408 | (def group? (comp #{:group} :type)) |
391 | 409 |
|
|
504 | 522 | group-props {:group item-props |
505 | 523 | :label (group-label-fn item-props) |
506 | 524 | :parts parts |
| 525 | + :theme theme |
507 | 526 | :hide-show! (handler-fn (on-group-expand (toggle expanded-groups group))) |
508 | 527 | :toggle! (handler-fn |
509 | 528 | (let [new-model (toggle-group model)] |
|
526 | 545 | :model model |
527 | 546 | :label (label-fn item-props) |
528 | 547 | :parts parts |
| 548 | + :theme theme |
529 | 549 | :showing? (if-not group |
530 | 550 | true |
531 | 551 | (every? (set expanded-groups) (ancestor-paths group))) |
|
0 commit comments