|
1175 | 1175 | (defn nested-v-grid [{:keys [row-tree column-tree |
1176 | 1176 | row-tree-depth column-tree-depth |
1177 | 1177 | row-header-widths column-header-heights |
1178 | | - row-height column-width column-depth |
1179 | | - theme |
| 1178 | + row-height column-width |
1180 | 1179 | row-header-width column-header-height] |
1181 | 1180 | :or {row-header-width 40 column-header-height 40 |
1182 | 1181 | row-height 20 column-width 40}}] |
|
1252 | 1251 | (reset! internal-row-tree (u/deref-or-value row-tree)) |
1253 | 1252 | (reset! internal-column-tree (u/deref-or-value column-tree))) |
1254 | 1253 | :reagent-render |
1255 | | - (fn [{:keys [row-tree column-tree |
1256 | | - cell-value |
1257 | | - theme-cells? |
1258 | | - on-resize] |
1259 | | - {:keys [cell |
| 1254 | + (fn [{:keys [row-tree column-tree |
| 1255 | + cell-value |
| 1256 | + theme-cells? |
| 1257 | + on-resize] |
| 1258 | + {:keys [cell corner-header |
1260 | 1259 | row-header column-header |
1261 | 1260 | row-header-label column-header-label |
1262 | 1261 | row-header-grid column-header-grid |
1263 | | - row-height column-width |
1264 | | - cell-grid] |
1265 | | - :as parts} :parts |
1266 | | - :as props |
1267 | | - :or {on-resize (fn [{:keys [value dimension]}] |
1268 | | - (case dimension |
1269 | | - :column-header-height (reset! column-header-heights-internal value)))}}] |
| 1262 | + corner-header-grid cell-grid |
| 1263 | + row-height column-width]} :parts |
| 1264 | + :as props |
| 1265 | + :or {on-resize (fn [{:keys [value dimension]}] |
| 1266 | + (case dimension |
| 1267 | + :column-header-height (reset! column-header-heights-internal value)))}}] |
1270 | 1268 | (mapv u/deref-or-value [row-tree row-header-widths row-height |
1271 | 1269 | column-tree column-header-heights column-width]) |
1272 | | - (let [theme (theme/defaults |
1273 | | - props |
1274 | | - {:user [(theme/<-props props {:part ::wrapper |
1275 | | - :include [:style :class]})]}) |
1276 | | - themed (fn [part props] (theme/apply props {:part part} theme)) |
1277 | | - spacer-container [:div {:style {:position :sticky |
1278 | | - :grid-row-start 1 |
1279 | | - :grid-column-start 1 |
1280 | | - :left 0 |
1281 | | - :top 0 |
1282 | | - :background-color :white}}] |
1283 | | - row-headers (for [row-path @row-windowed-paths |
1284 | | - :let [props {:row-path row-path |
1285 | | - :path row-path |
1286 | | - :style {:grid-row-start (ngu/path->grid-line-name row-path) |
1287 | | - :grid-row-end (str "span " (get @row-spans row-path)) |
1288 | | - :grid-column-start (count row-path) |
1289 | | - :grid-column-end (str "span " (inc (- @row-depth (count row-path))))}} |
1290 | | - props (assoc props :children [(u/part row-header-label props |
1291 | | - :default ngp/row-header-label)]) |
1292 | | - props (themed ::row-header props)]] |
1293 | | - (u/part row-header props {:key row-path})) |
1294 | | - column-headers (for [column-path @column-windowed-paths |
1295 | | - :let [props (themed ::column-header |
1296 | | - {:column-path column-path |
1297 | | - :path column-path |
1298 | | - :style {:grid-column-start (ngu/path->grid-line-name column-path) |
1299 | | - :grid-column-end (str "span " (get @column-spans column-path)) |
1300 | | - :grid-row-start (count column-path) |
1301 | | - :grid-row-end (str "span " (inc (- @column-depth (count column-path)))) |
1302 | | - :overflow :hidden} |
1303 | | - :children [(u/part column-header-label props |
1304 | | - :default ngp/column-header-label)]})]] |
1305 | | - (u/part column-header props {:key column-path})) |
| 1270 | + (let [theme |
| 1271 | + (theme/defaults props {:user [(theme/<-props props {:part ::wrapper |
| 1272 | + :include [:style :class]})]}) |
| 1273 | + |
| 1274 | + themed |
| 1275 | + (fn [part props] (theme/apply props {:part part} theme)) |
| 1276 | + |
1306 | 1277 | row-width-resizers |
1307 | 1278 | (for [i (range @row-depth)] |
1308 | 1279 | ^{:key [::row-width-resizer i]} |
|
1355 | 1326 | :keypath (get @column-windowed-keypaths i) |
1356 | 1327 | :size (get @column-windowed-sizes i) |
1357 | 1328 | :dimension :column-width}])) |
1358 | | - main-container [:div |
1359 | | - (themed ::wrapper |
1360 | | - {:style {:grid-template-rows (ngu/grid-template [@column-header-height-total @row-height-total]) |
1361 | | - :grid-template-columns (ngu/grid-template [@row-header-width-total @column-width-total])} |
1362 | | - :ref wrapper-ref!})] |
1363 | | - cells (for [row-path @row-windowed-leaf-paths |
1364 | | - column-path @column-windowed-leaf-paths |
1365 | | - :let [props {:row-path row-path |
1366 | | - :column-path column-path} |
1367 | | - props (cond-> props |
1368 | | - cell-value (assoc :cell-value |
1369 | | - (cell-value props)) |
1370 | | - theme-cells? (->> (theme ::cell-wrapper)))]] |
1371 | | - (u/part cell props {:key [row-path column-path] |
1372 | | - :default ngp/cell-wrapper}))] |
| 1329 | + |
| 1330 | + main-container |
| 1331 | + [:div |
| 1332 | + (themed ::wrapper |
| 1333 | + {:style {:grid-template-rows (ngu/grid-template [@column-header-height-total @row-height-total]) |
| 1334 | + :grid-template-columns (ngu/grid-template [@row-header-width-total @column-width-total])} |
| 1335 | + :ref wrapper-ref!})] |
| 1336 | + |
| 1337 | + row-headers |
| 1338 | + (for [row-path @row-windowed-paths |
| 1339 | + :let [props {:row-path row-path |
| 1340 | + :path row-path |
| 1341 | + :style {:grid-row-start (ngu/path->grid-line-name row-path) |
| 1342 | + :grid-row-end (str "span " (get @row-spans row-path)) |
| 1343 | + :grid-column-start (count row-path) |
| 1344 | + :grid-column-end (str "span " (inc (- @row-depth (count row-path))))}} |
| 1345 | + props (assoc props :children [(u/part row-header-label props |
| 1346 | + :default ngp/row-header-label)]) |
| 1347 | + props (themed ::row-header props)]] |
| 1348 | + (u/part row-header props {:key row-path})) |
| 1349 | + |
| 1350 | + column-headers |
| 1351 | + (for [column-path @column-windowed-paths |
| 1352 | + :let [props (themed ::column-header |
| 1353 | + {:column-path column-path |
| 1354 | + :path column-path |
| 1355 | + :style {:grid-column-start (ngu/path->grid-line-name column-path) |
| 1356 | + :grid-column-end (str "span " (get @column-spans column-path)) |
| 1357 | + :grid-row-start (count column-path) |
| 1358 | + :grid-row-end (str "span " (inc (- @column-depth (count column-path)))) |
| 1359 | + :overflow :hidden} |
| 1360 | + :children [(u/part column-header-label props |
| 1361 | + :default ngp/column-header-label)]})]] |
| 1362 | + (u/part column-header props {:key column-path})) |
| 1363 | + |
| 1364 | + corner-headers |
| 1365 | + (for [column-index (range @row-depth) |
| 1366 | + row-index (range @column-depth) |
| 1367 | + :let [props (themed ::corner-header |
| 1368 | + {:row-index row-index |
| 1369 | + :column-index column-index |
| 1370 | + :style {:grid-row-start (inc row-index) |
| 1371 | + :grid-column-start (inc column-index)} |
| 1372 | + :children [[:div "HI"]]})]] |
| 1373 | + (u/part corner-header props {:key [::corner-header row-index column-index]})) |
| 1374 | + |
| 1375 | + cells |
| 1376 | + (for [row-path @row-windowed-leaf-paths |
| 1377 | + column-path @column-windowed-leaf-paths |
| 1378 | + :let [props {:row-path row-path |
| 1379 | + :column-path column-path} |
| 1380 | + props (cond-> props |
| 1381 | + cell-value (assoc :cell-value |
| 1382 | + (cell-value props)) |
| 1383 | + theme-cells? (->> (theme ::cell-wrapper)))]] |
| 1384 | + (u/part cell props {:key [row-path column-path] |
| 1385 | + :default ngp/cell-wrapper}))] |
1373 | 1386 | (conj main-container |
1374 | 1387 | (u/part cell-grid |
1375 | 1388 | (themed ::cell-grid |
|
1392 | 1405 | {:children (concat row-headers row-width-resizers (row-height-resizers)) |
1393 | 1406 | :style {:grid-template-rows @row-template |
1394 | 1407 | :grid-template-columns @row-header-template}})) |
1395 | | - spacer-container |
| 1408 | + (u/part corner-header-grid |
| 1409 | + (themed ::corner-header-grid |
| 1410 | + {:children (concat corner-headers row-width-resizers column-height-resizers) |
| 1411 | + :style {:grid-template-rows @column-header-template |
| 1412 | + :grid-template-columns @row-header-template}})) |
1396 | 1413 | (u/deref-or-value overlay))))}))) |
0 commit comments