solid-recharts 0.1.0 → 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/LICENSE +24 -0
- package/package.json +10 -7
- package/src/cartesian/Area.tsx +40 -55
- package/src/cartesian/Bar.tsx +66 -58
- package/src/cartesian/BarStack.tsx +5 -2
- package/src/cartesian/Brush.tsx +1 -1
- package/src/cartesian/Funnel.tsx +15 -19
- package/src/cartesian/Line.tsx +34 -51
- package/src/cartesian/LineDrawShape.tsx +8 -6
- package/src/cartesian/ReferenceArea.tsx +25 -35
- package/src/cartesian/ReferenceDot.tsx +24 -34
- package/src/cartesian/ReferenceLine.tsx +25 -34
- package/src/cartesian/Scatter.tsx +25 -37
- package/src/cartesian/XAxis.tsx +54 -67
- package/src/cartesian/YAxis.tsx +53 -66
- package/src/cartesian/ZAxis.tsx +27 -40
- package/src/chart/SunburstChart.tsx +1 -1
- package/src/component/ActivePoints.tsx +0 -9
- package/src/component/Customized.tsx +1 -1
- package/src/component/Dots.tsx +7 -3
- package/src/context/ErrorBarContext.tsx +15 -24
- package/src/polar/Pie.tsx +36 -48
- package/src/polar/PolarAngleAxis.tsx +41 -50
- package/src/polar/PolarRadiusAxis.tsx +40 -48
- package/src/polar/Radar.tsx +22 -34
- package/src/polar/RadialBar.tsx +21 -39
- package/src/shape/Curve.tsx +1 -1
- package/src/shape/Symbols.tsx +1 -1
- package/src/state/RechartsReduxContext.tsx +1 -1
- package/src/state/SetLegendPayload.ts +19 -27
- package/src/state/SetTooltipEntrySettings.tsx +9 -26
- package/src/state/cartesianAxisSlice.ts +40 -60
- package/src/state/createCollectionActions.ts +51 -0
- package/src/state/createSelector.ts +97 -0
- package/src/state/externalEventsMiddleware.ts +2 -11
- package/src/state/graphicalItemsSlice.ts +27 -40
- package/src/state/isEventThrottled.ts +12 -0
- package/src/state/keyboardEventsMiddleware.ts +2 -8
- package/src/state/layoutSlice.ts +8 -4
- package/src/state/legendSlice.ts +24 -26
- package/src/state/mouseEventsMiddleware.ts +2 -13
- package/src/state/patched.ts +19 -0
- package/src/state/referenceElementsSlice.ts +40 -31
- package/src/state/registerInStore.ts +68 -0
- package/src/state/selectors/areaSelectors.ts +13 -36
- package/src/state/selectors/arrayEqualityCheck.ts +32 -7
- package/src/state/selectors/axisSelectors.ts +215 -169
- package/src/state/selectors/barSelectors.ts +8 -36
- package/src/state/selectors/combiners/combineConfiguredScale.ts +1 -1
- package/src/state/selectors/combiners/combineRealScaleType.ts +1 -1
- package/src/state/selectors/dataSelectors.ts +35 -16
- package/src/state/selectors/numberDomainEqualityCheck.ts +16 -8
- package/src/state/selectors/selectAxisForGraphicalItem.ts +52 -0
- package/src/state/store.ts +0 -1
- package/src/state/tooltipSlice.ts +93 -64
- package/src/util/ActiveShapeUtils.tsx +0 -7
- package/src/util/BarUtils.tsx +27 -22
- package/src/util/ChartUtils.ts +69 -25
- package/src/util/propsAreEqual.ts +3 -33
- package/src/util/stacks/stackTypes.ts +1 -1
- package/src/util/types.ts +2 -2
- package/test/animation/CSSTransitionAnimate.timing.spec.tsx +1 -1
- package/test/animation/JavascriptAnimate.spec.tsx +1 -1
- package/test/animation/legacyAnimationLengthChange.spec.tsx +1 -1
- package/test/cartesian/Area.animation.spec.tsx +1 -1
- package/test/cartesian/Area.range.spec.tsx +1 -1
- package/test/cartesian/Area.spec.tsx +1 -1
- package/test/cartesian/Area.stacked.render.spec.tsx +1 -1
- package/test/cartesian/Area.typed.spec.tsx +1 -1
- package/test/cartesian/Axis.integration.spec.tsx +1 -1
- package/test/cartesian/Bar/Bar.csstransition.spec.tsx +1 -1
- package/test/cartesian/Bar/Bar.spec.tsx +1 -1
- package/test/cartesian/Bar/Bar.typed.spec.tsx +1 -1
- package/test/cartesian/Bar.animation.spec.tsx +1 -1
- package/test/cartesian/Bar.stackDomain.spec.tsx +1 -1
- package/test/cartesian/Bar.stacked.render.spec.tsx +1 -1
- package/test/cartesian/Bar.zeroDimensionFiltering.spec.tsx +1 -1
- package/test/cartesian/Brush.keyboard.spec.tsx +1 -1
- package/test/cartesian/Brush.panorama.spec.tsx +1 -1
- package/test/cartesian/Brush.props.spec.tsx +1 -1
- package/test/cartesian/Brush.render.spec.tsx +1 -1
- package/test/cartesian/Brush.spec.tsx +1 -1
- package/test/cartesian/Brush.stacked.spec.tsx +1 -1
- package/test/cartesian/CartesianAxis.render.spec.tsx +1 -1
- package/test/cartesian/CartesianAxis.spec.tsx +2 -2
- package/test/cartesian/CartesianGrid.render.spec.tsx +1 -1
- package/test/cartesian/CartesianGrid.spec.tsx +1 -1
- package/test/cartesian/ErrorBar.render.spec.tsx +1 -1
- package/test/cartesian/ErrorBar.spec.tsx +1 -1
- package/test/cartesian/Funnel.animation.spec.tsx +1 -1
- package/test/cartesian/Funnel.spec.tsx +1 -1
- package/test/cartesian/Funnel.typed.spec.tsx +1 -1
- package/test/cartesian/GraphicalItemClipPath.scale-behavior.spec.tsx +2 -2
- package/test/cartesian/Line.animation.spec.tsx +1 -1
- package/test/cartesian/Line.sparseAnimationPath.spec.tsx +1 -1
- package/test/cartesian/Line.spec.tsx +1 -1
- package/test/cartesian/Line.typed.spec.tsx +1 -1
- package/test/cartesian/ReferenceArea.render.spec.tsx +1 -1
- package/test/cartesian/ReferenceArea.spec.tsx +1 -1
- package/test/cartesian/ReferenceArea.typed.spec.tsx +1 -1
- package/test/cartesian/ReferenceDot.render.spec.tsx +1 -1
- package/test/cartesian/ReferenceDot.spec.tsx +1 -1
- package/test/cartesian/ReferenceDot.typed.spec.tsx +1 -1
- package/test/cartesian/ReferenceLine/ReferenceLine.panorama.spec.tsx +1 -1
- package/test/cartesian/ReferenceLine/ReferenceLine.spec.tsx +1 -1
- package/test/cartesian/ReferenceLine/ReferenceLine.typed.spec.tsx +1 -1
- package/test/cartesian/ReferenceLine/getEndPoints.spec.ts +1 -1
- package/test/cartesian/ReferenceLine.render.spec.tsx +1 -1
- package/test/cartesian/Scatter.animation.spec.tsx +1 -1
- package/test/cartesian/Scatter.render.spec.tsx +1 -1
- package/test/cartesian/Scatter.spec.tsx +1 -1
- package/test/cartesian/Scatter.typed.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.barSize.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.brush.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.categorydomain.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.datatypes.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.hide.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.multiaxis.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.numberdomain.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.padding.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.padding_clip.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.state.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.tick.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.timescale.spec.tsx +2 -2
- package/test/cartesian/XAxis/XAxis.typed.spec.tsx +1 -1
- package/test/cartesian/XAxis/XAxis.vertical.spec.tsx +1 -1
- package/test/cartesian/XAxis.tickFormatter.spec.tsx +1 -1
- package/test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx +1 -1
- package/test/cartesian/YAxis/YAxis.interval-zero.spec.tsx +1 -1
- package/test/cartesian/YAxis/YAxis.label.spec.tsx +1 -1
- package/test/cartesian/YAxis/YAxis.spec.tsx +1 -1
- package/test/cartesian/YAxis/YAxis.tick.spec.tsx +1 -1
- package/test/cartesian/YAxis/YAxis.tickFormatter.spec.tsx +1 -1
- package/test/cartesian/YAxis/YAxis.typed.spec.tsx +1 -1
- package/test/cartesian/ZAxis.spec.tsx +1 -1
- package/test/cartesian/ZAxis.typed.spec.tsx +1 -1
- package/test/cartesian/axisLineAndStroke.spec.tsx +1 -1
- package/test/cartesian/miscFeatureGaps.spec.tsx +1 -1
- package/test/chart/AccessibilityLayer.spec.tsx +1 -1
- package/test/chart/AccessibilityScans.spec.tsx +2 -2
- package/test/chart/AreaChart.spec.tsx +1 -1
- package/test/chart/AreaChart.typed.spec.tsx +1 -1
- package/test/chart/BarChart.spec.tsx +1 -1
- package/test/chart/BarChart.typed.spec.tsx +1 -1
- package/test/chart/CategoricalChart.spec.tsx +1 -1
- package/test/chart/ComposedChart.spec.tsx +1 -1
- package/test/chart/ComposedChart.typed.spec.tsx +1 -1
- package/test/chart/FunnelChart.spec.tsx +1 -1
- package/test/chart/FunnelChart.typed.spec.tsx +1 -1
- package/test/chart/LineChart.smoke.spec.tsx +1 -1
- package/test/chart/LineChart.spec.tsx +1 -1
- package/test/chart/LineChart.typed.spec.tsx +1 -1
- package/test/chart/NicheChartTooltip.spec.tsx +1 -1
- package/test/chart/PieChart.spec.tsx +1 -1
- package/test/chart/PieChart.typed.spec.tsx +1 -1
- package/test/chart/RadarChart.spec.tsx +1 -1
- package/test/chart/RadarChart.typed.spec.tsx +1 -1
- package/test/chart/RadialBarChart.spec.tsx +1 -1
- package/test/chart/RadialBarChart.typed.spec.tsx +1 -1
- package/test/chart/RechartsWrapper.spec.tsx +1 -1
- package/test/chart/Sankey.content.spec.tsx +1 -1
- package/test/chart/Sankey.spec.tsx +1 -1
- package/test/chart/ScatterChart.spec.tsx +1 -1
- package/test/chart/ScatterChart.typed.spec.tsx +1 -1
- package/test/chart/SunburstChart.spec.tsx +1 -1
- package/test/chart/Treemap.animation.spec.tsx +1 -1
- package/test/chart/Treemap.spec.tsx +1 -1
- package/test/chart/chartEvents.spec.tsx +1 -1
- package/test/chart/responsive.spec.tsx +1 -1
- package/test/component/Cell.render.spec.tsx +1 -1
- package/test/component/Cell.spec.tsx +1 -1
- package/test/component/Cursor.spec.tsx +1 -1
- package/test/component/DefaultTooltipContent.spec.tsx +1 -1
- package/test/component/Label.render.spec.tsx +1 -1
- package/test/component/Label.spec.tsx +1 -1
- package/test/component/LabelList.spec.tsx +1 -1
- package/test/component/Legend.itemSorter.spec.tsx +1 -1
- package/test/component/Legend.render.spec.tsx +1 -1
- package/test/component/Legend.spec.tsx +1 -1
- package/test/component/ResponsiveContainer.spec.tsx +1 -1
- package/test/component/ResponsiveContainerDataTest.spec.tsx +1 -1
- package/test/component/Text.spec.tsx +1 -1
- package/test/component/Tooltip/ActiveDot.spec.tsx +1 -1
- package/test/component/Tooltip/tooltipEventType.spec.tsx +1 -1
- package/test/component/Tooltip/tooltipTestHelpers.tsx +1 -1
- package/test/component/Tooltip.defaultIndex.spec.tsx +1 -1
- package/test/component/Tooltip.hover.spec.tsx +1 -1
- package/test/component/Tooltip.item.spec.tsx +1 -1
- package/test/component/Tooltip.keyboard.spec.tsx +1 -1
- package/test/component/Tooltip.payload.spec.tsx +1 -1
- package/test/component/Tooltip.touch.spec.tsx +1 -1
- package/test/component/Tooltip.visibility.spec.tsx +1 -1
- package/test/component/TooltipBoundingBox.spec.tsx +2 -2
- package/test/container/ClipPath.spec.tsx +1 -1
- package/test/context/chartLayoutContext.spec.tsx +1 -1
- package/test/helper/createSelectorTestCase.tsx +1 -1
- package/test/helper/mockAxes.ts +1 -1
- package/test/helper/selectorTestHelpers.tsx +1 -1
- package/test/hooks/useActiveTooltipDataPoints.spec.tsx +1 -1
- package/test/hooks/useOffset.spec.tsx +1 -1
- package/test/hooks/useTooltipStateHooks.spec.tsx +1 -1
- package/test/polar/Pie/Pie-TwoLevelPieChart.spec.tsx +1 -1
- package/test/polar/Pie/Pie.spec.tsx +1 -1
- package/test/polar/Pie/Pie.typed.spec.tsx +1 -1
- package/test/polar/Pie.animation.spec.tsx +1 -1
- package/test/polar/PieWithLegend.animation.spec.tsx +1 -1
- package/test/polar/PolarAngleAxis/PolarAngleAxis.events.spec.tsx +1 -1
- package/test/polar/PolarAngleAxis/PolarAngleAxis.spec.tsx +1 -1
- package/test/polar/PolarAngleAxis/PolarAngleAxis.typed.spec.tsx +1 -1
- package/test/polar/PolarAngleAxis.render.spec.tsx +1 -1
- package/test/polar/PolarGrid.render.spec.tsx +1 -1
- package/test/polar/PolarGrid.spec.tsx +1 -1
- package/test/polar/PolarLegendPerRow.render.spec.tsx +1 -1
- package/test/polar/PolarRadiusAxis.events.spec.tsx +1 -1
- package/test/polar/PolarRadiusAxis.render.spec.tsx +1 -1
- package/test/polar/PolarRadiusAxis.spec.tsx +1 -1
- package/test/polar/PolarRadiusAxis.typed.spec.tsx +1 -1
- package/test/polar/PolarTooltipLegend.render.spec.tsx +1 -1
- package/test/polar/Radar.animation.spec.tsx +1 -1
- package/test/polar/Radar.render.spec.tsx +1 -1
- package/test/polar/Radar.spec.tsx +1 -1
- package/test/polar/Radar.typed.spec.tsx +1 -1
- package/test/polar/RadialBar/RadialBar.spec.tsx +1 -1
- package/test/polar/RadialBar/RadialBar.typed.spec.tsx +1 -1
- package/test/polar/RadialBar.animation.spec.tsx +1 -1
- package/test/polar/RadialBar.render.spec.tsx +1 -1
- package/test/polar/RadialBar.stacked.spec.tsx +1 -1
- package/test/setup.ts +1 -1
- package/test/shape/ActiveShape.spec.tsx +1 -1
- package/test/shape/Cross.spec.tsx +1 -1
- package/test/shape/Curve.spec.tsx +2 -2
- package/test/shape/Curve.typed.spec.tsx +1 -1
- package/test/shape/Dot.spec.tsx +1 -1
- package/test/shape/Polygon.spec.tsx +1 -1
- package/test/shape/Rectangle.animation.spec.tsx +1 -1
- package/test/shape/Rectangle.spec.tsx +1 -1
- package/test/shape/Sector.spec.tsx +1 -1
- package/test/shape/Symbols.spec.tsx +1 -1
- package/test/shape/Trapezoid.spec.tsx +1 -1
- package/test/state/createCollectionActions.spec.ts +87 -0
- package/test/state/createSelector.spec.ts +158 -0
- package/test/state/hooks.spec.tsx +1 -1
- package/test/state/registerInStore.spec.tsx +101 -0
- package/test/state/selectors/axisSelectors.spec.tsx +1 -1
- package/test/state/selectors/combiners/combineConfiguredScale.spec.ts +1 -1
- package/test/state/selectors/combiners/combineRealScaleType.spec.ts +1 -1
- package/test/state/selectors/dataSelectors.spec.tsx +1 -1
- package/test/state/selectors/legendSelectors.spec.tsx +1 -1
- package/test/state/selectors/radarSelectors.spec.tsx +1 -1
- package/test/state/selectors/selectActiveTooltipIndex.spec.tsx +1 -1
- package/test/state/selectors/selectDisplayedData.spec.tsx +1 -1
- package/test/state/selectors/selectStackGroups.spec.tsx +1 -1
- package/test/state/selectors/selectorMemoization.spec.tsx +136 -0
- package/test/state/selectors/selectors.spec.tsx +1 -1
- package/test/util/CartesianUtils/CartesianUtils.spec.ts +1 -1
- package/test/util/ChartUtils/ChartUtils.spec.ts +1 -1
- package/test/util/ChartUtils/getCateCoordinateOfLine.spec.ts +14 -0
- package/test/util/ChartUtils/getStackedData.spec.ts +1 -1
- package/test/util/ChartUtils/truncateByDomain.spec.ts +1 -1
- package/test/util/DomUtils.spec.tsx +1 -1
- package/test/util/FunnelUtils.spec.tsx +1 -1
- package/test/util/scale/createCategoricalInverse.spec.ts +1 -1
- package/test/util/useElementOffset.spec.tsx +1 -1
- package/test/util/usePrefersReducedMotion.spec.ts +1 -1
- package/test/util/useUniqueId.spec.ts +1 -1
- package/test/zIndex/AllZIndexPortals.spec.tsx +1 -1
- package/test/zIndex/DynamicZIndex.spec.tsx +1 -1
- package/test/zIndex/ZIndexLayer.portalOwner.spec.tsx +1 -1
- package/test/zIndex/componentZIndex.spec.tsx +1 -1
- package/test/zIndex/multiChartZIndexIsolation.spec.tsx +1 -1
- package/test-results/.last-run.json +4 -0
- package/NEXT_SESSION_PROMPT.md +0 -114
- package/src/state/reduxDevtoolsJsonStringifyReplacer.ts +0 -15
- package/src/util/axisPropsAreEqual.ts +0 -42
- package/src/util/resolveDefaultProps.tsx +0 -8
- package/src/util/typedDataKey.ts +0 -8
- package/test/helper/render.ts +0 -7
- package/test/state/reduxDevtoolsJsonStringifyReplacer.spec.ts +0 -25
- package/test/util/axisPropsAreEqual.spec.ts +0 -93
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Regression gate for the memoized selector graph (ADR-0002).
|
|
2
|
+
//
|
|
3
|
+
// This is the direct test of the performance win: the expensive
|
|
4
|
+
// applied-values / displayed-data chain must be SHARED (a repeat call returns
|
|
5
|
+
// the identical reference) and must NOT be invalidated by a tooltip/mousemove
|
|
6
|
+
// interaction (the classic recharts hotspot), while STILL invalidating when the
|
|
7
|
+
// underlying chart data actually changes. Reference identity is the observable
|
|
8
|
+
// proxy for "did the O(series×points) combiner re-run".
|
|
9
|
+
import { describe, expect, it } from "vitest";
|
|
10
|
+
import { flush } from "solid-js";
|
|
11
|
+
import { render } from "@solidjs/testing-library";
|
|
12
|
+
import { Line, LineChart, XAxis } from "../../../src";
|
|
13
|
+
import { useAppStore } from "../../../src/state/hooks";
|
|
14
|
+
import { defaultAxisId } from "../../../src/state/cartesianAxisSlice";
|
|
15
|
+
import {
|
|
16
|
+
selectAllAppliedValues,
|
|
17
|
+
selectAxisDomain,
|
|
18
|
+
selectAxisScale,
|
|
19
|
+
selectCartesianItemsSettings,
|
|
20
|
+
selectDisplayedData,
|
|
21
|
+
selectNumericalDomain,
|
|
22
|
+
selectTicksOfGraphicalItem,
|
|
23
|
+
} from "../../../src/state/selectors/axisSelectors";
|
|
24
|
+
import type { RechartsStore } from "../../../src/state/store";
|
|
25
|
+
|
|
26
|
+
const data = [
|
|
27
|
+
{ name: "a", uv: 10 },
|
|
28
|
+
{ name: "b", uv: 30 },
|
|
29
|
+
{ name: "c", uv: 20 },
|
|
30
|
+
{ name: "d", uv: 40 },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
function renderChartAndCaptureStore(): RechartsStore {
|
|
34
|
+
let store: RechartsStore | undefined;
|
|
35
|
+
const Capture = (): null => {
|
|
36
|
+
store = useAppStore();
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
render(() => (
|
|
40
|
+
<LineChart width={200} height={200} data={data}>
|
|
41
|
+
<XAxis dataKey="name" />
|
|
42
|
+
<Line dataKey="uv" isAnimationActive={false} />
|
|
43
|
+
<Capture />
|
|
44
|
+
</LineChart>
|
|
45
|
+
));
|
|
46
|
+
flush();
|
|
47
|
+
flush();
|
|
48
|
+
flush();
|
|
49
|
+
if (store == null) {
|
|
50
|
+
throw new Error("store capture failed");
|
|
51
|
+
}
|
|
52
|
+
return store;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
describe("memoized selector graph", () => {
|
|
56
|
+
it("shares the applied-values chain: a repeat call returns the identical reference", () => {
|
|
57
|
+
const store = renderChartAndCaptureStore();
|
|
58
|
+
const first = selectAllAppliedValues(store.state, "xAxis", defaultAxisId, false);
|
|
59
|
+
const second = selectAllAppliedValues(store.state, "xAxis", defaultAxisId, false);
|
|
60
|
+
expect(second).toBe(first);
|
|
61
|
+
// The intermediate nodes are shared too.
|
|
62
|
+
expect(selectDisplayedData(store.state, "xAxis", defaultAxisId, false)).toBe(
|
|
63
|
+
selectDisplayedData(store.state, "xAxis", defaultAxisId, false),
|
|
64
|
+
);
|
|
65
|
+
expect(selectCartesianItemsSettings(store.state, "xAxis", defaultAxisId)).toBe(
|
|
66
|
+
selectCartesianItemsSettings(store.state, "xAxis", defaultAxisId),
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("does NOT invalidate the data chain on a tooltip/mousemove interaction (the fan-out win)", () => {
|
|
71
|
+
const store = renderChartAndCaptureStore();
|
|
72
|
+
const before = selectAllAppliedValues(store.state, "xAxis", defaultAxisId, false);
|
|
73
|
+
const displayedBefore = selectDisplayedData(store.state, "xAxis", defaultAxisId, false);
|
|
74
|
+
|
|
75
|
+
// Simulate the per-frame mousemove state write.
|
|
76
|
+
store.actions.tooltip.setMouseOverAxisIndex({
|
|
77
|
+
activeIndex: "2",
|
|
78
|
+
activeDataKey: undefined,
|
|
79
|
+
activeCoordinate: { x: 50, y: 50 },
|
|
80
|
+
});
|
|
81
|
+
flush();
|
|
82
|
+
|
|
83
|
+
const after = selectAllAppliedValues(store.state, "xAxis", defaultAxisId, false);
|
|
84
|
+
const displayedAfter = selectDisplayedData(store.state, "xAxis", defaultAxisId, false);
|
|
85
|
+
// The expensive chain is untouched by the interaction — same references,
|
|
86
|
+
// so no combiner re-ran. This is what collapses the ~10× mousemove fan-out.
|
|
87
|
+
expect(after).toBe(before);
|
|
88
|
+
expect(displayedAfter).toBe(displayedBefore);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("keeps the full domain→scale→ticks chain stable across a mousemove", () => {
|
|
92
|
+
const store = renderChartAndCaptureStore();
|
|
93
|
+
const axes = ["xAxis", "yAxis"] as const;
|
|
94
|
+
const before = axes.map((axisType) => ({
|
|
95
|
+
numericalDomain: selectNumericalDomain(store.state, axisType, defaultAxisId, false),
|
|
96
|
+
axisDomain: selectAxisDomain(store.state, axisType, defaultAxisId, false),
|
|
97
|
+
scale: selectAxisScale(store.state, axisType, defaultAxisId, false),
|
|
98
|
+
ticks: selectTicksOfGraphicalItem(store.state, axisType, defaultAxisId, false),
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
store.actions.tooltip.setMouseOverAxisIndex({
|
|
102
|
+
activeIndex: "1",
|
|
103
|
+
activeDataKey: undefined,
|
|
104
|
+
activeCoordinate: { x: 30, y: 30 },
|
|
105
|
+
});
|
|
106
|
+
flush();
|
|
107
|
+
|
|
108
|
+
axes.forEach((axisType, i) => {
|
|
109
|
+
const prev = before[i]!;
|
|
110
|
+
expect(selectNumericalDomain(store.state, axisType, defaultAxisId, false)).toBe(
|
|
111
|
+
prev.numericalDomain,
|
|
112
|
+
);
|
|
113
|
+
expect(selectAxisDomain(store.state, axisType, defaultAxisId, false)).toBe(prev.axisDomain);
|
|
114
|
+
expect(selectAxisScale(store.state, axisType, defaultAxisId, false)).toBe(prev.scale);
|
|
115
|
+
expect(selectTicksOfGraphicalItem(store.state, axisType, defaultAxisId, false)).toBe(
|
|
116
|
+
prev.ticks,
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("DOES invalidate when the chart data changes (correctness)", () => {
|
|
122
|
+
const store = renderChartAndCaptureStore();
|
|
123
|
+
const before = selectAllAppliedValues(store.state, "xAxis", defaultAxisId, false);
|
|
124
|
+
|
|
125
|
+
store.actions.chartData.setChartData([
|
|
126
|
+
{ name: "a", uv: 11 },
|
|
127
|
+
{ name: "b", uv: 31 },
|
|
128
|
+
{ name: "c", uv: 21 },
|
|
129
|
+
]);
|
|
130
|
+
flush();
|
|
131
|
+
|
|
132
|
+
const after = selectAllAppliedValues(store.state, "xAxis", defaultAxisId, false);
|
|
133
|
+
expect(after).not.toBe(before);
|
|
134
|
+
expect(after.map((v) => v.value)).toEqual(["a", "b", "c"]);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Solid-native store actions; tooltip selector exports live in tooltipSelectors.
|
|
4
4
|
import { createEffect, flush } from "solid-js";
|
|
5
5
|
import { describe, expect, it, test, vi } from "vitest";
|
|
6
|
-
import { render } from "
|
|
6
|
+
import { render } from "@solidjs/testing-library";
|
|
7
7
|
import { RechartsStoreProvider } from "../../../src/state/RechartsStoreProvider";
|
|
8
8
|
import { createRechartsStore, type RechartsRootState } from "../../../src/state/store";
|
|
9
9
|
import { arrayTooltipSearcher } from "../../../src/state/optionsSlice";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { scaleLinear, scaleBand } from "
|
|
2
|
+
import { scaleLinear, scaleBand } from "d3-scale";
|
|
3
3
|
import { getAngledRectangleWidth, normalizeAngle } from "../../../src/util/CartesianUtils";
|
|
4
4
|
import { rechartsScaleFactory } from "../../../src/util/scale/RechartsScale";
|
|
5
5
|
import { CartesianScaleHelperImpl } from "../../../src/util/scale/CartesianScaleHelper";
|
|
@@ -79,5 +79,19 @@ describe("getCateCoordinateOfLine", () => {
|
|
|
79
79
|
});
|
|
80
80
|
expect(actual).toBe(18);
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
it("should not match NaN tick values and should fall back to the indexed tick", () => {
|
|
84
|
+
const actual = getCateCoordinateOfLine({
|
|
85
|
+
axis: { type: "category", dataKey: "foo", scale: mockScale },
|
|
86
|
+
bandSize: 4,
|
|
87
|
+
entry: { foo: NaN },
|
|
88
|
+
index: 0,
|
|
89
|
+
ticks: [
|
|
90
|
+
{ coordinate: 8, index: 0, value: "fallback" },
|
|
91
|
+
{ coordinate: 16, index: 1, value: NaN },
|
|
92
|
+
],
|
|
93
|
+
});
|
|
94
|
+
expect(actual).toBe(10);
|
|
95
|
+
});
|
|
82
96
|
});
|
|
83
97
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Ported from recharts 3.8.1 test/util/DomUtils.spec.tsx.
|
|
2
2
|
// Harness changes only: render from the local Solid shim (thunk), no React
|
|
3
3
|
// import. Assertions are byte-identical to recharts.
|
|
4
|
-
import { render } from "
|
|
4
|
+
import { render } from "@solidjs/testing-library";
|
|
5
5
|
import {
|
|
6
6
|
getStringSize,
|
|
7
7
|
clearStringCache,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// <Shape>/<Layer> emits `<g class="recharts-layer recharts-active-shape">`, so
|
|
7
7
|
// `toHaveClass('recharts-active-shape')` (substring-class match) still holds.
|
|
8
8
|
import { describe, expect, it } from "vitest";
|
|
9
|
-
import { render } from "
|
|
9
|
+
import { render } from "@solidjs/testing-library";
|
|
10
10
|
import { FunnelTrapezoid, type FunnelTrapezoidProps } from "../../src/util/FunnelUtils";
|
|
11
11
|
import type { Coordinate, TrapezoidViewBox } from "../../src/util/types";
|
|
12
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Ported from recharts 3.8.1 test/util/scale/createCategoricalInverse.spec.ts (commit 7a23854).
|
|
2
2
|
import { describe, it, expect } from "vitest";
|
|
3
|
-
import { scaleLinear } from "
|
|
3
|
+
import { scaleLinear } from "d3-scale";
|
|
4
4
|
import { bisect, createCategoricalInverse } from "../../../src/util/scale/createCategoricalInverse";
|
|
5
5
|
import { CustomScaleDefinition } from "../../../src/util/scale/CustomScaleDefinition";
|
|
6
6
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// values are byte-identical to recharts.
|
|
8
8
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
9
9
|
import { flush } from "solid-js";
|
|
10
|
-
import { renderHook } from "
|
|
10
|
+
import { renderHook } from "@solidjs/testing-library";
|
|
11
11
|
import { useElementOffset } from "../../src/util/useElementOffset";
|
|
12
12
|
import { getMockDomRect } from "../helper/mockGetBoundingClientRect";
|
|
13
13
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// an Accessor, so the value is read via `result()` where React wrote
|
|
4
4
|
// `result.current`. Assertions/mocks are otherwise byte-identical.
|
|
5
5
|
import { test } from "vitest";
|
|
6
|
-
import { renderHook } from "
|
|
6
|
+
import { renderHook } from "@solidjs/testing-library";
|
|
7
7
|
|
|
8
8
|
import { usePrefersReducedMotion } from "../../src/util/usePrefersReducedMotion";
|
|
9
9
|
import { Global } from "../../src/util/Global";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// spec's structure; the stability assertions hold by construction. Assertions
|
|
6
6
|
// are otherwise byte-identical.
|
|
7
7
|
import { describe, it, expect } from "vitest";
|
|
8
|
-
import { renderHook } from "
|
|
8
|
+
import { renderHook } from "@solidjs/testing-library";
|
|
9
9
|
import { useUniqueId } from "../../src/util/useUniqueId";
|
|
10
10
|
import { useIdFallback } from "../../src/util/useId";
|
|
11
11
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// `store.actions.zIndex.registerZIndexPortal(…)` + `flush()`.
|
|
11
11
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
12
12
|
import { flush } from "solid-js";
|
|
13
|
-
import { render } from "
|
|
13
|
+
import { render } from "@solidjs/testing-library";
|
|
14
14
|
import { RechartsStoreContext } from "../../src/state/RechartsStoreContext";
|
|
15
15
|
import { AllZIndexPortals } from "../../src/zIndex/ZIndexPortal";
|
|
16
16
|
import { createRechartsStore, type RechartsStore } from "../../src/state/store";
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { describe, it, expect } from "vitest";
|
|
14
14
|
import { createSignal, flush } from "solid-js";
|
|
15
15
|
import { LineChart, Line, XAxis, YAxis } from "../../src";
|
|
16
|
-
import { fireEvent, render, screen } from "
|
|
16
|
+
import { fireEvent, render, screen } from "@solidjs/testing-library";
|
|
17
17
|
|
|
18
18
|
describe("Dynamic zIndex updates", () => {
|
|
19
19
|
it("should keep the line in the DOM when zIndex changes dynamically", () => {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { describe, expect, it } from "vitest";
|
|
10
10
|
import { createSignal, flush } from "solid-js";
|
|
11
11
|
import type { JSX } from "@solidjs/web";
|
|
12
|
-
import { render, fireEvent } from "
|
|
12
|
+
import { render, fireEvent } from "@solidjs/testing-library";
|
|
13
13
|
import { BarChart, Bar } from "../../src";
|
|
14
14
|
import type { AnimationController } from "../../src";
|
|
15
15
|
import { AnimationControllerProvider } from "../../src/animation/useAnimationController";
|
|
@@ -10,7 +10,7 @@ import { describe, expect, it } from "vitest";
|
|
|
10
10
|
import { createSignal, flush, Show } from "solid-js";
|
|
11
11
|
import { Bar, BarChart, Pie, PieChart } from "../../src";
|
|
12
12
|
import { assertNotNull } from "../helper/assertNotNull";
|
|
13
|
-
import { render } from "
|
|
13
|
+
import { render } from "@solidjs/testing-library";
|
|
14
14
|
|
|
15
15
|
const barData = [
|
|
16
16
|
{ name: "a", uv: 100 },
|
package/NEXT_SESSION_PROMPT.md
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# Session goal: grow the test suite (and fix what it surfaces)
|
|
2
|
-
|
|
3
|
-
You are continuing a faithful port of **recharts 3.8.1 → SolidJS 2.0** living at
|
|
4
|
-
`/Users/thomas/Downloads/solid-recharts/packages/solid-recharts`. The feature port is ~80%
|
|
5
|
-
complete; **test coverage is the gap** — ~1217 cases vs recharts' ~3658 (~33%). Your job this
|
|
6
|
-
session is to **port reference specs into the Solid suite**, and **fix any real port bugs the
|
|
7
|
-
new tests surface**. Quality over volume: every test must be faithful and must pass for the
|
|
8
|
-
right reason.
|
|
9
|
-
|
|
10
|
-
## The reference
|
|
11
|
-
|
|
12
|
-
recharts 3.8.1 source + tests are checked out at:
|
|
13
|
-
|
|
14
|
-
- `/Users/thomas/Documents/Github/recharts-reference/src`
|
|
15
|
-
- `/Users/thomas/Documents/Github/recharts-reference/test`
|
|
16
|
-
|
|
17
|
-
Port the reference spec's _intent and exact assertions_ (golden numbers, geometry, counts),
|
|
18
|
-
adapting only the React→Solid mechanics.
|
|
19
|
-
|
|
20
|
-
## Non-negotiable conventions (these OVERRIDE defaults)
|
|
21
|
-
|
|
22
|
-
1. **Gate after EVERY change**: `vp check --fix` (lint/format/type — must end at _0 errors_;
|
|
23
|
-
10 warnings is the known steady-state baseline) AND `vp test run` (must stay fully green).
|
|
24
|
-
Do NOT use `npx vitest` — use `vp test run <pattern>`.
|
|
25
|
-
2. **No `any`, no `as`, no non-null `!` in src, no `@ts-expect-error`.** The lint is
|
|
26
|
-
type-aware and WILL catch these (it already caught a bad test this project). Use typed
|
|
27
|
-
coercion / helpers instead.
|
|
28
|
-
3. **Faithful porting.** If a feature is genuinely deferred in the port (check the file's
|
|
29
|
-
header comment), don't assert it — write a _subset_ spec mirroring the existing ported
|
|
30
|
-
specs' style, and note in the spec header which reference assertions you omitted and why.
|
|
31
|
-
If the spec fails because the **port has a real bug or missing-but-claimed feature, FIX the
|
|
32
|
-
port** (faithfully to recharts), don't weaken the test.
|
|
33
|
-
4. **Document deviations** in spec/source header comments (the codebase does this consistently
|
|
34
|
-
— match the surrounding style, comment density, and naming).
|
|
35
|
-
|
|
36
|
-
## Solid 2.0 gotchas that WILL bite (all learned the hard way — see memory)
|
|
37
|
-
|
|
38
|
-
- A global guard in `test/setup.ts` **fails any test on a non-allowlisted Solid diagnostic**
|
|
39
|
-
(STRICT_READ_UNTRACKED etc). Common fixes:
|
|
40
|
-
- Don't read a reactive/accessor value directly in `<Show when={...}>` static children —
|
|
41
|
-
use the accessor-child form `<Show when={obj()}>{(v) => ...}</Show>` with a TRUTHY object
|
|
42
|
-
`when`, OR a plain **ternary** in JSX for a captured non-reactive const (a
|
|
43
|
-
`<Show when={capturedConst}>` still trips STRICT_READ).
|
|
44
|
-
- Bake values into `<For>`-item descriptors; don't render recursive hierarchies via
|
|
45
|
-
components that read reactive `props.*`.
|
|
46
|
-
- **`mouseenter`/`mouseleave` do NOT bubble.** Item handlers live on the wrapping node
|
|
47
|
-
`<Layer>` — `fireEvent.mouseEnter` the Layer `g`, not the inner shape.
|
|
48
|
-
- **Bar item-hover tooltip needs `<Tooltip shared={false}>`** (shared tooltips use the
|
|
49
|
-
axis/mouse path, not item-enter).
|
|
50
|
-
- Solid 2.0 **defers propagation to a flush boundary**: after a sync signal set, a memo read
|
|
51
|
-
in the same tick is stale until `flush()`. Tests call `flush()` after render and after
|
|
52
|
-
`fireEvent`. Use local values (not re-read memos) inside event handlers.
|
|
53
|
-
- Test wrappers: use `props.children`, never destructure `{children}` (breaks the store).
|
|
54
|
-
|
|
55
|
-
## Exact commands
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
cd /Users/thomas/Downloads/solid-recharts/packages/solid-recharts
|
|
59
|
-
vp test run <Name> # run one spec (substring match), e.g. vp test run ChartUtils
|
|
60
|
-
vp test run # full suite (currently 1217 passing / 115 files)
|
|
61
|
-
vp check --fix # the gate (0 errors / 10 warnings = clean)
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Prioritized worklist (port in this order — fastest/safest first)
|
|
65
|
-
|
|
66
|
-
**Tier 1 — pure-function specs (no DOM, no flake, highest value).** These pin exact numeric
|
|
67
|
-
behavior of code we already ship but barely test. Reference paths under `…/recharts-reference/test/`:
|
|
68
|
-
|
|
69
|
-
- `util/ChartUtils.spec.tsx`, `util/BarUtils.spec.tsx`, `util/DataUtils.spec.ts` (extend ours)
|
|
70
|
-
- `util/round.spec.ts`, `util/isWellBehavedNumber.spec.ts`, `util/getRelativeCoordinate.spec.ts`
|
|
71
|
-
- `util/ChartUtils/{truncateByDomain,getStackedData,getCateCoordinateOfLine}.spec.*`
|
|
72
|
-
- `util/scale/{getNiceTickValues,arithmetic,createCategoricalInverse}.spec.ts`
|
|
73
|
-
- `util/cursor/{getCursorRectangle,getCursorPoints,getRadialCursorPoints}.spec.ts`
|
|
74
|
-
- `util/payload/getUniqPayload.spec.ts`, `util/tooltip/translate.spec.ts`
|
|
75
|
-
- `util/CartesianUtils/{CartesianUtils,rectWithPoints}.spec.ts`, `util/PolarUtils.spec.ts`
|
|
76
|
-
- `util/resolveDefaultProps.spec.tsx` (NB: our port uses Solid `merge`, not resolveDefaultProps
|
|
77
|
-
— adapt or skip with a note), `util/isDomainSpecifiedByUser.spec.ts`, `util/TickUtils.spec.ts`
|
|
78
|
-
- Also untested port units with NO ref-named spec but clearly testable: `src/util/getSliced.ts`,
|
|
79
|
-
`getEveryNth.ts`, `getActiveCoordinate.ts`, `YAxisUtils.ts`, `getRadiusAndStrokeWidthFromDot.ts`,
|
|
80
|
-
`ReduceCSSCalc.ts` — write fresh unit specs from the port's behavior + reference src.
|
|
81
|
-
|
|
82
|
-
**Tier 2 — state selectors (test through the store; medium effort).**
|
|
83
|
-
`state/selectors/*.spec.tsx` — `dataSelectors`, `axisSelectors`, `legendSelectors`,
|
|
84
|
-
`lineSelectors`, `pieSelectors`, `scatterSelectors`, `radialBarSelectors`, `selectChartOffset`,
|
|
85
|
-
`combiners/combineActiveTooltipIndex`. Use the existing `test/helper/render` + store patterns.
|
|
86
|
-
|
|
87
|
-
**Tier 3 — component/integration specs (deepen behavior).**
|
|
88
|
-
`component/{Text,Label,LabelList,Legend,DefaultTooltipContent,Cursor,ResponsiveContainer}.spec.tsx`,
|
|
89
|
-
`cartesian/{Area,Line,Bar/Bar,Scatter,CartesianAxis,CartesianGrid,ErrorBar,Brush}.spec.tsx`,
|
|
90
|
-
`polar/{Pie/Pie,Radar,RadialBar/RadialBar,PolarGrid,PolarAngleAxis,PolarRadiusAxis}.spec.tsx`,
|
|
91
|
-
`chart/{ComposedChart,RadarChart,ScatterChart,CategoricalChart}.spec.tsx`. These are big in the
|
|
92
|
-
reference — port the parity-critical subset and document omissions (the existing `*.spec.tsx`
|
|
93
|
-
headers show the house style).
|
|
94
|
-
|
|
95
|
-
## Working rhythm
|
|
96
|
-
|
|
97
|
-
1. Pick the next worklist item. Read the reference spec + the port's source.
|
|
98
|
-
2. Port the spec into the mirrored path under `test/` (match existing naming/structure).
|
|
99
|
-
3. `vp test run <Name>`. If it fails: decide — port bug (fix src faithfully) vs deferred feature
|
|
100
|
-
(subset the spec + document). Never weaken a test to hide a real gap.
|
|
101
|
-
4. `vp check --fix`. Confirm 0 errors.
|
|
102
|
-
5. Periodically run the full `vp test run` to catch cross-file regressions.
|
|
103
|
-
6. Update `MEMORY.md` + a memory file when you learn something non-obvious or finish a cluster.
|
|
104
|
-
|
|
105
|
-
## Context to load first
|
|
106
|
-
|
|
107
|
-
Read the memory index at
|
|
108
|
-
`/Users/thomas/.claude/projects/-Users-thomas-Downloads-solid-recharts/memory/MEMORY.md` and the
|
|
109
|
-
files it points to (especially `expectclean-or-diagnostics-silent.md`,
|
|
110
|
-
`solid2-reactivity-timing.md`, `root-config-and-lint.md`, `custom-shape-render-props.md`) — they
|
|
111
|
-
encode the gate, the diagnostic guard, and the reactivity rules above.
|
|
112
|
-
|
|
113
|
-
Start with **Tier 1** and report progress in batches (files ported, tests added, any port bugs
|
|
114
|
-
fixed). Keep the suite green the whole way.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Ported from recharts 3.8.1 src/state/reduxDevtoolsJsonStringifyReplacer.ts
|
|
2
|
-
// Pure util — no framework surface — behavior is byte-identical to recharts.
|
|
3
|
-
|
|
4
|
-
export function reduxDevtoolsJsonStringifyReplacer(key: string, value: unknown) {
|
|
5
|
-
if (value instanceof HTMLElement) {
|
|
6
|
-
return `HTMLElement <${value.tagName} class="${value.className}">`;
|
|
7
|
-
}
|
|
8
|
-
if (value === window) {
|
|
9
|
-
return "global.window";
|
|
10
|
-
}
|
|
11
|
-
if (key === "children" && typeof value === "object" && value !== null) {
|
|
12
|
-
return "<<CHILDREN>>";
|
|
13
|
-
}
|
|
14
|
-
return value;
|
|
15
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Ported from recharts 3.8.1 src/util/axisPropsAreEqual.ts (commit 7a23854).
|
|
2
|
-
import { AxisRange } from "../state/selectors/axisSelectors";
|
|
3
|
-
import { AxisDomain } from "./types";
|
|
4
|
-
import { propsAreEqual } from "./propsAreEqual";
|
|
5
|
-
|
|
6
|
-
function shortArraysAreEqual(
|
|
7
|
-
arr1: AxisDomain | AxisRange | undefined,
|
|
8
|
-
arr2: AxisDomain | AxisRange | undefined,
|
|
9
|
-
): boolean {
|
|
10
|
-
if (arr1 === arr2) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (Array.isArray(arr1) && arr1.length === 2 && Array.isArray(arr2) && arr2.length === 2) {
|
|
15
|
-
return arr1[0] === arr2[0] && arr1[1] === arr2[1];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function axisPropsAreEqual<
|
|
22
|
-
T extends Record<string, unknown> & {
|
|
23
|
-
domain?: AxisDomain;
|
|
24
|
-
range?: AxisRange;
|
|
25
|
-
},
|
|
26
|
-
>(prevProps: T, nextProps: T): boolean {
|
|
27
|
-
if (prevProps === nextProps) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
const { domain: prevDomain, range: prevRange, ...prevRest } = prevProps;
|
|
31
|
-
const { domain: nextDomain, range: nextRange, ...nextRest } = nextProps;
|
|
32
|
-
|
|
33
|
-
if (!shortArraysAreEqual(prevDomain, nextDomain)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!shortArraysAreEqual(prevRange, nextRange)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return propsAreEqual(prevRest, nextRest);
|
|
42
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// SKIPPED — intentionally NOT ported to the SolidJS port.
|
|
2
|
-
//
|
|
3
|
-
// Reason: React defaultProps shim — use Solid merge()
|
|
4
|
-
//
|
|
5
|
-
// TODO: do not port this file as-is. The Solid-native port replaces it (see the
|
|
6
|
-
// reason above). If a consumer needs this path, wire it to the Solid equivalent
|
|
7
|
-
// instead. Tracked in scripts/porting-queue.mjs SKIP list and project memory.
|
|
8
|
-
export {};
|
package/src/util/typedDataKey.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// SKIPPED — intentionally NOT ported to the SolidJS port.
|
|
2
|
-
//
|
|
3
|
-
// Reason: already inlined as TypedDataKey in util/types.ts
|
|
4
|
-
//
|
|
5
|
-
// TODO: do not port this file as-is. The Solid-native port replaces it (see the
|
|
6
|
-
// reason above). If a consumer needs this path, wire it to the Solid equivalent
|
|
7
|
-
// instead. Tracked in scripts/porting-queue.mjs SKIP list and project memory.
|
|
8
|
-
export {};
|
package/test/helper/render.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Test render helper, backed by the @solid-recharts/testing-library workspace
|
|
2
|
-
// package (a vendored Solid 2.0 port of @solidjs/testing-library — the official
|
|
3
|
-
// 0.8.x still targets Solid 1.x via the removed `solid-js/web` path). Specs
|
|
4
|
-
// import `render`, `cleanup`, and the @testing-library/dom query/event helpers
|
|
5
|
-
// (screen, fireEvent, waitFor, …) from here so there's a single swap point for
|
|
6
|
-
// when the package is published to npm.
|
|
7
|
-
export * from "@solid-recharts/testing-library";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { reduxDevtoolsJsonStringifyReplacer } from "../../src/state/reduxDevtoolsJsonStringifyReplacer";
|
|
3
|
-
|
|
4
|
-
describe("reduxDevtoolsJsonStringifyReplacer", () => {
|
|
5
|
-
it("should return the original value if the value is not an object", () => {
|
|
6
|
-
expect(reduxDevtoolsJsonStringifyReplacer("", "foo")).toBe("foo");
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("should return string if the value is an HTML element", () => {
|
|
10
|
-
const p = document.createElement("p");
|
|
11
|
-
p.classList.add("my-example-class");
|
|
12
|
-
expect(reduxDevtoolsJsonStringifyReplacer("", p)).toBe(
|
|
13
|
-
'HTMLElement <P class="my-example-class">',
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should return string if the value is a global window object", () => {
|
|
18
|
-
/*
|
|
19
|
-
* Firefox devtools throw exceptions when attempting to deeply serialize window object
|
|
20
|
-
* because some of the properties inside belong to another iframe
|
|
21
|
-
* and that other iframe sometimes has cross-origin access limitations.
|
|
22
|
-
*/
|
|
23
|
-
expect(reduxDevtoolsJsonStringifyReplacer("", window)).toBe("global.window");
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// Ported from recharts 3.8.1 test/util/axisPropsAreEqual.spec.ts (commit 7a23854).
|
|
2
|
-
// Solid deviation: the comparator is pure, so tests use plain prop records rather
|
|
3
|
-
// than importing React-oriented axis prop types.
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { axisPropsAreEqual } from "../../src/util/axisPropsAreEqual";
|
|
6
|
-
import { AxisRange } from "../../src/state/selectors/axisSelectors";
|
|
7
|
-
|
|
8
|
-
describe("axisPropsAreEqual", () => {
|
|
9
|
-
it("should return true for identical props", () => {
|
|
10
|
-
const props1 = { xAxisId: 1 };
|
|
11
|
-
const props2 = { xAxisId: 1 };
|
|
12
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("should return false for different props", () => {
|
|
16
|
-
const props1 = { width: "auto" };
|
|
17
|
-
const props2 = { width: "auto", height: "auto" };
|
|
18
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should return false for different nested props", () => {
|
|
22
|
-
const props1 = { mirror: true, padding: { left: 0 } };
|
|
23
|
-
const props2 = { mirror: true, padding: { left: 10 } };
|
|
24
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should return true for same reference nested props", () => {
|
|
28
|
-
const nested = { left: 0 };
|
|
29
|
-
const props1 = { minTickGap: 1, padding: nested };
|
|
30
|
-
const props2 = { minTickGap: 1, padding: nested };
|
|
31
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("should return true for same value, different reference, allowlisted nested props", () => {
|
|
35
|
-
const props1 = { axisLine: { x: 10, y: 20 } };
|
|
36
|
-
const props2 = { axisLine: { x: 10, y: 20 } };
|
|
37
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(true);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("should return false for different value, different reference, allowlisted nested props", () => {
|
|
41
|
-
const props1 = { axisLine: { x: 10, y: 20 } };
|
|
42
|
-
const props2 = { axisLine: { x: 10, y: 30 } };
|
|
43
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should treat undefined and null as if they were equal", () => {
|
|
47
|
-
const props1: { label: null | undefined } = { label: undefined };
|
|
48
|
-
const props2: { label: null | undefined } = { label: null };
|
|
49
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should treat positive and negative zero as equal", () => {
|
|
53
|
-
const props1 = { tickMargin: 0 };
|
|
54
|
-
const props2 = { tickMargin: -0 };
|
|
55
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should treat NaN values as equal", () => {
|
|
59
|
-
const props1 = { angle: NaN };
|
|
60
|
-
const props2 = { angle: NaN };
|
|
61
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should treat two equal domain arrays as equal", () => {
|
|
65
|
-
const props1 = { domain: [0, 100] };
|
|
66
|
-
const props2 = { domain: [0, 100] };
|
|
67
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(true);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("should treat two different domain arrays as different", () => {
|
|
71
|
-
const props1 = { domain: [0, 100] };
|
|
72
|
-
const props2 = { domain: [0, 200] };
|
|
73
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("should treat two equal range arrays as equal", () => {
|
|
77
|
-
const props1: { range: AxisRange } = { range: [0, 500] };
|
|
78
|
-
const props2: { range: AxisRange } = { range: [0, 500] };
|
|
79
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(true);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should treat two different range arrays as different", () => {
|
|
83
|
-
const props1: { range: AxisRange } = { range: [0, 500] };
|
|
84
|
-
const props2: { range: AxisRange } = { range: [0, 600] };
|
|
85
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(false);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("should treat two same categorical domains as different", () => {
|
|
89
|
-
const props1 = { domain: ["a", "b", "c"] };
|
|
90
|
-
const props2 = { domain: ["a", "b", "c"] };
|
|
91
|
-
expect(axisPropsAreEqual(props1, props2)).toBe(false);
|
|
92
|
-
});
|
|
93
|
-
});
|