@patterninc/pattern-ui 0.0.0-main.202610070652.6ff70dca923d → 0.0.0-main.202610070722.e4b4a045849e

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 (53) hide show
  1. package/dist/components/Charts/area/index.js +4 -1
  2. package/dist/components/Charts/area-chart.js +123 -125
  3. package/dist/components/Charts/background.js +280 -0
  4. package/dist/components/Charts/bar/index.js +6 -3
  5. package/dist/components/Charts/bar-chart.js +71 -74
  6. package/dist/components/Charts/bar-squares.js +1 -1
  7. package/dist/components/Charts/bar-x-axis.js +64 -62
  8. package/dist/components/Charts/bar-y-axis.js +73 -71
  9. package/dist/components/Charts/candlestick/index.js +4 -1
  10. package/dist/components/Charts/chart-context.js +54 -52
  11. package/dist/components/Charts/chart-density.js +83 -0
  12. package/dist/components/Charts/composed/index.js +4 -1
  13. package/dist/components/Charts/composed-chart.js +101 -103
  14. package/dist/components/Charts/core/index.js +4 -1
  15. package/dist/components/Charts/grid.js +139 -156
  16. package/dist/components/Charts/line/index.js +4 -1
  17. package/dist/components/Charts/line-chart.js +149 -151
  18. package/dist/components/Charts/live/index.js +4 -1
  19. package/dist/components/Charts/pie/index.js +2 -1
  20. package/dist/components/Charts/pie-chart.js +11 -4
  21. package/dist/components/Charts/pie-slice.js +258 -178
  22. package/dist/components/Charts/primitives/Background/index.js +3 -0
  23. package/dist/components/Charts/primitives/ReferenceArea/index.js +3 -0
  24. package/dist/components/Charts/reference-area.js +370 -0
  25. package/dist/components/Charts/scatter/index.js +4 -1
  26. package/dist/components/Charts/time-series-chart-shell.js +223 -219
  27. package/dist/components/Charts/x-axis.js +72 -70
  28. package/dist/components/Charts/y-axis.js +89 -123
  29. package/dist/hooks/useFocusState/useFocusState.js +4 -2
  30. package/dist/hooks/useToggle/useToggle.js +2 -2
  31. package/package.json +1 -1
  32. package/src/components/Charts/area-chart.tsx +12 -3
  33. package/src/components/Charts/background.tsx +180 -0
  34. package/src/components/Charts/bar-chart.tsx +12 -3
  35. package/src/components/Charts/bar-x-axis.tsx +6 -3
  36. package/src/components/Charts/bar-y-axis.tsx +11 -5
  37. package/src/components/Charts/chart-context.tsx +5 -0
  38. package/src/components/Charts/chart-density.ts +91 -0
  39. package/src/components/Charts/composed-chart.tsx +12 -3
  40. package/src/components/Charts/core/index.ts +15 -0
  41. package/src/components/Charts/grid.tsx +9 -5
  42. package/src/components/Charts/line-chart.tsx +12 -3
  43. package/src/components/Charts/pie/index.ts +6 -0
  44. package/src/components/Charts/pie-chart.tsx +32 -7
  45. package/src/components/Charts/pie-slice.tsx +90 -8
  46. package/src/components/Charts/primitives/Background/index.ts +2 -0
  47. package/src/components/Charts/primitives/ReferenceArea/index.ts +6 -0
  48. package/src/components/Charts/reference-area.tsx +246 -0
  49. package/src/components/Charts/time-series-chart-shell.tsx +4 -0
  50. package/src/components/Charts/x-axis.tsx +8 -3
  51. package/src/components/Charts/y-axis.tsx +7 -8
  52. package/src/hooks/useFocusState/useFocusState.tsx +7 -3
  53. package/src/hooks/useToggle/useToggle.tsx +1 -1
@@ -7,6 +7,7 @@ import { ChartLegendHoverProvider, useChartLegendHover } from "../chart-legend-h
7
7
  import { SeriesPointMarker, getSeriesMarkerVisualExtent } from "../series-point-marker.js";
8
8
  import { SeriesMarkers } from "../series-markers.js";
9
9
  import { Area } from "../area-series.js";
10
+ import { CHART_DENSITY, CHART_DENSITY_IDS, DEFAULT_CHART_DENSITY, resolveChartMargin, resolveDensityMaxLabels, resolveDensityTickCount } from "../chart-density.js";
10
11
  import { ChartLoadingLabel } from "../chart-loading-label.js";
11
12
  import { DEFAULT_CHART_LIFECYCLE, DEFAULT_CHART_STATUS, DEFAULT_Y_DOMAIN_TWEEN_MS, isChartInteractionPhase, resolveRestingChartPhase } from "../chart-phase.js";
12
13
  import { PatternArea } from "../pattern-area.js";
@@ -25,9 +26,11 @@ import { AreaChartLoading } from "../area-chart-loading.js";
25
26
  import { measureMaxLabelWidthPx, resolveYAxisMarginPx } from "../axis-tick-fit.js";
26
27
  import { PatternCircles, PatternHexagons, PatternLines, PatternWaves } from "../visx-pattern.js";
