@diagrammo/dgmo 0.47.0 → 0.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/dist/advanced.js +11 -11
  2. package/dist/auto.js +16 -16
  3. package/dist/auto.mjs +41 -12
  4. package/dist/block.js +4 -4
  5. package/dist/{chunk-FNB3PNGF.js → chunk-7DTWEFUE.js} +3 -3
  6. package/dist/{chunk-2DXMZRWJ.js → chunk-B65G5DNL.js} +8 -1
  7. package/dist/{chunk-RZCF2VVM.js → chunk-B7JUCQUA.js} +3 -1
  8. package/dist/{chunk-DU7W62N5.js → chunk-FANX6UJR.js} +3 -3
  9. package/dist/{chunk-6FZYCKXB.js → chunk-HSH73DP6.js} +2 -2
  10. package/dist/{chunk-P4RH4OSP.js → chunk-ILKORZ3H.js} +2 -2
  11. package/dist/{chunk-Y5QGVTVC.js → chunk-JTSMEYIZ.js} +7 -3
  12. package/dist/{chunk-RCERWOJR.js → chunk-ODZVHU3R.js} +1 -2
  13. package/dist/{chunk-DZAQBW35.js → chunk-SGZYXELT.js} +3 -7
  14. package/dist/{chunk-CUVHQHZ7.js → chunk-THXCFRTU.js} +3 -3
  15. package/dist/{chunk-IH6ZMVQ5.js → chunk-UC7TFHUM.js} +29 -11
  16. package/dist/{chunk-EMS2SK26.js → chunk-ZBWMSD5N.js} +3 -1
  17. package/dist/cli.cjs +15 -15
  18. package/dist/{dgmo-router-DZCIDUO5.js → dgmo-router-X35VLZLM.js} +3 -3
  19. package/dist/element.js +16 -16
  20. package/dist/element.mjs +41 -12
  21. package/dist/{flowchart-renderer-ZAEOL4DX.js → flowchart-renderer-SNDSII4D.js} +2 -2
  22. package/dist/index.d.ts +4 -2
  23. package/dist/index.js +4 -4
  24. package/dist/{parser-FUSKFGZN.js → parser-2EWECDSA.js} +2 -2
  25. package/dist/{renderer-UWA5XS74.js → renderer-4JHRUBE6.js} +3 -3
  26. package/dist/{renderer-WZRREQ2P.js → renderer-5MYBMBYO.js} +2 -2
  27. package/dist/{renderer-TOCOVLHS.js → renderer-B2OMQIQG.js} +3 -3
  28. package/dist/{renderer-2XQQQ6QR.js → renderer-N43WR5GV.js} +3 -3
  29. package/dist/{renderer-T7YKC5VP.js → renderer-ZRNG54CW.js} +3 -3
  30. package/dist/{state-renderer-RFYHSP4K.js → state-renderer-B4DQBM6M.js} +2 -2
  31. package/package.json +23 -71
  32. package/dist/advanced.cjs +0 -71648
  33. package/dist/advanced.d.cts +0 -5719
  34. package/dist/auto.cjs +0 -70648
  35. package/dist/auto.d.cts +0 -54
  36. package/dist/block.cjs +0 -70208
  37. package/dist/block.d.cts +0 -115
  38. package/dist/editor.cjs +0 -526
  39. package/dist/editor.d.cts +0 -26
  40. package/dist/element.cjs +0 -70530
  41. package/dist/element.d.cts +0 -62
  42. package/dist/highlight.cjs +0 -852
  43. package/dist/highlight.d.cts +0 -49
  44. package/dist/index.cjs +0 -70491
  45. package/dist/index.d.cts +0 -160
  46. package/dist/pert.cjs +0 -325
  47. package/dist/pert.d.cts +0 -559
  48. package/dist/themes-1-CuKpeH.d.cts +0 -908
  49. package/src/advanced.ts +0 -873
  50. package/src/arc/parser.ts +0 -15
  51. package/src/arc/renderer.ts +0 -633
  52. package/src/auto/index.ts +0 -621
  53. package/src/auto/shared.ts +0 -370
  54. package/src/auto/styles.ts +0 -73
  55. package/src/block/layout.ts +0 -198
  56. package/src/block/parser.ts +0 -427
  57. package/src/block/renderer.ts +0 -484
  58. package/src/block/types.ts +0 -67
  59. package/src/boxes-and-lines/collapse.ts +0 -96
  60. package/src/boxes-and-lines/focus.ts +0 -257
  61. package/src/boxes-and-lines/label-placement.ts +0 -339
  62. package/src/boxes-and-lines/layout-grouped.ts +0 -912
  63. package/src/boxes-and-lines/layout-layered.ts +0 -722
  64. package/src/boxes-and-lines/layout-search.ts +0 -1678
  65. package/src/boxes-and-lines/layout.ts +0 -398
  66. package/src/boxes-and-lines/parser.ts +0 -1181
  67. package/src/boxes-and-lines/renderer.ts +0 -1465
  68. package/src/boxes-and-lines/types.ts +0 -66
  69. package/src/c4/layout.ts +0 -2441
  70. package/src/c4/parser.ts +0 -1158
  71. package/src/c4/renderer.ts +0 -2008
  72. package/src/c4/types.ts +0 -89
  73. package/src/chart-type-registry.ts +0 -529
  74. package/src/chart-types.ts +0 -225
  75. package/src/chart.ts +0 -685
  76. package/src/charts-d3/bar.ts +0 -338
  77. package/src/charts-d3/chord.ts +0 -140
  78. package/src/charts-d3/function.ts +0 -147
  79. package/src/charts-d3/funnel.ts +0 -104
  80. package/src/charts-d3/heatmap.ts +0 -145
  81. package/src/charts-d3/index.ts +0 -337
  82. package/src/charts-d3/interactions.ts +0 -477
  83. package/src/charts-d3/line.ts +0 -344
  84. package/src/charts-d3/mount.ts +0 -151
  85. package/src/charts-d3/pie.ts +0 -117
  86. package/src/charts-d3/polar.ts +0 -89
  87. package/src/charts-d3/radar.ts +0 -0
  88. package/src/charts-d3/sankey.ts +0 -0
  89. package/src/charts-d3/scatter.ts +0 -185
  90. package/src/charts-d3/shared.ts +0 -208
  91. package/src/class/layout.ts +0 -326
  92. package/src/class/parser.ts +0 -635
  93. package/src/class/renderer.ts +0 -793
  94. package/src/class/types.ts +0 -58
  95. package/src/cli-banner.ts +0 -106
  96. package/src/cli.ts +0 -1080
  97. package/src/colors-diagnostics.ts +0 -35
  98. package/src/colors.ts +0 -379
  99. package/src/completion-types.ts +0 -27
  100. package/src/completion.ts +0 -2668
  101. package/src/cycle/layout.ts +0 -1026
  102. package/src/cycle/parser.ts +0 -387
  103. package/src/cycle/renderer.ts +0 -653
  104. package/src/cycle/types.ts +0 -101
  105. package/src/d3.ts +0 -1434
  106. package/src/data-chart-parser.ts +0 -1007
  107. package/src/dgmo-router.ts +0 -296
  108. package/src/diagnostics-registry.ts +0 -108
  109. package/src/diagnostics.ts +0 -0
  110. package/src/dimensions.ts +0 -20
  111. package/src/directives-registry.ts +0 -396
  112. package/src/editor/dgmo.grammar +0 -76
  113. package/src/editor/dgmo.grammar.d.ts +0 -2
  114. package/src/editor/dgmo.grammar.js +0 -18
  115. package/src/editor/dgmo.grammar.terms.d.ts +0 -5
  116. package/src/editor/dgmo.grammar.terms.js +0 -35
  117. package/src/editor/highlight-api.ts +0 -596
  118. package/src/editor/highlight.ts +0 -36
  119. package/src/editor/index.ts +0 -27
  120. package/src/editor/keywords.ts +0 -128
  121. package/src/editor/tokens.ts +0 -30
  122. package/src/element/index.ts +0 -432
  123. package/src/embed/css.ts +0 -312
  124. package/src/embed/escape.ts +0 -15
  125. package/src/embed/index.ts +0 -280
  126. package/src/er/classify.ts +0 -228
  127. package/src/er/layout.ts +0 -530
  128. package/src/er/parser.ts +0 -750
  129. package/src/er/renderer.ts +0 -725
  130. package/src/er/types.ts +0 -52
  131. package/src/error-card.ts +0 -269
  132. package/src/event-line/diagnostics.ts +0 -117
  133. package/src/event-line/parser.ts +0 -643
  134. package/src/event-line/renderer.ts +0 -1742
  135. package/src/event-line/types.ts +0 -74
  136. package/src/fonts.ts +0 -3
  137. package/src/gantt/calculator.ts +0 -979
  138. package/src/gantt/parser.ts +0 -1641
  139. package/src/gantt/renderer.ts +0 -3787
  140. package/src/gantt/resolver.ts +0 -172
  141. package/src/gantt/types.ts +0 -206
  142. package/src/graph/diagnostics.ts +0 -64
  143. package/src/graph/edge-spline.ts +0 -29
  144. package/src/graph/flowchart-parser.ts +0 -759
  145. package/src/graph/flowchart-renderer.ts +0 -817
  146. package/src/graph/layout.ts +0 -472
  147. package/src/graph/notes.ts +0 -21
  148. package/src/graph/state-collapse.ts +0 -78
  149. package/src/graph/state-parser.ts +0 -574
  150. package/src/graph/state-renderer.ts +0 -653
  151. package/src/graph/types.ts +0 -65
  152. package/src/index.ts +0 -261
  153. package/src/infra/compute.ts +0 -1385
  154. package/src/infra/layout.ts +0 -888
  155. package/src/infra/parser.ts +0 -1234
  156. package/src/infra/renderer.ts +0 -2534
  157. package/src/infra/roles.ts +0 -75
  158. package/src/infra/types.ts +0 -216
  159. package/src/infra/validation.ts +0 -201
  160. package/src/journey-map/layout.ts +0 -490
  161. package/src/journey-map/parser.ts +0 -557
  162. package/src/journey-map/renderer.ts +0 -1580
  163. package/src/journey-map/types.ts +0 -47
  164. package/src/kanban/mutations.ts +0 -175
  165. package/src/kanban/parser.ts +0 -509
  166. package/src/kanban/renderer.ts +0 -1449
  167. package/src/kanban/types.ts +0 -39
  168. package/src/label-layout.ts +0 -368
  169. package/src/map/colorize.ts +0 -54
  170. package/src/map/completion.ts +0 -316
  171. package/src/map/context-labels.ts +0 -609
  172. package/src/map/data/PROVENANCE.json +0 -1
  173. package/src/map/data/README.md +0 -40
  174. package/src/map/data/airport-collisions.json +0 -1
  175. package/src/map/data/airports.json +0 -1
  176. package/src/map/data/gazetteer.json +0 -1
  177. package/src/map/data/lakes.json +0 -1
  178. package/src/map/data/mountain-ranges.json +0 -1
  179. package/src/map/data/na-lakes.json +0 -1
  180. package/src/map/data/na-land.json +0 -1
  181. package/src/map/data/region-names.json +0 -1
  182. package/src/map/data/rivers.json +0 -1
  183. package/src/map/data/types.ts +0 -121
  184. package/src/map/data/us-states.json +0 -1
  185. package/src/map/data/water-bodies.json +0 -1
  186. package/src/map/data/world-coarse.json +0 -1
  187. package/src/map/data/world-detail.json +0 -1
  188. package/src/map/diagnostics.ts +0 -134
  189. package/src/map/dimensions.ts +0 -150
  190. package/src/map/geo-query.ts +0 -295
  191. package/src/map/geo.ts +0 -438
  192. package/src/map/invert.ts +0 -111
  193. package/src/map/layout.ts +0 -5069
  194. package/src/map/legend-band.ts +0 -127
  195. package/src/map/load-data.ts +0 -186
  196. package/src/map/parser.ts +0 -783
  197. package/src/map/renderer.ts +0 -1445
  198. package/src/map/resolved-types.ts +0 -160
  199. package/src/map/resolver.ts +0 -1146
  200. package/src/map/types.ts +0 -194
  201. package/src/mindmap/collapse.ts +0 -67
  202. package/src/mindmap/layout.ts +0 -649
  203. package/src/mindmap/parser.ts +0 -430
  204. package/src/mindmap/renderer.ts +0 -637
  205. package/src/mindmap/text-wrap.ts +0 -218
  206. package/src/mindmap/types.ts +0 -56
  207. package/src/org/collapse.ts +0 -151
  208. package/src/org/layout.ts +0 -1262
  209. package/src/org/parser.ts +0 -519
  210. package/src/org/renderer.ts +0 -866
  211. package/src/org/resolver.ts +0 -636
  212. package/src/palettes/atlas.ts +0 -77
  213. package/src/palettes/blueprint.ts +0 -73
  214. package/src/palettes/catppuccin.ts +0 -84
  215. package/src/palettes/color-utils.ts +0 -443
  216. package/src/palettes/index.ts +0 -67
  217. package/src/palettes/nord.ts +0 -67
  218. package/src/palettes/registry.ts +0 -114
  219. package/src/palettes/slate.ts +0 -73
  220. package/src/palettes/tidewater.ts +0 -73
  221. package/src/palettes/tokyo-night.ts +0 -86
  222. package/src/palettes/types.ts +0 -88
  223. package/src/pert/analyzer.ts +0 -1183
  224. package/src/pert/diagnostics.ts +0 -110
  225. package/src/pert/index.ts +0 -43
  226. package/src/pert/internal.ts +0 -252
  227. package/src/pert/layout.ts +0 -971
  228. package/src/pert/monte-carlo.ts +0 -446
  229. package/src/pert/parser.ts +0 -1606
  230. package/src/pert/renderer.ts +0 -4009
  231. package/src/pert/share-normalize.ts +0 -62
  232. package/src/pert/types.ts +0 -604
  233. package/src/pyramid/parser.ts +0 -185
  234. package/src/pyramid/renderer.ts +0 -768
  235. package/src/pyramid/types.ts +0 -28
  236. package/src/quadrant/parser.ts +0 -18
  237. package/src/quadrant/renderer.ts +0 -638
  238. package/src/raci/diagnostics.ts +0 -213
  239. package/src/raci/index.ts +0 -23
  240. package/src/raci/mutations.ts +0 -321
  241. package/src/raci/parser.ts +0 -699
  242. package/src/raci/renderer.ts +0 -1627
  243. package/src/raci/types.ts +0 -82
  244. package/src/raci/variants.ts +0 -320
  245. package/src/render.ts +0 -268
  246. package/src/ring/parser.ts +0 -212
  247. package/src/ring/renderer.ts +0 -490
  248. package/src/ring/types.ts +0 -27
  249. package/src/sequence/collapse.ts +0 -174
  250. package/src/sequence/parser.ts +0 -1596
  251. package/src/sequence/participant-inference.ts +0 -152
  252. package/src/sequence/renderer.ts +0 -3168
  253. package/src/sequence/tag-resolution.ts +0 -164
  254. package/src/sharing.ts +0 -211
  255. package/src/sitemap/collapse.ts +0 -100
  256. package/src/sitemap/layout.ts +0 -925
  257. package/src/sitemap/parser.ts +0 -755
  258. package/src/sitemap/renderer.ts +0 -828
  259. package/src/sitemap/types.ts +0 -42
  260. package/src/slope/parser.ts +0 -18
  261. package/src/slope/renderer.ts +0 -378
  262. package/src/swimlane/diagnostics.ts +0 -94
  263. package/src/swimlane/layout.ts +0 -597
  264. package/src/swimlane/parser.ts +0 -613
  265. package/src/swimlane/renderer.ts +0 -681
  266. package/src/swimlane/types.ts +0 -151
  267. package/src/tech-radar/interactive.ts +0 -1129
  268. package/src/tech-radar/layout.ts +0 -197
  269. package/src/tech-radar/parser.ts +0 -436
  270. package/src/tech-radar/renderer.ts +0 -1239
  271. package/src/tech-radar/shared.ts +0 -151
  272. package/src/tech-radar/types.ts +0 -86
  273. package/src/themes.ts +0 -22
  274. package/src/timeline/parser.ts +0 -472
  275. package/src/timeline/renderer.ts +0 -3024
  276. package/src/timeline/types.ts +0 -33
  277. package/src/timeline/viz-parser.ts +0 -21
  278. package/src/treemap/diagnostics.ts +0 -62
  279. package/src/treemap/layout-radial.ts +0 -233
  280. package/src/treemap/layout.ts +0 -189
  281. package/src/treemap/parser.ts +0 -463
  282. package/src/treemap/renderer-radial.ts +0 -438
  283. package/src/treemap/renderer.ts +0 -572
  284. package/src/treemap/treemap-shared.ts +0 -309
  285. package/src/treemap/types.ts +0 -60
  286. package/src/utils/arrow-markers.ts +0 -51
  287. package/src/utils/arrows-diagnostics.ts +0 -62
  288. package/src/utils/arrows.ts +0 -227
  289. package/src/utils/brand.ts +0 -61
  290. package/src/utils/card.ts +0 -183
  291. package/src/utils/collapse-engine/tree-edges.ts +0 -115
  292. package/src/utils/collapse-engine/tree.ts +0 -117
  293. package/src/utils/d3-helpers.ts +0 -219
  294. package/src/utils/d3-types.ts +0 -9
  295. package/src/utils/description-helpers.ts +0 -38
  296. package/src/utils/duration.ts +0 -312
  297. package/src/utils/export-container.ts +0 -41
  298. package/src/utils/expr-eval.ts +0 -27
  299. package/src/utils/fit-canvas.ts +0 -64
  300. package/src/utils/hover-styles.ts +0 -673
  301. package/src/utils/inline-markdown.ts +0 -96
  302. package/src/utils/legend-constants.ts +0 -48
  303. package/src/utils/legend-d3.ts +0 -618
  304. package/src/utils/legend-integration.ts +0 -107
  305. package/src/utils/legend-layout.ts +0 -776
  306. package/src/utils/legend-svg.ts +0 -214
  307. package/src/utils/legend-types.ts +0 -272
  308. package/src/utils/name-normalize.ts +0 -163
  309. package/src/utils/note-box/constants.ts +0 -25
  310. package/src/utils/note-box/index.ts +0 -11
  311. package/src/utils/note-box/metrics.ts +0 -90
  312. package/src/utils/note-box/svg.ts +0 -331
  313. package/src/utils/notes/bounds.ts +0 -30
  314. package/src/utils/notes/build.ts +0 -131
  315. package/src/utils/notes/index.ts +0 -18
  316. package/src/utils/notes/model.ts +0 -19
  317. package/src/utils/notes/parse.ts +0 -131
  318. package/src/utils/notes/place.ts +0 -177
  319. package/src/utils/notes/resolve.ts +0 -88
  320. package/src/utils/number-format.ts +0 -36
  321. package/src/utils/parsing.ts +0 -953
  322. package/src/utils/reserved-key-registry.ts +0 -239
  323. package/src/utils/safe-href.ts +0 -38
  324. package/src/utils/scaling.ts +0 -97
  325. package/src/utils/svg-embed.ts +0 -251
  326. package/src/utils/tag-groups.ts +0 -607
  327. package/src/utils/text-measure.ts +0 -122
  328. package/src/utils/time-ticks.ts +0 -253
  329. package/src/utils/title-constants.ts +0 -24
  330. package/src/utils/visual-conventions.ts +0 -61
  331. package/src/utils/wrapped-desc.ts +0 -87
  332. package/src/venn/parser.ts +0 -18
  333. package/src/venn/renderer.ts +0 -1047
  334. package/src/version-control/diagnostics.ts +0 -67
  335. package/src/version-control/parser.ts +0 -544
  336. package/src/version-control/renderer.ts +0 -724
  337. package/src/version-control/types.ts +0 -100
  338. package/src/visualizations/parse.ts +0 -1560
  339. package/src/visualizations/types.ts +0 -262
  340. package/src/wireframe/layout.ts +0 -479
  341. package/src/wireframe/parser.ts +0 -1114
  342. package/src/wireframe/renderer.ts +0 -1318
  343. package/src/wireframe/types.ts +0 -110
  344. package/src/wordcloud/parser.ts +0 -18
  345. package/src/wordcloud/renderer.ts +0 -357
