@aiconstructions/graficos 0.0.0-stage → 0.2.2
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 +57 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +189 -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,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
10
|
+
import { cn } from "../../lib/utils";
|
|
11
|
+
import {
|
|
12
|
+
HEATMAP_DEFAULT_LEVEL_COLORS
|
|
13
|
+
} from "./heatmap-colors";
|
|
14
|
+
const HeatmapContext = createContext(null);
|
|
15
|
+
const HeatmapInteractionContext = createContext(null);
|
|
16
|
+
function HeatmapInteractionProvider({
|
|
17
|
+
children
|
|
18
|
+
}) {
|
|
19
|
+
const [hoveredCell, setHoveredCell] = useState(null);
|
|
20
|
+
const [hoveredLegendLevel, setHoveredLegendLevel] = useState(
|
|
21
|
+
null
|
|
22
|
+
);
|
|
23
|
+
const [tooltipData, setTooltipData] = useState(
|
|
24
|
+
null
|
|
25
|
+
);
|
|
26
|
+
const clearInteraction = useCallback(() => {
|
|
27
|
+
setHoveredCell(null);
|
|
28
|
+
setHoveredLegendLevel(null);
|
|
29
|
+
setTooltipData(null);
|
|
30
|
+
}, []);
|
|
31
|
+
const value = useMemo(
|
|
32
|
+
() => ({
|
|
33
|
+
hoveredCell,
|
|
34
|
+
hoveredLegendLevel,
|
|
35
|
+
tooltipData,
|
|
36
|
+
setHoveredCell,
|
|
37
|
+
setHoveredLegendLevel,
|
|
38
|
+
setTooltipData,
|
|
39
|
+
clearInteraction
|
|
40
|
+
}),
|
|
41
|
+
[clearInteraction, hoveredCell, hoveredLegendLevel, tooltipData]
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ jsx(HeatmapInteractionContext.Provider, { value, children });
|
|
44
|
+
}
|
|
45
|
+
function HeatmapProvider({
|
|
46
|
+
children,
|
|
47
|
+
value
|
|
48
|
+
}) {
|
|
49
|
+
return /* @__PURE__ */ jsx(HeatmapContext.Provider, { value, children });
|
|
50
|
+
}
|
|
51
|
+
function useHeatmap() {
|
|
52
|
+
const context = useContext(HeatmapContext);
|
|
53
|
+
if (!context) {
|
|
54
|
+
throw new Error("useHeatmap must be used within a HeatmapProvider");
|
|
55
|
+
}
|
|
56
|
+
return context;
|
|
57
|
+
}
|
|
58
|
+
function useHeatmapInteraction() {
|
|
59
|
+
const context = useContext(HeatmapInteractionContext);
|
|
60
|
+
if (!context) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
"useHeatmapInteraction must be used within a HeatmapInteractionProvider"
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return context;
|
|
66
|
+
}
|
|
67
|
+
function useHeatmapInteractionOptional() {
|
|
68
|
+
return useContext(HeatmapInteractionContext);
|
|
69
|
+
}
|
|
70
|
+
function HeatmapInteractionBoundary({
|
|
71
|
+
children,
|
|
72
|
+
className
|
|
73
|
+
}) {
|
|
74
|
+
const { clearInteraction } = useHeatmapInteraction();
|
|
75
|
+
return /* @__PURE__ */ jsx(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: cn("size-full min-h-0 min-w-0", className),
|
|
79
|
+
onPointerLeave: clearInteraction,
|
|
80
|
+
children
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function HeatmapInteractionRoot({ children }) {
|
|
85
|
+
const existing = useContext(HeatmapInteractionContext);
|
|
86
|
+
if (existing) {
|
|
87
|
+
return children;
|
|
88
|
+
}
|
|
89
|
+
return /* @__PURE__ */ jsx(HeatmapInteractionProvider, { children });
|
|
90
|
+
}
|
|
91
|
+
const heatmapCssVars = {
|
|
92
|
+
empty: HEATMAP_DEFAULT_LEVEL_COLORS[0],
|
|
93
|
+
level1: HEATMAP_DEFAULT_LEVEL_COLORS[1],
|
|
94
|
+
level2: HEATMAP_DEFAULT_LEVEL_COLORS[2],
|
|
95
|
+
level3: HEATMAP_DEFAULT_LEVEL_COLORS[3],
|
|
96
|
+
level4: HEATMAP_DEFAULT_LEVEL_COLORS[4]
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
HeatmapInteractionBoundary,
|
|
100
|
+
HeatmapInteractionProvider,
|
|
101
|
+
HeatmapInteractionRoot,
|
|
102
|
+
HeatmapProvider,
|
|
103
|
+
heatmapCssVars,
|
|
104
|
+
useHeatmap,
|
|
105
|
+
useHeatmapInteraction,
|
|
106
|
+
useHeatmapInteractionOptional
|
|
107
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { m } from "motion/react";
|
|
4
|
+
import { memo } from "react";
|
|
5
|
+
import {
|
|
6
|
+
buildHeatmapLegendGradient,
|
|
7
|
+
resolveHeatmapHoverStyle
|
|
8
|
+
} from "./heatmap-utils";
|
|
9
|
+
const HEATMAP_INACTIVE_TRANSITION = {
|
|
10
|
+
duration: 0.22,
|
|
11
|
+
ease: [0.4, 0, 0.2, 1]
|
|
12
|
+
};
|
|
13
|
+
const HeatmapLegendGradient = memo(function HeatmapLegendGradient2({
|
|
14
|
+
levels,
|
|
15
|
+
levelStyles,
|
|
16
|
+
cellSize,
|
|
17
|
+
gap,
|
|
18
|
+
cornerRadius,
|
|
19
|
+
gradientSpan,
|
|
20
|
+
highlightedLevel,
|
|
21
|
+
isDimming,
|
|
22
|
+
inactiveOpacity,
|
|
23
|
+
inactiveScale,
|
|
24
|
+
activeScale,
|
|
25
|
+
isInteractive,
|
|
26
|
+
onEnter,
|
|
27
|
+
onLeave
|
|
28
|
+
}) {
|
|
29
|
+
const barWidth = gradientSpan * cellSize + (gradientSpan - 1) * gap;
|
|
30
|
+
const barHeight = cellSize;
|
|
31
|
+
const pillRadius = Math.min(cornerRadius, barHeight / 2);
|
|
32
|
+
const segmentWidth = barWidth / levels.length;
|
|
33
|
+
const gradient = buildHeatmapLegendGradient(levelStyles);
|
|
34
|
+
return /* @__PURE__ */ jsxs(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
className: "relative shrink-0",
|
|
38
|
+
style: { width: barWidth, height: barHeight },
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
m.div,
|
|
42
|
+
{
|
|
43
|
+
animate: {
|
|
44
|
+
opacity: isDimming && highlightedLevel === null ? inactiveOpacity : 1,
|
|
45
|
+
scale: 1
|
|
46
|
+
},
|
|
47
|
+
"aria-hidden": "true",
|
|
48
|
+
className: "absolute inset-0",
|
|
49
|
+
initial: { opacity: 1, scale: 1 },
|
|
50
|
+
style: {
|
|
51
|
+
borderRadius: pillRadius,
|
|
52
|
+
background: gradient
|
|
53
|
+
},
|
|
54
|
+
transition: HEATMAP_INACTIVE_TRANSITION
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
levels.map((level, index) => {
|
|
58
|
+
const isHighlighted = highlightedLevel === level;
|
|
59
|
+
const isDimmed = isDimming && !isHighlighted;
|
|
60
|
+
const hoverStyle = resolveHeatmapHoverStyle(isHighlighted, isDimmed, {
|
|
61
|
+
inactiveOpacity,
|
|
62
|
+
inactiveScale,
|
|
63
|
+
activeScale
|
|
64
|
+
});
|
|
65
|
+
return /* @__PURE__ */ jsx(
|
|
66
|
+
m.span,
|
|
67
|
+
{
|
|
68
|
+
animate: {
|
|
69
|
+
opacity: hoverStyle.opacity,
|
|
70
|
+
scale: hoverStyle.scale
|
|
71
|
+
},
|
|
72
|
+
className: "absolute top-0 block",
|
|
73
|
+
initial: { opacity: 1, scale: 1 },
|
|
74
|
+
onPointerEnter: () => onEnter(level),
|
|
75
|
+
onPointerLeave: onLeave,
|
|
76
|
+
style: {
|
|
77
|
+
left: index * segmentWidth,
|
|
78
|
+
width: segmentWidth,
|
|
79
|
+
height: barHeight,
|
|
80
|
+
cursor: isInteractive ? "pointer" : void 0,
|
|
81
|
+
transformOrigin: "center center"
|
|
82
|
+
},
|
|
83
|
+
transition: HEATMAP_INACTIVE_TRANSITION
|
|
84
|
+
},
|
|
85
|
+
level
|
|
86
|
+
);
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
HeatmapLegendGradient.displayName = "HeatmapLegendGradient";
|
|
93
|
+
var heatmap_legend_gradient_default = HeatmapLegendGradient;
|
|
94
|
+
export {
|
|
95
|
+
HeatmapLegendGradient,
|
|
96
|
+
heatmap_legend_gradient_default as default
|
|
97
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo } from "react";
|
|
4
|
+
import { renderPatternPreset } from "../pattern-preset";
|
|
5
|
+
import {
|
|
6
|
+
heatmapLevelPatternId,
|
|
7
|
+
heatmapLevelPatternRenderOptions,
|
|
8
|
+
isHeatmapLevelPattern
|
|
9
|
+
} from "./heatmap-colors";
|
|
10
|
+
const HeatmapLegendSwatch = memo(function HeatmapLegendSwatch2({
|
|
11
|
+
level,
|
|
12
|
+
style,
|
|
13
|
+
cellSize,
|
|
14
|
+
cornerRadius
|
|
15
|
+
}) {
|
|
16
|
+
const shellStyle = {
|
|
17
|
+
width: cellSize,
|
|
18
|
+
height: cellSize,
|
|
19
|
+
borderRadius: cornerRadius
|
|
20
|
+
};
|
|
21
|
+
if (isHeatmapLevelPattern(style) && style.pattern) {
|
|
22
|
+
const patternId = heatmapLevelPatternId(level);
|
|
23
|
+
const patternNode = renderPatternPreset(
|
|
24
|
+
style.pattern,
|
|
25
|
+
patternId,
|
|
26
|
+
heatmapLevelPatternRenderOptions(style)
|
|
27
|
+
);
|
|
28
|
+
const opacity = style.patternOpacity ?? 1;
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
"span",
|
|
31
|
+
{
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
className: "block shrink-0 overflow-hidden",
|
|
34
|
+
style: { ...shellStyle, opacity },
|
|
35
|
+
children: /* @__PURE__ */ jsxs(
|
|
36
|
+
"svg",
|
|
37
|
+
{
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
className: "block size-full",
|
|
40
|
+
viewBox: `0 0 ${cellSize} ${cellSize}`,
|
|
41
|
+
children: [
|
|
42
|
+
patternNode ? /* @__PURE__ */ jsx("defs", { children: patternNode }) : null,
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
"rect",
|
|
45
|
+
{
|
|
46
|
+
fill: patternNode ? `url(#${patternId})` : style.color,
|
|
47
|
+
height: cellSize,
|
|
48
|
+
rx: cornerRadius,
|
|
49
|
+
ry: cornerRadius,
|
|
50
|
+
width: cellSize
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
"aria-hidden": "true",
|
|
63
|
+
className: "block shrink-0",
|
|
64
|
+
style: {
|
|
65
|
+
...shellStyle,
|
|
66
|
+
backgroundColor: style.color,
|
|
67
|
+
border: level === 0 ? `1px solid ${style.color}` : void 0,
|
|
68
|
+
boxSizing: "border-box"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
HeatmapLegendSwatch.displayName = "HeatmapLegendSwatch";
|
|
74
|
+
export {
|
|
75
|
+
HeatmapLegendSwatch
|
|
76
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { domAnimation, LazyMotion, m } from "motion/react";
|
|
4
|
+
import { memo, useCallback } from "react";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
import {
|
|
7
|
+
defaultHeatmapColorScale
|
|
8
|
+
} from "./heatmap-colors";
|
|
9
|
+
import { useHeatmapInteractionOptional } from "./heatmap-context";
|
|
10
|
+
import { HeatmapLegendGradient } from "./heatmap-legend-gradient";
|
|
11
|
+
import { HeatmapLegendSwatch } from "./heatmap-legend-swatch";
|
|
12
|
+
import {
|
|
13
|
+
getHeatmapContributionLevel,
|
|
14
|
+
isHeatmapHoverEffectEnabled,
|
|
15
|
+
resolveHeatmapHoverStyle
|
|
16
|
+
} from "./heatmap-utils";
|
|
17
|
+
const HEATMAP_LEGEND_LEVELS = [0, 1, 2, 3, 4];
|
|
18
|
+
const HEATMAP_INACTIVE_OPACITY = 0.3;
|
|
19
|
+
const HEATMAP_INACTIVE_TRANSITION = {
|
|
20
|
+
duration: 0.22,
|
|
21
|
+
ease: [0.4, 0, 0.2, 1]
|
|
22
|
+
};
|
|
23
|
+
const HeatmapLegend = memo(function HeatmapLegend2({
|
|
24
|
+
lessLabel = "Menos",
|
|
25
|
+
moreLabel = "Mais",
|
|
26
|
+
cellSize = 11,
|
|
27
|
+
gap = 2,
|
|
28
|
+
cornerRadius = 2,
|
|
29
|
+
align = "end",
|
|
30
|
+
variant = "swatches",
|
|
31
|
+
gradientSpan = 5,
|
|
32
|
+
fontSize,
|
|
33
|
+
labelClassName,
|
|
34
|
+
levelStyles: levelStylesProp,
|
|
35
|
+
colorScale = defaultHeatmapColorScale,
|
|
36
|
+
inactiveOpacity = HEATMAP_INACTIVE_OPACITY,
|
|
37
|
+
inactiveScale = 1,
|
|
38
|
+
activeScale = 1,
|
|
39
|
+
interactive,
|
|
40
|
+
className
|
|
41
|
+
}) {
|
|
42
|
+
const interaction = useHeatmapInteractionOptional();
|
|
43
|
+
const isInteractive = interactive ?? interaction != null;
|
|
44
|
+
const levelStyles = levelStylesProp ?? HEATMAP_LEGEND_LEVELS.map((level) => ({
|
|
45
|
+
color: colorScale(level),
|
|
46
|
+
fillMode: "solid",
|
|
47
|
+
pattern: "none"
|
|
48
|
+
}));
|
|
49
|
+
const {
|
|
50
|
+
hoveredLegendLevel,
|
|
51
|
+
tooltipData,
|
|
52
|
+
setHoveredCell,
|
|
53
|
+
setHoveredLegendLevel,
|
|
54
|
+
setTooltipData
|
|
55
|
+
} = interaction ?? {
|
|
56
|
+
hoveredLegendLevel: null,
|
|
57
|
+
tooltipData: null,
|
|
58
|
+
setHoveredCell: () => void 0,
|
|
59
|
+
setHoveredLegendLevel: () => void 0,
|
|
60
|
+
setTooltipData: () => void 0
|
|
61
|
+
};
|
|
62
|
+
const highlightedLevel = hoveredLegendLevel ?? (tooltipData ? getHeatmapContributionLevel(tooltipData.count) : null);
|
|
63
|
+
const hoverParams = { inactiveOpacity, inactiveScale, activeScale };
|
|
64
|
+
const inactiveEnabled = isHeatmapHoverEffectEnabled(hoverParams);
|
|
65
|
+
const isDimming = isInteractive && highlightedLevel !== null && inactiveEnabled;
|
|
66
|
+
const handleLegendEnter = useCallback(
|
|
67
|
+
(level) => {
|
|
68
|
+
if (!isInteractive) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
setHoveredLegendLevel(level);
|
|
72
|
+
setHoveredCell(null);
|
|
73
|
+
setTooltipData(null);
|
|
74
|
+
},
|
|
75
|
+
[isInteractive, setHoveredCell, setHoveredLegendLevel, setTooltipData]
|
|
76
|
+
);
|
|
77
|
+
const handleLegendLeave = useCallback(() => {
|
|
78
|
+
if (!isInteractive) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setHoveredLegendLevel(null);
|
|
82
|
+
}, [isInteractive, setHoveredLegendLevel]);
|
|
83
|
+
const labelStyle = fontSize == null ? void 0 : { fontSize };
|
|
84
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsxs(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: cn(
|
|
88
|
+
"flex w-full items-center gap-1.5 text-chart-label text-xs",
|
|
89
|
+
align === "start" && "justify-start",
|
|
90
|
+
align === "center" && "justify-center",
|
|
91
|
+
align === "end" && "justify-end",
|
|
92
|
+
className
|
|
93
|
+
),
|
|
94
|
+
"data-chart-legend": "",
|
|
95
|
+
style: labelStyle,
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsx("span", { className: labelClassName, children: lessLabel }),
|
|
98
|
+
variant === "gradient" ? /* @__PURE__ */ jsx(
|
|
99
|
+
HeatmapLegendGradient,
|
|
100
|
+
{
|
|
101
|
+
activeScale,
|
|
102
|
+
cellSize,
|
|
103
|
+
cornerRadius,
|
|
104
|
+
gap,
|
|
105
|
+
gradientSpan,
|
|
106
|
+
highlightedLevel,
|
|
107
|
+
inactiveOpacity,
|
|
108
|
+
inactiveScale,
|
|
109
|
+
isDimming,
|
|
110
|
+
isInteractive,
|
|
111
|
+
levelStyles,
|
|
112
|
+
levels: HEATMAP_LEGEND_LEVELS,
|
|
113
|
+
onEnter: handleLegendEnter,
|
|
114
|
+
onLeave: handleLegendLeave
|
|
115
|
+
}
|
|
116
|
+
) : /* @__PURE__ */ jsx("div", { className: "flex items-center", style: { gap }, children: HEATMAP_LEGEND_LEVELS.map((level) => {
|
|
117
|
+
const isHighlighted = highlightedLevel === level;
|
|
118
|
+
const isDimmed = isDimming && !isHighlighted;
|
|
119
|
+
const hoverStyle = resolveHeatmapHoverStyle(
|
|
120
|
+
isHighlighted,
|
|
121
|
+
isDimmed,
|
|
122
|
+
hoverParams
|
|
123
|
+
);
|
|
124
|
+
const style = levelStyles[level];
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
m.span,
|
|
127
|
+
{
|
|
128
|
+
animate: {
|
|
129
|
+
opacity: hoverStyle.opacity,
|
|
130
|
+
scale: hoverStyle.scale
|
|
131
|
+
},
|
|
132
|
+
"aria-hidden": "true",
|
|
133
|
+
className: "block shrink-0 leading-none",
|
|
134
|
+
initial: { opacity: 1, scale: 1 },
|
|
135
|
+
onPointerEnter: () => handleLegendEnter(level),
|
|
136
|
+
onPointerLeave: handleLegendLeave,
|
|
137
|
+
style: {
|
|
138
|
+
cursor: isInteractive ? "pointer" : void 0
|
|
139
|
+
},
|
|
140
|
+
transition: HEATMAP_INACTIVE_TRANSITION,
|
|
141
|
+
children: /* @__PURE__ */ jsx(
|
|
142
|
+
HeatmapLegendSwatch,
|
|
143
|
+
{
|
|
144
|
+
cellSize,
|
|
145
|
+
cornerRadius,
|
|
146
|
+
level,
|
|
147
|
+
style
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
},
|
|
151
|
+
level
|
|
152
|
+
);
|
|
153
|
+
}) }),
|
|
154
|
+
/* @__PURE__ */ jsx("span", { className: labelClassName, children: moreLabel })
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
) });
|
|
158
|
+
});
|
|
159
|
+
HeatmapLegend.displayName = "HeatmapLegend";
|
|
160
|
+
var heatmap_legend_default = HeatmapLegend;
|
|
161
|
+
export {
|
|
162
|
+
HEATMAP_LEGEND_LEVELS,
|
|
163
|
+
HeatmapLegend,
|
|
164
|
+
heatmap_legend_default as default
|
|
165
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, memo } from "react";
|
|
4
|
+
import { renderPatternPreset } from "../pattern-preset";
|
|
5
|
+
import {
|
|
6
|
+
heatmapLevelPatternId,
|
|
7
|
+
heatmapLevelPatternRenderOptions,
|
|
8
|
+
isHeatmapLevelPattern
|
|
9
|
+
} from "./heatmap-colors";
|
|
10
|
+
const HeatmapPatternDefs = memo(function HeatmapPatternDefs2({
|
|
11
|
+
levelStyles
|
|
12
|
+
}) {
|
|
13
|
+
const nodes = levelStyles.flatMap((style, level) => {
|
|
14
|
+
if (!isHeatmapLevelPattern(style)) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const id = heatmapLevelPatternId(level);
|
|
18
|
+
const pattern = style.pattern;
|
|
19
|
+
if (!pattern) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const node = renderPatternPreset(
|
|
23
|
+
pattern,
|
|
24
|
+
id,
|
|
25
|
+
heatmapLevelPatternRenderOptions(style)
|
|
26
|
+
);
|
|
27
|
+
return node ? [/* @__PURE__ */ jsx(Fragment, { children: node }, id)] : [];
|
|
28
|
+
});
|
|
29
|
+
if (nodes.length === 0) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return /* @__PURE__ */ jsx("defs", { children: nodes });
|
|
33
|
+
});
|
|
34
|
+
HeatmapPatternDefs.displayName = "HeatmapPatternDefs";
|
|
35
|
+
export {
|
|
36
|
+
HeatmapPatternDefs
|
|
37
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function heatmapRectCells({
|
|
2
|
+
data = [],
|
|
3
|
+
bins,
|
|
4
|
+
count,
|
|
5
|
+
binWidth = 6,
|
|
6
|
+
binHeight = 6,
|
|
7
|
+
x0 = 0,
|
|
8
|
+
gap = 1,
|
|
9
|
+
xScale,
|
|
10
|
+
yScale,
|
|
11
|
+
colorScale = () => void 0,
|
|
12
|
+
opacityScale = () => 1
|
|
13
|
+
}) {
|
|
14
|
+
const width = binWidth - gap;
|
|
15
|
+
const height = binHeight - gap;
|
|
16
|
+
return data.map((datum, column) => {
|
|
17
|
+
const x = xScale(column);
|
|
18
|
+
return bins(datum).map((bin, row) => {
|
|
19
|
+
const countValue = count(bin);
|
|
20
|
+
return {
|
|
21
|
+
bin,
|
|
22
|
+
row,
|
|
23
|
+
column,
|
|
24
|
+
datum,
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
gap,
|
|
28
|
+
count: countValue,
|
|
29
|
+
x: x + x0,
|
|
30
|
+
y: yScale(row) + gap,
|
|
31
|
+
color: colorScale(countValue),
|
|
32
|
+
opacity: opacityScale(countValue)
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
heatmapRectCells
|
|
39
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Children, isValidElement } from "react";
|
|
2
|
+
import { resolveChartChildElement } from "../chart-child-passthrough";
|
|
3
|
+
import {
|
|
4
|
+
HEATMAP_SEPARATOR_MARKER,
|
|
5
|
+
HeatmapSeparator
|
|
6
|
+
} from "./heatmap-separator";
|
|
7
|
+
import { resolveHeatmapSeparatorLayout } from "./heatmap-utils";
|
|
8
|
+
function getChildComponentName(child) {
|
|
9
|
+
const childType = child.type;
|
|
10
|
+
return typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
|
|
11
|
+
}
|
|
12
|
+
function isHeatmapSeparatorElement(child) {
|
|
13
|
+
const resolved = resolveChartChildElement(child);
|
|
14
|
+
const type = resolved.type;
|
|
15
|
+
return resolved.type === HeatmapSeparator || type[HEATMAP_SEPARATOR_MARKER] === true || getChildComponentName(resolved) === "HeatmapSeparator";
|
|
16
|
+
}
|
|
17
|
+
function readHeatmapSeparatorConfig(child) {
|
|
18
|
+
const props = resolveChartChildElement(child).props;
|
|
19
|
+
const groupBy = props.groupBy ?? "every";
|
|
20
|
+
if (groupBy === "quarter") {
|
|
21
|
+
return {
|
|
22
|
+
groupBy: "quarter",
|
|
23
|
+
spacing: props.spacing ?? 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (props.every == null || props.every <= 0) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
groupBy: "every",
|
|
31
|
+
every: props.every,
|
|
32
|
+
spacing: props.spacing ?? 0
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function resolveHeatmapSeparatorConfig(children, chartSeparators) {
|
|
36
|
+
let config = null;
|
|
37
|
+
const visit = (node) => {
|
|
38
|
+
if (config) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
Children.forEach(node, (child) => {
|
|
42
|
+
if (config || !isValidElement(child)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (isHeatmapSeparatorElement(child)) {
|
|
46
|
+
config = readHeatmapSeparatorConfig(child);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const childProps = child.props;
|
|
50
|
+
if (childProps?.children) {
|
|
51
|
+
visit(childProps.children);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
visit(children);
|
|
56
|
+
return config ?? normalizeHeatmapSeparatorConfig(chartSeparators);
|
|
57
|
+
}
|
|
58
|
+
function normalizeHeatmapSeparatorConfig(config) {
|
|
59
|
+
if (!config) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (config.groupBy === "quarter") {
|
|
63
|
+
return {
|
|
64
|
+
groupBy: "quarter",
|
|
65
|
+
spacing: config.spacing ?? 0
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (!config.every || config.every <= 0) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
groupBy: "every",
|
|
73
|
+
every: config.every,
|
|
74
|
+
spacing: config.spacing ?? 0
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function resolveHeatmapSeparatorConfigWithData(children, columns, chartSeparators) {
|
|
78
|
+
const config = resolveHeatmapSeparatorConfig(children, chartSeparators);
|
|
79
|
+
return resolveHeatmapSeparatorLayout(config, columns);
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
resolveHeatmapSeparatorConfig,
|
|
83
|
+
resolveHeatmapSeparatorConfigWithData
|
|
84
|
+
};
|