@k2b/ui 0.53.0 → 0.54.0

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 (313) hide show
  1. package/dist/base.css +103 -0
  2. package/dist/browser/actions/SortableList.js +174 -0
  3. package/dist/browser/actions/SortableList.js.map +1 -0
  4. package/dist/browser/actions/Toolbar.js +186 -101
  5. package/dist/browser/actions/Toolbar.js.map +1 -1
  6. package/dist/browser/actions/drag-and-drop.js +2 -1
  7. package/dist/browser/actions/drag-and-drop.js.map +1 -1
  8. package/dist/browser/actions/index.js +1 -0
  9. package/dist/browser/actions/index.js.map +1 -1
  10. package/dist/browser/actions/sortable-list-messages.js +35 -0
  11. package/dist/browser/actions/sortable-list-messages.js.map +1 -0
  12. package/dist/browser/chart-inspection.js +2 -1
  13. package/dist/browser/chart-inspection.js.map +1 -1
  14. package/dist/browser/charts/core/balance-flow-data.js +93 -0
  15. package/dist/browser/charts/core/balance-flow-data.js.map +1 -0
  16. package/dist/browser/charts/core/balance-flow-fields.js +19 -0
  17. package/dist/browser/charts/core/balance-flow-fields.js.map +1 -0
  18. package/dist/browser/charts/core/balance-flow-frame.js +44 -0
  19. package/dist/browser/charts/core/balance-flow-frame.js.map +1 -0
  20. package/dist/browser/charts/core/balance-flow-messages.js +49 -0
  21. package/dist/browser/charts/core/balance-flow-messages.js.map +1 -0
  22. package/dist/browser/charts/core/balance-flow-size.js +42 -0
  23. package/dist/browser/charts/core/balance-flow-size.js.map +1 -0
  24. package/dist/browser/charts/core/balance-flow.js +195 -0
  25. package/dist/browser/charts/core/balance-flow.js.map +1 -0
  26. package/dist/browser/charts/core/calendar-layout.js +105 -0
  27. package/dist/browser/charts/core/calendar-layout.js.map +1 -0
  28. package/dist/browser/charts/core/calendar.js +2 -104
  29. package/dist/browser/charts/core/calendar.js.map +1 -1
  30. package/dist/browser/charts/core/index.js +9 -1
  31. package/dist/browser/charts/core/index.js.map +1 -1
  32. package/dist/browser/charts/core/inspection.js +2 -1
  33. package/dist/browser/charts/core/inspection.js.map +1 -1
  34. package/dist/browser/charts/core/number-format.js +53 -0
  35. package/dist/browser/charts/core/number-format.js.map +1 -0
  36. package/dist/browser/charts/core/registry.js +3 -1
  37. package/dist/browser/charts/core/registry.js.map +1 -1
  38. package/dist/browser/charts/core/render-size.js +2 -0
  39. package/dist/browser/charts/core/render-size.js.map +1 -1
  40. package/dist/browser/charts/core/render.js +8 -1
  41. package/dist/browser/charts/core/render.js.map +1 -1
  42. package/dist/browser/charts/core/snapshot.js +3 -3
  43. package/dist/browser/charts/core/snapshot.js.map +1 -1
  44. package/dist/browser/charts/core/types.js.map +1 -1
  45. package/dist/browser/charts/description.js.map +1 -1
  46. package/dist/browser/charts.js +2 -0
  47. package/dist/browser/charts.js.map +1 -1
  48. package/dist/browser/content/Chart.js +3 -1
  49. package/dist/browser/content/Chart.js.map +1 -1
  50. package/dist/browser/content/ChartBalanceFlow.js +90 -0
  51. package/dist/browser/content/ChartBalanceFlow.js.map +1 -0
  52. package/dist/browser/content/ChartExplorer.js +1 -1
  53. package/dist/browser/content/ChartExplorer.js.map +1 -1
  54. package/dist/browser/content/ChartRoot.js +1 -1
  55. package/dist/browser/content/ChartRoot.js.map +1 -1
  56. package/dist/browser/content/DataTable.js +212 -261
  57. package/dist/browser/content/DataTable.js.map +1 -1
  58. package/dist/browser/content/FileView.js +70 -99
  59. package/dist/browser/content/FileView.js.map +1 -1
  60. package/dist/browser/content/LoadMore.js +185 -0
  61. package/dist/browser/content/LoadMore.js.map +1 -0
  62. package/dist/browser/content/PdfPages.js +638 -0
  63. package/dist/browser/content/PdfPages.js.map +1 -0
  64. package/dist/browser/content/PdfViewer.js +264 -553
  65. package/dist/browser/content/PdfViewer.js.map +1 -1
  66. package/dist/browser/content/VirtualFeed.js +379 -89
  67. package/dist/browser/content/VirtualFeed.js.map +1 -1
  68. package/dist/browser/content/chart-balance-flow-controller.js +184 -0
  69. package/dist/browser/content/chart-balance-flow-controller.js.map +1 -0
  70. package/dist/browser/content/chart-balance-flow.js +6 -0
  71. package/dist/browser/content/chart-balance-flow.js.map +1 -0
  72. package/dist/browser/content/chart-inspection-core.js +1 -73
  73. package/dist/browser/content/chart-inspection-core.js.map +1 -1
  74. package/dist/browser/content/chart-inspection-mount.js +75 -0
  75. package/dist/browser/content/chart-inspection-mount.js.map +1 -0
  76. package/dist/browser/content/chart-svg.js +1 -1
  77. package/dist/browser/content/chart-svg.js.map +1 -1
  78. package/dist/browser/content/feed-messages.js +22 -2
  79. package/dist/browser/content/feed-messages.js.map +1 -1
  80. package/dist/browser/content/index.js +1 -1
  81. package/dist/browser/content/index.js.map +1 -1
  82. package/dist/browser/content/pdf-messages.js +8 -8
  83. package/dist/browser/content/pdf-messages.js.map +1 -1
  84. package/dist/browser/feedback/dialog-core.js +1 -1
  85. package/dist/browser/feedback/dialog-core.js.map +1 -1
  86. package/dist/browser/feedback/index.js.map +1 -1
  87. package/dist/browser/feedback/prompt-confirm.js +25 -14
  88. package/dist/browser/feedback/prompt-confirm.js.map +1 -1
  89. package/dist/browser/feedback/prompts.js +46 -38
  90. package/dist/browser/feedback/prompts.js.map +1 -1
  91. package/dist/browser/feedback/success-check.js +60 -0
  92. package/dist/browser/feedback/success-check.js.map +1 -0
  93. package/dist/browser/feedback/toast-hit.js +16 -0
  94. package/dist/browser/feedback/toast-hit.js.map +1 -0
  95. package/dist/browser/feedback/toast-messages.js +6 -2
  96. package/dist/browser/feedback/toast-messages.js.map +1 -1
  97. package/dist/browser/feedback/toast.js +609 -98
  98. package/dist/browser/feedback/toast.js.map +1 -1
  99. package/dist/browser/intl/messages.js +4 -0
  100. package/dist/browser/intl/messages.js.map +1 -1
  101. package/dist/browser/layout/AppWorkspace.js +58 -21
  102. package/dist/browser/layout/AppWorkspace.js.map +1 -1
  103. package/dist/browser/layout/BottomSheet.js +58 -40
  104. package/dist/browser/layout/BottomSheet.js.map +1 -1
  105. package/dist/browser/layout/DetailPanel.js +27 -27
  106. package/dist/browser/layout/DetailPanel.js.map +1 -1
  107. package/dist/browser/layout/Discussion.js +119 -160
  108. package/dist/browser/layout/Discussion.js.map +1 -1
  109. package/dist/browser/layout/PanelDialog.js +130 -116
  110. package/dist/browser/layout/PanelDialog.js.map +1 -1
  111. package/dist/browser/layout/index.js.map +1 -1
  112. package/dist/browser/layout/sheet-motion.js +479 -0
  113. package/dist/browser/layout/sheet-motion.js.map +1 -0
  114. package/dist/browser/surfaces/NoticeCard.js +68 -47
  115. package/dist/browser/surfaces/NoticeCard.js.map +1 -1
  116. package/dist/browser/text-editor/TextEditor.js +7 -3
  117. package/dist/browser/text-editor/TextEditor.js.map +1 -1
  118. package/dist/browser/text-editor/clipboard-html.js +62 -26
  119. package/dist/browser/text-editor/clipboard-html.js.map +1 -1
  120. package/dist/browser/text-editor/clipboard-loading.js +44 -15
  121. package/dist/browser/text-editor/clipboard-loading.js.map +1 -1
  122. package/dist/browser/text-editor/engine.js +9 -4
  123. package/dist/browser/text-editor/engine.js.map +1 -1
  124. package/dist/browser/text-editor/format.js +37 -1
  125. package/dist/browser/text-editor/format.js.map +1 -1
  126. package/dist/browser/text-editor/paste.js +2 -1
  127. package/dist/browser/text-editor/paste.js.map +1 -1
  128. package/dist/ssr/actions/SortableList.js +116 -0
  129. package/dist/ssr/actions/SortableList.js.map +1 -0
  130. package/dist/ssr/actions/Toolbar.js +89 -35
  131. package/dist/ssr/actions/Toolbar.js.map +1 -1
  132. package/dist/ssr/actions/drag-and-drop.js +2 -1
  133. package/dist/ssr/actions/drag-and-drop.js.map +1 -1
  134. package/dist/ssr/actions/index.js +1 -0
  135. package/dist/ssr/actions/index.js.map +1 -1
  136. package/dist/ssr/actions/sortable-list-messages.js +35 -0
  137. package/dist/ssr/actions/sortable-list-messages.js.map +1 -0
  138. package/dist/ssr/chart-inspection.js +2 -1
  139. package/dist/ssr/chart-inspection.js.map +1 -1
  140. package/dist/ssr/charts/core/balance-flow-data.js +93 -0
  141. package/dist/ssr/charts/core/balance-flow-data.js.map +1 -0
  142. package/dist/ssr/charts/core/balance-flow-fields.js +19 -0
  143. package/dist/ssr/charts/core/balance-flow-fields.js.map +1 -0
  144. package/dist/ssr/charts/core/balance-flow-frame.js +44 -0
  145. package/dist/ssr/charts/core/balance-flow-frame.js.map +1 -0
  146. package/dist/ssr/charts/core/balance-flow-messages.js +49 -0
  147. package/dist/ssr/charts/core/balance-flow-messages.js.map +1 -0
  148. package/dist/ssr/charts/core/balance-flow-size.js +42 -0
  149. package/dist/ssr/charts/core/balance-flow-size.js.map +1 -0
  150. package/dist/ssr/charts/core/balance-flow.js +195 -0
  151. package/dist/ssr/charts/core/balance-flow.js.map +1 -0
  152. package/dist/ssr/charts/core/calendar-layout.js +105 -0
  153. package/dist/ssr/charts/core/calendar-layout.js.map +1 -0
  154. package/dist/ssr/charts/core/calendar.js +2 -104
  155. package/dist/ssr/charts/core/calendar.js.map +1 -1
  156. package/dist/ssr/charts/core/index.js +9 -1
  157. package/dist/ssr/charts/core/index.js.map +1 -1
  158. package/dist/ssr/charts/core/inspection.js +2 -1
  159. package/dist/ssr/charts/core/inspection.js.map +1 -1
  160. package/dist/ssr/charts/core/number-format.js +53 -0
  161. package/dist/ssr/charts/core/number-format.js.map +1 -0
  162. package/dist/ssr/charts/core/registry.js +3 -1
  163. package/dist/ssr/charts/core/registry.js.map +1 -1
  164. package/dist/ssr/charts/core/render-size.js +2 -0
  165. package/dist/ssr/charts/core/render-size.js.map +1 -1
  166. package/dist/ssr/charts/core/render.js +8 -1
  167. package/dist/ssr/charts/core/render.js.map +1 -1
  168. package/dist/ssr/charts/core/snapshot.js +3 -3
  169. package/dist/ssr/charts/core/snapshot.js.map +1 -1
  170. package/dist/ssr/charts/core/types.js.map +1 -1
  171. package/dist/ssr/charts/description.js.map +1 -1
  172. package/dist/ssr/charts.js +2 -0
  173. package/dist/ssr/charts.js.map +1 -1
  174. package/dist/ssr/content/Chart.js +3 -1
  175. package/dist/ssr/content/Chart.js.map +1 -1
  176. package/dist/ssr/content/ChartBalanceFlow.js +69 -0
  177. package/dist/ssr/content/ChartBalanceFlow.js.map +1 -0
  178. package/dist/ssr/content/ChartExplorer.js +1 -1
  179. package/dist/ssr/content/ChartExplorer.js.map +1 -1
  180. package/dist/ssr/content/ChartRoot.js +1 -1
  181. package/dist/ssr/content/ChartRoot.js.map +1 -1
  182. package/dist/ssr/content/DataTable.js +72 -118
  183. package/dist/ssr/content/DataTable.js.map +1 -1
  184. package/dist/ssr/content/FileView.js +39 -50
  185. package/dist/ssr/content/FileView.js.map +1 -1
  186. package/dist/ssr/content/LoadMore.js +146 -0
  187. package/dist/ssr/content/LoadMore.js.map +1 -0
  188. package/dist/ssr/content/PdfPages.js +538 -0
  189. package/dist/ssr/content/PdfPages.js.map +1 -0
  190. package/dist/ssr/content/PdfViewer.js +226 -457
  191. package/dist/ssr/content/PdfViewer.js.map +1 -1
  192. package/dist/ssr/content/VirtualFeed.js +292 -44
  193. package/dist/ssr/content/VirtualFeed.js.map +1 -1
  194. package/dist/ssr/content/chart-balance-flow-controller.js +184 -0
  195. package/dist/ssr/content/chart-balance-flow-controller.js.map +1 -0
  196. package/dist/ssr/content/chart-balance-flow.js +6 -0
  197. package/dist/ssr/content/chart-balance-flow.js.map +1 -0
  198. package/dist/ssr/content/chart-inspection-core.js +1 -73
  199. package/dist/ssr/content/chart-inspection-core.js.map +1 -1
  200. package/dist/ssr/content/chart-inspection-mount.js +75 -0
  201. package/dist/ssr/content/chart-inspection-mount.js.map +1 -0
  202. package/dist/ssr/content/chart-svg.js +1 -1
  203. package/dist/ssr/content/chart-svg.js.map +1 -1
  204. package/dist/ssr/content/feed-messages.js +22 -2
  205. package/dist/ssr/content/feed-messages.js.map +1 -1
  206. package/dist/ssr/content/index.js +1 -1
  207. package/dist/ssr/content/index.js.map +1 -1
  208. package/dist/ssr/content/pdf-messages.js +8 -8
  209. package/dist/ssr/content/pdf-messages.js.map +1 -1
  210. package/dist/ssr/feedback/dialog-core.js +1 -1
  211. package/dist/ssr/feedback/dialog-core.js.map +1 -1
  212. package/dist/ssr/feedback/index.js.map +1 -1
  213. package/dist/ssr/feedback/prompt-confirm.js +13 -2
  214. package/dist/ssr/feedback/prompt-confirm.js.map +1 -1
  215. package/dist/ssr/feedback/prompts.js +32 -24
  216. package/dist/ssr/feedback/prompts.js.map +1 -1
  217. package/dist/ssr/feedback/success-check.js +47 -0
  218. package/dist/ssr/feedback/success-check.js.map +1 -0
  219. package/dist/ssr/feedback/toast-hit.js +16 -0
  220. package/dist/ssr/feedback/toast-hit.js.map +1 -0
  221. package/dist/ssr/feedback/toast-messages.js +6 -2
  222. package/dist/ssr/feedback/toast-messages.js.map +1 -1
  223. package/dist/ssr/feedback/toast.js +609 -98
  224. package/dist/ssr/feedback/toast.js.map +1 -1
  225. package/dist/ssr/intl/messages.js +4 -0
  226. package/dist/ssr/intl/messages.js.map +1 -1
  227. package/dist/ssr/layout/AppWorkspace.js +39 -5
  228. package/dist/ssr/layout/AppWorkspace.js.map +1 -1
  229. package/dist/ssr/layout/BottomSheet.js +32 -4
  230. package/dist/ssr/layout/BottomSheet.js.map +1 -1
  231. package/dist/ssr/layout/DetailPanel.js +10 -10
  232. package/dist/ssr/layout/DetailPanel.js.map +1 -1
  233. package/dist/ssr/layout/Discussion.js +39 -65
  234. package/dist/ssr/layout/Discussion.js.map +1 -1
  235. package/dist/ssr/layout/PanelDialog.js +54 -35
  236. package/dist/ssr/layout/PanelDialog.js.map +1 -1
  237. package/dist/ssr/layout/index.js.map +1 -1
  238. package/dist/ssr/layout/sheet-motion.js +479 -0
  239. package/dist/ssr/layout/sheet-motion.js.map +1 -0
  240. package/dist/ssr/surfaces/NoticeCard.js +33 -17
  241. package/dist/ssr/surfaces/NoticeCard.js.map +1 -1
  242. package/dist/ssr/text-editor/TextEditor.js +7 -3
  243. package/dist/ssr/text-editor/TextEditor.js.map +1 -1
  244. package/dist/ssr/text-editor/clipboard-html.js +62 -26
  245. package/dist/ssr/text-editor/clipboard-html.js.map +1 -1
  246. package/dist/ssr/text-editor/clipboard-loading.js +44 -15
  247. package/dist/ssr/text-editor/clipboard-loading.js.map +1 -1
  248. package/dist/ssr/text-editor/engine.js +9 -4
  249. package/dist/ssr/text-editor/engine.js.map +1 -1
  250. package/dist/ssr/text-editor/format.js +37 -1
  251. package/dist/ssr/text-editor/format.js.map +1 -1
  252. package/dist/ssr/text-editor/paste.js +2 -1
  253. package/dist/ssr/text-editor/paste.js.map +1 -1
  254. package/dist/styles.css +1 -1
  255. package/dist/types/actions/SortableList.d.ts +26 -0
  256. package/dist/types/actions/Toolbar.d.ts +11 -0
  257. package/dist/types/actions/drag-and-drop.d.ts +2 -0
  258. package/dist/types/actions/index.d.ts +2 -0
  259. package/dist/types/actions/sortable-list-messages.d.ts +15 -0
  260. package/dist/types/chart-inspection.d.ts +2 -1
  261. package/dist/types/charts/core/balance-flow-data.d.ts +37 -0
  262. package/dist/types/charts/core/balance-flow-fields.d.ts +13 -0
  263. package/dist/types/charts/core/balance-flow-frame.d.ts +4 -0
  264. package/dist/types/charts/core/balance-flow-messages.d.ts +97 -0
  265. package/dist/types/charts/core/balance-flow-size.d.ts +21 -0
  266. package/dist/types/charts/core/balance-flow.d.ts +70 -0
  267. package/dist/types/charts/core/calendar-layout.d.ts +67 -0
  268. package/dist/types/charts/core/calendar.d.ts +2 -64
  269. package/dist/types/charts/core/index.d.ts +9 -1
  270. package/dist/types/charts/core/number-format.d.ts +28 -0
  271. package/dist/types/charts/core/registry.d.ts +2 -0
  272. package/dist/types/charts/core/types.d.ts +1 -0
  273. package/dist/types/charts/description.d.ts +17 -0
  274. package/dist/types/charts.d.ts +2 -0
  275. package/dist/types/content/ChartBalanceFlow.d.ts +17 -0
  276. package/dist/types/content/ChartRoot.d.ts +2 -1
  277. package/dist/types/content/DataTable.d.ts +7 -1
  278. package/dist/types/content/LoadMore.d.ts +41 -0
  279. package/dist/types/content/PdfPages.d.ts +57 -0
  280. package/dist/types/content/PdfViewer.d.ts +35 -19
  281. package/dist/types/content/VirtualFeed.d.ts +57 -18
  282. package/dist/types/content/chart-balance-flow-controller.d.ts +12 -0
  283. package/dist/types/content/chart-balance-flow.d.ts +4 -0
  284. package/dist/types/content/chart-inspection-core.d.ts +0 -17
  285. package/dist/types/content/chart-inspection-mount.d.ts +21 -0
  286. package/dist/types/content/feed-messages.d.ts +10 -0
  287. package/dist/types/content/index.d.ts +3 -3
  288. package/dist/types/content/pdf-messages.d.ts +2 -2
  289. package/dist/types/feedback/index.d.ts +2 -2
  290. package/dist/types/feedback/prompt-confirm.d.ts +2 -0
  291. package/dist/types/feedback/prompts.d.ts +5 -1
  292. package/dist/types/feedback/success-check.d.ts +4 -0
  293. package/dist/types/feedback/toast-hit.d.ts +5 -0
  294. package/dist/types/feedback/toast-messages.d.ts +3 -1
  295. package/dist/types/feedback/toast.d.ts +42 -5
  296. package/dist/types/intl/messages.d.ts +2 -0
  297. package/dist/types/layout/AppWorkspace.d.ts +10 -0
  298. package/dist/types/layout/BottomSheet.d.ts +6 -0
  299. package/dist/types/layout/DetailPanel.d.ts +4 -1
  300. package/dist/types/layout/PanelDialog.d.ts +5 -0
  301. package/dist/types/layout/index.d.ts +1 -1
  302. package/dist/types/layout/sheet-motion.d.ts +32 -0
  303. package/dist/types/surfaces/NoticeCard.d.ts +14 -1
  304. package/dist/types/text-editor/TextEditor.d.ts +5 -0
  305. package/dist/types/text-editor/clipboard-loading.d.ts +2 -3
  306. package/dist/types/text-editor/engine.d.ts +6 -1
  307. package/dist/types/text-editor/format.d.ts +3 -1
  308. package/package.json +2 -2
  309. package/dist/browser/content/PdfPreview.js +0 -448
  310. package/dist/browser/content/PdfPreview.js.map +0 -1
  311. package/dist/ssr/content/PdfPreview.js +0 -300
  312. package/dist/ssr/content/PdfPreview.js.map +0 -1
  313. package/dist/types/content/PdfPreview.d.ts +0 -26
