@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,423 @@
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 { memo, useEffect, useMemo, useState } from 'react';
13
+ import { createPortal } from 'react-dom';
14
+ import { cn } from '../../cn';
15
+ import { useChart, useChartStable } from './chart-context';
16
+ import { shortDateFmt } from './chart-formatters';
17
+ import { DEFAULT_Y_DOMAIN_TWEEN_MS } from './chart-phase';
18
+ import { LINE_LOADING_PULSE_EASE } from './line-loading-timing';
19
+ const X_AXIS_POSITION_TWEEN_MS = DEFAULT_Y_DOMAIN_TWEEN_MS;
20
+ function XAxisLabel({ label, x, crosshairX, hoveredLabel, isHovering, tickerHalfWidth, animatePosition, }) {
21
+ const fadeBuffer = 20;
22
+ const fadeRadius = tickerHalfWidth + fadeBuffer;
23
+ let opacity = 1;
24
+ if (isHovering && crosshairX !== null) {
25
+ const distance = Math.abs(x - crosshairX);
26
+ if (distance < tickerHalfWidth) {
27
+ opacity = 0;
28
+ }
29
+ else if (hoveredLabel && label === hoveredLabel) {
30
+ opacity = 0;
31
+ }
32
+ else if (distance < fadeRadius) {
33
+ opacity = (distance - tickerHalfWidth) / fadeBuffer;
34
+ }
35
+ }
36
+ return (_jsx("div", { className: "absolute", style: {
37
+ left: x,
38
+ bottom: 12,
39
+ width: 0,
40
+ display: 'flex',
41
+ justifyContent: 'center',
42
+ transition: animatePosition
43
+ ? `left ${X_AXIS_POSITION_TWEEN_MS}ms cubic-bezier(${LINE_LOADING_PULSE_EASE.join(', ')})`
44
+ : undefined,
45
+ }, children: _jsx("span", { className: cn('whitespace-nowrap text-chart-label text-xs'), style: {
46
+ opacity,
47
+ transition: 'opacity 0.4s ease-in-out',
48
+ }, children: label }) }));
49
+ }
50
+ const MAX_GAP_LAYOUTS = 400;
51
+ function binomial(n, k) {
52
+ if (k < 0 || k > n) {
53
+ return 0;
54
+ }
55
+ let result = 1;
56
+ for (let i = 0; i < k; i++) {
57
+ result = (result * (n - i)) / (i + 1);
58
+ }
59
+ return result;
60
+ }
61
+ /** All ways to split `span` into `parts` positive integer gaps. */
62
+ function composePositiveSum(sum, parts) {
63
+ if (parts === 1) {
64
+ return sum >= 1 ? [[sum]] : [];
65
+ }
66
+ const layouts = [];
67
+ for (let gap = 1; gap <= sum - (parts - 1); gap++) {
68
+ for (const tail of composePositiveSum(sum - gap, parts - 1)) {
69
+ layouts.push([gap, ...tail]);
70
+ }
71
+ }
72
+ return layouts;
73
+ }
74
+ function gapsToIndices(gaps) {
75
+ const indices = [0];
76
+ let position = 0;
77
+ for (const gap of gaps) {
78
+ position += gap;
79
+ indices.push(position);
80
+ }
81
+ return indices;
82
+ }
83
+ function indicesForTickCount(length, tickCount) {
84
+ const span = length - 1;
85
+ if (span <= 0) {
86
+ return [0];
87
+ }
88
+ const rawIndices = Array.from({ length: tickCount }, (_, index) => Math.round((index / (tickCount - 1)) * span));
89
+ const indices = [...new Set(rawIndices)].sort((a, b) => a - b);
90
+ if (indices[0] !== 0) {
91
+ indices.unshift(0);
92
+ }
93
+ if (indices.at(-1) !== span) {
94
+ indices.push(span);
95
+ }
96
+ return [...new Set(indices)].sort((a, b) => a - b);
97
+ }
98
+ function allIndexLayouts(length, tickCount) {
99
+ const span = length - 1;
100
+ if (span <= 0) {
101
+ return [[0]];
102
+ }
103
+ const gapCount = tickCount - 1;
104
+ if (gapCount <= 0) {
105
+ return [[0]];
106
+ }
107
+ const layoutCount = binomial(span - 1, gapCount - 1);
108
+ if (layoutCount > MAX_GAP_LAYOUTS) {
109
+ return [indicesForTickCount(length, tickCount)];
110
+ }
111
+ return composePositiveSum(span, gapCount).map(gapsToIndices);
112
+ }
113
+ function dedupeIndicesByLabel(indices, data, dateLabels, xAccessor) {
114
+ const seenLabels = new Set();
115
+ const deduped = [];
116
+ for (const index of indices) {
117
+ const point = data[index];
118
+ if (!point) {
119
+ continue;
120
+ }
121
+ const label = dateLabels[index] ?? shortDateFmt.format(xAccessor(point));
122
+ if (seenLabels.has(label)) {
123
+ continue;
124
+ }
125
+ seenLabels.add(label);
126
+ deduped.push(index);
127
+ }
128
+ return deduped;
129
+ }
130
+ function indexGaps(indices) {
131
+ const gaps = [];
132
+ for (let i = 1; i < indices.length; i++) {
133
+ const current = indices[i];
134
+ const previous = indices[i - 1];
135
+ if (current == null || previous == null) {
136
+ continue;
137
+ }
138
+ gaps.push(current - previous);
139
+ }
140
+ return gaps;
141
+ }
142
+ function smallestGapEdgePreference(indices) {
143
+ const gaps = indexGaps(indices);
144
+ const smallestGap = Math.min(...gaps);
145
+ const smallestGapIndex = gaps.indexOf(smallestGap);
146
+ if (smallestGapIndex === gaps.length - 1) {
147
+ return 0;
148
+ }
149
+ if (smallestGapIndex === 0) {
150
+ return 1;
151
+ }
152
+ return 2;
153
+ }
154
+ function scoreTickLayout(indices, resolveXPx, targetCount) {
155
+ if (indices.length < 2) {
156
+ return {
157
+ score: Number.POSITIVE_INFINITY,
158
+ symmetryPenalty: Number.POSITIVE_INFINITY,
159
+ countDistance: Number.POSITIVE_INFINITY,
160
+ edgePreference: Number.POSITIVE_INFINITY,
161
+ };
162
+ }
163
+ const pixelGaps = [];
164
+ for (let i = 1; i < indices.length; i++) {
165
+ const current = indices[i];
166
+ const previous = indices[i - 1];
167
+ if (current == null || previous == null) {
168
+ continue;
169
+ }
170
+ pixelGaps.push(resolveXPx(current) - resolveXPx(previous));
171
+ }
172
+ const minGap = Math.min(...pixelGaps);
173
+ const maxGap = Math.max(...pixelGaps);
174
+ const meanGap = pixelGaps.reduce((sum, gap) => sum + gap, 0) / pixelGaps.length;
175
+ const spreadRatio = meanGap > 0 ? (maxGap - minGap) / meanGap : maxGap - minGap;
176
+ const countDistance = Math.abs(indices.length - targetCount);
177
+ const gaps = indexGaps(indices);
178
+ const smallestGap = Math.min(...gaps);
179
+ const smallestGapIndex = gaps.indexOf(smallestGap);
180
+ const interiorPenalty = smallestGapIndex > 0 && smallestGapIndex < gaps.length - 1 ? 0.08 : 0;
181
+ const symmetryPenalty = gaps.reduce((penalty, gap, index) => {
182
+ return penalty + Math.abs(gap - (gaps.at(-1 - index) ?? gap));
183
+ }, 0) / gaps.length;
184
+ return {
185
+ score: spreadRatio + 0.1 * countDistance + interiorPenalty + symmetryPenalty * 0.02,
186
+ symmetryPenalty,
187
+ countDistance,
188
+ edgePreference: smallestGapEdgePreference(indices),
189
+ };
190
+ }
191
+ function isBetterTickLayout(next, best, nextCountDistance, bestCountDistance) {
192
+ if (next.score < best.score - 1e-6) {
193
+ return true;
194
+ }
195
+ if (Math.abs(next.score - best.score) > 1e-6) {
196
+ return false;
197
+ }
198
+ if (nextCountDistance < bestCountDistance) {
199
+ return true;
200
+ }
201
+ if (nextCountDistance > bestCountDistance) {
202
+ return false;
203
+ }
204
+ if (next.symmetryPenalty < best.symmetryPenalty - 1e-6) {
205
+ return true;
206
+ }
207
+ if (next.symmetryPenalty > best.symmetryPenalty + 1e-6) {
208
+ return false;
209
+ }
210
+ return next.edgePreference < best.edgePreference;
211
+ }
212
+ /**
213
+ * Picks tick indices with the most even on-screen spacing. Tries
214
+ * `targetCount ± 1` and evaluates every gap layout when feasible.
215
+ */
216
+ export function selectEvenlySpacedIndices(length, targetCount, options) {
217
+ if (length <= 0) {
218
+ return [];
219
+ }
220
+ if (length === 1) {
221
+ return [0];
222
+ }
223
+ if (length <= targetCount) {
224
+ return Array.from({ length }, (_, index) => index);
225
+ }
226
+ const resolveXPx = options?.resolveXPx ?? ((index) => index);
227
+ const minCount = Math.max(2, targetCount - 1);
228
+ const maxCount = Math.min(length, targetCount + 1);
229
+ let bestIndices = indicesForTickCount(length, targetCount);
230
+ let bestScore = scoreTickLayout(bestIndices, resolveXPx, targetCount);
231
+ let bestCountDistance = bestScore.countDistance;
232
+ for (let tickCount = minCount; tickCount <= maxCount; tickCount++) {
233
+ for (const rawIndices of allIndexLayouts(length, tickCount)) {
234
+ const indices = options?.data && options.dateLabels && options.xAccessor
235
+ ? dedupeIndicesByLabel(rawIndices, options.data, options.dateLabels, options.xAccessor)
236
+ : rawIndices;
237
+ if (indices.length < 2) {
238
+ continue;
239
+ }
240
+ const layoutScore = scoreTickLayout(indices, resolveXPx, targetCount);
241
+ const countDistance = Math.abs(indices.length - targetCount);
242
+ if (isBetterTickLayout(layoutScore, bestScore, countDistance, bestCountDistance)) {
243
+ bestIndices = indices;
244
+ bestScore = layoutScore;
245
+ bestCountDistance = countDistance;
246
+ }
247
+ }
248
+ }
249
+ return bestIndices;
250
+ }
251
+ function buildDataAlignedTicks({ data, dateLabels, marginLeft, targetTickCount, xAccessor, xScale, }) {
252
+ const seenLabels = new Set();
253
+ const ticks = [];
254
+ const resolveXPx = (index) => {
255
+ const point = data[index];
256
+ if (!point) {
257
+ return index;
258
+ }
259
+ return xScale(xAccessor(point)) ?? 0;
260
+ };
261
+ for (const index of selectEvenlySpacedIndices(data.length, targetTickCount, {
262
+ data,
263
+ dateLabels,
264
+ resolveXPx,
265
+ xAccessor,
266
+ })) {
267
+ const point = data[index];
268
+ if (!point) {
269
+ continue;
270
+ }
271
+ const date = xAccessor(point);
272
+ const label = dateLabels[index] ?? shortDateFmt.format(date);
273
+ if (seenLabels.has(label)) {
274
+ continue;
275
+ }
276
+ seenLabels.add(label);
277
+ ticks.push({
278
+ date,
279
+ label,
280
+ x: (xScale(date) ?? 0) + marginLeft,
281
+ });
282
+ }
283
+ return ticks;
284
+ }
285
+ function buildDomainTicks({ marginLeft, numTicks, xScale, }) {
286
+ const domain = xScale.domain();
287
+ const startDate = domain[0];
288
+ const endDate = domain[1];
289
+ if (!(startDate && endDate)) {
290
+ return [];
291
+ }
292
+ const startTime = startDate.getTime();
293
+ const endTime = endDate.getTime();
294
+ const timeRange = endTime - startTime;
295
+ const tickCount = Math.max(2, numTicks);
296
+ const seenLabels = new Set();
297
+ const ticks = [];
298
+ for (let i = 0; i < tickCount; i++) {
299
+ const t = i / (tickCount - 1);
300
+ const date = new Date(startTime + t * timeRange);
301
+ const label = shortDateFmt.format(date);
302
+ if (seenLabels.has(label)) {
303
+ continue;
304
+ }
305
+ seenLabels.add(label);
306
+ ticks.push({
307
+ date,
308
+ label,
309
+ x: (xScale(date) ?? 0) + marginLeft,
310
+ });
311
+ }
312
+ return ticks;
313
+ }
314
+ function domainExtendsPastData(data, xAccessor, xScale) {
315
+ if (data.length === 0) {
316
+ return false;
317
+ }
318
+ const domainEnd = xScale.domain()[1];
319
+ const lastPoint = data.at(-1);
320
+ if (!(domainEnd && lastPoint)) {
321
+ return false;
322
+ }
323
+ return domainEnd.getTime() > xAccessor(lastPoint).getTime();
324
+ }
325
+ /** Domain ticks for the projection tail when brush keeps data-aligned labels. */
326
+ function appendProjectionTailTicks(ticks, data, xAccessor, xScale, marginLeft, maxExtraTicks) {
327
+ if (data.length === 0 || maxExtraTicks <= 0) {
328
+ return ticks;
329
+ }
330
+ const lastPoint = data.at(-1);
331
+ const domainEnd = xScale.domain()[1];
332
+ if (!(lastPoint && domainEnd)) {
333
+ return ticks;
334
+ }
335
+ const lastDate = xAccessor(lastPoint);
336
+ const startTime = lastDate.getTime();
337
+ const endTime = domainEnd.getTime();
338
+ if (endTime <= startTime) {
339
+ return ticks;
340
+ }
341
+ const seenLabels = new Set(ticks.map((tick) => tick.label));
342
+ const extras = [];
343
+ const extraCount = Math.min(maxExtraTicks, 3);
344
+ for (let i = 1; i <= extraCount; i++) {
345
+ const date = new Date(startTime + (i / (extraCount + 1)) * (endTime - startTime));
346
+ const label = shortDateFmt.format(date);
347
+ if (seenLabels.has(label)) {
348
+ continue;
349
+ }
350
+ seenLabels.add(label);
351
+ extras.push({
352
+ date,
353
+ label,
354
+ x: (xScale(date) ?? 0) + marginLeft,
355
+ });
356
+ }
357
+ const endLabel = shortDateFmt.format(domainEnd);
358
+ if (!seenLabels.has(endLabel)) {
359
+ extras.push({
360
+ date: domainEnd,
361
+ label: endLabel,
362
+ x: (xScale(domainEnd) ?? 0) + marginLeft,
363
+ });
364
+ }
365
+ if (extras.length === 0) {
366
+ return ticks;
367
+ }
368
+ return [...ticks, ...extras].sort((a, b) => a.x - b.x);
369
+ }
370
+ export function XAxis(props) {
371
+ const { containerRef } = useChartStable();
372
+ const [mounted, setMounted] = useState(false);
373
+ useEffect(() => {
374
+ setMounted(true);
375
+ }, []);
376
+ const container = containerRef.current;
377
+ if (!(mounted && container)) {
378
+ return null;
379
+ }
380
+ return _jsx(XAxisInner, { ...props, container: container });
381
+ }
382
+ const XAxisInner = memo(function XAxisInner({ numTicks = 5, tickerHalfWidth = 50, tickMode = 'data', container, }) {
383
+ const { xScale, margin, tooltipData, data, xAccessor, dateLabels, xDomain } = useChart();
384
+ const labelsToShow = useMemo(() => {
385
+ const projectionExtendsScale = tickMode === 'data' && domainExtendsPastData(data, xAccessor, xScale);
386
+ if (tickMode === 'domain') {
387
+ return buildDomainTicks({
388
+ marginLeft: margin.left,
389
+ numTicks,
390
+ xScale,
391
+ });
392
+ }
393
+ // No brush: evenly spaced ticks across the full domain (data + projection).
394
+ if (projectionExtendsScale && xDomain == null) {
395
+ return buildDomainTicks({
396
+ marginLeft: margin.left,
397
+ numTicks,
398
+ xScale,
399
+ });
400
+ }
401
+ const dataTicks = buildDataAlignedTicks({
402
+ data,
403
+ dateLabels,
404
+ marginLeft: margin.left,
405
+ targetTickCount: numTicks,
406
+ xAccessor,
407
+ xScale,
408
+ });
409
+ // Brush: keep data-aligned ticks, add labels only in the projection tail.
410
+ if (projectionExtendsScale && xDomain != null) {
411
+ return appendProjectionTailTicks(dataTicks, data, xAccessor, xScale, margin.left, Math.max(1, numTicks - dataTicks.length + 1));
412
+ }
413
+ return dataTicks;
414
+ }, [tickMode, xDomain, data, dateLabels, xAccessor, xScale, margin.left, numTicks]);
415
+ const isHovering = tooltipData !== null;
416
+ const crosshairX = tooltipData ? tooltipData.x + margin.left : null;
417
+ const hoveredLabel = isHovering && tooltipData
418
+ ? (dateLabels[tooltipData.index] ?? shortDateFmt.format(xAccessor(tooltipData.point)))
419
+ : null;
420
+ return createPortal(_jsx("div", { className: "pointer-events-none absolute inset-0", children: labelsToShow.map((item) => (_jsx(XAxisLabel, { animatePosition: xDomain == null, crosshairX: crosshairX, hoveredLabel: hoveredLabel, isHovering: isHovering, label: item.label, tickerHalfWidth: tickerHalfWidth, x: item.x }, `${item.date.getTime()}-${item.x}`))) }), container);
421
+ });
422
+ XAxis.displayName = 'XAxis';
423
+ export default XAxis;
@@ -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 { scaleLinear } from '@visx/scale';
11
+ import type { LineConfig } from './chart-context';
12
+ /** Default axis id when `yAxisId` is omitted (Recharts-style `0` / primary left axis). */
13
+ export declare const DEFAULT_Y_AXIS_ID = "left";
14
+ export type YAxisOrientation = 'left' | 'right';
15
+ export declare function normalizeYAxisId(id?: string | number): string;
16
+ export declare function groupLinesByYAxisId(lines: LineConfig[]): Map<string, LineConfig[]>;
17
+ type YScale = ReturnType<typeof scaleLinear<number>>;
18
+ export declare function getPrimaryYScale(yScales: Record<string, YScale>, fallback: YScale): YScale;
19
+ export declare function buildYScalesForLines({ lines, innerHeight, resolveDomain, }: {
20
+ lines: LineConfig[];
21
+ /** Passed by callers; domain is resolved via `resolveDomain`. */
22
+ data?: Record<string, unknown>[];
23
+ innerHeight: number;
24
+ resolveDomain: (dataKeys: string[]) => [number, number];
25
+ }): Record<string, YScale>;
26
+ /** Build y-scales from pre-computed (already nice'd) domain endpoints. */
27
+ export declare function buildYScalesFromDomains({ lines, innerHeight, domainsByAxis, }: {
28
+ lines: LineConfig[];
29
+ innerHeight: number;
30
+ domainsByAxis: Record<string, [number, number]>;
31
+ }): Record<string, YScale>;
32
+ /** Single-axis charts (bar, scatter, candlestick, live line). */
33
+ export declare function wrapSingleYScale(yScale: YScale): Record<string, YScale>;
34
+ export {};
@@ -0,0 +1,80 @@
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 { scaleLinear } from '@visx/scale';
11
+ /** Default axis id when `yAxisId` is omitted (Recharts-style `0` / primary left axis). */
12
+ export const DEFAULT_Y_AXIS_ID = 'left';
13
+ export function normalizeYAxisId(id) {
14
+ if (id == null || id === '') {
15
+ return DEFAULT_Y_AXIS_ID;
16
+ }
17
+ return String(id);
18
+ }
19
+ export function groupLinesByYAxisId(lines) {
20
+ const groups = new Map();
21
+ for (const line of lines) {
22
+ const axisId = normalizeYAxisId(line.yAxisId);
23
+ const bucket = groups.get(axisId) ?? [];
24
+ bucket.push(line);
25
+ groups.set(axisId, bucket);
26
+ }
27
+ return groups;
28
+ }
29
+ export function getPrimaryYScale(yScales, fallback) {
30
+ const primary = yScales[DEFAULT_Y_AXIS_ID];
31
+ if (primary) {
32
+ return primary;
33
+ }
34
+ const first = Object.values(yScales)[0];
35
+ return first ?? fallback;
36
+ }
37
+ export function buildYScalesForLines({ lines, innerHeight, resolveDomain, }) {
38
+ const groups = groupLinesByYAxisId(lines);
39
+ const scales = {};
40
+ for (const [axisId, axisLines] of groups) {
41
+ const dataKeys = axisLines.map((line) => line.dataKey);
42
+ const domain = resolveDomain(dataKeys);
43
+ scales[axisId] = scaleLinear({
44
+ range: [innerHeight, 0],
45
+ domain,
46
+ nice: true,
47
+ });
48
+ }
49
+ if (!scales[DEFAULT_Y_AXIS_ID]) {
50
+ scales[DEFAULT_Y_AXIS_ID] = scaleLinear({
51
+ range: [innerHeight, 0],
52
+ domain: [0, 100],
53
+ nice: true,
54
+ });
55
+ }
56
+ return scales;
57
+ }
58
+ /** Build y-scales from pre-computed (already nice'd) domain endpoints. */
59
+ export function buildYScalesFromDomains({ lines, innerHeight, domainsByAxis, }) {
60
+ const groups = groupLinesByYAxisId(lines);
61
+ const scales = {};
62
+ for (const [axisId] of groups) {
63
+ const domain = domainsByAxis[axisId] ?? domainsByAxis[DEFAULT_Y_AXIS_ID] ?? [0, 100];
64
+ scales[axisId] = scaleLinear({
65
+ range: [innerHeight, 0],
66
+ domain,
67
+ });
68
+ }
69
+ if (!scales[DEFAULT_Y_AXIS_ID]) {
70
+ scales[DEFAULT_Y_AXIS_ID] = scaleLinear({
71
+ range: [innerHeight, 0],
72
+ domain: domainsByAxis[DEFAULT_Y_AXIS_ID] ?? [0, 100],
73
+ });
74
+ }
75
+ return scales;
76
+ }
77
+ /** Single-axis charts (bar, scatter, candlestick, live line). */
78
+ export function wrapSingleYScale(yScale) {
79
+ return { [DEFAULT_Y_AXIS_ID]: yScale };
80
+ }
@@ -0,0 +1,20 @@
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
+ /** Default hint passed to `scale.ticks()` (d3 — approximate tick count). */
11
+ export declare const Y_AXIS_DEFAULT_TICK_COUNT = 5;
12
+ /** Minimum valid `numTicks` for `scale.ticks()` — values ≤ 0 yield no ticks. */
13
+ export declare const Y_AXIS_MIN_TICK_COUNT = 1;
14
+ /**
15
+ * Upper bound for the tick count hint. D3 may return more "nice" ticks above ~10;
16
+ * keeping the hint in a modest range avoids overcrowded axes.
17
+ */
18
+ export declare const Y_AXIS_MAX_TICK_COUNT = 10;
19
+ /** Clamps a user `numTicks` value to a valid d3 tick-count hint. */
20
+ export declare function resolveYAxisTickCount(numTicks?: number): number;
@@ -0,0 +1,32 @@
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
+ /** Default hint passed to `scale.ticks()` (d3 — approximate tick count). */
11
+ export const Y_AXIS_DEFAULT_TICK_COUNT = 5;
12
+ /** Minimum valid `numTicks` for `scale.ticks()` — values ≤ 0 yield no ticks. */
13
+ export const Y_AXIS_MIN_TICK_COUNT = 1;
14
+ /**
15
+ * Upper bound for the tick count hint. D3 may return more "nice" ticks above ~10;
16
+ * keeping the hint in a modest range avoids overcrowded axes.
17
+ */
18
+ export const Y_AXIS_MAX_TICK_COUNT = 10;
19
+ /** Clamps a user `numTicks` value to a valid d3 tick-count hint. */
20
+ export function resolveYAxisTickCount(numTicks) {
21
+ if (numTicks == null || !Number.isFinite(numTicks)) {
22
+ return Y_AXIS_DEFAULT_TICK_COUNT;
23
+ }
24
+ const rounded = Math.round(numTicks);
25
+ if (rounded < Y_AXIS_MIN_TICK_COUNT) {
26
+ return Y_AXIS_MIN_TICK_COUNT;
27
+ }
28
+ if (rounded > Y_AXIS_MAX_TICK_COUNT) {
29
+ return Y_AXIS_MAX_TICK_COUNT;
30
+ }
31
+ return rounded;
32
+ }
@@ -0,0 +1,26 @@
1
+ import type { LineConfig } from './chart-context';
2
+ import { type ChartPhase } from './chart-phase';
3
+ export type YDomain = [number, number];
4
+ /** Apply visx `nice()` to raw domain endpoints for stable grid ticks. */
5
+ export declare function niceYDomain(domain: YDomain): YDomain;
6
+ /**
7
+ * Skip Y tween when both endpoints move less than the threshold relative to span.
8
+ * When in doubt callers should tween — beauty wins over micro-optimization.
9
+ */
10
+ export declare function shouldTweenYDomain(from: YDomain, to: YDomain): boolean;
11
+ /** Phases where the chart shows loading chrome (shimmer, pulse, label). */
12
+ export declare function isLoadingChromePhase(phase: ChartPhase): boolean;
13
+ /** Phases where grid lines use loading stroke styling (muted / dashed chrome). */
14
+ export declare function isLoadingGridChromePhase(phase: ChartPhase): boolean;
15
+ /** Phases where Y-domain tween runs after the series has exited. */
16
+ export declare function isYDomainTweenPhase(phase: ChartPhase): boolean;
17
+ /** Phases where {@link ReferenceArea} bands are shown (fade in/out on transitions). */
18
+ export declare function isReferenceAreaVisiblePhase(phase: ChartPhase): boolean;
19
+ export declare function resolveAnimatedYDestinationDomains(chartPhase: ChartPhase, skeletonByAxis: Record<string, YDomain>, targetByAxis: Record<string, YDomain>): Record<string, YDomain>;
20
+ export declare function computeYDomainsByAxis({ lines, resolveDomain, }: {
21
+ lines: LineConfig[];
22
+ resolveDomain: (dataKeys: string[]) => YDomain;
23
+ }): Record<string, YDomain>;
24
+ /** Merge domain maps, normalizing axis ids to strings. */
25
+ export declare function mergeYDomainRecords(...records: Record<string, YDomain>[]): Record<string, YDomain>;
26
+ export declare function domainsEqual(left: Record<string, YDomain>, right: Record<string, YDomain>): boolean;