@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,182 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, 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 { scaleLinear } from '@visx/scale';
|
|
13
|
+
import { AreaClosed, LinePath } from '@visx/shape';
|
|
14
|
+
import { motion, useReducedMotion } from 'motion/react';
|
|
15
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
16
|
+
import { chartCssVars, useChartStable } from './chart-context';
|
|
17
|
+
import { LINE_LOADING_PULSE_EASE, LOADING_LABEL_EXIT_S } from './line-loading-timing';
|
|
18
|
+
/** One shimmer sweep, in seconds. */
|
|
19
|
+
const DEFAULT_SWEEP_DURATION_S = 2;
|
|
20
|
+
/** Sweep travel in objectBoundingBox space: off the left edge to off the right. */
|
|
21
|
+
const SWEEP_START_X = -1;
|
|
22
|
+
const SWEEP_END_X = 2;
|
|
23
|
+
/** Diagonal tilt of the shimmer band, in degrees. */
|
|
24
|
+
const SWEEP_ANGLE_DEG = 25;
|
|
25
|
+
const HEIGHT_MIN_PCT = 20;
|
|
26
|
+
const HEIGHT_MAX_PCT = 80;
|
|
27
|
+
const DEFAULT_POINT_COUNT = 14;
|
|
28
|
+
const BAR_CORNER_RADIUS = 2;
|
|
29
|
+
const DEFAULT_BAR_COUNT = 12;
|
|
30
|
+
const DEFAULT_FILL = 'var(--foreground)';
|
|
31
|
+
const DEFAULT_BAR_FILL_OPACITY = 0.45;
|
|
32
|
+
const LINE_STROKE_OPACITY = 0.55;
|
|
33
|
+
const AREA_FILL_TOP_OPACITY = 0.18;
|
|
34
|
+
const AREA_FILL_BOTTOM_OPACITY = 0.02;
|
|
35
|
+
/** Bar width as a fraction of its band (the rest is the inter-bar gap). */
|
|
36
|
+
const DEFAULT_BAR_FRACTION = 0.7;
|
|
37
|
+
// ─── Pure, SSR-safe helpers ──────────────────────────────────────────────
|
|
38
|
+
// Heights come from a deterministic hash of (index, seed), never
|
|
39
|
+
// `Math.random()`, so the first server render and first client render agree
|
|
40
|
+
// (no Next.js hydration mismatch). Re-randomizing only bumps the numeric seed
|
|
41
|
+
// on the client, after a sweep completes.
|
|
42
|
+
/** Cheap deterministic hash to a fractional part in [0, 1). */
|
|
43
|
+
function hashFract(n) {
|
|
44
|
+
const x = Math.sin(n) * 43_758.5453;
|
|
45
|
+
return x - Math.floor(x);
|
|
46
|
+
}
|
|
47
|
+
/** Deterministic heights (percentages of the available height) for a seed. */
|
|
48
|
+
export function getSkeletonHeights(count, seed = 0, min = HEIGHT_MIN_PCT, max = HEIGHT_MAX_PCT) {
|
|
49
|
+
const range = max - min;
|
|
50
|
+
return Array.from({ length: count }, (_, i) => min + Math.floor(hashFract((i + 1) * 12.9898 + seed) * range));
|
|
51
|
+
}
|
|
52
|
+
/** Deterministic up/down (±1) per bar for the "center" baseline. */
|
|
53
|
+
function getSkeletonSigns(count, seed = 0) {
|
|
54
|
+
return Array.from({ length: count }, (_, i) => hashFract((i + 1) * 78.233 + seed) < 0.5 ? -1 : 1);
|
|
55
|
+
}
|
|
56
|
+
/** Bell-curve opacity stops (sin squared) for the shimmer band's soft edges. */
|
|
57
|
+
function generateEasedGradientStops(steps = 17, minOpacity = 0.05, maxOpacity = 0.9) {
|
|
58
|
+
return Array.from({ length: steps }, (_, i) => {
|
|
59
|
+
const t = i / (steps - 1);
|
|
60
|
+
const eased = Math.sin(t * Math.PI) ** 2;
|
|
61
|
+
const opacity = minOpacity + eased * (maxOpacity - minOpacity);
|
|
62
|
+
return {
|
|
63
|
+
offset: `${(t * 100).toFixed(0)}%`,
|
|
64
|
+
opacity: Number(opacity.toFixed(3)),
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// ─── Shared mask defs (`${chartId}-mask` is the mask id) ─────────────────────
|
|
69
|
+
function LoadingSweepMask({ chartId, width, height, durationSeconds, onSweepComplete, }) {
|
|
70
|
+
const gradientStops = useMemo(() => generateEasedGradientStops(), []);
|
|
71
|
+
const lastXRef = useRef(SWEEP_START_X);
|
|
72
|
+
const handleUpdate = useCallback((latest) => {
|
|
73
|
+
const xValue = typeof latest.x === 'number' ? latest.x : SWEEP_START_X;
|
|
74
|
+
// Re-roll once the band has cleared the visible area (crossed past 1),
|
|
75
|
+
// so the silhouette never changes shape under the user's eye.
|
|
76
|
+
if (xValue >= 1 && lastXRef.current < 1) {
|
|
77
|
+
onSweepComplete();
|
|
78
|
+
}
|
|
79
|
+
lastXRef.current = xValue;
|
|
80
|
+
}, [onSweepComplete]);
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsx("linearGradient", { id: `${chartId}-grad`, x1: "0", x2: "1", y1: "0", y2: "0", children: gradientStops.map(({ offset, opacity }) => (_jsx("stop", { offset: offset, stopColor: "white", stopOpacity: opacity }, offset))) }), _jsx("pattern", { height: "1", id: `${chartId}-pattern`, patternContentUnits: "objectBoundingBox", patternTransform: `rotate(${SWEEP_ANGLE_DEG})`, patternUnits: "objectBoundingBox", width: 3, x: "0", y: "0", children: _jsx(motion.rect, { animate: { x: SWEEP_END_X }, fill: `url(#${chartId}-grad)`, height: "1", initial: { x: SWEEP_START_X }, onUpdate: handleUpdate, transition: {
|
|
82
|
+
duration: durationSeconds,
|
|
83
|
+
ease: 'linear',
|
|
84
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
85
|
+
repeatType: 'loop',
|
|
86
|
+
}, width: "1", y: "0" }) }), _jsx("mask", { id: `${chartId}-mask`, maskUnits: "userSpaceOnUse", children: _jsx("rect", { fill: `url(#${chartId}-pattern)`, height: height, width: width }) })] }));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Renders a placeholder line/area silhouette (its own, not the chart's skeleton)
|
|
90
|
+
* with the shimmer sweeping across it. The silhouette re-randomizes between
|
|
91
|
+
* passes. Reads inner dimensions from chart context.
|
|
92
|
+
*/
|
|
93
|
+
export function LineLoadingSweep({ curve, withArea = false, mode = 'loop', onTransitionComplete, stroke = chartCssVars.foreground, strokeOpacity = LINE_STROKE_OPACITY, strokeWidth = 2, pointCount = DEFAULT_POINT_COUNT, durationSeconds = DEFAULT_SWEEP_DURATION_S, }) {
|
|
94
|
+
const { innerWidth, innerHeight } = useChartStable();
|
|
95
|
+
const reduceMotion = useReducedMotion();
|
|
96
|
+
const reactId = useId();
|
|
97
|
+
const chartId = `line-sweep-${reactId.replace(/[^a-zA-Z0-9_-]/g, '')}`;
|
|
98
|
+
const isLoop = mode === 'loop';
|
|
99
|
+
const [tick, setTick] = useState(0);
|
|
100
|
+
// Re-randomize only while looping; hold the silhouette steady through a
|
|
101
|
+
// transition so it fades out (or in) as one piece.
|
|
102
|
+
const onSweepComplete = useCallback(() => {
|
|
103
|
+
if (isLoop) {
|
|
104
|
+
setTick((prev) => prev + 1);
|
|
105
|
+
}
|
|
106
|
+
}, [isLoop]);
|
|
107
|
+
const heights = useMemo(() => getSkeletonHeights(pointCount, tick), [pointCount, tick]);
|
|
108
|
+
// With reduced motion there is no fade to await, so signal the handoff
|
|
109
|
+
// immediately or the phase machine would stall mid-transition.
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (reduceMotion && !isLoop) {
|
|
112
|
+
onTransitionComplete?.();
|
|
113
|
+
}
|
|
114
|
+
}, [reduceMotion, isLoop, onTransitionComplete]);
|
|
115
|
+
if (innerWidth <= 0 || innerHeight <= 0 || heights.length < 2) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const xScale = scaleLinear({
|
|
119
|
+
domain: [0, heights.length - 1],
|
|
120
|
+
range: [0, innerWidth],
|
|
121
|
+
});
|
|
122
|
+
const yScale = scaleLinear({ domain: [0, 100], range: [innerHeight, 0] });
|
|
123
|
+
const points = heights.map((value, index) => ({ index, value }));
|
|
124
|
+
const getX = (d) => xScale(d.index);
|
|
125
|
+
const getY = (d) => yScale(d.value);
|
|
126
|
+
const silhouette = (_jsxs(_Fragment, { children: [withArea ? (_jsx(AreaClosed, { curve: curve, data: points, fill: `url(#${chartId}-area)`, x: getX, y: getY, yScale: yScale })) : null, _jsx(LinePath, { curve: curve, data: points, fill: "none", stroke: stroke, strokeLinecap: "round", strokeOpacity: strokeOpacity, strokeWidth: strokeWidth, x: getX, y: getY })] }));
|
|
127
|
+
const areaGradient = withArea ? (_jsxs("linearGradient", { id: `${chartId}-area`, x1: "0", x2: "0", y1: "0", y2: "1", children: [_jsx("stop", { offset: "0%", stopColor: stroke, stopOpacity: AREA_FILL_TOP_OPACITY }), _jsx("stop", { offset: "100%", stopColor: stroke, stopOpacity: AREA_FILL_BOTTOM_OPACITY })] })) : null;
|
|
128
|
+
if (reduceMotion) {
|
|
129
|
+
return (_jsxs(_Fragment, { children: [areaGradient ? _jsx("defs", { children: areaGradient }) : null, silhouette] }));
|
|
130
|
+
}
|
|
131
|
+
const maskUrl = `url(#${chartId}-mask)`;
|
|
132
|
+
const defs = (_jsxs("defs", { children: [areaGradient, _jsx(LoadingSweepMask, { chartId: chartId, durationSeconds: durationSeconds, height: innerHeight, onSweepComplete: onSweepComplete, width: innerWidth })] }));
|
|
133
|
+
if (isLoop) {
|
|
134
|
+
return (_jsxs(_Fragment, { children: [defs, _jsx("g", { mask: maskUrl, children: silhouette })] }));
|
|
135
|
+
}
|
|
136
|
+
// Transition: fade the swept silhouette out (exit) or in (enter), then hand
|
|
137
|
+
// off to the chart so it can reveal the real series.
|
|
138
|
+
return (_jsxs(_Fragment, { children: [defs, _jsx(motion.g, { animate: { opacity: mode === 'exit' ? 0 : 1 }, initial: { opacity: mode === 'exit' ? 1 : 0 }, mask: maskUrl, onAnimationComplete: onTransitionComplete, transition: {
|
|
139
|
+
duration: LOADING_LABEL_EXIT_S,
|
|
140
|
+
ease: [...LINE_LOADING_PULSE_EASE],
|
|
141
|
+
}, children: silhouette })] }));
|
|
142
|
+
}
|
|
143
|
+
LineLoadingSweep.displayName = 'LineLoadingSweep';
|
|
144
|
+
// ─── Bar loading skeleton (seeded bars under the sweep, inner coords) ─────────
|
|
145
|
+
function SkeletonBars({ heights, signs, innerWidth, innerHeight, baseline, barFraction, fill, fillOpacity, }) {
|
|
146
|
+
const bandWidth = innerWidth / heights.length;
|
|
147
|
+
const barW = bandWidth * barFraction;
|
|
148
|
+
const xOffset = (bandWidth * (1 - barFraction)) / 2;
|
|
149
|
+
const isCenter = baseline === 'center';
|
|
150
|
+
const baselineY = isCenter ? innerHeight / 2 : innerHeight;
|
|
151
|
+
const halfBarH = isCenter ? innerHeight / 2 : innerHeight;
|
|
152
|
+
return (_jsx(_Fragment, { children: heights.map((value, i) => {
|
|
153
|
+
const sign = isCenter ? (signs[i] ?? 1) : 1;
|
|
154
|
+
const barH = Math.max(1, halfBarH * (value / 100));
|
|
155
|
+
const x = i * bandWidth + xOffset;
|
|
156
|
+
const y = sign === 1 ? baselineY - barH : baselineY;
|
|
157
|
+
return (_jsx("rect", { fill: fill, fillOpacity: fillOpacity, height: barH, rx: BAR_CORNER_RADIUS, width: barW, x: x, y: y }, `${x.toFixed(2)}-${value}`));
|
|
158
|
+
}) }));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Skeleton bars masked by the shimmer sweep, re-randomizing between passes.
|
|
162
|
+
* Rendered in the chart's inner coordinate space (origin at the inner top-left),
|
|
163
|
+
* so a `BarChart` drops it inside its margin-translated group.
|
|
164
|
+
*/
|
|
165
|
+
export function BarLoadingSkeleton({ innerWidth, innerHeight, barCount = DEFAULT_BAR_COUNT, fill = DEFAULT_FILL, fillOpacity = DEFAULT_BAR_FILL_OPACITY, baseline = 'bottom', barFraction = DEFAULT_BAR_FRACTION, durationSeconds = DEFAULT_SWEEP_DURATION_S, }) {
|
|
166
|
+
const reduceMotion = useReducedMotion();
|
|
167
|
+
const reactId = useId();
|
|
168
|
+
const chartId = `bar-sweep-${reactId.replace(/[^a-zA-Z0-9_-]/g, '')}`;
|
|
169
|
+
const [tick, setTick] = useState(0);
|
|
170
|
+
const onSweepComplete = useCallback(() => setTick((prev) => prev + 1), []);
|
|
171
|
+
const heights = useMemo(() => getSkeletonHeights(barCount, tick), [barCount, tick]);
|
|
172
|
+
const signs = useMemo(() => getSkeletonSigns(barCount, tick), [barCount, tick]);
|
|
173
|
+
if (innerWidth <= 0 || innerHeight <= 0) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
const bars = (_jsx(SkeletonBars, { barFraction: barFraction, baseline: baseline, fill: fill, fillOpacity: fillOpacity, heights: heights, innerHeight: innerHeight, innerWidth: innerWidth, signs: signs }));
|
|
177
|
+
if (reduceMotion) {
|
|
178
|
+
return bars;
|
|
179
|
+
}
|
|
180
|
+
return (_jsxs(_Fragment, { children: [_jsx("defs", { children: _jsx(LoadingSweepMask, { chartId: chartId, durationSeconds: durationSeconds, height: innerHeight, onSweepComplete: onSweepComplete, width: innerWidth }) }), _jsx("g", { mask: `url(#${chartId}-mask)`, children: bars })] }));
|
|
181
|
+
}
|
|
182
|
+
BarLoadingSkeleton.displayName = 'BarLoadingSkeleton';
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { Transition } from 'motion/react';
|
|
11
|
+
export declare function transitionWithDelay(transition: Transition | undefined, delaySeconds: number, fallback?: Transition): Transition;
|
|
12
|
+
export interface SpringOptions {
|
|
13
|
+
stiffness: number;
|
|
14
|
+
damping: number;
|
|
15
|
+
mass?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function springOptionsFromTransition(transition?: Transition, fallback?: SpringOptions): SpringOptions;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DEFAULT_CHART_ENTER_TRANSITION } from './animation';
|
|
2
|
+
export function transitionWithDelay(transition, delaySeconds, fallback = DEFAULT_CHART_ENTER_TRANSITION) {
|
|
3
|
+
const base = transition ?? fallback;
|
|
4
|
+
return { ...base, delay: delaySeconds };
|
|
5
|
+
}
|
|
6
|
+
export function springOptionsFromTransition(transition, fallback = { stiffness: 60, damping: 20 }) {
|
|
7
|
+
if (!transition) {
|
|
8
|
+
return fallback;
|
|
9
|
+
}
|
|
10
|
+
if (transition.type === 'spring') {
|
|
11
|
+
const bounce = typeof transition.bounce === 'number' ? transition.bounce : undefined;
|
|
12
|
+
const baseStiffness = typeof transition.stiffness === 'number' ? transition.stiffness : fallback.stiffness;
|
|
13
|
+
const baseDamping = typeof transition.damping === 'number' ? transition.damping : fallback.damping;
|
|
14
|
+
return {
|
|
15
|
+
stiffness: bounce == null
|
|
16
|
+
? baseStiffness
|
|
17
|
+
: Math.min(400, Math.max(80, baseStiffness * (1 + bounce * 0.35))),
|
|
18
|
+
damping: bounce == null ? baseDamping : Math.max(8, baseDamping * (1 - bounce * 0.25)),
|
|
19
|
+
mass: typeof transition.mass === 'number' ? transition.mass : fallback.mass,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const duration = 'duration' in transition && typeof transition.duration === 'number' ? transition.duration : 0.8;
|
|
23
|
+
return {
|
|
24
|
+
stiffness: Math.min(500, Math.max(40, 280 / duration)),
|
|
25
|
+
damping: Math.min(40, Math.max(12, 18 + duration * 4)),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 RefObject } from 'react';
|
|
11
|
+
export declare function findPathLengthAtX(path: SVGPathElement | null, pathLength: number, targetX: number): number;
|
|
12
|
+
interface PathStrokeMetrics {
|
|
13
|
+
pathD: string | null;
|
|
14
|
+
pathLength: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Caller passes the references that drive the rendered path (renderData,
|
|
18
|
+
* innerWidth, etc.) as `deps`. A stringified summary like
|
|
19
|
+
* `${renderData.length}:${innerWidth}` is *not* safe here — same-length
|
|
20
|
+
* in-place mutations of `renderData` keep the summary identical, so the
|
|
21
|
+
* effect would never re-fire and `pathD`/`pathLength` would stay frozen on
|
|
22
|
+
* the previous geometry (the area fill repaints from `renderData` directly
|
|
23
|
+
* and would diverge from the stroke).
|
|
24
|
+
*/
|
|
25
|
+
export declare function usePathStrokeMetrics(pathRef: RefObject<SVGPathElement | null>, deps: readonly unknown[]): PathStrokeMetrics;
|
|
26
|
+
export declare function resolveDashTailBounds(dashFromIndex: number | undefined, dataLength: number): boolean;
|
|
27
|
+
export declare function resolveDashStartX(data: Record<string, unknown>[], dashFromIndex: number, xScale: (value: Date | number) => number | undefined, xAccessor: (datum: Record<string, unknown>) => Date | number): number;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
// NOTE: usePathStrokeMetrics intentionally accepts caller-controlled deps, so
|
|
11
|
+
// useExhaustiveDependencies reports here by design (warn-level in biome.json).
|
|
12
|
+
import { useEffect, useState } from 'react';
|
|
13
|
+
export function findPathLengthAtX(path, pathLength, targetX) {
|
|
14
|
+
if (!path || pathLength === 0) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
let low = 0;
|
|
18
|
+
let high = pathLength;
|
|
19
|
+
const tolerance = 0.5;
|
|
20
|
+
while (high - low > tolerance) {
|
|
21
|
+
const mid = (low + high) / 2;
|
|
22
|
+
const point = path.getPointAtLength(mid);
|
|
23
|
+
if (point.x < targetX) {
|
|
24
|
+
low = mid;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
high = mid;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return (low + high) / 2;
|
|
31
|
+
}
|
|
32
|
+
const EMPTY_METRICS = { pathD: null, pathLength: 0 };
|
|
33
|
+
/**
|
|
34
|
+
* Caller passes the references that drive the rendered path (renderData,
|
|
35
|
+
* innerWidth, etc.) as `deps`. A stringified summary like
|
|
36
|
+
* `${renderData.length}:${innerWidth}` is *not* safe here — same-length
|
|
37
|
+
* in-place mutations of `renderData` keep the summary identical, so the
|
|
38
|
+
* effect would never re-fire and `pathD`/`pathLength` would stay frozen on
|
|
39
|
+
* the previous geometry (the area fill repaints from `renderData` directly
|
|
40
|
+
* and would diverge from the stroke).
|
|
41
|
+
*/
|
|
42
|
+
export function usePathStrokeMetrics(pathRef, deps) {
|
|
43
|
+
const [metrics, setMetrics] = useState(EMPTY_METRICS);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const path = pathRef.current;
|
|
46
|
+
if (!path) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const d = path.getAttribute('d');
|
|
50
|
+
const len = d ? path.getTotalLength() : 0;
|
|
51
|
+
setMetrics((prev) => prev.pathD === d && prev.pathLength === len ? prev : { pathD: d, pathLength: len });
|
|
52
|
+
}, deps);
|
|
53
|
+
return metrics;
|
|
54
|
+
}
|
|
55
|
+
export function resolveDashTailBounds(dashFromIndex, dataLength) {
|
|
56
|
+
return dashFromIndex != null && dashFromIndex >= 0 && dashFromIndex < dataLength - 1;
|
|
57
|
+
}
|
|
58
|
+
export function resolveDashStartX(data, dashFromIndex, xScale, xAccessor) {
|
|
59
|
+
const dashFromPoint = data[dashFromIndex];
|
|
60
|
+
if (!dashFromPoint) {
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
return xScale(xAccessor(dashFromPoint)) ?? 0;
|
|
64
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type CurveFactory = any;
|
|
2
|
+
export interface PatternAreaProps {
|
|
3
|
+
/** Key in data to use for y values */
|
|
4
|
+
dataKey: string;
|
|
5
|
+
/** Fill color or pattern URL (e.g. `url(#pattern-id)`) */
|
|
6
|
+
fill: string;
|
|
7
|
+
/** Curve function. Default: curveMonotoneX */
|
|
8
|
+
curve?: CurveFactory;
|
|
9
|
+
/** @deprecated Pattern fill is not clip-revealed; only the stroke `Area` animates. */
|
|
10
|
+
animate?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Filled area using an SVG pattern (`url(#id)`).
|
|
14
|
+
* Pair with `PatternLines` in `AreaChart` children and an `Area` with `fillOpacity={0}` for the stroke line.
|
|
15
|
+
*/
|
|
16
|
+
export declare function PatternArea({ dataKey, fill, curve }: PatternAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare namespace PatternArea {
|
|
18
|
+
var displayName: string;
|
|
19
|
+
}
|
|
20
|
+
export default PatternArea;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { curveMonotoneX } from '@visx/curve';
|
|
13
|
+
import { AreaClosed } from '@visx/shape';
|
|
14
|
+
import { useChartStable } from './chart-context';
|
|
15
|
+
/**
|
|
16
|
+
* Filled area using an SVG pattern (`url(#id)`).
|
|
17
|
+
* Pair with `PatternLines` in `AreaChart` children and an `Area` with `fillOpacity={0}` for the stroke line.
|
|
18
|
+
*/
|
|
19
|
+
export function PatternArea({ dataKey, fill, curve = curveMonotoneX }) {
|
|
20
|
+
const { renderData, xScale, yScale, xAccessor } = useChartStable();
|
|
21
|
+
return (_jsx(AreaClosed, { curve: curve, data: renderData, fill: fill, x: (d) => xScale(xAccessor(d)) ?? 0, y: (d) => {
|
|
22
|
+
const v = d[dataKey];
|
|
23
|
+
return typeof v === 'number' ? (yScale(v) ?? 0) : 0;
|
|
24
|
+
}, yScale: yScale }));
|
|
25
|
+
}
|
|
26
|
+
PatternArea.displayName = 'PatternArea';
|
|
27
|
+
export default PatternArea;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 declare const PATTERN_PRESET_IDS: readonly ["none", "diagonal", "horizontal", "vertical", "cross", "dots", "circles", "accent"];
|
|
12
|
+
export type PatternPresetId = (typeof PATTERN_PRESET_IDS)[number];
|
|
13
|
+
export interface PatternPresetOptions {
|
|
14
|
+
color?: string;
|
|
15
|
+
scale?: number;
|
|
16
|
+
strokeWidth?: number;
|
|
17
|
+
radius?: number;
|
|
18
|
+
complement?: boolean;
|
|
19
|
+
fill?: string;
|
|
20
|
+
/** Dot grid only — when false, render hollow dots (stroke only). Default: true */
|
|
21
|
+
dotFill?: boolean;
|
|
22
|
+
tileBackground?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Presets rendered with @visx/pattern `PatternCircles`. */
|
|
25
|
+
export declare function isCirclePattern(preset: PatternPresetId): boolean;
|
|
26
|
+
/** @deprecated Use `isCirclePattern`. */
|
|
27
|
+
export declare function isCirclesPattern(preset: PatternPresetId): boolean;
|
|
28
|
+
export declare function patternPresetTileSize(preset: PatternPresetId, scale?: number): {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
strokeWidth: number;
|
|
32
|
+
};
|
|
33
|
+
/** Renders a @visx/pattern definition node for the given preset. */
|
|
34
|
+
export declare function renderPatternPreset(preset: PatternPresetId, id: string, options?: PatternPresetOptions): ReactNode;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { PatternCircles, PatternLines } from './visx-pattern';
|
|
4
|
+
export const PATTERN_PRESET_IDS = [
|
|
5
|
+
'none',
|
|
6
|
+
'diagonal',
|
|
7
|
+
'horizontal',
|
|
8
|
+
'vertical',
|
|
9
|
+
'cross',
|
|
10
|
+
'dots',
|
|
11
|
+
'circles',
|
|
12
|
+
'accent',
|
|
13
|
+
];
|
|
14
|
+
/** Presets rendered with @visx/pattern `PatternCircles`. */
|
|
15
|
+
export function isCirclePattern(preset) {
|
|
16
|
+
return preset === 'circles' || preset === 'dots';
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated Use `isCirclePattern`. */
|
|
19
|
+
export function isCirclesPattern(preset) {
|
|
20
|
+
return isCirclePattern(preset);
|
|
21
|
+
}
|
|
22
|
+
export function patternPresetTileSize(preset, scale = 1) {
|
|
23
|
+
let base = { width: 6, height: 6, strokeWidth: 1 };
|
|
24
|
+
if (preset === 'dots') {
|
|
25
|
+
base = { width: 10, height: 10, strokeWidth: 0 };
|
|
26
|
+
}
|
|
27
|
+
else if (preset === 'cross') {
|
|
28
|
+
base = { width: 8, height: 8, strokeWidth: 1 };
|
|
29
|
+
}
|
|
30
|
+
else if (preset === 'circles') {
|
|
31
|
+
base = { width: 6, height: 6, strokeWidth: 1 };
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
width: base.width * scale,
|
|
35
|
+
height: base.height * scale,
|
|
36
|
+
strokeWidth: base.strokeWidth * scale,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function renderPatternCircles(preset, _id, color, common, options, scale) {
|
|
40
|
+
const isDotGrid = preset === 'dots';
|
|
41
|
+
const radius = options.radius ?? (isDotGrid ? Math.max(0.5, 1.5 * scale) : 2 * scale);
|
|
42
|
+
const dotFillEnabled = options.dotFill !== false;
|
|
43
|
+
if (isDotGrid) {
|
|
44
|
+
const dotFill = dotFillEnabled ? options.fill || color : undefined;
|
|
45
|
+
return (_jsx(PatternCircles, { ...common, complement: options.complement, fill: dotFill, radius: radius, stroke: dotFillEnabled && options.fill ? undefined : color, strokeWidth: dotFillEnabled && !options.fill ? (options.strokeWidth ?? 0) : (options.strokeWidth ?? 1) }));
|
|
46
|
+
}
|
|
47
|
+
return (_jsx(PatternCircles, { ...common, complement: options.complement, fill: options.fill || undefined, radius: radius, stroke: color, strokeWidth: options.strokeWidth ?? common.strokeWidth }));
|
|
48
|
+
}
|
|
49
|
+
/** Renders a @visx/pattern definition node for the given preset. */
|
|
50
|
+
export function renderPatternPreset(preset, id, options = {}) {
|
|
51
|
+
if (preset === 'none') {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const color = options.color ?? 'var(--chart-1)';
|
|
55
|
+
const scale = options.scale ?? 1;
|
|
56
|
+
const tile = patternPresetTileSize(preset, scale);
|
|
57
|
+
const common = {
|
|
58
|
+
id,
|
|
59
|
+
height: tile.height,
|
|
60
|
+
width: tile.width,
|
|
61
|
+
strokeWidth: tile.strokeWidth,
|
|
62
|
+
...(options.tileBackground ? { background: options.tileBackground } : {}),
|
|
63
|
+
};
|
|
64
|
+
if (preset === 'dots' || preset === 'circles') {
|
|
65
|
+
return renderPatternCircles(preset, id, color, common, options, scale);
|
|
66
|
+
}
|
|
67
|
+
const strokeWidth = options.strokeWidth ?? tile.strokeWidth;
|
|
68
|
+
switch (preset) {
|
|
69
|
+
case 'diagonal':
|
|
70
|
+
return (_jsx(PatternLines, { ...common, orientation: ['diagonal'], stroke: color, strokeWidth: strokeWidth }));
|
|
71
|
+
case 'horizontal':
|
|
72
|
+
return (_jsx(PatternLines, { ...common, orientation: ['horizontal'], stroke: color, strokeWidth: strokeWidth }));
|
|
73
|
+
case 'vertical':
|
|
74
|
+
return (_jsx(PatternLines, { ...common, orientation: ['vertical'], stroke: color, strokeWidth: strokeWidth }));
|
|
75
|
+
case 'cross':
|
|
76
|
+
return (_jsx(PatternLines, { ...common, orientation: ['diagonal', 'diagonalRightToLeft'], stroke: color, strokeWidth: strokeWidth }));
|
|
77
|
+
case 'accent':
|
|
78
|
+
return (_jsx(PatternLines, { ...common, orientation: ['diagonal'], stroke: "#e879f9", strokeWidth: strokeWidth }));
|
|
79
|
+
default:
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import type { ProjectionPoint } from './projection-utils';
|
|
12
|
+
export interface ProjectionLineConfig {
|
|
13
|
+
yAxisId: string;
|
|
14
|
+
data: ProjectionPoint[];
|
|
15
|
+
}
|
|
16
|
+
/** Collect {@link ProjectionLine} props from chart children for domain extension. */
|
|
17
|
+
export declare function extractProjectionLineConfigs(children: ReactNode): ProjectionLineConfig[];
|
|
18
|
+
export declare function mergeProjectionYDomain(domain: [number, number], configs: ProjectionLineConfig[], yAxisId: string): [number, number];
|
|
19
|
+
export declare function mergeProjectionXDomainMax(maxTime: number, configs: ProjectionLineConfig[]): number;
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { Children, Fragment, isValidElement } from 'react';
|
|
11
|
+
import { isChartClipPassthrough } from './chart-child-passthrough';
|
|
12
|
+
import { projectionDateExtents, projectionValueExtents } from './projection-utils';
|
|
13
|
+
import { normalizeYAxisId } from './y-axis-scales';
|
|
14
|
+
function getChildComponentName(child) {
|
|
15
|
+
const childType = child.type;
|
|
16
|
+
return typeof child.type === 'function' ? childType.displayName || childType.name || '' : '';
|
|
17
|
+
}
|
|
18
|
+
function isProjectionLineElement(child) {
|
|
19
|
+
return getChildComponentName(child) === 'ProjectionLine';
|
|
20
|
+
}
|
|
21
|
+
function normalizeProjectionData(data) {
|
|
22
|
+
if (!data?.length) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
return data.map((point) => ({
|
|
26
|
+
date: point.date instanceof Date ? point.date : new Date(point.date),
|
|
27
|
+
value: point.value,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
/** Collect {@link ProjectionLine} props from chart children for domain extension. */
|
|
31
|
+
export function extractProjectionLineConfigs(children) {
|
|
32
|
+
const configs = [];
|
|
33
|
+
const visit = (node) => {
|
|
34
|
+
Children.forEach(node, (child) => {
|
|
35
|
+
if (!isValidElement(child)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (child.type === Fragment) {
|
|
39
|
+
visit(child.props.children);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (isProjectionLineElement(child)) {
|
|
43
|
+
const props = child.props;
|
|
44
|
+
const data = normalizeProjectionData(props?.data);
|
|
45
|
+
if (data.length >= 2) {
|
|
46
|
+
configs.push({
|
|
47
|
+
yAxisId: normalizeYAxisId(props?.yAxisId),
|
|
48
|
+
data,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (isChartClipPassthrough(child.type)) {
|
|
54
|
+
visit(child.props.children);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const childProps = child.props;
|
|
58
|
+
if (childProps?.children) {
|
|
59
|
+
visit(childProps.children);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
visit(children);
|
|
64
|
+
return configs;
|
|
65
|
+
}
|
|
66
|
+
export function mergeProjectionYDomain(domain, configs, yAxisId) {
|
|
67
|
+
const paths = configs.filter((config) => config.yAxisId === yAxisId).map((config) => config.data);
|
|
68
|
+
const extents = projectionValueExtents(paths);
|
|
69
|
+
if (!extents) {
|
|
70
|
+
return domain;
|
|
71
|
+
}
|
|
72
|
+
const [min, max] = domain;
|
|
73
|
+
const nextMin = Math.min(min, extents.minValue);
|
|
74
|
+
const nextMax = Math.max(max, extents.maxValue);
|
|
75
|
+
if (nextMin >= 0 && min >= 0) {
|
|
76
|
+
return [0, nextMax <= 0 ? 100 : nextMax * 1.1];
|
|
77
|
+
}
|
|
78
|
+
const padding = (nextMax - nextMin) * 0.05 || 1;
|
|
79
|
+
return [nextMin - padding, nextMax + padding];
|
|
80
|
+
}
|
|
81
|
+
export function mergeProjectionXDomainMax(maxTime, configs) {
|
|
82
|
+
const paths = configs.map((config) => config.data);
|
|
83
|
+
const extents = projectionDateExtents(paths);
|
|
84
|
+
if (!extents) {
|
|
85
|
+
return maxTime;
|
|
86
|
+
}
|
|
87
|
+
return Math.max(maxTime, extents.maxTime);
|
|
88
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ProjectionPoint } from './projection-utils';
|
|
2
|
+
export interface ProjectionLineEndMarkerProps {
|
|
3
|
+
data: ProjectionPoint[];
|
|
4
|
+
yAxisId?: string | number;
|
|
5
|
+
stroke?: string;
|
|
6
|
+
strokeOpacity?: number;
|
|
7
|
+
radius?: number;
|
|
8
|
+
}
|
|
9
|
+
/** Renders the projection horizon dot outside the series reveal clip. */
|
|
10
|
+
export declare function ProjectionLineEndMarker({ data, yAxisId, stroke, strokeOpacity, radius, }: ProjectionLineEndMarkerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
+
export declare namespace ProjectionLineEndMarker {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export default ProjectionLineEndMarker;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { useCallback } from 'react';
|
|
13
|
+
import { useChartStable, useYScale } from './chart-context';
|
|
14
|
+
/** Renders the projection horizon dot outside the series reveal clip. */
|
|
15
|
+
export function ProjectionLineEndMarker({ data, yAxisId, stroke = 'var(--chart-3)', strokeOpacity = 1, radius = 5, }) {
|
|
16
|
+
const { xScale, chartPhase, innerWidth } = useChartStable();
|
|
17
|
+
const yScale = useYScale(yAxisId);
|
|
18
|
+
const getX = useCallback((point) => xScale(point.date) ?? 0, [xScale]);
|
|
19
|
+
const getY = useCallback((point) => yScale(point.value) ?? 0, [yScale]);
|
|
20
|
+
const showStroke = chartPhase === 'revealing' || chartPhase === 'ready' || chartPhase === 'exitingReady';
|
|
21
|
+
if (!showStroke || data.length < 2) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const endPoint = data.at(-1);
|
|
25
|
+
if (!endPoint) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const edgePadding = radius + 1;
|
|
29
|
+
const endX = Math.min(getX(endPoint), Math.max(0, innerWidth - edgePadding));
|
|
30
|
+
const endY = getY(endPoint);
|
|
31
|
+
return _jsx("circle", { cx: endX, cy: endY, fill: stroke, fillOpacity: strokeOpacity, r: radius * 0.85 });
|
|
32
|
+
}
|
|
33
|
+
ProjectionLineEndMarker.displayName = 'ProjectionLineEndMarker';
|
|
34
|
+
ProjectionLineEndMarker.__isPostOverlay = true;
|
|
35
|
+
export default ProjectionLineEndMarker;
|