|
309 | 309 | theme/args-desc
|
310 | 310 | (part/describe-args part-structure))))))
|
311 | 311 |
|
| 312 | +(defn safe-assoc |
| 313 | + [v idx val] |
| 314 | + (if (< idx (count v)) |
| 315 | + (assoc v idx val) |
| 316 | + (into (vec (concat v (repeat (- idx (count v)) nil))) [val]))) |
| 317 | + |
312 | 318 | (defn nested-v-grid [{:keys [row-tree column-tree
|
313 | 319 | row-tree-depth column-tree-depth
|
314 | 320 | row-header-widths column-header-heights
|
|
397 | 403 | safe-column-header-heights (r/reaction
|
398 | 404 | (->> (concat @internal-column-header-heights
|
399 | 405 | (repeat (u/deref-or-value column-header-height)))
|
| 406 | + (map #(or % column-header-height)) |
400 | 407 | (take @column-depth)
|
401 | 408 | vec))
|
402 | 409 | safe-row-header-widths (r/reaction
|
403 | 410 | (->> (concat @internal-row-header-widths
|
404 | 411 | (repeat (u/deref-or-value row-header-width)))
|
405 | 412 | (take @row-depth)
|
| 413 | + (map #(or % row-header-width)) |
406 | 414 | vec))
|
407 | 415 | column-header-height-total (r/reaction (apply + @safe-column-header-heights))
|
408 | 416 | column-width-total (r/reaction (:sum-size @column-traversal))
|
|
520 | 528 | resize-column-header-height? true
|
521 | 529 | on-resize (fn [{:keys [header-dimension size-dimension keypath size]}]
|
522 | 530 | (case [header-dimension size-dimension]
|
523 |
| - [:column :height] (swap! internal-column-header-heights assoc-in keypath size) |
524 |
| - [:row :width] (swap! internal-row-header-widths assoc-in keypath size) |
| 531 | + [:column :height] (swap! internal-column-header-heights safe-assoc (first keypath) size) |
| 532 | + [:row :width] (swap! internal-row-header-widths safe-assoc (first keypath) size) |
525 | 533 | [:row :height] (swap! internal-row-tree update-in keypath assoc :size size)
|
526 | 534 | [:column :width] (swap! internal-column-tree update-in keypath assoc :size size)))}}]
|
527 | 535 | (let [ensure-reactivity u/deref-or-value
|
|
0 commit comments