@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.
Files changed (239) hide show
  1. package/LICENSE-bklit +21 -0
  2. package/README.md +282 -0
  3. package/dist/AccessConsole.d.ts +40 -0
  4. package/dist/AccessConsole.js +160 -0
  5. package/dist/CatalogManager.d.ts +12 -0
  6. package/dist/CatalogManager.js +123 -0
  7. package/dist/ConnectionPanel.d.ts +41 -0
  8. package/dist/ConnectionPanel.js +228 -0
  9. package/dist/CoverageLedger.d.ts +16 -0
  10. package/dist/CoverageLedger.js +16 -0
  11. package/dist/DashboardBoard.d.ts +10 -0
  12. package/dist/DashboardBoard.js +206 -0
  13. package/dist/EditableField.d.ts +18 -0
  14. package/dist/EditableField.js +61 -0
  15. package/dist/FlowView.d.ts +13 -0
  16. package/dist/FlowView.js +93 -0
  17. package/dist/GovernanceTimeline.d.ts +16 -0
  18. package/dist/GovernanceTimeline.js +93 -0
  19. package/dist/ObjectExplorer.d.ts +9 -0
  20. package/dist/ObjectExplorer.js +153 -0
  21. package/dist/PipelineConsole.d.ts +20 -0
  22. package/dist/PipelineConsole.js +272 -0
  23. package/dist/QueryConsole.d.ts +11 -0
  24. package/dist/QueryConsole.js +144 -0
  25. package/dist/SavedQueryPanel.d.ts +16 -0
  26. package/dist/SavedQueryPanel.js +78 -0
  27. package/dist/TraceExplorer.d.ts +54 -0
  28. package/dist/TraceExplorer.js +342 -0
  29. package/dist/TransformEditor.d.ts +23 -0
  30. package/dist/TransformEditor.js +129 -0
  31. package/dist/WorkflowCanvas.d.ts +24 -0
  32. package/dist/WorkflowCanvas.js +701 -0
  33. package/dist/charts/bklit/animation.d.ts +19 -0
  34. package/dist/charts/bklit/animation.js +28 -0
  35. package/dist/charts/bklit/area-chart-loading.d.ts +33 -0
  36. package/dist/charts/bklit/area-chart-loading.js +30 -0
  37. package/dist/charts/bklit/area-chart.d.ts +47 -0
  38. package/dist/charts/bklit/area-chart.js +65 -0
  39. package/dist/charts/bklit/area-gradient-defs.d.ts +28 -0
  40. package/dist/charts/bklit/area-gradient-defs.js +23 -0
  41. package/dist/charts/bklit/area.d.ts +75 -0
  42. package/dist/charts/bklit/area.js +112 -0
  43. package/dist/charts/bklit/bar-chart-loading.d.ts +16 -0
  44. package/dist/charts/bklit/bar-chart-loading.js +22 -0
  45. package/dist/charts/bklit/bar-chart.d.ts +54 -0
  46. package/dist/charts/bklit/bar-chart.js +440 -0
  47. package/dist/charts/bklit/bar-depth-geometry.d.ts +41 -0
  48. package/dist/charts/bklit/bar-depth-geometry.js +46 -0
  49. package/dist/charts/bklit/bar-squares-layout.d.ts +36 -0
  50. package/dist/charts/bklit/bar-squares-layout.js +46 -0
  51. package/dist/charts/bklit/bar-squares.d.ts +48 -0
  52. package/dist/charts/bklit/bar-squares.js +206 -0
  53. package/dist/charts/bklit/bar-x-axis.d.ts +13 -0
  54. package/dist/charts/bklit/bar-x-axis.js +81 -0
  55. package/dist/charts/bklit/bar-y-axis.d.ts +11 -0
  56. package/dist/charts/bklit/bar-y-axis.js +72 -0
  57. package/dist/charts/bklit/bar.d.ts +40 -0
  58. package/dist/charts/bklit/bar.js +207 -0
  59. package/dist/charts/bklit/chart-child-passthrough.d.ts +25 -0
  60. package/dist/charts/bklit/chart-child-passthrough.js +82 -0
  61. package/dist/charts/bklit/chart-config-context.d.ts +34 -0
  62. package/dist/charts/bklit/chart-config-context.js +55 -0
  63. package/dist/charts/bklit/chart-context.d.ts +207 -0
  64. package/dist/charts/bklit/chart-context.js +200 -0
  65. package/dist/charts/bklit/chart-defs.d.ts +21 -0
  66. package/dist/charts/bklit/chart-defs.js +57 -0
  67. package/dist/charts/bklit/chart-formatters.d.ts +16 -0
  68. package/dist/charts/bklit/chart-formatters.js +26 -0
  69. package/dist/charts/bklit/chart-legend-hover.d.ts +21 -0
  70. package/dist/charts/bklit/chart-legend-hover.js +26 -0
  71. package/dist/charts/bklit/chart-loading-label.d.ts +9 -0
  72. package/dist/charts/bklit/chart-loading-label.js +29 -0
  73. package/dist/charts/bklit/chart-phase.d.ts +39 -0
  74. package/dist/charts/bklit/chart-phase.js +20 -0
  75. package/dist/charts/bklit/chart-reveal-clip.d.ts +32 -0
  76. package/dist/charts/bklit/chart-reveal-clip.js +23 -0
  77. package/dist/charts/bklit/dash-tail-stroke.d.ts +17 -0
  78. package/dist/charts/bklit/dash-tail-stroke.js +21 -0
  79. package/dist/charts/bklit/decimate-time-series.d.ts +18 -0
  80. package/dist/charts/bklit/decimate-time-series.js +120 -0
  81. package/dist/charts/bklit/fade-edges.d.ts +42 -0
  82. package/dist/charts/bklit/fade-edges.js +34 -0
  83. package/dist/charts/bklit/filter-data-by-x-domain.d.ts +13 -0
  84. package/dist/charts/bklit/filter-data-by-x-domain.js +50 -0
  85. package/dist/charts/bklit/generate-chart-skeleton-data.d.ts +24 -0
  86. package/dist/charts/bklit/generate-chart-skeleton-data.js +33 -0
  87. package/dist/charts/bklit/grid.d.ts +57 -0
  88. package/dist/charts/bklit/grid.js +88 -0
  89. package/dist/charts/bklit/highlight-segment-bounds.d.ts +26 -0
  90. package/dist/charts/bklit/highlight-segment-bounds.js +35 -0
  91. package/dist/charts/bklit/highlight-segment.d.ts +30 -0
  92. package/dist/charts/bklit/highlight-segment.js +22 -0
  93. package/dist/charts/bklit/indicator-fade.d.ts +23 -0
  94. package/dist/charts/bklit/indicator-fade.js +41 -0
  95. package/dist/charts/bklit/line-chart-loading.d.ts +33 -0
  96. package/dist/charts/bklit/line-chart-loading.js +30 -0
  97. package/dist/charts/bklit/line-chart.d.ts +45 -0
  98. package/dist/charts/bklit/line-chart.js +99 -0
  99. package/dist/charts/bklit/line-loading-pulse.d.ts +19 -0
  100. package/dist/charts/bklit/line-loading-pulse.js +132 -0
  101. package/dist/charts/bklit/line-loading-timing.d.ts +18 -0
  102. package/dist/charts/bklit/line-loading-timing.js +18 -0
  103. package/dist/charts/bklit/line-series-terminal-marker.d.ts +15 -0
  104. package/dist/charts/bklit/line-series-terminal-marker.js +54 -0
  105. package/dist/charts/bklit/line.d.ts +63 -0
  106. package/dist/charts/bklit/line.js +104 -0
  107. package/dist/charts/bklit/loading-sweep.d.ts +65 -0
  108. package/dist/charts/bklit/loading-sweep.js +182 -0
  109. package/dist/charts/bklit/motion-utils.d.ts +17 -0
  110. package/dist/charts/bklit/motion-utils.js +27 -0
  111. package/dist/charts/bklit/path-stroke-utils.d.ts +28 -0
  112. package/dist/charts/bklit/path-stroke-utils.js +64 -0
  113. package/dist/charts/bklit/pattern-area.d.ts +20 -0
  114. package/dist/charts/bklit/pattern-area.js +27 -0
  115. package/dist/charts/bklit/pattern-preset.d.ts +34 -0
  116. package/dist/charts/bklit/pattern-preset.js +82 -0
  117. package/dist/charts/bklit/projection-config.d.ts +19 -0
  118. package/dist/charts/bklit/projection-config.js +88 -0
  119. package/dist/charts/bklit/projection-line-end-marker.d.ts +14 -0
  120. package/dist/charts/bklit/projection-line-end-marker.js +35 -0
  121. package/dist/charts/bklit/projection-line.d.ts +39 -0
  122. package/dist/charts/bklit/projection-line.js +87 -0
  123. package/dist/charts/bklit/projection-utils.d.ts +54 -0
  124. package/dist/charts/bklit/projection-utils.js +252 -0
  125. package/dist/charts/bklit/reference-area-config.d.ts +18 -0
  126. package/dist/charts/bklit/reference-area-config.js +47 -0
  127. package/dist/charts/bklit/reference-area-registration-context.d.ts +7 -0
  128. package/dist/charts/bklit/reference-area-registration-context.js +15 -0
  129. package/dist/charts/bklit/series-bar-layout.d.ts +26 -0
  130. package/dist/charts/bklit/series-bar-layout.js +39 -0
  131. package/dist/charts/bklit/series-dash-tail-overlay.d.ts +16 -0
  132. package/dist/charts/bklit/series-dash-tail-overlay.js +47 -0
  133. package/dist/charts/bklit/series-highlight-layer.d.ts +31 -0
  134. package/dist/charts/bklit/series-highlight-layer.js +20 -0
  135. package/dist/charts/bklit/series-hover-dim.d.ts +28 -0
  136. package/dist/charts/bklit/series-hover-dim.js +34 -0
  137. package/dist/charts/bklit/series-markers.d.ts +13 -0
  138. package/dist/charts/bklit/series-markers.js +106 -0
  139. package/dist/charts/bklit/series-path-utils.d.ts +18 -0
  140. package/dist/charts/bklit/series-path-utils.js +68 -0
  141. package/dist/charts/bklit/series-point-marker.d.ts +47 -0
  142. package/dist/charts/bklit/series-point-marker.js +47 -0
  143. package/dist/charts/bklit/static-chart-preview-context.d.ts +15 -0
  144. package/dist/charts/bklit/static-chart-preview-context.js +20 -0
  145. package/dist/charts/bklit/time-series-chart-shell.d.ts +46 -0
  146. package/dist/charts/bklit/time-series-chart-shell.js +398 -0
  147. package/dist/charts/bklit/tooltip/chart-tooltip.d.ts +75 -0
  148. package/dist/charts/bklit/tooltip/chart-tooltip.js +158 -0
  149. package/dist/charts/bklit/tooltip/date-ticker.d.ts +10 -0
  150. package/dist/charts/bklit/tooltip/date-ticker.js +85 -0
  151. package/dist/charts/bklit/tooltip/index.d.ts +15 -0
  152. package/dist/charts/bklit/tooltip/index.js +15 -0
  153. package/dist/charts/bklit/tooltip/tooltip-box.d.ts +56 -0
  154. package/dist/charts/bklit/tooltip/tooltip-box.js +122 -0
  155. package/dist/charts/bklit/tooltip/tooltip-content.d.ts +26 -0
  156. package/dist/charts/bklit/tooltip/tooltip-content.js +8 -0
  157. package/dist/charts/bklit/tooltip/tooltip-dot.d.ts +27 -0
  158. package/dist/charts/bklit/tooltip/tooltip-dot.js +62 -0
  159. package/dist/charts/bklit/tooltip/tooltip-indicator.d.ts +44 -0
  160. package/dist/charts/bklit/tooltip/tooltip-indicator.js +73 -0
  161. package/dist/charts/bklit/use-animated-series-path.d.ts +18 -0
  162. package/dist/charts/bklit/use-animated-series-path.js +101 -0
  163. package/dist/charts/bklit/use-animated-y-domains.d.ts +13 -0
  164. package/dist/charts/bklit/use-animated-y-domains.js +158 -0
  165. package/dist/charts/bklit/use-chart-interaction.d.ts +40 -0
  166. package/dist/charts/bklit/use-chart-interaction.js +252 -0
  167. package/dist/charts/bklit/use-chart-phase-orchestrator.d.ts +22 -0
  168. package/dist/charts/bklit/use-chart-phase-orchestrator.js +147 -0
  169. package/dist/charts/bklit/use-enter-complete.d.ts +16 -0
  170. package/dist/charts/bklit/use-enter-complete.js +22 -0
  171. package/dist/charts/bklit/use-grid-shimmer.d.ts +15 -0
  172. package/dist/charts/bklit/use-grid-shimmer.js +71 -0
  173. package/dist/charts/bklit/use-highlight-segment.d.ts +22 -0
  174. package/dist/charts/bklit/use-highlight-segment.js +42 -0
  175. package/dist/charts/bklit/use-mount-progress.d.ts +12 -0
  176. package/dist/charts/bklit/use-mount-progress.js +30 -0
  177. package/dist/charts/bklit/use-scheduled-tooltip.d.ts +8 -0
  178. package/dist/charts/bklit/use-scheduled-tooltip.js +84 -0
  179. package/dist/charts/bklit/visx-pattern.d.ts +27 -0
  180. package/dist/charts/bklit/visx-pattern.js +28 -0
  181. package/dist/charts/bklit/x-axis.d.ts +26 -0
  182. package/dist/charts/bklit/x-axis.js +423 -0
  183. package/dist/charts/bklit/y-axis-scales.d.ts +34 -0
  184. package/dist/charts/bklit/y-axis-scales.js +80 -0
  185. package/dist/charts/bklit/y-axis-ticks.d.ts +20 -0
  186. package/dist/charts/bklit/y-axis-ticks.js +32 -0
  187. package/dist/charts/bklit/y-domain-utils.d.ts +26 -0
  188. package/dist/charts/bklit/y-domain-utils.js +96 -0
  189. package/dist/charts/bklit.d.ts +2 -0
  190. package/dist/charts/bklit.js +90 -0
  191. package/dist/charts/components/shimmering-text.d.ts +31 -0
  192. package/dist/charts/components/shimmering-text.js +39 -0
  193. package/dist/charts/css.d.ts +35 -0
  194. package/dist/charts/css.js +64 -0
  195. package/dist/charts/recharts.d.ts +28 -0
  196. package/dist/charts/recharts.js +48 -0
  197. package/dist/charts/registry.d.ts +34 -0
  198. package/dist/charts/registry.js +60 -0
  199. package/dist/charts/skeleton.d.ts +55 -0
  200. package/dist/charts/skeleton.js +66 -0
  201. package/dist/cn.d.ts +10 -0
  202. package/dist/cn.js +13 -0
  203. package/dist/context.d.ts +346 -0
  204. package/dist/context.js +95 -0
  205. package/dist/index.d.ts +30 -0
  206. package/dist/index.js +65 -0
  207. package/dist/routes.d.ts +70 -0
  208. package/dist/routes.js +73 -0
  209. package/dist/source-fields.d.ts +111 -0
  210. package/dist/source-fields.js +204 -0
  211. package/dist/ui/chart.d.ts +54 -0
  212. package/dist/ui/chart.js +122 -0
  213. package/dist/ui/dialog.d.ts +27 -0
  214. package/dist/ui/dialog.js +24 -0
  215. package/dist/ui/field.d.ts +29 -0
  216. package/dist/ui/field.js +31 -0
  217. package/dist/ui/select.d.ts +42 -0
  218. package/dist/ui/select.js +30 -0
  219. package/dist/ui/sheet.d.ts +38 -0
  220. package/dist/ui/sheet.js +37 -0
  221. package/dist/ui/switch.d.ts +17 -0
  222. package/dist/ui/switch.js +14 -0
  223. package/dist/ui/tabs.d.ts +30 -0
  224. package/dist/ui/tabs.js +36 -0
  225. package/dist/ui/tooltip.d.ts +37 -0
  226. package/dist/ui/tooltip.js +43 -0
  227. package/dist/workflow/graph.d.ts +112 -0
  228. package/dist/workflow/graph.js +297 -0
  229. package/dist/workflow/index.d.ts +16 -0
  230. package/dist/workflow/index.js +16 -0
  231. package/dist/workflow/model.d.ts +151 -0
  232. package/dist/workflow/model.js +97 -0
  233. package/dist/workflow/name.d.ts +28 -0
  234. package/dist/workflow/name.js +28 -0
  235. package/dist/workflow/nodes.d.ts +40 -0
  236. package/dist/workflow/nodes.js +86 -0
  237. package/dist/workflow/validate.d.ts +104 -0
  238. package/dist/workflow/validate.js +199 -0
  239. package/package.json +148 -0
