@octanejs/recharts 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/package.json +4 -4
  2. package/src/animation/CSSTransitionAnimate.tsrx +142 -0
  3. package/src/cartesian/Area.tsrx +1096 -0
  4. package/src/cartesian/Area.tsrx.d.ts +340 -0
  5. package/src/cartesian/AreaRevealShape.tsrx +202 -0
  6. package/src/cartesian/CartesianGrid.tsrx +643 -0
  7. package/src/cartesian/CartesianGrid.tsrx.d.ts +219 -0
  8. package/src/cartesian/ErrorBar.tsrx +322 -0
  9. package/src/cartesian/ErrorBar.tsrx.d.ts +131 -0
  10. package/src/cartesian/Funnel.tsrx +833 -0
  11. package/src/cartesian/Funnel.tsrx.d.ts +274 -0
  12. package/src/cartesian/ReferenceLine.tsrx +452 -0
  13. package/src/cartesian/ReferenceLine.tsrx.d.ts +178 -0
  14. package/src/cartesian/Scatter.tsrx +1076 -0
  15. package/src/cartesian/Scatter.tsrx.d.ts +351 -0
  16. package/src/cartesian/ZAxis.tsrx +148 -0
  17. package/src/cartesian/ZAxis.tsrx.d.ts +102 -0
  18. package/src/chart/AreaChart.tsrx +22 -0
  19. package/src/chart/AreaChart.tsrx.d.ts +12 -0
  20. package/src/chart/ComposedChart.tsrx +22 -0
  21. package/src/chart/ComposedChart.tsrx.d.ts +12 -0
  22. package/src/chart/FunnelChart.tsrx +22 -0
  23. package/src/chart/FunnelChart.tsrx.d.ts +12 -0
  24. package/src/chart/PieChart.tsrx +31 -0
  25. package/src/chart/PieChart.tsrx.d.ts +31 -0
  26. package/src/chart/PolarChart.tsrx +121 -0
  27. package/src/chart/RadarChart.tsrx +53 -0
  28. package/src/chart/RadarChart.tsrx.d.ts +31 -0
  29. package/src/chart/RadialBarChart.tsrx +31 -0
  30. package/src/chart/RadialBarChart.tsrx.d.ts +31 -0
  31. package/src/chart/Sankey.tsrx +1542 -0
  32. package/src/chart/Sankey.tsrx.d.ts +253 -0
  33. package/src/chart/ScatterChart.tsrx +22 -0
  34. package/src/chart/ScatterChart.tsrx.d.ts +12 -0
  35. package/src/chart/SunburstChart.tsrx +495 -0
  36. package/src/chart/SunburstChart.tsrx.d.ts +146 -0
  37. package/src/chart/types.ts +19 -0
  38. package/src/component/Cursor.tsrx +157 -0
  39. package/src/component/DefaultLegendContent.tsrx +288 -0
  40. package/src/component/DefaultLegendContent.tsrx.d.ts +125 -0
  41. package/src/component/DefaultTooltipContent.tsrx +215 -0
  42. package/src/component/DefaultTooltipContent.tsrx.d.ts +87 -0
  43. package/src/component/Legend.tsrx +302 -0
  44. package/src/component/Legend.tsrx.d.ts +88 -0
  45. package/src/component/ResponsiveContainer.ts +1 -22
  46. package/src/component/ResponsiveContainer.tsrx +171 -0
  47. package/src/component/ResponsiveContainer.tsrx.d.ts +81 -0
  48. package/src/component/Tooltip.tsrx +425 -0
  49. package/src/component/Tooltip.tsrx.d.ts +246 -0
  50. package/src/component/TooltipBoundingBox.tsrx +135 -0
  51. package/src/context/CellsContext.ts +12 -0
  52. package/src/context/legendPayloadContext.tsrx +11 -0
  53. package/src/context/useTooltipAxis.ts +20 -0
  54. package/src/index.d.ts +236 -0
  55. package/src/index.ts +67 -0
  56. package/src/polar/Pie.tsrx +1224 -0
  57. package/src/polar/Pie.tsrx.d.ts +436 -0
  58. package/src/polar/PolarAngleAxis.tsrx +554 -0
  59. package/src/polar/PolarAngleAxis.tsrx.d.ts +215 -0
  60. package/src/polar/PolarGrid.tsrx +317 -0
  61. package/src/polar/PolarGrid.tsrx.d.ts +117 -0
  62. package/src/polar/PolarRadiusAxis.tsrx +463 -0
  63. package/src/polar/PolarRadiusAxis.tsrx.d.ts +209 -0
  64. package/src/polar/Radar.tsrx +696 -0
  65. package/src/polar/Radar.tsrx.d.ts +215 -0
  66. package/src/polar/RadialBar.tsrx +887 -0
  67. package/src/polar/RadialBar.tsrx.d.ts +340 -0
  68. package/src/state/ReportPolarOptions.tsrx +11 -0
  69. package/src/state/selectors/areaSelectors.ts +257 -0
  70. package/src/state/selectors/funnelSelectors.ts +86 -0
  71. package/src/state/selectors/pieSelectors.ts +134 -0
  72. package/src/state/selectors/polarGridSelectors.ts +43 -0
  73. package/src/state/selectors/polarScaleSelectors.ts +159 -0
  74. package/src/state/selectors/polarSelectors.ts +198 -0
  75. package/src/state/selectors/radarSelectors.ts +228 -0
  76. package/src/state/selectors/radialBarSelectors.ts +511 -0
  77. package/src/state/selectors/scatterSelectors.ts +168 -0
  78. package/src/util/FunnelUtils.tsrx +19 -0
  79. package/src/util/RadialBarUtils.tsrx +29 -0
  80. package/src/util/ScatterUtils.tsrx +34 -0
  81. package/src/util/cursor/getCursorPoints.ts +45 -0
  82. package/src/util/cursor/getCursorRectangle.ts +28 -0
  83. package/src/util/cursor/getRadialCursorPoints.ts +31 -0
  84. package/src/util/payload/getUniqPayload.ts +28 -0
  85. package/src/util/scale/CartesianScaleHelper.ts +71 -0
  86. package/src/util/tooltip/translate.ts +168 -0
  87. package/src/util/types.ts +3 -0
  88. package/src/util/useElementOffset.ts +147 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/recharts",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -39,10 +39,10 @@
