@dudousxd/nestjs-catalog-react 0.1.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/LICENSE-bklit +21 -0
- package/README.md +282 -0
- package/dist/AccessConsole.d.ts +40 -0
- package/dist/AccessConsole.js +160 -0
- package/dist/CatalogManager.d.ts +12 -0
- package/dist/CatalogManager.js +123 -0
- package/dist/ConnectionPanel.d.ts +41 -0
- package/dist/ConnectionPanel.js +228 -0
- package/dist/CoverageLedger.d.ts +16 -0
- package/dist/CoverageLedger.js +16 -0
- package/dist/DashboardBoard.d.ts +10 -0
- package/dist/DashboardBoard.js +206 -0
- package/dist/EditableField.d.ts +18 -0
- package/dist/EditableField.js +61 -0
- package/dist/FlowView.d.ts +13 -0
- package/dist/FlowView.js +93 -0
- package/dist/GovernanceTimeline.d.ts +16 -0
- package/dist/GovernanceTimeline.js +93 -0
- package/dist/ObjectExplorer.d.ts +9 -0
- package/dist/ObjectExplorer.js +153 -0
- package/dist/PipelineConsole.d.ts +20 -0
- package/dist/PipelineConsole.js +272 -0
- package/dist/QueryConsole.d.ts +11 -0
- package/dist/QueryConsole.js +144 -0
- package/dist/SavedQueryPanel.d.ts +16 -0
- package/dist/SavedQueryPanel.js +78 -0
- package/dist/TraceExplorer.d.ts +54 -0
- package/dist/TraceExplorer.js +342 -0
- package/dist/TransformEditor.d.ts +23 -0
- package/dist/TransformEditor.js +129 -0
- package/dist/WorkflowCanvas.d.ts +24 -0
- package/dist/WorkflowCanvas.js +701 -0
- package/dist/charts/bklit/animation.d.ts +19 -0
- package/dist/charts/bklit/animation.js +28 -0
- package/dist/charts/bklit/area-chart-loading.d.ts +33 -0
- package/dist/charts/bklit/area-chart-loading.js +30 -0
- package/dist/charts/bklit/area-chart.d.ts +47 -0
- package/dist/charts/bklit/area-chart.js +65 -0
- package/dist/charts/bklit/area-gradient-defs.d.ts +28 -0
- package/dist/charts/bklit/area-gradient-defs.js +23 -0
- package/dist/charts/bklit/area.d.ts +75 -0
- package/dist/charts/bklit/area.js +112 -0
- package/dist/charts/bklit/bar-chart-loading.d.ts +16 -0
- package/dist/charts/bklit/bar-chart-loading.js +22 -0
- package/dist/charts/bklit/bar-chart.d.ts +54 -0
- package/dist/charts/bklit/bar-chart.js +440 -0
- package/dist/charts/bklit/bar-depth-geometry.d.ts +41 -0
- package/dist/charts/bklit/bar-depth-geometry.js +46 -0
- package/dist/charts/bklit/bar-squares-layout.d.ts +36 -0
- package/dist/charts/bklit/bar-squares-layout.js +46 -0
- package/dist/charts/bklit/bar-squares.d.ts +48 -0
- package/dist/charts/bklit/bar-squares.js +206 -0
- package/dist/charts/bklit/bar-x-axis.d.ts +13 -0
- package/dist/charts/bklit/bar-x-axis.js +81 -0
- package/dist/charts/bklit/bar-y-axis.d.ts +11 -0
- package/dist/charts/bklit/bar-y-axis.js +72 -0
- package/dist/charts/bklit/bar.d.ts +40 -0
- package/dist/charts/bklit/bar.js +207 -0
- package/dist/charts/bklit/chart-child-passthrough.d.ts +25 -0
- package/dist/charts/bklit/chart-child-passthrough.js +82 -0
- package/dist/charts/bklit/chart-config-context.d.ts +34 -0
- package/dist/charts/bklit/chart-config-context.js +55 -0
- package/dist/charts/bklit/chart-context.d.ts +207 -0
- package/dist/charts/bklit/chart-context.js +200 -0
- package/dist/charts/bklit/chart-defs.d.ts +21 -0
- package/dist/charts/bklit/chart-defs.js +57 -0
- package/dist/charts/bklit/chart-formatters.d.ts +16 -0
- package/dist/charts/bklit/chart-formatters.js +26 -0
- package/dist/charts/bklit/chart-legend-hover.d.ts +21 -0
- package/dist/charts/bklit/chart-legend-hover.js +26 -0
- package/dist/charts/bklit/chart-loading-label.d.ts +9 -0
- package/dist/charts/bklit/chart-loading-label.js +29 -0
- package/dist/charts/bklit/chart-phase.d.ts +39 -0
- package/dist/charts/bklit/chart-phase.js +20 -0
- package/dist/charts/bklit/chart-reveal-clip.d.ts +32 -0
- package/dist/charts/bklit/chart-reveal-clip.js +23 -0
- package/dist/charts/bklit/dash-tail-stroke.d.ts +17 -0
- package/dist/charts/bklit/dash-tail-stroke.js +21 -0
- package/dist/charts/bklit/decimate-time-series.d.ts +18 -0
- package/dist/charts/bklit/decimate-time-series.js +120 -0
- package/dist/charts/bklit/fade-edges.d.ts +42 -0
- package/dist/charts/bklit/fade-edges.js +34 -0
- package/dist/charts/bklit/filter-data-by-x-domain.d.ts +13 -0
- package/dist/charts/bklit/filter-data-by-x-domain.js +50 -0
- package/dist/charts/bklit/generate-chart-skeleton-data.d.ts +24 -0
- package/dist/charts/bklit/generate-chart-skeleton-data.js +33 -0
- package/dist/charts/bklit/grid.d.ts +57 -0
- package/dist/charts/bklit/grid.js +88 -0
- package/dist/charts/bklit/highlight-segment-bounds.d.ts +26 -0
- package/dist/charts/bklit/highlight-segment-bounds.js +35 -0
- package/dist/charts/bklit/highlight-segment.d.ts +30 -0
- package/dist/charts/bklit/highlight-segment.js +22 -0
- package/dist/charts/bklit/indicator-fade.d.ts +23 -0
- package/dist/charts/bklit/indicator-fade.js +41 -0
- package/dist/charts/bklit/line-chart-loading.d.ts +33 -0
- package/dist/charts/bklit/line-chart-loading.js +30 -0
- package/dist/charts/bklit/line-chart.d.ts +45 -0
- package/dist/charts/bklit/line-chart.js +99 -0
- package/dist/charts/bklit/line-loading-pulse.d.ts +19 -0
- package/dist/charts/bklit/line-loading-pulse.js +132 -0
- package/dist/charts/bklit/line-loading-timing.d.ts +18 -0
- package/dist/charts/bklit/line-loading-timing.js +18 -0
- package/dist/charts/bklit/line-series-terminal-marker.d.ts +15 -0
- package/dist/charts/bklit/line-series-terminal-marker.js +54 -0
- package/dist/charts/bklit/line.d.ts +63 -0
- package/dist/charts/bklit/line.js +104 -0
- package/dist/charts/bklit/loading-sweep.d.ts +65 -0
- package/dist/charts/bklit/loading-sweep.js +182 -0
- package/dist/charts/bklit/motion-utils.d.ts +17 -0
- package/dist/charts/bklit/motion-utils.js +27 -0
- package/dist/charts/bklit/path-stroke-utils.d.ts +28 -0
- package/dist/charts/bklit/path-stroke-utils.js +64 -0
- package/dist/charts/bklit/pattern-area.d.ts +20 -0
- package/dist/charts/bklit/pattern-area.js +27 -0
- package/dist/charts/bklit/pattern-preset.d.ts +34 -0
- package/dist/charts/bklit/pattern-preset.js +82 -0
- package/dist/charts/bklit/projection-config.d.ts +19 -0
- package/dist/charts/bklit/projection-config.js +88 -0
- package/dist/charts/bklit/projection-line-end-marker.d.ts +14 -0
- package/dist/charts/bklit/projection-line-end-marker.js +35 -0
- package/dist/charts/bklit/projection-line.d.ts +39 -0
- package/dist/charts/bklit/projection-line.js +87 -0
- package/dist/charts/bklit/projection-utils.d.ts +54 -0
- package/dist/charts/bklit/projection-utils.js +252 -0
- package/dist/charts/bklit/reference-area-config.d.ts +18 -0
- package/dist/charts/bklit/reference-area-config.js +47 -0
- package/dist/charts/bklit/reference-area-registration-context.d.ts +7 -0
- package/dist/charts/bklit/reference-area-registration-context.js +15 -0
- package/dist/charts/bklit/series-bar-layout.d.ts +26 -0
- package/dist/charts/bklit/series-bar-layout.js +39 -0
- package/dist/charts/bklit/series-dash-tail-overlay.d.ts +16 -0
- package/dist/charts/bklit/series-dash-tail-overlay.js +47 -0
- package/dist/charts/bklit/series-highlight-layer.d.ts +31 -0
- package/dist/charts/bklit/series-highlight-layer.js +20 -0
- package/dist/charts/bklit/series-hover-dim.d.ts +28 -0
- package/dist/charts/bklit/series-hover-dim.js +34 -0
- package/dist/charts/bklit/series-markers.d.ts +13 -0
- package/dist/charts/bklit/series-markers.js +106 -0
- package/dist/charts/bklit/series-path-utils.d.ts +18 -0
- package/dist/charts/bklit/series-path-utils.js +68 -0
- package/dist/charts/bklit/series-point-marker.d.ts +47 -0
- package/dist/charts/bklit/series-point-marker.js +47 -0
- package/dist/charts/bklit/static-chart-preview-context.d.ts +15 -0
- package/dist/charts/bklit/static-chart-preview-context.js +20 -0
- package/dist/charts/bklit/time-series-chart-shell.d.ts +46 -0
- package/dist/charts/bklit/time-series-chart-shell.js +398 -0
- package/dist/charts/bklit/tooltip/chart-tooltip.d.ts +75 -0
- package/dist/charts/bklit/tooltip/chart-tooltip.js +158 -0
- package/dist/charts/bklit/tooltip/date-ticker.d.ts +10 -0
- package/dist/charts/bklit/tooltip/date-ticker.js +85 -0
- package/dist/charts/bklit/tooltip/index.d.ts +15 -0
- package/dist/charts/bklit/tooltip/index.js +15 -0
- package/dist/charts/bklit/tooltip/tooltip-box.d.ts +56 -0
- package/dist/charts/bklit/tooltip/tooltip-box.js +122 -0
- package/dist/charts/bklit/tooltip/tooltip-content.d.ts +26 -0
- package/dist/charts/bklit/tooltip/tooltip-content.js +8 -0
- package/dist/charts/bklit/tooltip/tooltip-dot.d.ts +27 -0
- package/dist/charts/bklit/tooltip/tooltip-dot.js +62 -0
- package/dist/charts/bklit/tooltip/tooltip-indicator.d.ts +44 -0
- package/dist/charts/bklit/tooltip/tooltip-indicator.js +73 -0
- package/dist/charts/bklit/use-animated-series-path.d.ts +18 -0
- package/dist/charts/bklit/use-animated-series-path.js +101 -0
- package/dist/charts/bklit/use-animated-y-domains.d.ts +13 -0
- package/dist/charts/bklit/use-animated-y-domains.js +158 -0
- package/dist/charts/bklit/use-chart-interaction.d.ts +40 -0
- package/dist/charts/bklit/use-chart-interaction.js +252 -0
- package/dist/charts/bklit/use-chart-phase-orchestrator.d.ts +22 -0
- package/dist/charts/bklit/use-chart-phase-orchestrator.js +147 -0
- package/dist/charts/bklit/use-enter-complete.d.ts +16 -0
- package/dist/charts/bklit/use-enter-complete.js +22 -0
- package/dist/charts/bklit/use-grid-shimmer.d.ts +15 -0
- package/dist/charts/bklit/use-grid-shimmer.js +71 -0
- package/dist/charts/bklit/use-highlight-segment.d.ts +22 -0
- package/dist/charts/bklit/use-highlight-segment.js +42 -0
- package/dist/charts/bklit/use-mount-progress.d.ts +12 -0
- package/dist/charts/bklit/use-mount-progress.js +30 -0
- package/dist/charts/bklit/use-scheduled-tooltip.d.ts +8 -0
- package/dist/charts/bklit/use-scheduled-tooltip.js +84 -0
- package/dist/charts/bklit/visx-pattern.d.ts +27 -0
- package/dist/charts/bklit/visx-pattern.js +28 -0
- package/dist/charts/bklit/x-axis.d.ts +26 -0
- package/dist/charts/bklit/x-axis.js +423 -0
- package/dist/charts/bklit/y-axis-scales.d.ts +34 -0
- package/dist/charts/bklit/y-axis-scales.js +80 -0
- package/dist/charts/bklit/y-axis-ticks.d.ts +20 -0
- package/dist/charts/bklit/y-axis-ticks.js +32 -0
- package/dist/charts/bklit/y-domain-utils.d.ts +26 -0
- package/dist/charts/bklit/y-domain-utils.js +96 -0
- package/dist/charts/bklit.d.ts +2 -0
- package/dist/charts/bklit.js +90 -0
- package/dist/charts/components/shimmering-text.d.ts +31 -0
- package/dist/charts/components/shimmering-text.js +39 -0
- package/dist/charts/css.d.ts +35 -0
- package/dist/charts/css.js +64 -0
- package/dist/charts/recharts.d.ts +28 -0
- package/dist/charts/recharts.js +48 -0
- package/dist/charts/registry.d.ts +34 -0
- package/dist/charts/registry.js +60 -0
- package/dist/charts/skeleton.d.ts +55 -0
- package/dist/charts/skeleton.js +66 -0
- package/dist/cn.d.ts +10 -0
- package/dist/cn.js +13 -0
- package/dist/context.d.ts +346 -0
- package/dist/context.js +95 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +65 -0
- package/dist/routes.d.ts +70 -0
- package/dist/routes.js +73 -0
- package/dist/source-fields.d.ts +111 -0
- package/dist/source-fields.js +204 -0
- package/dist/ui/chart.d.ts +54 -0
- package/dist/ui/chart.js +122 -0
- package/dist/ui/dialog.d.ts +27 -0
- package/dist/ui/dialog.js +24 -0
- package/dist/ui/field.d.ts +29 -0
- package/dist/ui/field.js +31 -0
- package/dist/ui/select.d.ts +42 -0
- package/dist/ui/select.js +30 -0
- package/dist/ui/sheet.d.ts +38 -0
- package/dist/ui/sheet.js +37 -0
- package/dist/ui/switch.d.ts +17 -0
- package/dist/ui/switch.js +14 -0
- package/dist/ui/tabs.d.ts +30 -0
- package/dist/ui/tabs.js +36 -0
- package/dist/ui/tooltip.d.ts +37 -0
- package/dist/ui/tooltip.js +43 -0
- package/dist/workflow/graph.d.ts +112 -0
- package/dist/workflow/graph.js +297 -0
- package/dist/workflow/index.d.ts +16 -0
- package/dist/workflow/index.js +16 -0
- package/dist/workflow/model.d.ts +151 -0
- package/dist/workflow/model.js +97 -0
- package/dist/workflow/name.d.ts +28 -0
- package/dist/workflow/name.js +28 -0
- package/dist/workflow/nodes.d.ts +40 -0
- package/dist/workflow/nodes.js +86 -0
- package/dist/workflow/validate.d.ts +104 -0
- package/dist/workflow/validate.js +199 -0
- package/package.json +148 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
5
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
6
|
+
* LICENSE-bklit at the root of this package.
|
|
7
|
+
*
|
|
8
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
9
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
10
|
+
* with upstream stays a diff rather than a merge.
|
|
11
|
+
*/
|
|
12
|
+
import { motion, useSpring } from 'motion/react';
|
|
13
|
+
import { memo, useMemo, useRef } from 'react';
|
|
14
|
+
const TICKER_ITEM_HEIGHT = 24;
|
|
15
|
+
/** Full scroll stacks are skipped above this count — single label + instant updates. */
|
|
16
|
+
const COMPACT_TICKER_THRESHOLD = 60;
|
|
17
|
+
const DateTickerCompact = memo(function DateTickerCompact({ currentIndex, labels, }) {
|
|
18
|
+
const label = labels[currentIndex] ?? labels[0] ?? '';
|
|
19
|
+
return (_jsx("div", { className: "overflow-hidden rounded-full bg-zinc-900 px-4 py-1 text-white shadow-lg dark:bg-zinc-100 dark:text-zinc-900", children: _jsx("div", { className: "flex h-6 items-center justify-center", children: _jsx("span", { className: "whitespace-nowrap font-medium text-sm", children: label }) }) }));
|
|
20
|
+
});
|
|
21
|
+
const DateTickerInner = memo(function DateTickerInner({ currentIndex, labels, }) {
|
|
22
|
+
// Parse labels into month and day parts
|
|
23
|
+
const parsedLabels = useMemo(() => {
|
|
24
|
+
return labels.map((label, index) => {
|
|
25
|
+
const parts = label.split(' ');
|
|
26
|
+
const month = parts[0] || '';
|
|
27
|
+
const day = parts[1] || '';
|
|
28
|
+
return { month, day, full: label, key: `${label}::${index}` };
|
|
29
|
+
});
|
|
30
|
+
}, [labels]);
|
|
31
|
+
// Month segments: one entry per consecutive run (Jan → Feb → …), keyed by start index
|
|
32
|
+
const monthSegments = useMemo(() => {
|
|
33
|
+
const segments = [];
|
|
34
|
+
parsedLabels.forEach((label, index) => {
|
|
35
|
+
const prev = segments.at(-1);
|
|
36
|
+
if (!prev || prev.month !== label.month) {
|
|
37
|
+
segments.push({
|
|
38
|
+
month: label.month,
|
|
39
|
+
key: `${label.month}-${index}`,
|
|
40
|
+
startIndex: index,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return segments;
|
|
45
|
+
}, [parsedLabels]);
|
|
46
|
+
// Index into monthSegments for the current data point
|
|
47
|
+
const currentMonthIndex = useMemo(() => {
|
|
48
|
+
if (currentIndex < 0 || currentIndex >= parsedLabels.length) {
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
for (let i = monthSegments.length - 1; i >= 0; i--) {
|
|
52
|
+
const segment = monthSegments[i];
|
|
53
|
+
if (segment && segment.startIndex <= currentIndex) {
|
|
54
|
+
return i;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return 0;
|
|
58
|
+
}, [currentIndex, parsedLabels.length, monthSegments]);
|
|
59
|
+
// Track previous month index
|
|
60
|
+
const prevMonthIndexRef = useRef(-1);
|
|
61
|
+
// Animated Y offsets
|
|
62
|
+
const dayY = useSpring(0, { stiffness: 400, damping: 35 });
|
|
63
|
+
const monthY = useSpring(0, { stiffness: 400, damping: 35 });
|
|
64
|
+
dayY.set(-currentIndex * TICKER_ITEM_HEIGHT);
|
|
65
|
+
if (currentMonthIndex >= 0) {
|
|
66
|
+
const isFirstRender = prevMonthIndexRef.current === -1;
|
|
67
|
+
const monthChanged = prevMonthIndexRef.current !== currentMonthIndex;
|
|
68
|
+
if (isFirstRender || monthChanged) {
|
|
69
|
+
monthY.set(-currentMonthIndex * TICKER_ITEM_HEIGHT);
|
|
70
|
+
prevMonthIndexRef.current = currentMonthIndex;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return (_jsx("div", { className: "overflow-hidden rounded-full bg-zinc-900 px-4 py-1 text-white shadow-lg dark:bg-zinc-100 dark:text-zinc-900", children: _jsx("div", { className: "relative h-6 overflow-hidden", children: _jsxs("div", { className: "flex items-center justify-center gap-1", children: [_jsx("div", { className: "relative h-6 overflow-hidden", children: _jsx(motion.div, { className: "flex flex-col", style: { y: monthY }, children: monthSegments.map((segment) => (_jsx("div", { className: "flex h-6 shrink-0 items-center justify-center", children: _jsx("span", { className: "whitespace-nowrap font-medium text-sm", children: segment.month }) }, segment.key))) }) }), _jsx("div", { className: "relative h-6 overflow-hidden", children: _jsx(motion.div, { className: "flex flex-col", style: { y: dayY }, children: parsedLabels.map((label) => (_jsx("div", { className: "flex h-6 shrink-0 items-center justify-center", children: _jsx("span", { className: "whitespace-nowrap font-medium text-sm", children: label.day }) }, label.key))) }) })] }) }) }));
|
|
74
|
+
});
|
|
75
|
+
export function DateTicker({ currentIndex, labels, visible }) {
|
|
76
|
+
if (!visible || labels.length === 0) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (labels.length > COMPACT_TICKER_THRESHOLD) {
|
|
80
|
+
return _jsx(DateTickerCompact, { currentIndex: currentIndex, labels: labels });
|
|
81
|
+
}
|
|
82
|
+
return _jsx(DateTickerInner, { currentIndex: currentIndex, labels: labels });
|
|
83
|
+
}
|
|
84
|
+
DateTicker.displayName = 'DateTicker';
|
|
85
|
+
export default DateTicker;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
3
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
4
|
+
* LICENSE-bklit at the root of this package.
|
|
5
|
+
*
|
|
6
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
7
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
8
|
+
* with upstream stays a diff rather than a merge.
|
|
9
|
+
*/
|
|
10
|
+
export { ChartTooltip, type ChartTooltipProps } from './chart-tooltip';
|
|
11
|
+
export { DateTicker, type DateTickerProps } from './date-ticker';
|
|
12
|
+
export { TooltipBox, type TooltipBoxProps } from './tooltip-box';
|
|
13
|
+
export { TooltipContent, type TooltipContentProps, type TooltipRow, } from './tooltip-content';
|
|
14
|
+
export { TooltipDot, type TooltipDotProps } from './tooltip-dot';
|
|
15
|
+
export { type IndicatorWidth, TooltipIndicator, type TooltipIndicatorProps, } from './tooltip-indicator';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
3
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
4
|
+
* LICENSE-bklit at the root of this package.
|
|
5
|
+
*
|
|
6
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
7
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
8
|
+
* with upstream stays a diff rather than a merge.
|
|
9
|
+
*/
|
|
10
|
+
export { ChartTooltip } from './chart-tooltip';
|
|
11
|
+
export { DateTicker } from './date-ticker';
|
|
12
|
+
export { TooltipBox } from './tooltip-box';
|
|
13
|
+
export { TooltipContent, } from './tooltip-content';
|
|
14
|
+
export { TooltipDot } from './tooltip-dot';
|
|
15
|
+
export { TooltipIndicator, } from './tooltip-indicator';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
3
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
4
|
+
* LICENSE-bklit at the root of this package.
|
|
5
|
+
*
|
|
6
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
7
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
8
|
+
* with upstream stays a diff rather than a merge.
|
|
9
|
+
*/
|
|
10
|
+
import { useSpring } from 'motion/react';
|
|
11
|
+
import type { RefObject } from 'react';
|
|
12
|
+
import { type SpringConfig } from '../chart-config-context';
|
|
13
|
+
export interface TooltipBoxProps {
|
|
14
|
+
/** X position in pixels (relative to container) */
|
|
15
|
+
x: number;
|
|
16
|
+
/** Y position in pixels (relative to container) */
|
|
17
|
+
y: number;
|
|
18
|
+
/** Whether the tooltip is visible */
|
|
19
|
+
visible: boolean;
|
|
20
|
+
/** Container ref for portal rendering */
|
|
21
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
22
|
+
/** Container width for flip detection */
|
|
23
|
+
containerWidth: number;
|
|
24
|
+
/** Container height for bounds clamping */
|
|
25
|
+
containerHeight: number;
|
|
26
|
+
/** Offset from the target position */
|
|
27
|
+
offset?: number;
|
|
28
|
+
/** Custom class name */
|
|
29
|
+
className?: string;
|
|
30
|
+
/** Tooltip content */
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
/** Override left position (bypasses internal calculation) */
|
|
33
|
+
left?: number | ReturnType<typeof useSpring>;
|
|
34
|
+
/** Override top position (bypasses internal calculation) */
|
|
35
|
+
top?: number | ReturnType<typeof useSpring>;
|
|
36
|
+
/** Force flip direction (for custom positioning) */
|
|
37
|
+
flipped?: boolean;
|
|
38
|
+
/** Per-chart override; falls back to `ChartConfigProvider.tooltipBoxSpring`. */
|
|
39
|
+
springConfig?: SpringConfig;
|
|
40
|
+
/** Animate panel position with a spring. Default: true */
|
|
41
|
+
animate?: boolean;
|
|
42
|
+
/** Fade/scale the panel on show. Default: true */
|
|
43
|
+
entrance?: boolean;
|
|
44
|
+
/** Inline styles for the inner tooltip panel. */
|
|
45
|
+
panelStyle?: React.CSSProperties;
|
|
46
|
+
/**
|
|
47
|
+
* Tooltip panel background color (CSS variable or color value).
|
|
48
|
+
* Default: `var(--chart-tooltip-background)`.
|
|
49
|
+
*/
|
|
50
|
+
backgroundColor?: string;
|
|
51
|
+
}
|
|
52
|
+
export declare function TooltipBox(props: TooltipBoxProps): import("react/jsx-runtime").JSX.Element | null;
|
|
53
|
+
export declare namespace TooltipBox {
|
|
54
|
+
var displayName: string;
|
|
55
|
+
}
|
|
56
|
+
export default TooltipBox;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
5
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
6
|
+
* LICENSE-bklit at the root of this package.
|
|
7
|
+
*
|
|
8
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
9
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
10
|
+
* with upstream stays a diff rather than a merge.
|
|
11
|
+
*/
|
|
12
|
+
import { motion, useSpring } from 'motion/react';
|
|
13
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
14
|
+
import { createPortal } from 'react-dom';
|
|
15
|
+
import { cn } from '../../../cn';
|
|
16
|
+
import { useChartConfig } from '../chart-config-context';
|
|
17
|
+
import { chartCssVars } from '../chart-context';
|
|
18
|
+
// Inner-only-on-visible so `useSpring` initializes at the cursor's actual x/y
|
|
19
|
+
// instead of (0, 0) on first hover.
|
|
20
|
+
export function TooltipBox(props) {
|
|
21
|
+
const [mounted, setMounted] = useState(false);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setMounted(true);
|
|
24
|
+
}, []);
|
|
25
|
+
const container = props.containerRef.current;
|
|
26
|
+
if (!(mounted && container)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (!props.visible) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return _jsx(TooltipBoxInner, { ...props, container: container });
|
|
33
|
+
}
|
|
34
|
+
function TooltipBoxInner({ x, y, containerWidth, containerHeight, offset = 16, className = '', children, left: leftOverride, top: topOverride, flipped: flippedOverride, springConfig, animate = true, entrance = true, panelStyle, backgroundColor = chartCssVars.tooltipBackground, container, }) {
|
|
35
|
+
const { tooltipBoxSpring } = useChartConfig();
|
|
36
|
+
const effectiveSpring = springConfig ?? tooltipBoxSpring;
|
|
37
|
+
const tooltipRef = useRef(null);
|
|
38
|
+
const tooltipWidthRef = useRef(180);
|
|
39
|
+
const tooltipHeightRef = useRef(80);
|
|
40
|
+
const [staticPosition, setStaticPosition] = useState({ left: x, top: y });
|
|
41
|
+
const tw = tooltipWidthRef.current;
|
|
42
|
+
const th = tooltipHeightRef.current;
|
|
43
|
+
const shouldFlipX = x + tw + offset > containerWidth;
|
|
44
|
+
const targetX = shouldFlipX ? x - offset - tw : x + offset;
|
|
45
|
+
const targetY = Math.max(offset, Math.min(y - th / 2, containerHeight - th - offset));
|
|
46
|
+
const animatedLeft = useSpring(targetX, effectiveSpring);
|
|
47
|
+
const animatedTop = useSpring(targetY, effectiveSpring);
|
|
48
|
+
if (animate && leftOverride === undefined) {
|
|
49
|
+
animatedLeft.set(targetX);
|
|
50
|
+
}
|
|
51
|
+
if (animate && topOverride === undefined) {
|
|
52
|
+
animatedTop.set(targetY);
|
|
53
|
+
}
|
|
54
|
+
useLayoutEffect(() => {
|
|
55
|
+
if (!tooltipRef.current) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const el = tooltipRef.current;
|
|
59
|
+
const w = el.offsetWidth;
|
|
60
|
+
const h = el.offsetHeight;
|
|
61
|
+
if (w > 0) {
|
|
62
|
+
tooltipWidthRef.current = w;
|
|
63
|
+
}
|
|
64
|
+
if (h > 0) {
|
|
65
|
+
tooltipHeightRef.current = h;
|
|
66
|
+
}
|
|
67
|
+
const w2 = tooltipWidthRef.current;
|
|
68
|
+
const h2 = tooltipHeightRef.current;
|
|
69
|
+
const flip = x + w2 + offset > containerWidth;
|
|
70
|
+
const tx = flip ? x - offset - w2 : x + offset;
|
|
71
|
+
const ty = Math.max(offset, Math.min(y - h2 / 2, containerHeight - h2 - offset));
|
|
72
|
+
if (!animate) {
|
|
73
|
+
setStaticPosition({ left: tx, top: ty });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (leftOverride === undefined) {
|
|
77
|
+
animatedLeft.set(tx);
|
|
78
|
+
}
|
|
79
|
+
if (topOverride === undefined) {
|
|
80
|
+
animatedTop.set(ty);
|
|
81
|
+
}
|
|
82
|
+
}, [
|
|
83
|
+
x,
|
|
84
|
+
y,
|
|
85
|
+
containerWidth,
|
|
86
|
+
containerHeight,
|
|
87
|
+
offset,
|
|
88
|
+
leftOverride,
|
|
89
|
+
topOverride,
|
|
90
|
+
animate,
|
|
91
|
+
animatedLeft,
|
|
92
|
+
animatedTop,
|
|
93
|
+
]);
|
|
94
|
+
const prevFlipRef = useRef(shouldFlipX);
|
|
95
|
+
const [flipKey, setFlipKey] = useState(0);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (prevFlipRef.current !== shouldFlipX) {
|
|
98
|
+
setFlipKey((k) => k + 1);
|
|
99
|
+
prevFlipRef.current = shouldFlipX;
|
|
100
|
+
}
|
|
101
|
+
}, [shouldFlipX]);
|
|
102
|
+
const finalLeft = animate ? (leftOverride ?? animatedLeft) : staticPosition.left;
|
|
103
|
+
const finalTop = animate ? (topOverride ?? animatedTop) : staticPosition.top;
|
|
104
|
+
const isFlipped = flippedOverride ?? shouldFlipX;
|
|
105
|
+
const transformOrigin = isFlipped ? 'right top' : 'left top';
|
|
106
|
+
const panelClassName = cn('min-w-[140px] overflow-hidden rounded-lg text-chart-tooltip-foreground shadow-lg', panelStyle?.backgroundColor === undefined &&
|
|
107
|
+
backgroundColor === chartCssVars.tooltipBackground &&
|
|
108
|
+
'bg-chart-tooltip-background', panelStyle?.backdropFilter === undefined && 'backdrop-blur-md');
|
|
109
|
+
const panelStyleResolved = {
|
|
110
|
+
transformOrigin,
|
|
111
|
+
...(panelStyle?.backgroundColor === undefined && {
|
|
112
|
+
backgroundColor,
|
|
113
|
+
}),
|
|
114
|
+
...panelStyle,
|
|
115
|
+
};
|
|
116
|
+
if (!entrance) {
|
|
117
|
+
return createPortal(_jsx("div", { className: cn('pointer-events-none absolute z-50', className), ref: tooltipRef, style: { left: staticPosition.left, top: staticPosition.top }, children: _jsx("div", { className: panelClassName, style: panelStyleResolved, children: children }) }), container);
|
|
118
|
+
}
|
|
119
|
+
return createPortal(_jsx(motion.div, { animate: { opacity: 1 }, className: cn('pointer-events-none absolute z-50', className), exit: { opacity: 0 }, initial: { opacity: 0 }, ref: tooltipRef, style: { left: finalLeft, top: finalTop }, transition: { duration: 0.1 }, children: _jsx(motion.div, { animate: { scale: 1, opacity: 1, x: 0 }, className: panelClassName, initial: { scale: 0.85, opacity: 0, x: isFlipped ? 20 : -20 }, style: panelStyleResolved, transition: { type: 'spring', stiffness: 300, damping: 25 }, children: children }, flipKey) }), container);
|
|
120
|
+
}
|
|
121
|
+
TooltipBox.displayName = 'TooltipBox';
|
|
122
|
+
export default TooltipBox;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
3
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
4
|
+
* LICENSE-bklit at the root of this package.
|
|
5
|
+
*
|
|
6
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
7
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
8
|
+
* with upstream stays a diff rather than a merge.
|
|
9
|
+
*/
|
|
10
|
+
import type { ReactNode } from 'react';
|
|
11
|
+
export interface TooltipRow {
|
|
12
|
+
color: string;
|
|
13
|
+
label: string;
|
|
14
|
+
value: string | number;
|
|
15
|
+
}
|
|
16
|
+
export interface TooltipContentProps {
|
|
17
|
+
title?: string;
|
|
18
|
+
rows: TooltipRow[];
|
|
19
|
+
/** Optional additional content (e.g., markers) */
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export declare function TooltipContent({ title, rows, children }: TooltipContentProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare namespace TooltipContent {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
export default TooltipContent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { intFmt } from '../chart-formatters';
|
|
4
|
+
export function TooltipContent({ title, rows, children }) {
|
|
5
|
+
return (_jsx("div", { className: "overflow-hidden", children: _jsxs("div", { className: "px-3 py-2.5", children: [title && (_jsx("div", { className: "mb-2 text-left font-medium text-chart-tooltip-foreground text-xs", children: title })), _jsx("div", { className: "space-y-1.5", children: rows.map((row) => (_jsxs("div", { className: "flex items-center justify-between gap-4", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "h-2.5 w-2.5 shrink-0 rounded-full", style: { backgroundColor: row.color } }), _jsx("span", { className: "text-chart-tooltip-muted text-sm", children: row.label })] }), _jsx("span", { className: "font-medium text-chart-tooltip-foreground text-sm tabular-nums", children: typeof row.value === 'number' ? intFmt(row.value) : row.value })] }, `${row.label}-${row.color}`))) }), children && (_jsx("div", { className: "mt-2 transition-opacity duration-200 ease-out", children: children }))] }) }));
|
|
6
|
+
}
|
|
7
|
+
TooltipContent.displayName = 'TooltipContent';
|
|
8
|
+
export default TooltipContent;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type SpringConfig } from '../chart-config-context';
|
|
2
|
+
export interface TooltipDotProps {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
color: string;
|
|
7
|
+
/** Half of width/height for dots; half-extent for ring squares. Default: 5 */
|
|
8
|
+
size?: number;
|
|
9
|
+
strokeColor?: string;
|
|
10
|
+
strokeWidth?: number;
|
|
11
|
+
/** Dot fill or transparent ring around the hovered mark. Default: "dot" */
|
|
12
|
+
variant?: 'dot' | 'ring';
|
|
13
|
+
/**
|
|
14
|
+
* Ring corner radius as a fraction of side length (0 = square, 0.5 = circle).
|
|
15
|
+
* Same semantics as bar square radius.
|
|
16
|
+
*/
|
|
17
|
+
cornerRadiusFraction?: number;
|
|
18
|
+
/** Per-chart override; falls back to `ChartConfigProvider.tooltipSpring`. */
|
|
19
|
+
springConfig?: SpringConfig;
|
|
20
|
+
/** Animate position with a spring. Default: true */
|
|
21
|
+
animate?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function TooltipDot({ x, y, visible, color, size, strokeColor, strokeWidth, variant, cornerRadiusFraction, springConfig, animate, }: TooltipDotProps): import("react/jsx-runtime").JSX.Element | null;
|
|
24
|
+
export declare namespace TooltipDot {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
27
|
+
export default TooltipDot;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
5
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
6
|
+
* LICENSE-bklit at the root of this package.
|
|
7
|
+
*
|
|
8
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
9
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
10
|
+
* with upstream stays a diff rather than a merge.
|
|
11
|
+
*/
|
|
12
|
+
import { motion, useSpring, useTransform } from 'motion/react';
|
|
13
|
+
import { useChartConfig } from '../chart-config-context';
|
|
14
|
+
import { chartCssVars } from '../chart-context';
|
|
15
|
+
function ringCornerRadius(halfExtent, cornerRadiusFraction) {
|
|
16
|
+
const side = halfExtent * 2;
|
|
17
|
+
return side * Math.max(0, Math.min(0.5, cornerRadiusFraction));
|
|
18
|
+
}
|
|
19
|
+
function AnimatedRingDot({ x, y, halfExtent, cornerRadiusFraction, fill, stroke, strokeWidth, springConfig, }) {
|
|
20
|
+
const { tooltipSpring } = useChartConfig();
|
|
21
|
+
const effectiveSpring = springConfig ?? tooltipSpring;
|
|
22
|
+
const animatedX = useSpring(x, effectiveSpring);
|
|
23
|
+
const animatedY = useSpring(y, effectiveSpring);
|
|
24
|
+
const side = halfExtent * 2;
|
|
25
|
+
const rx = ringCornerRadius(halfExtent, cornerRadiusFraction);
|
|
26
|
+
const rectX = useTransform(animatedX, (value) => value - halfExtent);
|
|
27
|
+
const rectY = useTransform(animatedY, (value) => value - halfExtent);
|
|
28
|
+
animatedX.set(x);
|
|
29
|
+
animatedY.set(y);
|
|
30
|
+
return (_jsx(motion.rect, { fill: fill, height: side, rx: rx, ry: rx, stroke: stroke, strokeWidth: strokeWidth, width: side, x: rectX, y: rectY }));
|
|
31
|
+
}
|
|
32
|
+
export function TooltipDot({ x, y, visible, color, size = 5, strokeColor = chartCssVars.background, strokeWidth = 2, variant = 'dot', cornerRadiusFraction = 0.25, springConfig, animate = true, }) {
|
|
33
|
+
const { tooltipSpring } = useChartConfig();
|
|
34
|
+
const effectiveSpring = springConfig ?? tooltipSpring;
|
|
35
|
+
const animatedX = useSpring(x, effectiveSpring);
|
|
36
|
+
const animatedY = useSpring(y, effectiveSpring);
|
|
37
|
+
const isRing = variant === 'ring';
|
|
38
|
+
const fill = isRing ? 'transparent' : color;
|
|
39
|
+
const stroke = isRing ? color : strokeColor;
|
|
40
|
+
const effectiveStrokeWidth = isRing ? (strokeWidth ?? 1.5) : strokeWidth;
|
|
41
|
+
if (animate && !isRing) {
|
|
42
|
+
animatedX.set(x);
|
|
43
|
+
animatedY.set(y);
|
|
44
|
+
}
|
|
45
|
+
if (!visible) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (isRing) {
|
|
49
|
+
if (animate) {
|
|
50
|
+
return (_jsx(AnimatedRingDot, { cornerRadiusFraction: cornerRadiusFraction, fill: fill, halfExtent: size, springConfig: springConfig, stroke: stroke, strokeWidth: effectiveStrokeWidth, x: x, y: y }));
|
|
51
|
+
}
|
|
52
|
+
const side = size * 2;
|
|
53
|
+
const rx = ringCornerRadius(size, cornerRadiusFraction);
|
|
54
|
+
return (_jsx("rect", { fill: fill, height: side, rx: rx, ry: rx, stroke: stroke, strokeWidth: effectiveStrokeWidth, width: side, x: x - size, y: y - size }));
|
|
55
|
+
}
|
|
56
|
+
if (!animate) {
|
|
57
|
+
return (_jsx("circle", { cx: x, cy: y, fill: fill, r: size, stroke: stroke, strokeWidth: effectiveStrokeWidth }));
|
|
58
|
+
}
|
|
59
|
+
return (_jsx(motion.circle, { cx: animatedX, cy: animatedY, fill: fill, r: size, stroke: stroke, strokeWidth: effectiveStrokeWidth }));
|
|
60
|
+
}
|
|
61
|
+
TooltipDot.displayName = 'TooltipDot';
|
|
62
|
+
export default TooltipDot;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type SpringConfig } from '../chart-config-context';
|
|
2
|
+
import { type IndicatorFadeEdges } from '../indicator-fade';
|
|
3
|
+
export type IndicatorWidth = number | 'line' | 'thin' | 'medium' | 'thick';
|
|
4
|
+
export interface TooltipIndicatorProps {
|
|
5
|
+
/** X position in pixels (center of the indicator) */
|
|
6
|
+
x: number;
|
|
7
|
+
/** Height of the indicator */
|
|
8
|
+
height: number;
|
|
9
|
+
/** Whether the indicator is visible */
|
|
10
|
+
visible: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Width of the indicator - number (pixels) or preset.
|
|
13
|
+
* Ignored if `span` is provided.
|
|
14
|
+
*/
|
|
15
|
+
width?: IndicatorWidth;
|
|
16
|
+
/**
|
|
17
|
+
* Number of columns/days to span, with current point centered.
|
|
18
|
+
* Requires `columnWidth` to be set.
|
|
19
|
+
*/
|
|
20
|
+
span?: number;
|
|
21
|
+
/** Width of a single column/day in pixels. Required when using `span`. */
|
|
22
|
+
columnWidth?: number;
|
|
23
|
+
/** Primary color at edges (10% and 90%) */
|
|
24
|
+
colorEdge?: string;
|
|
25
|
+
/** Secondary color at center (50%) */
|
|
26
|
+
colorMid?: string;
|
|
27
|
+
/** Vertical fade: both ends, top, bottom, or none (solid). */
|
|
28
|
+
fadeEdges?: IndicatorFadeEdges | boolean;
|
|
29
|
+
/** Fade zone size as a percentage of indicator height. Default: 10 */
|
|
30
|
+
fadeLength?: number;
|
|
31
|
+
/** Animate position with a spring. Default: true */
|
|
32
|
+
animate?: boolean;
|
|
33
|
+
/** Unique ID for the gradient */
|
|
34
|
+
gradientId?: string;
|
|
35
|
+
/** Per-chart override; falls back to `ChartConfigProvider.tooltipSpring`. */
|
|
36
|
+
springConfig?: SpringConfig;
|
|
37
|
+
/** SVG stroke dash pattern. When set, renders a dashed stroke instead of a solid fill. */
|
|
38
|
+
strokeDasharray?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function TooltipIndicator(props: TooltipIndicatorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
41
|
+
export declare namespace TooltipIndicator {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
44
|
+
export default TooltipIndicator;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
5
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
6
|
+
* LICENSE-bklit at the root of this package.
|
|
7
|
+
*
|
|
8
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
9
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
10
|
+
* with upstream stays a diff rather than a merge.
|
|
11
|
+
*/
|
|
12
|
+
import { motion, useSpring } from 'motion/react';
|
|
13
|
+
import { useEffect } from 'react';
|
|
14
|
+
import { useChartConfig } from '../chart-config-context';
|
|
15
|
+
import { chartCssVars } from '../chart-context';
|
|
16
|
+
import { indicatorFadeGradientStops, resolveVerticalFadeSides, } from '../indicator-fade';
|
|
17
|
+
function resolveWidth(width) {
|
|
18
|
+
if (typeof width === 'number') {
|
|
19
|
+
return width;
|
|
20
|
+
}
|
|
21
|
+
switch (width) {
|
|
22
|
+
case 'line':
|
|
23
|
+
return 1;
|
|
24
|
+
case 'thin':
|
|
25
|
+
return 2;
|
|
26
|
+
case 'medium':
|
|
27
|
+
return 4;
|
|
28
|
+
case 'thick':
|
|
29
|
+
return 8;
|
|
30
|
+
default:
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Inner-only-on-visible so `useSpring` initializes at the real cursor x
|
|
35
|
+
// instead of 0 on first hover.
|
|
36
|
+
export function TooltipIndicator(props) {
|
|
37
|
+
if (!props.visible) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return _jsx(TooltipIndicatorInner, { ...props });
|
|
41
|
+
}
|
|
42
|
+
function TooltipIndicatorInner({ x, visible, height, width = 'line', span, columnWidth, colorEdge = chartCssVars.crosshair, colorMid = chartCssVars.crosshair, fadeEdges = 'both', fadeLength = 10, animate = true, gradientId = 'tooltip-indicator-gradient', springConfig, strokeDasharray, }) {
|
|
43
|
+
const { tooltipSpring } = useChartConfig();
|
|
44
|
+
const effectiveSpring = springConfig ?? tooltipSpring;
|
|
45
|
+
const pixelWidth = span !== undefined && columnWidth !== undefined ? span * columnWidth : resolveWidth(width);
|
|
46
|
+
const rectX = x - pixelWidth / 2;
|
|
47
|
+
const lineX = x;
|
|
48
|
+
const animatedX = useSpring(rectX, effectiveSpring);
|
|
49
|
+
const animatedLineX = useSpring(lineX, effectiveSpring);
|
|
50
|
+
if (animate) {
|
|
51
|
+
animatedX.set(rectX);
|
|
52
|
+
animatedLineX.set(lineX);
|
|
53
|
+
}
|
|
54
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: we need to jump the animatedX when the visible prop changes
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
animatedX.set(rectX);
|
|
57
|
+
animatedLineX.set(lineX);
|
|
58
|
+
}, [animatedLineX, animatedX, lineX, rectX, visible]);
|
|
59
|
+
const indicatorFill = colorMid || colorEdge;
|
|
60
|
+
const fadeSides = resolveVerticalFadeSides(fadeEdges);
|
|
61
|
+
const dashed = Boolean(strokeDasharray);
|
|
62
|
+
if (dashed) {
|
|
63
|
+
const strokeWidth = Math.max(1, pixelWidth);
|
|
64
|
+
return animate ? (_jsx(motion.line, { stroke: indicatorFill, strokeDasharray: strokeDasharray, strokeWidth: strokeWidth, x1: animatedLineX, x2: animatedLineX, y1: 0, y2: height })) : (_jsx("line", { stroke: indicatorFill, strokeDasharray: strokeDasharray, strokeWidth: strokeWidth, x1: lineX, x2: lineX, y1: 0, y2: height }));
|
|
65
|
+
}
|
|
66
|
+
if (!fadeSides.any) {
|
|
67
|
+
return animate ? (_jsx(motion.rect, { fill: indicatorFill, height: height, width: pixelWidth, x: animatedX, y: 0 })) : (_jsx("rect", { fill: indicatorFill, height: height, width: pixelWidth, x: rectX, y: 0 }));
|
|
68
|
+
}
|
|
69
|
+
const fadeStops = indicatorFadeGradientStops(fadeSides, fadeLength);
|
|
70
|
+
return (_jsxs("g", { children: [_jsx("defs", { children: _jsx("linearGradient", { id: gradientId, x1: "0%", x2: "0%", y1: "0%", y2: "100%", children: fadeStops.map((stop) => (_jsx("stop", { offset: stop.offset, style: { stopColor: indicatorFill, stopOpacity: stop.opacity } }, stop.offset))) }) }), animate ? (_jsx(motion.rect, { fill: `url(#${gradientId})`, height: height, width: pixelWidth, x: animatedX, y: 0 })) : (_jsx("rect", { fill: `url(#${gradientId})`, height: height, width: pixelWidth, x: rectX, y: 0 }))] }));
|
|
71
|
+
}
|
|
72
|
+
TooltipIndicator.displayName = 'TooltipIndicator';
|
|
73
|
+
export default TooltipIndicator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type CurveFactory = any;
|
|
2
|
+
export interface UseAnimatedSeriesPathOptions {
|
|
3
|
+
renderData: Record<string, unknown>[];
|
|
4
|
+
xAccessor: (datum: Record<string, unknown>) => Date;
|
|
5
|
+
xScale: (value: Date) => number | undefined;
|
|
6
|
+
yScale: (value: number) => number | undefined;
|
|
7
|
+
dataKey: string;
|
|
8
|
+
curve: CurveFactory;
|
|
9
|
+
chartPhase: string;
|
|
10
|
+
durationMs: number;
|
|
11
|
+
innerWidth: number;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function useAnimatedSeriesPath({ renderData, xAccessor, xScale, yScale, dataKey, curve, chartPhase, durationMs, innerWidth, enabled, }: UseAnimatedSeriesPathOptions): {
|
|
15
|
+
pathD: string;
|
|
16
|
+
isPathAnimating: boolean;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/**
|
|
3
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
4
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
5
|
+
* LICENSE-bklit at the root of this package.
|
|
6
|
+
*
|
|
7
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
8
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
9
|
+
* with upstream stays a diff rather than a merge.
|
|
10
|
+
*/
|
|
11
|
+
import { animate, useReducedMotion } from 'motion/react';
|
|
12
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
13
|
+
import { LINE_LOADING_PULSE_EASE } from './line-loading-timing';
|
|
14
|
+
import { computeSeriesPathPoints, interpolateSeriesPathPoints, seriesPathFromPoints, seriesPathTransitionSignature, } from './series-path-utils';
|
|
15
|
+
export function useAnimatedSeriesPath({ renderData, xAccessor, xScale, yScale, dataKey, curve, chartPhase, durationMs, innerWidth, enabled, }) {
|
|
16
|
+
const reducedMotion = useReducedMotion();
|
|
17
|
+
const [animatedPoints, setAnimatedPoints] = useState(null);
|
|
18
|
+
const displayedPointsRef = useRef(null);
|
|
19
|
+
const animatingRef = useRef(false);
|
|
20
|
+
const xScaleDomain = useMemo(() => {
|
|
21
|
+
const scaleWithDomain = xScale;
|
|
22
|
+
return scaleWithDomain.domain?.() ?? [new Date(0), new Date(0)];
|
|
23
|
+
}, [xScale]);
|
|
24
|
+
const transitionSignature = useMemo(() => seriesPathTransitionSignature({
|
|
25
|
+
renderData,
|
|
26
|
+
xAccessor,
|
|
27
|
+
dataKey,
|
|
28
|
+
innerWidth,
|
|
29
|
+
xDomainMin: xScaleDomain[0]?.getTime?.() ?? 0,
|
|
30
|
+
xDomainMax: xScaleDomain[1]?.getTime?.() ?? 0,
|
|
31
|
+
}), [renderData, xAccessor, dataKey, innerWidth, xScaleDomain]);
|
|
32
|
+
const targetPoints = useMemo(() => computeSeriesPathPoints(renderData, xAccessor, xScale, yScale, dataKey), [renderData, xAccessor, xScale, yScale, dataKey]);
|
|
33
|
+
const prevTransitionSignatureRef = useRef(transitionSignature);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!animatingRef.current) {
|
|
36
|
+
displayedPointsRef.current = targetPoints;
|
|
37
|
+
}
|
|
38
|
+
}, [targetPoints]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const shouldAnimate = enabled &&
|
|
41
|
+
!reducedMotion &&
|
|
42
|
+
chartPhase === 'ready' &&
|
|
43
|
+
durationMs > 0 &&
|
|
44
|
+
renderData.length > 0;
|
|
45
|
+
if (!shouldAnimate) {
|
|
46
|
+
animatingRef.current = false;
|
|
47
|
+
setAnimatedPoints(null);
|
|
48
|
+
displayedPointsRef.current = targetPoints;
|
|
49
|
+
prevTransitionSignatureRef.current = transitionSignature;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (prevTransitionSignatureRef.current === transitionSignature) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
prevTransitionSignatureRef.current = transitionSignature;
|
|
56
|
+
const fromPoints = displayedPointsRef.current ?? targetPoints;
|
|
57
|
+
if (fromPoints.length === 0) {
|
|
58
|
+
displayedPointsRef.current = targetPoints;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
animatingRef.current = true;
|
|
62
|
+
const fromSnapshot = fromPoints;
|
|
63
|
+
const control = animate(0, 1, {
|
|
64
|
+
duration: durationMs / 1000,
|
|
65
|
+
ease: [...LINE_LOADING_PULSE_EASE],
|
|
66
|
+
onUpdate: (progress) => {
|
|
67
|
+
const currentTarget = computeSeriesPathPoints(renderData, xAccessor, xScale, yScale, dataKey);
|
|
68
|
+
const next = interpolateSeriesPathPoints(fromSnapshot, currentTarget, progress);
|
|
69
|
+
displayedPointsRef.current = next;
|
|
70
|
+
setAnimatedPoints(next);
|
|
71
|
+
},
|
|
72
|
+
onComplete: () => {
|
|
73
|
+
animatingRef.current = false;
|
|
74
|
+
displayedPointsRef.current = targetPoints;
|
|
75
|
+
setAnimatedPoints(null);
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
return () => {
|
|
79
|
+
control.stop();
|
|
80
|
+
animatingRef.current = false;
|
|
81
|
+
};
|
|
82
|
+
}, [
|
|
83
|
+
transitionSignature,
|
|
84
|
+
chartPhase,
|
|
85
|
+
durationMs,
|
|
86
|
+
enabled,
|
|
87
|
+
reducedMotion,
|
|
88
|
+
renderData,
|
|
89
|
+
xAccessor,
|
|
90
|
+
xScale,
|
|
91
|
+
yScale,
|
|
92
|
+
dataKey,
|
|
93
|
+
targetPoints,
|
|
94
|
+
]);
|
|
95
|
+
const activePoints = animatedPoints ?? targetPoints;
|
|
96
|
+
const pathD = useMemo(() => seriesPathFromPoints(activePoints, curve), [activePoints, curve]);
|
|
97
|
+
return {
|
|
98
|
+
pathD,
|
|
99
|
+
isPathAnimating: animatedPoints != null,
|
|
100
|
+
};
|
|
101
|
+
}
|