@aiconstructions/graficos 0.0.0-stage → 0.2.1
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/ALTERACOES.md +53 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +188 -2
- package/dist/aic/cores.js +83 -0
- package/dist/aic/index.js +22 -0
- package/dist/aic/interacao.js +55 -0
- package/dist/charts/animation.js +55 -0
- package/dist/charts/arc-geometry.js +58 -0
- package/dist/charts/arc-path.js +15 -0
- package/dist/charts/area-chart-loading.js +89 -0
- package/dist/charts/area-chart.js +149 -0
- package/dist/charts/area-gradient-defs.js +90 -0
- package/dist/charts/area-value-label-layout.js +70 -0
- package/dist/charts/area-value-labels.js +211 -0
- package/dist/charts/area.js +272 -0
- package/dist/charts/background.js +198 -0
- package/dist/charts/band-config.js +82 -0
- package/dist/charts/band-geometry.js +186 -0
- package/dist/charts/band.js +346 -0
- package/dist/charts/bar-chart-loading.js +27 -0
- package/dist/charts/bar-chart.js +545 -0
- package/dist/charts/bar-depth-geometry.js +18 -0
- package/dist/charts/bar-depth.js +608 -0
- package/dist/charts/bar-lollipop.js +278 -0
- package/dist/charts/bar-squares-layout.js +66 -0
- package/dist/charts/bar-squares.js +467 -0
- package/dist/charts/bar-value-label-layout.js +42 -0
- package/dist/charts/bar-x-axis.js +133 -0
- package/dist/charts/bar-y-axis.js +116 -0
- package/dist/charts/bar.js +457 -0
- package/dist/charts/bollinger.js +49 -0
- package/dist/charts/candlestick-chart.js +370 -0
- package/dist/charts/candlestick.js +368 -0
- package/dist/charts/chart-brush-handle.js +91 -0
- package/dist/charts/chart-brush-layout.js +91 -0
- package/dist/charts/chart-brush-selection-overlay.js +87 -0
- package/dist/charts/chart-brush-state.js +253 -0
- package/dist/charts/chart-brush-track-overlay.js +103 -0
- package/dist/charts/chart-brush.js +517 -0
- package/dist/charts/chart-center-typography.js +8 -0
- package/dist/charts/chart-child-passthrough.js +119 -0
- package/dist/charts/chart-config-context.js +56 -0
- package/dist/charts/chart-context.js +337 -0
- package/dist/charts/chart-crosshair.js +262 -0
- package/dist/charts/chart-data-override.js +186 -0
- package/dist/charts/chart-defs.js +56 -0
- package/dist/charts/chart-formatters.js +77 -0
- package/dist/charts/chart-legend-hover.js +27 -0
- package/dist/charts/chart-legend.js +163 -0
- package/dist/charts/chart-loading-label.js +52 -0
- package/dist/charts/chart-parent-size.js +138 -0
- package/dist/charts/chart-phase.js +29 -0
- package/dist/charts/chart-reveal-clip.js +62 -0
- package/dist/charts/chart-scale.js +19 -0
- package/dist/charts/chart-stat-flow.js +72 -0
- package/dist/charts/choropleth/choropleth-background.js +29 -0
- package/dist/charts/choropleth/choropleth-camera.js +379 -0
- package/dist/charts/choropleth/choropleth-chart.js +644 -0
- package/dist/charts/choropleth/choropleth-context.js +152 -0
- package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
- package/dist/charts/choropleth/choropleth-feature.js +291 -0
- package/dist/charts/choropleth/choropleth-graticule.js +40 -0
- package/dist/charts/choropleth/choropleth-marker.js +222 -0
- package/dist/charts/choropleth/choropleth-projection.js +37 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
- package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
- package/dist/charts/choropleth/index.js +44 -0
- package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
- package/dist/charts/composed-chart.js +346 -0
- package/dist/charts/crosshair-store.js +49 -0
- package/dist/charts/dash-tail-stroke.js +58 -0
- package/dist/charts/date-pill-store.js +50 -0
- package/dist/charts/date-ranges.js +131 -0
- package/dist/charts/deadline.js +295 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.js +171 -0
- package/dist/charts/fast-path.js +78 -0
- package/dist/charts/filter-data-by-x-domain.js +45 -0
- package/dist/charts/funnel-chart.js +773 -0
- package/dist/charts/gauge-arc-layers.js +479 -0
- package/dist/charts/gauge-dial.js +329 -0
- package/dist/charts/gauge-label-layout.js +148 -0
- package/dist/charts/gauge.js +946 -0
- package/dist/charts/generate-chart-skeleton-data.js +27 -0
- package/dist/charts/gradients.js +158 -0
- package/dist/charts/grid-lines.js +114 -0
- package/dist/charts/grid.js +225 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
- package/dist/charts/heatmap/heatmap-animation.js +128 -0
- package/dist/charts/heatmap/heatmap-cells.js +519 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
- package/dist/charts/heatmap/heatmap-chart.js +548 -0
- package/dist/charts/heatmap/heatmap-colors.js +127 -0
- package/dist/charts/heatmap/heatmap-context.js +107 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
- package/dist/charts/heatmap/heatmap-legend.js +165 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
- package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
- package/dist/charts/heatmap/heatmap-separator.js +168 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
- package/dist/charts/heatmap/heatmap-utils.js +633 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
- package/dist/charts/heatmap/index.js +208 -0
- package/dist/charts/highlight-segment-bounds.js +34 -0
- package/dist/charts/highlight-segment.js +119 -0
- package/dist/charts/index.js +944 -0
- package/dist/charts/indicator-fade.js +44 -0
- package/dist/charts/legend/index.js +22 -0
- package/dist/charts/legend/legend-context.js +47 -0
- package/dist/charts/legend/legend-item.js +30 -0
- package/dist/charts/legend/legend-label.js +14 -0
- package/dist/charts/legend/legend-marker.js +18 -0
- package/dist/charts/legend/legend-progress.js +39 -0
- package/dist/charts/legend/legend-value.js +31 -0
- package/dist/charts/legend/legend.js +69 -0
- package/dist/charts/line-backdrop.js +129 -0
- package/dist/charts/line-chart-loading.js +85 -0
- package/dist/charts/line-chart.js +182 -0
- package/dist/charts/line-loading-pulse.js +185 -0
- package/dist/charts/line-loading-timing.js +12 -0
- package/dist/charts/line-path.js +58 -0
- package/dist/charts/line-series-terminal-marker.js +75 -0
- package/dist/charts/line.js +499 -0
- package/dist/charts/live-line-chart.js +494 -0
- package/dist/charts/live-line.js +277 -0
- package/dist/charts/live-x-axis.js +116 -0
- package/dist/charts/live-y-axis.js +164 -0
- package/dist/charts/loading-sweep.js +344 -0
- package/dist/charts/local-point.js +56 -0
- package/dist/charts/markers/chart-markers.js +149 -0
- package/dist/charts/markers/index.js +14 -0
- package/dist/charts/markers/marker-group.js +411 -0
- package/dist/charts/motion-utils.js +29 -0
- package/dist/charts/notch-gauge-shared.js +146 -0
- package/dist/charts/particle-line.js +1340 -0
- package/dist/charts/path-stroke-utils.js +51 -0
- package/dist/charts/pattern-area.js +127 -0
- package/dist/charts/pattern-preset.js +287 -0
- package/dist/charts/pattern-tile.js +31 -0
- package/dist/charts/patterns/circles.js +62 -0
- package/dist/charts/patterns/constants.js +9 -0
- package/dist/charts/patterns/hexagons.js +38 -0
- package/dist/charts/patterns/index.js +16 -0
- package/dist/charts/patterns/lines.js +65 -0
- package/dist/charts/patterns/path.js +37 -0
- package/dist/charts/patterns/pattern.js +16 -0
- package/dist/charts/patterns/waves.js +40 -0
- package/dist/charts/pie-center-shell.js +127 -0
- package/dist/charts/pie-center.js +87 -0
- package/dist/charts/pie-chart.js +377 -0
- package/dist/charts/pie-context.js +116 -0
- package/dist/charts/pie-slice.js +394 -0
- package/dist/charts/pie-ticks.js +332 -0
- package/dist/charts/profit-loss-legend-hover.js +18 -0
- package/dist/charts/profit-loss-legend.js +53 -0
- package/dist/charts/profit-loss-line.js +162 -0
- package/dist/charts/profit-loss-segments.js +88 -0
- package/dist/charts/projection-config.js +90 -0
- package/dist/charts/projection-line-end-marker.js +50 -0
- package/dist/charts/projection-line.js +466 -0
- package/dist/charts/projection-utils.js +303 -0
- package/dist/charts/radar-area.js +192 -0
- package/dist/charts/radar-axis.js +41 -0
- package/dist/charts/radar-chart.js +184 -0
- package/dist/charts/radar-context.js +104 -0
- package/dist/charts/radar-grid.js +121 -0
- package/dist/charts/radar-labels.js +62 -0
- package/dist/charts/radial-area.js +498 -0
- package/dist/charts/radial-axis.js +652 -0
- package/dist/charts/radial-bar.js +316 -0
- package/dist/charts/radial-center.js +67 -0
- package/dist/charts/radial-chart.js +740 -0
- package/dist/charts/radial-dot-bar-layout.js +68 -0
- package/dist/charts/radial-dot-bar.js +387 -0
- package/dist/charts/radial-geometry.js +114 -0
- package/dist/charts/radial-legend.js +66 -0
- package/dist/charts/radial-line.js +280 -0
- package/dist/charts/radial-ring-bar.js +255 -0
- package/dist/charts/radial-scrubber.js +120 -0
- package/dist/charts/radial-series-color.js +10 -0
- package/dist/charts/reference-area-config.js +43 -0
- package/dist/charts/reference-area-geometry.js +76 -0
- package/dist/charts/reference-area-registration-context.js +10 -0
- package/dist/charts/reference-area.js +241 -0
- package/dist/charts/responsive-chart-label-count.js +18 -0
- package/dist/charts/ring-center.js +78 -0
- package/dist/charts/ring-chart.js +362 -0
- package/dist/charts/ring-context.js +122 -0
- package/dist/charts/ring-grid.js +175 -0
- package/dist/charts/ring-labels.js +109 -0
- package/dist/charts/ring.js +237 -0
- package/dist/charts/sankey/index.js +22 -0
- package/dist/charts/sankey/sankey-chart.js +199 -0
- package/dist/charts/sankey/sankey-context.js +32 -0
- package/dist/charts/sankey/sankey-link.js +232 -0
- package/dist/charts/sankey/sankey-node.js +348 -0
- package/dist/charts/sankey/sankey-tooltip.js +94 -0
- package/dist/charts/scatter-chart-shell.js +279 -0
- package/dist/charts/scatter-chart.js +150 -0
- package/dist/charts/scatter-jitter.js +86 -0
- package/dist/charts/scatter-svg.js +17 -0
- package/dist/charts/scatter.js +92 -0
- package/dist/charts/segment.js +107 -0
- package/dist/charts/series-bar-layout.js +42 -0
- package/dist/charts/series-bar.js +241 -0
- package/dist/charts/series-dash-tail-overlay.js +53 -0
- package/dist/charts/series-highlight-layer.js +43 -0
- package/dist/charts/series-hover-dim.js +32 -0
- package/dist/charts/series-markers.js +239 -0
- package/dist/charts/series-path-utils.js +185 -0
- package/dist/charts/series-point-marker.js +150 -0
- package/dist/charts/sparkline-geometry.js +197 -0
- package/dist/charts/sparkline.js +910 -0
- package/dist/charts/static-chart-preview-context.js +16 -0
- package/dist/charts/sunburst-breadcrumb.js +33 -0
- package/dist/charts/sunburst-center.js +37 -0
- package/dist/charts/sunburst-chart.js +408 -0
- package/dist/charts/sunburst-context.js +140 -0
- package/dist/charts/sunburst-data.js +0 -0
- package/dist/charts/sunburst-hint.js +42 -0
- package/dist/charts/sunburst-labels.js +130 -0
- package/dist/charts/sunburst-segment.js +144 -0
- package/dist/charts/sunburst.js +419 -0
- package/dist/charts/time-series-chart-shell.js +688 -0
- package/dist/charts/tooltip/chart-tooltip.js +516 -0
- package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
- package/dist/charts/tooltip/date-ticker.js +376 -0
- package/dist/charts/tooltip/index.js +32 -0
- package/dist/charts/tooltip/liquid-glass.js +142 -0
- package/dist/charts/tooltip/tooltip-box.js +502 -0
- package/dist/charts/tooltip/tooltip-content.js +59 -0
- package/dist/charts/tooltip/tooltip-dot.js +170 -0
- package/dist/charts/tooltip/tooltip-indicator.js +175 -0
- package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
- package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
- package/dist/charts/trend-line-utils.js +64 -0
- package/dist/charts/trend-line.js +318 -0
- package/dist/charts/use-animated-band.js +175 -0
- package/dist/charts/use-animated-series-path.js +208 -0
- package/dist/charts/use-animated-y-domains.js +192 -0
- package/dist/charts/use-category-slots.js +29 -0
- package/dist/charts/use-chart-interaction.js +296 -0
- package/dist/charts/use-chart-phase-orchestrator.js +183 -0
- package/dist/charts/use-enter-complete.js +18 -0
- package/dist/charts/use-grid-shimmer.js +88 -0
- package/dist/charts/use-highlight-segment.js +65 -0
- package/dist/charts/use-mount-progress.js +23 -0
- package/dist/charts/use-scatter-chart-interaction.js +364 -0
- package/dist/charts/use-scheduled-tooltip.js +84 -0
- package/dist/charts/visx-pattern.js +30 -0
- package/dist/charts/weekends.js +174 -0
- package/dist/charts/x-axis-hover.js +46 -0
- package/dist/charts/x-axis.js +523 -0
- package/dist/charts/y-axis-scales.js +71 -0
- package/dist/charts/y-axis-ticks.js +22 -0
- package/dist/charts/y-axis.js +233 -0
- package/dist/charts/y-domain-utils.js +189 -0
- package/dist/index.d.ts +7346 -0
- package/dist/index.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/shimmering-text.js +54 -0
- package/package.json +78 -4
- package/tema.css +202 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
domAnimation,
|
|
5
|
+
frameData,
|
|
6
|
+
JSAnimation,
|
|
7
|
+
LazyMotion,
|
|
8
|
+
m,
|
|
9
|
+
useMotionValue,
|
|
10
|
+
useReducedMotion,
|
|
11
|
+
useSpring
|
|
12
|
+
} from "motion/react";
|
|
13
|
+
import {
|
|
14
|
+
memo,
|
|
15
|
+
useLayoutEffect,
|
|
16
|
+
useMemo,
|
|
17
|
+
useRef
|
|
18
|
+
} from "react";
|
|
19
|
+
import { cn } from "../../lib/utils";
|
|
20
|
+
import {
|
|
21
|
+
DATE_TICKER_GLASS_CLASS,
|
|
22
|
+
LiquidGlassFilter,
|
|
23
|
+
useLiquidGlass
|
|
24
|
+
} from "./liquid-glass";
|
|
25
|
+
const TICKER_ITEM_HEIGHT = 24;
|
|
26
|
+
const TICKER_SPRING = { stiffness: 400, damping: 35 };
|
|
27
|
+
const COMPACT_TICKER_THRESHOLD = 60;
|
|
28
|
+
function driveSpring(value, target, instant) {
|
|
29
|
+
if (instant) {
|
|
30
|
+
value.jump(target);
|
|
31
|
+
} else {
|
|
32
|
+
value.set(target);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function toSegments(values) {
|
|
36
|
+
const segments = [];
|
|
37
|
+
values.forEach((value, index) => {
|
|
38
|
+
if (segments.at(-1)?.value !== value) {
|
|
39
|
+
segments.push({ value, key: `${value}-${index}`, startIndex: index });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return segments;
|
|
43
|
+
}
|
|
44
|
+
function segmentIndexAt(segments, index, total) {
|
|
45
|
+
if (index < 0 || index >= total) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
49
|
+
const segment = segments[i];
|
|
50
|
+
if (segment && segment.startIndex <= index) {
|
|
51
|
+
return i;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
function useActiveItemWidth(stackRef, items, activeIndex, width, reduceMotion) {
|
|
57
|
+
const widthsRef = useRef([]);
|
|
58
|
+
const activeIndexRef = useRef(activeIndex);
|
|
59
|
+
const fontsPendingRef = useRef(false);
|
|
60
|
+
const mountedRef = useRef(true);
|
|
61
|
+
useLayoutEffect(() => {
|
|
62
|
+
activeIndexRef.current = activeIndex;
|
|
63
|
+
});
|
|
64
|
+
useLayoutEffect(() => {
|
|
65
|
+
mountedRef.current = true;
|
|
66
|
+
return () => {
|
|
67
|
+
mountedRef.current = false;
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
useLayoutEffect(() => {
|
|
71
|
+
const measure = (snap) => {
|
|
72
|
+
const stack = stackRef.current;
|
|
73
|
+
if (!(mountedRef.current && stack)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
widthsRef.current = Array.from(
|
|
77
|
+
stack.querySelectorAll("[data-ticker-item]"),
|
|
78
|
+
(node) => node.getBoundingClientRect().width
|
|
79
|
+
);
|
|
80
|
+
const next = widthsRef.current[activeIndexRef.current];
|
|
81
|
+
if (next === void 0) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
driveSpring(width, next, snap || reduceMotion);
|
|
85
|
+
};
|
|
86
|
+
measure(widthsRef.current.length === 0);
|
|
87
|
+
const fonts = typeof document === "undefined" ? void 0 : document.fonts;
|
|
88
|
+
if (fonts && fonts.status === "loading" && !fontsPendingRef.current) {
|
|
89
|
+
fontsPendingRef.current = true;
|
|
90
|
+
fonts.ready.then(() => {
|
|
91
|
+
fontsPendingRef.current = false;
|
|
92
|
+
measure(false);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}, [stackRef, items, width, reduceMotion]);
|
|
96
|
+
useLayoutEffect(() => {
|
|
97
|
+
const target = widthsRef.current[activeIndex];
|
|
98
|
+
if (target !== void 0) {
|
|
99
|
+
driveSpring(width, target, reduceMotion);
|
|
100
|
+
}
|
|
101
|
+
}, [activeIndex, width, reduceMotion]);
|
|
102
|
+
}
|
|
103
|
+
const DATE_TICKER_PILL_CLASS = "overflow-hidden rounded-full bg-chart-pill px-4 py-1 text-chart-pill-foreground shadow-lg";
|
|
104
|
+
function SolidSurface({
|
|
105
|
+
className,
|
|
106
|
+
style,
|
|
107
|
+
children
|
|
108
|
+
}) {
|
|
109
|
+
return /* @__PURE__ */ jsx(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
className: cn(DATE_TICKER_PILL_CLASS, className),
|
|
113
|
+
"data-slot": "date-pill",
|
|
114
|
+
style,
|
|
115
|
+
children
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function GlassSurface({
|
|
120
|
+
className,
|
|
121
|
+
style,
|
|
122
|
+
children
|
|
123
|
+
}) {
|
|
124
|
+
const surfaceRef = useRef(null);
|
|
125
|
+
const glass = useLiquidGlass();
|
|
126
|
+
return /* @__PURE__ */ jsxs(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
className: cn(DATE_TICKER_GLASS_CLASS, className),
|
|
130
|
+
"data-slot": "date-pill",
|
|
131
|
+
"data-variant": "glass",
|
|
132
|
+
ref: surfaceRef,
|
|
133
|
+
style: { ...glass.style, ...style },
|
|
134
|
+
children: [
|
|
135
|
+
glass.svgFilter && /* @__PURE__ */ jsx(LiquidGlassFilter, { id: glass.filterId, surfaceRef }),
|
|
136
|
+
children
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
function DateTickerSurface({
|
|
142
|
+
variant = "solid",
|
|
143
|
+
...props
|
|
144
|
+
}) {
|
|
145
|
+
return variant === "glass" ? /* @__PURE__ */ jsx(GlassSurface, { ...props }) : /* @__PURE__ */ jsx(SolidSurface, { ...props });
|
|
146
|
+
}
|
|
147
|
+
const FRAME_MS = 1e3 / 60;
|
|
148
|
+
function useLabelWidth(labelRef, boxRef, width, reduceMotion) {
|
|
149
|
+
useLayoutEffect(() => {
|
|
150
|
+
const labelEl = labelRef.current;
|
|
151
|
+
if (!labelEl) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
let animation = null;
|
|
155
|
+
const stop = () => {
|
|
156
|
+
animation?.stop();
|
|
157
|
+
animation = null;
|
|
158
|
+
};
|
|
159
|
+
const start = (target, startTime) => {
|
|
160
|
+
stop();
|
|
161
|
+
animation = new JSAnimation({
|
|
162
|
+
keyframes: [width.get(), target],
|
|
163
|
+
velocity: width.getVelocity(),
|
|
164
|
+
type: "spring",
|
|
165
|
+
restDelta: 1e-3,
|
|
166
|
+
restSpeed: 0.01,
|
|
167
|
+
...TICKER_SPRING,
|
|
168
|
+
startTime,
|
|
169
|
+
onUpdate: (latest) => width.set(latest)
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
let measured = labelEl.getBoundingClientRect().width;
|
|
173
|
+
stop();
|
|
174
|
+
width.jump(measured);
|
|
175
|
+
const follow = (next) => {
|
|
176
|
+
if (reduceMotion) {
|
|
177
|
+
stop();
|
|
178
|
+
width.jump(next);
|
|
179
|
+
if (boxRef.current) {
|
|
180
|
+
boxRef.current.style.width = `${next}px`;
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const sinceFrame = performance.now() - frameData.timestamp;
|
|
185
|
+
start(
|
|
186
|
+
next,
|
|
187
|
+
sinceFrame >= 0 && sinceFrame < FRAME_MS ? frameData.timestamp : void 0
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
|
+
if (typeof ResizeObserver === "undefined") {
|
|
191
|
+
return stop;
|
|
192
|
+
}
|
|
193
|
+
const observer = new ResizeObserver(() => {
|
|
194
|
+
const next = labelEl.getBoundingClientRect().width;
|
|
195
|
+
if (next !== measured) {
|
|
196
|
+
measured = next;
|
|
197
|
+
follow(next);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
observer.observe(labelEl, { box: "border-box" });
|
|
201
|
+
return () => {
|
|
202
|
+
observer.disconnect();
|
|
203
|
+
stop();
|
|
204
|
+
};
|
|
205
|
+
}, [labelRef, boxRef, width, reduceMotion]);
|
|
206
|
+
}
|
|
207
|
+
const DateTickerCompact = memo(function DateTickerCompact2({
|
|
208
|
+
currentIndex,
|
|
209
|
+
labels,
|
|
210
|
+
className,
|
|
211
|
+
style,
|
|
212
|
+
variant
|
|
213
|
+
}) {
|
|
214
|
+
const reduceMotion = useReducedMotion() === true;
|
|
215
|
+
const label = labels[currentIndex] ?? labels[0] ?? "";
|
|
216
|
+
const labelRef = useRef(null);
|
|
217
|
+
const boxRef = useRef(null);
|
|
218
|
+
const width = useMotionValue(0);
|
|
219
|
+
useLabelWidth(labelRef, boxRef, width, reduceMotion);
|
|
220
|
+
return /* @__PURE__ */ jsx(DateTickerSurface, { className, style, variant, children: /* @__PURE__ */ jsx(m.div, { className: "relative h-6", ref: boxRef, style: { width }, children: /* @__PURE__ */ jsx(
|
|
221
|
+
m.div,
|
|
222
|
+
{
|
|
223
|
+
className: "absolute top-0 left-1/2 flex h-6 items-center",
|
|
224
|
+
style: { x: "-50%" },
|
|
225
|
+
children: /* @__PURE__ */ jsx(
|
|
226
|
+
"span",
|
|
227
|
+
{
|
|
228
|
+
className: "whitespace-nowrap font-medium text-sm",
|
|
229
|
+
"data-ticker-item": true,
|
|
230
|
+
ref: labelRef,
|
|
231
|
+
children: label
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
) }) });
|
|
236
|
+
});
|
|
237
|
+
const DateTickerInner = memo(function DateTickerInner2({
|
|
238
|
+
currentIndex,
|
|
239
|
+
labels,
|
|
240
|
+
className,
|
|
241
|
+
style,
|
|
242
|
+
variant
|
|
243
|
+
}) {
|
|
244
|
+
const reduceMotion = useReducedMotion() === true;
|
|
245
|
+
const parsedLabels = useMemo(() => {
|
|
246
|
+
return labels.map((label) => {
|
|
247
|
+
const parts = label.split(" ");
|
|
248
|
+
return { month: parts[0] || "", day: parts[1] || "" };
|
|
249
|
+
});
|
|
250
|
+
}, [labels]);
|
|
251
|
+
const monthSegments = useMemo(
|
|
252
|
+
() => toSegments(parsedLabels.map((label) => label.month)),
|
|
253
|
+
[parsedLabels]
|
|
254
|
+
);
|
|
255
|
+
const daySegments = useMemo(
|
|
256
|
+
() => toSegments(parsedLabels.map((label) => label.day)),
|
|
257
|
+
[parsedLabels]
|
|
258
|
+
);
|
|
259
|
+
const currentMonthIndex = segmentIndexAt(
|
|
260
|
+
monthSegments,
|
|
261
|
+
currentIndex,
|
|
262
|
+
parsedLabels.length
|
|
263
|
+
);
|
|
264
|
+
const currentDayIndex = segmentIndexAt(
|
|
265
|
+
daySegments,
|
|
266
|
+
currentIndex,
|
|
267
|
+
parsedLabels.length
|
|
268
|
+
);
|
|
269
|
+
const dayY = useSpring(0, TICKER_SPRING);
|
|
270
|
+
const monthY = useSpring(0, TICKER_SPRING);
|
|
271
|
+
const monthStackRef = useRef(null);
|
|
272
|
+
const dayStackRef = useRef(null);
|
|
273
|
+
const monthWidth = useSpring(0, TICKER_SPRING);
|
|
274
|
+
const dayWidth = useSpring(0, TICKER_SPRING);
|
|
275
|
+
useActiveItemWidth(
|
|
276
|
+
monthStackRef,
|
|
277
|
+
monthSegments,
|
|
278
|
+
currentMonthIndex,
|
|
279
|
+
monthWidth,
|
|
280
|
+
reduceMotion
|
|
281
|
+
);
|
|
282
|
+
useActiveItemWidth(
|
|
283
|
+
dayStackRef,
|
|
284
|
+
daySegments,
|
|
285
|
+
currentDayIndex,
|
|
286
|
+
dayWidth,
|
|
287
|
+
reduceMotion
|
|
288
|
+
);
|
|
289
|
+
useLayoutEffect(() => {
|
|
290
|
+
driveSpring(dayY, -currentDayIndex * TICKER_ITEM_HEIGHT, reduceMotion);
|
|
291
|
+
}, [currentDayIndex, dayY, reduceMotion]);
|
|
292
|
+
useLayoutEffect(() => {
|
|
293
|
+
driveSpring(monthY, -currentMonthIndex * TICKER_ITEM_HEIGHT, reduceMotion);
|
|
294
|
+
}, [currentMonthIndex, monthY, reduceMotion]);
|
|
295
|
+
return /* @__PURE__ */ jsx(DateTickerSurface, { className, style, variant, children: /* @__PURE__ */ jsx("div", { className: "relative h-6 overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-1", children: [
|
|
296
|
+
/* @__PURE__ */ jsx(
|
|
297
|
+
m.div,
|
|
298
|
+
{
|
|
299
|
+
className: "relative h-6 overflow-hidden",
|
|
300
|
+
style: { width: monthWidth },
|
|
301
|
+
children: /* @__PURE__ */ jsx(
|
|
302
|
+
m.div,
|
|
303
|
+
{
|
|
304
|
+
className: "absolute top-0 left-1/2 flex flex-col items-center",
|
|
305
|
+
ref: monthStackRef,
|
|
306
|
+
style: { x: "-50%", y: monthY },
|
|
307
|
+
children: monthSegments.map((segment) => /* @__PURE__ */ jsx(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
className: "flex h-6 shrink-0 items-center justify-center",
|
|
311
|
+
"data-ticker-item": true,
|
|
312
|
+
children: /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap font-medium text-sm", children: segment.value })
|
|
313
|
+
},
|
|
314
|
+
segment.key
|
|
315
|
+
))
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
),
|
|
320
|
+
/* @__PURE__ */ jsx(
|
|
321
|
+
m.div,
|
|
322
|
+
{
|
|
323
|
+
className: "relative h-6 overflow-hidden",
|
|
324
|
+
style: { width: dayWidth },
|
|
325
|
+
children: /* @__PURE__ */ jsx(
|
|
326
|
+
m.div,
|
|
327
|
+
{
|
|
328
|
+
className: "absolute top-0 left-1/2 flex flex-col items-center",
|
|
329
|
+
ref: dayStackRef,
|
|
330
|
+
style: { x: "-50%", y: dayY },
|
|
331
|
+
children: daySegments.map((segment) => /* @__PURE__ */ jsx(
|
|
332
|
+
"div",
|
|
333
|
+
{
|
|
334
|
+
className: "flex h-6 shrink-0 items-center justify-center",
|
|
335
|
+
"data-ticker-item": true,
|
|
336
|
+
children: /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap font-medium text-sm", children: segment.value })
|
|
337
|
+
},
|
|
338
|
+
segment.key
|
|
339
|
+
))
|
|
340
|
+
}
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
] }) }) });
|
|
345
|
+
});
|
|
346
|
+
function DateTicker({
|
|
347
|
+
currentIndex,
|
|
348
|
+
labels,
|
|
349
|
+
visible,
|
|
350
|
+
animation = "roll",
|
|
351
|
+
variant,
|
|
352
|
+
className,
|
|
353
|
+
style
|
|
354
|
+
}) {
|
|
355
|
+
if (!visible || labels.length === 0) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
const Variant = animation === "static" || labels.length > COMPACT_TICKER_THRESHOLD ? DateTickerCompact : DateTickerInner;
|
|
359
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
|
|
360
|
+
Variant,
|
|
361
|
+
{
|
|
362
|
+
className,
|
|
363
|
+
currentIndex,
|
|
364
|
+
labels,
|
|
365
|
+
style,
|
|
366
|
+
variant
|
|
367
|
+
}
|
|
368
|
+
) });
|
|
369
|
+
}
|
|
370
|
+
DateTicker.displayName = "DateTicker";
|
|
371
|
+
var date_ticker_default = DateTicker;
|
|
372
|
+
export {
|
|
373
|
+
DATE_TICKER_PILL_CLASS,
|
|
374
|
+
DateTicker,
|
|
375
|
+
date_ticker_default as default
|
|
376
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChartTooltip
|
|
3
|
+
} from "./chart-tooltip";
|
|
4
|
+
import {
|
|
5
|
+
CursorTooltipBox
|
|
6
|
+
} from "./cursor-tooltip-box";
|
|
7
|
+
import {
|
|
8
|
+
DATE_TICKER_PILL_CLASS,
|
|
9
|
+
DateTicker
|
|
10
|
+
} from "./date-ticker";
|
|
11
|
+
import { DATE_TICKER_GLASS_CLASS } from "./liquid-glass";
|
|
12
|
+
import { TooltipBox } from "./tooltip-box";
|
|
13
|
+
import {
|
|
14
|
+
TooltipContent,
|
|
15
|
+
TooltipHeader
|
|
16
|
+
} from "./tooltip-content";
|
|
17
|
+
import { TooltipDot } from "./tooltip-dot";
|
|
18
|
+
import {
|
|
19
|
+
TooltipIndicator
|
|
20
|
+
} from "./tooltip-indicator";
|
|
21
|
+
export {
|
|
22
|
+
ChartTooltip,
|
|
23
|
+
CursorTooltipBox,
|
|
24
|
+
DATE_TICKER_GLASS_CLASS,
|
|
25
|
+
DATE_TICKER_PILL_CLASS,
|
|
26
|
+
DateTicker,
|
|
27
|
+
TooltipBox,
|
|
28
|
+
TooltipContent,
|
|
29
|
+
TooltipDot,
|
|
30
|
+
TooltipHeader,
|
|
31
|
+
TooltipIndicator
|
|
32
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useId,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useRef
|
|
7
|
+
} from "react";
|
|
8
|
+
const MAP_WIDTH = 128;
|
|
9
|
+
const MAP_HEIGHT = 32;
|
|
10
|
+
const MAP_BORDER = 0.07;
|
|
11
|
+
const MAP_BLUR = 4;
|
|
12
|
+
const DISPLACEMENT_SCALE = -48;
|
|
13
|
+
const CHANNEL_OFFSETS = { r: 0, g: 6, b: 12 };
|
|
14
|
+
const SATURATION = 1.6;
|
|
15
|
+
function displacementMapUri() {
|
|
16
|
+
const radius = MAP_HEIGHT / 2;
|
|
17
|
+
const inset = Math.min(MAP_WIDTH, MAP_HEIGHT) * (MAP_BORDER / 2);
|
|
18
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${MAP_WIDTH} ${MAP_HEIGHT}" width="${MAP_WIDTH}" height="${MAP_HEIGHT}">
|
|
19
|
+
<defs>
|
|
20
|
+
<linearGradient id="r" x1="100%" y1="0%" x2="0%" y2="0%"><stop offset="0%" stop-color="#000"/><stop offset="100%" stop-color="#f00"/></linearGradient>
|
|
21
|
+
<linearGradient id="b" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" stop-color="#000"/><stop offset="100%" stop-color="#00f"/></linearGradient>
|
|
22
|
+
<filter id="s"><feGaussianBlur stdDeviation="${MAP_BLUR}"/></filter>
|
|
23
|
+
</defs>
|
|
24
|
+
<rect width="${MAP_WIDTH}" height="${MAP_HEIGHT}" fill="#000"/>
|
|
25
|
+
<rect width="${MAP_WIDTH}" height="${MAP_HEIGHT}" rx="${radius}" fill="url(#r)"/>
|
|
26
|
+
<rect width="${MAP_WIDTH}" height="${MAP_HEIGHT}" rx="${radius}" fill="url(#b)" style="mix-blend-mode:difference"/>
|
|
27
|
+
<rect x="${inset}" y="${inset}" width="${MAP_WIDTH - inset * 2}" height="${MAP_HEIGHT - inset * 2}" rx="${radius - inset}" fill="hsl(0 0% 50% / 0.93)" filter="url(#s)"/>
|
|
28
|
+
</svg>`;
|
|
29
|
+
return `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
|
30
|
+
}
|
|
31
|
+
let cachedMapUri = null;
|
|
32
|
+
function getDisplacementMapUri() {
|
|
33
|
+
cachedMapUri ??= displacementMapUri();
|
|
34
|
+
return cachedMapUri;
|
|
35
|
+
}
|
|
36
|
+
let cachedSupport = null;
|
|
37
|
+
function supportsSvgBackdropFilter() {
|
|
38
|
+
if (cachedSupport !== null) {
|
|
39
|
+
return cachedSupport;
|
|
40
|
+
}
|
|
41
|
+
if (typeof window === "undefined" || typeof CSS === "undefined") {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const brands = navigator.userAgentData?.brands;
|
|
45
|
+
const isChromium = brands?.some((b) => b.brand === "Chromium") ?? false;
|
|
46
|
+
cachedSupport = isChromium && CSS.supports("backdrop-filter", "url(#bklit-glass)");
|
|
47
|
+
return cachedSupport;
|
|
48
|
+
}
|
|
49
|
+
const DATE_TICKER_GLASS_CLASS = "relative overflow-hidden rounded-full px-4 py-1 text-chart-foreground bg-chart-glass shadow-[inset_0_0_0_1px_rgb(255_255_255/0.35),inset_1.5px_2px_0_-1px_rgb(255_255_255/0.9),inset_-1.5px_-2px_0_-1px_rgb(255_255_255/0.5),inset_0_-8px_12px_-8px_rgb(255_255_255/0.4),0_6px_20px_rgb(0_0_0/0.12),0_1px_3px_rgb(0_0_0/0.1)] dark:shadow-[inset_0_0_0_1px_rgb(255_255_255/0.14),inset_1.5px_2px_0_-1px_rgb(255_255_255/0.45),inset_-1.5px_-2px_0_-1px_rgb(255_255_255/0.2),inset_0_-8px_12px_-8px_rgb(255_255_255/0.12),0_6px_20px_rgb(0_0_0/0.4)]";
|
|
50
|
+
const FALLBACK_BACKDROP = `blur(6px) saturate(${SATURATION})`;
|
|
51
|
+
function useLiquidGlass() {
|
|
52
|
+
const filterId = `bklit-glass-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
53
|
+
const svgFilter = supportsSvgBackdropFilter();
|
|
54
|
+
const backdrop = svgFilter ? `url(#${filterId}) saturate(${SATURATION})` : FALLBACK_BACKDROP;
|
|
55
|
+
return {
|
|
56
|
+
filterId,
|
|
57
|
+
svgFilter,
|
|
58
|
+
style: { backdropFilter: backdrop, WebkitBackdropFilter: backdrop }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function LiquidGlassFilter({
|
|
62
|
+
id,
|
|
63
|
+
surfaceRef
|
|
64
|
+
}) {
|
|
65
|
+
const imageRef = useRef(null);
|
|
66
|
+
useLayoutEffect(() => {
|
|
67
|
+
const surface = surfaceRef.current;
|
|
68
|
+
const image = imageRef.current;
|
|
69
|
+
if (!(surface && image)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const sync = () => {
|
|
73
|
+
image.setAttribute("width", `${surface.offsetWidth}`);
|
|
74
|
+
image.setAttribute("height", `${surface.offsetHeight}`);
|
|
75
|
+
};
|
|
76
|
+
sync();
|
|
77
|
+
if (typeof ResizeObserver === "undefined") {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const observer = new ResizeObserver(sync);
|
|
81
|
+
observer.observe(surface);
|
|
82
|
+
return () => observer.disconnect();
|
|
83
|
+
}, [surfaceRef]);
|
|
84
|
+
const channel = (key, matrix, result) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
85
|
+
/* @__PURE__ */ jsx(
|
|
86
|
+
"feDisplacementMap",
|
|
87
|
+
{
|
|
88
|
+
in: "SourceGraphic",
|
|
89
|
+
in2: "map",
|
|
90
|
+
result: `${result}-displaced`,
|
|
91
|
+
scale: DISPLACEMENT_SCALE + CHANNEL_OFFSETS[key],
|
|
92
|
+
xChannelSelector: "R",
|
|
93
|
+
yChannelSelector: "B"
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
"feColorMatrix",
|
|
98
|
+
{
|
|
99
|
+
in: `${result}-displaced`,
|
|
100
|
+
result,
|
|
101
|
+
type: "matrix",
|
|
102
|
+
values: matrix
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] });
|
|
106
|
+
return /* @__PURE__ */ jsx(
|
|
107
|
+
"svg",
|
|
108
|
+
{
|
|
109
|
+
"aria-hidden": "true",
|
|
110
|
+
className: "pointer-events-none absolute",
|
|
111
|
+
height: "0",
|
|
112
|
+
width: "0",
|
|
113
|
+
children: /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("filter", { colorInterpolationFilters: "sRGB", id, children: [
|
|
114
|
+
/* @__PURE__ */ jsx(
|
|
115
|
+
"feImage",
|
|
116
|
+
{
|
|
117
|
+
height: MAP_HEIGHT,
|
|
118
|
+
href: getDisplacementMapUri(),
|
|
119
|
+
preserveAspectRatio: "none",
|
|
120
|
+
ref: imageRef,
|
|
121
|
+
result: "map",
|
|
122
|
+
width: MAP_WIDTH,
|
|
123
|
+
x: "0",
|
|
124
|
+
y: "0"
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
channel("r", "1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0", "red"),
|
|
128
|
+
channel("g", "0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0", "green"),
|
|
129
|
+
channel("b", "0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0", "blue"),
|
|
130
|
+
/* @__PURE__ */ jsx("feBlend", { in: "red", in2: "green", mode: "screen", result: "rg" }),
|
|
131
|
+
/* @__PURE__ */ jsx("feBlend", { in: "rg", in2: "blue", mode: "screen", result: "rgb" }),
|
|
132
|
+
/* @__PURE__ */ jsx("feGaussianBlur", { in: "rgb", stdDeviation: "0.3" })
|
|
133
|
+
] }) })
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
DATE_TICKER_GLASS_CLASS,
|
|
139
|
+
LiquidGlassFilter,
|
|
140
|
+
supportsSvgBackdropFilter,
|
|
141
|
+
useLiquidGlass
|
|
142
|
+
};
|