39
39
  "reselect": "5.2.0",
40
40
  "tiny-invariant": "^1.3.3",
41
41
  "victory-vendor": "^37.3.6",
42
- "@octanejs/redux": "0.1.16"
42
+ "@octanejs/redux": "0.1.18"
43
43
  },
44
44
  "peerDependencies": {
45
- "octane": "0.1.19"
45
+ "octane": "0.1.21"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@tsrx/react": "^0.2.56",
@@ -51,7 +51,7 @@
51
51
  "react-dom": "^19.2.7",
52
52
  "recharts": "3.9.2",
53
53
  "vitest": "^4.1.10",
54
- "octane": "0.1.19"
54
+ "octane": "0.1.21"
55
55
  },
56
56
  "scripts": {
57
57
  "test": "vitest run"
@@ -0,0 +1,142 @@
1
+ import * as React from 'octane';
2
+ import { CSSProperties, useCallback, useEffect, useRef, useState, type OctaneNode } from 'octane';
3
+ import { noop } from '../util/DataUtils';
4
+ import { resolveDefaultProps } from '../util/resolveDefaultProps';
5
+ import { useAnimationController } from './useAnimationController';
6
+ import { getTransitionVal } from './util';
7
+ import { Global } from '../util/Global';
8
+ import { usePrefersReducedMotion } from '../util/usePrefersReducedMotion';
9
+ import { CSSTransitionAnimation } from './AnimationHandle';
10
+ import { RequestAnimationFrameTimeoutController } from './timeoutController';
11
+ import { EasingInput, NamedBezier } from './easing';
12
+ import type { AnimationController } from './AnimationController';
13
+
14
+ type CSSTransitionAnimateProps = {
15
+ animationId: string;
16
+ animationController?: AnimationController;
17
+ duration?: number;
18
+ begin?: number;
19
+ easing?: NamedBezier;
20
+ isActive?: boolean | 'auto';
21
+ canBegin?: boolean;
22
+ from: string;
23
+ to: string;
24
+ attributeName: string;
25
+ onAnimationStart?: () => void;
26
+ onAnimationEnd?: () => void;
27
+ children: (style: CSSProperties) => OctaneNode;
28
+ };
29
+
30
+ const defaultProps = {
31
+ begin: 0,
32
+ duration: 1000,
33
+ easing: 'ease',
34
+ isActive: true,
35
+ canBegin: true,
36
+ onAnimationEnd: () => {},
37
+ onAnimationStart: () => {},
38
+ } as const satisfies Partial<CSSTransitionAnimateProps>;
39
+
40
+ export function extractCssEasing(easingInput: EasingInput): NamedBezier | undefined {
41
+ if (easingInput === 'spring' || typeof easingInput !== 'string') {
42
+ return undefined;
43
+ }
44
+ return easingInput;
45
+ }
46
+
47
+ export function CSSTransitionAnimate(outsideProps: CSSTransitionAnimateProps) {
48
+ const props = resolveDefaultProps(outsideProps, defaultProps);
49
+ const {
50
+ animationId,
51
+ from,
52
+ to,
53
+ attributeName,
54
+ isActive: isActiveProp,
55
+ canBegin,
56
+ duration,
57
+ easing,
58
+ begin,
59
+ onAnimationEnd,
60
+ onAnimationStart: onAnimationStartFromProps,
61
+ children,
62
+ } = props;
63
+
64
+ const prefersReducedMotion = usePrefersReducedMotion();
65
+
66
+ const isActive =
67
+ isActiveProp === 'auto' ? !Global.isSsr && !prefersReducedMotion : isActiveProp;
68
+
69
+ const animationController = useAnimationController(props.animationController);
70
+ const [style, setStyle] = useState<string | number>(() => {
71
+ if (!isActive) {
72
+ return to;
73
+ }
74
+ return from;
75
+ });
76
+ const initialized = useRef(false);
77
+
78
+ const onAnimationStart = useCallback(() => {
79
+ setStyle(from);
80
+ onAnimationStartFromProps();
81
+ }, [from, onAnimationStartFromProps]);
82
+
83
+ useEffect(() => {
84
+ if (!isActive || !canBegin) {
85
+ return noop;
86
+ }
87
+
88
+ initialized.current = true;
89
+
90
+ const timeoutController = new RequestAnimationFrameTimeoutController();
91
+
92
+ const animation = new CSSTransitionAnimation({
93
+ animationId: animationId + attributeName,
94
+ easing,
95
+ animationDuration: duration,
96
+ animationBegin: begin,
97
+ onAnimationStart,
98
+ onAnimationEnd,
99
+ from,
100
+ to,
101
+ });
102
+
103
+ return animationController(timeoutController, animation, setStyle);
104
+ }, [
105
+ isActive,
106
+ canBegin,
107
+ duration,
108
+ easing,
109
+ begin,
110
+ onAnimationStart,
111
+ onAnimationEnd,
112
+ animationController,
113
+ to,
114
+ from,
115
+ animationId,
116
+ attributeName,
117
+ ]);
118
+
119
+ if (!isActive) {
120
+ initialized.current = false;
121
+ return children({
122
+ [attributeName]: to,
123
+ });
124
+ }
125
+ if (!canBegin) {
126
+ initialized.current = false;
127
+ return children({
128
+ [attributeName]: from,
129
+ });
130
+ }
131
+
132
+ if (initialized.current) {
133
+ const transition = getTransitionVal([attributeName], duration, easing);
134
+ return children({
135
+ transition,
136
+ [attributeName]: style,
137
+ });
138
+ }
139
+ return children({
140
+ [attributeName]: from,
141
+ });
142
+ }