@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,57 @@
|
|
|
1
|
+
export interface GridProps {
|
|
2
|
+
/** Show horizontal grid lines. Default: true */
|
|
3
|
+
horizontal?: boolean;
|
|
4
|
+
/** Show vertical grid lines. Default: false */
|
|
5
|
+
vertical?: boolean;
|
|
6
|
+
/** Number of horizontal grid lines. Default: 5 */
|
|
7
|
+
numTicksRows?: number;
|
|
8
|
+
/** Number of vertical grid lines. Default: 10 */
|
|
9
|
+
numTicksColumns?: number;
|
|
10
|
+
/** Explicit tick values for horizontal grid lines. Overrides numTicksRows. */
|
|
11
|
+
rowTickValues?: number[];
|
|
12
|
+
/** Grid line stroke color. Default: var(--chart-grid) */
|
|
13
|
+
stroke?: string;
|
|
14
|
+
/** Grid stroke while loading chrome is active. Falls back to `stroke`. */
|
|
15
|
+
loadingStroke?: string;
|
|
16
|
+
/** Grid line stroke opacity. Default: 1 */
|
|
17
|
+
strokeOpacity?: number;
|
|
18
|
+
/** Grid line stroke width. Default: 1 */
|
|
19
|
+
strokeWidth?: number;
|
|
20
|
+
/** Grid line dash array. Default: "4,4" for dashed lines */
|
|
21
|
+
strokeDasharray?: string;
|
|
22
|
+
/** Horizontal row values rendered with alternate styling (e.g. zero baseline). */
|
|
23
|
+
highlightRowValues?: number[];
|
|
24
|
+
/** Stroke for highlighted rows. Default: var(--chart-foreground-muted) */
|
|
25
|
+
highlightRowStroke?: string;
|
|
26
|
+
/** Stroke opacity for highlighted rows. Default: 1 */
|
|
27
|
+
highlightRowStrokeOpacity?: number;
|
|
28
|
+
/** Stroke width for highlighted rows. Default: 1 */
|
|
29
|
+
highlightRowStrokeWidth?: number;
|
|
30
|
+
/** Dash array for highlighted rows. Default: solid line */
|
|
31
|
+
highlightRowStrokeDasharray?: string;
|
|
32
|
+
/** Enable horizontal fade effect on grid rows (fades at left/right). Default: true */
|
|
33
|
+
fadeHorizontal?: boolean;
|
|
34
|
+
/** Enable vertical fade effect on grid columns (fades at top/bottom). Default: false */
|
|
35
|
+
fadeVertical?: boolean;
|
|
36
|
+
/** Omit the first and last horizontal grid lines. Default: false */
|
|
37
|
+
hideHorizontalEdgeLines?: boolean;
|
|
38
|
+
/** Omit the first and last vertical grid lines. Default: false */
|
|
39
|
+
hideVerticalEdgeLines?: boolean;
|
|
40
|
+
/** Y-scale for horizontal grid lines. Default: primary (`"left"`) axis. */
|
|
41
|
+
yAxisId?: string | number;
|
|
42
|
+
/** Animate a shimmer band across horizontal grid lines. Default: false */
|
|
43
|
+
shimmer?: boolean;
|
|
44
|
+
/** Shimmer band stroke (color and opacity via color-mix or oklch alpha). */
|
|
45
|
+
shimmerStroke?: string;
|
|
46
|
+
/** Shimmer band width in pixels. Default: 140 */
|
|
47
|
+
shimmerLength?: number;
|
|
48
|
+
/** Shimmer speed multiplier (higher = faster). Default: 1 */
|
|
49
|
+
shimmerSpeed?: number;
|
|
50
|
+
/** Match loop timing to the loading line pulse (cycle + inter-loop pause). */
|
|
51
|
+
shimmerSync?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare function Grid({ horizontal, vertical, numTicksRows, numTicksColumns, rowTickValues, stroke, loadingStroke, strokeOpacity, strokeWidth, strokeDasharray, highlightRowValues, highlightRowStroke, highlightRowStrokeOpacity, highlightRowStrokeWidth, highlightRowStrokeDasharray, fadeHorizontal, fadeVertical, hideHorizontalEdgeLines, hideVerticalEdgeLines, yAxisId, shimmer, shimmerStroke, shimmerLength, shimmerSpeed, shimmerSync, }: GridProps): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
export declare namespace Grid {
|
|
55
|
+
var displayName: string;
|
|
56
|
+
}
|
|
57
|
+
export default Grid;
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { GridColumns, GridRows } from '@visx/grid';
|
|
13
|
+
import { motion } from 'motion/react';
|
|
14
|
+
import { useId } from 'react';
|
|
15
|
+
import { chartCssVars, useChartStable, useYScale } from './chart-context';
|
|
16
|
+
import { useGridShimmer } from './use-grid-shimmer';
|
|
17
|
+
import { isLoadingChromePhase, isLoadingGridChromePhase } from './y-domain-utils';
|
|
18
|
+
const DEFAULT_SHIMMER_LENGTH_PX = 140;
|
|
19
|
+
const DEFAULT_SHIMMER_SPEED = 1;
|
|
20
|
+
const DEFAULT_SHIMMER_STROKE = 'color-mix(in oklch, var(--foreground) 68%, transparent)';
|
|
21
|
+
function hideEdgeTicks(ticks, hideEdgeLines) {
|
|
22
|
+
if (!hideEdgeLines || ticks.length <= 2) {
|
|
23
|
+
return ticks;
|
|
24
|
+
}
|
|
25
|
+
return ticks.slice(1, -1);
|
|
26
|
+
}
|
|
27
|
+
function resolveRowTickValues(options) {
|
|
28
|
+
const { hideHorizontalEdgeLines, numTicksRows, rowTickValues, yScale } = options;
|
|
29
|
+
const ticks = rowTickValues ?? (yScale.ticks ? yScale.ticks(numTicksRows) : []);
|
|
30
|
+
const filtered = hideEdgeTicks(ticks, hideHorizontalEdgeLines);
|
|
31
|
+
if (filtered === ticks && !rowTickValues && !hideHorizontalEdgeLines) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return filtered.length > 0 ? filtered : undefined;
|
|
35
|
+
}
|
|
36
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: grid fade masks and shimmer share one layer tree
|
|
37
|
+
export function Grid({ horizontal = true, vertical = false, numTicksRows = 5, numTicksColumns = 10, rowTickValues, stroke = chartCssVars.grid, loadingStroke, strokeOpacity = 1, strokeWidth = 1, strokeDasharray = '4,4', highlightRowValues, highlightRowStroke = chartCssVars.foregroundMuted, highlightRowStrokeOpacity = 1, highlightRowStrokeWidth = 1, highlightRowStrokeDasharray = '0', fadeHorizontal = true, fadeVertical = false, hideHorizontalEdgeLines = false, hideVerticalEdgeLines = false, yAxisId, shimmer = false, shimmerStroke = DEFAULT_SHIMMER_STROKE, shimmerLength = DEFAULT_SHIMMER_LENGTH_PX, shimmerSpeed = DEFAULT_SHIMMER_SPEED, shimmerSync = false, }) {
|
|
38
|
+
const { xScale, innerWidth, innerHeight, orientation, barScale, chartPhase } = useChartStable();
|
|
39
|
+
const yScale = useYScale(yAxisId);
|
|
40
|
+
const shimmerActive = shimmer && isLoadingChromePhase(chartPhase);
|
|
41
|
+
const gridStroke = isLoadingGridChromePhase(chartPhase) && loadingStroke != null ? loadingStroke : stroke;
|
|
42
|
+
const { shimmerEnabled, shimmerTransform } = useGridShimmer({
|
|
43
|
+
innerWidth,
|
|
44
|
+
shimmer,
|
|
45
|
+
shimmerLength,
|
|
46
|
+
shimmerSpeed,
|
|
47
|
+
shimmerSync,
|
|
48
|
+
active: shimmerActive,
|
|
49
|
+
});
|
|
50
|
+
// For bar charts, determine which scale to use for grid lines
|
|
51
|
+
// Horizontal bar charts: vertical grid should use yScale (value scale)
|
|
52
|
+
// Vertical bar charts: horizontal grid uses yScale (value scale)
|
|
53
|
+
const isHorizontalBarChart = orientation === 'horizontal' && barScale;
|
|
54
|
+
// For vertical grid lines in horizontal bar charts, use yScale (the value scale)
|
|
55
|
+
// For time-based charts, use xScale
|
|
56
|
+
const columnScale = isHorizontalBarChart ? yScale : xScale;
|
|
57
|
+
const rowTickValuesResolved = resolveRowTickValues({
|
|
58
|
+
hideHorizontalEdgeLines,
|
|
59
|
+
numTicksRows,
|
|
60
|
+
rowTickValues,
|
|
61
|
+
yScale,
|
|
62
|
+
});
|
|
63
|
+
const columnTickValuesResolved = vertical && columnScale && typeof columnScale === 'function' && hideVerticalEdgeLines
|
|
64
|
+
? (() => {
|
|
65
|
+
const ticks = columnScale.ticks?.(numTicksColumns) ?? [];
|
|
66
|
+
const filtered = hideEdgeTicks(ticks, true);
|
|
67
|
+
return filtered.length > 0 ? filtered : undefined;
|
|
68
|
+
})()
|
|
69
|
+
: undefined;
|
|
70
|
+
const uniqueId = useId();
|
|
71
|
+
// Horizontal fade mask (for grid rows - fades left/right)
|
|
72
|
+
const hMaskId = `grid-rows-fade-${uniqueId}`;
|
|
73
|
+
const hGradientId = `${hMaskId}-gradient`;
|
|
74
|
+
const shimmerGradientId = `grid-shimmer-${uniqueId}`;
|
|
75
|
+
// Vertical fade mask (for grid columns - fades top/bottom)
|
|
76
|
+
const vMaskId = `grid-cols-fade-${uniqueId}`;
|
|
77
|
+
const vGradientId = `${vMaskId}-gradient`;
|
|
78
|
+
const horizontalFadeMask = fadeHorizontal ? `url(#${hMaskId})` : undefined;
|
|
79
|
+
return (_jsxs("g", { className: "chart-grid", children: [horizontal && fadeHorizontal && (_jsxs("defs", { children: [_jsxs("linearGradient", { id: hGradientId, x1: "0%", x2: "100%", y1: "0%", y2: "0%", children: [_jsx("stop", { offset: "0%", style: { stopColor: 'white', stopOpacity: 0 } }), _jsx("stop", { offset: "10%", style: { stopColor: 'white', stopOpacity: 1 } }), _jsx("stop", { offset: "90%", style: { stopColor: 'white', stopOpacity: 1 } }), _jsx("stop", { offset: "100%", style: { stopColor: 'white', stopOpacity: 0 } })] }), _jsx("mask", { id: hMaskId, children: _jsx("rect", { fill: `url(#${hGradientId})`, height: innerHeight, width: innerWidth, x: "0", y: "0" }) })] })), horizontal && shimmerEnabled ? (_jsx("defs", { children: _jsxs(motion.linearGradient, { gradientTransform: shimmerTransform, gradientUnits: "userSpaceOnUse", id: shimmerGradientId, x1: 0, x2: shimmerLength, y1: 0, y2: 0, children: [_jsx("stop", { offset: "0%", stopColor: shimmerStroke, stopOpacity: 0 }), _jsx("stop", { offset: "35%", stopColor: shimmerStroke, stopOpacity: 0.45 }), _jsx("stop", { offset: "50%", stopColor: shimmerStroke, stopOpacity: 1 }), _jsx("stop", { offset: "65%", stopColor: shimmerStroke, stopOpacity: 0.45 }), _jsx("stop", { offset: "100%", stopColor: shimmerStroke, stopOpacity: 0 })] }) })) : null, vertical && fadeVertical && (_jsxs("defs", { children: [_jsxs("linearGradient", { id: vGradientId, x1: "0%", x2: "0%", y1: "0%", y2: "100%", children: [_jsx("stop", { offset: "0%", style: { stopColor: 'white', stopOpacity: 0 } }), _jsx("stop", { offset: "10%", style: { stopColor: 'white', stopOpacity: 1 } }), _jsx("stop", { offset: "90%", style: { stopColor: 'white', stopOpacity: 1 } }), _jsx("stop", { offset: "100%", style: { stopColor: 'white', stopOpacity: 0 } })] }), _jsx("mask", { id: vMaskId, children: _jsx("rect", { fill: `url(#${vGradientId})`, height: innerHeight, width: innerWidth, x: "0", y: "0" }) })] })), horizontal && (_jsxs("g", { mask: horizontalFadeMask, children: [_jsx(GridRows, { numTicks: rowTickValuesResolved ? undefined : numTicksRows, scale: yScale, stroke: gridStroke, strokeDasharray: strokeDasharray, strokeOpacity: strokeOpacity, strokeWidth: strokeWidth, tickValues: rowTickValuesResolved, width: innerWidth }), shimmerEnabled ? (_jsx(GridRows, { numTicks: rowTickValuesResolved ? undefined : numTicksRows, scale: yScale, stroke: `url(#${shimmerGradientId})`, strokeDasharray: strokeDasharray, strokeOpacity: 1, strokeWidth: strokeWidth, tickValues: rowTickValuesResolved, width: innerWidth })) : null] })), horizontal && highlightRowValues && highlightRowValues.length > 0 ? (_jsx("g", { className: "chart-grid-highlight-rows", children: highlightRowValues.map((value) => {
|
|
80
|
+
const y = yScale(value);
|
|
81
|
+
if (y == null || !Number.isFinite(y)) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return (_jsx("line", { stroke: highlightRowStroke, strokeDasharray: highlightRowStrokeDasharray, strokeOpacity: highlightRowStrokeOpacity, strokeWidth: highlightRowStrokeWidth, x1: 0, x2: innerWidth, y1: y, y2: y }, value));
|
|
85
|
+
}) })) : null, vertical && columnScale && typeof columnScale === 'function' && (_jsx("g", { mask: fadeVertical ? `url(#${vMaskId})` : undefined, children: _jsx(GridColumns, { height: innerHeight, numTicks: columnTickValuesResolved ? undefined : numTicksColumns, scale: columnScale, stroke: stroke, strokeDasharray: strokeDasharray, strokeOpacity: strokeOpacity, strokeWidth: strokeWidth, tickValues: columnTickValuesResolved }) }))] }));
|
|
86
|
+
}
|
|
87
|
+
Grid.displayName = 'Grid';
|
|
88
|
+
export default Grid;
|
|
@@ -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 { TooltipData } from './chart-context';
|
|
11
|
+
import type { ChartSelection } from './use-chart-interaction';
|
|
12
|
+
export interface SegmentBounds {
|
|
13
|
+
/** Left edge of the highlight band, in pixels. */
|
|
14
|
+
x: number;
|
|
15
|
+
/** Width of the highlight band, in pixels. */
|
|
16
|
+
width: number;
|
|
17
|
+
isActive: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const INACTIVE_SEGMENT: SegmentBounds;
|
|
20
|
+
/**
|
|
21
|
+
* The highlight band `{x, width}` in pixel space, from the data + `xScale` plus
|
|
22
|
+
* the current hover/selection. Hover spans one data point either side of the dot
|
|
23
|
+
* (clamped to the ends); an active drag-selection uses the dragged pixel range
|
|
24
|
+
* directly and takes priority over hover.
|
|
25
|
+
*/
|
|
26
|
+
export declare function computeSegmentBounds(data: Record<string, unknown>[], xScale: (value: Date) => number | undefined, xAccessor: (d: Record<string, unknown>) => Date, tooltipData: Pick<TooltipData, 'index'> | null | undefined, selection: Pick<ChartSelection, 'active' | 'startX' | 'endX'> | null | undefined): SegmentBounds;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const INACTIVE_SEGMENT = {
|
|
2
|
+
x: 0,
|
|
3
|
+
width: 0,
|
|
4
|
+
isActive: false,
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The highlight band `{x, width}` in pixel space, from the data + `xScale` plus
|
|
8
|
+
* the current hover/selection. Hover spans one data point either side of the dot
|
|
9
|
+
* (clamped to the ends); an active drag-selection uses the dragged pixel range
|
|
10
|
+
* directly and takes priority over hover.
|
|
11
|
+
*/
|
|
12
|
+
export function computeSegmentBounds(data, xScale, xAccessor, tooltipData, selection) {
|
|
13
|
+
if (data.length === 0) {
|
|
14
|
+
return INACTIVE_SEGMENT;
|
|
15
|
+
}
|
|
16
|
+
if (selection?.active) {
|
|
17
|
+
const x = Math.min(selection.startX, selection.endX);
|
|
18
|
+
const width = Math.abs(selection.endX - selection.startX);
|
|
19
|
+
return { x, width, isActive: true };
|
|
20
|
+
}
|
|
21
|
+
if (!tooltipData) {
|
|
22
|
+
return INACTIVE_SEGMENT;
|
|
23
|
+
}
|
|
24
|
+
const idx = tooltipData.index;
|
|
25
|
+
const startIdx = Math.max(0, idx - 1);
|
|
26
|
+
const endIdx = Math.min(data.length - 1, idx + 1);
|
|
27
|
+
const startPoint = data[startIdx];
|
|
28
|
+
const endPoint = data[endIdx];
|
|
29
|
+
if (!(startPoint && endPoint)) {
|
|
30
|
+
return INACTIVE_SEGMENT;
|
|
31
|
+
}
|
|
32
|
+
const startX = xScale(xAccessor(startPoint)) ?? 0;
|
|
33
|
+
const endX = xScale(xAccessor(endPoint)) ?? 0;
|
|
34
|
+
return { x: startX, width: Math.max(0, endX - startX), isActive: true };
|
|
35
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 MotionValue } from 'motion/react';
|
|
11
|
+
import { type RefObject } from 'react';
|
|
12
|
+
export interface HighlightSegmentProps {
|
|
13
|
+
/** Ref to the rendered base stroke `<path>` — its `d` is re-used verbatim. */
|
|
14
|
+
pathRef: RefObject<SVGPathElement | null>;
|
|
15
|
+
/** Whether to render (caller gates on showHighlight + active + loaded). */
|
|
16
|
+
visible: boolean;
|
|
17
|
+
stroke: string;
|
|
18
|
+
strokeWidth: number;
|
|
19
|
+
/** Plot height — the clip band spans it fully. */
|
|
20
|
+
height: number;
|
|
21
|
+
/** Spring-eased left edge of the clip band (px). */
|
|
22
|
+
x: MotionValue<number>;
|
|
23
|
+
/** Spring-eased width of the clip band (px). */
|
|
24
|
+
width: MotionValue<number>;
|
|
25
|
+
}
|
|
26
|
+
export declare function HighlightSegment({ pathRef, visible, stroke, strokeWidth, height, x, width, }: HighlightSegmentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
27
|
+
export declare namespace HighlightSegment {
|
|
28
|
+
var displayName: string;
|
|
29
|
+
}
|
|
30
|
+
export default HighlightSegment;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { motion } from 'motion/react';
|
|
13
|
+
import { useId } from 'react';
|
|
14
|
+
export function HighlightSegment({ pathRef, visible, stroke, strokeWidth, height, x, width, }) {
|
|
15
|
+
const clipId = useId();
|
|
16
|
+
if (!(visible && pathRef.current)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsx("defs", { children: _jsx("clipPath", { id: clipId, children: _jsx(motion.rect, { height: height, width: width, x: x, y: 0 }) }) }), _jsx(motion.path, { animate: { opacity: 1 }, clipPath: `url(#${clipId})`, d: pathRef.current.getAttribute('d') || '', exit: { opacity: 0 }, fill: "none", initial: { opacity: 0 }, stroke: stroke, strokeLinecap: "round", strokeWidth: strokeWidth, transition: { duration: 0.4, ease: 'easeInOut' } })] }));
|
|
20
|
+
}
|
|
21
|
+
HighlightSegment.displayName = 'HighlightSegment';
|
|
22
|
+
export default HighlightSegment;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
/** Vertical fade on the tooltip crosshair indicator. */
|
|
11
|
+
export type IndicatorFadeEdges = 'both' | 'none' | 'top' | 'bottom';
|
|
12
|
+
export interface VerticalFadeSides {
|
|
13
|
+
top: boolean;
|
|
14
|
+
bottom: boolean;
|
|
15
|
+
any: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function resolveVerticalFadeSides(fade: IndicatorFadeEdges | boolean): VerticalFadeSides;
|
|
18
|
+
export interface IndicatorFadeGradientStop {
|
|
19
|
+
offset: string;
|
|
20
|
+
opacity: number;
|
|
21
|
+
}
|
|
22
|
+
/** Opacity stops for the crosshair vertical gradient. */
|
|
23
|
+
export declare function indicatorFadeGradientStops(sides: VerticalFadeSides, fadeLengthPercent?: number): IndicatorFadeGradientStop[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function resolveVerticalFadeSides(fade) {
|
|
2
|
+
if (fade === false || fade === 'none') {
|
|
3
|
+
return { top: false, bottom: false, any: false };
|
|
4
|
+
}
|
|
5
|
+
if (fade === true || fade === 'both') {
|
|
6
|
+
return { top: true, bottom: true, any: true };
|
|
7
|
+
}
|
|
8
|
+
if (fade === 'top') {
|
|
9
|
+
return { top: true, bottom: false, any: true };
|
|
10
|
+
}
|
|
11
|
+
return { top: false, bottom: true, any: true };
|
|
12
|
+
}
|
|
13
|
+
/** Opacity stops for the crosshair vertical gradient. */
|
|
14
|
+
export function indicatorFadeGradientStops(sides, fadeLengthPercent = 10) {
|
|
15
|
+
const fade = Math.min(40, Math.max(2, fadeLengthPercent));
|
|
16
|
+
const innerEnd = 100 - fade;
|
|
17
|
+
if (!sides.any) {
|
|
18
|
+
return [{ offset: '0%', opacity: 1 }];
|
|
19
|
+
}
|
|
20
|
+
if (sides.top && sides.bottom) {
|
|
21
|
+
return [
|
|
22
|
+
{ offset: '0%', opacity: 0 },
|
|
23
|
+
{ offset: `${fade}%`, opacity: 1 },
|
|
24
|
+
{ offset: '50%', opacity: 1 },
|
|
25
|
+
{ offset: `${innerEnd}%`, opacity: 1 },
|
|
26
|
+
{ offset: '100%', opacity: 0 },
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
if (sides.top) {
|
|
30
|
+
return [
|
|
31
|
+
{ offset: '0%', opacity: 0 },
|
|
32
|
+
{ offset: `${fade}%`, opacity: 1 },
|
|
33
|
+
{ offset: '100%', opacity: 1 },
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
return [
|
|
37
|
+
{ offset: '0%', opacity: 1 },
|
|
38
|
+
{ offset: `${innerEnd}%`, opacity: 1 },
|
|
39
|
+
{ offset: '100%', opacity: 0 },
|
|
40
|
+
];
|
|
41
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Margin } from './chart-context';
|
|
2
|
+
import type { LoadingStyle } from './chart-phase';
|
|
3
|
+
export interface LineChartLoadingProps {
|
|
4
|
+
/** Chart margins */
|
|
5
|
+
margin?: Partial<Margin>;
|
|
6
|
+
/** Stroke color for the animated loading segment. */
|
|
7
|
+
stroke?: string;
|
|
8
|
+
/** Stroke opacity for the animated loading segment. Default: 0.5 */
|
|
9
|
+
strokeOpacity?: number;
|
|
10
|
+
/** Grid line stroke (color and opacity via color-mix or oklch alpha). */
|
|
11
|
+
gridStroke?: string;
|
|
12
|
+
/** Shimmer band stroke (color and opacity via color-mix or oklch alpha). */
|
|
13
|
+
gridShimmerStroke?: string;
|
|
14
|
+
/** Animate a shimmer band across grid lines. Default: true */
|
|
15
|
+
gridShimmer?: boolean;
|
|
16
|
+
/** Shimmer band width in pixels. Default: 140 */
|
|
17
|
+
gridShimmerLength?: number;
|
|
18
|
+
/** Shimmer speed multiplier (higher = faster). Default: 1 */
|
|
19
|
+
gridShimmerSpeed?: number;
|
|
20
|
+
/** Match shimmer loop to the loading line pulse (cycle + inter-loop pause). */
|
|
21
|
+
gridShimmerSync?: boolean;
|
|
22
|
+
/** Loading animation: `"pulse"` (default traveling pulse) or `"sweep"` (a
|
|
23
|
+
* diagonal shimmer across the skeleton line). Default: `"pulse"`. */
|
|
24
|
+
loadingStyle?: LoadingStyle;
|
|
25
|
+
/** Centered shimmer label text. Default: "Loading" */
|
|
26
|
+
label?: string;
|
|
27
|
+
/** Aspect ratio as "width / height". Default: "2 / 1" */
|
|
28
|
+
aspectRatio?: string;
|
|
29
|
+
/** Additional class name for the container */
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function LineChartLoading({ margin, stroke, strokeOpacity, gridStroke, gridShimmerStroke, gridShimmer, gridShimmerLength, gridShimmerSpeed, gridShimmerSync, loadingStyle, label, aspectRatio, className, }: LineChartLoadingProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export default LineChartLoading;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { curveNatural } from '@visx/curve';
|
|
13
|
+
import { useMemo } from 'react';
|
|
14
|
+
import { DEFAULT_SKELETON_DATA_KEY, DEFAULT_SKELETON_POINT_COUNT, generateChartSkeletonData, } from './generate-chart-skeleton-data';
|
|
15
|
+
import { Grid } from './grid';
|
|
16
|
+
import { Line } from './line';
|
|
17
|
+
import { LineChart } from './line-chart';
|
|
18
|
+
const LOADING_DATA_KEY = DEFAULT_SKELETON_DATA_KEY;
|
|
19
|
+
const DEFAULT_LOADING_STROKE = 'var(--foreground)';
|
|
20
|
+
const DEFAULT_LOADING_GRID_STROKE = 'color-mix(in oklch, var(--chart-grid) 50%, transparent)';
|
|
21
|
+
const DEFAULT_LOADING_GRID_SHIMMER_STROKE = 'color-mix(in oklch, var(--foreground) 68%, transparent)';
|
|
22
|
+
const DEFAULT_LOADING_STROKE_OPACITY = 0.5;
|
|
23
|
+
export function LineChartLoading({ margin, stroke = DEFAULT_LOADING_STROKE, strokeOpacity = DEFAULT_LOADING_STROKE_OPACITY, gridStroke = DEFAULT_LOADING_GRID_STROKE, gridShimmerStroke = DEFAULT_LOADING_GRID_SHIMMER_STROKE, gridShimmer = true, gridShimmerLength, gridShimmerSpeed, gridShimmerSync = false, loadingStyle = 'pulse', label = 'Loading', aspectRatio = '2 / 1', className = '', }) {
|
|
24
|
+
const data = useMemo(() => generateChartSkeletonData({
|
|
25
|
+
dataKey: DEFAULT_SKELETON_DATA_KEY,
|
|
26
|
+
pointCount: DEFAULT_SKELETON_POINT_COUNT,
|
|
27
|
+
}), []);
|
|
28
|
+
return (_jsxs(LineChart, { animationDuration: 0, aspectRatio: aspectRatio, className: className, data: data, loadingLabel: label, margin: margin, status: "loading", children: [_jsx(Grid, { horizontal: true, shimmer: loadingStyle === 'sweep' ? false : gridShimmer, shimmerLength: gridShimmerLength, shimmerSpeed: gridShimmerSpeed, shimmerStroke: gridShimmerStroke, shimmerSync: gridShimmerSync, stroke: gridStroke }), _jsx(Line, { curve: curveNatural, dataKey: LOADING_DATA_KEY, fadeEdges: false, loadingStroke: stroke, loadingStrokeOpacity: strokeOpacity, loadingStyle: loadingStyle, showHighlight: false, stroke: "transparent", strokeWidth: 2.5 })] }));
|
|
29
|
+
}
|
|
30
|
+
export default LineChartLoading;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Transition } from 'motion/react';
|
|
2
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
3
|
+
import type { Margin } from './chart-context';
|
|
4
|
+
import { type ChartPhase, type ChartStatus } from './chart-phase';
|
|
5
|
+
export interface LineChartProps {
|
|
6
|
+
/** Data array - each item should have a date field and numeric values */
|
|
7
|
+
data: Record<string, unknown>[];
|
|
8
|
+
/** Key in data for the x-axis (date). Default: "date" */
|
|
9
|
+
xDataKey?: string;
|
|
10
|
+
/** Chart margins */
|
|
11
|
+
margin?: Partial<Margin>;
|
|
12
|
+
/** Animation duration in milliseconds. Default: 1100 */
|
|
13
|
+
animationDuration?: number;
|
|
14
|
+
/** CSS easing for clip-reveal. Default: cubic-bezier(0.85, 0, 0.15, 1) */
|
|
15
|
+
animationEasing?: string;
|
|
16
|
+
enterTransition?: Transition;
|
|
17
|
+
revealSignature?: string;
|
|
18
|
+
/** Aspect ratio as "width / height". Default: "2 / 1". Omit to fill a sized parent. */
|
|
19
|
+
aspectRatio?: string;
|
|
20
|
+
/** Additional class name for the container */
|
|
21
|
+
className?: string;
|
|
22
|
+
/** Loading vs ready — drives chart phase and loading chrome. Default: `"ready"`. */
|
|
23
|
+
status?: ChartStatus;
|
|
24
|
+
/** Centered shimmer label while loading. */
|
|
25
|
+
loadingLabel?: string;
|
|
26
|
+
/** Animate y-domain over this duration (ms) on status transitions. Default: 500. */
|
|
27
|
+
yDomainTweenDuration?: number;
|
|
28
|
+
/** Animate y-domain when status or target domain changes. Default: true */
|
|
29
|
+
yDomainTween?: boolean;
|
|
30
|
+
/** Visible x-domain for brush zoom. */
|
|
31
|
+
xDomain?: [Date, Date];
|
|
32
|
+
/** Full dataset length for x-scale padding when `xDomain` is set. */
|
|
33
|
+
xDomainSlotCount?: number;
|
|
34
|
+
/** Tween y-domain when brush changes the visible x-range. Default: false */
|
|
35
|
+
tweenYDomainOnXDomainChange?: boolean;
|
|
36
|
+
/** Inline container styles (e.g. fixed height for brush strip). */
|
|
37
|
+
style?: CSSProperties;
|
|
38
|
+
/** Fires when the internal chart phase changes (e.g. OG capture readiness). */
|
|
39
|
+
onPhaseChange?: (phase: ChartPhase) => void;
|
|
40
|
+
/** Child components (Line, Grid, ChartTooltip, etc.) */
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}
|
|
43
|
+
export declare function LineChart({ data, xDataKey, margin: marginProp, animationDuration, animationEasing, enterTransition, revealSignature, aspectRatio, className, status, loadingLabel, yDomainTweenDuration, yDomainTween, xDomain, xDomainSlotCount, tweenYDomainOnXDomainChange, style, onPhaseChange, children, }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export { Line, type LineProps } from './line';
|
|
45
|
+
export default LineChart;
|
|
@@ -0,0 +1,99 @@
|
|
|
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 { ParentSize } from '@visx/responsive';
|
|
13
|
+
import { Children, isValidElement, useCallback, useMemo, useRef, useState, } from 'react';
|
|
14
|
+
import { cn } from '../../cn';
|
|
15
|
+
import { ChartLoadingLabel } from './chart-loading-label';
|
|
16
|
+
import { DEFAULT_CHART_STATUS, DEFAULT_Y_DOMAIN_TWEEN_MS, resolveRestingChartPhase, } from './chart-phase';
|
|
17
|
+
import { Line } from './line';
|
|
18
|
+
import { TimeSeriesChartInner } from './time-series-chart-shell';
|
|
19
|
+
const DEFAULT_MARGIN = { top: 40, right: 40, bottom: 40, left: 40 };
|
|
20
|
+
/** Series renderers that carry a dataKey but must not drive the shared y-domain. */
|
|
21
|
+
const LINE_DOMAIN_EXCLUDED_NAMES = new Set([
|
|
22
|
+
'ProfitLossLine',
|
|
23
|
+
'LineSeriesTerminalMarker',
|
|
24
|
+
'Area',
|
|
25
|
+
'SeriesBar',
|
|
26
|
+
'Scatter',
|
|
27
|
+
'Candlestick',
|
|
28
|
+
'Bar',
|
|
29
|
+
'PatternArea',
|
|
30
|
+
]);
|
|
31
|
+
function getChildComponentName(child) {
|
|
32
|
+
const childType = child.type;
|
|
33
|
+
return typeof child.type === 'function' ? childType.displayName || childType.name || '' : '';
|
|
34
|
+
}
|
|
35
|
+
function registersLineDomain(child, props) {
|
|
36
|
+
if (!props?.dataKey) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const componentName = getChildComponentName(child);
|
|
40
|
+
if (componentName === 'Line' || child.type === Line) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (LINE_DOMAIN_EXCLUDED_NAMES.has(componentName)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// MDX / duplicate bundle instances may not share the same `Line` reference.
|
|
47
|
+
return typeof props.dataKey === 'string' && props.dataKey.length > 0;
|
|
48
|
+
}
|
|
49
|
+
function extractLineConfigs(children) {
|
|
50
|
+
const configs = [];
|
|
51
|
+
const visit = (node) => {
|
|
52
|
+
Children.forEach(node, (child) => {
|
|
53
|
+
if (!isValidElement(child)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const props = child.props;
|
|
57
|
+
if (registersLineDomain(child, props) && props?.dataKey) {
|
|
58
|
+
configs.push({
|
|
59
|
+
dataKey: props.dataKey,
|
|
60
|
+
stroke: props.stroke || 'var(--chart-line-primary)',
|
|
61
|
+
strokeWidth: props.strokeWidth || 2.5,
|
|
62
|
+
yAxisId: props.yAxisId,
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const childProps = child.props;
|
|
67
|
+
if (childProps?.children) {
|
|
68
|
+
visit(childProps.children);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
visit(children);
|
|
73
|
+
return configs;
|
|
74
|
+
}
|
|
75
|
+
function ChartInner({ width, height, data, xDataKey, margin, animationDuration, animationEasing, enterTransition, revealSignature, chartStatus, loadingLabel, yDomainTweenDuration, yDomainTween, xDomain, xDomainSlotCount, tweenYDomainOnXDomainChange, children, containerRef, onPhaseChange, }) {
|
|
76
|
+
const lines = useMemo(() => extractLineConfigs(children), [children]);
|
|
77
|
+
return (_jsx(TimeSeriesChartInner, { animationDuration: animationDuration, animationEasing: animationEasing, chartStatus: chartStatus, clipPathId: "chart-grow-clip", containerRef: containerRef, data: data, enterTransition: enterTransition, height: height, lines: lines, loadingLabel: loadingLabel, margin: margin, onPhaseChange: onPhaseChange, revealSignature: revealSignature, tweenYDomainOnXDomainChange: tweenYDomainOnXDomainChange, width: width, xDataKey: xDataKey, xDomain: xDomain, xDomainSlotCount: xDomainSlotCount, yDomainTween: yDomainTween, yDomainTweenDuration: yDomainTweenDuration, children: children }));
|
|
78
|
+
}
|
|
79
|
+
export function LineChart({ data, xDataKey = 'date', margin: marginProp, animationDuration = 1100, animationEasing, enterTransition, revealSignature, aspectRatio = '2 / 1', className = '', status = DEFAULT_CHART_STATUS, loadingLabel, yDomainTweenDuration = DEFAULT_Y_DOMAIN_TWEEN_MS, yDomainTween = true, xDomain, xDomainSlotCount, tweenYDomainOnXDomainChange = false, style, onPhaseChange, children, }) {
|
|
80
|
+
const containerRef = useRef(null);
|
|
81
|
+
const margin = { ...DEFAULT_MARGIN, ...marginProp };
|
|
82
|
+
const [chartPhase, setChartPhase] = useState(() => resolveRestingChartPhase(status));
|
|
83
|
+
const handlePhaseChange = useCallback((phase) => {
|
|
84
|
+
setChartPhase(phase);
|
|
85
|
+
onPhaseChange?.(phase);
|
|
86
|
+
}, [onPhaseChange]);
|
|
87
|
+
const showLoadingLabel = Boolean(loadingLabel?.trim() &&
|
|
88
|
+
(chartPhase === 'loading' ||
|
|
89
|
+
chartPhase === 'exiting' ||
|
|
90
|
+
chartPhase === 'gridTweenReady' ||
|
|
91
|
+
chartPhase === 'revealingLoading'));
|
|
92
|
+
return (_jsxs("div", { className: cn('relative w-full', className), ref: containerRef, style: {
|
|
93
|
+
...(aspectRatio ? { aspectRatio } : undefined),
|
|
94
|
+
touchAction: 'none',
|
|
95
|
+
...style,
|
|
96
|
+
}, children: [_jsx(ParentSize, { debounceTime: 10, children: ({ width, height }) => (_jsx(ChartInner, { animationDuration: animationDuration, animationEasing: animationEasing, chartStatus: status, containerRef: containerRef, data: data, enterTransition: enterTransition, height: height, loadingLabel: loadingLabel, margin: margin, onPhaseChange: handlePhaseChange, revealSignature: revealSignature, tweenYDomainOnXDomainChange: tweenYDomainOnXDomainChange, width: width, xDataKey: xDataKey, xDomain: xDomain, xDomainSlotCount: xDomainSlotCount, yDomainTween: yDomainTween, yDomainTweenDuration: yDomainTweenDuration, children: children })) }), showLoadingLabel ? (_jsx(ChartLoadingLabel, { exiting: chartPhase !== 'loading', text: loadingLabel })) : null] }));
|
|
97
|
+
}
|
|
98
|
+
export { Line } from './line';
|
|
99
|
+
export default LineChart;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ChartPhase } from './chart-phase';
|
|
2
|
+
export type LineLoadingPulseMode = 'loop' | 'exit' | 'enter';
|
|
3
|
+
export declare function resolveLineLoadingPulseMode(phase: ChartPhase): LineLoadingPulseMode | null;
|
|
4
|
+
export interface LineLoadingPulseStrokeProps {
|
|
5
|
+
pathD: string;
|
|
6
|
+
mode?: LineLoadingPulseMode;
|
|
7
|
+
/** Bumps to restart loop cycles without remounting the stroke. */
|
|
8
|
+
loopEpoch?: number;
|
|
9
|
+
stroke?: string;
|
|
10
|
+
/** Stroke opacity for the animated segment. Default: 0.5 */
|
|
11
|
+
strokeOpacity?: number;
|
|
12
|
+
strokeWidth?: number;
|
|
13
|
+
onCycleComplete?: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function LineLoadingPulseStroke({ pathD, mode, loopEpoch, stroke, strokeOpacity, strokeWidth, onCycleComplete, }: LineLoadingPulseStrokeProps): import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
export declare namespace LineLoadingPulseStroke {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
19
|
+
export default LineLoadingPulseStroke;
|