@@ -1,1449 +0,0 @@
1
- // ============================================================
2
- // Kanban Board SVG Renderer
3
- // ============================================================
4
-
5
- import { tagAttrKey } from '../utils/tag-groups';
6
- import * as d3Selection from 'd3-selection';
7
- import { FONT_FAMILY } from '../fonts';
8
- import type { PaletteColors } from '../palettes';
9
- import { contrastText, mix, shapeFill } from '../palettes/color-utils';
10
- import { renderInlineText } from '../utils/inline-markdown';
11
- import type {
12
- ParsedKanban,
13
- KanbanColumn,
14
- KanbanCard,
15
- KanbanTagGroup,
16
- } from './types';
17
- import { parseKanban } from './parser';
18
- import { isArchiveColumn } from './mutations';
19
- import { LEGEND_HEIGHT, measureLegendText } from '../utils/legend-constants';
20
- import { getMaxLegendReservedHeight } from '../utils/legend-layout';
21
- import { renderIntegratedLegend } from '../utils/legend-integration';
22
- import type {
23
- LegendConfig,
24
- LegendCallbacks,
25
- D3Sel,
26
- } from '../utils/legend-types';
27
- import { ScaleContext } from '../utils/scaling';
28
- import { measureText } from '../utils/text-measure';
29
-
30
- // ============================================================
31
- // Public options object
32
- // ============================================================
33
-
34
- interface KanbanInteractiveOptions {
35
- onNavigateToLine?: (line: number) => void;
36
- exportDims?: { width: number; height: number };
37
- activeTagGroup?: string | null;
38
- currentSwimlaneGroup?: string | null;
39
- onSwimlaneChange?: (group: string | null) => void;
40
- collapsedLanes?: Set<string>;
41
- collapsedColumns?: Set<string>;
42
- compactMeta?: boolean;
43
- exportMode?: boolean;
44
- }
45
-
46
- // ============================================================
47
- // Constants
48
- // ============================================================
49
-
50
- const DIAGRAM_PADDING = 20;
51
- const COLUMN_GAP = 16;
52
- const COLUMN_HEADER_HEIGHT = 36;
53
- const COLUMN_PADDING = 12;
54
- const COLUMN_MIN_WIDTH = 200;
55
- const CARD_HEADER_HEIGHT = 24;
56
- const CARD_META_LINE_HEIGHT = 14;
57
- const CARD_SEPARATOR_GAP = 4;
58
- const CARD_GAP = 8;
59
- import { CARD_RADIUS } from '../utils/visual-conventions'; // shared (Story 111.1)
60
- const CARD_PADDING_X = 10;
61
- const CARD_PADDING_Y = 6;
62
- const CARD_STROKE_WIDTH = 1.5;
63
- import { TITLE_FONT_SIZE, TITLE_FONT_WEIGHT } from '../utils/title-constants';
64
- const TITLE_HEIGHT = 30;
65
- const COLUMN_HEADER_FONT_SIZE = 13;
66
- const CARD_TITLE_FONT_SIZE = 12;
67
- const CARD_META_FONT_SIZE = 10;
68
- const WIP_FONT_SIZE = 10;
69
- const COLUMN_RADIUS = 8;
70
- const COLUMN_HEADER_RADIUS = 8;
71
- const COLLAPSED_COLUMN_WIDTH = 40;
72
- const COLLAPSED_LANE_HEIGHT = 26;
73
-
74
- // ============================================================
75
- // Tag color resolution
76
- // ============================================================
77
-
78
- function resolveCardTagMeta(
79
- card: KanbanCard,
80
- tagGroups: readonly KanbanTagGroup[],
81
- hiddenMetaGroups?: string[]
82
- ): { label: string; value: string; color?: string }[] {
83
- const meta: { label: string; value: string; color?: string }[] = [];
84
- for (const group of tagGroups) {
85
- if (hiddenMetaGroups?.includes(group.name.toLowerCase())) continue;
86
- const tagValue = card.tags[tagAttrKey(group.name)];
87
- const value = tagValue ?? group.defaultValue;
88
- if (!value) continue;
89
- const entry = group.entries.find(
90
- (e) => e.value.toLowerCase() === value.toLowerCase()
91
- );
92
- meta.push({
93
- label: group.name,
94
- value,
95
- ...(entry?.color !== undefined && { color: entry.color }),
96
- });
97
- }
98
- return meta;
99
- }
100
-
101
- function resolveCardTagColor(
102
- card: KanbanCard,
103
- tagGroups: readonly KanbanTagGroup[],
104
- activeTagGroup: string | null
105
- ): string | undefined {
106
- if (!activeTagGroup) return card.color;
107
- const group = tagGroups.find(
108
- (g) => g.name.toLowerCase() === activeTagGroup.toLowerCase()
109
- );
110
- if (!group) return card.color;
111
- const tagValue = card.tags[tagAttrKey(group.name)];
112
- const value = tagValue ?? group.defaultValue;
113
- if (!value) return undefined;
114
- const entry = group.entries.find(
115
- (e) => e.value.toLowerCase() === value.toLowerCase()
116
- );
117
- return entry?.color;
118
- }
119
-
120
- // ============================================================
121
- // Layout computation
122
- // ============================================================
123
-
124
- interface ColumnLayout {
125
- x: number;
126
- y: number;
127
- width: number;
128
- height: number;
129
- column: KanbanColumn;
130
- cardLayouts: CardLayout[];
131
- }
132
-
133
- interface CardLayout {
134
- x: number;
135
- y: number;
136
- width: number;
137
- height: number;
138
- card: KanbanCard;
139
- }
140
-
141
- function computeLayout(
142
- parsed: ParsedKanban,
143
- _palette: PaletteColors,
144
- collapsedColumns?: Set<string>,
145
- hiddenMetaGroups?: string[],
146
- sDiagramPadding = DIAGRAM_PADDING,
147
- sTitleHeight = TITLE_HEIGHT,
148
- sCardTitleFontSize = CARD_TITLE_FONT_SIZE,
149
- sColumnHeaderFontSize = COLUMN_HEADER_FONT_SIZE,
150
- sColumnHeaderHeight = COLUMN_HEADER_HEIGHT,
151
- sColumnPadding = COLUMN_PADDING,
152
- sCardPaddingX = CARD_PADDING_X,
153
- sCardPaddingY = CARD_PADDING_Y,
154
- sCardSeparatorGap = CARD_SEPARATOR_GAP,
155
- sCardMetaLineHeight = CARD_META_LINE_HEIGHT,
156
- sCardHeaderHeight = CARD_HEADER_HEIGHT,
157
- sCardMetaFontSize = CARD_META_FONT_SIZE,
158
- sCardGap = CARD_GAP,
159
- sColumnMinWidth = COLUMN_MIN_WIDTH,
160
- sColumnGap = COLUMN_GAP,
161
- sCollapsedColumnWidth = COLLAPSED_COLUMN_WIDTH
162
- ): { columns: ColumnLayout[]; totalWidth: number; totalHeight: number } {
163
- const showTitle = !!parsed.title && parsed.options['no-title'] !== 'on';
164
- const headerHeight = showTitle ? sTitleHeight + 8 : 0;
165
- const startY = sDiagramPadding + headerHeight;
166
-
167
- const columnLayouts: ColumnLayout[] = [];
168
-
169
- let maxColumnHeight = 0;
170
-
171
- const visibleColumns = parsed.columns.filter((c) => !isArchiveColumn(c.name));
172
-
173
- for (const col of visibleColumns) {
174
- const isCollapsed = collapsedColumns?.has(col.id) ?? false;
175
-
176
- if (isCollapsed) {
177
- columnLayouts.push({
178
- x: 0,
179
- y: startY,
180
- width: sCollapsedColumnWidth,
181
- height: 0,
182
- column: col,
183
- cardLayouts: [],
184
- });
185
- continue;
186
- }
187
-
188
- let maxCardTextWidth = measureText(col.name, sColumnHeaderFontSize);
189
-
190
- const cardLayouts: CardLayout[] = [];
191
- let cardY = sColumnHeaderHeight + sColumnPadding;
192
-
193
- for (const card of col.cards) {
194
- const titleWidth = measureText(card.title, sCardTitleFontSize);
195
- maxCardTextWidth = Math.max(
196
- maxCardTextWidth,
197
- titleWidth + sCardPaddingX * 2
198
- );
199
-
200
- const tagMeta = resolveCardTagMeta(
201
- card,
202
- parsed.tagGroups,
203
- hiddenMetaGroups
204
- );
205
- const metaCount = tagMeta.length + card.details.length;
206
- const metaHeight =
207
- metaCount > 0
208
- ? sCardSeparatorGap +
209
- 1 +
210
- sCardPaddingY +
211
- metaCount * sCardMetaLineHeight
212
- : 0;
213
- const cardHeight = sCardHeaderHeight + sCardPaddingY + metaHeight;
214
-
215
- for (const m of tagMeta) {
216
- const metaW =
217
- measureText(`${m.label}: ${m.value}`, sCardMetaFontSize) +
218
- sCardPaddingX * 2;
219
- maxCardTextWidth = Math.max(maxCardTextWidth, metaW);
220
- }
221
-
222
- cardLayouts.push({
223
- x: sColumnPadding,
224
- y: cardY,
225
- width: 0,
226
- height: cardHeight,
227
- card,
228
- });
229
-
230
- cardY += cardHeight + sCardGap;
231
- }
232
-
233
- const colWidth = Math.max(
234
- sColumnMinWidth,
235
- maxCardTextWidth + sColumnPadding * 2
236
- );
237
-
238
- for (const cl of cardLayouts) {
239
- cl.width = colWidth - sColumnPadding * 2;
240
- }
241
-
242
- const colHeight = cardY + sColumnPadding;
243
- maxColumnHeight = Math.max(maxColumnHeight, colHeight);
244
-
245
- columnLayouts.push({
246
- x: 0,
247
- y: startY,
248
- width: colWidth,
249
- height: colHeight,
250
- column: col,
251
- cardLayouts,
252
- });
253
- }
254
-
255
- let currentX = sDiagramPadding;
256
- for (const cl of columnLayouts) {
257
- cl.x = currentX;
258
- cl.height = maxColumnHeight;
259
- currentX += cl.width + sColumnGap;
260
- }
261
-
262
- const totalWidth = currentX - sColumnGap + sDiagramPadding;
263
- const totalHeight = startY + maxColumnHeight + sDiagramPadding;
264
-
265
- return { columns: columnLayouts, totalWidth, totalHeight };
266
- }
267
-
268
- // ============================================================
269
- // Render function
270
- // ============================================================
271
-
272
- export function renderKanban(
273
- container: HTMLElement,
274
- parsed: ParsedKanban,
275
- palette: PaletteColors,
276
- isDark: boolean,
277
- options?: KanbanInteractiveOptions
278
- ): void {
279
- const exportDims = options?.exportDims;
280
- const activeTagGroup = options?.activeTagGroup ?? null;
281
- const onSwimlaneChange = options?.onSwimlaneChange;
282
- const collapsedLanes = options?.collapsedLanes;
283
- // Fall back to the columns declared collapsed in source (`[Column] collapsed:
284
- // true`) when no interactive set is supplied — so a bare render honors the
285
- // marker. Interactive callers pass their own set, seeded from source.
286
- const collapsedColumns =
287
- options?.collapsedColumns ??
288
- new Set(parsed.columns.filter((c) => c.collapsed).map((c) => c.id));
289
- const compactMeta = options?.compactMeta ?? false;
290
- const solid = parsed.options['solid-fill'] === 'on';
291
- const requestedSwimlane = options?.currentSwimlaneGroup ?? null;
292
- const swimlaneGroup = requestedSwimlane
293
- ? (parsed.tagGroups.find(
294
- (g) => g.name.toLowerCase() === requestedSwimlane.toLowerCase()
295
- ) ?? null)
296
- : null;
297
-
298
- const hiddenMetaGroups: string[] = [];
299
- if (compactMeta) {
300
- if (activeTagGroup) hiddenMetaGroups.push(activeTagGroup.toLowerCase());
301
- if (requestedSwimlane)
302
- hiddenMetaGroups.push(requestedSwimlane.toLowerCase());
303
- }
304
-
305
- const visibleColumns = parsed.columns.filter((c) => !isArchiveColumn(c.name));
306
- const colCount = Math.max(1, visibleColumns.length);
307
- const idealWidth =
308
- colCount * COLUMN_MIN_WIDTH +
309
- (colCount - 1) * COLUMN_GAP +
310
- 2 * DIAGRAM_PADDING;
311
- const containerWidth =
312
- exportDims?.width ?? container.getBoundingClientRect().width;
313
- const ctx =
314
- exportDims || containerWidth <= 0
315
- ? ScaleContext.identity()
316
- : ScaleContext.from(containerWidth, idealWidth);
317
-
318
- const sDiagramPadding = ctx.aesthetic(DIAGRAM_PADDING);
319
- const sColumnGap = ctx.aesthetic(COLUMN_GAP);
320
- const sColumnHeaderHeight = ctx.structural(COLUMN_HEADER_HEIGHT);
321
- const sColumnPadding = ctx.aesthetic(COLUMN_PADDING);
322
- const sColumnMinWidth = ctx.structural(COLUMN_MIN_WIDTH);
323
- const sCardHeaderHeight = ctx.structural(CARD_HEADER_HEIGHT);
324
- const sCardMetaLineHeight = ctx.structural(CARD_META_LINE_HEIGHT);
325
- const sCardSeparatorGap = ctx.structural(CARD_SEPARATOR_GAP);
326
- const sCardGap = ctx.aesthetic(CARD_GAP);
327
- const sCardRadius = ctx.structural(CARD_RADIUS);
328
- const sCardPaddingX = ctx.aesthetic(CARD_PADDING_X);
329
- const sCardPaddingY = ctx.aesthetic(CARD_PADDING_Y);
330
- const sCardStrokeWidth = ctx.structural(CARD_STROKE_WIDTH);
331
- const sTitleHeight = ctx.structural(TITLE_HEIGHT);
332
- const sColumnHeaderFontSize = ctx.text(COLUMN_HEADER_FONT_SIZE);
333
- const sCardTitleFontSize = ctx.text(CARD_TITLE_FONT_SIZE);
334
- const sCardMetaFontSize = ctx.text(CARD_META_FONT_SIZE);
335
- const sWipFontSize = ctx.text(WIP_FONT_SIZE);
336
- const sColumnRadius = ctx.structural(COLUMN_RADIUS);
337
- const sColumnHeaderRadius = ctx.structural(COLUMN_HEADER_RADIUS);
338
- const sCollapsedColumnWidth = ctx.structural(COLLAPSED_COLUMN_WIDTH);
339
- const sCollapsedLaneHeight = ctx.structural(COLLAPSED_LANE_HEIGHT);
340
- const sTitleFontSize = ctx.text(TITLE_FONT_SIZE);
341
- const sLaneHeaderWidth = ctx.structural(LANE_HEADER_WIDTH);
342
- const sLaneGap = ctx.aesthetic(LANE_GAP);
343
-
344
- const layout = computeLayout(
345
- parsed,
346
- palette,
347
- collapsedColumns,
348
- hiddenMetaGroups,
349
- sDiagramPadding,
350
- sTitleHeight,
351
- sCardTitleFontSize,
352
- sColumnHeaderFontSize,
353
- sColumnHeaderHeight,
354
- sColumnPadding,
355
- sCardPaddingX,
356
- sCardPaddingY,
357
- sCardSeparatorGap,
358
- sCardMetaLineHeight,
359
- sCardHeaderHeight,
360
- sCardMetaFontSize,
361
- sCardGap,
362
- sColumnMinWidth,
363
- sColumnGap,
364
- sCollapsedColumnWidth
365
- );
366
-
367
- const width = exportDims?.width ?? layout.totalWidth;
368
- const height = exportDims?.height ?? layout.totalHeight;
369
-
370
- container.innerHTML = '';
371
-
372
- const svg = d3Selection
373
- .select(container)
374
- .append('svg')
375
- .attr('xmlns', 'http://www.w3.org/2000/svg')
376
- .attr('width', width)
377
- .attr('height', height)
378
- .attr('viewBox', `0 0 ${width} ${height}`)
379
- .attr('preserveAspectRatio', 'xMidYMin meet')
380
- .attr('font-family', FONT_FAMILY)
381
- .style('background', palette.bg);
382
-
383
- if (ctx.isBelowFloor) {
384
- svg.attr('width', '100%');
385
- }
386
-
387
- const showTopTitle = !!parsed.title && parsed.options['no-title'] !== 'on';
388
- if (showTopTitle) {
389
- svg
390
- .append('text')
391
- .attr('class', 'chart-title')
392
- .attr('data-line-number', parsed.titleLineNumber ?? 0)
393
- .attr('x', sDiagramPadding)
394
- .attr('y', sDiagramPadding + sTitleFontSize)
395
- .attr('font-size', sTitleFontSize)
396
- .attr('font-weight', TITLE_FONT_WEIGHT)
397
- .attr('fill', palette.text)
398
- .text(parsed.title!);
399
- }
400
-
401
- if (parsed.tagGroups.length > 0) {
402
- const titleTextWidth = showTopTitle
403
- ? measureLegendText(parsed.title!, sTitleFontSize) + 16
404
- : 0;
405
- const legendX = sDiagramPadding + titleTextWidth;
406
- const legendConfig: LegendConfig = {
407
- groups: parsed.tagGroups,
408
- position: { placement: 'top-center', titleRelation: 'inline-with-title' },
409
- mode: options?.exportMode ? 'export' : 'preview',
410
- };
411
- const legendH = getMaxLegendReservedHeight(
412
- legendConfig,
413
- width - legendX - sDiagramPadding
414
- );
415
- const legendY = sDiagramPadding + (sTitleFontSize - legendH) / 2;
416
- const legendG = svg
417
- .append('g')
418
- .attr('class', 'kanban-legend')
419
- .attr('transform', `translate(${legendX},${legendY})`);
420
-
421
- const showSwimlaneIcon = !!onSwimlaneChange && !exportDims;
422
-
423
- const legendCallbacks: LegendCallbacks | undefined = showSwimlaneIcon
424
- ? {
425
- onGroupRendered: (groupName, groupEl, isActive) => {
426
- const isCurrent =
427
- swimlaneGroup?.name.toLowerCase() === groupName.toLowerCase();
428
- const textW = measureLegendText(groupName, 11);
429
- const iconX = isActive ? 4 + 6 + textW + 6 : 8 + textW + 4;
430
- const iconY = (LEGEND_HEIGHT - 7) / 2;
431
- const iconEl = drawSwimlaneIcon(
432
- groupEl,
433
- iconX,
434
- iconY,
435
- isCurrent,
436
- palette
437
- );
438
- iconEl.append('title').text(`Group by ${groupName}`);
439
- iconEl.style('cursor', 'pointer').on('click', (event: Event) => {
440
- event.stopPropagation();
441
- onSwimlaneChange?.(isCurrent ? null : groupName);
442
- });
443
- },
444
- }
445
- : undefined;
446
-
447
- renderIntegratedLegend(legendG, {
448
- ...legendConfig,
449
- palette,
450
- isDark,
451
- width: width - legendX - sDiagramPadding,
452
- activeGroup: activeTagGroup ?? null,
453
- ...(legendCallbacks !== undefined && { callbacks: legendCallbacks }),
454
- });
455
- }
456
-
457
- if (swimlaneGroup) {
458
- renderSwimlaneBoard(
459
- svg,
460
- parsed,
461
- layout,
462
- swimlaneGroup,
463
- palette,
464
- isDark,
465
- activeTagGroup,
466
- collapsedLanes,
467
- collapsedColumns,
468
- hiddenMetaGroups,
469
- sDiagramPadding,
470
- sTitleHeight,
471
- sLaneHeaderWidth,
472
- sColumnGap,
473
- sCollapsedColumnWidth,
474
- sColumnHeaderHeight,
475
- sColumnPadding,
476
- sCardHeaderHeight,
477
- sCardPaddingY,
478
- sCardGap,
479
- sCollapsedLaneHeight,
480
- sLaneGap,
481
- sCardSeparatorGap,
482
- sCardMetaLineHeight,
483
- sColumnHeaderFontSize,
484
- sColumnRadius,
485
- sColumnHeaderRadius,
486
- sWipFontSize,
487
- sCardRadius,
488
- sCardPaddingX,
489
- sCardStrokeWidth,
490
- sCardTitleFontSize,
491
- sCardMetaFontSize
492
- );
493
- return;
494
- }
495
-
496
- const defaultColBg = isDark
497
- ? mix(palette.surface, palette.bg, 50)
498
- : mix(palette.surface, palette.bg, 30);
499
- const defaultColHeaderBg = isDark
500
- ? mix(palette.surface, palette.bg, 70)
501
- : mix(palette.surface, palette.bg, 50);
502
-
503
- for (const colLayout of layout.columns) {
504
- const col = colLayout.column;
505
- const isColCollapsed = collapsedColumns?.has(col.id) ?? false;
506
- const g = svg
507
- .append('g')
508
- .attr('class', 'kanban-column')
509
- .attr('data-column-id', col.id)
510
- .attr('data-line-number', col.lineNumber);
511
-
512
- const thisColBg = defaultColBg;
513
- const thisColHeaderBg = col.color
514
- ? shapeFill(palette, col.color, isDark, { solid })
515
- : defaultColHeaderBg;
516
- const onHeaderText = col.color
517
- ? contrastText(
518
- thisColHeaderBg,
519
- palette.textOnFillLight,
520
- palette.textOnFillDark
521
- )
522
- : palette.text;
523
-
524
- if (isColCollapsed) {
525
- g.append('rect')
526
- .attr('x', colLayout.x)
527
- .attr('y', colLayout.y)
528
- .attr('width', sCollapsedColumnWidth)
529
- .attr('height', colLayout.height)
530
- .attr('rx', sColumnRadius)
531
- .attr('fill', thisColBg);
532
-
533
- g.append('rect')
534
- .attr('x', colLayout.x)
535
- .attr('y', colLayout.y)
536
- .attr('width', sCollapsedColumnWidth)
537
- .attr('height', sColumnHeaderHeight)
538
- .attr('rx', sColumnHeaderRadius)
539
- .attr('fill', thisColHeaderBg);
540
-
541
- g.append('text')
542
- .attr('x', colLayout.x + sCollapsedColumnWidth / 2)
543
- .attr('y', colLayout.y + sColumnHeaderHeight / 2 + sWipFontSize / 2 - 1)
544
- .attr('font-size', sWipFontSize)
545
- .attr('font-weight', 'bold')
546
- .attr('fill', col.color ? onHeaderText : palette.textMuted)
547
- .attr('text-anchor', 'middle')
548
- .text(String(col.cards.length));
549
-
550
- g.append('text')
551
- .attr('x', colLayout.x + sCollapsedColumnWidth / 2)
552
- .attr('y', colLayout.y + sColumnHeaderHeight + sColumnPadding)
553
- .attr('font-size', sCardTitleFontSize)
554
- .attr('font-weight', 'bold')
555
- .attr('fill', palette.text)
556
- .attr('text-anchor', 'middle')
557
- .attr('writing-mode', 'tb')
558
- .text(col.name);
559
-
560
- continue;
561
- }
562
-
563
- g.append('rect')
564
- .attr('x', colLayout.x)
565
- .attr('y', colLayout.y)
566
- .attr('width', colLayout.width)
567
- .attr('height', colLayout.height)
568
- .attr('rx', sColumnRadius)
569
- .attr('fill', thisColBg);
570
-
571
- g.append('rect')
572
- .attr('x', colLayout.x)
573
- .attr('y', colLayout.y)
574
- .attr('width', colLayout.width)
575
- .attr('height', sColumnHeaderHeight)
576
- .attr('rx', sColumnHeaderRadius)
577
- .attr('fill', thisColHeaderBg);
578
-
579
- g.append('text')
580
- .attr('x', colLayout.x + sColumnPadding)
581
- .attr(
582
- 'y',
583
- colLayout.y + sColumnHeaderHeight / 2 + sColumnHeaderFontSize / 2 - 2
584
- )
585
- .attr('font-size', sColumnHeaderFontSize)
586
- .attr('font-weight', 'bold')
587
- .attr('fill', onHeaderText)
588
- .text(col.name);
589
-
590
- {
591
- const wipExceeded =
592
- col.wipLimit != null && col.cards.length > col.wipLimit;
593
- const badgeText =
594
- col.wipLimit != null
595
- ? `${col.cards.length}/${col.wipLimit}`
596
- : String(col.cards.length);
597
- g.append('text')
598
- .attr('x', colLayout.x + colLayout.width - sColumnPadding)
599
- .attr('y', colLayout.y + sColumnHeaderHeight / 2 + sWipFontSize / 2 - 1)
600
- .attr('text-anchor', 'end')
601
- .attr('font-size', sWipFontSize)
602
- .attr(
603
- 'fill',
604
- wipExceeded
605
- ? palette.colors.red
606
- : col.color
607
- ? onHeaderText
608
- : palette.textMuted
609
- )
610
- .attr('font-weight', wipExceeded ? 'bold' : 'normal')
611
- .text(badgeText);
612
- }
613
-
614
- for (const cardLayout of colLayout.cardLayouts) {
615
- const card = cardLayout.card;
616
- const resolvedColor = resolveCardTagColor(
617
- card,
618
- parsed.tagGroups,
619
- activeTagGroup ?? null
620
- );
621
- const tagMeta = resolveCardTagMeta(
622
- card,
623
- parsed.tagGroups,
624
- hiddenMetaGroups
625
- );
626
- const hasMeta = tagMeta.length > 0 || card.details.length > 0;
627
-
628
- const cardFill = shapeFill(
629
- palette,
630
- resolvedColor ?? palette.primary,
631
- isDark,
632
- { solid }
633
- );
634
- const cardStroke = resolvedColor ?? palette.textMuted;
635
- const onCardText = contrastText(
636
- cardFill,
637
- palette.textOnFillLight,
638
- palette.textOnFillDark
639
- );
640
-
641
- const cg = g
642
- .append('g')
643
- .attr('class', 'kanban-card')
644
- .attr('data-card-id', card.id)
645
- .attr('data-line-number', card.lineNumber);
646
-
647
- if (activeTagGroup) {
648
- const tagKey = tagAttrKey(activeTagGroup);
649
- const tagValue = card.tags[tagKey];
650
- const group = parsed.tagGroups.find(
651
- (tg) => tg.name.toLowerCase() === tagKey
652
- );
653
- const value = tagValue ?? group?.defaultValue;
654
- if (value) {
655
- cg.attr(`data-tag-${tagKey}`, value.toLowerCase());
656
- }
657
- }
658
-
659
- const cx = colLayout.x + cardLayout.x;
660
- const cy = colLayout.y + cardLayout.y;
661
-
662
- cg.append('rect')
663
- .attr('x', cx)
664
- .attr('y', cy)
665
- .attr('width', cardLayout.width)
666
- .attr('height', cardLayout.height)
667
- .attr('rx', sCardRadius)
668
- .attr('fill', cardFill)
669
- .attr('stroke', cardStroke)
670
- .attr('stroke-width', sCardStrokeWidth);
671
-
672
- const titleEl = cg
673
- .append('text')
674
- .attr('x', cx + sCardPaddingX)
675
- .attr('y', cy + sCardPaddingY + sCardTitleFontSize)
676
- .attr('font-size', sCardTitleFontSize)
677
- .attr('font-weight', '500')
678
- .attr('fill', onCardText);
679
- renderInlineText(titleEl, card.title, palette, sCardTitleFontSize);
680
-
681
- if (hasMeta) {
682
- const separatorY = cy + sCardHeaderHeight;
683
-
684
- cg.append('line')
685
- .attr('x1', cx)
686
- .attr('y1', separatorY)
687
- .attr('x2', cx + cardLayout.width)
688
- .attr('y2', separatorY)
689
- .attr('stroke', solid ? onCardText : cardStroke)
690
- .attr('stroke-opacity', 0.3)
691
- .attr('stroke-width', 1);
692
-
693
- let metaY = separatorY + sCardSeparatorGap + sCardMetaFontSize;
694
-
695
- for (const meta of tagMeta) {
696
- cg.append('text')
697
- .attr('x', cx + sCardPaddingX)
698
- .attr('y', metaY)
699
- .attr('font-size', sCardMetaFontSize)
700
- .attr('fill', onCardText)
701
- .text(`${meta.label}: `);
702
-
703
- const labelWidth = measureText(`${meta.label}: `, sCardMetaFontSize);
704
- cg.append('text')
705
- .attr('x', cx + sCardPaddingX + labelWidth)
706
- .attr('y', metaY)
707
- .attr('font-size', sCardMetaFontSize)
708
- .attr('fill', onCardText)
709
- .text(meta.value);
710
-
711
- metaY += sCardMetaLineHeight;
712
- }
713
-
714
- for (const detail of card.details) {
715
- const detailEl = cg
716
- .append('text')
717
- .attr('x', cx + sCardPaddingX)
718
- .attr('y', metaY)
719
- .attr('font-size', sCardMetaFontSize)
720
- .attr('fill', onCardText);
721
- renderInlineText(detailEl, detail, palette, sCardMetaFontSize);
722
-
723
- metaY += sCardMetaLineHeight;
724
- }
725
- }
726
- }
727
- }
728
- }
729
-
730
- // ============================================================
731
- // Export convenience function
732
- // ============================================================
733
-
734
- export function renderKanbanForExport(
735
- content: string,
736
- theme: 'light' | 'dark' | 'transparent',
737
- palette: PaletteColors
738
- ): string {
739
- const parsed = parseKanban(content, palette);
740
- if (parsed.error || parsed.columns.length === 0) return '';
741
-
742
- const isDark = theme === 'dark';
743
- const layout = computeLayout(parsed, palette);
744
-
745
- const container = document.createElement('div');
746
- renderKanban(container, parsed, palette, isDark, {
747
- exportDims: { width: layout.totalWidth, height: layout.totalHeight },
748
- exportMode: true,
749
- });
750
-
751
- const svgEl = container.querySelector('svg');
752
- return svgEl?.outerHTML ?? '';
753
- }
754
-
755
- // ============================================================
756
- // Swimlane: icon, bucketing, layout, render
757
- // ============================================================
758
-
759
- const LANE_HEADER_WIDTH = 140;
760
- const LANE_GAP = 14;
761
-
762
- function drawSwimlaneIcon(
763
- parent: D3Sel,
764
- x: number,
765
- y: number,
766
- isActive: boolean,
767
- palette: PaletteColors
768
- ): D3Sel {
769
- const iconG = parent
770
- .append('g')
771
- .attr('class', 'kanban-swimlane-icon')
772
- .attr('transform', `translate(${x}, ${y})`);
773
-
774
- // Transparent hit area so the whole icon (not just the 2px bars) is clickable
775
- iconG
776
- .append('rect')
777
- .attr('x', -5)
778
- .attr('y', -5)
779
- .attr('width', 22)
780
- .attr('height', 18)
781
- .attr('fill', 'transparent');
782
-
783
- const color = isActive ? palette.primary : palette.textMuted;
784
- const opacity = isActive ? 1 : 0.35;
785
- const barWidths = [8, 12, 6];
786
- const barH = 2;
787
- const gap = 3;
788
-
789
- for (let i = 0; i < barWidths.length; i++) {
790
- iconG
791
- .append('rect')
792
- .attr('x', 0)
793
- .attr('y', i * gap)
794
- .attr('width', barWidths[i]!)
795
- .attr('height', barH)
796
- .attr('rx', 1)
797
- .attr('fill', color)
798
- .attr('opacity', opacity);
799
- }
800
-
801
- return iconG;
802
- }
803
-
804
- interface SwimlaneBucket {
805
- laneName: string;
806
- laneColor?: string;
807
- isFallback: boolean;
808
- cellsByColumn: Record<string, KanbanCard[]>;
809
- }
810
-
811
- function bucketCardsBySwimlane(
812
- columns: KanbanColumn[],
813
- swimlaneGroup: KanbanTagGroup
814
- ): SwimlaneBucket[] {
815
- const tagKey = tagAttrKey(swimlaneGroup.name);
816
- const buckets = new Map<string, SwimlaneBucket>();
817
-
818
- // Seed lanes from declaration order
819
- for (const entry of swimlaneGroup.entries) {
820
- buckets.set(entry.value.toLowerCase(), {
821
- laneName: entry.value,
822
- laneColor: entry.color,
823
- isFallback: false,
824
- cellsByColumn: {},
825
- });
826
- }
827
-
828
- const fallbackKey = `__no_${tagKey}__`;
829
-
830
- for (const col of columns) {
831
- for (const card of col.cards) {
832
- const raw = card.tags[tagKey] ?? swimlaneGroup.defaultValue;
833
- let bucketKey: string;
834
- if (raw && buckets.has(raw.toLowerCase())) {
835
- bucketKey = raw.toLowerCase();
836
- } else {
837
- if (!buckets.has(fallbackKey)) {
838
- buckets.set(fallbackKey, {
839
- laneName: `No ${swimlaneGroup.name}`,
840
- isFallback: true,
841
- cellsByColumn: {},
842
- });
843
- }
844
- bucketKey = fallbackKey;
845
- }
846
- const bucket = buckets.get(bucketKey)!;
847
- (bucket.cellsByColumn[col.id] ??= []).push(card);
848
- }
849
- }
850
-
851
- // Drop empty seeded lanes that have no cards (and aren't fallback).
852
- // Phase A choice: keep entries even if empty so users see the structure.
853
- return Array.from(buckets.values());
854
- }
855
-
856
- interface SwimlaneCellLayout {
857
- column: KanbanColumn;
858
- cards: KanbanCard[];
859
- cardLayouts: CardLayout[];
860
- }
861
-
862
- interface SwimlaneLaneLayout {
863
- bucket: SwimlaneBucket;
864
- y: number;
865
- height: number;
866
- cells: SwimlaneCellLayout[];
867
- }
868
-
869
- interface SwimlaneBoardLayout {
870
- columnXs: { column: KanbanColumn; x: number; width: number }[];
871
- lanes: SwimlaneLaneLayout[];
872
- totalWidth: number;
873
- totalHeight: number;
874
- startY: number;
875
- }
876
-
877
- function computeCardHeight(
878
- card: KanbanCard,
879
- tagGroups: readonly KanbanTagGroup[],
880
- hiddenMetaGroups?: string[],
881
- sCardSeparatorGap = CARD_SEPARATOR_GAP,
882
- sCardPaddingY = CARD_PADDING_Y,
883
- sCardMetaLineHeight = CARD_META_LINE_HEIGHT,
884
- sCardHeaderHeight = CARD_HEADER_HEIGHT
885
- ) {
886
- const tagMeta = resolveCardTagMeta(card, tagGroups, hiddenMetaGroups);
887
- const metaCount = tagMeta.length + card.details.length;
888
- const metaHeight =
889
- metaCount > 0
890
- ? sCardSeparatorGap + 1 + sCardPaddingY + metaCount * sCardMetaLineHeight
891
- : 0;
892
- return sCardHeaderHeight + sCardPaddingY + metaHeight;
893
- }
894
-
895
- function computeSwimlaneLayout(
896
- parsed: ParsedKanban,
897
- buckets: SwimlaneBucket[],
898
- baseLayout: { columns: ColumnLayout[] },
899
- collapsedLanes?: Set<string>,
900
- collapsedColumns?: Set<string>,
901
- hiddenMetaGroups?: string[],
902
- sDiagramPadding = DIAGRAM_PADDING,
903
- sTitleHeight = TITLE_HEIGHT,
904
- sLaneHeaderWidth = LANE_HEADER_WIDTH,
905
- sColumnGap = COLUMN_GAP,
906
- sCollapsedColumnWidth = COLLAPSED_COLUMN_WIDTH,
907
- sColumnHeaderHeight = COLUMN_HEADER_HEIGHT,
908
- sColumnPadding = COLUMN_PADDING,
909
- sCardHeaderHeight = CARD_HEADER_HEIGHT,
910
- sCardPaddingY = CARD_PADDING_Y,
911
- sCardGap = CARD_GAP,
912
- sCollapsedLaneHeight = COLLAPSED_LANE_HEIGHT,
913
- sLaneGap = LANE_GAP,
914
- sCardSeparatorGap = CARD_SEPARATOR_GAP,
915
- sCardMetaLineHeight = CARD_META_LINE_HEIGHT
916
- ): SwimlaneBoardLayout {
917
- const headerHeight =
918
- parsed.title && parsed.options['no-title'] !== 'on' ? sTitleHeight + 8 : 0;
919
- const startY = sDiagramPadding + headerHeight;
920
-
921
- const columnXs: SwimlaneBoardLayout['columnXs'] = [];
922
- let currentX = sDiagramPadding + sLaneHeaderWidth;
923
- for (const col of baseLayout.columns) {
924
- const isColCollapsed = collapsedColumns?.has(col.column.id) ?? false;
925
- const w = isColCollapsed ? sCollapsedColumnWidth : col.width;
926
- columnXs.push({ column: col.column, x: currentX, width: w });
927
- currentX += w + sColumnGap;
928
- }
929
- const totalWidth = currentX - sColumnGap + sDiagramPadding;
930
-
931
- const lanes: SwimlaneLaneLayout[] = [];
932
- let laneY = startY + sColumnHeaderHeight + sColumnPadding;
933
- const minCellH = sCardHeaderHeight + sCardPaddingY + sCardGap;
934
-
935
- for (const bucket of buckets) {
936
- const isLaneCollapsed = collapsedLanes?.has(bucket.laneName) ?? false;
937
-
938
- if (isLaneCollapsed) {
939
- const cells: SwimlaneCellLayout[] = columnXs.map((colInfo) => ({
940
- column: colInfo.column,
941
- cards: bucket.cellsByColumn[colInfo.column.id] ?? [],
942
- cardLayouts: [],
943
- }));
944
- lanes.push({ bucket, y: laneY, height: sCollapsedLaneHeight, cells });
945
- laneY += sCollapsedLaneHeight + sLaneGap;
946
- continue;
947
- }
948
-
949
- let maxCellH = minCellH;
950
- const cellsTmp: { column: KanbanColumn; cards: KanbanCard[]; h: number }[] =
951
- [];
952
-
953
- for (const colInfo of columnXs) {
954
- const isColCollapsed = collapsedColumns?.has(colInfo.column.id) ?? false;
955
- const cards = bucket.cellsByColumn[colInfo.column.id] ?? [];
956
- if (isColCollapsed) {
957
- cellsTmp.push({ column: colInfo.column, cards, h: 0 });
958
- continue;
959
- }
960
- let h = 0;
961
- for (const c of cards) {
962
- h +=
963
- computeCardHeight(
964
- c,
965
- parsed.tagGroups,
966
- hiddenMetaGroups,
967
- sCardSeparatorGap,
968
- sCardPaddingY,
969
- sCardMetaLineHeight,
970
- sCardHeaderHeight
971
- ) + sCardGap;
972
- }
973
- h = Math.max(h - (cards.length > 0 ? sCardGap : 0), 0);
974
- cellsTmp.push({ column: colInfo.column, cards, h });
975
- if (h > maxCellH) maxCellH = h;
976
- }
977
-
978
- const laneHeight = Math.max(maxCellH, minCellH);
979
-
980
- const cells: SwimlaneCellLayout[] = cellsTmp.map((tmp, i) => {
981
- const colInfo = columnXs[i]!;
982
- const isColCollapsed = collapsedColumns?.has(colInfo.column.id) ?? false;
983
- if (isColCollapsed) {
984
- return { column: tmp.column, cards: tmp.cards, cardLayouts: [] };
985
- }
986
- const cardLayouts: CardLayout[] = [];
987
- let cy = 0;
988
- for (const card of tmp.cards) {
989
- const ch = computeCardHeight(
990
- card,
991
- parsed.tagGroups,
992
- hiddenMetaGroups,
993
- sCardSeparatorGap,
994
- sCardPaddingY,
995
- sCardMetaLineHeight,
996
- sCardHeaderHeight
997
- );
998
- cardLayouts.push({
999
- x: colInfo.x + sColumnPadding,
1000
- y: laneY + cy,
1001
- width: colInfo.width - sColumnPadding * 2,
1002
- height: ch,
1003
- card,
1004
- });
1005
- cy += ch + sCardGap;
1006
- }
1007
- return { column: tmp.column, cards: tmp.cards, cardLayouts };
1008
- });
1009
-
1010
- lanes.push({ bucket, y: laneY, height: laneHeight, cells });
1011
- laneY += laneHeight + sLaneGap;
1012
- }
1013
-
1014
- const totalHeight = laneY - sLaneGap + sColumnPadding + sDiagramPadding;
1015
-
1016
- return { columnXs, lanes, totalWidth, totalHeight, startY };
1017
- }
1018
-
1019
- function renderSwimlaneBoard(
1020
- svg: D3Sel,
1021
- parsed: ParsedKanban,
1022
- baseLayout: {
1023
- columns: ColumnLayout[];
1024
- totalWidth: number;
1025
- totalHeight: number;
1026
- },
1027
- swimlaneGroup: KanbanTagGroup,
1028
- palette: PaletteColors,
1029
- isDark: boolean,
1030
- activeTagGroup: string | null,
1031
- collapsedLanes?: Set<string>,
1032
- collapsedColumns?: Set<string>,
1033
- hiddenMetaGroups?: string[],
1034
- sDiagramPadding = DIAGRAM_PADDING,
1035
- sTitleHeight = TITLE_HEIGHT,
1036
- sLaneHeaderWidth = LANE_HEADER_WIDTH,
1037
- sColumnGap = COLUMN_GAP,
1038
- sCollapsedColumnWidth = COLLAPSED_COLUMN_WIDTH,
1039
- sColumnHeaderHeight = COLUMN_HEADER_HEIGHT,
1040
- sColumnPadding = COLUMN_PADDING,
1041
- sCardHeaderHeight = CARD_HEADER_HEIGHT,
1042
- sCardPaddingY = CARD_PADDING_Y,
1043
- sCardGap = CARD_GAP,
1044
- sCollapsedLaneHeight = COLLAPSED_LANE_HEIGHT,
1045
- sLaneGap = LANE_GAP,
1046
- sCardSeparatorGap = CARD_SEPARATOR_GAP,
1047
- sCardMetaLineHeight = CARD_META_LINE_HEIGHT,
1048
- sColumnHeaderFontSize = COLUMN_HEADER_FONT_SIZE,
1049
- sColumnRadius = COLUMN_RADIUS,
1050
- sColumnHeaderRadius = COLUMN_HEADER_RADIUS,
1051
- sWipFontSize = WIP_FONT_SIZE,
1052
- sCardRadius = CARD_RADIUS,
1053
- sCardPaddingX = CARD_PADDING_X,
1054
- sCardStrokeWidth = CARD_STROKE_WIDTH,
1055
- sCardTitleFontSize = CARD_TITLE_FONT_SIZE,
1056
- sCardMetaFontSize = CARD_META_FONT_SIZE
1057
- ): void {
1058
- const visibleColumns = parsed.columns.filter((c) => !isArchiveColumn(c.name));
1059
- const buckets = bucketCardsBySwimlane(visibleColumns, swimlaneGroup);
1060
- const grid = computeSwimlaneLayout(
1061
- parsed,
1062
- buckets,
1063
- baseLayout,
1064
- collapsedLanes,
1065
- collapsedColumns,
1066
- hiddenMetaGroups,
1067
- sDiagramPadding,
1068
- sTitleHeight,
1069
- sLaneHeaderWidth,
1070
- sColumnGap,
1071
- sCollapsedColumnWidth,
1072
- sColumnHeaderHeight,
1073
- sColumnPadding,
1074
- sCardHeaderHeight,
1075
- sCardPaddingY,
1076
- sCardGap,
1077
- sCollapsedLaneHeight,
1078
- sLaneGap,
1079
- sCardSeparatorGap,
1080
- sCardMetaLineHeight
1081
- );
1082
-
1083
- const currentW = parseFloat(svg.attr('width') || '0');
1084
- const currentH = parseFloat(svg.attr('height') || '0');
1085
- if (grid.totalWidth > currentW) {
1086
- svg.attr('width', grid.totalWidth);
1087
- svg.attr(
1088
- 'viewBox',
1089
- `0 0 ${grid.totalWidth} ${Math.max(currentH, grid.totalHeight)}`
1090
- );
1091
- }
1092
- if (grid.totalHeight > currentH) {
1093
- svg.attr('height', grid.totalHeight);
1094
- svg.attr(
1095
- 'viewBox',
1096
- `0 0 ${Math.max(currentW, grid.totalWidth)} ${grid.totalHeight}`
1097
- );
1098
- }
1099
-
1100
- const defaultColBg = isDark
1101
- ? mix(palette.surface, palette.bg, 50)
1102
- : mix(palette.surface, palette.bg, 30);
1103
- const defaultColHeaderBg = isDark
1104
- ? mix(palette.surface, palette.bg, 70)
1105
- : mix(palette.surface, palette.bg, 50);
1106
-
1107
- for (const colInfo of grid.columnXs) {
1108
- const col = colInfo.column;
1109
- const isColCollapsed = collapsedColumns?.has(col.id) ?? false;
1110
- const headerG = svg
1111
- .append('g')
1112
- .attr('class', 'kanban-column kanban-column-header')
1113
- .attr('data-column-id', col.id)
1114
- .attr('data-line-number', col.lineNumber);
1115
-
1116
- const colHeaderBg = col.color
1117
- ? shapeFill(palette, col.color, isDark, {
1118
- solid: parsed.options['solid-fill'] === 'on',
1119
- })
1120
- : defaultColHeaderBg;
1121
-
1122
- headerG
1123
- .append('rect')
1124
- .attr('x', colInfo.x)
1125
- .attr('y', grid.startY)
1126
- .attr('width', colInfo.width)
1127
- .attr('height', sColumnHeaderHeight)
1128
- .attr('rx', sColumnHeaderRadius)
1129
- .attr('fill', colHeaderBg);
1130
-
1131
- if (isColCollapsed) {
1132
- headerG
1133
- .append('text')
1134
- .attr('x', colInfo.x + colInfo.width / 2)
1135
- .attr('y', grid.startY + sColumnHeaderHeight / 2 + sWipFontSize / 2 - 1)
1136
- .attr('font-size', sWipFontSize)
1137
- .attr('font-weight', 'bold')
1138
- .attr('fill', palette.textMuted)
1139
- .attr('text-anchor', 'middle')
1140
- .text(String(col.cards.length));
1141
- } else {
1142
- headerG
1143
- .append('text')
1144
- .attr('x', colInfo.x + sColumnPadding)
1145
- .attr(
1146
- 'y',
1147
- grid.startY + sColumnHeaderHeight / 2 + sColumnHeaderFontSize / 2 - 2
1148
- )
1149
- .attr('font-size', sColumnHeaderFontSize)
1150
- .attr('font-weight', 'bold')
1151
- .attr('fill', palette.text)
1152
- .text(col.name);
1153
-
1154
- const wipExceeded =
1155
- col.wipLimit != null && col.cards.length > col.wipLimit;
1156
- const badgeText =
1157
- col.wipLimit != null
1158
- ? `${col.cards.length}/${col.wipLimit}`
1159
- : String(col.cards.length);
1160
- headerG
1161
- .append('text')
1162
- .attr('x', colInfo.x + colInfo.width - sColumnPadding)
1163
- .attr('y', grid.startY + sColumnHeaderHeight / 2 + sWipFontSize / 2 - 1)
1164
- .attr('text-anchor', 'end')
1165
- .attr('font-size', sWipFontSize)
1166
- .attr('fill', wipExceeded ? palette.colors.red : palette.textMuted)
1167
- .attr('font-weight', wipExceeded ? 'bold' : 'normal')
1168
- .text(badgeText);
1169
- }
1170
- }
1171
-
1172
- for (const lane of grid.lanes) {
1173
- const isLaneCollapsed = collapsedLanes?.has(lane.bucket.laneName) ?? false;
1174
- const laneG = svg
1175
- .append('g')
1176
- .attr('class', 'kanban-lane')
1177
- .attr('data-lane-name', lane.bucket.laneName);
1178
-
1179
- const headerG = laneG
1180
- .append('g')
1181
- .attr('class', 'kanban-lane-header')
1182
- .attr(
1183
- 'transform',
1184
- `translate(${sDiagramPadding}, ${lane.y - sColumnPadding})`
1185
- );
1186
-
1187
- headerG
1188
- .append('rect')
1189
- .attr('x', 0)
1190
- .attr('y', 0)
1191
- .attr('width', sLaneHeaderWidth - 8)
1192
- .attr('height', lane.height + sColumnPadding * 2)
1193
- .attr('rx', sColumnRadius)
1194
- .attr('fill', defaultColBg);
1195
-
1196
- let labelX = 10;
1197
- const totalCards = lane.cells.reduce((s, c) => s + c.cards.length, 0);
1198
- if (lane.bucket.laneColor) {
1199
- headerG
1200
- .append('circle')
1201
- .attr('cx', labelX + 4)
1202
- .attr('cy', 16)
1203
- .attr('r', 4)
1204
- .attr('fill', lane.bucket.laneColor);
1205
- labelX += 14;
1206
- }
1207
-
1208
- if (isLaneCollapsed) {
1209
- headerG
1210
- .append('text')
1211
- .attr('x', labelX)
1212
- .attr('y', 20)
1213
- .attr('font-size', 10)
1214
- .attr('fill', palette.textMuted)
1215
- .text(`${lane.bucket.laneName} (${totalCards})`);
1216
- } else {
1217
- headerG
1218
- .append('text')
1219
- .attr('x', labelX)
1220
- .attr('y', 20)
1221
- .attr('font-size', 12)
1222
- .attr('font-weight', 'bold')
1223
- .attr('fill', lane.bucket.isFallback ? palette.textMuted : palette.text)
1224
- .text(lane.bucket.laneName);
1225
- }
1226
-
1227
- if (isLaneCollapsed) {
1228
- for (const cell of lane.cells) {
1229
- const isColCollapsed = collapsedColumns?.has(cell.column.id) ?? false;
1230
- if (cell.cards.length > 0) {
1231
- const colInfo = grid.columnXs.find(
1232
- (c) => c.column.id === cell.column.id
1233
- );
1234
- if (!colInfo) continue;
1235
- const placeholderBg = lane.bucket.laneColor
1236
- ? mix(lane.bucket.laneColor, palette.bg, isDark ? 40 : 28)
1237
- : mix(palette.textMuted, palette.bg, isDark ? 28 : 22);
1238
- const pw = isColCollapsed
1239
- ? sCollapsedColumnWidth - 8
1240
- : colInfo.width - sColumnPadding * 2;
1241
- laneG
1242
- .append('rect')
1243
- .attr('x', colInfo.x + (isColCollapsed ? 4 : sColumnPadding))
1244
- .attr('y', lane.y)
1245
- .attr('width', pw)
1246
- .attr('height', 18)
1247
- .attr('rx', 4)
1248
- .attr('fill', placeholderBg);
1249
- laneG
1250
- .append('text')
1251
- .attr(
1252
- 'x',
1253
- colInfo.x + (isColCollapsed ? 4 : sColumnPadding) + pw / 2
1254
- )
1255
- .attr('y', lane.y + 13)
1256
- .attr('font-size', sWipFontSize)
1257
- .attr('font-weight', 'bold')
1258
- .attr('fill', palette.textMuted)
1259
- .attr('text-anchor', 'middle')
1260
- .text(String(cell.cards.length));
1261
- }
1262
- }
1263
- }
1264
-
1265
- laneG
1266
- .append('line')
1267
- .attr('x1', sDiagramPadding + sLaneHeaderWidth)
1268
- .attr('x2', grid.totalWidth - sDiagramPadding)
1269
- .attr('y1', lane.y + lane.height + sColumnPadding)
1270
- .attr('y2', lane.y + lane.height + sColumnPadding)
1271
- .attr('stroke', palette.border ?? palette.textMuted)
1272
- .attr('stroke-opacity', 0.4)
1273
- .attr('stroke-width', 1);
1274
-
1275
- if (!isLaneCollapsed) {
1276
- for (const cell of lane.cells) {
1277
- const isColCollapsed = collapsedColumns?.has(cell.column.id) ?? false;
1278
- if (isColCollapsed && cell.cards.length > 0) {
1279
- const colInfo = grid.columnXs.find(
1280
- (c) => c.column.id === cell.column.id
1281
- );
1282
- if (colInfo) {
1283
- const placeholderBg = lane.bucket.laneColor
1284
- ? mix(lane.bucket.laneColor, palette.bg, isDark ? 40 : 28)
1285
- : mix(palette.textMuted, palette.bg, isDark ? 28 : 22);
1286
- laneG
1287
- .append('rect')
1288
- .attr('x', colInfo.x + 4)
1289
- .attr('y', lane.y)
1290
- .attr('width', sCollapsedColumnWidth - 8)
1291
- .attr('height', 22)
1292
- .attr('rx', 4)
1293
- .attr('fill', placeholderBg);
1294
- laneG
1295
- .append('text')
1296
- .attr('x', colInfo.x + sCollapsedColumnWidth / 2)
1297
- .attr('y', lane.y + 16)
1298
- .attr('font-size', sWipFontSize)
1299
- .attr('font-weight', 'bold')
1300
- .attr('fill', palette.textMuted)
1301
- .attr('text-anchor', 'middle')
1302
- .text(String(cell.cards.length));
1303
- }
1304
- continue;
1305
- }
1306
- for (const cardLayout of cell.cardLayouts) {
1307
- renderSwimlaneCard(
1308
- laneG,
1309
- cardLayout,
1310
- parsed.tagGroups,
1311
- activeTagGroup,
1312
- palette,
1313
- isDark,
1314
- hiddenMetaGroups,
1315
- parsed.options['solid-fill'] === 'on',
1316
- sCardRadius,
1317
- sCardPaddingX,
1318
- sCardPaddingY,
1319
- sCardStrokeWidth,
1320
- sCardTitleFontSize,
1321
- sCardMetaFontSize,
1322
- sCardHeaderHeight,
1323
- sCardSeparatorGap,
1324
- sCardMetaLineHeight
1325
- );
1326
- }
1327
- }
1328
- }
1329
- }
1330
- }
1331
-
1332
- function renderSwimlaneCard(
1333
- parent: D3Sel,
1334
- cardLayout: CardLayout,
1335
- tagGroups: readonly KanbanTagGroup[],
1336
- activeTagGroup: string | null,
1337
- palette: PaletteColors,
1338
- isDark: boolean,
1339
- hiddenMetaGroups?: string[],
1340
- solid?: boolean,
1341
- sCardRadius = CARD_RADIUS,
1342
- sCardPaddingX = CARD_PADDING_X,
1343
- sCardPaddingY = CARD_PADDING_Y,
1344
- sCardStrokeWidth = CARD_STROKE_WIDTH,
1345
- sCardTitleFontSize = CARD_TITLE_FONT_SIZE,
1346
- sCardMetaFontSize = CARD_META_FONT_SIZE,
1347
- sCardHeaderHeight = CARD_HEADER_HEIGHT,
1348
- sCardSeparatorGap = CARD_SEPARATOR_GAP,
1349
- sCardMetaLineHeight = CARD_META_LINE_HEIGHT
1350
- ): void {
1351
- const card = cardLayout.card;
1352
- const resolvedColor = resolveCardTagColor(card, tagGroups, activeTagGroup);
1353
- const tagMeta = resolveCardTagMeta(card, tagGroups, hiddenMetaGroups);
1354
- const hasMeta = tagMeta.length > 0 || card.details.length > 0;
1355
-
1356
- const cardFill = shapeFill(
1357
- palette,
1358
- resolvedColor ?? palette.primary,
1359
- isDark,
1360
- {
1361
- ...(solid !== undefined && { solid }),
1362
- }
1363
- );
1364
- const cardStroke = resolvedColor ?? palette.textMuted;
1365
- const onCardText = contrastText(
1366
- cardFill,
1367
- palette.textOnFillLight,
1368
- palette.textOnFillDark
1369
- );
1370
-
1371
- const cg = parent
1372
- .append('g')
1373
- .attr('class', 'kanban-card')
1374
- .attr('data-card-id', card.id)
1375
- .attr('data-line-number', card.lineNumber);
1376
-
1377
- if (activeTagGroup) {
1378
- const tagKey = tagAttrKey(activeTagGroup);
1379
- const group = tagGroups.find((tg) => tg.name.toLowerCase() === tagKey);
1380
- const value = card.tags[tagKey] ?? group?.defaultValue;
1381
- if (value) {
1382
- cg.attr(`data-tag-${tagKey}`, value.toLowerCase());
1383
- }
1384
- }
1385
-
1386
- const cx = cardLayout.x;
1387
- const cy = cardLayout.y;
1388
-
1389
- cg.append('rect')
1390
- .attr('x', cx)
1391
- .attr('y', cy)
1392
- .attr('width', cardLayout.width)
1393
- .attr('height', cardLayout.height)
1394
- .attr('rx', sCardRadius)
1395
- .attr('fill', cardFill)
1396
- .attr('stroke', cardStroke)
1397
- .attr('stroke-width', sCardStrokeWidth);
1398
-
1399
- const titleEl = cg
1400
- .append('text')
1401
- .attr('x', cx + sCardPaddingX)
1402
- .attr('y', cy + sCardPaddingY + sCardTitleFontSize)
1403
- .attr('font-size', sCardTitleFontSize)
1404
- .attr('font-weight', '500')
1405
- .attr('fill', onCardText);
1406
- renderInlineText(titleEl, card.title, palette, sCardTitleFontSize);
1407
-
1408
- if (hasMeta) {
1409
- const separatorY = cy + sCardHeaderHeight;
1410
- cg.append('line')
1411
- .attr('x1', cx)
1412
- .attr('y1', separatorY)
1413
- .attr('x2', cx + cardLayout.width)
1414
- .attr('y2', separatorY)
1415
- .attr('stroke', cardStroke)
1416
- .attr('stroke-opacity', 0.3)
1417
- .attr('stroke-width', 1);
1418
-
1419
- let metaY = separatorY + sCardSeparatorGap + sCardMetaFontSize;
1420
-
1421
- for (const meta of tagMeta) {
1422
- cg.append('text')
1423
- .attr('x', cx + sCardPaddingX)
1424
- .attr('y', metaY)
1425
- .attr('font-size', sCardMetaFontSize)
1426
- .attr('fill', palette.textMuted)
1427
- .text(`${meta.label}: `);
1428
- const labelWidth = measureText(`${meta.label}: `, sCardMetaFontSize);
1429
- cg.append('text')
1430
- .attr('x', cx + sCardPaddingX + labelWidth)
1431
- .attr('y', metaY)
1432
- .attr('font-size', sCardMetaFontSize)
1433
- .attr('fill', onCardText)
1434
- .text(meta.value);
1435
- metaY += sCardMetaLineHeight;
1436
- }
1437
-
1438
- for (const detail of card.details) {
1439
- const detailEl = cg
1440
- .append('text')
1441
- .attr('x', cx + sCardPaddingX)
1442
- .attr('y', metaY)
1443
- .attr('font-size', sCardMetaFontSize)
1444
- .attr('fill', palette.textMuted);
1445
- renderInlineText(detailEl, detail, palette, sCardMetaFontSize);
1446
- metaY += sCardMetaLineHeight;
1447
- }
1448
- }
1449
- }