@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,82 @@
|
|
|
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, cloneElement, isValidElement, } from 'react';
|
|
11
|
+
/** Marker on wrapper components whose single child should inherit clip classification. */
|
|
12
|
+
export const CHART_CLIP_PASSTHROUGH = '__chartClipPassthrough';
|
|
13
|
+
export function isChartClipPassthrough(type) {
|
|
14
|
+
return (typeof type === 'function' &&
|
|
15
|
+
type[CHART_CLIP_PASSTHROUGH] === true);
|
|
16
|
+
}
|
|
17
|
+
/** Unwrap visibility wrappers so `Grid` / axes stay outside the series clip. */
|
|
18
|
+
export function resolveChartChildElement(child) {
|
|
19
|
+
if (isChartClipPassthrough(child.type)) {
|
|
20
|
+
const inner = child.props.children;
|
|
21
|
+
if (isValidElement(inner)) {
|
|
22
|
+
return resolveChartChildElement(inner);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return child;
|
|
26
|
+
}
|
|
27
|
+
/** Walk chart children, flattening React fragments (studio often groups layers in `<>...</>`). */
|
|
28
|
+
export function forEachChartChild(children, callback) {
|
|
29
|
+
let index = 0;
|
|
30
|
+
const visit = (nodes) => {
|
|
31
|
+
Children.forEach(nodes, (child) => {
|
|
32
|
+
if (!isValidElement(child)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (child.type === Fragment) {
|
|
36
|
+
visit(child.props.children);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
callback(child, index);
|
|
40
|
+
index += 1;
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
visit(children);
|
|
44
|
+
}
|
|
45
|
+
const CLIP_EXCLUDED_COMPONENT_NAMES = new Set([
|
|
46
|
+
'Background',
|
|
47
|
+
'Grid',
|
|
48
|
+
'XAxis',
|
|
49
|
+
'YAxis',
|
|
50
|
+
'BarXAxis',
|
|
51
|
+
'BarYAxis',
|
|
52
|
+
'LiveXAxis',
|
|
53
|
+
'LiveYAxis',
|
|
54
|
+
]);
|
|
55
|
+
const UNDERLAY_COMPONENT_NAMES = new Set(['ReferenceArea', 'BarColumnTrack']);
|
|
56
|
+
/** Markers render after the interaction overlay so they stay clickable. */
|
|
57
|
+
export function isPostOverlayComponent(child) {
|
|
58
|
+
const childType = child.type;
|
|
59
|
+
if (childType.__isChartMarkers || childType.__isPostOverlay) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
const componentName = typeof child.type === 'function' ? childType.displayName || childType.name || '' : '';
|
|
63
|
+
return (componentName === 'ChartMarkers' ||
|
|
64
|
+
componentName === 'MarkerGroup' ||
|
|
65
|
+
componentName === 'ChartBrush');
|
|
66
|
+
}
|
|
67
|
+
/** Renders above grid/axes but below series; excluded from grow-clip reveal. */
|
|
68
|
+
export function isUnderlayComponent(child) {
|
|
69
|
+
const childType = child.type;
|
|
70
|
+
const componentName = typeof child.type === 'function' ? childType.displayName || childType.name || '' : '';
|
|
71
|
+
return UNDERLAY_COMPONENT_NAMES.has(componentName);
|
|
72
|
+
}
|
|
73
|
+
/** Grid and axes stay visible during series clip reveal (e.g. loading → ready). */
|
|
74
|
+
export function isClipExcludedComponent(child) {
|
|
75
|
+
const childType = child.type;
|
|
76
|
+
const componentName = typeof child.type === 'function' ? childType.displayName || childType.name || '' : '';
|
|
77
|
+
return CLIP_EXCLUDED_COMPONENT_NAMES.has(componentName);
|
|
78
|
+
}
|
|
79
|
+
/** SVG layer lists from chart shells need stable keys when rendered as arrays. */
|
|
80
|
+
export function renderKeyedChartLayers(children) {
|
|
81
|
+
return children.map((child, index) => cloneElement(child, { key: child.key ?? `chart-layer-${index}` }));
|
|
82
|
+
}
|
|
@@ -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 interface SpringConfig {
|
|
12
|
+
stiffness: number;
|
|
13
|
+
damping: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ChartConfigValue {
|
|
16
|
+
/** Crosshair indicator, tooltip dot, date pill. */
|
|
17
|
+
tooltipSpring: SpringConfig;
|
|
18
|
+
/** Floating tooltip panel. */
|
|
19
|
+
tooltipBoxSpring: SpringConfig;
|
|
20
|
+
/** Line/area hover-highlight band (x + width). */
|
|
21
|
+
highlightSpring: SpringConfig;
|
|
22
|
+
}
|
|
23
|
+
export declare const DEFAULT_CHART_CONFIG: ChartConfigValue;
|
|
24
|
+
export interface ChartConfigProviderProps {
|
|
25
|
+
value?: Partial<ChartConfigValue>;
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
export declare function ChartConfigProvider({ value, children }: ChartConfigProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare function useChartConfig(): ChartConfigValue;
|
|
30
|
+
/** Maps a damping slider to the floating tooltip panel follow spring. `0` = instant. */
|
|
31
|
+
export declare function resolveTooltipBoxMotion(damping?: number): {
|
|
32
|
+
animate: boolean;
|
|
33
|
+
springConfig: SpringConfig;
|
|
34
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { createContext, useContext, useMemo } from 'react';
|
|
13
|
+
export const DEFAULT_CHART_CONFIG = {
|
|
14
|
+
tooltipSpring: { stiffness: 300, damping: 30 },
|
|
15
|
+
tooltipBoxSpring: { stiffness: 100, damping: 20 },
|
|
16
|
+
highlightSpring: { stiffness: 180, damping: 28 },
|
|
17
|
+
};
|
|
18
|
+
const ChartConfigContext = createContext(null);
|
|
19
|
+
export function ChartConfigProvider({ value, children }) {
|
|
20
|
+
const merged = useMemo(() => ({
|
|
21
|
+
...DEFAULT_CHART_CONFIG,
|
|
22
|
+
...value,
|
|
23
|
+
}), [value]);
|
|
24
|
+
return _jsx(ChartConfigContext.Provider, { value: merged, children: children });
|
|
25
|
+
}
|
|
26
|
+
export function useChartConfig() {
|
|
27
|
+
return useContext(ChartConfigContext) ?? DEFAULT_CHART_CONFIG;
|
|
28
|
+
}
|
|
29
|
+
const DEFAULT_TOOLTIP_BOX_DAMPING = DEFAULT_CHART_CONFIG.tooltipBoxSpring.damping;
|
|
30
|
+
/** Maps a damping slider to the floating tooltip panel follow spring. `0` = instant. */
|
|
31
|
+
export function resolveTooltipBoxMotion(damping) {
|
|
32
|
+
if (damping === 0) {
|
|
33
|
+
return {
|
|
34
|
+
animate: false,
|
|
35
|
+
springConfig: DEFAULT_CHART_CONFIG.tooltipBoxSpring,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const effectiveDamping = damping ?? DEFAULT_TOOLTIP_BOX_DAMPING;
|
|
39
|
+
let stiffness = DEFAULT_CHART_CONFIG.tooltipBoxSpring.stiffness;
|
|
40
|
+
if (effectiveDamping < DEFAULT_TOOLTIP_BOX_DAMPING) {
|
|
41
|
+
const t = (DEFAULT_TOOLTIP_BOX_DAMPING - effectiveDamping) / DEFAULT_TOOLTIP_BOX_DAMPING;
|
|
42
|
+
stiffness += t * 400;
|
|
43
|
+
}
|
|
44
|
+
else if (effectiveDamping > DEFAULT_TOOLTIP_BOX_DAMPING) {
|
|
45
|
+
const t = (effectiveDamping - DEFAULT_TOOLTIP_BOX_DAMPING) / (100 - DEFAULT_TOOLTIP_BOX_DAMPING);
|
|
46
|
+
stiffness -= t * 85;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
animate: true,
|
|
50
|
+
springConfig: {
|
|
51
|
+
stiffness: Math.max(12, Math.round(stiffness)),
|
|
52
|
+
damping: effectiveDamping,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
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 { scaleBand, scaleLinear, scaleTime } from '@visx/scale';
|
|
11
|
+
type ScaleLinear<Output, _Input = number> = ReturnType<typeof scaleLinear<Output>>;
|
|
12
|
+
type ScaleTime<Output, _Input = Date | number> = ReturnType<typeof scaleTime<Output>>;
|
|
13
|
+
type ScaleBand<Domain extends {
|
|
14
|
+
toString(): string;
|
|
15
|
+
}> = ReturnType<typeof scaleBand<Domain>>;
|
|
16
|
+
import type { Transition } from 'motion/react';
|
|
17
|
+
import { type Dispatch, type ReactNode, type RefObject, type SetStateAction } from 'react';
|
|
18
|
+
import type { ChartPhase, ChartStatus } from './chart-phase';
|
|
19
|
+
import type { ReferenceAreaConfig } from './reference-area-config';
|
|
20
|
+
import type { ChartSelection } from './use-chart-interaction';
|
|
21
|
+
import type { YDomain } from './y-domain-utils';
|
|
22
|
+
export declare const chartCssVars: {
|
|
23
|
+
background: string;
|
|
24
|
+
foreground: string;
|
|
25
|
+
foregroundMuted: string;
|
|
26
|
+
label: string;
|
|
27
|
+
linePrimary: string;
|
|
28
|
+
lineSecondary: string;
|
|
29
|
+
crosshair: string;
|
|
30
|
+
grid: string;
|
|
31
|
+
indicatorColor: string;
|
|
32
|
+
indicatorSecondaryColor: string;
|
|
33
|
+
markerBackground: string;
|
|
34
|
+
markerBorder: string;
|
|
35
|
+
markerForeground: string;
|
|
36
|
+
badgeBackground: string;
|
|
37
|
+
badgeForeground: string;
|
|
38
|
+
segmentBackground: string;
|
|
39
|
+
segmentLine: string;
|
|
40
|
+
brushBorder: string;
|
|
41
|
+
tooltipBackground: string;
|
|
42
|
+
};
|
|
43
|
+
/** Default scatter series colors from the chart palette (`--chart-1` … `--chart-5`). */
|
|
44
|
+
export declare const defaultScatterColors: readonly ["var(--chart-1)", "var(--chart-2)", "var(--chart-3)", "var(--chart-4)", "var(--chart-5)"];
|
|
45
|
+
export interface Margin {
|
|
46
|
+
top: number;
|
|
47
|
+
right: number;
|
|
48
|
+
bottom: number;
|
|
49
|
+
left: number;
|
|
50
|
+
}
|
|
51
|
+
export interface TooltipData {
|
|
52
|
+
/** The data point being hovered */
|
|
53
|
+
point: Record<string, unknown>;
|
|
54
|
+
/** Index in the data array */
|
|
55
|
+
index: number;
|
|
56
|
+
/** X position in pixels (relative to chart area) */
|
|
57
|
+
x: number;
|
|
58
|
+
/** Y positions for each line, keyed by dataKey */
|
|
59
|
+
yPositions: Record<string, number>;
|
|
60
|
+
/** X positions for each series (for grouped bars), keyed by dataKey */
|
|
61
|
+
xPositions?: Record<string, number>;
|
|
62
|
+
}
|
|
63
|
+
export interface LineConfig {
|
|
64
|
+
dataKey: string;
|
|
65
|
+
stroke: string;
|
|
66
|
+
strokeWidth: number;
|
|
67
|
+
/** Scale group id (Recharts `yAxisId`). Default: `"left"`. */
|
|
68
|
+
yAxisId?: string | number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Hover/selection state — every field here changes on mouse movement.
|
|
72
|
+
* Lives in its own context so cold consumers (Grid, YAxis, PatternArea, …)
|
|
73
|
+
* can subscribe to the stable slice and skip re-rendering on every hover.
|
|
74
|
+
*/
|
|
75
|
+
export interface ChartHoverContextValue {
|
|
76
|
+
tooltipData: TooltipData | null;
|
|
77
|
+
setTooltipData: Dispatch<SetStateAction<TooltipData | null>>;
|
|
78
|
+
/** Current drag/pinch selection range */
|
|
79
|
+
selection?: ChartSelection | null;
|
|
80
|
+
/** Clear the current selection */
|
|
81
|
+
clearSelection?: () => void;
|
|
82
|
+
/** Index of currently hovered bar */
|
|
83
|
+
hoveredBarIndex?: number | null;
|
|
84
|
+
/** Setter for hovered bar index */
|
|
85
|
+
setHoveredBarIndex?: (index: number | null) => void;
|
|
86
|
+
/** Index of currently hovered candle */
|
|
87
|
+
hoveredCandleIndex?: number | null;
|
|
88
|
+
/** Setter for hovered candle index */
|
|
89
|
+
setHoveredCandleIndex?: (index: number | null) => void;
|
|
90
|
+
}
|
|
91
|
+
export interface ChartContextValue extends ChartHoverContextValue {
|
|
92
|
+
data: Record<string, unknown>[];
|
|
93
|
+
/** Decimated subset for SVG path rendering; equals `data` when no decimation is needed. */
|
|
94
|
+
renderData: Record<string, unknown>[];
|
|
95
|
+
xScale: ScaleTime<number, number>;
|
|
96
|
+
/** Primary (left) y-scale — alias for `yScales[DEFAULT_Y_AXIS_ID]`. */
|
|
97
|
+
yScale: ScaleLinear<number, number>;
|
|
98
|
+
/** Per-axis y-scales keyed by `yAxisId`. */
|
|
99
|
+
yScales: Record<string, ScaleLinear<number, number>>;
|
|
100
|
+
width: number;
|
|
101
|
+
height: number;
|
|
102
|
+
innerWidth: number;
|
|
103
|
+
innerHeight: number;
|
|
104
|
+
margin: Margin;
|
|
105
|
+
columnWidth: number;
|
|
106
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
107
|
+
lines: LineConfig[];
|
|
108
|
+
/** {@link ReferenceArea} bands — drives y-axis label colors in range. */
|
|
109
|
+
referenceAreas: ReferenceAreaConfig[];
|
|
110
|
+
chartPhase: ChartPhase;
|
|
111
|
+
chartStatus: ChartStatus;
|
|
112
|
+
/** Centered label while `chartPhase` shows loading chrome. */
|
|
113
|
+
loadingLabel?: string;
|
|
114
|
+
/** Y-domain tween duration when transitioning loading ↔ ready (ms). */
|
|
115
|
+
yDomainTweenDuration: number;
|
|
116
|
+
/** Nice’d y-domains per axis from skeleton data (placeholder). */
|
|
117
|
+
yDomainSkeletonByAxis: Record<string, YDomain>;
|
|
118
|
+
/** Nice’d y-domains per axis from the current target data. */
|
|
119
|
+
yDomainTargetByAxis: Record<string, YDomain>;
|
|
120
|
+
isLoaded: boolean;
|
|
121
|
+
animationDuration: number;
|
|
122
|
+
/** CSS easing for clip-reveal / line draw (cartesian charts). */
|
|
123
|
+
animationEasing?: string;
|
|
124
|
+
/** Motion enter transition (spring or tween) — drives clip reveal when spring. */
|
|
125
|
+
enterTransition?: Transition;
|
|
126
|
+
/** Increments when enter animation should replay. */
|
|
127
|
+
revealEpoch?: number;
|
|
128
|
+
/** Fired when a one-shot loading pulse (exit / enter) completes. */
|
|
129
|
+
notifyLoadingPulseComplete?: () => void;
|
|
130
|
+
xAccessor: (d: Record<string, unknown>) => Date;
|
|
131
|
+
dateLabels: string[];
|
|
132
|
+
/** Active brush zoom range — when set, axis ticks align to visible data rows. */
|
|
133
|
+
xDomain?: [Date, Date];
|
|
134
|
+
/** Full dataset length when brush zoom is enabled (for zoom vs full-range detection). */
|
|
135
|
+
xDomainSlotCount?: number;
|
|
136
|
+
/** Band scale for categorical x-axis (bar charts) */
|
|
137
|
+
barScale?: ScaleBand<string>;
|
|
138
|
+
/** Width of each bar band */
|
|
139
|
+
bandWidth?: number;
|
|
140
|
+
/** X accessor for bar charts (returns string instead of Date) */
|
|
141
|
+
barXAccessor?: (d: Record<string, unknown>) => string;
|
|
142
|
+
/** Bar chart orientation */
|
|
143
|
+
orientation?: 'vertical' | 'horizontal';
|
|
144
|
+
/** Whether bars are stacked */
|
|
145
|
+
stacked?: boolean;
|
|
146
|
+
/** Stack offsets: Map of data index -> Map of dataKey -> cumulative offset */
|
|
147
|
+
stackOffsets?: Map<number, Map<string, number>>;
|
|
148
|
+
/** Squares variant — snap tooltip to top square and size ring dots. */
|
|
149
|
+
squareSnap?: {
|
|
150
|
+
squareGap: number;
|
|
151
|
+
groupGap?: number;
|
|
152
|
+
fit?: boolean;
|
|
153
|
+
};
|
|
154
|
+
/** `SeriesBar` dataKeys in tree order, for grouped columns at each x */
|
|
155
|
+
composedBarDataKeys?: string[];
|
|
156
|
+
/** Target bar width in px (Recharts `barSize` style). */
|
|
157
|
+
composedBarSize?: number;
|
|
158
|
+
/** Max bar width in px (Recharts `maxBarSize`). */
|
|
159
|
+
composedMaxBarSize?: number;
|
|
160
|
+
/** Gap between grouped `SeriesBar` columns in px. */
|
|
161
|
+
composedBarGap?: number;
|
|
162
|
+
/** When true, `SeriesBar` segments stack in child order at each x. */
|
|
163
|
+
composedStacked?: boolean;
|
|
164
|
+
/** Per-row cumulative offsets for stacked `SeriesBar` (data index → dataKey → offset). */
|
|
165
|
+
composedStackOffsets?: Map<number, Map<string, number>>;
|
|
166
|
+
/** Vertical gap in px between stacked `SeriesBar` segments. Default: 0 */
|
|
167
|
+
composedStackGap?: number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Stable slice of the chart context — everything that doesn't change on hover
|
|
171
|
+
* (data, scales, dimensions, animation state, layout config). Consumers that
|
|
172
|
+
* subscribe via `useChartStable()` skip re-renders on every mouse move.
|
|
173
|
+
*/
|
|
174
|
+
export type ChartStableContextValue = Omit<ChartContextValue, keyof ChartHoverContextValue>;
|
|
175
|
+
declare const ChartStableContext: import("react").Context<ChartStableContextValue | null>;
|
|
176
|
+
/**
|
|
177
|
+
* Splits the merged `value` into a stable slice and a volatile hover slice,
|
|
178
|
+
* publishing each to its own context. Each slice is memoized on its own
|
|
179
|
+
* field identities, so changing `tooltipData` does not bust the stable
|
|
180
|
+
* slice — consumers of `useChartStable()` skip re-renders on hover.
|
|
181
|
+
*/
|
|
182
|
+
export declare function ChartProvider({ children, value, }: {
|
|
183
|
+
children: ReactNode;
|
|
184
|
+
value: ChartContextValue;
|
|
185
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
186
|
+
/**
|
|
187
|
+
* Stable slice — data, scales, dimensions, animation state, layout config.
|
|
188
|
+
* Subscribers skip re-renders on hover (the hover slice lives in a separate
|
|
189
|
+
* context). Prefer this in cold consumers like axes, grid, pattern fills.
|
|
190
|
+
*/
|
|
191
|
+
export declare function useChartStable(): ChartStableContextValue;
|
|
192
|
+
/** Y-scale for a series axis (`yAxisId` on Line / Area / YAxis). */
|
|
193
|
+
export declare function useYScale(yAxisId?: string | number): ScaleLinear<number, number>;
|
|
194
|
+
/**
|
|
195
|
+
* Hover slice — tooltipData, selection, hovered bar / candle indices.
|
|
196
|
+
* Subscribers re-render on every mouse move. Use only when the component
|
|
197
|
+
* actually reads hover state.
|
|
198
|
+
*/
|
|
199
|
+
export declare function useChartHover(): ChartHoverContextValue;
|
|
200
|
+
/**
|
|
201
|
+
* Merged stable + hover context. Convenient for components that need both,
|
|
202
|
+
* but re-renders on every hover (because hover changes). Prefer
|
|
203
|
+
* `useChartStable()` or `useChartHover()` for hot consumers that only need
|
|
204
|
+
* one slice.
|
|
205
|
+
*/
|
|
206
|
+
export declare function useChart(): ChartContextValue;
|
|
207
|
+
export default ChartStableContext;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useMemo, } from 'react';
|
|
4
|
+
import { DEFAULT_Y_AXIS_ID } from './y-axis-scales';
|
|
5
|
+
// CSS variable references for theming
|
|
6
|
+
export const chartCssVars = {
|
|
7
|
+
background: 'var(--chart-background)',
|
|
8
|
+
foreground: 'var(--chart-foreground)',
|
|
9
|
+
foregroundMuted: 'var(--chart-foreground-muted)',
|
|
10
|
+
label: 'var(--chart-label)',
|
|
11
|
+
linePrimary: 'var(--chart-line-primary)',
|
|
12
|
+
lineSecondary: 'var(--chart-line-secondary)',
|
|
13
|
+
crosshair: 'var(--chart-crosshair)',
|
|
14
|
+
grid: 'var(--chart-grid)',
|
|
15
|
+
indicatorColor: 'var(--chart-indicator-color)',
|
|
16
|
+
indicatorSecondaryColor: 'var(--chart-indicator-secondary-color)',
|
|
17
|
+
markerBackground: 'var(--chart-marker-background)',
|
|
18
|
+
markerBorder: 'var(--chart-marker-border)',
|
|
19
|
+
markerForeground: 'var(--chart-marker-foreground)',
|
|
20
|
+
badgeBackground: 'var(--chart-marker-badge-background)',
|
|
21
|
+
badgeForeground: 'var(--chart-marker-badge-foreground)',
|
|
22
|
+
segmentBackground: 'var(--chart-segment-background)',
|
|
23
|
+
segmentLine: 'var(--chart-segment-line)',
|
|
24
|
+
brushBorder: 'var(--chart-brush-border)',
|
|
25
|
+
tooltipBackground: 'var(--chart-tooltip-background)',
|
|
26
|
+
};
|
|
27
|
+
/** Default scatter series colors from the chart palette (`--chart-1` … `--chart-5`). */
|
|
28
|
+
export const defaultScatterColors = [
|
|
29
|
+
'var(--chart-1)',
|
|
30
|
+
'var(--chart-2)',
|
|
31
|
+
'var(--chart-3)',
|
|
32
|
+
'var(--chart-4)',
|
|
33
|
+
'var(--chart-5)',
|
|
34
|
+
];
|
|
35
|
+
const ChartStableContext = createContext(null);
|
|
36
|
+
const ChartHoverContext = createContext(null);
|
|
37
|
+
/**
|
|
38
|
+
* Splits the merged `value` into a stable slice and a volatile hover slice,
|
|
39
|
+
* publishing each to its own context. Each slice is memoized on its own
|
|
40
|
+
* field identities, so changing `tooltipData` does not bust the stable
|
|
41
|
+
* slice — consumers of `useChartStable()` skip re-renders on hover.
|
|
42
|
+
*/
|
|
43
|
+
export function ChartProvider({ children, value, }) {
|
|
44
|
+
const stable = useMemo(() => ({
|
|
45
|
+
data: value.data,
|
|
46
|
+
renderData: value.renderData,
|
|
47
|
+
xScale: value.xScale,
|
|
48
|
+
yScale: value.yScale,
|
|
49
|
+
yScales: value.yScales,
|
|
50
|
+
width: value.width,
|
|
51
|
+
height: value.height,
|
|
52
|
+
innerWidth: value.innerWidth,
|
|
53
|
+
innerHeight: value.innerHeight,
|
|
54
|
+
margin: value.margin,
|
|
55
|
+
columnWidth: value.columnWidth,
|
|
56
|
+
containerRef: value.containerRef,
|
|
57
|
+
lines: value.lines,
|
|
58
|
+
referenceAreas: value.referenceAreas,
|
|
59
|
+
chartPhase: value.chartPhase,
|
|
60
|
+
chartStatus: value.chartStatus,
|
|
61
|
+
loadingLabel: value.loadingLabel,
|
|
62
|
+
yDomainTweenDuration: value.yDomainTweenDuration,
|
|
63
|
+
yDomainSkeletonByAxis: value.yDomainSkeletonByAxis,
|
|
64
|
+
yDomainTargetByAxis: value.yDomainTargetByAxis,
|
|
65
|
+
isLoaded: value.isLoaded,
|
|
66
|
+
animationDuration: value.animationDuration,
|
|
67
|
+
animationEasing: value.animationEasing,
|
|
68
|
+
enterTransition: value.enterTransition,
|
|
69
|
+
revealEpoch: value.revealEpoch,
|
|
70
|
+
notifyLoadingPulseComplete: value.notifyLoadingPulseComplete,
|
|
71
|
+
xAccessor: value.xAccessor,
|
|
72
|
+
dateLabels: value.dateLabels,
|
|
73
|
+
xDomain: value.xDomain,
|
|
74
|
+
xDomainSlotCount: value.xDomainSlotCount,
|
|
75
|
+
barScale: value.barScale,
|
|
76
|
+
bandWidth: value.bandWidth,
|
|
77
|
+
barXAccessor: value.barXAccessor,
|
|
78
|
+
orientation: value.orientation,
|
|
79
|
+
stacked: value.stacked,
|
|
80
|
+
stackOffsets: value.stackOffsets,
|
|
81
|
+
composedBarDataKeys: value.composedBarDataKeys,
|
|
82
|
+
composedBarSize: value.composedBarSize,
|
|
83
|
+
composedMaxBarSize: value.composedMaxBarSize,
|
|
84
|
+
composedBarGap: value.composedBarGap,
|
|
85
|
+
composedStacked: value.composedStacked,
|
|
86
|
+
composedStackOffsets: value.composedStackOffsets,
|
|
87
|
+
composedStackGap: value.composedStackGap,
|
|
88
|
+
}), [
|
|
89
|
+
value.data,
|
|
90
|
+
value.renderData,
|
|
91
|
+
value.xScale,
|
|
92
|
+
value.yScale,
|
|
93
|
+
value.yScales,
|
|
94
|
+
value.width,
|
|
95
|
+
value.height,
|
|
96
|
+
value.innerWidth,
|
|
97
|
+
value.innerHeight,
|
|
98
|
+
value.margin,
|
|
99
|
+
value.columnWidth,
|
|
100
|
+
value.containerRef,
|
|
101
|
+
value.lines,
|
|
102
|
+
value.referenceAreas,
|
|
103
|
+
value.chartPhase,
|
|
104
|
+
value.chartStatus,
|
|
105
|
+
value.loadingLabel,
|
|
106
|
+
value.yDomainTweenDuration,
|
|
107
|
+
value.yDomainSkeletonByAxis,
|
|
108
|
+
value.yDomainTargetByAxis,
|
|
109
|
+
value.isLoaded,
|
|
110
|
+
value.animationDuration,
|
|
111
|
+
value.animationEasing,
|
|
112
|
+
value.enterTransition,
|
|
113
|
+
value.revealEpoch,
|
|
114
|
+
value.notifyLoadingPulseComplete,
|
|
115
|
+
value.xAccessor,
|
|
116
|
+
value.dateLabels,
|
|
117
|
+
value.xDomain,
|
|
118
|
+
value.xDomainSlotCount,
|
|
119
|
+
value.barScale,
|
|
120
|
+
value.bandWidth,
|
|
121
|
+
value.barXAccessor,
|
|
122
|
+
value.orientation,
|
|
123
|
+
value.stacked,
|
|
124
|
+
value.stackOffsets,
|
|
125
|
+
value.composedBarDataKeys,
|
|
126
|
+
value.composedBarSize,
|
|
127
|
+
value.composedMaxBarSize,
|
|
128
|
+
value.composedBarGap,
|
|
129
|
+
value.composedStacked,
|
|
130
|
+
value.composedStackOffsets,
|
|
131
|
+
value.composedStackGap,
|
|
132
|
+
]);
|
|
133
|
+
const hover = useMemo(() => ({
|
|
134
|
+
tooltipData: value.tooltipData,
|
|
135
|
+
setTooltipData: value.setTooltipData,
|
|
136
|
+
selection: value.selection,
|
|
137
|
+
clearSelection: value.clearSelection,
|
|
138
|
+
hoveredBarIndex: value.hoveredBarIndex,
|
|
139
|
+
setHoveredBarIndex: value.setHoveredBarIndex,
|
|
140
|
+
hoveredCandleIndex: value.hoveredCandleIndex,
|
|
141
|
+
setHoveredCandleIndex: value.setHoveredCandleIndex,
|
|
142
|
+
}), [
|
|
143
|
+
value.tooltipData,
|
|
144
|
+
value.setTooltipData,
|
|
145
|
+
value.selection,
|
|
146
|
+
value.clearSelection,
|
|
147
|
+
value.hoveredBarIndex,
|
|
148
|
+
value.setHoveredBarIndex,
|
|
149
|
+
value.hoveredCandleIndex,
|
|
150
|
+
value.setHoveredCandleIndex,
|
|
151
|
+
]);
|
|
152
|
+
return (_jsx(ChartStableContext.Provider, { value: stable, children: _jsx(ChartHoverContext.Provider, { value: hover, children: children }) }));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Stable slice — data, scales, dimensions, animation state, layout config.
|
|
156
|
+
* Subscribers skip re-renders on hover (the hover slice lives in a separate
|
|
157
|
+
* context). Prefer this in cold consumers like axes, grid, pattern fills.
|
|
158
|
+
*/
|
|
159
|
+
export function useChartStable() {
|
|
160
|
+
const context = useContext(ChartStableContext);
|
|
161
|
+
if (!context) {
|
|
162
|
+
throw new Error('useChartStable must be used within a ChartProvider. ' +
|
|
163
|
+
'Make sure your component is wrapped in <LineChart>, <AreaChart>, <BarChart>, or <ComposedChart>.');
|
|
164
|
+
}
|
|
165
|
+
return context;
|
|
166
|
+
}
|
|
167
|
+
/** Y-scale for a series axis (`yAxisId` on Line / Area / YAxis). */
|
|
168
|
+
export function useYScale(yAxisId) {
|
|
169
|
+
const { yScales, yScale } = useChartStable();
|
|
170
|
+
const id = yAxisId == null || yAxisId === '' ? DEFAULT_Y_AXIS_ID : String(yAxisId);
|
|
171
|
+
return yScales[id] ?? yScale;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Hover slice — tooltipData, selection, hovered bar / candle indices.
|
|
175
|
+
* Subscribers re-render on every mouse move. Use only when the component
|
|
176
|
+
* actually reads hover state.
|
|
177
|
+
*/
|
|
178
|
+
export function useChartHover() {
|
|
179
|
+
const context = useContext(ChartHoverContext);
|
|
180
|
+
if (!context) {
|
|
181
|
+
throw new Error('useChartHover must be used within a ChartProvider. ' +
|
|
182
|
+
'Make sure your component is wrapped in <LineChart>, <AreaChart>, <BarChart>, or <ComposedChart>.');
|
|
183
|
+
}
|
|
184
|
+
return context;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Merged stable + hover context. Convenient for components that need both,
|
|
188
|
+
* but re-renders on every hover (because hover changes). Prefer
|
|
189
|
+
* `useChartStable()` or `useChartHover()` for hot consumers that only need
|
|
190
|
+
* one slice.
|
|
191
|
+
*/
|
|
192
|
+
export function useChart() {
|
|
193
|
+
const stable = useChartStable();
|
|
194
|
+
const hover = useChartHover();
|
|
195
|
+
// Identity changes on every hover (hover is the volatile slice) — that's
|
|
196
|
+
// fine for consumers using this merged hook; they explicitly opted in to
|
|
197
|
+
// re-rendering on hover.
|
|
198
|
+
return { ...stable, ...hover };
|
|
199
|
+
}
|
|
200
|
+
export default ChartStableContext;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 ReactElement, type ReactNode } from 'react';
|
|
11
|
+
export declare function getChartChildComponentName(child: ReactElement): string;
|
|
12
|
+
/** @visx/pattern default exports use short names (e.g. `Lines`); also match *Pattern* displayNames. */
|
|
13
|
+
export declare function isPatternDefComponent(child: ReactElement): boolean;
|
|
14
|
+
export declare function isGradientDefComponent(child: ReactElement): boolean;
|
|
15
|
+
export declare function isChartDefsComponent(child: ReactElement): boolean;
|
|
16
|
+
/** Split hoisted defs: @visx/pattern nodes already wrap `<defs>` and render at the svg root. */
|
|
17
|
+
export declare function partitionChartDefNodes(defNodes: ReactElement[]): {
|
|
18
|
+
patternDefNodes: ReactElement[];
|
|
19
|
+
gradientDefNodes: ReactElement[];
|
|
20
|
+
};
|
|
21
|
+
export declare function collectChartDefsChildren(children: ReactNode): ReactElement[];
|
|
@@ -0,0 +1,57 @@
|
|
|
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, isValidElement } from 'react';
|
|
11
|
+
export function getChartChildComponentName(child) {
|
|
12
|
+
const childType = child.type;
|
|
13
|
+
return typeof child.type === 'function' ? childType.displayName || childType.name || '' : '';
|
|
14
|
+
}
|
|
15
|
+
const VISX_PATTERN_COMPONENT_NAMES = new Set([
|
|
16
|
+
'Lines',
|
|
17
|
+
'Circles',
|
|
18
|
+
'Waves',
|
|
19
|
+
'Hexagons',
|
|
20
|
+
'Path',
|
|
21
|
+
'Pattern',
|
|
22
|
+
]);
|
|
23
|
+
/** @visx/pattern default exports use short names (e.g. `Lines`); also match *Pattern* displayNames. */
|
|
24
|
+
export function isPatternDefComponent(child) {
|
|
25
|
+
const name = getChartChildComponentName(child);
|
|
26
|
+
return name.includes('Pattern') || VISX_PATTERN_COMPONENT_NAMES.has(name);
|
|
27
|
+
}
|
|
28
|
+
export function isGradientDefComponent(child) {
|
|
29
|
+
const name = getChartChildComponentName(child);
|
|
30
|
+
return name.includes('Gradient') || name === 'LinearGradient' || name === 'RadialGradient';
|
|
31
|
+
}
|
|
32
|
+
export function isChartDefsComponent(child) {
|
|
33
|
+
return isPatternDefComponent(child) || isGradientDefComponent(child);
|
|
34
|
+
}
|
|
35
|
+
/** Split hoisted defs: @visx/pattern nodes already wrap `<defs>` and render at the svg root. */
|
|
36
|
+
export function partitionChartDefNodes(defNodes) {
|
|
37
|
+
const patternDefNodes = [];
|
|
38
|
+
const gradientDefNodes = [];
|
|
39
|
+
for (const node of defNodes) {
|
|
40
|
+
if (isPatternDefComponent(node)) {
|
|
41
|
+
patternDefNodes.push(node);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
gradientDefNodes.push(node);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { patternDefNodes, gradientDefNodes };
|
|
48
|
+
}
|
|
49
|
+
export function collectChartDefsChildren(children) {
|
|
50
|
+
const defNodes = [];
|
|
51
|
+
Children.forEach(children, (child) => {
|
|
52
|
+
if (isValidElement(child) && isChartDefsComponent(child)) {
|
|
53
|
+
defNodes.push(child);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return defNodes;
|
|
57
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from bklit-ui — https://github.com/bklit/bklit-ui
|
|
3
|
+
* Copyright (c) 2026 uixmat. Released under the MIT licence; the full text is in
|
|
4
|
+
* LICENSE-bklit at the root of this package.
|
|
5
|
+
*
|
|
6
|
+
* Local change: the `@/lib/utils` import was repointed at this package's own
|
|
7
|
+
* `cn`, which is the same function. Nothing else is modified, so re-syncing
|
|
8
|
+
* with upstream stays a diff rather than a merge.
|
|
9
|
+
*/
|
|
10
|
+
export declare const shortDateFmt: Intl.DateTimeFormat;
|
|
11
|
+
export declare const weekdayDateFmt: Intl.DateTimeFormat;
|
|
12
|
+
export declare const hmsTimeFmt: Intl.DateTimeFormat;
|
|
13
|
+
export declare const intFmt: {
|
|
14
|
+
(value: number): string;
|
|
15
|
+
(value: number | bigint): string;
|
|
16
|
+
};
|