@@ -0,0 +1,440 @@
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 { localPoint } from '@visx/event';
13
+ import { ParentSize } from '@visx/responsive';
14
+ import { scaleBand, scaleLinear } from '@visx/scale';
15
+ import { memo, useCallback, useEffect, useMemo, useRef, useState, } from 'react';
16
+ import { cn } from '../../cn';
17
+ import { DEFAULT_ANIMATION_EASING } from './animation';
18
+ import { topSquareCenterY } from './bar-squares-layout';
19
+ import { forEachChartChild, isChartClipPassthrough, isClipExcludedComponent, isPostOverlayComponent, isUnderlayComponent, renderKeyedChartLayers, resolveChartChildElement, } from './chart-child-passthrough';
20
+ import { ChartProvider } from './chart-context';
21
+ import { isGradientDefComponent, isPatternDefComponent } from './chart-defs';
22
+ import { shortDateFmt } from './chart-formatters';
23
+ import { DEFAULT_CHART_LIFECYCLE, resolveRestingChartPhase, } from './chart-phase';
24
+ import { BarLoadingSkeleton } from './loading-sweep';
25
+ import { extractReferenceAreaConfigs } from './reference-area-config';
26
+ import { useScheduledTooltip } from './use-scheduled-tooltip';
27
+ import { buildYScalesForLines, getPrimaryYScale, normalizeYAxisId, wrapSingleYScale, } from './y-axis-scales';
28
+ /** Skeleton bars to show when `status="loading"` and `data` is empty. */
29
+ const FALLBACK_LOADING_BARS = 12;
30
+ const DEFAULT_MARGIN = { top: 40, right: 40, bottom: 40, left: 40 };
31
+ // Extract bar configs from children synchronously
32
+ function extractBarConfigs(children) {
33
+ const configs = [];
34
+ forEachChartChild(children, (child) => {
35
+ const childType = child.type;
36
+ // Bar-depth surface layers (BarDepthBack/Front, BarPulse) carry a
37
+ // `dataKey` to pair with a Bar but are not series themselves — skip them
38
+ // so they don't inflate the series count and shrink the real bars.
39
+ if (childType.__isBarDepthLayer) {
40
+ return;
41
+ }
42
+ const componentName = typeof child.type === 'function' ? childType.displayName || childType.name || '' : '';
43
+ const props = child.props;
44
+ const isBarComponent = componentName === 'Bar' ||
45
+ componentName === 'BarSquares' ||
46
+ (props && typeof props.dataKey === 'string' && props.dataKey.length > 0);
47
+ if (isBarComponent && props?.dataKey) {
48
+ // Use stroke for tooltip dot color if provided, otherwise fall back to fill
49
+ // This allows gradient/pattern fills to have a solid dot color
50
+ const dotColor = props.stroke || props.fill || 'var(--chart-line-primary)';
51
+ configs.push({
52
+ dataKey: props.dataKey,
53
+ stroke: dotColor,
54
+ strokeWidth: 0,
55
+ yAxisId: props.yAxisId,
56
+ });
57
+ }
58
+ });
59
+ return configs;
60
+ }
61
+ function ChartInner(props) {
62
+ const { width, height } = props;
63
+ if (width < 10 || height < 10) {
64
+ return null;
65
+ }
66
+ return _jsx(ChartCore, { ...props });
67
+ }
68
+ const ChartCore = memo(function ChartCore({ width, height, data, xDataKey, margin, animationDuration, animationEasing, enterTransition, revealSignature = '', barGap, barWidthProp, orientation, stacked, stackGap, squareSnap, children, containerRef, onPhaseChange, status, }) {
69
+ const { tooltipData, setTooltipData, scheduleTooltip, clearTooltip } = useScheduledTooltip();
70
+ const [isLoaded, setIsLoaded] = useState(false);
71
+ const [revealEpoch, setRevealEpoch] = useState(0);
72
+ const hoveredBarIndex = tooltipData?.index ?? null;
73
+ const isHorizontal = orientation === 'horizontal';
74
+ // Extract bar configs synchronously from children
75
+ const lines = useMemo(() => extractBarConfigs(children), [children]);
76
+ const innerWidth = width - margin.left - margin.right;
77
+ const innerHeight = height - margin.top - margin.bottom;
78
+ // Category accessor function - returns string for categorical scale
79
+ const categoryAccessor = useCallback((d) => {
80
+ const value = d[xDataKey];
81
+ if (value instanceof Date) {
82
+ return shortDateFmt.format(value);
83
+ }
84
+ return String(value ?? '');
85
+ }, [xDataKey]);
86
+ // For compatibility with ChartContext, provide a Date-based xAccessor
87
+ const xAccessorDate = useCallback((d) => {
88
+ const value = d[xDataKey];
89
+ if (value instanceof Date) {
90
+ return value;
91
+ }
92
+ return new Date();
93
+ }, [xDataKey]);
94
+ // Category scale (band) - for the categorical axis
95
+ const categoryScale = useMemo(() => {
96
+ const domain = data.map((d) => categoryAccessor(d));
97
+ const range = isHorizontal ? [0, innerHeight] : [0, innerWidth];
98
+ return scaleBand({
99
+ range,
100
+ domain,
101
+ padding: barGap,
102
+ });
103
+ }, [innerWidth, innerHeight, data, categoryAccessor, barGap, isHorizontal]);
104
+ // Band width for bars - use prop if provided, otherwise use scale's bandwidth
105
+ const bandWidth = barWidthProp ?? categoryScale.bandwidth();
106
+ // Compute max value considering stacking
107
+ const maxValue = useMemo(() => {
108
+ if (stacked) {
109
+ // For stacked bars, sum all values at each data point
110
+ let max = 0;
111
+ for (const d of data) {
112
+ let sum = 0;
113
+ for (const line of lines) {
114
+ const value = d[line.dataKey];
115
+ if (typeof value === 'number') {
116
+ sum += value;
117
+ }
118
+ }
119
+ if (sum > max) {
120
+ max = sum;
121
+ }
122
+ }
123
+ return max || 100;
124
+ }
125
+ // For grouped bars, find max single value
126
+ let max = 0;
127
+ for (const line of lines) {
128
+ for (const d of data) {
129
+ const value = d[line.dataKey];
130
+ if (typeof value === 'number' && value > max) {
131
+ max = value;
132
+ }
133
+ }
134
+ }
135
+ return max || 100;
136
+ }, [data, lines, stacked]);
137
+ // Value scale (linear) - for the value axis
138
+ const valueScale = useMemo(() => {
139
+ const range = isHorizontal ? [0, innerWidth] : [innerHeight, 0];
140
+ return scaleLinear({
141
+ range,
142
+ domain: [0, maxValue * 1.1],
143
+ nice: true,
144
+ });
145
+ }, [innerWidth, innerHeight, maxValue, isHorizontal]);
146
+ const yScales = useMemo(() => {
147
+ if (isHorizontal) {
148
+ return wrapSingleYScale(valueScale);
149
+ }
150
+ return buildYScalesForLines({
151
+ lines,
152
+ data,
153
+ innerHeight,
154
+ resolveDomain: (dataKeys) => {
155
+ let max = 0;
156
+ for (const d of data) {
157
+ for (const key of dataKeys) {
158
+ const value = d[key];
159
+ if (typeof value === 'number' && value > max) {
160
+ max = value;
161
+ }
162
+ }
163
+ }
164
+ return [0, (max || 100) * 1.1];
165
+ },
166
+ });
167
+ }, [data, innerHeight, isHorizontal, lines, valueScale]);
168
+ const primaryYScale = getPrimaryYScale(yScales, valueScale);
169
+ // Compute stack offsets for stacked bars
170
+ const stackOffsets = useMemo(() => {
171
+ if (!stacked) {
172
+ return undefined;
173
+ }
174
+ const offsets = new Map();
175
+ for (let i = 0; i < data.length; i++) {
176
+ const d = data[i];
177
+ if (!d) {
178
+ continue;
179
+ }
180
+ const pointOffsets = new Map();
181
+ let cumulative = 0;
182
+ for (const line of lines) {
183
+ pointOffsets.set(line.dataKey, cumulative);
184
+ const value = d[line.dataKey];
185
+ if (typeof value === 'number') {
186
+ cumulative += value;
187
+ }
188
+ }
189
+ offsets.set(i, pointOffsets);
190
+ }
191
+ return offsets;
192
+ }, [data, lines, stacked]);
193
+ // Column width for tooltip indicator
194
+ const columnWidth = useMemo(() => {
195
+ if (data.length < 1) {
196
+ return 0;
197
+ }
198
+ return isHorizontal ? innerHeight / data.length : innerWidth / data.length;
199
+ }, [innerWidth, innerHeight, data.length, isHorizontal]);
200
+ // Pre-compute labels for ticker animation
201
+ const dateLabels = useMemo(() => data.map((d) => categoryAccessor(d)), [data, categoryAccessor]);
202
+ // Create a fake time scale for compatibility with ChartContext
203
+ const fakeTimeScale = useMemo(() => {
204
+ const now = Date.now();
205
+ const start = now - data.length * 24 * 60 * 60 * 1000;
206
+ const scale = {
207
+ ...categoryScale,
208
+ domain: () => [new Date(start), new Date(now)],
209
+ range: () => [0, innerWidth],
210
+ invert: (x) => new Date(start + (x / innerWidth) * (now - start)),
211
+ copy: () => scale,
212
+ };
213
+ return scale;
214
+ }, [categoryScale, innerWidth, data.length]);
215
+ // Animation timing — replay when motion settings change
216
+ // biome-ignore lint/correctness/useExhaustiveDependencies: revealSignature
217
+ useEffect(() => {
218
+ setRevealEpoch((n) => n + 1);
219
+ setIsLoaded(false);
220
+ // While loading, hold the skeleton (no reveal, no interaction). When
221
+ // status flips to "ready" this effect re-runs and plays the grow reveal.
222
+ if (status === 'loading') {
223
+ return;
224
+ }
225
+ const staggerMs = data.length > 1 ? animationDuration * 0.4 : 0;
226
+ const timer = setTimeout(() => {
227
+ setIsLoaded(true);
228
+ }, animationDuration + staggerMs);
229
+ return () => clearTimeout(timer);
230
+ }, [animationDuration, revealSignature, status]);
231
+ useEffect(() => {
232
+ onPhaseChange?.(isLoaded ? 'ready' : 'revealing');
233
+ }, [isLoaded, onPhaseChange]);
234
+ // Mouse move handler
235
+ const handleMouseMove = useCallback((event) => {
236
+ const point = localPoint(event);
237
+ if (!point) {
238
+ return;
239
+ }
240
+ const pos = isHorizontal ? point.y - margin.top : point.x - margin.left;
241
+ // Find which band the mouse is over
242
+ const bandIndex = Math.floor(pos / columnWidth);
243
+ const clampedIndex = Math.max(0, Math.min(data.length - 1, bandIndex));
244
+ const d = data[clampedIndex];
245
+ if (!d) {
246
+ return;
247
+ }
248
+ // Calculate positions for each bar
249
+ const yPositions = {};
250
+ const xPositions = {};
251
+ const barPos = categoryScale(categoryAccessor(d)) ?? 0;
252
+ if (isHorizontal) {
253
+ // Horizontal bars: dots at end of bar (x = value), centered vertically in band
254
+ const seriesCount = lines.length;
255
+ const groupGap = seriesCount > 1 ? 4 : 0;
256
+ const individualBarHeight = seriesCount > 0 ? (bandWidth - groupGap * (seriesCount - 1)) / seriesCount : bandWidth;
257
+ if (stacked) {
258
+ // Stacked horizontal: all bars same y, x at cumulative end
259
+ let cumulative = 0;
260
+ for (const line of lines) {
261
+ const value = d[line.dataKey];
262
+ if (typeof value === 'number') {
263
+ cumulative += value;
264
+ const axisScale = yScales[normalizeYAxisId(line.yAxisId)] ?? valueScale;
265
+ xPositions[line.dataKey] = axisScale(cumulative) ?? 0;
266
+ yPositions[line.dataKey] = barPos + bandWidth / 2;
267
+ }
268
+ }
269
+ }
270
+ else {
271
+ // Grouped horizontal: each bar at its own y position
272
+ lines.forEach((line, idx) => {
273
+ const value = d[line.dataKey];
274
+ if (typeof value === 'number') {
275
+ const axisScale = yScales[normalizeYAxisId(line.yAxisId)] ?? valueScale;
276
+ xPositions[line.dataKey] = axisScale(value) ?? 0;
277
+ yPositions[line.dataKey] =
278
+ barPos + idx * (individualBarHeight + groupGap) + individualBarHeight / 2;
279
+ }
280
+ });
281
+ }
282
+ }
283
+ else if (stacked) {
284
+ // Vertical stacked bars
285
+ let cumulative = 0;
286
+ let seriesIdx = 0;
287
+ for (const line of lines) {
288
+ const value = d[line.dataKey];
289
+ if (typeof value === 'number') {
290
+ cumulative += value;
291
+ const axisScale = yScales[normalizeYAxisId(line.yAxisId)] ?? primaryYScale;
292
+ const gapOffset = seriesIdx * stackGap;
293
+ yPositions[line.dataKey] = (axisScale(cumulative) ?? 0) - gapOffset;
294
+ seriesIdx++;
295
+ }
296
+ }
297
+ }
298
+ else {
299
+ // Vertical grouped bars
300
+ const seriesCount = lines.length;
301
+ const groupGap = seriesCount > 1 ? 4 : 0;
302
+ const individualBarWidth = seriesCount > 0 ? (bandWidth - groupGap * (seriesCount - 1)) / seriesCount : bandWidth;
303
+ lines.forEach((line, idx) => {
304
+ const value = d[line.dataKey];
305
+ if (typeof value === 'number') {
306
+ const axisScale = yScales[normalizeYAxisId(line.yAxisId)] ?? primaryYScale;
307
+ const baselineY = axisScale(0) ?? innerHeight;
308
+ const valueY = axisScale(value) ?? 0;
309
+ const barLengthPx = baselineY - valueY;
310
+ if (squareSnap && !isHorizontal && value > 0) {
311
+ yPositions[line.dataKey] = topSquareCenterY({
312
+ baselineY,
313
+ barLengthPx,
314
+ squareSize: individualBarWidth,
315
+ gap: squareSnap.squareGap,
316
+ fit: squareSnap.fit,
317
+ });
318
+ }
319
+ else {
320
+ yPositions[line.dataKey] = valueY;
321
+ }
322
+ xPositions[line.dataKey] =
323
+ barPos + idx * (individualBarWidth + groupGap) + individualBarWidth / 2;
324
+ }
325
+ });
326
+ }
327
+ // Tooltip position: for horizontal, position at max bar end; for vertical, center of band
328
+ let tooltipX;
329
+ if (isHorizontal) {
330
+ // Position tooltip at the end of the longest bar
331
+ const maxX = Math.max(...Object.values(xPositions), 0);
332
+ tooltipX = maxX;
333
+ }
334
+ else {
335
+ tooltipX = barPos + bandWidth / 2;
336
+ }
337
+ scheduleTooltip({
338
+ point: d,
339
+ index: clampedIndex,
340
+ x: tooltipX,
341
+ yPositions,
342
+ xPositions: Object.keys(xPositions).length > 0 ? xPositions : undefined,
343
+ });
344
+ }, [
345
+ categoryScale,
346
+ valueScale,
347
+ data,
348
+ lines,
349
+ margin.left,
350
+ margin.top,
351
+ categoryAccessor,
352
+ columnWidth,
353
+ bandWidth,
354
+ isHorizontal,
355
+ stacked,
356
+ stackGap,
357
+ scheduleTooltip,
358
+ yScales,
359
+ primaryYScale,
360
+ squareSnap,
361
+ innerHeight,
362
+ ]);
363
+ const handleMouseLeave = useCallback(() => {
364
+ clearTooltip();
365
+ }, [clearTooltip]);
366
+ const canInteract = isLoaded;
367
+ // Separate children into defs, pre-overlay, and post-overlay
368
+ const defsChildren = [];
369
+ const clipExcludedChildren = [];
370
+ const underlayChildren = [];
371
+ const preOverlayChildren = [];
372
+ const postOverlayChildren = [];
373
+ forEachChartChild(children, (child) => {
374
+ const resolvedChild = resolveChartChildElement(child);
375
+ if (isGradientDefComponent(child)) {
376
+ defsChildren.push(child);
377
+ }
378
+ else if (isPatternDefComponent(child)) {
379
+ preOverlayChildren.push(child);
380
+ }
381
+ else if (isPostOverlayComponent(resolvedChild)) {
382
+ postOverlayChildren.push(resolvedChild);
383
+ }
384
+ else if (isClipExcludedComponent(resolvedChild)) {
385
+ clipExcludedChildren.push(isChartClipPassthrough(child.type) ? resolvedChild : child);
386
+ }
387
+ else if (isUnderlayComponent(resolvedChild)) {
388
+ underlayChildren.push(resolvedChild);
389
+ }
390
+ else {
391
+ preOverlayChildren.push(child);
392
+ }
393
+ });
394
+ const referenceAreas = useMemo(() => extractReferenceAreaConfigs(children), [children]);
395
+ const contextValue = {
396
+ ...DEFAULT_CHART_LIFECYCLE,
397
+ chartPhase: resolveRestingChartPhase(status),
398
+ chartStatus: status,
399
+ data,
400
+ renderData: data,
401
+ xScale: fakeTimeScale,
402
+ yScale: isHorizontal ? valueScale : primaryYScale,
403
+ yScales,
404
+ width,
405
+ height,
406
+ innerWidth,
407
+ innerHeight,
408
+ margin,
409
+ columnWidth,
410
+ tooltipData,
411
+ setTooltipData,
412
+ containerRef,
413
+ lines,
414
+ referenceAreas,
415
+ isLoaded,
416
+ animationDuration,
417
+ animationEasing,
418
+ enterTransition,
419
+ revealEpoch,
420
+ xAccessor: xAccessorDate,
421
+ dateLabels,
422
+ // Bar-specific properties
423
+ barScale: categoryScale,
424
+ bandWidth,
425
+ hoveredBarIndex,
426
+ barXAccessor: categoryAccessor,
427
+ orientation,
428
+ stacked,
429
+ stackOffsets,
430
+ squareSnap,
431
+ };
432
+ return (_jsx(ChartProvider, { value: contextValue, children: _jsxs("svg", { "aria-hidden": "true", className: "overflow-visible", height: height, width: width, children: [defsChildren.length > 0 && _jsx("defs", { children: defsChildren }), _jsx("rect", { fill: "transparent", height: height, width: width, x: 0, y: 0 }), _jsxs("g", { onMouseLeave: canInteract ? handleMouseLeave : undefined, onMouseMove: canInteract ? handleMouseMove : undefined, style: { cursor: canInteract ? 'crosshair' : 'default' }, transform: `translate(${margin.left},${margin.top})`, children: [_jsx("rect", { fill: "transparent", height: innerHeight, width: innerWidth, x: 0, y: 0 }), renderKeyedChartLayers(clipExcludedChildren), renderKeyedChartLayers(underlayChildren), status === 'loading' ? (_jsx(BarLoadingSkeleton, { barCount: data.length || FALLBACK_LOADING_BARS, innerHeight: innerHeight, innerWidth: innerWidth })) : (renderKeyedChartLayers(preOverlayChildren)), renderKeyedChartLayers(postOverlayChildren)] })] }) }));
433
+ });
434
+ export function BarChart({ data, xDataKey = 'name', margin: marginProp, animationDuration = 1100, animationEasing = DEFAULT_ANIMATION_EASING, enterTransition, revealSignature, aspectRatio = '2 / 1', className = '', barGap = 0.2, barWidth, orientation = 'vertical', stacked = false, stackGap = 0, squareSnap, children, onPhaseChange, status = 'ready', }) {
435
+ const containerRef = useRef(null);
436
+ const margin = { ...DEFAULT_MARGIN, ...marginProp };
437
+ return (_jsx("div", { className: cn('relative w-full overflow-visible', className), ref: containerRef, style: { aspectRatio }, children: _jsx(ParentSize, { debounceTime: 10, children: ({ width, height }) => (_jsx(ChartInner, { animationDuration: animationDuration, animationEasing: animationEasing, barGap: barGap, barWidthProp: barWidth, containerRef: containerRef, data: data, enterTransition: enterTransition, height: height, margin: margin, onPhaseChange: onPhaseChange, orientation: orientation, revealSignature: revealSignature, squareSnap: squareSnap, stacked: stacked, stackGap: stackGap, status: status, width: width, xDataKey: xDataKey, children: children })) }) }));
438
+ }
439
+ BarChart.displayName = 'BarChart';
440
+ export default BarChart;
@@ -0,0 +1,41 @@
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
+ /**
11
+ * Shared 3D bar-depth geometry — the single source of truth for the
12
+ * perspective math used by BOTH `<Bar perspective>` (which shrinks a
13
+ * bar's front-face top) AND the bar-depth surfaces (`<BarDepthBack>`'s side +
14
+ * lid). Keeping the formula here means the front face and the 3D lid can never
15
+ * drift out of alignment.
16
+ */
17
+ /** Hard ceiling on side-face thickness in px. Capped further by the column gap
18
+ * so depth never bleeds past the next bar's leading edge. */
19
+ export declare const BAR_DEPTH_MAX_PX = 7;
20
+ /** The side parallelogram's back edge lifts by `depth * this ratio`, giving a
21
+ * subtle head-on perspective slope. */
22
+ export declare const BAR_DEPTH_PERSPECTIVE_RATIO = 0.45;
23
+ /**
24
+ * Maximum side-face depth in px for a chart, clamped so depth never spills past
25
+ * the gap between bars. `stepWidth` is d3-scaleBand's `step()` (bandwidth +
26
+ * gap); `bandWidth` is a single bar's width. Returns 0 for gapless/dense charts.
27
+ */
28
+ export declare function barDepthMaxDepth(stepWidth: number, bandWidth: number): number;
29
+ /**
30
+ * Per-bar side-face depth + perspective rise.
31
+ *
32
+ * - `absOffset` ∈ [0, 1]: the bar's normalized distance from the chart's
33
+ * horizontal center. 0 = dead center (no depth); 1 = chart edge (full depth).
34
+ * - `naturalHeight`: the bar's pixel height. Depth is capped by it so a short
35
+ * bar's side never reads wider than the bar is tall.
36
+ * - `maxDepth`: from `barDepthMaxDepth`.
37
+ */
38
+ export declare function barDepthAndRise(absOffset: number, naturalHeight: number, maxDepth: number): {
39
+ depth: number;
40
+ perspectiveRise: number;
41
+ };
@@ -0,0 +1,46 @@
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
+ /**
11
+ * Shared 3D bar-depth geometry — the single source of truth for the
12
+ * perspective math used by BOTH `<Bar perspective>` (which shrinks a
13
+ * bar's front-face top) AND the bar-depth surfaces (`<BarDepthBack>`'s side +
14
+ * lid). Keeping the formula here means the front face and the 3D lid can never
15
+ * drift out of alignment.
16
+ */
17
+ /** Hard ceiling on side-face thickness in px. Capped further by the column gap
18
+ * so depth never bleeds past the next bar's leading edge. */
19
+ export const BAR_DEPTH_MAX_PX = 7;
20
+ /** The side parallelogram's back edge lifts by `depth * this ratio`, giving a
21
+ * subtle head-on perspective slope. */
22
+ export const BAR_DEPTH_PERSPECTIVE_RATIO = 0.45;
23
+ /**
24
+ * Maximum side-face depth in px for a chart, clamped so depth never spills past
25
+ * the gap between bars. `stepWidth` is d3-scaleBand's `step()` (bandwidth +
26
+ * gap); `bandWidth` is a single bar's width. Returns 0 for gapless/dense charts.
27
+ */
28
+ export function barDepthMaxDepth(stepWidth, bandWidth) {
29
+ const gap = Math.max(0, stepWidth - bandWidth);
30
+ return Math.min(bandWidth * 0.22, Math.max(0, gap - 1), BAR_DEPTH_MAX_PX);
31
+ }
32
+ /**
33
+ * Per-bar side-face depth + perspective rise.
34
+ *
35
+ * - `absOffset` ∈ [0, 1]: the bar's normalized distance from the chart's
36
+ * horizontal center. 0 = dead center (no depth); 1 = chart edge (full depth).
37
+ * - `naturalHeight`: the bar's pixel height. Depth is capped by it so a short
38
+ * bar's side never reads wider than the bar is tall.
39
+ * - `maxDepth`: from `barDepthMaxDepth`.
40
+ */
41
+ export function barDepthAndRise(absOffset, naturalHeight, maxDepth) {
42
+ const offset = Math.min(1, Math.max(0, absOffset));
43
+ const cappedMaxDepth = Math.min(maxDepth, Math.max(0, naturalHeight));
44
+ const depth = offset * cappedMaxDepth;
45
+ return { depth, perspectiveRise: depth * BAR_DEPTH_PERSPECTIVE_RATIO };
46
+ }
@@ -0,0 +1,36 @@
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 interface SquareColumnLayout {
11
+ /** Number of squares in the column */
12
+ count: number;
13
+ /** Top-left Y of each square, bottom square first (relative to bar top at 0) */
14
+ positions: number[];
15
+ /** Quantized column height in pixels */
16
+ columnHeight: number;
17
+ squareSize: number;
18
+ /** Effective gap between squares (may differ when fit mode redistributes) */
19
+ gap: number;
20
+ }
21
+ export interface SquareColumnInput {
22
+ /** Raw bar length in pixels (baseline − value) */
23
+ barLengthPx: number;
24
+ /** Square width/height — typically equals bar width */
25
+ squareSize: number;
26
+ /** Gap between stacked squares in pixels */
27
+ gap: number;
28
+ /** When true, redistribute gap so column height matches barLengthPx exactly */
29
+ fit?: boolean;
30
+ }
31
+ /** Quantize bar length into a stack of square cells. */
32
+ export declare function computeSquareColumn({ barLengthPx, squareSize, gap, fit, }: SquareColumnInput): SquareColumnLayout;
33
+ /** Y center of the topmost square in a vertical column. */
34
+ export declare function topSquareCenterY({ baselineY, barLengthPx, squareSize, gap, fit, }: SquareColumnInput & {
35
+ baselineY: number;
36
+ }): number;
@@ -0,0 +1,46 @@
1
+ /** Quantize bar length into a stack of square cells. */
2
+ export function computeSquareColumn({ barLengthPx, squareSize, gap, fit = false, }) {
3
+ if (barLengthPx <= 0 || squareSize <= 0) {
4
+ return { count: 0, positions: [], columnHeight: 0, squareSize, gap };
5
+ }
6
+ if (fit) {
7
+ const count = Math.max(1, Math.floor((barLengthPx + gap) / (squareSize + gap)));
8
+ const effectiveGap = count > 1 ? Math.max(0, (barLengthPx - count * squareSize) / (count - 1)) : 0;
9
+ const step = squareSize + effectiveGap;
10
+ const columnHeight = barLengthPx;
11
+ const positions = [];
12
+ for (let i = 0; i < count; i++) {
13
+ positions.push(columnHeight - squareSize - i * step);
14
+ }
15
+ return {
16
+ count,
17
+ positions,
18
+ columnHeight,
19
+ squareSize,
20
+ gap: effectiveGap,
21
+ };
22
+ }
23
+ const step = squareSize + gap;
24
+ const count = Math.max(1, Math.round(barLengthPx / step));
25
+ const columnHeight = count * squareSize + Math.max(0, count - 1) * gap;
26
+ const positions = [];
27
+ for (let i = 0; i < count; i++) {
28
+ const offsetFromBottom = i * step;
29
+ positions.push(columnHeight - squareSize - offsetFromBottom);
30
+ }
31
+ return { count, positions, columnHeight, squareSize, gap };
32
+ }
33
+ /** Y center of the topmost square in a vertical column. */
34
+ export function topSquareCenterY({ baselineY, barLengthPx, squareSize, gap, fit = false, }) {
35
+ const { count, squareSize: size, columnHeight, } = computeSquareColumn({
36
+ barLengthPx,
37
+ squareSize,
38
+ gap,
39
+ fit,
40
+ });
41
+ if (count === 0) {
42
+ return baselineY;
43
+ }
44
+ const topY = baselineY - columnHeight;
45
+ return topY + size / 2;
46
+ }
@@ -0,0 +1,48 @@
1
+ import { type PatternPresetId } from './pattern-preset';
2
+ export interface GradientStop {
3
+ offset: number;
4
+ color: string;
5
+ }
6
+ export interface BarSquaresProps {
7
+ dataKey: string;
8
+ yAxisId?: string | number;
9
+ /** Fill color, gradient url, or pattern url. Default: var(--chart-line-primary) */
10
+ fill?: string;
11
+ /** Tooltip dot / ring stroke color when fill is gradient/pattern */
12
+ stroke?: string;
13
+ /** Gap between stacked squares in pixels. Default: 3 */
14
+ squareGap?: number;
15
+ /** Corner radius as a fraction of square size (0 = flat, 0.5 = circle). Default: 0.25 */
16
+ squareRadius?: number;
17
+ /** Redistribute gap so columns fit bar height exactly */
18
+ squareFit?: boolean;
19
+ /** Apply bar-spanning gradient from gradientStops */
20
+ useGradient?: boolean;
21
+ gradientStops?: GradientStop[];
22
+ /** Pattern preset when fill is a pattern (for gradient tinting) */
23
+ patternPreset?: PatternPresetId;
24
+ animate?: boolean;
25
+ fadedOpacity?: number;
26
+ staggerDelay?: number;
27
+ groupGap?: number;
28
+ }
29
+ export interface BarColumnTrackProps {
30
+ /** Fill color or pattern url. Default: var(--chart-grid) */
31
+ fill?: string;
32
+ opacity?: number;
33
+ squareGap?: number;
34
+ /** Corner radius fraction (matches squares). Default: 0.25 */
35
+ squareRadius?: number;
36
+ groupGap?: number;
37
+ squareFit?: boolean;
38
+ staggerDelay?: number;
39
+ }
40
+ export declare function BarSquares(props: BarSquaresProps): import("react/jsx-runtime").JSX.Element | null;
41
+ export declare namespace BarSquares {
42
+ var displayName: string;
43
+ }
44
+ export declare function BarColumnTrack(props: BarColumnTrackProps): import("react/jsx-runtime").JSX.Element | null;
45
+ export declare namespace BarColumnTrack {
46
+ var displayName: string;
47
+ }
48
+ export default BarSquares;