27
28
  import { PATTERN_PRESET_IDS, isCirclePattern, isCirclesPattern, patternPresetTileSize, renderPatternPreset } from "../pattern-preset.js";
29
+ import { Background } from "../background.js";
28
30
  import { indicatorFadeGradientStops, resolveVerticalFadeSides } from "../indicator-fade.js";
29
31
  import { ProjectionLineEndMarker } from "../projection-line-end-marker.js";
30
32
  import { ProjectionLine } from "../projection-line.js";
33
+ import { ReferenceArea } from "../reference-area.js";
31
34
  import { XAxis } from "../x-axis.js";
32
35
  import { Y_AXIS_DEFAULT_TICK_COUNT, Y_AXIS_MAX_TICK_COUNT, Y_AXIS_MIN_TICK_COUNT, resolveYAxisTickCount } from "../y-axis-ticks.js";
33
36
  import { YAxis } from "../y-axis.js";
@@ -40,4 +43,4 @@ import { TooltipDot } from "../tooltip/tooltip-dot.js";
40
43
  import { TooltipIndicator } from "../tooltip/tooltip-indicator.js";
41
44
  import { ChartTooltip } from "../tooltip/chart-tooltip.js";
42
45
 
43
- export { Area, AreaChart, AreaChartLoading, BarLoadingSkeleton, CHART_CLIP_PASSTHROUGH, ChartConfigProvider, ChartLegendHoverProvider, ChartLoadingLabel, ChartMarkers, ChartProvider, ChartRevealClip, ChartTooltip, DEFAULT_ANIMATION_DURATION_MS, DEFAULT_ANIMATION_EASING, DEFAULT_CHART_CONFIG, DEFAULT_CHART_ENTER_TRANSITION, DEFAULT_CHART_LIFECYCLE, DEFAULT_CHART_STATUS, DEFAULT_Y_AXIS_ID, DEFAULT_Y_DOMAIN_TWEEN_MS, DateTicker, Grid, LineLoadingSweep, MarkerGroup, MarkerTooltipContent, PATTERN_PRESET_IDS, PatternArea, PatternCircles, PatternHexagons, PatternLines, PatternWaves, ProjectionLine, ProjectionLineEndMarker, SeriesMarkers, SeriesPointMarker, StaticChartPreviewProvider, TooltipBox, TooltipContent, TooltipDot, TooltipIndicator, XAxis, YAxis, Y_AXIS_DEFAULT_TICK_COUNT, Y_AXIS_MAX_TICK_COUNT, Y_AXIS_MIN_TICK_COUNT, buildHorizontalTangentBezierPath, buildProjectionPath, chartCssVars, clampHoverIndexToMaxTime, clampPixelXToProjectionHoverMax, computeProjectionAnchorTangentSlope, computeYDomainsByAxis, defaultScatterColors, extractProjectionLineConfigs, generateChartSkeletonData, getPrimaryYScale, getSeriesMarkerVisualExtent, getSkeletonHeights, indicatorFadeGradientStops, isChartInteractionPhase, isCirclePattern, isCirclesPattern, isLoadingChromePhase, isYDomainTweenPhase, measureMaxLabelWidthPx, mergeProjectionXDomainMax, mergeProjectionYDomain, mergeYDomainRecords, niceYDomain, patternPresetTileSize, projectionDateExtents, projectionHoverMaxBySeries, projectionHoverMaxTime, projectionPinnedOverlayX, projectionValueExtents, renderPatternPreset, resolveRestingChartPhase, resolveTooltipBoxMotion, resolveVerticalFadeSides, resolveYAxisMarginPx, resolveYAxisTickCount, shouldTweenYDomain, useActiveMarkers, useAnimatedYDomains, useChart, useChartConfig, useChartHover, useChartInteraction, useChartLegendHover, useChartStable, useStaticChartPreview, useYScale };
46
+ export { Area, AreaChart, AreaChartLoading, Background, BarLoadingSkeleton, CHART_CLIP_PASSTHROUGH, CHART_DENSITY, CHART_DENSITY_IDS, ChartConfigProvider, ChartLegendHoverProvider, ChartLoadingLabel, ChartMarkers, ChartProvider, ChartRevealClip, ChartTooltip, DEFAULT_ANIMATION_DURATION_MS, DEFAULT_ANIMATION_EASING, DEFAULT_CHART_CONFIG, DEFAULT_CHART_DENSITY, DEFAULT_CHART_ENTER_TRANSITION, DEFAULT_CHART_LIFECYCLE, DEFAULT_CHART_STATUS, DEFAULT_Y_AXIS_ID, DEFAULT_Y_DOMAIN_TWEEN_MS, DateTicker, Grid, LineLoadingSweep, MarkerGroup, MarkerTooltipContent, PATTERN_PRESET_IDS, PatternArea, PatternCircles, PatternHexagons, PatternLines, PatternWaves, ProjectionLine, ProjectionLineEndMarker, ReferenceArea, SeriesMarkers, SeriesPointMarker, StaticChartPreviewProvider, TooltipBox, TooltipContent, TooltipDot, TooltipIndicator, XAxis, YAxis, Y_AXIS_DEFAULT_TICK_COUNT, Y_AXIS_MAX_TICK_COUNT, Y_AXIS_MIN_TICK_COUNT, buildHorizontalTangentBezierPath, buildProjectionPath, chartCssVars, clampHoverIndexToMaxTime, clampPixelXToProjectionHoverMax, computeProjectionAnchorTangentSlope, computeYDomainsByAxis, defaultScatterColors, extractProjectionLineConfigs, generateChartSkeletonData, getPrimaryYScale, getSeriesMarkerVisualExtent, getSkeletonHeights, indicatorFadeGradientStops, isChartInteractionPhase, isCirclePattern, isCirclesPattern, isLoadingChromePhase, isYDomainTweenPhase, measureMaxLabelWidthPx, mergeProjectionXDomainMax, mergeProjectionYDomain, mergeYDomainRecords, niceYDomain, patternPresetTileSize, projectionDateExtents, projectionHoverMaxBySeries, projectionHoverMaxTime, projectionPinnedOverlayX, projectionValueExtents, renderPatternPreset, resolveChartMargin, resolveDensityMaxLabels, resolveDensityTickCount, resolveRestingChartPhase, resolveTooltipBoxMotion, resolveVerticalFadeSides, resolveYAxisMarginPx, resolveYAxisTickCount, shouldTweenYDomain, useActiveMarkers, useAnimatedYDomains, useChart, useChartConfig, useChartHover, useChartInteraction, useChartLegendHover, useChartStable, useStaticChartPreview, useYScale };
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { Area } from "./area-series.js";
4
+ import { DEFAULT_CHART_DENSITY, resolveChartMargin } from "./chart-density.js";
4
5
  import { ChartLoadingLabel } from "./chart-loading-label.js";
