@k2b/ui 0.53.0 → 0.55.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.
- package/dist/base.css +103 -0
- package/dist/browser/actions/SortableList.js +174 -0
- package/dist/browser/actions/SortableList.js.map +1 -0
- package/dist/browser/actions/Toolbar.js +186 -101
- package/dist/browser/actions/Toolbar.js.map +1 -1
- package/dist/browser/actions/drag-and-drop.js +2 -1
- package/dist/browser/actions/drag-and-drop.js.map +1 -1
- package/dist/browser/actions/index.js +1 -0
- package/dist/browser/actions/index.js.map +1 -1
- package/dist/browser/actions/sortable-list-messages.js +35 -0
- package/dist/browser/actions/sortable-list-messages.js.map +1 -0
- package/dist/browser/chart-inspection.js +2 -1
- package/dist/browser/chart-inspection.js.map +1 -1
- package/dist/browser/charts/core/balance-flow-data.js +93 -0
- package/dist/browser/charts/core/balance-flow-data.js.map +1 -0
- package/dist/browser/charts/core/balance-flow-fields.js +19 -0
- package/dist/browser/charts/core/balance-flow-fields.js.map +1 -0
- package/dist/browser/charts/core/balance-flow-frame.js +44 -0
- package/dist/browser/charts/core/balance-flow-frame.js.map +1 -0
- package/dist/browser/charts/core/balance-flow-messages.js +49 -0
- package/dist/browser/charts/core/balance-flow-messages.js.map +1 -0
- package/dist/browser/charts/core/balance-flow-size.js +42 -0
- package/dist/browser/charts/core/balance-flow-size.js.map +1 -0
- package/dist/browser/charts/core/balance-flow.js +195 -0
- package/dist/browser/charts/core/balance-flow.js.map +1 -0
- package/dist/browser/charts/core/calendar-layout.js +105 -0
- package/dist/browser/charts/core/calendar-layout.js.map +1 -0
- package/dist/browser/charts/core/calendar.js +2 -104
- package/dist/browser/charts/core/calendar.js.map +1 -1
- package/dist/browser/charts/core/index.js +9 -1
- package/dist/browser/charts/core/index.js.map +1 -1
- package/dist/browser/charts/core/inspection.js +2 -1
- package/dist/browser/charts/core/inspection.js.map +1 -1
- package/dist/browser/charts/core/number-format.js +53 -0
- package/dist/browser/charts/core/number-format.js.map +1 -0
- package/dist/browser/charts/core/registry.js +3 -1
- package/dist/browser/charts/core/registry.js.map +1 -1
- package/dist/browser/charts/core/render-size.js +2 -0
- package/dist/browser/charts/core/render-size.js.map +1 -1
- package/dist/browser/charts/core/render.js +8 -1
- package/dist/browser/charts/core/render.js.map +1 -1
- package/dist/browser/charts/core/snapshot.js +3 -3
- package/dist/browser/charts/core/snapshot.js.map +1 -1
- package/dist/browser/charts/core/types.js.map +1 -1
- package/dist/browser/charts/description.js.map +1 -1
- package/dist/browser/charts.js +2 -0
- package/dist/browser/charts.js.map +1 -1
- package/dist/browser/content/Chart.js +3 -1
- package/dist/browser/content/Chart.js.map +1 -1
- package/dist/browser/content/ChartBalanceFlow.js +90 -0
- package/dist/browser/content/ChartBalanceFlow.js.map +1 -0
- package/dist/browser/content/ChartExplorer.js +1 -1
- package/dist/browser/content/ChartExplorer.js.map +1 -1
- package/dist/browser/content/ChartRoot.js +1 -1
- package/dist/browser/content/ChartRoot.js.map +1 -1
- package/dist/browser/content/DataTable.js +212 -261
- package/dist/browser/content/DataTable.js.map +1 -1
- package/dist/browser/content/FileView.js +70 -99
- package/dist/browser/content/FileView.js.map +1 -1
- package/dist/browser/content/LoadMore.js +185 -0
- package/dist/browser/content/LoadMore.js.map +1 -0
- package/dist/browser/content/MapDialog.js +686 -0
- package/dist/browser/content/MapDialog.js.map +1 -0
- package/dist/browser/content/MapTile.js +139 -0
- package/dist/browser/content/MapTile.js.map +1 -0
- package/dist/browser/content/MapView.js +19 -8
- package/dist/browser/content/MapView.js.map +1 -1
- package/dist/browser/content/PdfPages.js +638 -0
- package/dist/browser/content/PdfPages.js.map +1 -0
- package/dist/browser/content/PdfViewer.js +264 -553
- package/dist/browser/content/PdfViewer.js.map +1 -1
- package/dist/browser/content/VirtualFeed.js +379 -89
- package/dist/browser/content/VirtualFeed.js.map +1 -1
- package/dist/browser/content/chart-balance-flow-controller.js +184 -0
- package/dist/browser/content/chart-balance-flow-controller.js.map +1 -0
- package/dist/browser/content/chart-balance-flow.js +6 -0
- package/dist/browser/content/chart-balance-flow.js.map +1 -0
- package/dist/browser/content/chart-inspection-core.js +1 -73
- package/dist/browser/content/chart-inspection-core.js.map +1 -1
- package/dist/browser/content/chart-inspection-mount.js +75 -0
- package/dist/browser/content/chart-inspection-mount.js.map +1 -0
- package/dist/browser/content/chart-svg.js +1 -1
- package/dist/browser/content/chart-svg.js.map +1 -1
- package/dist/browser/content/feed-messages.js +22 -2
- package/dist/browser/content/feed-messages.js.map +1 -1
- package/dist/browser/content/index.js +4 -1
- package/dist/browser/content/index.js.map +1 -1
- package/dist/browser/content/map-dialog-messages.js +47 -0
- package/dist/browser/content/map-dialog-messages.js.map +1 -0
- package/dist/browser/content/map-navigation.js +15 -0
- package/dist/browser/content/map-navigation.js.map +1 -0
- package/dist/browser/content/map-view-messages.js +4 -0
- package/dist/browser/content/map-view-messages.js.map +1 -1
- package/dist/browser/content/map-view-types.js.map +1 -1
- package/dist/browser/content/pdf-messages.js +8 -8
- package/dist/browser/content/pdf-messages.js.map +1 -1
- package/dist/browser/feedback/dialog-core.js +22 -10
- package/dist/browser/feedback/dialog-core.js.map +1 -1
- package/dist/browser/feedback/index.js.map +1 -1
- package/dist/browser/feedback/prompt-confirm.js +25 -14
- package/dist/browser/feedback/prompt-confirm.js.map +1 -1
- package/dist/browser/feedback/prompts.js +46 -38
- package/dist/browser/feedback/prompts.js.map +1 -1
- package/dist/browser/feedback/success-check.js +60 -0
- package/dist/browser/feedback/success-check.js.map +1 -0
- package/dist/browser/feedback/toast-hit.js +16 -0
- package/dist/browser/feedback/toast-hit.js.map +1 -0
- package/dist/browser/feedback/toast-messages.js +6 -2
- package/dist/browser/feedback/toast-messages.js.map +1 -1
- package/dist/browser/feedback/toast.js +609 -98
- package/dist/browser/feedback/toast.js.map +1 -1
- package/dist/browser/intl/messages.js +4 -0
- package/dist/browser/intl/messages.js.map +1 -1
- package/dist/browser/layout/AppWorkspace.js +58 -21
- package/dist/browser/layout/AppWorkspace.js.map +1 -1
- package/dist/browser/layout/BottomSheet.js +58 -40
- package/dist/browser/layout/BottomSheet.js.map +1 -1
- package/dist/browser/layout/Breadcrumbs.js +97 -0
- package/dist/browser/layout/Breadcrumbs.js.map +1 -0
- package/dist/browser/layout/DetailPanel.js +27 -27
- package/dist/browser/layout/DetailPanel.js.map +1 -1
- package/dist/browser/layout/Discussion.js +119 -160
- package/dist/browser/layout/Discussion.js.map +1 -1
- package/dist/browser/layout/PanelDialog.js +130 -116
- package/dist/browser/layout/PanelDialog.js.map +1 -1
- package/dist/browser/layout/index.js +1 -0
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/browser/layout/sheet-motion.js +479 -0
- package/dist/browser/layout/sheet-motion.js.map +1 -0
- package/dist/browser/surfaces/NoticeCard.js +68 -47
- package/dist/browser/surfaces/NoticeCard.js.map +1 -1
- package/dist/browser/surfaces/Skeleton.js +32 -0
- package/dist/browser/surfaces/Skeleton.js.map +1 -1
- package/dist/browser/surfaces/index.js +1 -1
- package/dist/browser/surfaces/index.js.map +1 -1
- package/dist/browser/text-editor/TextEditor.js +7 -3
- package/dist/browser/text-editor/TextEditor.js.map +1 -1
- package/dist/browser/text-editor/clipboard-html.js +62 -26
- package/dist/browser/text-editor/clipboard-html.js.map +1 -1
- package/dist/browser/text-editor/clipboard-loading.js +44 -15
- package/dist/browser/text-editor/clipboard-loading.js.map +1 -1
- package/dist/browser/text-editor/engine.js +9 -4
- package/dist/browser/text-editor/engine.js.map +1 -1
- package/dist/browser/text-editor/format.js +37 -1
- package/dist/browser/text-editor/format.js.map +1 -1
- package/dist/browser/text-editor/paste.js +2 -1
- package/dist/browser/text-editor/paste.js.map +1 -1
- package/dist/ssr/actions/SortableList.js +116 -0
- package/dist/ssr/actions/SortableList.js.map +1 -0
- package/dist/ssr/actions/Toolbar.js +89 -35
- package/dist/ssr/actions/Toolbar.js.map +1 -1
- package/dist/ssr/actions/drag-and-drop.js +2 -1
- package/dist/ssr/actions/drag-and-drop.js.map +1 -1
- package/dist/ssr/actions/index.js +1 -0
- package/dist/ssr/actions/index.js.map +1 -1
- package/dist/ssr/actions/sortable-list-messages.js +35 -0
- package/dist/ssr/actions/sortable-list-messages.js.map +1 -0
- package/dist/ssr/chart-inspection.js +2 -1
- package/dist/ssr/chart-inspection.js.map +1 -1
- package/dist/ssr/charts/core/balance-flow-data.js +93 -0
- package/dist/ssr/charts/core/balance-flow-data.js.map +1 -0
- package/dist/ssr/charts/core/balance-flow-fields.js +19 -0
- package/dist/ssr/charts/core/balance-flow-fields.js.map +1 -0
- package/dist/ssr/charts/core/balance-flow-frame.js +44 -0
- package/dist/ssr/charts/core/balance-flow-frame.js.map +1 -0
- package/dist/ssr/charts/core/balance-flow-messages.js +49 -0
- package/dist/ssr/charts/core/balance-flow-messages.js.map +1 -0
- package/dist/ssr/charts/core/balance-flow-size.js +42 -0
- package/dist/ssr/charts/core/balance-flow-size.js.map +1 -0
- package/dist/ssr/charts/core/balance-flow.js +195 -0
- package/dist/ssr/charts/core/balance-flow.js.map +1 -0
- package/dist/ssr/charts/core/calendar-layout.js +105 -0
- package/dist/ssr/charts/core/calendar-layout.js.map +1 -0
- package/dist/ssr/charts/core/calendar.js +2 -104
- package/dist/ssr/charts/core/calendar.js.map +1 -1
- package/dist/ssr/charts/core/index.js +9 -1
- package/dist/ssr/charts/core/index.js.map +1 -1
- package/dist/ssr/charts/core/inspection.js +2 -1
- package/dist/ssr/charts/core/inspection.js.map +1 -1
- package/dist/ssr/charts/core/number-format.js +53 -0
- package/dist/ssr/charts/core/number-format.js.map +1 -0
- package/dist/ssr/charts/core/registry.js +3 -1
- package/dist/ssr/charts/core/registry.js.map +1 -1
- package/dist/ssr/charts/core/render-size.js +2 -0
- package/dist/ssr/charts/core/render-size.js.map +1 -1
- package/dist/ssr/charts/core/render.js +8 -1
- package/dist/ssr/charts/core/render.js.map +1 -1
- package/dist/ssr/charts/core/snapshot.js +3 -3
- package/dist/ssr/charts/core/snapshot.js.map +1 -1
- package/dist/ssr/charts/core/types.js.map +1 -1
- package/dist/ssr/charts/description.js.map +1 -1
- package/dist/ssr/charts.js +2 -0
- package/dist/ssr/charts.js.map +1 -1
- package/dist/ssr/content/Chart.js +3 -1
- package/dist/ssr/content/Chart.js.map +1 -1
- package/dist/ssr/content/ChartBalanceFlow.js +69 -0
- package/dist/ssr/content/ChartBalanceFlow.js.map +1 -0
- package/dist/ssr/content/ChartExplorer.js +1 -1
- package/dist/ssr/content/ChartExplorer.js.map +1 -1
- package/dist/ssr/content/ChartRoot.js +1 -1
- package/dist/ssr/content/ChartRoot.js.map +1 -1
- package/dist/ssr/content/DataTable.js +72 -118
- package/dist/ssr/content/DataTable.js.map +1 -1
- package/dist/ssr/content/FileView.js +39 -50
- package/dist/ssr/content/FileView.js.map +1 -1
- package/dist/ssr/content/LoadMore.js +146 -0
- package/dist/ssr/content/LoadMore.js.map +1 -0
- package/dist/ssr/content/MapDialog.js +469 -0
- package/dist/ssr/content/MapDialog.js.map +1 -0
- package/dist/ssr/content/MapTile.js +92 -0
- package/dist/ssr/content/MapTile.js.map +1 -0
- package/dist/ssr/content/MapView.js +12 -8
- package/dist/ssr/content/MapView.js.map +1 -1
- package/dist/ssr/content/PdfPages.js +538 -0
- package/dist/ssr/content/PdfPages.js.map +1 -0
- package/dist/ssr/content/PdfViewer.js +226 -457
- package/dist/ssr/content/PdfViewer.js.map +1 -1
- package/dist/ssr/content/VirtualFeed.js +292 -44
- package/dist/ssr/content/VirtualFeed.js.map +1 -1
- package/dist/ssr/content/chart-balance-flow-controller.js +184 -0
- package/dist/ssr/content/chart-balance-flow-controller.js.map +1 -0
- package/dist/ssr/content/chart-balance-flow.js +6 -0
- package/dist/ssr/content/chart-balance-flow.js.map +1 -0
- package/dist/ssr/content/chart-inspection-core.js +1 -73
- package/dist/ssr/content/chart-inspection-core.js.map +1 -1
- package/dist/ssr/content/chart-inspection-mount.js +75 -0
- package/dist/ssr/content/chart-inspection-mount.js.map +1 -0
- package/dist/ssr/content/chart-svg.js +1 -1
- package/dist/ssr/content/chart-svg.js.map +1 -1
- package/dist/ssr/content/feed-messages.js +22 -2
- package/dist/ssr/content/feed-messages.js.map +1 -1
- package/dist/ssr/content/index.js +4 -1
- package/dist/ssr/content/index.js.map +1 -1
- package/dist/ssr/content/map-dialog-messages.js +47 -0
- package/dist/ssr/content/map-dialog-messages.js.map +1 -0
- package/dist/ssr/content/map-navigation.js +15 -0
- package/dist/ssr/content/map-navigation.js.map +1 -0
- package/dist/ssr/content/map-view-messages.js +4 -0
- package/dist/ssr/content/map-view-messages.js.map +1 -1
- package/dist/ssr/content/map-view-types.js.map +1 -1
- package/dist/ssr/content/pdf-messages.js +8 -8
- package/dist/ssr/content/pdf-messages.js.map +1 -1
- package/dist/ssr/feedback/dialog-core.js +22 -10
- package/dist/ssr/feedback/dialog-core.js.map +1 -1
- package/dist/ssr/feedback/index.js.map +1 -1
- package/dist/ssr/feedback/prompt-confirm.js +13 -2
- package/dist/ssr/feedback/prompt-confirm.js.map +1 -1
- package/dist/ssr/feedback/prompts.js +32 -24
- package/dist/ssr/feedback/prompts.js.map +1 -1
- package/dist/ssr/feedback/success-check.js +47 -0
- package/dist/ssr/feedback/success-check.js.map +1 -0
- package/dist/ssr/feedback/toast-hit.js +16 -0
- package/dist/ssr/feedback/toast-hit.js.map +1 -0
- package/dist/ssr/feedback/toast-messages.js +6 -2
- package/dist/ssr/feedback/toast-messages.js.map +1 -1
- package/dist/ssr/feedback/toast.js +609 -98
- package/dist/ssr/feedback/toast.js.map +1 -1
- package/dist/ssr/intl/messages.js +4 -0
- package/dist/ssr/intl/messages.js.map +1 -1
- package/dist/ssr/layout/AppWorkspace.js +39 -5
- package/dist/ssr/layout/AppWorkspace.js.map +1 -1
- package/dist/ssr/layout/BottomSheet.js +32 -4
- package/dist/ssr/layout/BottomSheet.js.map +1 -1
- package/dist/ssr/layout/Breadcrumbs.js +62 -0
- package/dist/ssr/layout/Breadcrumbs.js.map +1 -0
- package/dist/ssr/layout/DetailPanel.js +10 -10
- package/dist/ssr/layout/DetailPanel.js.map +1 -1
- package/dist/ssr/layout/Discussion.js +39 -65
- package/dist/ssr/layout/Discussion.js.map +1 -1
- package/dist/ssr/layout/PanelDialog.js +54 -35
- package/dist/ssr/layout/PanelDialog.js.map +1 -1
- package/dist/ssr/layout/index.js +1 -0
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/ssr/layout/sheet-motion.js +479 -0
- package/dist/ssr/layout/sheet-motion.js.map +1 -0
- package/dist/ssr/surfaces/NoticeCard.js +33 -17
- package/dist/ssr/surfaces/NoticeCard.js.map +1 -1
- package/dist/ssr/surfaces/Skeleton.js +32 -0
- package/dist/ssr/surfaces/Skeleton.js.map +1 -1
- package/dist/ssr/surfaces/index.js +1 -1
- package/dist/ssr/surfaces/index.js.map +1 -1
- package/dist/ssr/text-editor/TextEditor.js +7 -3
- package/dist/ssr/text-editor/TextEditor.js.map +1 -1
- package/dist/ssr/text-editor/clipboard-html.js +62 -26
- package/dist/ssr/text-editor/clipboard-html.js.map +1 -1
- package/dist/ssr/text-editor/clipboard-loading.js +44 -15
- package/dist/ssr/text-editor/clipboard-loading.js.map +1 -1
- package/dist/ssr/text-editor/engine.js +9 -4
- package/dist/ssr/text-editor/engine.js.map +1 -1
- package/dist/ssr/text-editor/format.js +37 -1
- package/dist/ssr/text-editor/format.js.map +1 -1
- package/dist/ssr/text-editor/paste.js +2 -1
- package/dist/ssr/text-editor/paste.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/SortableList.d.ts +26 -0
- package/dist/types/actions/Toolbar.d.ts +11 -0
- package/dist/types/actions/drag-and-drop.d.ts +2 -0
- package/dist/types/actions/index.d.ts +2 -0
- package/dist/types/actions/sortable-list-messages.d.ts +15 -0
- package/dist/types/chart-inspection.d.ts +2 -1
- package/dist/types/charts/core/balance-flow-data.d.ts +37 -0
- package/dist/types/charts/core/balance-flow-fields.d.ts +13 -0
- package/dist/types/charts/core/balance-flow-frame.d.ts +4 -0
- package/dist/types/charts/core/balance-flow-messages.d.ts +97 -0
- package/dist/types/charts/core/balance-flow-size.d.ts +21 -0
- package/dist/types/charts/core/balance-flow.d.ts +70 -0
- package/dist/types/charts/core/calendar-layout.d.ts +67 -0
- package/dist/types/charts/core/calendar.d.ts +2 -64
- package/dist/types/charts/core/index.d.ts +9 -1
- package/dist/types/charts/core/number-format.d.ts +28 -0
- package/dist/types/charts/core/registry.d.ts +2 -0
- package/dist/types/charts/core/types.d.ts +1 -0
- package/dist/types/charts/description.d.ts +17 -0
- package/dist/types/charts.d.ts +2 -0
- package/dist/types/content/ChartBalanceFlow.d.ts +17 -0
- package/dist/types/content/ChartRoot.d.ts +2 -1
- package/dist/types/content/DataTable.d.ts +7 -1
- package/dist/types/content/LoadMore.d.ts +41 -0
- package/dist/types/content/MapDialog.d.ts +105 -0
- package/dist/types/content/MapTile.d.ts +37 -0
- package/dist/types/content/PdfPages.d.ts +57 -0
- package/dist/types/content/PdfViewer.d.ts +35 -19
- package/dist/types/content/VirtualFeed.d.ts +57 -18
- package/dist/types/content/chart-balance-flow-controller.d.ts +12 -0
- package/dist/types/content/chart-balance-flow.d.ts +4 -0
- package/dist/types/content/chart-inspection-core.d.ts +0 -17
- package/dist/types/content/chart-inspection-mount.d.ts +21 -0
- package/dist/types/content/feed-messages.d.ts +10 -0
- package/dist/types/content/index.d.ts +6 -3
- package/dist/types/content/map-dialog-messages.d.ts +19 -0
- package/dist/types/content/map-navigation.d.ts +13 -0
- package/dist/types/content/map-view-messages.d.ts +2 -0
- package/dist/types/content/map-view-types.d.ts +5 -0
- package/dist/types/content/pdf-messages.d.ts +2 -2
- package/dist/types/feedback/dialog-core.d.ts +6 -0
- package/dist/types/feedback/index.d.ts +2 -2
- package/dist/types/feedback/prompt-confirm.d.ts +2 -0
- package/dist/types/feedback/prompts.d.ts +5 -1
- package/dist/types/feedback/success-check.d.ts +4 -0
- package/dist/types/feedback/toast-hit.d.ts +5 -0
- package/dist/types/feedback/toast-messages.d.ts +3 -1
- package/dist/types/feedback/toast.d.ts +42 -5
- package/dist/types/intl/messages.d.ts +2 -0
- package/dist/types/layout/AppWorkspace.d.ts +10 -0
- package/dist/types/layout/BottomSheet.d.ts +6 -0
- package/dist/types/layout/Breadcrumbs.d.ts +19 -0
- package/dist/types/layout/DetailPanel.d.ts +4 -1
- package/dist/types/layout/PanelDialog.d.ts +5 -0
- package/dist/types/layout/index.d.ts +2 -1
- package/dist/types/layout/sheet-motion.d.ts +32 -0
- package/dist/types/surfaces/NoticeCard.d.ts +14 -1
- package/dist/types/surfaces/Skeleton.d.ts +13 -1
- package/dist/types/surfaces/index.d.ts +1 -1
- package/dist/types/text-editor/TextEditor.d.ts +5 -0
- package/dist/types/text-editor/clipboard-loading.d.ts +2 -3
- package/dist/types/text-editor/engine.d.ts +6 -1
- package/dist/types/text-editor/format.d.ts +3 -1
- package/package.json +2 -2
- package/dist/browser/content/PdfPreview.js +0 -448
- package/dist/browser/content/PdfPreview.js.map +0 -1
- package/dist/ssr/content/PdfPreview.js +0 -300
- package/dist/ssr/content/PdfPreview.js.map +0 -1
- package/dist/types/content/PdfPreview.d.ts +0 -26
|
@@ -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,EA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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,GAAG,CAAC;EACzD,OAAO;IAAE,KAAK,EAAE,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC;IAAE,MAAM,EAAE,QAAQ,CAA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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,GAC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CAAE;MACrF,IAAI,CAAC,IAAI,CACP,aAAa,CACX,2BAA2B,GAAG,CAAC,GAAG,QAAQ,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC,SAAS,aAAa,IAAI,CAAC,MAAM,WAAW,KAAK,oBAAoB,OAAO,EAAE,EAC9J;QAAE,GAAG,KAAK;QAAE,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;MAAE,CAAC,EACvD,IAAI,CAAC,OACP,CAAC,CACE,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CACxC,OAAO,CACN,KAAK,EACL,6BAA6B,SAAS,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAE,KAAK,IAAK,GAAG,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IACpK,CACJ,CAAC;IACH;IACA,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;EACnB;EACA,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM;EAC3E,OAAO,OAAO,CAAC;IAAE,KAAK;IAAE,MAAM;IAAE,SAAS,EAAE,IAAI,CAAC;EAAU,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CACxE,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,CACvC,OAAO,CAAC,OAAO,EAAE,oCAAoC,CAAC;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { renderHeader } from "./svg-common";
|
|
2
|
+
export const DAY = 86400000;
|
|
3
|
+
/** Bound sparse inputs too: three leap years of daily observations. */
|
|
4
|
+
export const CALENDAR_MAX_DAYS = 1098;
|
|
5
|
+
export function calendarDay(value) {
|
|
6
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) throw new RangeError("Calendar dates must be YYYY-MM-DD.");
|
|
7
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
8
|
+
if (!Number.isFinite(date.getTime()) || date.toISOString().slice(0, 10) !== value) throw new RangeError("Invalid calendar date.");
|
|
9
|
+
return date.getTime();
|
|
10
|
+
}
|
|
11
|
+
/** Intl uses 1..7, JS dates use 0..6. Old engines use an explicit locale fallback. */
|
|
12
|
+
export function calendarWeekStart(locale = "en") {
|
|
13
|
+
const info = new Intl.Locale(locale);
|
|
14
|
+
const fallback = {
|
|
15
|
+
"en-US": 0
|
|
16
|
+
};
|
|
17
|
+
const key = `${info.language}-${info.region ?? info.maximize().region}`;
|
|
18
|
+
return (info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay ?? fallback[key] ?? 1) % 7;
|
|
19
|
+
}
|
|
20
|
+
export const calendarWords = (locale = "en") => locale.split("-")[0] === "de" ? {
|
|
21
|
+
day: "Tag",
|
|
22
|
+
less: "weniger",
|
|
23
|
+
more: "mehr",
|
|
24
|
+
moreIn: "mehr rein",
|
|
25
|
+
moreOut: "mehr raus"
|
|
26
|
+
} : {
|
|
27
|
+
day: "Day",
|
|
28
|
+
less: "less",
|
|
29
|
+
more: "more",
|
|
30
|
+
moreIn: "more in",
|
|
31
|
+
moreOut: "more out"
|
|
32
|
+
};
|
|
33
|
+
export const calendarColor = (scale, value) => scale === "diverging" ? value < 0 ? "var(--k2b-flow-out-mark,#8b5cf6)" : "var(--k2b-flow-in-mark,#0891b2)" : "var(--stdlib-chart-c1,#3b82f6)";
|
|
34
|
+
export const pixels = value => `${+value.toPrecision(6)}px`;
|
|
35
|
+
export function calendarLayout(spec, size = {
|
|
36
|
+
width: spec.width ?? 480,
|
|
37
|
+
height: spec.height ?? 280
|
|
38
|
+
}) {
|
|
39
|
+
const seen = new Set();
|
|
40
|
+
const dates = spec.data.map(([date, value], index) => {
|
|
41
|
+
if (seen.has(date)) throw new RangeError("Calendar dates must be unique.");
|
|
42
|
+
seen.add(date);
|
|
43
|
+
const time = calendarDay(date);
|
|
44
|
+
if (value !== null && !Number.isNaN(value) && !Number.isFinite(value)) throw new RangeError("Calendar values must be finite.");
|
|
45
|
+
return {
|
|
46
|
+
date,
|
|
47
|
+
value,
|
|
48
|
+
index,
|
|
49
|
+
time
|
|
50
|
+
};
|
|
51
|
+
}).sort((a, b) => a.time - b.time);
|
|
52
|
+
if (dates.length && (dates.at(-1).time - dates[0].time) / DAY >= CALENDAR_MAX_DAYS) throw new RangeError("Calendar span must not exceed three years.");
|
|
53
|
+
const points = dates.filter(p => p.value !== null && Number.isFinite(p.value));
|
|
54
|
+
const weekStart = calendarWeekStart(spec.locale);
|
|
55
|
+
const first = dates[0]?.time ?? 0;
|
|
56
|
+
const monday = first - (new Date(first).getUTCDay() - weekStart + 7) % 7 * DAY;
|
|
57
|
+
const weeks = dates.length ? Math.floor((dates.at(-1).time - monday) / DAY / 7) + 1 : 0;
|
|
58
|
+
// A minimum-size coordinate space scales uniformly in CSS, including on the
|
|
59
|
+
// first server frame. Height follows the seven rows, never a host's fixed box.
|
|
60
|
+
const gap = 3,
|
|
61
|
+
left = 32;
|
|
62
|
+
const cell = Math.max(14, Math.min(32, Math.floor(((spec.displayWidth ?? size.width) - left - 4) / Math.max(1, weeks) - gap)));
|
|
63
|
+
const width = Math.max(240, left + weeks * (cell + gap) + 4);
|
|
64
|
+
const top = 32 + renderHeader(width, spec.title, spec.subtitle).height;
|
|
65
|
+
const min = Math.min(...points.map(p => p.value), 0),
|
|
66
|
+
max = Math.max(...points.map(p => p.value), 0);
|
|
67
|
+
const absMax = Math.max(-min, max);
|
|
68
|
+
return {
|
|
69
|
+
width,
|
|
70
|
+
height: top + 7 * (cell + gap) + 18,
|
|
71
|
+
minWidth: Math.max(240, width * 14 / cell),
|
|
72
|
+
maxWidth: width * 32 / cell,
|
|
73
|
+
firstMonday: monday,
|
|
74
|
+
lastDay: dates.at(-1)?.time ?? first,
|
|
75
|
+
weekStart,
|
|
76
|
+
weeks,
|
|
77
|
+
min,
|
|
78
|
+
max,
|
|
79
|
+
absMax,
|
|
80
|
+
cell,
|
|
81
|
+
cellWidth: cell,
|
|
82
|
+
top,
|
|
83
|
+
cells: points.map(p => {
|
|
84
|
+
const day = Math.round((p.time - monday) / DAY),
|
|
85
|
+
week = Math.floor(day / 7),
|
|
86
|
+
weekday = day % 7;
|
|
87
|
+
const intensity = spec.scale === "diverging" ? Math.abs(p.value) / (absMax || 1) : (p.value - min) / (max - min || 1);
|
|
88
|
+
const color = calendarColor(spec.scale, p.value);
|
|
89
|
+
return {
|
|
90
|
+
...p,
|
|
91
|
+
week,
|
|
92
|
+
weekday,
|
|
93
|
+
x: left + week * (cell + gap),
|
|
94
|
+
y: top + weekday * (cell + gap),
|
|
95
|
+
intensity,
|
|
96
|
+
color
|
|
97
|
+
};
|
|
98
|
+
})
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** A calendar viewport reserves the same content height in every request state. */
|
|
102
|
+
export function calendarViewportHeight(size, availableWidth = "100cqw") {
|
|
103
|
+
return `calc(16px + (${size.height / size.width} * clamp(${pixels(size.minWidth)}, ${availableWidth}, ${pixels(size.maxWidth)})))`;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=calendar-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["charts/core/calendar-layout.ts"],"sourcesContent":["import { type ChartOptions, type HeatmapOptions, renderHeader } from \"./svg-common\";\n\nexport type CalendarHeatmapOptions = ChartOptions & {\n layout: \"calendar\";\n data: [string, number | null][];\n scale: \"sequential\" | \"diverging\";\n /** Unit shown beside each tooltip value. */\n label?: string;\n locale?: string;\n format?: (value: number) => string;\n displayWidth?: number;\n};\nexport type HeatmapChartOptions = (HeatmapOptions & { layout?: undefined }) | CalendarHeatmapOptions;\nexport const DAY = 86400000;\n/** Bound sparse inputs too: three leap years of daily observations. */\nexport const CALENDAR_MAX_DAYS = 1098;\nexport function calendarDay(value: string): number {\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) throw new RangeError(\"Calendar dates must be YYYY-MM-DD.\");\n const date = new Date(`${value}T00:00:00Z`);\n if (!Number.isFinite(date.getTime()) || date.toISOString().slice(0, 10) !== value) throw new RangeError(\"Invalid calendar date.\");\n return date.getTime();\n}\n/** Intl uses 1..7, JS dates use 0..6. Old engines use an explicit locale fallback. */\nexport function calendarWeekStart(locale = \"en\"): number {\n const info: Intl.Locale & { weekInfo?: { firstDay: number }; getWeekInfo?: () => { firstDay: number } } = new Intl.Locale(locale);\n const fallback: Record<string, number> = { \"en-US\": 0 };\n const key = `${info.language}-${info.region ?? info.maximize().region}`;\n return (info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay ?? fallback[key] ?? 1) % 7;\n}\nexport const calendarWords = (locale = \"en\") =>\n locale.split(\"-\")[0] === \"de\"\n ? { day: \"Tag\", less: \"weniger\", more: \"mehr\", moreIn: \"mehr rein\", moreOut: \"mehr raus\" }\n : { day: \"Day\", less: \"less\", more: \"more\", moreIn: \"more in\", moreOut: \"more out\" };\nexport const calendarColor = (scale: CalendarHeatmapOptions[\"scale\"], value: number) =>\n scale === \"diverging\"\n ? value < 0\n ? \"var(--k2b-flow-out-mark,#8b5cf6)\"\n : \"var(--k2b-flow-in-mark,#0891b2)\"\n : \"var(--stdlib-chart-c1,#3b82f6)\";\nexport const pixels = (value: number) => `${+value.toPrecision(6)}px`;\nexport function calendarLayout(spec: CalendarHeatmapOptions, size = { width: spec.width ?? 480, height: spec.height ?? 280 }) {\n const seen = new Set<string>();\n const dates = spec.data\n .map(([date, value], index) => {\n if (seen.has(date)) throw new RangeError(\"Calendar dates must be unique.\");\n seen.add(date);\n const time = calendarDay(date);\n if (value !== null && !Number.isNaN(value) && !Number.isFinite(value)) throw new RangeError(\"Calendar values must be finite.\");\n return { date, value, index, time };\n })\n .sort((a, b) => a.time - b.time);\n if (dates.length && (dates.at(-1)!.time - dates[0]!.time) / DAY >= CALENDAR_MAX_DAYS)\n throw new RangeError(\"Calendar span must not exceed three years.\");\n const points = dates.filter((p): p is typeof p & { value: number } => p.value !== null && Number.isFinite(p.value));\n const weekStart = calendarWeekStart(spec.locale);\n const first = dates[0]?.time ?? 0;\n const monday = first - ((new Date(first).getUTCDay() - weekStart + 7) % 7) * DAY;\n const weeks = dates.length ? Math.floor((dates.at(-1)!.time - monday) / DAY / 7) + 1 : 0;\n // A minimum-size coordinate space scales uniformly in CSS, including on the\n // first server frame. Height follows the seven rows, never a host's fixed box.\n const gap = 3,\n left = 32;\n const cell = Math.max(14, Math.min(32, Math.floor(((spec.displayWidth ?? size.width) - left - 4) / Math.max(1, weeks) - gap)));\n const width = Math.max(240, left + weeks * (cell + gap) + 4);\n const top = 32 + renderHeader(width, spec.title, spec.subtitle).height;\n const min = Math.min(...points.map((p) => p.value), 0),\n max = Math.max(...points.map((p) => p.value), 0);\n const absMax = Math.max(-min, max);\n return {\n width,\n height: top + 7 * (cell + gap) + 18,\n minWidth: Math.max(240, (width * 14) / cell),\n maxWidth: (width * 32) / cell,\n firstMonday: monday,\n lastDay: dates.at(-1)?.time ?? first,\n weekStart,\n weeks,\n min,\n max,\n absMax,\n cell,\n cellWidth: cell,\n top,\n cells: points.map((p) => {\n const day = Math.round((p.time - monday) / DAY),\n week = Math.floor(day / 7),\n weekday = day % 7;\n const intensity = spec.scale === \"diverging\" ? Math.abs(p.value) / (absMax || 1) : (p.value - min) / (max - min || 1);\n const color = calendarColor(spec.scale, p.value);\n return { ...p, week, weekday, x: left + week * (cell + gap), y: top + weekday * (cell + gap), intensity, color };\n }),\n };\n}\n/** A calendar viewport reserves the same content height in every request state. */\nexport function calendarViewportHeight(\n size: { width: number; height: number; minWidth: number; maxWidth: number },\n availableWidth = \"100cqw\",\n): string {\n return `calc(16px + (${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GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,IAAI,GAAG,CAAC;QAC7C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;QAC1B,OAAO,GAAG,GAAG,GAAG,CAAC;MACnB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,KAAK,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;MACrH,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;MAChD,OAAO;QAAE,GAAG,CAAC;QAAE,IAAI;QAAE,OAAO;QAAE,CAAC,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,GAAG,CAAC;QAAE,CAAC,EAAE,GAAG,GAAG,OAAO,IAAI,IAAI,GAAG,GAAG,CAAC;QAAE,SAAS;QAAE;MAAM,CAAC;IAClH,CAAC;EACH,CAAC;AACH;AACA;AACA,OAAO,SAAS,sBAAsB,CACpC,IAA2E,EAC3E,cAAc,GAAG,QAAQ,EACjB;EACR,OAAO,gBAAgB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,YAAY,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,cAAc,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK;AACpI","ignoreList":[]}
|
|
@@ -1,104 +1,7 @@
|
|
|
1
|
+
import { calendarColor, calendarLayout, calendarWords, DAY, pixels } from "./calendar-layout";
|
|
1
2
|
import { chartDatumSvg, escapeXml, heatmap, renderHeader, svgRoot } from "./svg-renderers";
|
|
2
3
|
import { chartTextWidth } from "./text";
|
|
3
|
-
|
|
4
|
-
/** Bound sparse inputs too: three leap years of daily observations. */
|
|
5
|
-
export const CALENDAR_MAX_DAYS = 1098;
|
|
6
|
-
export function calendarDay(value) {
|
|
7
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) throw new RangeError("Calendar dates must be YYYY-MM-DD.");
|
|
8
|
-
const date = new Date(`${value}T00:00:00Z`);
|
|
9
|
-
if (!Number.isFinite(date.getTime()) || date.toISOString().slice(0, 10) !== value) throw new RangeError("Invalid calendar date.");
|
|
10
|
-
return date.getTime();
|
|
11
|
-
}
|
|
12
|
-
/** Intl uses 1..7, JS dates use 0..6. Old engines use an explicit locale fallback. */
|
|
13
|
-
export function calendarWeekStart(locale = "en") {
|
|
14
|
-
const info = new Intl.Locale(locale);
|
|
15
|
-
const fallback = {
|
|
16
|
-
"en-US": 0
|
|
17
|
-
};
|
|
18
|
-
const key = `${info.language}-${info.region ?? info.maximize().region}`;
|
|
19
|
-
return (info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay ?? fallback[key] ?? 1) % 7;
|
|
20
|
-
}
|
|
21
|
-
export const calendarWords = (locale = "en") => locale.split("-")[0] === "de" ? {
|
|
22
|
-
day: "Tag",
|
|
23
|
-
less: "weniger",
|
|
24
|
-
more: "mehr",
|
|
25
|
-
moreIn: "mehr rein",
|
|
26
|
-
moreOut: "mehr raus"
|
|
27
|
-
} : {
|
|
28
|
-
day: "Day",
|
|
29
|
-
less: "less",
|
|
30
|
-
more: "more",
|
|
31
|
-
moreIn: "more in",
|
|
32
|
-
moreOut: "more out"
|
|
33
|
-
};
|
|
34
|
-
const calendarColor = (scale, value) => scale === "diverging" ? value < 0 ? "var(--k2b-flow-out-mark,#8b5cf6)" : "var(--k2b-flow-in-mark,#0891b2)" : "var(--stdlib-chart-c1,#3b82f6)";
|
|
35
|
-
const pixels = value => `${+value.toPrecision(6)}px`;
|
|
36
|
-
export function calendarLayout(spec, size = {
|
|
37
|
-
width: spec.width ?? 480,
|
|
38
|
-
height: spec.height ?? 280
|
|
39
|
-
}) {
|
|
40
|
-
const seen = new Set();
|
|
41
|
-
const dates = spec.data.map(([date, value], index) => {
|
|
42
|
-
if (seen.has(date)) throw new RangeError("Calendar dates must be unique.");
|
|
43
|
-
seen.add(date);
|
|
44
|
-
const time = calendarDay(date);
|
|
45
|
-
if (value !== null && !Number.isNaN(value) && !Number.isFinite(value)) throw new RangeError("Calendar values must be finite.");
|
|
46
|
-
return {
|
|
47
|
-
date,
|
|
48
|
-
value,
|
|
49
|
-
index,
|
|
50
|
-
time
|
|
51
|
-
};
|
|
52
|
-
}).sort((a, b) => a.time - b.time);
|
|
53
|
-
if (dates.length && (dates.at(-1).time - dates[0].time) / DAY >= CALENDAR_MAX_DAYS) throw new RangeError("Calendar span must not exceed three years.");
|
|
54
|
-
const points = dates.filter(p => p.value !== null && Number.isFinite(p.value));
|
|
55
|
-
const weekStart = calendarWeekStart(spec.locale);
|
|
56
|
-
const first = dates[0]?.time ?? 0;
|
|
57
|
-
const monday = first - (new Date(first).getUTCDay() - weekStart + 7) % 7 * DAY;
|
|
58
|
-
const weeks = dates.length ? Math.floor((dates.at(-1).time - monday) / DAY / 7) + 1 : 0;
|
|
59
|
-
// A minimum-size coordinate space scales uniformly in CSS, including on the
|
|
60
|
-
// first server frame. Height follows the seven rows, never a host's fixed box.
|
|
61
|
-
const gap = 3,
|
|
62
|
-
left = 32;
|
|
63
|
-
const cell = Math.max(14, Math.min(32, Math.floor(((spec.displayWidth ?? size.width) - left - 4) / Math.max(1, weeks) - gap)));
|
|
64
|
-
const width = Math.max(240, left + weeks * (cell + gap) + 4);
|
|
65
|
-
const top = 32 + renderHeader(width, spec.title, spec.subtitle).height;
|
|
66
|
-
const min = Math.min(...points.map(p => p.value), 0),
|
|
67
|
-
max = Math.max(...points.map(p => p.value), 0);
|
|
68
|
-
const absMax = Math.max(-min, max);
|
|
69
|
-
return {
|
|
70
|
-
width,
|
|
71
|
-
height: top + 7 * (cell + gap) + 18,
|
|
72
|
-
minWidth: Math.max(240, width * 14 / cell),
|
|
73
|
-
maxWidth: width * 32 / cell,
|
|
74
|
-
firstMonday: monday,
|
|
75
|
-
lastDay: dates.at(-1)?.time ?? first,
|
|
76
|
-
weekStart,
|
|
77
|
-
weeks,
|
|
78
|
-
min,
|
|
79
|
-
max,
|
|
80
|
-
absMax,
|
|
81
|
-
cell,
|
|
82
|
-
cellWidth: cell,
|
|
83
|
-
top,
|
|
84
|
-
cells: points.map(p => {
|
|
85
|
-
const day = Math.round((p.time - monday) / DAY),
|
|
86
|
-
week = Math.floor(day / 7),
|
|
87
|
-
weekday = day % 7;
|
|
88
|
-
const intensity = spec.scale === "diverging" ? Math.abs(p.value) / (absMax || 1) : (p.value - min) / (max - min || 1);
|
|
89
|
-
const color = calendarColor(spec.scale, p.value);
|
|
90
|
-
return {
|
|
91
|
-
...p,
|
|
92
|
-
week,
|
|
93
|
-
weekday,
|
|
94
|
-
x: left + week * (cell + gap),
|
|
95
|
-
y: top + weekday * (cell + gap),
|
|
96
|
-
intensity,
|
|
97
|
-
color
|
|
98
|
-
};
|
|
99
|
-
})
|
|
100
|
-
};
|
|
101
|
-
}
|
|
4
|
+
export { CALENDAR_MAX_DAYS, calendarDay, calendarLayout, calendarViewportHeight, calendarWeekStart, calendarWords } from "./calendar-layout";
|
|
102
5
|
const paint = (color, intensity) => `color-mix(in srgb,${color} ${12 + 88 * Math.sqrt(intensity)}%,var(--k2b-surface-muted,#f4f4f5))`;
|
|
103
6
|
export function renderCalendarSvg(spec) {
|
|
104
7
|
const s = calendarLayout(spec),
|
|
@@ -194,9 +97,4 @@ export function renderCalendarSvg(spec) {
|
|
|
194
97
|
}, body.join("")).replace("<svg ", `<svg data-calendar="true" data-chart-min-width="${s.minWidth}" style="--k2b-calendar-min:${pixels(s.minWidth)};--k2b-calendar-max:${pixels(s.maxWidth)};--k2b-calendar-base:${width}px;--k2b-calendar-step:${step / width}" `);
|
|
195
98
|
}
|
|
196
99
|
export const renderHeatmapSvg = spec => spec.layout === "calendar" ? renderCalendarSvg(spec) : heatmap(spec);
|
|
197
|
-
|
|
198
|
-
/** A calendar viewport reserves the same content height in every request state. */
|
|
199
|
-
export function calendarViewportHeight(size, availableWidth = "100cqw") {
|
|
200
|
-
return `calc(16px + (${size.height / size.width} * clamp(${pixels(size.minWidth)}, ${availableWidth}, ${pixels(size.maxWidth)})))`;
|
|
201
|
-
}
|
|
202
100
|
//# sourceMappingURL=calendar.js.map
|