@@ -0,0 +1,93 @@
1
+ import { balanceFlowWords } from "./balance-flow-messages";
2
+ export const balanceFlowAmount = (spec, value) => spec.format?.(Math.abs(value)) ?? Math.abs(value).toLocaleString(spec.locale ?? "en", {
3
+ style: "currency",
4
+ currency: spec.currency
5
+ });
6
+ export const balanceFlowDisplayAmount = (spec, row) => `${row.direction === "in" ? "↙ " : row.direction === "out" ? "↗ " : ""}${balanceFlowAmount(spec, row.value)}`;
7
+ export { balanceFlowWords } from "./balance-flow-messages";
8
+ export function balanceFlowRows(spec, index = spec.period ?? 0) {
9
+ const p = spec.periods[index];
10
+ if (!p) return [];
11
+ const t = balanceFlowWords(spec.locale);
12
+ const owed = (label, value) => value < 0 ? `${label} (${t.balanceOwed})` : label;
13
+ return [{
14
+ key: "opening",
15
+ label: owed(t.balanceOpening, p.opening),
16
+ value: p.opening,
17
+ direction: "balance"
18
+ }, ...p.inflows.map((n, i) => ({
19
+ ...n,
20
+ key: `in-${i}`,
21
+ direction: "in"
22
+ })), {
23
+ key: "balance",
24
+ label: t.balanceAvailable,
25
+ value: Math.max(p.opening, 0) + p.inflows.reduce((s, n) => s + n.value, 0) + Math.max(-p.closing, 0),
26
+ direction: "neutral"
27
+ }, ...p.outflows.map((n, i) => ({
28
+ ...n,
29
+ key: `out-${i}`,
30
+ direction: "out"
31
+ })), {
32
+ key: "closing",
33
+ label: index + 1 < spec.periods.length ? balanceFlowBoundaryLabel(spec, index) : owed(t.balanceClosing, p.closing),
34
+ value: p.closing,
35
+ direction: "balance"
36
+ }];
37
+ }
38
+ export const balanceFlowDirection = (direction, locale = "en") => {
39
+ const t = balanceFlowWords(locale);
40
+ return direction === "in" ? t.balanceInflows : direction === "out" ? t.balanceOutflows : direction === "neutral" ? t.balanceAvailable : t.balanceBalance;
41
+ };
42
+ export const balanceFlowSummary = (spec, index = spec.period ?? 0) => {
43
+ const p = spec.periods[index];
44
+ if (!p) return balanceFlowWords(spec.locale).balanceEmpty;
45
+ const t = balanceFlowWords(spec.locale),
46
+ amount = v => `${balanceFlowAmount(spec, v)}${v < 0 ? ` (${t.balanceOwed})` : ""}`;
47
+ return `${p.label}: ${t.balanceOpening} ${amount(p.opening)}, ${t.balanceInflows} ${amount(p.inflows.reduce((s, n) => s + n.value, 0))}, ${t.balanceOutflows} ${amount(p.outflows.reduce((s, n) => s + n.value, 0))}, ${t.balanceClosing} ${amount(p.closing)}.`;
48
+ };
49
+ /** Same column order and text as editor chartRows/chartTooltip. */
50
+ export function balanceFlowTooltip(datum, locale = "en") {
51
+ const t = balanceFlowWords(locale);
52
+ return {
53
+ title: datum.label,
54
+ rows: datum.values.map(field => ({
55
+ label: field.label ?? (field.key === "period" ? t.balancePeriod : field.key === "direction" ? t.balanceDirection : t.chartFields({
56
+ key: field.key
57
+ })),
58
+ value: field.formatted ?? String(field.value)
59
+ }))
60
+ };
61
+ }
62
+ /** A shared boundary is described once, in the preceding period's closing datum. */
63
+ export const balanceFlowBoundaryLabel = (spec, index) => {
64
+ const t = balanceFlowWords(spec.locale),
65
+ current = spec.periods[index],
66
+ next = spec.periods[index + 1];
67
+ return next ? `${t.balanceClosing} ${current.label} = ${t.balanceOpening} ${next.label}${current.closing < 0 ? ` (${t.balanceOwed})` : ""}` : t.balanceClosing;
68
+ };
69
+ /** Full table data includes zero flows, although zero-width links have no inspection target. */
70
+ export function balanceFlowDatums(spec) {
71
+ return spec.periods.flatMap((_, period) => balanceFlowRows(spec, period).map((row, index) => ({
72
+ index,
73
+ seriesIndex: period,
74
+ role: "item",
75
+ label: row.label,
76
+ anchor: [0, 0],
77
+ values: [{
78
+ key: "period",
79
+ value: spec.periods[period].label
80
+ }, {
81
+ key: "direction",
82
+ value: balanceFlowDirection(row.direction, spec.locale)
83
+ }, {
84
+ key: "value",
85
+ value: row.value,
86
+ formatted: balanceFlowDisplayAmount(spec, row),
87
+ ...(spec.valueLabel ? {
88
+ label: spec.valueLabel
89
+ } : {})
90
+ }]
91
+ })));
92
+ }
93
+ //# sourceMappingURL=balance-flow-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["charts/core/balance-flow-data.ts"],"sourcesContent":["import { balanceFlowWords } from \"./balance-flow-messages\";\nimport type { BalanceFlowPeriod } from \"./balance-flow-size\";\nimport type { ChartOptions } from \"./svg-common\";\nimport type { ChartDatum } from \"./types\";\nexport type BalanceFlowOptions = ChartOptions & {\n periods: BalanceFlowPeriod[];\n currency: string;\n locale?: string;\n /** Period used by row/summary helpers; the continuous frame always opens at the newest end. */\n period?: number;\n format?: (value: number) => string;\n valueLabel?: string;\n displayWidth?: number;\n};\nexport const balanceFlowAmount = (spec: Pick<BalanceFlowOptions, \"locale\" | \"currency\" | \"format\">, value: number): string =>\n spec.format?.(Math.abs(value)) ?? Math.abs(value).toLocaleString(spec.locale ?? \"en\", { style: \"currency\", currency: spec.currency });\nexport const balanceFlowDisplayAmount = (\n spec: Pick<BalanceFlowOptions, \"locale\" | \"currency\" | \"format\">,\n row: Pick<BalanceFlowRow, \"direction\" | \"value\">,\n): string => `${row.direction === \"in\" ? \"↙ \" : row.direction === \"out\" ? \"↗ \" : \"\"}${balanceFlowAmount(spec, row.value)}`;\nexport { balanceFlowWords } from \"./balance-flow-messages\";\nexport type BalanceFlowRow = { label: string; value: number; direction: \"balance\" | \"in\" | \"out\" | \"neutral\"; key: string };\nexport function balanceFlowRows(spec: BalanceFlowOptions, index = spec.period ?? 0): BalanceFlowRow[] {\n const p = spec.periods[index];\n if (!p) return [];\n const t = balanceFlowWords(spec.locale);\n const owed = (label: string, value: number) => (value < 0 ? `${label} (${t.balanceOwed})` : label);\n return [\n { key: \"opening\", label: owed(t.balanceOpening, p.opening), value: p.opening, direction: \"balance\" },\n ...p.inflows.map((n, i) => ({ ...n, key: `in-${i}`, direction: \"in\" as const })),\n {\n key: \"balance\",\n label: t.balanceAvailable,\n value: Math.max(p.opening, 0) + p.inflows.reduce((s, n) => s + n.value, 0) + Math.max(-p.closing, 0),\n direction: \"neutral\",\n },\n ...p.outflows.map((n, i) => ({ ...n, key: `out-${i}`, direction: \"out\" as const })),\n {\n key: \"closing\",\n label: index + 1 < spec.periods.length ? balanceFlowBoundaryLabel(spec, index) : owed(t.balanceClosing, p.closing),\n value: p.closing,\n direction: \"balance\",\n },\n ];\n}\nexport const balanceFlowDirection = (direction: string, locale = \"en\") => {\n const t = balanceFlowWords(locale);\n return direction === \"in\"\n ? t.balanceInflows\n : direction === \"out\"\n ? t.balanceOutflows\n : direction === \"neutral\"\n ? t.balanceAvailable\n : t.balanceBalance;\n};\nexport const balanceFlowSummary = (spec: BalanceFlowOptions, index = spec.period ?? 0): string => {\n const p = spec.periods[index];\n if (!p) return balanceFlowWords(spec.locale).balanceEmpty;\n const t = balanceFlowWords(spec.locale),\n amount = (v: number) => `${balanceFlowAmount(spec, v)}${v < 0 ? ` (${t.balanceOwed})` : \"\"}`;\n return `${p.label}: ${t.balanceOpening} ${amount(p.opening)}, ${t.balanceInflows} ${amount(p.inflows.reduce((s, n) => s + n.value, 0))}, ${t.balanceOutflows} ${amount(p.outflows.reduce((s, n) => s + n.value, 0))}, ${t.balanceClosing} ${amount(p.closing)}.`;\n};\n/** Same column order and text as editor chartRows/chartTooltip. */\nexport function balanceFlowTooltip(datum: ChartDatum, locale = \"en\") {\n const t = balanceFlowWords(locale);\n return {\n title: datum.label,\n rows: datum.values.map((field) => ({\n label:\n field.label ??\n (field.key === \"period\" ? t.balancePeriod : field.key === \"direction\" ? t.balanceDirection : t.chartFields({ key: field.key })),\n value: field.formatted ?? String(field.value),\n })),\n };\n}\n/** A shared boundary is described once, in the preceding period's closing datum. */\nexport const balanceFlowBoundaryLabel = (spec: BalanceFlowOptions, index: number): string => {\n const t = balanceFlowWords(spec.locale),\n current = spec.periods[index]!,\n next = spec.periods[index + 1];\n return next\n ? `${t.balanceClosing} ${current.label} = ${t.balanceOpening} ${next.label}${current.closing < 0 ? ` (${t.balanceOwed})` : \"\"}`\n : t.balanceClosing;\n};\n/** Full table data includes zero flows, although zero-width links have no inspection target. */\nexport function balanceFlowDatums(spec: BalanceFlowOptions): ChartDatum[] {\n return spec.periods.flatMap((_, period) =>\n balanceFlowRows(spec, period).map((row, index) => ({\n index,\n seriesIndex: period,\n role: \"item\" as const,\n label: row.label,\n anchor: [0, 0] as [number, number],\n values: [\n { key: \"period\", value: spec.periods[period]!.label },\n { key: \"direction\", value: balanceFlowDirection(row.direction, spec.locale) },\n {\n key: \"value\",\n value: row.value,\n formatted: balanceFlowDisplayAmount(spec, row),\n ...(spec.valueLabel ? { label: spec.valueLabel } : {}),\n },\n ],\n })),\n );\n}\n"],"mappings":"AAAA,SAAS,gBAAgB,QAAQ,yBAAyB;AAc1D,OAAO,MAAM,iBAAiB,GAAG,CAAC,IAAgE,EAAE,KAAa,KAC/G,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE;EAAE,KAAK,EAAE,UAAU;EAAE,QAAQ,EAAE,IAAI,CAAC;AAAS,CAAC,CAAC;AACvI,OAAO,MAAM,wBAAwB,GAAG,CACtC,IAAgE,EAChE,GAAgD,KACrC,GAAG,GAAG,CAAC,SAAS,KAAK,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC,SAAS,KAAK,KAAK,GAAG,IAAI,GAAG,EAAE,GAAG,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE;AAC1H,SAAS,gBAAgB,QAAQ,yBAAyB;AAE1D,OAAO,SAAS,eAAe,CAAC,IAAwB,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,EAAoB;EACpG,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;EAC7B,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE;EACjB,MAAM,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC;EACvC,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,KAAa,KAAM,KAAK,GAAG,CAAC,GAAG,GAAG,KAAK,KAAK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AC,CAAC,CAAC,EAAE,MAAM,KACpC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,MAAM;IACjD,KAAK;IACL,WAAW,EAAE,MAAM;IACnB,IAAI,EAAE,MAAe;IACrB,KAAK,EAAE,GAAG,CAAC,KAAK;IAChB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAqB;IAClC,MAAM,EAAE,CACN;MAAE,GAAG,EAAE,QAAQ;MAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAE;IAAM,CAAC,EACrD;MAAE,GAAG,EAAE,WAAW;MAAE,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM;IAAE,CAAC,EAC7E;MACE,GAAG,EAAE,OAAO;MACZ,KAAK,EAAE,GAAG,CAAC,KAAK;MAChB,SAAS,EAAE,wBAAwB,CAAC,IAAI,EAAE,GAAG,CAAC;MAC9C,IAAI,IAAI,CAAC,UAAU,GAAG;QAAE,KAAK,EAAE,IAAI,CAAC;MAAW,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;EAEL,CAAC,CAAC,CACJ,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ /** Table headings are needed before drawing code; keep them separate from navigation and state copy. */
2
+ const fields = {
3
+ en: {
4
+ balancePeriod: "Period",
5
+ balanceDirection: "Direction",
6
+ chartFields: ({
7
+ key
8
+ }) => key === "detail" ? "Detail" : key === "value" ? "Value" : key
9
+ },
10
+ de: {
11
+ balancePeriod: "Zeitraum",
12
+ balanceDirection: "Richtung",
13
+ chartFields: ({
14
+ key
15
+ }) => key === "detail" ? "Details" : key === "value" ? "Wert" : key
16
+ }
17
+ };
18
+ export const balanceFlowFields = (locale = "en") => fields[locale.toLowerCase().split("-")[0] === "de" ? "de" : "en"];
19
+ //# sourceMappingURL=balance-flow-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["charts/core/balance-flow-fields.ts"],"sourcesContent":["/** Table headings are needed before drawing code; keep them separate from navigation and state copy. */\nconst fields = {\n en: {\n balancePeriod: \"Period\",\n balanceDirection: \"Direction\",\n chartFields: ({ key }: { key: string }) => (key === \"detail\" ? \"Detail\" : key === \"value\" ? \"Value\" : key),\n },\n de: {\n balancePeriod: \"Zeitraum\",\n balanceDirection: \"Richtung\",\n chartFields: ({ key }: { key: string }) => (key === \"detail\" ? \"Details\" : key === \"value\" ? \"Wert\" : key),\n },\n};\nexport const balanceFlowFields = (locale = \"en\") => fields[locale.toLowerCase().split(\"-\")[0] === \"de\" ? \"de\" : \"en\"];\n"],"mappings":"AAAA;AACA,MAAM,MAAM,GAAG;EACb,EAAE,EAAE;IACF,aAAa,EAAE,QAAQ;IACvB,gBAAgB,EAAE,WAAW;IAC7B,WAAW,EAAE,CAAC;MAAE;IAAqB,CAAC,KAAM,GAAG,KAAK,QAAQ,GAAG,QAAQ,GAAG,GAAG,KAAK,OAAO,GAAG,OAAO,GAAG;EACxG,CAAC;EACD,EAAE,EAAE;IACF,aAAa,EAAE,UAAU;IACzB,gBAAgB,EAAE,UAAU;IAC5B,WAAW,EAAE,CAAC;MAAE;IAAqB,CAAC,KAAM,GAAG,KAAK,QAAQ,GAAG,SAAS,GAAG,GAAG,KAAK,OAAO,GAAG,MAAM,GAAG;EACxG;AACF,CAAC;AACD,OAAO,MAAM,iBAAiB,GAAG,CAAC,MAAM,GAAG,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ import { balanceFlowDirection, balanceFlowDisplayAmount, balanceFlowRows, balanceFlowSummary, balanceFlowWords, renderBalanceFlowSvg } from "./balance-flow";
2
+ import { BalanceFlowError, balanceFlowHeight } from "./balance-flow-size";
3
+ import { escapeXml } from "./svg";
4
+ /** SSR-complete continuous canvas; reversed flex origin reveals the newest month without script. */
5
+ export function renderBalanceFlowHtml(spec, state = "data", error, view = "chart", retry = false, standalone = true) {
6
+ const cls = name => `k2b-balance-flow__${name}`;
7
+ const t = balanceFlowWords(spec.locale),
8
+ active = Math.max(0, spec.periods.length - 1),
9
+ height = balanceFlowHeight(spec.periods, spec.height);
10
+ let diagram = "";
11
+ try {
12
+ diagram = renderBalanceFlowSvg({
13
+ ...spec,
14
+ title: undefined,
15
+ subtitle: undefined,
16
+ inspect: true
17
+ }).replace("<svg ", '<svg preserveAspectRatio="none" ');
18
+ } catch (issue) {
19
+ state = "error";
20
+ error = issue instanceof BalanceFlowError ? `${issue.periodLabel}: ${t.balanceInvalid}` : t.balanceInvalid;
21
+ }
22
+ if (!spec.periods.length && state !== "loading" && state !== "error") state = "empty";
23
+ const shown = state === "data" || state === "stale",
24
+ p = spec.periods[active];
25
+ const table = index => `<table class="${cls("table")}"><caption>${escapeXml(spec.periods[index]?.label ?? "")}</caption><thead><tr><th scope="col">${escapeXml(t.chartFields({
26
+ key: "detail"
27
+ }))}</th><th scope="col">${escapeXml(t.balancePeriod)}</th><th scope="col">${escapeXml(t.balanceDirection)}</th><th scope="col">${escapeXml(spec.valueLabel ?? t.chartFields({
28
+ key: "value"
29
+ }))}</th></tr></thead><tbody>${balanceFlowRows(spec, index).map(row => `<tr data-direction="${row.direction}"><th scope="row">${escapeXml(row.label)}</th><td>${escapeXml(spec.periods[index]?.label ?? "")}</td><td>${escapeXml(balanceFlowDirection(row.direction, spec.locale))}</td><td class="${cls("number")}">${escapeXml(balanceFlowDisplayAmount(spec, row))}</td></tr>`).join("")}</tbody></table>`;
30
+ const phone = index => `<dl class="${cls("amounts")}" tabindex="0" aria-label="${escapeXml(spec.periods[index]?.label ?? "")}" data-balance-phone-period="${index}"${index === active ? "" : " hidden"}>${balanceFlowRows(spec, index).map(row => `<div data-direction="${row.direction}"><dt>${escapeXml(row.label)}</dt><dd>${escapeXml(balanceFlowDisplayAmount(spec, row))}</dd></div>`).join("")}</dl>`;
31
+ const status = state === "loading" ? t.chartLoading : state === "error" ? error ?? t.balanceInvalid : t.balanceEmpty;
32
+ return `<section class="${standalone ? "k2b-ui " : ""}k2b-balance-flow" data-balance-flow data-period="${active}" data-locale="${escapeXml(spec.locale ?? "en")}" data-view="${view}" data-state="${state}" style="--k2b-balance-flow-height:${height}px;--k2b-balance-period-width:${Math.max(620, spec.width ?? 620)}px;--k2b-balance-flow-phone-height:${180 * (height - 46) / height + 2}px;--k2b-balance-flow-rows:${Math.min(6, ...spec.periods.map(p => p.inflows.length + p.outflows.length + 3))}" aria-busy="${state === "loading"}">
33
+ <header class="${cls("header")}"><div>${spec.title ? `<h3>${escapeXml(spec.title)}</h3>` : ""}<div class="${cls("subtitle")}" role="status">${escapeXml(state === "stale" ? t.balanceStale : spec.subtitle ?? "")}</div></div><div class="${cls("views")}" role="group" aria-label="${escapeXml(t.chartView)}"><button type="button" data-balance-view="chart" aria-pressed="${view === "chart"}">${escapeXml(t.chartDiagram)}</button><button type="button" data-balance-view="table" aria-pressed="${view === "table"}">${escapeXml(t.chartData)}</button></div></header>
34
+ <nav class="${cls("nav")}" aria-label="${escapeXml(t.balancePeriod)}"><button type="button" data-balance-step="-1" aria-label="${escapeXml(t.balancePrevious)}"${!shown || active === 0 ? " disabled" : ""}>‹</button><strong data-balance-label>${escapeXml(p?.label ?? "—")}</strong><button type="button" data-balance-step="1" aria-label="${escapeXml(t.balanceNext)}"${!shown || active >= spec.periods.length - 1 ? " disabled" : ""}>›</button></nav>
35
+ <div class="${cls("content")}"><div class="${cls("content-box")}"><div class="${cls("status")}" role="${state === "error" ? "alert" : "status"}"${shown ? " hidden" : ""}><p>${escapeXml(status)}</p>${state === "error" && retry ? `<button type="button" data-balance-retry>${escapeXml(t.balanceRetry)}</button>` : ""}</div><div class="${cls("data")}"${shown ? "" : " hidden"}>
36
+ <div class="k2b-chart" data-chart-kind="balanceFlow"${view === "table" ? " hidden" : ""} tabindex="0" role="group" aria-label="${escapeXml(spec.title ?? t.balancePeriod)}" aria-description="${escapeXml(t.balanceKeyboard)}">
37
+ <div class="${cls("scroll")}" data-balance-scroll><div class="${cls("track")}" style="--k2b-balance-periods:${Math.max(1, spec.periods.length)}">
38
+ <div class="${cls("months")}">${spec.periods.map((period, i) => `<div data-balance-month="${i}"${i === active ? " data-balance-active" : ""}><strong>${escapeXml(period.label)}</strong></div>`).join("")}</div>
39
+ <div class="k2b-chart__svg">${diagram}</div></div></div></div>
40
+ <div class="k2b-chart__table" data-balance-table${view === "table" ? "" : " hidden"}>${spec.periods.map((_, i) => table(i)).join("")}</div><div data-balance-phone${view === "table" ? " hidden" : ""}>${spec.periods.map((_, i) => phone(i)).join("")}</div></div></div></div>
41
+ <p class="k2b-sr-only" data-balance-summary role="status">${escapeXml(shown && p ? balanceFlowSummary(spec, active) : status)}</p>
42
+ </section>`;
43
+ }
44
+ //# sourceMappingURL=balance-flow-frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["charts/core/balance-flow-frame.ts"],"sourcesContent":["import {\n type BalanceFlowOptions,\n balanceFlowDirection,\n balanceFlowDisplayAmount,\n balanceFlowRows,\n balanceFlowSummary,\n balanceFlowWords,\n renderBalanceFlowSvg,\n} from \"./balance-flow\";\nimport { BalanceFlowError, balanceFlowHeight } from \"./balance-flow-size\";\nimport { escapeXml } from \"./svg\";\n\nexport type BalanceFlowState = \"data\" | \"loading\" | \"empty\" | \"error\" | \"stale\";\n/** SSR-complete continuous canvas; reversed flex origin reveals the newest month without script. */\nexport function renderBalanceFlowHtml(\n spec: BalanceFlowOptions,\n state: BalanceFlowState = \"data\",\n error?: string,\n view: \"chart\" | \"table\" = \"chart\",\n retry = false,\n standalone = true,\n): string {\n const cls = (name: string) => `k2b-balance-flow__${name}`;\n const t = balanceFlowWords(spec.locale),\n active = Math.max(0, spec.periods.length - 1),\n height = balanceFlowHeight(spec.periods, spec.height);\n let diagram = \"\";\n try {\n diagram = renderBalanceFlowSvg({ ...spec, title: undefined, subtitle: undefined, inspect: true }).replace(\n \"<svg \",\n '<svg preserveAspectRatio=\"none\" ',\n );\n } catch (issue) {\n state = \"error\";\n error = issue instanceof BalanceFlowError ? `${issue.periodLabel}: ${t.balanceInvalid}` : t.balanceInvalid;\n }\n if (!spec.periods.length && state !== \"loading\" && state !== \"error\") state = \"empty\";\n const shown = state === \"data\" || state === \"stale\",\n p = spec.periods[active];\n const table = (index: number) =>\n `<table class=\"${cls(\"table\")}\"><caption>${escapeXml(spec.periods[index]?.label ?? \"\")}</caption><thead><tr><th scope=\"col\">${escapeXml(t.chartFields({ key: \"detail\" }))}</th><th scope=\"col\">${escapeXml(t.balancePeriod)}</th><th scope=\"col\">${escapeXml(t.balanceDirection)}</th><th scope=\"col\">${escapeXml(spec.valueLabel ?? t.chartFields({ key: \"value\" }))}</th></tr></thead><tbody>${balanceFlowRows(\n spec,\n index,\n )\n .map(\n (row) =>\n `<tr data-direction=\"${row.direction}\"><th scope=\"row\">${escapeXml(row.label)}</th><td>${escapeXml(spec.periods[index]?.label ?? \"\")}</td><td>${escapeXml(balanceFlowDirection(row.direction, spec.locale))}</td><td class=\"${cls(\"number\")}\">${escapeXml(balanceFlowDisplayAmount(spec, row))}</td></tr>`,\n )\n .join(\"\")}</tbody></table>`;\n const phone = (index: number) =>\n `<dl class=\"${cls(\"amounts\")}\" tabindex=\"0\" aria-label=\"${escapeXml(spec.periods[index]?.label ?? \"\")}\" data-balance-phone-period=\"${index}\"${index === active ? \"\" : \" hidden\"}>${balanceFlowRows(\n spec,\n index,\n )\n .map(\n (row) =>\n `<div data-direction=\"${row.direction}\"><dt>${escapeXml(row.label)}</dt><dd>${escapeXml(balanceFlowDisplayAmount(spec, row))}</dd></div>`,\n )\n .join(\"\")}</dl>`;\n const status = state === \"loading\" ? t.chartLoading : state === \"error\" ? (error ?? t.balanceInvalid) : t.balanceEmpty;\n return `<section class=\"${standalone ? \"k2b-ui \" : \"\"}k2b-balance-flow\" data-balance-flow data-period=\"${active}\" data-locale=\"${escapeXml(spec.locale ?? \"en\")}\" data-view=\"${view}\" data-state=\"${state}\" style=\"--k2b-balance-flow-height:${height}px;--k2b-balance-period-width:${Math.max(620, spec.width ?? 620)}px;--k2b-balance-flow-phone-height:${(180 * (height - 46)) / height + 2}px;--k2b-balance-flow-rows:${Math.min(6, ...spec.periods.map((p) => p.inflows.length + p.outflows.length + 3))}\" aria-busy=\"${state === \"loading\"}\">\n<header class=\"${cls(\"header\")}\"><div>${spec.title ? `<h3>${escapeXml(spec.title)}</h3>` : \"\"}<div class=\"${cls(\"subtitle\")}\" role=\"status\">${escapeXml(state === \"stale\" ? t.balanceStale : (spec.subtitle ?? \"\"))}</div></div><div class=\"${cls(\"views\")}\" role=\"group\" aria-label=\"${escapeXml(t.chartView)}\"><button type=\"button\" data-balance-view=\"chart\" aria-pressed=\"${view === \"chart\"}\">${escapeXml(t.chartDiagram)}</button><button type=\"button\" data-balance-view=\"table\" aria-pressed=\"${view === \"table\"}\">${escapeXml(t.chartData)}</button></div></header>\n<nav class=\"${cls(\"nav\")}\" aria-label=\"${escapeXml(t.balancePeriod)}\"><button type=\"button\" data-balance-step=\"-1\" aria-label=\"${escapeXml(t.balancePrevious)}\"${!shown || active === 0 ? \" disabled\" : \"\"}>‹</button><strong data-balance-label>${escapeXml(p?.label ?? \"—\")}</strong><button type=\"button\" data-balance-step=\"1\" aria-label=\"${escapeXml(t.balanceNext)}\"${!shown || active >= spec.periods.length - 1 ? \" disabled\" : \"\"}>›</button></nav>\n<div class=\"${cls(\"content\")}\"><div class=\"${cls(\"content-box\")}\"><div class=\"${cls(\"status\")}\" role=\"${state === \"error\" ? \"alert\" : \"status\"}\"${shown ? \" hidden\" : \"\"}><p>${escapeXml(status)}</p>${state === \"error\" && retry ? `<button type=\"button\" data-balance-retry>${escapeXml(t.balanceRetry)}</button>` : \"\"}</div><div class=\"${cls(\"data\")}\"${shown ? \"\" : \" hidden\"}>\n<div class=\"k2b-chart\" data-chart-kind=\"balanceFlow\"${view === \"table\" ? \" hidden\" : \"\"} tabindex=\"0\" role=\"group\" aria-label=\"${escapeXml(spec.title ?? t.balancePeriod)}\" aria-description=\"${escapeXml(t.balanceKeyboard)}\">\n<div class=\"${cls(\"scroll\")}\" data-balance-scroll><div class=\"${cls(\"track\")}\" style=\"--k2b-balance-periods:${Math.max(1, spec.periods.length)}\">\n<div class=\"${cls(\"months\")}\">${spec.periods.map((period, i) => `<div data-balance-month=\"${i}\"${i === active ? \" data-balance-active\" : \"\"}><strong>${escapeXml(period.label)}</strong></div>`).join(\"\")}</div>\n<div class=\"k2b-chart__svg\">${diagram}</div></div></div></div>\n<div class=\"k2b-chart__table\" data-balance-table${view === \"table\" ? \"\" : \" hidden\"}>${spec.periods.map((_, i) => table(i)).join(\"\")}</div><div data-balance-phone${view === \"table\" ? \" hidden\" : \"\"}>${spec.periods.map((_, i) => phone(i)).join(\"\")}</div></div></div></div>\n<p class=\"k2b-sr-only\" data-balance-summary role=\"status\">${escapeXml(shown && p ? balanceFlowSummary(spec, active) : status)}</p>\n</section>`;\n}\n"],"mappings":"AAAA,SAEE,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,QACf,gBAAgB;AACvB,SAAS,gBAAgB,EAAE,iBAAiB,QAAQ,qBAAqB;AACzE,SAAS,SAAS,QAAQ,OAAO;AAGjC;AACA,OAAO,SAAS,qBAAqB,CACnC,IAAwB,EACxB,KAAuB,GAAG,MAAM,EAChC,KAAc,EACd,IAAuB,GAAG,OAAO,EACjC,KAAK,GAAG,KAAK,EACb,UAAU,GAAG,IAAI,EACT;EACR,MAAM,GAAG,GAAI,IAAY,IAAK,qBAAqB,IAAI,EAAE;EACzD,MAAM,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC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,GAAG,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACtP,4DAA4D,SAAS,CAAC,KAAK,IAAI,CAAC,GAAG,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;AAC7H,WAAW;AACX","ignoreList":[]}
@@ -0,0 +1,49 @@
1
+ /** Kind-owned chart messages, shared by the pure renderer, table and interaction host. */
2
+ import { balanceFlowFields } from "./balance-flow-fields";
3
+ const messages = {
4
+ en: {
5
+ balanceOpening: "Opening",
6
+ balanceClosing: "Closing",
7
+ balanceInflows: "Inflows",
8
+ balanceOutflows: "Outflows",
9
+ balanceBalance: "Balance",
10
+ balanceAvailable: "Available",
11
+ balanceOwed: "owed",
12
+ balancePrevious: "Previous period",
13
+ balanceNext: "Next period",
14
+ balanceEmpty: "No periods to show.",
15
+ balanceInvalid: "The amounts do not balance. Check opening, inflows, outflows and closing.",
16
+ balanceStale: "Showing the last loaded amounts.",
17
+ balanceRetry: "Try again",
18
+ balanceKeyboard: "←/→: period. ↑/↓: amounts. Enter: pin. Escape: close.",
19
+ chartView: "Chart view",
20
+ chartDiagram: "Diagram",
21
+ chartData: "Table",
22
+ chartLoading: "Loading …"
23
+ },
24
+ de: {
25
+ balanceOpening: "Anfang",
26
+ balanceClosing: "Schluss",
27
+ balanceInflows: "Eingänge",
28
+ balanceOutflows: "Ausgänge",
29
+ balanceBalance: "Saldo",
30
+ balanceAvailable: "Verfügbar",
31
+ balanceOwed: "geschuldet",
32
+ balancePrevious: "Vorheriger Zeitraum",
33
+ balanceNext: "Nächster Zeitraum",
34
+ balanceEmpty: "Keine Zeiträume vorhanden.",
35
+ balanceInvalid: "Die Beträge gehen nicht auf. Anfang, Eingänge, Ausgänge und Schluss prüfen.",
36
+ balanceStale: "Die zuletzt geladenen Beträge werden angezeigt.",
37
+ balanceRetry: "Erneut versuchen",
38
+ balanceKeyboard: "←/→: Zeitraum. ↑/↓: Beträge. Enter: festhalten. Escape: schließen.",
39
+ chartView: "Diagrammansicht",
40
+ chartDiagram: "Diagramm",
41
+ chartData: "Tabelle",
42
+ chartLoading: "Lädt …"
43
+ }
44
+ };
45
+ export const balanceFlowWords = (locale = "en") => ({
46
+ ...messages[locale.toLowerCase().split("-")[0] === "de" ? "de" : "en"],
47
+ ...balanceFlowFields(locale)
48
+ });
49
+ //# sourceMappingURL=balance-flow-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["charts/core/balance-flow-messages.ts"],"sourcesContent":["/** Kind-owned chart messages, shared by the pure renderer, table and interaction host. */\nimport { balanceFlowFields } from \"./balance-flow-fields\";\n\nconst messages = {\n en: {\n balanceOpening: \"Opening\",\n balanceClosing: \"Closing\",\n balanceInflows: \"Inflows\",\n balanceOutflows: \"Outflows\",\n balanceBalance: \"Balance\",\n balanceAvailable: \"Available\",\n balanceOwed: \"owed\",\n balancePrevious: \"Previous period\",\n balanceNext: \"Next period\",\n balanceEmpty: \"No periods to show.\",\n balanceInvalid: \"The amounts do not balance. Check opening, inflows, outflows and closing.\",\n balanceStale: \"Showing the last loaded amounts.\",\n balanceRetry: \"Try again\",\n balanceKeyboard: \"←/→: period. ↑/↓: amounts. Enter: pin. Escape: close.\",\n chartView: \"Chart view\",\n chartDiagram: \"Diagram\",\n chartData: \"Table\",\n chartLoading: \"Loading …\",\n },\n de: {\n balanceOpening: \"Anfang\",\n balanceClosing: \"Schluss\",\n balanceInflows: \"Eingänge\",\n balanceOutflows: \"Ausgänge\",\n balanceBalance: \"Saldo\",\n balanceAvailable: \"Verfügbar\",\n balanceOwed: \"geschuldet\",\n balancePrevious: \"Vorheriger Zeitraum\",\n balanceNext: \"Nächster Zeitraum\",\n balanceEmpty: \"Keine Zeiträume vorhanden.\",\n balanceInvalid: \"Die Beträge gehen nicht auf. Anfang, Eingänge, Ausgänge und Schluss prüfen.\",\n balanceStale: \"Die zuletzt geladenen Beträge werden angezeigt.\",\n balanceRetry: \"Erneut versuchen\",\n balanceKeyboard: \"←/→: Zeitraum. ↑/↓: Beträge. Enter: festhalten. Escape: schließen.\",\n chartView: \"Diagrammansicht\",\n chartDiagram: \"Diagramm\",\n chartData: \"Tabelle\",\n chartLoading: \"Lädt …\",\n },\n};\nexport const balanceFlowWords = (locale = \"en\") => ({\n ...messages[locale.toLowerCase().split(\"-\")[0] === \"de\" ? \"de\" : \"en\"],\n ...balanceFlowFields(locale),\n});\n"],"mappings":"AAAA;AACA,SAAS,iBAAiB,QAAQ,uBAAuB;AAEzD,MAAM,QAAQ,GAAG;EACf,EAAE,EAAE;IACF,cAAc,EAAE,SAAS;IACzB,cAAc,EAAE,SAAS;IACzB,cAAc,EAAE,SAAS;IACzB,eAAe,EAAE,UAAU;IAC3B,cAAc,EAAE,SAAS;IACzB,gBAAgB,EAAE,WAAW;IAC7B,WAAW,EAAE,MAAM;IACnB,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,qBAAqB;IACnC,cAAc,EAAE,2EAA2E;IAC3F,YAAY,EAAE,kCAAkC;IAChD,YAAY,EAAE,WAAW;IACzB,eAAe,EAAE,uDAAuD;IACxE,SAAS,EAAE,YAAY;IACvB,YAAY,EAAE,SAAS;IACvB,SAAS,EAAE,OAAO;IAClB,YAAY,EAAE;EAChB,CAAC;EACD,EAAE,EAAE;IACF,cAAc,EAAE,QAAQ;IACxB,cAAc,EAAE,SAAS;IACzB,cAAc,EAAE,UAAU;IAC1B,eAAe,EAAE,UAAU;IAC3B,cAAc,EAAE,OAAO;IACvB,gBAAgB,EAAE,WAAW;IAC7B,WAAW,EAAE,YAAY;IACzB,eAAe,EAAE,qBAAqB;IACtC,WAAW,EAAE,mBAAmB;IAChC,YAAY,EAAE,4BAA4B;IAC1C,cAAc,EAAE,6EAA6E;IAC7F,YAAY,EAAE,iDAAiD;IAC/D,YAAY,EAAE,kBAAkB;IAChC,eAAe,EAAE,oEAAoE;IACrF,SAAS,EAAE,iBAAiB;IAC5B,YAAY,EAAE,UAAU;IACxB,SAAS,EAAE,SAAS;IACpB,YAAY,EAAE;EAChB;AACF,CAAC;AACD,OAAO,MAAM,gBAAgB,GAAG,CAAC,MAAM,GAAG,IAAI,MAAM;EAClD,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;EACtE,GAAG,iBAAiB,CAAC,MAAM;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ /** Portable balance-flow data. Amounts keep the decimal value supplied by the author. */
2
+
3
+ // Compare decimal input values exactly, including scientific notation. No currency rounding or epsilon can hide a broken ledger.
4
+ const decimal = value => {
5
+ if (!Number.isFinite(value)) throw new RangeError("Balance flow amounts must be finite.");
6
+ const [mantissa = "", exponent = "0"] = String(value).split("e");
7
+ const [integer = "", fraction = ""] = mantissa.split(".");
8
+ return {
9
+ units: BigInt(integer + fraction),
10
+ places: fraction.length - Number(exponent)
11
+ };
12
+ };
13
+ const sumEquals = (terms, expected) => {
14
+ const numbers = [...terms, -expected].map(decimal);
15
+ const places = Math.max(...numbers.map(n => n.places));
16
+ return numbers.reduce((total, n) => total + n.units * 10n ** BigInt(places - n.places), 0n) === 0n;
17
+ };
18
+ /** Retain the period identity across the JSON, frame and Notebook diagnostic boundaries. */
19
+ export class BalanceFlowError extends RangeError {
20
+ constructor(period, periodLabel, message) {
21
+ super(`Balance flow ${periodLabel}: ${message}`);
22
+ this.period = period;
23
+ this.periodLabel = periodLabel;
24
+ }
25
+ }
26
+ export function validateBalanceFlow(periods) {
27
+ for (const [index, period] of periods.entries()) {
28
+ try {
29
+ for (const item of [...period.inflows, ...period.outflows]) if (!Number.isFinite(item.value) || item.value < 0) throw new RangeError("flows must be finite and nonnegative.");
30
+ if (!sumEquals([period.opening, ...period.inflows.map(n => n.value), ...period.outflows.map(n => -n.value)], period.closing)) throw new RangeError("opening + inflows − outflows must equal closing.");
31
+ const previous = periods[index - 1];
32
+ if (previous && !sumEquals([previous.closing], period.opening)) throw new RangeError("opening must equal the previous period's closing.");
33
+ // Finite individual numbers can still overflow a Sankey total.
34
+ if (!Number.isFinite(Math.abs(period.opening) + Math.abs(period.closing) + [...period.inflows, ...period.outflows].reduce((s, n) => s + n.value, 0))) throw new RangeError("totals must be finite.");
35
+ } catch (error) {
36
+ throw new BalanceFlowError(index, period.label, error instanceof Error ? error.message : "Invalid amounts.");
37
+ }
38
+ }
39
+ }
40
+ /** One content height for every period and state, independent of the selected month and measured browser width. */
41
+ export const balanceFlowHeight = (periods, height = 280) => Math.max(height, 64 + Math.max(1, ...periods.map(p => Math.max(p.inflows.length, p.outflows.length))) * 36);
42
+ //# sourceMappingURL=balance-flow-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["charts/core/balance-flow-size.ts"],"sourcesContent":["/** Portable balance-flow data. Amounts keep the decimal value supplied by the author. */\nexport type BalanceFlowItem = { label: string; value: number };\nexport type BalanceFlowPeriod = {\n label: string;\n opening: number;\n inflows: BalanceFlowItem[];\n outflows: BalanceFlowItem[];\n closing: number;\n};\n\n// Compare decimal input values exactly, including scientific notation. No currency rounding or epsilon can hide a broken ledger.\nconst decimal = (value: number) => {\n if (!Number.isFinite(value)) throw new RangeError(\"Balance flow amounts must be finite.\");\n const [mantissa = \"\", exponent = \"0\"] = String(value).split(\"e\");\n const [integer = \"\", fraction = \"\"] = mantissa.split(\".\");\n return { units: BigInt(integer + fraction), places: fraction.length - Number(exponent) };\n};\nconst sumEquals = (terms: number[], expected: number) => {\n const numbers = [...terms, -expected].map(decimal);\n const places = Math.max(...numbers.map((n) => n.places));\n return numbers.reduce((total, n) => total + n.units * 10n ** BigInt(places - n.places), 0n) === 0n;\n};\n/** Retain the period identity across the JSON, frame and Notebook diagnostic boundaries. */\nexport class BalanceFlowError extends RangeError {\n constructor(\n readonly period: number,\n readonly periodLabel: string,\n message: string,\n ) {\n super(`Balance flow ${periodLabel}: ${message}`);\n }\n}\nexport function validateBalanceFlow(periods: readonly BalanceFlowPeriod[]): void {\n for (const [index, period] of periods.entries()) {\n try {\n for (const item of [...period.inflows, ...period.outflows])\n if (!Number.isFinite(item.value) || item.value < 0) throw new RangeError(\"flows must be finite and nonnegative.\");\n if (!sumEquals([period.opening, ...period.inflows.map((n) => n.value), ...period.outflows.map((n) => -n.value)], period.closing))\n throw new RangeError(\"opening + inflows − outflows must equal closing.\");\n const previous = periods[index - 1];\n if (previous && !sumEquals([previous.closing], period.opening))\n throw new RangeError(\"opening must equal the previous period's closing.\");\n // Finite individual numbers can still overflow a Sankey total.\n if (\n !Number.isFinite(\n Math.abs(period.opening) + Math.abs(period.closing) + [...period.inflows, ...period.outflows].reduce((s, n) => s + n.value, 0),\n )\n )\n throw new RangeError(\"totals must be finite.\");\n } catch (error) {\n throw new BalanceFlowError(index, period.label, error instanceof Error ? error.message : \"Invalid amounts.\");\n }\n }\n}\n/** One content height for every period and state, independent of the selected month and measured browser width. */\nexport const balanceFlowHeight = (periods: readonly BalanceFlowPeriod[], height = 280): number =>\n Math.max(height, 64 + Math.max(1, ...periods.map((p) => Math.max(p.inflows.length, p.outflows.length))) * 36);\n"],"mappings":"AAAA;;AAUA;AACA,MAAM,OAAO,GAAI,KAAa,IAAK;EACjC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,UAAU,CAAC,sCAAsC,CAAC;EACzF,MAAM,CAAC,QAAQ,GAAG,EAAE,EAAE,QAAQ,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;EAChE,MAAM,CAAC,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,G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AAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAE,CAAC,IAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC","ignoreList":[]}
@@ -0,0 +1,195 @@
1
+ import { balanceFlowDatums, balanceFlowDisplayAmount, balanceFlowRows, balanceFlowSummary, balanceFlowTooltip, balanceFlowWords } from "./balance-flow-data";
2
+ export * from "./balance-flow-data";
3
+ import { balanceFlowHeight, validateBalanceFlow } from "./balance-flow-size";
4
+ import { chartDatumSvg, escapeXml, renderHeader, svgRoot } from "./svg-common";
5
+
6
+ /** Conservative proportional-font advances in em, shared by DOM-free SVG label layout.
7
+ * Wide glyphs retain their natural shape; fitting removes whole code points instead of stretching text.
8
+ */
9
+ function chartTextWidth(text, size) {
10
+ return Array.from(text).reduce((width, glyph) => width + (/\s/.test(glyph) ? 0.34 : /[ilI.,:;!|'`]/.test(glyph) ? 0.32 : /[MW@%&]/.test(glyph) ? 1 : /[A-Z0-9]/.test(glyph) ? 0.74 : /[a-zäöüßéèáàóúñç()-]/i.test(glyph) ? 0.64 : 1), 0) * size;
11
+ }
12
+ function fitChartText(text, width, size) {
13
+ if (chartTextWidth(text, size) <= width) return text;
14
+ const glyphs = Array.from(text);
15
+ while (glyphs.length && chartTextWidth(glyphs.join("") + "…", size) > width) glyphs.pop();
16
+ return chartTextWidth("…", size) <= width ? glyphs.join("") + "…" : "";
17
+ }
18
+ export { BalanceFlowError, balanceFlowHeight, validateBalanceFlow } from "./balance-flow-size";
19
+ export const balanceFlowColors = {
20
+ balance: "var(--k2b-balance-flow-mark,#3b82f6)",
21
+ in: "var(--k2b-flow-in-mark,#0891b2)",
22
+ out: "var(--k2b-flow-out-mark,#8b5cf6)",
23
+ neutral: "var(--k2b-placeholder-color,#71717a)"
24
+ };
25
+ /** Common scale and bottom edge make every closing/opening join geometrically identical. */
26
+ export function balanceFlowLayout(spec) {
27
+ validateBalanceFlow(spec.periods);
28
+ const index = spec.period ?? 0;
29
+ if (!Number.isInteger(index) || index < 0 || index >= Math.max(1, spec.periods.length)) throw new RangeError("Invalid period.");
30
+ const width = Math.max(620, spec.width ?? 620),
31
+ height = balanceFlowHeight(spec.periods, spec.height);
32
+ const rows = balanceFlowRows(spec, index);
33
+ const nodes = rows.map((n, index) => ({
34
+ id: n.key,
35
+ index,
36
+ incoming: 0,
37
+ outgoing: 0,
38
+ value: 0,
39
+ stage: 0,
40
+ x: 0,
41
+ y: 0,
42
+ height: 0,
43
+ showLabel: false
44
+ }));
45
+ const links = rows.filter(n => n.key !== "balance" && n.value !== 0).map(n => {
46
+ const source = n.direction === "in" || n.key === "opening" && n.value > 0 || n.key === "closing" && n.value < 0;
47
+ return {
48
+ source: source ? n.key : "balance",
49
+ target: source ? "balance" : n.key,
50
+ value: Math.abs(n.value)
51
+ };
52
+ });
53
+ // This reconciled star is acyclic by construction. Keep Sankey node value = max(in, out),
54
+ // without running a general graph layout that every position below would replace.
55
+ const routedLinks = links.map(link => {
56
+ const sourceNode = nodes.find(n => n.id === link.source);
57
+ const targetNode = nodes.find(n => n.id === link.target);
58
+ sourceNode.outgoing += link.value;
59
+ targetNode.incoming += link.value;
60
+ return {
61
+ ...link,
62
+ sourceNode,
63
+ targetNode
64
+ };
65
+ });
66
+ for (const node of nodes) node.value = Math.max(node.incoming, node.outgoing);
67
+ const scene = {
68
+ nodes,
69
+ links: routedLinks,
70
+ width,
71
+ height,
72
+ header: {
73
+ height: 0
74
+ }
75
+ };
76
+ const bottom = height - 46,
77
+ top = 16;
78
+ const largest = Math.max(1, ...spec.periods.map((_, i) => balanceFlowRows(spec, i).find(r => r.key === "balance").value));
79
+ const gaps = Math.max(1, ...spec.periods.map(p => Math.max(p.inflows.length, p.outflows.length)));
80
+ const scale = Math.max(0, bottom - top - gaps * 12) / largest;
81
+ const nodeWidth = 8;
82
+ for (const node of scene.nodes) {
83
+ const row = rows[node.index];
84
+ node.stage = row.key === "balance" ? 1 : row.direction === "in" || row.key === "opening" ? 0 : 2;
85
+ node.x = row.key === "opening" ? index > 0 ? -nodeWidth / 2 : 0 : row.key === "closing" ? width - (index + 1 < spec.periods.length ? nodeWidth / 2 : nodeWidth) : node.stage === 0 ? 40 : node.stage === 1 ? width / 2 - nodeWidth / 2 : width - 40 - nodeWidth;
86
+ node.height = Math.max(1, Math.abs(row.value) * scale);
87
+ node.y = bottom - node.height;
88
+ node.showLabel = node.value > 0 || row.key === "opening" || row.key === "closing";
89
+ }
90
+ for (const stage of scene.nodes.length ? [0, 2] : []) {
91
+ let cursor = top;
92
+ for (const node of scene.nodes.filter(n => n.stage === stage && n.id !== "opening" && n.id !== "closing")) {
93
+ node.y = cursor;
94
+ cursor += node.height + 12;
95
+ }
96
+ }
97
+ const labelY = new Map();
98
+ for (const stage of [0, 1, 2]) {
99
+ const labels = scene.nodes.filter(n => n.stage === stage && n.showLabel && rows[n.index].direction !== "balance").sort((a, b) => a.y - b.y);
100
+ labels.forEach((node, i) => labelY.set(node.index, Math.max(node.y + node.height / 2, i ? labelY.get(labels[i - 1].index) + 36 : top + 12)));
101
+ for (let i = labels.length - 1; i >= 0; i--) {
102
+ const node = labels[i];
103
+ labelY.set(node.index, Math.min(labelY.get(node.index), i + 1 < labels.length ? labelY.get(labels[i + 1].index) - 36 : bottom - 24));
104
+ }
105
+ }
106
+ const used = new Map();
107
+ const routed = scene.links.map(link => {
108
+ const source = link.sourceNode,
109
+ target = link.targetNode,
110
+ thickness = Math.max(1, link.value * scale);
111
+ const edgeY = (node, other) => {
112
+ if (node.id !== "balance") return node.y;
113
+ const side = other.stage === 0 ? 0 : 2;
114
+ const offset = used.get(side) ?? 0;
115
+ used.set(side, offset + thickness);
116
+ return node.y + offset;
117
+ };
118
+ // Put the carry-forward band at the bottom on both sides of the available node.
119
+ const sy = source.id === "balance" && (target.id === "opening" || target.id === "closing") ? bottom - thickness : edgeY(source, target);
120
+ const ty = target.id === "balance" && (source.id === "opening" || source.id === "closing") ? bottom - thickness : edgeY(target, source);
121
+ const forward = source.x < target.x;
122
+ const boundaryX = node => node.id === "opening" ? 0 : node.id === "closing" ? width : undefined;
123
+ const x1 = boundaryX(source) ?? source.x + (forward ? nodeWidth : 0),
124
+ x2 = boundaryX(target) ?? target.x + (forward ? 0 : nodeWidth),
125
+ mid = (x1 + x2) / 2;
126
+ return {
127
+ ...link,
128
+ thickness,
129
+ sy,
130
+ ty,
131
+ x1,
132
+ x2,
133
+ path: `M${x1},${sy}C${mid},${sy} ${mid},${ty} ${x2},${ty}L${x2},${ty + thickness}C${mid},${ty + thickness} ${mid},${sy + thickness} ${x1},${sy + thickness}Z`
134
+ };
135
+ });
136
+ return {
137
+ ...scene,
138
+ nodeWidth,
139
+ links: routed,
140
+ rows,
141
+ labelY,
142
+ scale,
143
+ bottom
144
+ };
145
+ }
146
+ export function renderBalanceFlowSvg(spec) {
147
+ validateBalanceFlow(spec.periods);
148
+ const periodWidth = Math.max(620, spec.width ?? 620),
149
+ width = periodWidth * Math.max(1, spec.periods.length);
150
+ const header = renderHeader(width, spec.title, spec.subtitle);
151
+ const body = [header.svg.replace(/<text /g, '<text fill="var(--k2b-text,#27272a)" font-size="13" ')];
152
+ const datums = balanceFlowDatums(spec);
153
+ for (const [period] of spec.periods.entries()) {
154
+ const scene = balanceFlowLayout({
155
+ ...spec,
156
+ period
157
+ });
158
+ const offset = period * periodWidth;
159
+ body.push(`<g data-balance-period="${period}" transform="translate(${offset},${header.height})" aria-label="${escapeXml(balanceFlowSummary(spec, period))}">`);
160
+ for (const link of scene.links) {
161
+ const source = scene.rows[link.sourceNode.index],
162
+ target = scene.rows[link.targetNode.index];
163
+ const direction = source.direction === "neutral" ? target.direction : source.direction;
164
+ body.push(`<path class="k2b-balance-flow-band" data-balance-band="${source.key}-${target.key}" fill="${balanceFlowColors[direction]}" fill-opacity="0.24" stroke="none" pointer-events="none" d="${link.path}"/>`);
165
+ }
166
+ for (const node of scene.nodes) {
167
+ const row = scene.rows[node.index];
168
+ if (!node.showLabel || row.key === "opening" && period > 0) continue;
169
+ const color = balanceFlowColors[row.direction],
170
+ balance = row.direction === "balance",
171
+ right = node.stage === 2;
172
+ const x = balance ? right ? scene.width - 20 : 20 : node.stage === 1 ? scene.width / 2 : node.x + (right ? -12 : scene.nodeWidth + 12),
173
+ y = node.y + node.height / 2;
174
+ const captionY = balance || node.stage === 1 ? scene.bottom + 20 : scene.labelY.get(node.index) ?? y;
175
+ const leader = !balance && node.stage !== 1 && Math.abs(captionY - y) > 1 ? `<path class="k2b-chart-category-band" d="M${node.x + (right ? 0 : scene.nodeWidth)},${y}L${x},${captionY}" fill="none" stroke="${color}" stroke-width="1"/>` : "";
176
+ const captionWidth = node.stage === 1 ? 130 : balance ? 220 : 180;
177
+ // One caption and one inspection target represent both sides of each carry.
178
+ const captionText = balance ? `${right ? spec.periods[period].label : row.label} · ${balanceFlowDisplayAmount(spec, row)}${right && row.value < 0 ? ` (${balanceFlowWords(spec.locale).balanceOwed})` : ""}` : row.label;
179
+ const caption = `<g class="${balance ? "k2b-balance-flow-carry" : "k2b-balance-flow-caption"}" data-balance-caption="${row.key}" fill="var(--k2b-text,#27272a)" font-family="inherit" font-size="12" text-anchor="${node.stage === 1 ? "middle" : right ? "end" : "start"}" stroke="var(--k2b-surface,#fff)" stroke-width="4" paint-order="stroke">${leader}<text x="${x}" y="${captionY - 3}">${escapeXml(fitChartText(captionText, captionWidth, 12))}</text>${balance ? "" : `<text x="${x}" y="${captionY + 14}" font-weight="600" style="font-variant-numeric:tabular-nums">${escapeXml(fitChartText(balanceFlowDisplayAmount(spec, row), captionWidth, 12))}</text>`}</g>`;
180
+ const datum = datums.find(d => d.seriesIndex === period && d.index === node.index);
181
+ body.push(chartDatumSvg(`<rect data-balance-key="${row.key}" x="${node.x}" y="${node.y}" width="${scene.nodeWidth}" height="${node.height}" fill="${color}" stroke="none"/>${caption}`, {
182
+ ...datum,
183
+ anchor: [node.x + scene.nodeWidth / 2, y]
184
+ }, spec.inspect).replace(/<title>[\s\S]*?<\/title>/g, "").replace("<g ", `<g role="img" aria-label="${escapeXml([datum.label, ...balanceFlowTooltip(datum, spec.locale).rows.map(field => `${field.label}: ${field.value}`)].join(" · "))}" `));
185
+ }
186
+ body.push("</g>");
187
+ }
188
+ const height = balanceFlowHeight(spec.periods, spec.height) + header.height;
189
+ return svgRoot({
190
+ width,
191
+ height,
192
+ className: spec.className
193
+ }, body.join("")).replace(/<style>[\s\S]*?<\/style>/, "").replace("<svg ", '<svg data-balance-flow-svg="true" ');
194
+ }
195
+ //# sourceMappingURL=balance-flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["charts/core/balance-flow.ts"],"sourcesContent":["import {\n type BalanceFlowOptions,\n balanceFlowDatums,\n balanceFlowDisplayAmount,\n balanceFlowRows,\n balanceFlowSummary,\n balanceFlowTooltip,\n balanceFlowWords,\n} from \"./balance-flow-data\";\n\nexport * from \"./balance-flow-data\";\n\nimport { balanceFlowHeight, validateBalanceFlow } from \"./balance-flow-size\";\nimport { chartDatumSvg, escapeXml, renderHeader, svgRoot } from \"./svg-common\";\n\n/** Conservative proportional-font advances in em, shared by DOM-free SVG label layout.\n * Wide glyphs retain their natural shape; fitting removes whole code points instead of stretching text.\n */\nfunction chartTextWidth(text: string, size: number): number {\n return (\n Array.from(text).reduce(\n (width, glyph) =>\n width +\n (/\\s/.test(glyph)\n ? 0.34\n : /[ilI.,:;!|'`]/.test(glyph)\n ? 0.32\n : /[MW@%&]/.test(glyph)\n ? 1\n : /[A-Z0-9]/.test(glyph)\n ? 0.74\n : /[a-zäöüßéèáàóúñç()-]/i.test(glyph)\n ? 0.64\n : 1),\n 0,\n ) * size\n );\n}\n\nfunction fitChartText(text: string, width: number, size: number): string {\n if (chartTextWidth(text, size) <= width) return text;\n const glyphs = Array.from(text);\n while (glyphs.length && chartTextWidth(glyphs.join(\"\") + \"…\", size) > width) glyphs.pop();\n return chartTextWidth(\"…\", size) <= width ? glyphs.join(\"\") + \"…\" : \"\";\n}\n\nimport type { ChartDatum } from \"./types\";\n\nexport {\n BalanceFlowError,\n type BalanceFlowItem,\n type BalanceFlowPeriod,\n balanceFlowHeight,\n validateBalanceFlow,\n} from \"./balance-flow-size\";\nexport const balanceFlowColors = {\n balance: \"var(--k2b-balance-flow-mark,#3b82f6)\",\n in: \"var(--k2b-flow-in-mark,#0891b2)\",\n out: \"var(--k2b-flow-out-mark,#8b5cf6)\",\n neutral: \"var(--k2b-placeholder-color,#71717a)\",\n};\n/** Common scale and bottom edge make every closing/opening join geometrically identical. */\nexport function balanceFlowLayout(spec: BalanceFlowOptions) {\n validateBalanceFlow(spec.periods);\n const index = spec.period ?? 0;\n if (!Number.isInteger(index) || index < 0 || index >= Math.max(1, spec.periods.length)) throw new RangeError(\"Invalid period.\");\n const width = Math.max(620, spec.width ?? 620),\n height = balanceFlowHeight(spec.periods, spec.height);\n const rows = balanceFlowRows(spec, index);\n const nodes = rows.map((n, index) => ({\n id: n.key,\n index,\n incoming: 0,\n outgoing: 0,\n value: 0,\n stage: 0,\n x: 0,\n y: 0,\n height: 0,\n showLabel: false,\n }));\n const links = rows\n .filter((n) => n.key !== \"balance\" && n.value !== 0)\n .map((n) => {\n const source = n.direction === \"in\" || (n.key === \"opening\" && n.value > 0) || (n.key === \"closing\" && n.value < 0);\n return { source: source ? n.key : \"balance\", target: source ? \"balance\" : n.key, value: Math.abs(n.value) };\n });\n // This reconciled star is acyclic by construction. Keep Sankey node value = max(in, out),\n // without running a general graph layout that every position below would replace.\n const routedLinks = links.map((link) => {\n const sourceNode = nodes.find((n) => n.id === link.source)!;\n const targetNode = nodes.find((n) => n.id === link.target)!;\n sourceNode.outgoing += link.value;\n targetNode.incoming += link.value;\n return { ...link, sourceNode, targetNode };\n });\n for (const node of nodes) node.value = Math.max(node.incoming, node.outgoing);\n const scene = { nodes, links: routedLinks, width, height, header: { height: 0 } };\n const bottom = height - 46,\n top = 16;\n const largest = Math.max(1, ...spec.periods.map((_, i) => balanceFlowRows(spec, i).find((r) => r.key === \"balance\")!.value));\n const gaps = Math.max(1, ...spec.periods.map((p) => Math.max(p.inflows.length, p.outflows.length)));\n const scale = Math.max(0, bottom - top - gaps * 12) / largest;\n const nodeWidth = 8;\n for (const node of scene.nodes) {\n const row = rows[node.index]!;\n node.stage = row.key === \"balance\" ? 1 : row.direction === \"in\" || row.key === \"opening\" ? 0 : 2;\n node.x =\n row.key === \"opening\"\n ? index > 0\n ? -nodeWidth / 2\n : 0\n : row.key === \"closing\"\n ? width - (index + 1 < spec.periods.length ? nodeWidth / 2 : nodeWidth)\n : node.stage === 0\n ? 40\n : node.stage === 1\n ? width / 2 - nodeWidth / 2\n : width - 40 - nodeWidth;\n node.height = Math.max(1, Math.abs(row.value) * scale);\n node.y = bottom - node.height;\n node.showLabel = node.value > 0 || row.key === \"opening\" || row.key === \"closing\";\n }\n for (const stage of scene.nodes.length ? [0, 2] : []) {\n let cursor = top;\n for (const node of scene.nodes.filter((n) => n.stage === stage && n.id !== \"opening\" && n.id !== \"closing\")) {\n node.y = cursor;\n cursor += node.height + 12;\n }\n }\n const labelY = new Map<number, number>();\n for (const stage of [0, 1, 2]) {\n const labels = scene.nodes\n .filter((n) => n.stage === stage && n.showLabel && rows[n.index]!.direction !== \"balance\")\n .sort((a, b) => a.y - b.y);\n labels.forEach((node, i) =>\n labelY.set(node.index, Math.max(node.y + node.height / 2, i ? labelY.get(labels[i - 1]!.index)! + 36 : top + 12)),\n );\n for (let i = labels.length - 1; i >= 0; i--) {\n const node = labels[i]!;\n labelY.set(\n node.index,\n Math.min(labelY.get(node.index)!, i + 1 < labels.length ? labelY.get(labels[i + 1]!.index)! - 36 : bottom - 24),\n );\n }\n }\n const used = new Map<number, number>();\n const routed = scene.links.map((link) => {\n const source = link.sourceNode,\n target = link.targetNode,\n thickness = Math.max(1, link.value * scale);\n const edgeY = (node: typeof source, other: typeof source) => {\n if (node.id !== \"balance\") return node.y;\n const side = other.stage === 0 ? 0 : 2;\n const offset = used.get(side) ?? 0;\n used.set(side, offset + thickness);\n return node.y + offset;\n };\n // Put the carry-forward band at the bottom on both sides of the available node.\n const sy = source.id === \"balance\" && (target.id === \"opening\" || target.id === \"closing\") ? bottom - thickness : edgeY(source, target);\n const ty = target.id === \"balance\" && (source.id === \"opening\" || source.id === \"closing\") ? bottom - thickness : edgeY(target, source);\n const forward = source.x < target.x;\n const boundaryX = (node: typeof source) => (node.id === \"opening\" ? 0 : node.id === \"closing\" ? width : undefined);\n const x1 = boundaryX(source) ?? source.x + (forward ? nodeWidth : 0),\n x2 = boundaryX(target) ?? target.x + (forward ? 0 : nodeWidth),\n mid = (x1 + x2) / 2;\n return {\n ...link,\n thickness,\n sy,\n ty,\n x1,\n x2,\n path: `M${x1},${sy}C${mid},${sy} ${mid},${ty} ${x2},${ty}L${x2},${ty + thickness}C${mid},${ty + thickness} ${mid},${sy + thickness} ${x1},${sy + thickness}Z`,\n };\n });\n return { ...scene, nodeWidth, links: routed, rows, labelY, scale, bottom };\n}\nexport function renderBalanceFlowSvg(spec: BalanceFlowOptions): string {\n validateBalanceFlow(spec.periods);\n const periodWidth = Math.max(620, spec.width ?? 620),\n width = periodWidth * Math.max(1, spec.periods.length);\n const header = renderHeader(width, spec.title, spec.subtitle);\n const body: string[] = [header.svg.replace(/<text /g, '<text fill=\"var(--k2b-text,#27272a)\" font-size=\"13\" ')];\n const datums = balanceFlowDatums(spec);\n for (const [period] of spec.periods.entries()) {\n const scene = balanceFlowLayout({ ...spec, period });\n const offset = period * periodWidth;\n body.push(\n `<g data-balance-period=\"${period}\" transform=\"translate(${offset},${header.height})\" aria-label=\"${escapeXml(balanceFlowSummary(spec, period))}\">`,\n );\n for (const link of scene.links) {\n const source = scene.rows[link.sourceNode.index]!,\n target = scene.rows[link.targetNode.index]!;\n const direction = source.direction === \"neutral\" ? target.direction : source.direction;\n body.push(\n `<path class=\"k2b-balance-flow-band\" data-balance-band=\"${source.key}-${target.key}\" fill=\"${balanceFlowColors[direction]}\" fill-opacity=\"0.24\" stroke=\"none\" pointer-events=\"none\" d=\"${link.path}\"/>`,\n );\n }\n for (const node of scene.nodes) {\n const row = scene.rows[node.index]!;\n if (!node.showLabel || (row.key === \"opening\" && period > 0)) continue;\n const color = balanceFlowColors[row.direction],\n balance = row.direction === \"balance\",\n right = node.stage === 2;\n const x = balance\n ? right\n ? scene.width - 20\n : 20\n : node.stage === 1\n ? scene.width / 2\n : node.x + (right ? -12 : scene.nodeWidth + 12),\n y = node.y + node.height / 2;\n const captionY = balance || node.stage === 1 ? scene.bottom + 20 : (scene.labelY.get(node.index) ?? y);\n const leader =\n !balance && node.stage !== 1 && Math.abs(captionY - y) > 1\n ? `<path class=\"k2b-chart-category-band\" d=\"M${node.x + (right ? 0 : scene.nodeWidth)},${y}L${x},${captionY}\" fill=\"none\" stroke=\"${color}\" stroke-width=\"1\"/>`\n : \"\";\n const captionWidth = node.stage === 1 ? 130 : balance ? 220 : 180;\n // One caption and one inspection target represent both sides of each carry.\n const captionText = balance\n ? `${right ? spec.periods[period]!.label : row.label} · ${balanceFlowDisplayAmount(spec, row)}${right && row.value < 0 ? ` (${balanceFlowWords(spec.locale).balanceOwed})` : \"\"}`\n : row.label;\n const caption = `<g class=\"${balance ? \"k2b-balance-flow-carry\" : \"k2b-balance-flow-caption\"}\" data-balance-caption=\"${row.key}\" fill=\"var(--k2b-text,#27272a)\" font-family=\"inherit\" font-size=\"12\" text-anchor=\"${node.stage === 1 ? \"middle\" : right ? \"end\" : \"start\"}\" stroke=\"var(--k2b-surface,#fff)\" stroke-width=\"4\" paint-order=\"stroke\">${leader}<text x=\"${x}\" y=\"${captionY - 3}\">${escapeXml(fitChartText(captionText, captionWidth, 12))}</text>${balance ? \"\" : `<text x=\"${x}\" y=\"${captionY + 14}\" font-weight=\"600\" style=\"font-variant-numeric:tabular-nums\">${escapeXml(fitChartText(balanceFlowDisplayAmount(spec, row), captionWidth, 12))}</text>`}</g>`;\n const datum = datums.find((d) => d.seriesIndex === period && d.index === node.index)!;\n body.push(\n chartDatumSvg(\n `<rect data-balance-key=\"${row.key}\" x=\"${node.x}\" y=\"${node.y}\" width=\"${scene.nodeWidth}\" height=\"${node.height}\" fill=\"${color}\" stroke=\"none\"/>${caption}`,\n { ...datum, anchor: [node.x + scene.nodeWidth / 2, y] },\n spec.inspect,\n )\n .replace(/<title>[\\s\\S]*?<\\/title>/g, \"\")\n .replace(\n \"<g \",\n `<g role=\"img\" aria-label=\"${escapeXml([datum.label, ...balanceFlowTooltip(datum, spec.locale).rows.map((field) => `${field.label}: ${field.value}`)].join(\" · \"))}\" `,\n ),\n );\n }\n body.push(\"</g>\");\n }\n const height = balanceFlowHeight(spec.periods, spec.height) + header.height;\n return svgRoot({ width, height, className: spec.className }, body.join(\"\"))\n .replace(/<style>[\\s\\S]*?<\\/style>/, \"\")\n .replace(\"<svg \", '<svg data-balance-flow-svg=\"true\" ');\n}\n"],"mappings":"AAAA,SAEE,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,QACX,qBAAqB;AAE5B,cAAc,qBAAqB;AAEnC,SAAS,iBAAiB,EAAE,mBAAmB,QAAQ,qBAAqB;AAC5E,SAAS,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,QAAQ,cAAc;;AAE9E;AACA;AACA;AACA,SAAS,cAAc,CAAC,IAAY,EAAE,IAAY,EAAU;EAC1D,OACE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CACrB,CAAC,KAAK,EAAE,KAAK,KACX,KAAK,IACJ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GACb,IAAI,GACJ,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,GACzB,IAAI,GACJ,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GACnB,CAAC,GACD,UAAU,CAAC,IAAI,CAAC,KAAK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