5
6
  import { DEFAULT_CHART_STATUS, DEFAULT_Y_DOMAIN_TWEEN_MS, resolveRestingChartPhase } from "./chart-phase.js";
6
7
  import { PatternArea } from "./pattern-area.js";
@@ -12,12 +13,6 @@ import { cn } from "cn";
12
13
  import { ParentSize } from "@visx/responsive";
13
14
 
14
15
  //#region src/components/Charts/area-chart.tsx
15
- const DEFAULT_MARGIN = {
16
- top: 40,
17
- right: 40,
18
- bottom: 40,
19
- left: 40
20
- };
21
16
  function extractAreaConfigs(children) {
22
17
  const configs = [];
23
18
  Children.forEach(children, (child) => {
@@ -36,8 +31,8 @@ function extractAreaConfigs(children) {
36
31
  return configs;
37
32
  }
38
33
  function ChartInner(t0) {
39
- const $ = c(24);
40
- const { width, height, data, xDataKey, margin, animationDuration, animationEasing, enterTransition, revealSignature, chartStatus, loadingLabel, yDomainTweenDuration, yDomainTween, xDomain, xDomainSlotCount, tweenYDomainOnXDomainChange, children, containerRef, onPhaseChange, clipPathId } = t0;
34
+ const $ = c(25);
35
+ const { width, height, data, xDataKey, margin, density, animationDuration, animationEasing, enterTransition, revealSignature, chartStatus, loadingLabel, yDomainTweenDuration, yDomainTween, xDomain, xDomainSlotCount, tweenYDomainOnXDomainChange, children, containerRef, onPhaseChange, clipPathId } = t0;
41
36
  let t1;
42
37
  if ($[0] !== children) {
43
38
  t1 = extractAreaConfigs(children);
@@ -46,7 +41,7 @@ function ChartInner(t0) {
46
41
  } else t1 = $[1];
47
42
  const lines = t1;
48
43
  let t2;
49
- if ($[2] !== animationDuration || $[3] !== animationEasing || $[4] !== chartStatus || $[5] !== children || $[6] !== clipPathId || $[7] !== containerRef || $[8] !== data || $[9] !== enterTransition || $[10] !== height || $[11] !== lines || $[12] !== loadingLabel || $[13] !== margin || $[14] !== onPhaseChange || $[15] !== revealSignature || $[16] !== tweenYDomainOnXDomainChange || $[17] !== width || $[18] !== xDataKey || $[19] !== xDomain || $[20] !== xDomainSlotCount || $[21] !== yDomainTween || $[22] !== yDomainTweenDuration) {
44
+ if ($[2] !== animationDuration || $[3] !== animationEasing || $[4] !== chartStatus || $[5] !== children || $[6] !== clipPathId || $[7] !== containerRef || $[8] !== data || $[9] !== density || $[10] !== enterTransition || $[11] !== height || $[12] !== lines || $[13] !== loadingLabel || $[14] !== margin || $[15] !== onPhaseChange || $[16] !== revealSignature || $[17] !== tweenYDomainOnXDomainChange || $[18] !== width || $[19] !== xDataKey || $[20] !== xDomain || $[21] !== xDomainSlotCount || $[22] !== yDomainTween || $[23] !== yDomainTweenDuration) {
50
45
  t2 = /* @__PURE__ */ jsx(TimeSeriesChartInner, {
51
46
  animationDuration,
52
47
  animationEasing,
@@ -58,6 +53,7 @@ function ChartInner(t0) {
58
53
  height,
59
54
  lines,
60
55
  loadingLabel,
56
+ density,
61
57
  margin,
62
58
  onPhaseChange,
63
59
  revealSignature,
@@ -77,97 +73,97 @@ function ChartInner(t0) {
77
73
  $[6] = clipPathId;
78
74
  $[7] = containerRef;
79
75
  $[8] = data;
80
- $[9] = enterTransition;
81
- $[10] = height;
82
- $[11] = lines;
83
- $[12] = loadingLabel;
84
- $[13] = margin;
85
- $[14] = onPhaseChange;
86
- $[15] = revealSignature;
87
- $[16] = tweenYDomainOnXDomainChange;
88
- $[17] = width;
89
- $[18] = xDataKey;
90
- $[19] = xDomain;
91
- $[20] = xDomainSlotCount;
92
- $[21] = yDomainTween;
93
- $[22] = yDomainTweenDuration;
94
- $[23] = t2;
95
- } else t2 = $[23];
76
+ $[9] = density;
77
+ $[10] = enterTransition;
78
+ $[11] = height;
79
+ $[12] = lines;
80
+ $[13] = loadingLabel;
81
+ $[14] = margin;
82
+ $[15] = onPhaseChange;
83
+ $[16] = revealSignature;
84
+ $[17] = tweenYDomainOnXDomainChange;
85
+ $[18] = width;
86
+ $[19] = xDataKey;
87
+ $[20] = xDomain;
88
+ $[21] = xDomainSlotCount;
89
+ $[22] = yDomainTween;
90
+ $[23] = yDomainTweenDuration;
91
+ $[24] = t2;
92
+ } else t2 = $[24];
96
93
  return t2;
97
94
  }
98
95
  function AreaChart(t0) {
99
- const $ = c(42);
100
- const { data, xDataKey: t1, margin: marginProp, animationDuration: t2, animationEasing, enterTransition, revealSignature, aspectRatio: t3, className: t4, status: t5, loadingLabel, yDomainTweenDuration: t6, yDomainTween: t7, xDomain, xDomainSlotCount, tweenYDomainOnXDomainChange: t8, style, onPhaseChange, children } = t0;
96
+ const $ = c(44);
97
+ const { data, xDataKey: t1, density: t2, margin: marginProp, animationDuration: t3, animationEasing, enterTransition, revealSignature, aspectRatio: t4, className: t5, status: t6, loadingLabel, yDomainTweenDuration: t7, yDomainTween: t8, xDomain, xDomainSlotCount, tweenYDomainOnXDomainChange: t9, style, onPhaseChange, children } = t0;
101
98
  const xDataKey = t1 === void 0 ? "date" : t1;
102
- const animationDuration = t2 === void 0 ? 1100 : t2;
103
- const aspectRatio = t3 === void 0 ? "2 / 1" : t3;
104
- const className = t4 === void 0 ? "" : t4;
105
- const status = t5 === void 0 ? DEFAULT_CHART_STATUS : t5;
106
- const yDomainTweenDuration = t6 === void 0 ? 500 : t6;
107
- const yDomainTween = t7 === void 0 ? true : t7;
108
- const tweenYDomainOnXDomainChange = t8 === void 0 ? false : t8;
109
- const t9 = useId();
110
- let t10;
111
- if ($[0] !== t9) {
112
- let t11;
99
+ const density = t2 === void 0 ? DEFAULT_CHART_DENSITY : t2;
100
+ const animationDuration = t3 === void 0 ? 1100 : t3;
101
+ const aspectRatio = t4 === void 0 ? "2 / 1" : t4;
102
+ const className = t5 === void 0 ? "" : t5;
103
+ const status = t6 === void 0 ? DEFAULT_CHART_STATUS : t6;
104
+ const yDomainTweenDuration = t7 === void 0 ? 500 : t7;
105
+ const yDomainTween = t8 === void 0 ? true : t8;
106
+ const tweenYDomainOnXDomainChange = t9 === void 0 ? false : t9;
107
+ const t10 = useId();
108
+ let t11;
109
+ if ($[0] !== t10) {
110
+ let t12;
113
111
  if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
114
- t11 = /:/g;
115
- $[2] = t11;
116
- } else t11 = $[2];
117
- t10 = t9.replace(t11, "");
118
- $[0] = t9;
119
- $[1] = t10;
120
- } else t10 = $[1];
121
- const clipPathId = `chart-area-grow-clip-${t10}`;
112
+ t12 = /:/g;
113
+ $[2] = t12;
114
+ } else t12 = $[2];
115
+ t11 = t10.replace(t12, "");
116
+ $[0] = t10;
117
+ $[1] = t11;
118
+ } else t11 = $[1];
119
+ const clipPathId = `chart-area-grow-clip-${t11}`;
122
120
  const containerRef = useRef(null);
123
- let t11;
124
- if ($[3] !== marginProp) {
125
- t11 = {
126
- ...DEFAULT_MARGIN,
127
- ...marginProp
128
- };
129
- $[3] = marginProp;
130
- $[4] = t11;
131
- } else t11 = $[4];
132
- const margin = t11;
133
121
  let t12;
134
- if ($[5] !== status) {
135
- t12 = () => resolveRestingChartPhase(status);
136
- $[5] = status;
137
- $[6] = t12;
138
- } else t12 = $[6];
139
- const [chartPhase, setChartPhase] = useState(t12);
122
+ if ($[3] !== density || $[4] !== marginProp) {
123
+ t12 = resolveChartMargin(density, marginProp);
124
+ $[3] = density;
125
+ $[4] = marginProp;
126
+ $[5] = t12;
127
+ } else t12 = $[5];
128
+ const margin = t12;
140
129
  let t13;
141
- if ($[7] !== chartPhase || $[8] !== loadingLabel) {
142
- t13 = loadingLabel?.trim() && (chartPhase === "loading" || chartPhase === "exiting" || chartPhase === "gridTweenReady" || chartPhase === "revealingLoading");
143
- $[7] = chartPhase;
144
- $[8] = loadingLabel;
145
- $[9] = t13;
146
- } else t13 = $[9];
147
- const showLoadingLabel = Boolean(t13);
130
+ if ($[6] !== status) {
131
+ t13 = () => resolveRestingChartPhase(status);
132
+ $[6] = status;
133
+ $[7] = t13;
134
+ } else t13 = $[7];
135
+ const [chartPhase, setChartPhase] = useState(t13);
148
136
  let t14;
149
- if ($[10] !== className) {
150
- t14 = cn("relative w-full", className);
151
- $[10] = className;
152
- $[11] = t14;
153
- } else t14 = $[11];
137
+ if ($[8] !== chartPhase || $[9] !== loadingLabel) {
138
+ t14 = loadingLabel?.trim() && (chartPhase === "loading" || chartPhase === "exiting" || chartPhase === "gridTweenReady" || chartPhase === "revealingLoading");
139
+ $[8] = chartPhase;
140
+ $[9] = loadingLabel;
141
+ $[10] = t14;
142
+ } else t14 = $[10];
143
+ const showLoadingLabel = Boolean(t14);
154
144
  let t15;
155
- if ($[12] !== aspectRatio || $[13] !== style) {
156
- t15 = {
145
+ if ($[11] !== className) {
146
+ t15 = cn("relative w-full", className);
147
+ $[11] = className;
148
+ $[12] = t15;
149
+ } else t15 = $[12];
150
+ let t16;
151
+ if ($[13] !== aspectRatio || $[14] !== style) {
152
+ t16 = {
157
153
  aspectRatio,
158
154
  touchAction: "none",
159
155
  ...style
160
156
  };
161
- $[12] = aspectRatio;
162
- $[13] = style;
163
- $[14] = t15;
164
- } else t15 = $[14];
165
- let t16;
166
- if ($[15] !== animationDuration || $[16] !== animationEasing || $[17] !== children || $[18] !== clipPathId || $[19] !== data || $[20] !== enterTransition || $[21] !== loadingLabel || $[22] !== margin || $[23] !== onPhaseChange || $[24] !== revealSignature || $[25] !== status || $[26] !== tweenYDomainOnXDomainChange || $[27] !== xDataKey || $[28] !== xDomain || $[29] !== xDomainSlotCount || $[30] !== yDomainTween || $[31] !== yDomainTweenDuration) {
167
- t16 = /* @__PURE__ */ jsx(ParentSize, {
157
+ $[13] = aspectRatio;
158
+ $[14] = style;
159
+ $[15] = t16;
160
+ } else t16 = $[15];
161
+ let t17;
162
+ if ($[16] !== animationDuration || $[17] !== animationEasing || $[18] !== children || $[19] !== clipPathId || $[20] !== data || $[21] !== density || $[22] !== enterTransition || $[23] !== loadingLabel || $[24] !== margin || $[25] !== onPhaseChange || $[26] !== revealSignature || $[27] !== status || $[28] !== tweenYDomainOnXDomainChange || $[29] !== xDataKey || $[30] !== xDomain || $[31] !== xDomainSlotCount || $[32] !== yDomainTween || $[33] !== yDomainTweenDuration) {
163
+ t17 = /* @__PURE__ */ jsx(ParentSize, {
168
164
  debounceTime: 10,
169
- children: (t17) => {
170
- const { width, height } = t17;
165
+ children: (t18) => {
166
+ const { width, height } = t18;
171
167
  return /* @__PURE__ */ jsx(ChartInner, {
172
168
  animationDuration,
173
169
  animationEasing,
@@ -177,6 +173,7 @@ function AreaChart(t0) {
177
173
  enterTransition,
178
174
  height,
179
175
  loadingLabel,
176
+ density,
180
177
  margin,
181
178
  onPhaseChange: (phase) => {
182
179
  setChartPhase(phase);
@@ -195,51 +192,52 @@ function AreaChart(t0) {
195
192
  });
196
193
  }
197
194
  });
198
- $[15] = animationDuration;
199
- $[16] = animationEasing;
200
- $[17] = children;
201
- $[18] = clipPathId;
202
- $[19] = data;
203
- $[20] = enterTransition;
204
- $[21] = loadingLabel;
205
- $[22] = margin;
206
- $[23] = onPhaseChange;
207
- $[24] = revealSignature;
208
- $[25] = status;
209
- $[26] = tweenYDomainOnXDomainChange;
210
- $[27] = xDataKey;
211
- $[28] = xDomain;
212
- $[29] = xDomainSlotCount;
213
- $[30] = yDomainTween;
214
- $[31] = yDomainTweenDuration;
215
- $[32] = t16;
216
- } else t16 = $[32];
217
- let t17;
218
- if ($[33] !== chartPhase || $[34] !== loadingLabel || $[35] !== showLoadingLabel) {
219
- t17 = showLoadingLabel ? /* @__PURE__ */ jsx(ChartLoadingLabel, {
195
+ $[16] = animationDuration;
196
+ $[17] = animationEasing;
197
+ $[18] = children;
198
+ $[19] = clipPathId;
199
+ $[20] = data;
200
+ $[21] = density;
201
+ $[22] = enterTransition;
202
+ $[23] = loadingLabel;
203
+ $[24] = margin;
204
+ $[25] = onPhaseChange;
205
+ $[26] = revealSignature;
206
+ $[27] = status;
207
+ $[28] = tweenYDomainOnXDomainChange;
208
+ $[29] = xDataKey;
209
+ $[30] = xDomain;
210
+ $[31] = xDomainSlotCount;
211
+ $[32] = yDomainTween;
212
+ $[33] = yDomainTweenDuration;
213
+ $[34] = t17;
214
+ } else t17 = $[34];
215
+ let t18;
216
+ if ($[35] !== chartPhase || $[36] !== loadingLabel || $[37] !== showLoadingLabel) {
217
+ t18 = showLoadingLabel ? /* @__PURE__ */ jsx(ChartLoadingLabel, {
220
218
  exiting: chartPhase !== "loading",
221
219
  text: loadingLabel
222
220
  }) : null;
223
- $[33] = chartPhase;
224
- $[34] = loadingLabel;
225
- $[35] = showLoadingLabel;
226
- $[36] = t17;
227
- } else t17 = $[36];
228
- let t18;
229
- if ($[37] !== t14 || $[38] !== t15 || $[39] !== t16 || $[40] !== t17) {
230
- t18 = /* @__PURE__ */ jsxs("div", {
231
- className: t14,
221
+ $[35] = chartPhase;
222
+ $[36] = loadingLabel;
223
+ $[37] = showLoadingLabel;
224
+ $[38] = t18;
225
+ } else t18 = $[38];
226
+ let t19;
227
+ if ($[39] !== t15 || $[40] !== t16 || $[41] !== t17 || $[42] !== t18) {
228
+ t19 = /* @__PURE__ */ jsxs("div", {
229
+ className: t15,
232
230
  ref: containerRef,
233
- style: t15,
234
- children: [t16, t17]
231
+ style: t16,
232
+ children: [t17, t18]
235
233
  });
236
- $[37] = t14;
237
- $[38] = t15;
238
- $[39] = t16;
239
- $[40] = t17;
240
- $[41] = t18;
241
- } else t18 = $[41];
242
- return t18;
234
+ $[39] = t15;
235
+ $[40] = t16;
236
+ $[41] = t17;
237
+ $[42] = t18;
238
+ $[43] = t19;
239
+ } else t19 = $[43];
240
+ return t19;
243
241
  }
244
242
 
245
243
  //#endregion
@@ -0,0 +1,280 @@
1
+ "use client";
2
+
3
+ import { useChartStable } from "./chart-context.js";
4
+ import { renderPatternPreset } from "./pattern-preset.js";
5
+ import { c } from "react/compiler-runtime";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { useId } from "react";
8
+ import { motion } from "motion/react";
9
+
10
+ //#region src/components/Charts/background.tsx
11
+ const BACKGROUND_ENTER_FADE_MS = 420;
12
+ function clampFadeLength(length) {
13
+ return Math.min(45, Math.max(0, length));
14
+ }
15
+ function fadeMaskStops(lengthPercent) {
16
+ const edge = clampFadeLength(lengthPercent);
17
+ return [
18
+ {
19
+ offset: "0%",
20
+ opacity: 0
21
+ },
22
+ {
23
+ offset: `${edge}%`,
24
+ opacity: 1
25
+ },
26
+ {
27
+ offset: `${100 - edge}%`,
28
+ opacity: 1
29
+ },
30
+ {
31
+ offset: "100%",
32
+ opacity: 0
33
+ }
34
+ ];
35
+ }
36
+ /** Plot-area pattern fill for charts without a grid. Renders behind series layers. */
37
+ function Background(t0) {
38
+ const $ = c(60);
39
+ const { pattern: t1, color: t2, scale: t3, strokeWidth, radius, complement, fill, dotFill, tileBackground, showFill: t4, opacity: t5, fadeHorizontal: t6, fadeVertical: t7, fadeHorizontalLength: t8, fadeVerticalLength: t9, qaTestId: t10 } = t0;
40
+ const pattern = t1 === void 0 ? "diagonal" : t1;
41
+ const color = t2 === void 0 ? "var(--chart-grid)" : t2;
42
+ const scale = t3 === void 0 ? 1 : t3;
43
+ const showFill = t4 === void 0 ? true : t4;
44
+ const opacity = t5 === void 0 ? 1 : t5;
45
+ const fadeHorizontal = t6 === void 0 ? true : t6;
46
+ const fadeVertical = t7 === void 0 ? true : t7;
47
+ const fadeHorizontalLength = t8 === void 0 ? 10 : t8;
48
+ const fadeVerticalLength = t9 === void 0 ? 10 : t9;
49
+ const qaTestId = t10 === void 0 ? "background" : t10;
50
+ const { innerWidth, innerHeight, isLoaded, enterTransition } = useChartStable();
51
+ const t11 = useId();
52
+ let t12;
53
+ if ($[0] !== t11) {
54
+ let t13;
55
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
56
+ t13 = /:/g;
57
+ $[2] = t13;
58
+ } else t13 = $[2];
59
+ t12 = t11.replace(t13, "");
60
+ $[0] = t11;
61
+ $[1] = t12;
62
+ } else t12 = $[1];
63
+ const uniqueId = t12;
64
+ const patternId = `chart-background-${uniqueId}`;
65
+ if (pattern === "none" || !showFill || innerWidth <= 0 || innerHeight <= 0) return null;
66
+ let t13;
67
+ if ($[3] !== color || $[4] !== complement || $[5] !== dotFill || $[6] !== fill || $[7] !== pattern || $[8] !== patternId || $[9] !== radius || $[10] !== scale || $[11] !== strokeWidth || $[12] !== tileBackground) {
68
+ t13 = renderPatternPreset(pattern, patternId, {
69
+ color,
70
+ scale,
71
+ strokeWidth,
72
+ radius,
73
+ complement,
74
+ fill,
75
+ dotFill,
76
+ tileBackground
77
+ });
78
+ $[3] = color;
79
+ $[4] = complement;
80
+ $[5] = dotFill;
81
+ $[6] = fill;
82
+ $[7] = pattern;
83
+ $[8] = patternId;
84
+ $[9] = radius;
85
+ $[10] = scale;
86
+ $[11] = strokeWidth;
87
+ $[12] = tileBackground;
88
+ $[13] = t13;
89
+ } else t13 = $[13];
90
+ const patternNode = t13;
91
+ if (!patternNode) return null;
92
+ let enterFade;
93
+ let hMaskRef;
94
+ let revealOpacity;
95
+ let t14;
96
+ let t15;
97
+ let t16;
98
+ let t17;
99
+ let vMaskRef;
100
+ if ($[14] !== enterTransition || $[15] !== fadeHorizontal || $[16] !== fadeHorizontalLength || $[17] !== fadeVertical || $[18] !== fadeVerticalLength || $[19] !== innerHeight || $[20] !== innerWidth || $[21] !== isLoaded || $[22] !== opacity || $[23] !== qaTestId || $[24] !== uniqueId) {
101
+ const hStops = fadeMaskStops(fadeHorizontalLength);
102
+ const vStops = fadeMaskStops(fadeVerticalLength);
103
+ const hMaskId = `chart-background-fade-h-${uniqueId}`;
104
+ const hGradientId = `${hMaskId}-gradient`;
105
+ const vMaskId = `chart-background-fade-v-${uniqueId}`;
106
+ const vGradientId = `${vMaskId}-gradient`;
107
+ hMaskRef = fadeHorizontal ? `url(#${hMaskId})` : void 0;
108
+ vMaskRef = fadeVertical ? `url(#${vMaskId})` : void 0;
109
+ revealOpacity = isLoaded ? opacity : 0;
110
+ let t18;
111
+ if ($[33] !== enterTransition) {
112
+ t18 = enterTransition && typeof enterTransition === "object" ? enterTransition : {
113
+ duration: BACKGROUND_ENTER_FADE_MS / 1e3,
114
+ ease: "easeOut"
115
+ };
116
+ $[33] = enterTransition;
117
+ $[34] = t18;
118
+ } else t18 = $[34];
119
+ enterFade = t18;
120
+ t14 = "true";
121
+ t15 = "chart-background";
122
+ t16 = qaTestId;
123
+ t17 = fadeHorizontal || fadeVertical ? /* @__PURE__ */ jsxs("defs", { children: [fadeHorizontal ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("linearGradient", {
124
+ id: hGradientId,
125
+ x1: "0%",
126
+ x2: "100%",
127
+ y1: "0%",
128
+ y2: "0%",
129
+ children: hStops.map(_temp)
130
+ }), /* @__PURE__ */ jsx("mask", {
131
+ id: hMaskId,
132
+ children: /* @__PURE__ */ jsx("rect", {
133
+ fill: `url(#${hGradientId})`,
134
+ height: innerHeight,
135
+ width: innerWidth,
136
+ x: 0,
137
+ y: 0
138
+ })
139
+ })] }) : null, fadeVertical ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("linearGradient", {
140
+ id: vGradientId,
141
+ x1: "0%",
142
+ x2: "0%",
143
+ y1: "0%",
144
+ y2: "100%",
145
+ children: vStops.map(_temp2)
146
+ }), /* @__PURE__ */ jsx("mask", {
147
+ id: vMaskId,
148
+ children: /* @__PURE__ */ jsx("rect", {
149
+ fill: `url(#${vGradientId})`,
150
+ height: innerHeight,
151
+ width: innerWidth,
152
+ x: 0,
153
+ y: 0
154
+ })
155
+ })] }) : null] }) : null;
156
+ $[14] = enterTransition;
157
+ $[15] = fadeHorizontal;
158
+ $[16] = fadeHorizontalLength;
159
+ $[17] = fadeVertical;
160
+ $[18] = fadeVerticalLength;
161
+ $[19] = innerHeight;
162
+ $[20] = innerWidth;
163
+ $[21] = isLoaded;
164
+ $[22] = opacity;
165
+ $[23] = qaTestId;
166
+ $[24] = uniqueId;
167
+ $[25] = enterFade;
168
+ $[26] = hMaskRef;
169
+ $[27] = revealOpacity;
170
+ $[28] = t14;
171
+ $[29] = t15;
172
+ $[30] = t16;
173
+ $[31] = t17;
174
+ $[32] = vMaskRef;
175
+ } else {
176
+ enterFade = $[25];
177
+ hMaskRef = $[26];
178
+ revealOpacity = $[27];
179
+ t14 = $[28];
180
+ t15 = $[29];
181
+ t16 = $[30];
182
+ t17 = $[31];
183
+ vMaskRef = $[32];
184
+ }
185
+ let t18;
186
+ if ($[35] !== patternNode) {
187
+ t18 = /* @__PURE__ */ jsx("defs", { children: patternNode });
188
+ $[35] = patternNode;
189
+ $[36] = t18;
190
+ } else t18 = $[36];
191
+ let t19;
192
+ if ($[37] !== revealOpacity) {
193
+ t19 = { opacity: revealOpacity };
194
+ $[37] = revealOpacity;
195
+ $[38] = t19;
196
+ } else t19 = $[38];
197
+ const t20 = `url(#${patternId})`;
198
+ let t21;
199
+ if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
200
+ t21 = { opacity: 0 };
201
+ $[39] = t21;
202
+ } else t21 = $[39];
203
+ let t22;
204
+ if ($[40] !== enterFade || $[41] !== isLoaded) {
205
+ t22 = isLoaded ? enterFade : { duration: 0 };
206
+ $[40] = enterFade;
207
+ $[41] = isLoaded;
208
+ $[42] = t22;
209
+ } else t22 = $[42];
210
+ let t23;
211
+ if ($[43] !== innerHeight || $[44] !== innerWidth || $[45] !== t19 || $[46] !== t20 || $[47] !== t22 || $[48] !== vMaskRef) {
212
+ t23 = /* @__PURE__ */ jsx(motion.rect, {
213
+ animate: t19,
214
+ fill: t20,
215
+ height: innerHeight,
216
+ initial: t21,
217
+ mask: vMaskRef,
218
+ transition: t22,
219
+ width: innerWidth,
220
+ x: 0,
221
+ y: 0
222
+ });
223
+ $[43] = innerHeight;
224
+ $[44] = innerWidth;
225
+ $[45] = t19;
226
+ $[46] = t20;
227
+ $[47] = t22;
228
+ $[48] = vMaskRef;
229
+ $[49] = t23;
230
+ } else t23 = $[49];
231
+ let t24;
232
+ if ($[50] !== hMaskRef || $[51] !== t23) {
233
+ t24 = /* @__PURE__ */ jsx("g", {
234
+ mask: hMaskRef,
235
+ children: t23
236
+ });
237
+ $[50] = hMaskRef;
238
+ $[51] = t23;
239
+ $[52] = t24;
240
+ } else t24 = $[52];
241
+ let t25;
242
+ if ($[53] !== t14 || $[54] !== t15 || $[55] !== t16 || $[56] !== t17 || $[57] !== t18 || $[58] !== t24) {
243
+ t25 = /* @__PURE__ */ jsxs("g", {
244
+ "aria-hidden": t14,
245
+ className: t15,
246
+ "qa-test-id": t16,
247
+ children: [
248
+ t17,
249
+ t18,
250
+ t24
251
+ ]
252
+ });
253
+ $[53] = t14;
254
+ $[54] = t15;
255
+ $[55] = t16;
256
+ $[56] = t17;
257
+ $[57] = t18;
258
+ $[58] = t24;
259
+ $[59] = t25;
260
+ } else t25 = $[59];
261
+ return t25;
262
+ }
263
+ function _temp2(stop_0) {
264
+ return /* @__PURE__ */ jsx("stop", {
265
+ offset: stop_0.offset,
266
+ stopColor: "white",
267
+ stopOpacity: stop_0.opacity
268
+ }, `v-${stop_0.offset}`);
269
+ }
270
+ function _temp(stop) {
271
+ return /* @__PURE__ */ jsx("stop", {
272
+ offset: stop.offset,
273
+ stopColor: "white",
274
+ stopOpacity: stop.opacity
275
+ }, `h-${stop.offset}`);
276
+ }
277
+ Background.displayName = "Background";
278
+
279
+ //#endregion
280
+ export { Background, Background as default };