@octanejs/recharts 0.1.41 → 0.1.43
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 → LICENSE.recharts} +3 -2
- package/README.md +12 -0
- package/package.json +10 -9
- package/src/animation/AnimatedItems.tsrx +36 -3
- package/src/animation/AnimationController.ts +17 -65
- package/src/animation/{AnimationControllerImpl.js → AnimationControllerImpl.ts} +19 -12
- package/src/animation/{AnimationHandle.js → AnimationHandle.ts} +82 -65
- package/src/animation/CSSTransitionAnimate.tsrx +3 -2
- package/src/animation/JavascriptAnimate.tsrx +18 -2
- package/src/animation/easing.ts +235 -0
- package/src/animation/{matchBy.js → matchBy.ts} +76 -120
- package/src/animation/timeoutController.ts +71 -0
- package/src/animation/useAnimationController.ts +4 -1
- package/src/animation/useAnimationStartSnapshot.ts +3 -3
- package/src/animation/util.ts +12 -0
- package/src/cartesian/Area.tsrx +33 -31
- package/src/cartesian/AreaRevealShape.tsrx +4 -3
- package/src/cartesian/Bar.ts +1 -0
- package/src/cartesian/Bar.tsrx +293 -39
- package/src/cartesian/BarStack.tsrx +31 -9
- package/src/cartesian/CartesianAxis.tsrx +154 -22
- package/src/cartesian/CartesianGrid.tsrx +5 -6
- package/src/cartesian/ErrorBar.tsrx +9 -8
- package/src/cartesian/Funnel.tsrx +40 -37
- package/src/cartesian/GraphicalItemClipPath.tsrx +11 -4
- package/src/cartesian/Line.ts +1 -0
- package/src/cartesian/Line.tsrx +206 -28
- package/src/cartesian/LineDrawShape.tsrx +23 -10
- package/src/cartesian/ReferenceLine.tsrx +8 -8
- package/src/cartesian/Scatter.tsrx +61 -66
- package/src/cartesian/XAxis.tsrx +78 -9
- package/src/cartesian/YAxis.tsrx +85 -12
- package/src/cartesian/getCartesianPosition.ts +265 -0
- package/src/cartesian/getEquidistantTicks.ts +144 -0
- package/src/cartesian/getTicks.ts +221 -0
- package/src/chart/AreaChart.tsrx +5 -1
- package/src/chart/BarChart.tsrx +8 -2
- package/src/chart/CartesianChart.tsrx +17 -4
- package/src/chart/CategoricalChart.tsrx +4 -1
- package/src/chart/ComposedChart.tsrx +5 -1
- package/src/chart/FunnelChart.tsrx +5 -1
- package/src/chart/LineChart.tsrx +8 -2
- package/src/chart/PieChart.tsrx +6 -2
- package/src/chart/PolarChart.tsrx +5 -4
- package/src/chart/RadarChart.tsrx +6 -2
- package/src/chart/RadialBarChart.tsrx +6 -2
- package/src/chart/RechartsWrapper.tsrx +57 -21
- package/src/chart/Sankey.tsrx +89 -91
- package/src/chart/ScatterChart.tsrx +5 -1
- package/src/chart/SunburstChart.tsrx +21 -14
- package/src/chart/types.ts +0 -1
- package/src/component/ActivePoints.tsrx +30 -5
- package/src/component/Cell.ts +19 -1
- package/src/component/Cursor.tsrx +11 -10
- package/src/component/DefaultLegendContent.tsrx +15 -10
- package/src/component/DefaultTooltipContent.tsrx +11 -9
- package/src/component/Dots.tsrx +37 -6
- package/src/component/Label.tsrx +99 -19
- package/src/component/LabelList.tsrx +54 -5
- package/src/component/Legend.tsrx +9 -5
- package/src/component/ResponsiveContainer.tsrx +13 -10
- package/src/component/Text.tsrx +95 -32
- package/src/component/Tooltip.tsrx +11 -10
- package/src/component/TooltipBoundingBox.tsrx +4 -5
- package/src/component/{responsiveContainerUtils.js → responsiveContainerUtils.ts} +59 -36
- package/src/container/ClipPathProvider.tsrx +6 -2
- package/src/container/Layer.tsrx +8 -1
- package/src/container/RootSurface.tsrx +15 -4
- package/src/container/Surface.tsrx +15 -1
- package/src/context/CellsContext.ts +6 -5
- package/src/context/ErrorBarContext.tsrx +23 -4
- package/src/context/RegisterGraphicalItemId.tsrx +10 -2
- package/src/context/accessibilityContext.ts +5 -0
- package/src/context/brushUpdateContext.ts +11 -0
- package/src/context/chartDataContext.ts +5 -4
- package/src/context/chartLayoutContext.ts +22 -8
- package/src/context/legendPayloadContext.tsrx +1 -1
- package/src/context/tooltipContext.ts +83 -0
- package/src/{hooks.js → hooks.ts} +88 -66
- package/src/index.ts +37 -37
- package/src/legacy-props.ts +129 -0
- package/src/polar/Pie.tsrx +91 -69
- package/src/polar/PolarAngleAxis.tsrx +47 -47
- package/src/polar/PolarGrid.tsrx +7 -6
- package/src/polar/PolarRadiusAxis.tsrx +29 -21
- package/src/polar/Radar.tsrx +26 -19
- package/src/polar/RadialBar.tsrx +59 -42
- package/src/polar/{defaultPolarAngleAxisProps.js → defaultPolarAngleAxisProps.ts} +6 -6
- package/src/polar/{defaultPolarRadiusAxisProps.js → defaultPolarRadiusAxisProps.ts} +5 -4
- package/src/shape/Cross.tsrx +14 -2
- package/src/shape/Curve.tsrx +111 -23
- package/src/shape/Dot.tsrx +12 -1
- package/src/shape/Polygon.tsrx +28 -6
- package/src/shape/Rectangle.tsrx +30 -3
- package/src/shape/Sector.tsrx +48 -6
- package/src/shape/Symbols.tsrx +24 -6
- package/src/shape/Trapezoid.tsrx +33 -3
- package/src/state/RechartsStoreProvider.tsrx +11 -2
- package/src/state/ReportChartProps.ts +2 -2
- package/src/state/ReportMainChartProps.ts +2 -1
- package/src/state/SetGraphicalItem.ts +6 -4
- package/src/state/SetLegendPayload.ts +7 -4
- package/src/state/SetTooltipEntrySettings.ts +5 -2
- package/src/state/brushSlice.ts +40 -0
- package/src/state/cartesianAxisSlice.ts +291 -0
- package/src/state/chartDataSlice.ts +87 -0
- package/src/state/errorBarSlice.ts +78 -0
- package/src/state/eventSettingsSlice.ts +30 -0
- package/src/state/{externalEventsMiddleware.js → externalEventsMiddleware.ts} +55 -34
- package/src/state/graphicalItemsSlice.ts +180 -0
- package/src/state/{keyboardEventsMiddleware.js → keyboardEventsMiddleware.ts} +72 -57
- package/src/state/layoutSlice.ts +50 -0
- package/src/state/legendSlice.ts +109 -0
- package/src/state/{mouseEventsMiddleware.js → mouseEventsMiddleware.ts} +45 -35
- package/src/state/optionsSlice.ts +65 -0
- package/src/state/polarAxisSlice.ts +42 -0
- package/src/state/polarOptionsSlice.ts +43 -0
- package/src/state/reduxDevtoolsJsonStringifyReplacer.ts +13 -0
- package/src/state/referenceElementsSlice.ts +100 -0
- package/src/state/renderedTicksSlice.ts +60 -0
- package/src/state/rootPropsSlice.ts +72 -0
- package/src/state/selectors/areaSelectors.ts +1 -2
- package/src/state/selectors/{arrayEqualityCheck.js → arrayEqualityCheck.ts} +4 -5
- package/src/state/selectors/axisSelectors.ts +2502 -0
- package/src/state/selectors/barSelectors.ts +373 -0
- package/src/state/selectors/barStackSelectors.ts +99 -0
- package/src/state/selectors/brushSelectors.ts +28 -0
- package/src/state/selectors/combiners/combineActiveLabel.ts +16 -0
- package/src/state/selectors/combiners/{combineActiveTooltipIndex.js → combineActiveTooltipIndex.ts} +45 -23
- package/src/state/selectors/combiners/combineAllBarPositions.ts +130 -0
- package/src/state/selectors/combiners/combineAxisRangeWithReverse.ts +16 -0
- package/src/state/selectors/combiners/combineBarPosition.ts +23 -0
- package/src/state/selectors/combiners/combineBarSizeList.ts +79 -0
- package/src/state/selectors/combiners/{combineCheckedDomain.js → combineCheckedDomain.ts} +9 -6
- package/src/state/selectors/combiners/combineConfiguredScale.ts +100 -0
- package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.ts +46 -0
- package/src/state/selectors/combiners/{combineDisplayedStackedData.js → combineDisplayedStackedData.ts} +23 -19
- package/src/state/selectors/combiners/combineInverseScaleFunction.ts +16 -0
- package/src/state/selectors/combiners/{combineRealScaleType.js → combineRealScaleType.ts} +16 -8
- package/src/state/selectors/combiners/combineStackedData.ts +27 -0
- package/src/state/selectors/combiners/combineTooltipInteractionState.ts +86 -0
- package/src/state/selectors/combiners/combineTooltipPayload.ts +201 -0
- package/src/state/selectors/combiners/{combineTooltipPayloadConfigurations.js → combineTooltipPayloadConfigurations.ts} +17 -18
- package/src/state/selectors/containerSelectors.ts +12 -0
- package/src/state/selectors/{dataSelectors.js → dataSelectors.ts} +43 -41
- package/src/state/selectors/funnelSelectors.ts +5 -5
- package/src/state/selectors/graphicalItemSelectors.ts +22 -0
- package/src/state/selectors/legendSelectors.ts +25 -0
- package/src/state/selectors/lineSelectors.ts +159 -0
- package/src/state/selectors/numberDomainEqualityCheck.ts +15 -0
- package/src/state/selectors/pickAxisId.ts +6 -0
- package/src/state/selectors/pickAxisType.ts +4 -0
- package/src/state/selectors/pieSelectors.ts +14 -13
- package/src/state/selectors/polarAxisSelectors.ts +223 -0
- package/src/state/selectors/polarSelectors.ts +1 -1
- package/src/state/selectors/radarSelectors.ts +1 -1
- package/src/state/selectors/radialBarSelectors.ts +17 -16
- package/src/state/selectors/rootPropsSelectors.ts +26 -0
- package/src/state/selectors/scatterSelectors.ts +11 -10
- package/src/state/selectors/{selectActivePropsFromChartPointer.js → selectActivePropsFromChartPointer.ts} +11 -4
- package/src/state/selectors/selectAllAxes.ts +20 -0
- package/src/state/selectors/selectChartOffset.ts +17 -0
- package/src/state/selectors/selectChartOffsetInternal.ts +147 -0
- package/src/state/selectors/{selectPlotArea.js → selectPlotArea.ts} +4 -3
- package/src/state/selectors/selectTooltipAxisId.ts +6 -0
- package/src/state/selectors/{selectTooltipAxisType.js → selectTooltipAxisType.ts} +10 -4
- package/src/state/selectors/selectTooltipEventType.ts +39 -0
- package/src/state/selectors/selectTooltipPayloadSearcher.ts +6 -0
- package/src/state/selectors/selectTooltipSettings.ts +6 -0
- package/src/state/selectors/selectTooltipState.ts +5 -0
- package/src/state/selectors/selectors.ts +315 -0
- package/src/state/selectors/tooltipSelectors.ts +611 -0
- package/src/state/selectors/touchSelectors.ts +52 -0
- package/src/state/{store.js → store.ts} +46 -36
- package/src/state/tooltipSlice.ts +507 -0
- package/src/state/{touchEventsMiddleware.js → touchEventsMiddleware.ts} +54 -42
- package/src/state/types/AreaSettings.ts +15 -0
- package/src/state/types/BarSettings.ts +15 -0
- package/src/state/types/LineSettings.ts +10 -0
- package/src/state/types/PieSettings.ts +32 -0
- package/src/state/types/RadarSettings.ts +6 -0
- package/src/state/types/RadialBarSettings.ts +10 -0
- package/src/state/types/ScatterSettings.ts +13 -0
- package/src/state/types/StackedGraphicalItem.ts +34 -0
- package/src/state/zIndexSlice.ts +137 -0
- package/src/synchronisation/syncSelectors.ts +7 -0
- package/src/synchronisation/types.ts +42 -0
- package/src/synchronisation/useChartSynchronisation.tsrx +26 -11
- package/src/types.ts +55 -0
- package/src/util/ActiveShapeUtils.tsrx +34 -10
- package/src/util/BarUtils.tsrx +43 -3
- package/src/util/{CartesianUtils.js → CartesianUtils.ts} +22 -39
- package/src/util/ChartUtils.ts +759 -0
- package/src/util/{Constants.js → Constants.ts} +6 -6
- package/src/util/DOMUtils.ts +135 -0
- package/src/util/{DataUtils.js → DataUtils.ts} +120 -47
- package/src/util/Events.ts +22 -0
- package/src/util/FunnelUtils.tsrx +3 -3
- package/src/util/Global.ts +13 -0
- package/src/util/IfOverflow.ts +16 -0
- package/src/util/LRUCache.ts +42 -0
- package/src/util/{LogUtils.js → LogUtils.ts} +7 -12
- package/src/util/OctaneTypes.ts +51 -0
- package/src/util/PolarUtils.ts +132 -0
- package/src/util/RadialBarUtils.tsrx +3 -3
- package/src/util/ReduceCSSCalc.ts +186 -0
- package/src/util/ScatterUtils.tsrx +9 -7
- package/src/util/{TickUtils.js → TickUtils.ts} +30 -13
- package/src/util/{YAxisUtils.js → YAxisUtils.ts} +27 -17
- package/src/util/axisPropsAreEqual.ts +49 -0
- package/src/util/createEventProxy.ts +20 -0
- package/src/util/{excludeEventProps.js → excludeEventProps.ts} +8 -6
- package/src/util/getActiveCoordinate.ts +210 -0
- package/src/util/{getAxisTypeBasedOnLayout.js → getAxisTypeBasedOnLayout.ts} +7 -3
- package/src/util/getClassNameFromUnknown.ts +7 -0
- package/src/util/{getEveryNth.js → getEveryNth.ts} +5 -6
- package/src/util/getRadiusAndStrokeWidthFromDot.ts +31 -0
- package/src/util/{getRelativeCoordinate.js → getRelativeCoordinate.ts} +26 -9
- package/src/util/getSliced.ts +14 -0
- package/src/util/{isDomainSpecifiedByUser.js → isDomainSpecifiedByUser.ts} +46 -100
- package/src/util/isWellBehavedNumber.ts +8 -0
- package/src/util/payload/getUniqPayload.ts +1 -1
- package/src/util/{propsAreEqual.js → propsAreEqual.ts} +10 -8
- package/src/util/{resolveDefaultProps.js → resolveDefaultProps.ts} +35 -57
- package/src/util/round.ts +33 -0
- package/src/util/scale/CustomScaleDefinition.ts +82 -0
- package/src/util/scale/RechartsScale.ts +131 -0
- package/src/util/scale/{createCategoricalInverse.js → createCategoricalInverse.ts} +24 -29
- package/src/util/scale/{getNiceTickValues.js → getNiceTickValues.ts} +125 -146
- package/src/util/scale/index.ts +2 -0
- package/src/util/scale/util/{arithmetic.js → arithmetic.ts} +12 -8
- package/src/util/stacks/getStackSeriesIdentifier.ts +21 -0
- package/src/util/stacks/stackTypes.ts +58 -0
- package/src/util/{svgPropertiesNoEvents.js → svgPropertiesNoEvents.ts} +52 -27
- package/src/util/tooltip/translate.ts +2 -1
- package/src/util/typedDataKey.ts +49 -0
- package/src/util/types.ts +1265 -7
- package/src/util/{useUniqueId.js → useUniqueId.ts} +9 -5
- package/src/zIndex/{DefaultZIndexes.js → DefaultZIndexes.ts} +13 -4
- package/src/zIndex/ZIndexLayer.tsrx +13 -4
- package/src/zIndex/ZIndexPortal.tsrx +14 -4
- package/src/zIndex/{getZIndexFromUnknown.js → getZIndexFromUnknown.ts} +3 -3
- package/src/zIndex/{zIndexSelectors.js → zIndexSelectors.ts} +17 -11
- package/src/animation/easing.js +0 -193
- package/src/animation/timeoutController.js +0 -49
- package/src/animation/util.js +0 -11
- package/src/cartesian/Area.tsrx.d.ts +0 -340
- package/src/cartesian/Bar.tsrx.d.ts +0 -4
- package/src/cartesian/BarStack.tsrx.d.ts +0 -6
- package/src/cartesian/CartesianAxis.tsrx.d.ts +0 -3
- package/src/cartesian/CartesianGrid.tsrx.d.ts +0 -219
- package/src/cartesian/ErrorBar.tsrx.d.ts +0 -131
- package/src/cartesian/Funnel.tsrx.d.ts +0 -274
- package/src/cartesian/Line.tsrx.d.ts +0 -4
- package/src/cartesian/LineDrawShape.tsrx.d.ts +0 -2
- package/src/cartesian/ReferenceLine.tsrx.d.ts +0 -178
- package/src/cartesian/Scatter.tsrx.d.ts +0 -351
- package/src/cartesian/XAxis.tsrx.d.ts +0 -3
- package/src/cartesian/YAxis.tsrx.d.ts +0 -3
- package/src/cartesian/ZAxis.tsrx.d.ts +0 -102
- package/src/cartesian/getCartesianPosition.js +0 -277
- package/src/cartesian/getEquidistantTicks.js +0 -133
- package/src/cartesian/getTicks.js +0 -280
- package/src/chart/AreaChart.tsrx.d.ts +0 -12
- package/src/chart/BarChart.tsrx.d.ts +0 -2
- package/src/chart/CartesianChart.tsrx.d.ts +0 -10
- package/src/chart/ComposedChart.tsrx.d.ts +0 -12
- package/src/chart/FunnelChart.tsrx.d.ts +0 -12
- package/src/chart/LineChart.tsrx.d.ts +0 -2
- package/src/chart/PieChart.tsrx.d.ts +0 -31
- package/src/chart/RadarChart.tsrx.d.ts +0 -31
- package/src/chart/RadialBarChart.tsrx.d.ts +0 -31
- package/src/chart/Sankey.tsrx.d.ts +0 -253
- package/src/chart/ScatterChart.tsrx.d.ts +0 -12
- package/src/chart/SunburstChart.tsrx.d.ts +0 -146
- package/src/component/DefaultLegendContent.tsrx.d.ts +0 -125
- package/src/component/DefaultTooltipContent.tsrx.d.ts +0 -87
- package/src/component/Label.tsrx.d.ts +0 -12
- package/src/component/LabelList.tsrx.d.ts +0 -8
- package/src/component/Legend.tsrx.d.ts +0 -88
- package/src/component/ResponsiveContainer.tsrx.d.ts +0 -81
- package/src/component/Text.tsrx.d.ts +0 -9
- package/src/component/Tooltip.tsrx.d.ts +0 -246
- package/src/container/Layer.tsrx.d.ts +0 -6
- package/src/container/Surface.tsrx.d.ts +0 -12
- package/src/context/accessibilityContext.js +0 -10
- package/src/context/tooltipContext.js +0 -55
- package/src/index.d.ts +0 -281
- package/src/polar/Pie.tsrx.d.ts +0 -436
- package/src/polar/PolarAngleAxis.tsrx.d.ts +0 -215
- package/src/polar/PolarGrid.tsrx.d.ts +0 -117
- package/src/polar/PolarRadiusAxis.tsrx.d.ts +0 -209
- package/src/polar/Radar.tsrx.d.ts +0 -215
- package/src/polar/RadialBar.tsrx.d.ts +0 -340
- package/src/shape/Cross.tsrx.d.ts +0 -12
- package/src/shape/Curve.tsrx.d.ts +0 -42
- package/src/shape/Dot.tsrx.d.ts +0 -9
- package/src/shape/Polygon.tsrx.d.ts +0 -13
- package/src/shape/Rectangle.tsrx.d.ts +0 -31
- package/src/shape/Sector.tsrx.d.ts +0 -29
- package/src/shape/Symbols.tsrx.d.ts +0 -15
- package/src/shape/Trapezoid.tsrx.d.ts +0 -29
- package/src/state/brushSlice.js +0 -36
- package/src/state/cartesianAxisSlice.js +0 -256
- package/src/state/chartDataSlice.js +0 -67
- package/src/state/errorBarSlice.js +0 -53
- package/src/state/eventSettingsSlice.js +0 -25
- package/src/state/graphicalItemsSlice.js +0 -91
- package/src/state/layoutSlice.js +0 -57
- package/src/state/legendSlice.js +0 -83
- package/src/state/optionsSlice.js +0 -45
- package/src/state/polarAxisSlice.js +0 -33
- package/src/state/polarOptionsSlice.js +0 -26
- package/src/state/reduxDevtoolsJsonStringifyReplacer.js +0 -14
- package/src/state/referenceElementsSlice.js +0 -51
- package/src/state/renderedTicksSlice.js +0 -41
- package/src/state/rootPropsSlice.js +0 -48
- package/src/state/selectors/axisSelectors.js +0 -2113
- package/src/state/selectors/barSelectors.js +0 -263
- package/src/state/selectors/barStackSelectors.js +0 -65
- package/src/state/selectors/brushSelectors.js +0 -21
- package/src/state/selectors/combiners/combineActiveLabel.js +0 -18
- package/src/state/selectors/combiners/combineAllBarPositions.js +0 -169
- package/src/state/selectors/combiners/combineAxisRangeWithReverse.js +0 -11
- package/src/state/selectors/combiners/combineBarPosition.js +0 -17
- package/src/state/selectors/combiners/combineBarSizeList.js +0 -115
- package/src/state/selectors/combiners/combineConfiguredScale.js +0 -46
- package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.js +0 -48
- package/src/state/selectors/combiners/combineInverseScaleFunction.js +0 -12
- package/src/state/selectors/combiners/combineStackedData.js +0 -22
- package/src/state/selectors/combiners/combineTooltipInteractionState.js +0 -121
- package/src/state/selectors/combiners/combineTooltipPayload.js +0 -248
- package/src/state/selectors/containerSelectors.js +0 -6
- package/src/state/selectors/graphicalItemSelectors.js +0 -25
- package/src/state/selectors/legendSelectors.js +0 -18
- package/src/state/selectors/lineSelectors.js +0 -106
- package/src/state/selectors/numberDomainEqualityCheck.js +0 -11
- package/src/state/selectors/pickAxisId.js +0 -3
- package/src/state/selectors/pickAxisType.js +0 -3
- package/src/state/selectors/polarAxisSelectors.js +0 -237
- package/src/state/selectors/rootPropsSelectors.js +0 -13
- package/src/state/selectors/selectAllAxes.js +0 -15
- package/src/state/selectors/selectChartOffset.js +0 -12
- package/src/state/selectors/selectChartOffsetInternal.js +0 -174
- package/src/state/selectors/selectTooltipAxisId.js +0 -3
- package/src/state/selectors/selectTooltipEventType.js +0 -27
- package/src/state/selectors/selectTooltipPayloadSearcher.js +0 -3
- package/src/state/selectors/selectTooltipSettings.js +0 -3
- package/src/state/selectors/selectTooltipState.js +0 -3
- package/src/state/selectors/selectors.js +0 -222
- package/src/state/selectors/tooltipSelectors.js +0 -471
- package/src/state/selectors/touchSelectors.js +0 -31
- package/src/state/tooltipSlice.js +0 -237
- package/src/state/types/StackedGraphicalItem.js +0 -18
- package/src/state/zIndexSlice.js +0 -167
- package/src/synchronisation/syncSelectors.js +0 -5
- package/src/util/ChartUtils.js +0 -630
- package/src/util/DOMUtils.js +0 -180
- package/src/util/Events.js +0 -7
- package/src/util/Global.js +0 -13
- package/src/util/LRUCache.js +0 -58
- package/src/util/PolarUtils.js +0 -190
- package/src/util/ReduceCSSCalc.js +0 -260
- package/src/util/axisPropsAreEqual.js +0 -63
- package/src/util/createEventProxy.js +0 -18
- package/src/util/getActiveCoordinate.js +0 -253
- package/src/util/getClassNameFromUnknown.js +0 -8
- package/src/util/getRadiusAndStrokeWidthFromDot.js +0 -28
- package/src/util/getSliced.js +0 -11
- package/src/util/isWellBehavedNumber.js +0 -8
- package/src/util/round.js +0 -39
- package/src/util/scale/RechartsScale.js +0 -68
- package/src/util/scale/index.js +0 -3
- package/src/util/stacks/getStackSeriesIdentifier.js +0 -10
- package/src/zIndex/ZIndexLayer.tsrx.d.ts +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
MIT License
|
|
1
|
+
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2015-present recharts
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -13,6 +13,18 @@ byte-identical to upstream in the differential rig. The phased plan lives in
|
|
|
13
13
|
import { BarChart, Bar, XAxis, YAxis } from '@octanejs/recharts';
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## TypeScript
|
|
17
|
+
|
|
18
|
+
The package exports authored TypeScript and `.tsrx` source, including its component
|
|
19
|
+
prop types. Check applications with `tsrx-tsc --noEmit` and the
|
|
20
|
+
`octane/compiler/volar` compiler configured by the Octane CLI. Plain `tsc` does not
|
|
21
|
+
check `.tsrx` implementations.
|
|
22
|
+
|
|
23
|
+
The package is checked with `strict: true`, `skipLibCheck: false`, and no Node
|
|
24
|
+
ambient types. `BarProps`, `PieProps`, and the other component prop exports come
|
|
25
|
+
from the implementations, not a separate declaration facade. Events use native
|
|
26
|
+
DOM types, and refs use Octane's ref-as-prop contract.
|
|
27
|
+
|
|
16
28
|
## Status
|
|
17
29
|
|
|
18
30
|
Current scope, known divergences, and verification status are tracked in the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/recharts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.43",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -21,31 +21,32 @@
|
|
|
21
21
|
},
|
|
22
22
|
"main": "src/index.ts",
|
|
23
23
|
"module": "src/index.ts",
|
|
24
|
-
"types": "src/index.
|
|
24
|
+
"types": "src/index.ts",
|
|
25
25
|
"files": [
|
|
26
26
|
"src",
|
|
27
|
-
"README.md"
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE.recharts"
|
|
28
29
|
],
|
|
29
30
|
"exports": {
|
|
30
31
|
".": {
|
|
31
|
-
"types": "./src/index.
|
|
32
|
+
"types": "./src/index.ts",
|
|
32
33
|
"default": "./src/index.ts"
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@reduxjs/toolkit": "
|
|
37
|
+
"@reduxjs/toolkit": "~2.10.1",
|
|
37
38
|
"clsx": "^2.1.1",
|
|
38
39
|
"decimal.js-light": "^2.5.1",
|
|
39
40
|
"es-toolkit": "^1.49.0",
|
|
40
41
|
"eventemitter3": "^5.0.4",
|
|
41
|
-
"immer": "^
|
|
42
|
+
"immer": "^10.2.0",
|
|
42
43
|
"reselect": "5.2.0",
|
|
43
44
|
"tiny-invariant": "^1.3.3",
|
|
44
45
|
"victory-vendor": "^37.3.6",
|
|
45
|
-
"@octanejs/redux": "0.1.
|
|
46
|
+
"@octanejs/redux": "0.1.43"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"octane": "0.1.
|
|
49
|
+
"octane": "0.1.46"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@tsrx/react": "^0.2.58",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"react-dom": "^19.2.7",
|
|
55
56
|
"recharts": "3.9.2",
|
|
56
57
|
"vitest": "^4.1.10",
|
|
57
|
-
"octane": "0.1.
|
|
58
|
+
"octane": "0.1.46"
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
61
|
"test": "vitest run"
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
import type { MutableRefObject, OctaneNode } from '../util/OctaneTypes.ts';
|
|
2
|
+
import type { EasingInput } from './easing';
|
|
3
|
+
import type { AnimationItem, AnimationMatchByProp } from './matchBy';
|
|
4
|
+
import type { CartesianLayout, PolarLayout } from '../util/types';
|
|
5
|
+
|
|
6
|
+
export type AnimationInterpolateFn<ItemType, LayoutType extends CartesianLayout | PolarLayout> =
|
|
7
|
+
(items: | ReadonlyArray<AnimationItem<ItemType>>
|
|
8
|
+
| null, animationElapsedTime: number, layout: LayoutType) => ReadonlyArray<ItemType>;
|
|
9
|
+
export type AnimatedItemsProps<ItemType, LayoutType extends CartesianLayout | PolarLayout> = {
|
|
10
|
+
animationInput: unknown;
|
|
11
|
+
animationIdPrefix: string;
|
|
12
|
+
items: ReadonlyArray<ItemType> | undefined;
|
|
13
|
+
previousItemsRef: MutableRefObject<ReadonlyArray<ItemType> | null | undefined>;
|
|
14
|
+
isAnimationActive: boolean | 'auto';
|
|
15
|
+
animationBegin: number;
|
|
16
|
+
animationDuration: number;
|
|
17
|
+
animationEasing: EasingInput;
|
|
18
|
+
onAnimationStart?: () => void;
|
|
19
|
+
onAnimationEnd?: () => void;
|
|
20
|
+
animationInterpolateFn: AnimationInterpolateFn<ItemType, LayoutType>;
|
|
21
|
+
animationMatchBy?: AnimationMatchByProp<ItemType>;
|
|
22
|
+
shouldUpdatePreviousRef?: (animationElapsedTime: number) => boolean;
|
|
23
|
+
children: (items: ReadonlyArray<
|
|
24
|
+
ItemType
|
|
25
|
+
>, animationElapsedTime: number, isEntrance: boolean) => OctaneNode;
|
|
26
|
+
layout: LayoutType;
|
|
27
|
+
};
|
|
1
28
|
// Port of animation/AnimatedItems.tsx — the reusable enter/update/exit
|
|
2
29
|
// animation wrapper for array-based chart data (Bar, Line, Area, Pie, …).
|
|
3
30
|
import { useCallback, useState } from 'octane';
|
|
@@ -9,7 +36,7 @@ import { useAnimationStartSnapshot } from './useAnimationStartSnapshot.ts';
|
|
|
9
36
|
/**
|
|
10
37
|
* Tracks animation state and provides callbacks for animation start/end.
|
|
11
38
|
*/
|
|
12
|
-
export function useAnimationCallbacks(onAnimationStart, onAnimationEnd) {
|
|
39
|
+
export function useAnimationCallbacks(onAnimationStart?: () => void, onAnimationEnd?: () => void) {
|
|
13
40
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
14
41
|
const handleAnimationStart = useCallback(() => {
|
|
15
42
|
if (typeof onAnimationStart === 'function') {
|
|
@@ -30,7 +57,9 @@ export function useAnimationCallbacks(onAnimationStart, onAnimationEnd) {
|
|
|
30
57
|
};
|
|
31
58
|
}
|
|
32
59
|
|
|
33
|
-
export function AnimatedItems(
|
|
60
|
+
export function AnimatedItems<ItemType, LayoutType extends CartesianLayout | PolarLayout>(
|
|
61
|
+
props: AnimatedItemsProps<ItemType, LayoutType>,
|
|
62
|
+
) {
|
|
34
63
|
const {
|
|
35
64
|
animationInput,
|
|
36
65
|
animationIdPrefix,
|
|
@@ -51,7 +80,11 @@ export function AnimatedItems(props) {
|
|
|
51
80
|
const animationId = useAnimationId(animationInput, animationIdPrefix);
|
|
52
81
|
const animationStartItems = useAnimationStartSnapshot(animationId, previousItemsRef);
|
|
53
82
|
const rawPrevItems = animationStartItems.startValue ?? null;
|
|
54
|
-
const animationItems = matchAnimationItems(
|
|
83
|
+
const animationItems: ReadonlyArray<AnimationItem<ItemType>> | null = matchAnimationItems(
|
|
84
|
+
rawPrevItems,
|
|
85
|
+
items,
|
|
86
|
+
animationMatchBy ?? matchByIndex,
|
|
87
|
+
);
|
|
55
88
|
return <JavascriptAnimate
|
|
56
89
|
animationId={animationId}
|
|
57
90
|
begin={animationBegin}
|
|
@@ -1,73 +1,25 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// `CSSTransitionAnimate` importing a module that does not exist.
|
|
5
|
-
//
|
|
6
|
-
// `TimeoutController`, `CallbackType` and `CancelableTimeout` live in
|
|
7
|
-
// `animation/timeoutController.ts` upstream, and `AnimationHandle` is exported
|
|
8
|
-
// as a type from `animation/AnimationHandle.ts`. Both of those modules are
|
|
9
|
-
// vendored here as compiled `.js`, which carries their runtime classes but
|
|
10
|
-
// erases every type-only export, so they cannot be imported by name yet. They
|
|
11
|
-
// are co-located here until those two modules are typed; move them back to
|
|
12
|
-
// their upstream homes at that point rather than growing this module.
|
|
13
|
-
import type { CSSTransitionAnimation, JavascriptAnimation } from './AnimationHandle';
|
|
1
|
+
// Adapted from recharts@3.9.2, commit b3451050c027a23957ffa50a2665c9119df21e47.
|
|
2
|
+
import type { CancelableTimeout, TimeoutController } from './timeoutController';
|
|
3
|
+
import { AnimationHandle } from './AnimationHandle';
|
|
14
4
|
|
|
15
5
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
export type CallbackType = (now: number) => void;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* A function that, when called, cancels the timeout.
|
|
23
|
-
*
|
|
24
|
-
* @since 3.9
|
|
25
|
-
*/
|
|
26
|
-
export type CancelableTimeout = () => void;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* TimeoutController is responsible for controlling the movement of time.
|
|
30
|
-
* Think of it as a clock.
|
|
31
|
-
*
|
|
32
|
-
* Recharts default implementation uses requestAnimationFrame which works great
|
|
33
|
-
* in a browser. You may choose to override this which is especially useful if
|
|
34
|
-
* you want to control animations.
|
|
35
|
-
*
|
|
36
|
-
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animation guide}
|
|
37
|
-
*
|
|
38
|
-
* @since 3.9
|
|
39
|
-
*/
|
|
40
|
-
export interface TimeoutController {
|
|
41
|
-
/**
|
|
42
|
-
* Sets a timeout that executes a callback after a specified delay.
|
|
43
|
-
* Allows setting multiple timeouts and provides a way to cancel them
|
|
44
|
-
* independently.
|
|
45
|
-
*
|
|
46
|
-
* The input (`delay`) is relative — "wait for this long". The output (`now`,
|
|
47
|
-
* the callback's parameter) is absolute — "this is the time now".
|
|
48
|
-
*/
|
|
49
|
-
setTimeout(callback: CallbackType, delay?: number): CancelableTimeout;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Recharts animation state machine.
|
|
6
|
+
* JavaScript animations produce numbers and CSS transitions produce strings.
|
|
7
|
+
* Keep the listener's value type tied to the supplied animation handle.
|
|
54
8
|
*
|
|
55
9
|
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animation guide}
|
|
56
10
|
*
|
|
57
11
|
* @since 3.9
|
|
58
12
|
*/
|
|
59
|
-
export type
|
|
13
|
+
export type OnAnimationStateUpdate<T extends number | string = number | string> = (
|
|
14
|
+
newState: T,
|
|
15
|
+
) => void;
|
|
60
16
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
* @since 3.9
|
|
69
|
-
*/
|
|
70
|
-
export type OnAnimationStateUpdate = (newState: number | string) => void;
|
|
17
|
+
export type AnimationControllerHandle<T extends number | string> = Omit<
|
|
18
|
+
AnimationHandle,
|
|
19
|
+
'getInterpolated'
|
|
20
|
+
> & {
|
|
21
|
+
getInterpolated(): T;
|
|
22
|
+
};
|
|
71
23
|
|
|
72
24
|
/**
|
|
73
25
|
* AnimationController accepts the animation state machine (= RechartsAnimation) plus a timeout controller,
|
|
@@ -83,8 +35,8 @@ export type OnAnimationStateUpdate = (newState: number | string) => void;
|
|
|
83
35
|
*
|
|
84
36
|
* @since 3.9
|
|
85
37
|
*/
|
|
86
|
-
export type AnimationController = (
|
|
38
|
+
export type AnimationController = <T extends number | string>(
|
|
87
39
|
timeoutController: TimeoutController,
|
|
88
|
-
animationHandle:
|
|
89
|
-
listener: OnAnimationStateUpdate
|
|
40
|
+
animationHandle: AnimationControllerHandle<T>,
|
|
41
|
+
listener: OnAnimationStateUpdate<T>,
|
|
90
42
|
) => CancelableTimeout;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// Adapted from recharts@3.9.2, commit b3451050c027a23957ffa50a2665c9119df21e47.
|
|
2
|
+
import {
|
|
3
|
+
AnimationController,
|
|
4
|
+
AnimationControllerHandle,
|
|
5
|
+
OnAnimationStateUpdate,
|
|
6
|
+
} from './AnimationController';
|
|
7
|
+
import { CancelableTimeout, TimeoutController } from './timeoutController';
|
|
8
|
+
|
|
3
9
|
/**
|
|
4
10
|
* JavaScript animations require trigger and repaint as soon as possible,
|
|
5
11
|
* so this class uses the timeoutController to trigger updates as quickly as the controller allows.
|
|
@@ -7,10 +13,14 @@
|
|
|
7
13
|
* JavaScript animation progress is represented as a stream of values. The exact type depends on the animationHandle type.
|
|
8
14
|
* Each individual consumer is then responsible for mapping those values onto a React component.
|
|
9
15
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
export const animationControllerImpl: AnimationController = <T extends number | string>(
|
|
17
|
+
timeoutController: TimeoutController,
|
|
18
|
+
animationHandle: AnimationControllerHandle<T>,
|
|
19
|
+
listener: OnAnimationStateUpdate<T>,
|
|
20
|
+
): CancelableTimeout => {
|
|
21
|
+
let cancellable: CancelableTimeout | undefined;
|
|
22
|
+
const nextUpdate = (now: number) => {
|
|
23
|
+
const timeRemaining = animationHandle.tick(now);
|
|
14
24
|
if (animationHandle.getState() === 'active') {
|
|
15
25
|
listener(animationHandle.getInterpolated());
|
|
16
26
|
if (animationHandle.getProgress() === 1) {
|
|
@@ -23,11 +33,8 @@ export var animationControllerImpl = (timeoutController, animationHandle, listen
|
|
|
23
33
|
}
|
|
24
34
|
cancellable = timeoutController.setTimeout(nextUpdate, timeRemaining);
|
|
25
35
|
};
|
|
36
|
+
|
|
26
37
|
cancellable = timeoutController.setTimeout(nextUpdate, 0);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return (_cancellable = cancellable) === null || _cancellable === void 0
|
|
30
|
-
? void 0
|
|
31
|
-
: _cancellable();
|
|
32
|
-
};
|
|
38
|
+
|
|
39
|
+
return () => cancellable?.();
|
|
33
40
|
};
|
|
@@ -1,54 +1,67 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
-
function _defineProperty(e, r, t) {
|
|
4
|
-
return (
|
|
5
|
-
(r = _toPropertyKey(r)) in e
|
|
6
|
-
? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 })
|
|
7
|
-
: (e[r] = t),
|
|
8
|
-
e
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
function _toPropertyKey(t) {
|
|
12
|
-
var i = _toPrimitive(t, 'string');
|
|
13
|
-
return 'symbol' == typeof i ? i : i + '';
|
|
14
|
-
}
|
|
15
|
-
function _toPrimitive(t, r) {
|
|
16
|
-
if ('object' != typeof t || !t) return t;
|
|
17
|
-
var e = t[Symbol.toPrimitive];
|
|
18
|
-
if (void 0 !== e) {
|
|
19
|
-
var i = e.call(t, r || 'default');
|
|
20
|
-
if ('object' != typeof i) return i;
|
|
21
|
-
throw new TypeError('@@toPrimitive must return a primitive value.');
|
|
22
|
-
}
|
|
23
|
-
return ('string' === r ? String : Number)(t);
|
|
24
|
-
}
|
|
1
|
+
// Adapted from recharts@3.9.2, commit b3451050c027a23957ffa50a2665c9119df21e47.
|
|
25
2
|
// eslint-disable-next-line max-classes-per-file
|
|
26
3
|
import { interpolate } from '../util/DataUtils';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
import { EasingFunction, NamedBezier } from './easing';
|
|
5
|
+
|
|
6
|
+
const INIT = 'init' as const;
|
|
7
|
+
const PENDING = 'pending' as const;
|
|
8
|
+
const ACTIVE = 'active' as const;
|
|
9
|
+
const COMPLETED = 'completed' as const;
|
|
10
|
+
|
|
11
|
+
export type AnimationState = typeof INIT | typeof PENDING | typeof ACTIVE | typeof COMPLETED;
|
|
12
|
+
|
|
13
|
+
type AnimationStateCallback = () => void;
|
|
14
|
+
|
|
15
|
+
function duration(time: number): number {
|
|
32
16
|
return Math.max(0, time);
|
|
33
17
|
}
|
|
34
|
-
|
|
18
|
+
|
|
19
|
+
abstract class RechartsAnimation<T, E> {
|
|
35
20
|
/**
|
|
36
21
|
* Returns the absolute time after the animationBegin delay has been completed,
|
|
37
22
|
* and when the animationDuration started ticking.
|
|
38
23
|
*/
|
|
39
|
-
getAnimationStartedTime() {
|
|
24
|
+
public getAnimationStartedTime(): number | undefined {
|
|
40
25
|
return this.animationStartedTime;
|
|
41
26
|
}
|
|
42
27
|
|
|
43
28
|
/**
|
|
44
29
|
* Returns the absolute time of when the animation began - now it will wait for {animationBegin} ms before the transition starts
|
|
45
30
|
*/
|
|
46
|
-
getBeginStartedTime() {
|
|
31
|
+
public getBeginStartedTime(): number | undefined {
|
|
47
32
|
return this.beginStartedTime;
|
|
48
33
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
|
|
35
|
+
private readonly onAnimationEnd: undefined | AnimationStateCallback;
|
|
36
|
+
|
|
37
|
+
private progress: number;
|
|
38
|
+
|
|
39
|
+
private animationStartedTime: number | undefined;
|
|
40
|
+
|
|
41
|
+
private beginStartedTime: number | undefined;
|
|
42
|
+
|
|
43
|
+
protected readonly animationDuration: number;
|
|
44
|
+
|
|
45
|
+
private readonly animationBegin: number;
|
|
46
|
+
|
|
47
|
+
private readonly from: T;
|
|
48
|
+
|
|
49
|
+
private readonly to: T;
|
|
50
|
+
|
|
51
|
+
protected readonly easing: E;
|
|
52
|
+
|
|
53
|
+
private readonly animationId: string;
|
|
54
|
+
|
|
55
|
+
constructor(param: {
|
|
56
|
+
animationId: string;
|
|
57
|
+
onAnimationStart: undefined | AnimationStateCallback;
|
|
58
|
+
onAnimationEnd: undefined | AnimationStateCallback;
|
|
59
|
+
animationDuration: number;
|
|
60
|
+
animationBegin: number;
|
|
61
|
+
from: T;
|
|
62
|
+
to: T;
|
|
63
|
+
easing: E;
|
|
64
|
+
}) {
|
|
52
65
|
this.animationId = param.animationId;
|
|
53
66
|
this.onAnimationEnd = param.onAnimationEnd;
|
|
54
67
|
this.animationDuration = duration(param.animationDuration);
|
|
@@ -58,10 +71,11 @@ class RechartsAnimation {
|
|
|
58
71
|
this.to = param.to;
|
|
59
72
|
this.easing = param.easing;
|
|
60
73
|
// Mimic what the previous animationManager was doing - call onAnimationStart immediately and synchronously
|
|
61
|
-
|
|
62
|
-
_param$onAnimationSta === void 0 ||
|
|
63
|
-
_param$onAnimationSta.call(param);
|
|
74
|
+
param.onAnimationStart?.();
|
|
64
75
|
}
|
|
76
|
+
|
|
77
|
+
private state: AnimationState = INIT;
|
|
78
|
+
|
|
65
79
|
/**
|
|
66
80
|
* Returns the state machine current state
|
|
67
81
|
* - `init`: animation had just been created. It immediately calls `onAnimationStart`
|
|
@@ -70,14 +84,14 @@ class RechartsAnimation {
|
|
|
70
84
|
* - `completed`: animation has completed its transition and executed `onAnimationEnd`.
|
|
71
85
|
* This state is final and the animation is no longer allowed to transition to other states.
|
|
72
86
|
*/
|
|
73
|
-
getState() {
|
|
87
|
+
public getState() {
|
|
74
88
|
return this.state;
|
|
75
89
|
}
|
|
76
90
|
|
|
77
91
|
/**
|
|
78
92
|
* Returns the easing input or function
|
|
79
93
|
*/
|
|
80
|
-
getEasing() {
|
|
94
|
+
public getEasing(): E {
|
|
81
95
|
return this.easing;
|
|
82
96
|
}
|
|
83
97
|
|
|
@@ -85,7 +99,7 @@ class RechartsAnimation {
|
|
|
85
99
|
* Returns the configuration - the duration of the transition.
|
|
86
100
|
* Does not change in time, does not change when state changes, this is a static value.
|
|
87
101
|
*/
|
|
88
|
-
getAnimationDuration() {
|
|
102
|
+
public getAnimationDuration(): number {
|
|
89
103
|
return this.animationDuration;
|
|
90
104
|
}
|
|
91
105
|
|
|
@@ -100,38 +114,41 @@ class RechartsAnimation {
|
|
|
100
114
|
* This is useful because it's the same number you can take and put into setTimeout(fn, X)
|
|
101
115
|
* as that's how much time we need to wait until the next state transition happens.
|
|
102
116
|
*/
|
|
103
|
-
tick(now) {
|
|
117
|
+
public tick(now: number): number {
|
|
104
118
|
if (this.getState() === INIT) {
|
|
105
119
|
this.state = PENDING;
|
|
106
120
|
this.beginStartedTime = now;
|
|
107
121
|
return this.animationBegin;
|
|
108
122
|
}
|
|
123
|
+
|
|
109
124
|
if (this.getState() === PENDING) {
|
|
110
125
|
if (this.beginStartedTime == null) {
|
|
111
126
|
throw new Error();
|
|
112
127
|
}
|
|
113
|
-
|
|
114
|
-
if (
|
|
128
|
+
const timeElapsed = now - this.beginStartedTime;
|
|
129
|
+
if (timeElapsed >= this.animationBegin) {
|
|
115
130
|
this.state = ACTIVE;
|
|
116
131
|
this.animationStartedTime = now;
|
|
117
132
|
// The state flipped just now so the elapsed time is zero
|
|
118
133
|
return this.nextAnimationUpdate(0);
|
|
119
134
|
}
|
|
120
|
-
return duration(this.animationBegin -
|
|
135
|
+
return duration(this.animationBegin - timeElapsed);
|
|
121
136
|
}
|
|
137
|
+
|
|
122
138
|
if (this.getState() === ACTIVE) {
|
|
123
139
|
if (this.animationStartedTime == null) {
|
|
124
140
|
throw new Error();
|
|
125
141
|
}
|
|
126
|
-
|
|
127
|
-
this.setProgress(
|
|
128
|
-
return this.nextAnimationUpdate(
|
|
142
|
+
const timeElapsed = now - this.animationStartedTime;
|
|
143
|
+
this.setProgress(timeElapsed / this.animationDuration);
|
|
144
|
+
return this.nextAnimationUpdate(timeElapsed);
|
|
129
145
|
}
|
|
130
146
|
|
|
131
147
|
// state === COMPLETED, nothing interesting is going to happen
|
|
132
148
|
return 0;
|
|
133
149
|
}
|
|
134
|
-
|
|
150
|
+
|
|
151
|
+
private setProgress(newProgress: number) {
|
|
135
152
|
this.progress = Math.min(1, Math.max(0, newProgress));
|
|
136
153
|
}
|
|
137
154
|
|
|
@@ -150,7 +167,7 @@ class RechartsAnimation {
|
|
|
150
167
|
* The progress is linear with time.
|
|
151
168
|
* If you wish for easing, use `getInterpolated()` instead.
|
|
152
169
|
*/
|
|
153
|
-
getProgress() {
|
|
170
|
+
public getProgress(): number {
|
|
154
171
|
return this.progress;
|
|
155
172
|
}
|
|
156
173
|
|
|
@@ -161,14 +178,11 @@ class RechartsAnimation {
|
|
|
161
178
|
* - tick function doesn't do anything
|
|
162
179
|
* - getState() always returns 'completed'
|
|
163
180
|
*/
|
|
164
|
-
complete() {
|
|
181
|
+
public complete() {
|
|
165
182
|
this.progress = 1;
|
|
166
183
|
if (this.state === 'active') {
|
|
167
|
-
var _this$onAnimationEnd;
|
|
168
184
|
// Do not call callbacks if the animation was interrupted before it even started!
|
|
169
|
-
|
|
170
|
-
_this$onAnimationEnd === void 0 ||
|
|
171
|
-
_this$onAnimationEnd.call(this);
|
|
185
|
+
this.onAnimationEnd?.();
|
|
172
186
|
}
|
|
173
187
|
this.state = COMPLETED;
|
|
174
188
|
}
|
|
@@ -177,7 +191,7 @@ class RechartsAnimation {
|
|
|
177
191
|
* Returns the starting value of the animation.
|
|
178
192
|
* Does not include progress, easing, interpolation, none of that - just the static starting value
|
|
179
193
|
*/
|
|
180
|
-
getFrom() {
|
|
194
|
+
public getFrom() {
|
|
181
195
|
return this.from;
|
|
182
196
|
}
|
|
183
197
|
|
|
@@ -185,14 +199,14 @@ class RechartsAnimation {
|
|
|
185
199
|
* Returns the end value of the animation.
|
|
186
200
|
* Does not include progress, easing, interpolation, none of that - just the static end value
|
|
187
201
|
*/
|
|
188
|
-
getTo() {
|
|
202
|
+
public getTo() {
|
|
189
203
|
return this.to;
|
|
190
204
|
}
|
|
191
205
|
|
|
192
206
|
/**
|
|
193
207
|
* Unique identifier of an animation
|
|
194
208
|
*/
|
|
195
|
-
getAnimationId() {
|
|
209
|
+
public getAnimationId(): string {
|
|
196
210
|
return this.animationId;
|
|
197
211
|
}
|
|
198
212
|
|
|
@@ -200,7 +214,7 @@ class RechartsAnimation {
|
|
|
200
214
|
* Returns the configuration - the duration of delay in between animation initialization, and transition.
|
|
201
215
|
* Does not change in time, does not change when state changes, this is a static value.
|
|
202
216
|
*/
|
|
203
|
-
getAnimationBegin() {
|
|
217
|
+
getAnimationBegin(): number {
|
|
204
218
|
return this.animationBegin;
|
|
205
219
|
}
|
|
206
220
|
|
|
@@ -208,10 +222,12 @@ class RechartsAnimation {
|
|
|
208
222
|
* Returns value of the transition at the current time.
|
|
209
223
|
* The exact details differ based on the animation type
|
|
210
224
|
*/
|
|
225
|
+
public abstract getInterpolated(): T;
|
|
211
226
|
|
|
212
227
|
/**
|
|
213
228
|
* Returns the duration of time of when the controller should ask for the next update
|
|
214
229
|
*/
|
|
230
|
+
protected abstract nextAnimationUpdate(timeElapsed: number): number;
|
|
215
231
|
}
|
|
216
232
|
|
|
217
233
|
/**
|
|
@@ -220,9 +236,9 @@ class RechartsAnimation {
|
|
|
220
236
|
*
|
|
221
237
|
* @since 3.9
|
|
222
238
|
*/
|
|
223
|
-
export class JavascriptAnimation extends RechartsAnimation {
|
|
239
|
+
export class JavascriptAnimation extends RechartsAnimation<number, EasingFunction> {
|
|
224
240
|
// eslint-disable-next-line class-methods-use-this
|
|
225
|
-
nextAnimationUpdate() {
|
|
241
|
+
protected nextAnimationUpdate(): number {
|
|
226
242
|
/*
|
|
227
243
|
* JavaScript-based animations have to update as soon as possible,
|
|
228
244
|
* so we return 0 here to indicate that the next update should be scheduled immediately
|
|
@@ -236,7 +252,7 @@ export class JavascriptAnimation extends RechartsAnimation {
|
|
|
236
252
|
* This value, unlike getProgress(), can escape the [0..1] range
|
|
237
253
|
* because this is entirely within the easing function control. Spring typically does this.
|
|
238
254
|
*/
|
|
239
|
-
getInterpolated() {
|
|
255
|
+
public getInterpolated(): number {
|
|
240
256
|
return this.easing(interpolate(this.getFrom(), this.getTo(), this.getProgress()));
|
|
241
257
|
}
|
|
242
258
|
}
|
|
@@ -247,8 +263,8 @@ export class JavascriptAnimation extends RechartsAnimation {
|
|
|
247
263
|
*
|
|
248
264
|
* @since 3.9
|
|
249
265
|
*/
|
|
250
|
-
export class CSSTransitionAnimation extends RechartsAnimation {
|
|
251
|
-
nextAnimationUpdate(timeElapsed) {
|
|
266
|
+
export class CSSTransitionAnimation extends RechartsAnimation<string, NamedBezier> {
|
|
267
|
+
protected nextAnimationUpdate(timeElapsed: number): number {
|
|
252
268
|
/**
|
|
253
269
|
* CSS transitions do not need DOM updates past the initial render
|
|
254
270
|
* so here we just instruct the controller to wait until the animation duration is over.
|
|
@@ -263,7 +279,7 @@ export class CSSTransitionAnimation extends RechartsAnimation {
|
|
|
263
279
|
* so all we need to do here is return the final state
|
|
264
280
|
* and let browser handle the rest.
|
|
265
281
|
*/
|
|
266
|
-
getInterpolated() {
|
|
282
|
+
public getInterpolated(): string {
|
|
267
283
|
return this.getTo();
|
|
268
284
|
}
|
|
269
285
|
}
|
|
@@ -289,3 +305,4 @@ export class CSSTransitionAnimation extends RechartsAnimation {
|
|
|
289
305
|
*
|
|
290
306
|
* @since 3.9
|
|
291
307
|
*/
|
|
308
|
+
export type AnimationHandle = JavascriptAnimation | CSSTransitionAnimation;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { OctaneNode } from '../util/OctaneTypes.ts';
|
|
1
2
|
import * as React from 'octane';
|
|
2
|
-
import { useCallback, useEffect, useRef, useState
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'octane';
|
|
3
4
|
import type { Octane } from 'octane/jsx-runtime';
|
|
4
5
|
import { noop } from '../util/DataUtils';
|
|
5
6
|
import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
|
@@ -14,7 +15,7 @@ import type { AnimationController } from './AnimationController';
|
|
|
14
15
|
|
|
15
16
|
// `octane` does not export `CSSProperties`. The object form of octane's JSX
|
|
16
17
|
// `style` prop is the type this render prop hands out, so take it from there
|
|
17
|
-
// (`octane/jsx-runtime` types it as `string |
|
|
18
|
+
// (`octane/jsx-runtime` types it as `string | CSSProperties`) rather than
|
|
18
19
|
// importing @types/react, which this package does not depend on.
|
|
19
20
|
type CSSProperties = Exclude<NonNullable<Octane.HTMLAttributes<Element>['style']>, string>;
|
|
20
21
|
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import type { OctaneNode } from '../util/OctaneTypes.ts';
|
|
2
|
+
import type { EasingInput } from './easing';
|
|
3
|
+
import type { AnimationController } from './AnimationController';
|
|
4
|
+
|
|
5
|
+
type JavascriptAnimateProps = {
|
|
6
|
+
animationId: string;
|
|
7
|
+
animationController?: AnimationController;
|
|
8
|
+
duration?: number;
|
|
9
|
+
begin?: number;
|
|
10
|
+
easing?: EasingInput;
|
|
11
|
+
isActive?: boolean | 'auto';
|
|
12
|
+
canBegin?: boolean;
|
|
13
|
+
onAnimationStart?: () => void;
|
|
14
|
+
onAnimationEnd?: () => void;
|
|
15
|
+
children: (animationElapsedTime: number) => OctaneNode;
|
|
16
|
+
};
|
|
1
17
|
// Port of animation/JavascriptAnimate.tsx — the render-prop animation driver:
|
|
2
18
|
// `children(t)` with t progressing 0→1 through the (vendored) animation core.
|
|
3
19
|
// `isActive={false}` renders a single synchronous `children(1)` — the static
|
|
@@ -21,12 +37,12 @@ const defaultJavascriptAnimateProps = {
|
|
|
21
37
|
canBegin: true,
|
|
22
38
|
onAnimationEnd: () => {},
|
|
23
39
|
onAnimationStart: () => {},
|
|
24
|
-
}
|
|
40
|
+
} as const satisfies Partial<JavascriptAnimateProps>;
|
|
25
41
|
|
|
26
42
|
const from = 0;
|
|
27
43
|
const to = 1;
|
|
28
44
|
|
|
29
|
-
export function JavascriptAnimate(outsideProps) {
|
|
45
|
+
export function JavascriptAnimate(outsideProps: JavascriptAnimateProps) {
|
|
30
46
|
const props = resolveDefaultProps(outsideProps, defaultJavascriptAnimateProps);
|
|
31
47
|
const {
|
|
32
48
|
animationId,
|