@octanejs/recharts 0.1.0

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 (219) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +53 -0
  3. package/src/animation/AnimatedItems.tsrx +82 -0
  4. package/src/animation/AnimationControllerImpl.js +33 -0
  5. package/src/animation/AnimationHandle.js +291 -0
  6. package/src/animation/JavascriptAnimate.tsrx +81 -0
  7. package/src/animation/easing.js +193 -0
  8. package/src/animation/matchBy.js +279 -0
  9. package/src/animation/timeoutController.js +49 -0
  10. package/src/animation/useAnimationController.ts +22 -0
  11. package/src/animation/useAnimationStartSnapshot.ts +43 -0
  12. package/src/animation/util.js +11 -0
  13. package/src/cartesian/Bar.ts +4 -0
  14. package/src/cartesian/Bar.tsrx +716 -0
  15. package/src/cartesian/Bar.tsrx.d.ts +4 -0
  16. package/src/cartesian/BarStack.tsrx +97 -0
  17. package/src/cartesian/BarStack.tsrx.d.ts +6 -0
  18. package/src/cartesian/CartesianAxis.tsrx +413 -0
  19. package/src/cartesian/CartesianAxis.tsrx.d.ts +3 -0
  20. package/src/cartesian/GraphicalItemClipPath.tsrx +44 -0
  21. package/src/cartesian/Line.ts +4 -0
  22. package/src/cartesian/Line.tsrx +544 -0
  23. package/src/cartesian/Line.tsrx.d.ts +4 -0
  24. package/src/cartesian/LineDrawShape.tsrx +106 -0
  25. package/src/cartesian/LineDrawShape.tsrx.d.ts +2 -0
  26. package/src/cartesian/XAxis.tsrx +156 -0
  27. package/src/cartesian/XAxis.tsrx.d.ts +3 -0
  28. package/src/cartesian/YAxis.tsrx +183 -0
  29. package/src/cartesian/YAxis.tsrx.d.ts +3 -0
  30. package/src/cartesian/getCartesianPosition.js +277 -0
  31. package/src/cartesian/getEquidistantTicks.js +133 -0
  32. package/src/cartesian/getTicks.js +280 -0
  33. package/src/cartesian/useAnimatedLineLength.ts +33 -0
  34. package/src/chart/BarChart.tsrx +22 -0
  35. package/src/chart/BarChart.tsrx.d.ts +2 -0
  36. package/src/chart/CartesianChart.tsrx +76 -0
  37. package/src/chart/CartesianChart.tsrx.d.ts +10 -0
  38. package/src/chart/CategoricalChart.tsrx +54 -0
  39. package/src/chart/LineChart.tsrx +22 -0
  40. package/src/chart/LineChart.tsrx.d.ts +2 -0
  41. package/src/chart/RechartsWrapper.tsrx +294 -0
  42. package/src/component/ActivePoints.tsrx +76 -0
  43. package/src/component/Cell.ts +37 -0
  44. package/src/component/Dots.tsrx +74 -0
  45. package/src/component/Label.tsrx +309 -0
  46. package/src/component/Label.tsrx.d.ts +12 -0
  47. package/src/component/LabelList.tsrx +83 -0
  48. package/src/component/LabelList.tsrx.d.ts +8 -0
  49. package/src/component/ResponsiveContainer.ts +22 -0
  50. package/src/component/Text.tsrx +281 -0
  51. package/src/component/Text.tsrx.d.ts +9 -0
  52. package/src/component/responsiveContainerUtils.js +111 -0
  53. package/src/container/ClipPathProvider.tsrx +29 -0
  54. package/src/container/Layer.tsrx +9 -0
  55. package/src/container/Layer.tsrx.d.ts +6 -0
  56. package/src/container/RootSurface.tsrx +76 -0
  57. package/src/container/Surface.tsrx +23 -0
  58. package/src/container/Surface.tsrx.d.ts +12 -0
  59. package/src/context/CellsContext.ts +80 -0
  60. package/src/context/ErrorBarContext.tsrx +53 -0
  61. package/src/context/PanoramaContext.ts +10 -0
  62. package/src/context/RegisterGraphicalItemId.tsrx +19 -0
  63. package/src/context/accessibilityContext.js +10 -0
  64. package/src/context/chartDataContext.ts +57 -0
  65. package/src/context/chartLayoutContext.ts +171 -0
  66. package/src/context/legendPortalContext.ts +5 -0
  67. package/src/context/tooltipContext.js +55 -0
  68. package/src/context/tooltipPortalContext.ts +5 -0
  69. package/src/hooks.js +509 -0
  70. package/src/index.ts +64 -0
  71. package/src/internal.ts +37 -0
  72. package/src/polar/defaultPolarAngleAxisProps.js +27 -0
  73. package/src/polar/defaultPolarRadiusAxisProps.js +24 -0
  74. package/src/shape/Cross.tsrx +25 -0
  75. package/src/shape/Cross.tsrx.d.ts +12 -0
  76. package/src/shape/Curve.tsrx +132 -0
  77. package/src/shape/Curve.tsrx.d.ts +42 -0
  78. package/src/shape/Dot.tsrx +21 -0
  79. package/src/shape/Dot.tsrx.d.ts +9 -0
  80. package/src/shape/Polygon.tsrx +95 -0
  81. package/src/shape/Polygon.tsrx.d.ts +13 -0
  82. package/src/shape/Rectangle.tsrx +162 -0
  83. package/src/shape/Rectangle.tsrx.d.ts +31 -0
  84. package/src/shape/Sector.tsrx +219 -0
  85. package/src/shape/Sector.tsrx.d.ts +29 -0
  86. package/src/shape/Symbols.tsrx +95 -0
  87. package/src/shape/Symbols.tsrx.d.ts +15 -0
  88. package/src/shape/Trapezoid.tsrx +56 -0
  89. package/src/shape/Trapezoid.tsrx.d.ts +29 -0
  90. package/src/state/RechartsReduxContext.ts +7 -0
  91. package/src/state/RechartsStoreProvider.tsrx +24 -0
  92. package/src/state/ReportChartProps.ts +13 -0
  93. package/src/state/ReportEventSettings.ts +15 -0
  94. package/src/state/ReportMainChartProps.ts +22 -0
  95. package/src/state/SetGraphicalItem.ts +61 -0
  96. package/src/state/SetLegendPayload.ts +61 -0
  97. package/src/state/SetTooltipEntrySettings.ts +40 -0
  98. package/src/state/brushSlice.js +36 -0
  99. package/src/state/cartesianAxisSlice.js +256 -0
  100. package/src/state/chartDataSlice.js +67 -0
  101. package/src/state/errorBarSlice.js +53 -0
  102. package/src/state/eventSettingsSlice.js +25 -0
  103. package/src/state/externalEventsMiddleware.js +127 -0
  104. package/src/state/graphicalItemsSlice.js +91 -0
  105. package/src/state/hooks.ts +46 -0
  106. package/src/state/keyboardEventsMiddleware.js +226 -0
  107. package/src/state/layoutSlice.js +57 -0
  108. package/src/state/legendSlice.js +83 -0
  109. package/src/state/mouseEventsMiddleware.js +130 -0
  110. package/src/state/optionsSlice.js +45 -0
  111. package/src/state/polarAxisSlice.js +33 -0
  112. package/src/state/polarOptionsSlice.js +26 -0
  113. package/src/state/reduxDevtoolsJsonStringifyReplacer.js +14 -0
  114. package/src/state/referenceElementsSlice.js +51 -0
  115. package/src/state/renderedTicksSlice.js +41 -0
  116. package/src/state/rootPropsSlice.js +48 -0
  117. package/src/state/selectors/arrayEqualityCheck.js +32 -0
  118. package/src/state/selectors/axisSelectors.js +2113 -0
  119. package/src/state/selectors/barSelectors.js +263 -0
  120. package/src/state/selectors/barStackSelectors.js +65 -0
  121. package/src/state/selectors/brushSelectors.js +21 -0
  122. package/src/state/selectors/combiners/combineActiveLabel.js +18 -0
  123. package/src/state/selectors/combiners/combineActiveTooltipIndex.js +75 -0
  124. package/src/state/selectors/combiners/combineAllBarPositions.js +169 -0
  125. package/src/state/selectors/combiners/combineAxisRangeWithReverse.js +11 -0
  126. package/src/state/selectors/combiners/combineBarPosition.js +17 -0
  127. package/src/state/selectors/combiners/combineBarSizeList.js +115 -0
  128. package/src/state/selectors/combiners/combineCheckedDomain.js +44 -0
  129. package/src/state/selectors/combiners/combineConfiguredScale.js +46 -0
  130. package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.js +48 -0
  131. package/src/state/selectors/combiners/combineDisplayedStackedData.js +54 -0
  132. package/src/state/selectors/combiners/combineInverseScaleFunction.js +12 -0
  133. package/src/state/selectors/combiners/combineRealScaleType.js +36 -0
  134. package/src/state/selectors/combiners/combineStackedData.js +22 -0
  135. package/src/state/selectors/combiners/combineTooltipInteractionState.js +121 -0
  136. package/src/state/selectors/combiners/combineTooltipPayload.js +248 -0
  137. package/src/state/selectors/combiners/combineTooltipPayloadConfigurations.js +59 -0
  138. package/src/state/selectors/containerSelectors.js +6 -0
  139. package/src/state/selectors/dataSelectors.js +97 -0
  140. package/src/state/selectors/graphicalItemSelectors.js +25 -0
  141. package/src/state/selectors/legendSelectors.js +18 -0
  142. package/src/state/selectors/lineSelectors.js +106 -0
  143. package/src/state/selectors/numberDomainEqualityCheck.js +11 -0
  144. package/src/state/selectors/pickAxisId.js +3 -0
  145. package/src/state/selectors/pickAxisType.js +3 -0
  146. package/src/state/selectors/polarAxisSelectors.js +237 -0
  147. package/src/state/selectors/rootPropsSelectors.js +13 -0
  148. package/src/state/selectors/selectActivePropsFromChartPointer.js +23 -0
  149. package/src/state/selectors/selectAllAxes.js +15 -0
  150. package/src/state/selectors/selectChartOffset.js +12 -0
  151. package/src/state/selectors/selectChartOffsetInternal.js +174 -0
  152. package/src/state/selectors/selectPlotArea.js +19 -0
  153. package/src/state/selectors/selectTooltipAxisId.js +3 -0
  154. package/src/state/selectors/selectTooltipAxisType.js +25 -0
  155. package/src/state/selectors/selectTooltipEventType.js +27 -0
  156. package/src/state/selectors/selectTooltipPayloadSearcher.js +3 -0
  157. package/src/state/selectors/selectTooltipSettings.js +3 -0
  158. package/src/state/selectors/selectTooltipState.js +3 -0
  159. package/src/state/selectors/selectors.js +222 -0
  160. package/src/state/selectors/tooltipSelectors.js +471 -0
  161. package/src/state/selectors/touchSelectors.js +31 -0
  162. package/src/state/store.js +101 -0
  163. package/src/state/tooltipSlice.js +237 -0
  164. package/src/state/touchEventsMiddleware.js +140 -0
  165. package/src/state/types/StackedGraphicalItem.js +18 -0
  166. package/src/state/zIndexSlice.js +167 -0
  167. package/src/synchronisation/syncSelectors.js +5 -0
  168. package/src/synchronisation/useChartSynchronisation.tsrx +285 -0
  169. package/src/util/ActiveShapeUtils.tsrx +62 -0
  170. package/src/util/BarUtils.tsrx +35 -0
  171. package/src/util/CartesianUtils.js +66 -0
  172. package/src/util/ChartUtils.js +630 -0
  173. package/src/util/Constants.js +42 -0
  174. package/src/util/DOMUtils.js +180 -0
  175. package/src/util/DataUtils.js +199 -0
  176. package/src/util/Events.js +7 -0
  177. package/src/util/Global.js +13 -0
  178. package/src/util/LRUCache.js +58 -0
  179. package/src/util/LogUtils.js +29 -0
  180. package/src/util/PolarUtils.js +190 -0
  181. package/src/util/ReactUtils.ts +94 -0
  182. package/src/util/ReduceCSSCalc.js +260 -0
  183. package/src/util/TickUtils.js +43 -0
  184. package/src/util/YAxisUtils.js +43 -0
  185. package/src/util/axisPropsAreEqual.js +63 -0
  186. package/src/util/createEventProxy.js +18 -0
  187. package/src/util/excludeEventProps.js +172 -0
  188. package/src/util/getActiveCoordinate.js +253 -0
  189. package/src/util/getAxisTypeBasedOnLayout.js +17 -0
  190. package/src/util/getClassNameFromUnknown.js +8 -0
  191. package/src/util/getEveryNth.js +29 -0
  192. package/src/util/getRadiusAndStrokeWidthFromDot.js +28 -0
  193. package/src/util/getRelativeCoordinate.js +96 -0
  194. package/src/util/getSliced.js +11 -0
  195. package/src/util/isDomainSpecifiedByUser.js +255 -0
  196. package/src/util/isWellBehavedNumber.js +8 -0
  197. package/src/util/propsAreEqual.js +96 -0
  198. package/src/util/resolveDefaultProps.js +131 -0
  199. package/src/util/round.js +39 -0
  200. package/src/util/scale/RechartsScale.js +68 -0
  201. package/src/util/scale/createCategoricalInverse.js +77 -0
  202. package/src/util/scale/getNiceTickValues.js +354 -0
  203. package/src/util/scale/index.js +3 -0
  204. package/src/util/scale/util/arithmetic.js +51 -0
  205. package/src/util/stacks/getStackSeriesIdentifier.js +10 -0
  206. package/src/util/svgPropertiesAndEvents.ts +29 -0
  207. package/src/util/svgPropertiesNoEvents.js +383 -0
  208. package/src/util/types.ts +59 -0
  209. package/src/util/useAnimationId.ts +14 -0
  210. package/src/util/useId.ts +13 -0
  211. package/src/util/usePrefersReducedMotion.ts +30 -0
  212. package/src/util/useReportScale.ts +26 -0
  213. package/src/util/useUniqueId.js +34 -0
  214. package/src/zIndex/DefaultZIndexes.js +75 -0
  215. package/src/zIndex/ZIndexLayer.tsrx +80 -0
  216. package/src/zIndex/ZIndexLayer.tsrx.d.ts +2 -0
  217. package/src/zIndex/ZIndexPortal.tsrx +43 -0
  218. package/src/zIndex/getZIndexFromUnknown.js +15 -0
  219. package/src/zIndex/zIndexSelectors.js +45 -0
@@ -0,0 +1,255 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/isDomainSpecifiedByUser.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ function _slicedToArray(r, e) {
4
+ return (
5
+ _arrayWithHoles(r) ||
6
+ _iterableToArrayLimit(r, e) ||
7
+ _unsupportedIterableToArray(r, e) ||
8
+ _nonIterableRest()
9
+ );
10
+ }
11
+ function _nonIterableRest() {
12
+ throw new TypeError(
13
+ 'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
14
+ );
15
+ }
16
+ function _unsupportedIterableToArray(r, a) {
17
+ if (r) {
18
+ if ('string' == typeof r) return _arrayLikeToArray(r, a);
19
+ var t = {}.toString.call(r).slice(8, -1);
20
+ return (
21
+ 'Object' === t && r.constructor && (t = r.constructor.name),
22
+ 'Map' === t || 'Set' === t
23
+ ? Array.from(r)
24
+ : 'Arguments' === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)
25
+ ? _arrayLikeToArray(r, a)
26
+ : void 0
27
+ );
28
+ }
29
+ }
30
+ function _arrayLikeToArray(r, a) {
31
+ (null == a || a > r.length) && (a = r.length);
32
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
33
+ return n;
34
+ }
35
+ function _iterableToArrayLimit(r, l) {
36
+ var t =
37
+ null == r ? null : ('undefined' != typeof Symbol && r[Symbol.iterator]) || r['@@iterator'];
38
+ if (null != t) {
39
+ var e,
40
+ n,
41
+ i,
42
+ u,
43
+ a = [],
44
+ f = !0,
45
+ o = !1;
46
+ try {
47
+ if (((i = (t = t.call(r)).next), 0 === l)) {
48
+ if (Object(t) !== t) return;
49
+ f = !1;
50
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
51
+ } catch (r) {
52
+ ((o = !0), (n = r));
53
+ } finally {
54
+ try {
55
+ if (!f && null != t.return && ((u = t.return()), Object(u) !== u)) return;
56
+ } finally {
57
+ if (o) throw n;
58
+ }
59
+ }
60
+ return a;
61
+ }
62
+ }
63
+ function _arrayWithHoles(r) {
64
+ if (Array.isArray(r)) return r;
65
+ }
66
+ import { MAX_VALUE_REG, MIN_VALUE_REG } from './ChartUtils';
67
+ import { isNumber } from './DataUtils';
68
+ import { isWellBehavedNumber } from './isWellBehavedNumber';
69
+ export function isWellFormedNumberDomain(v) {
70
+ if (Array.isArray(v) && v.length === 2) {
71
+ var _v = _slicedToArray(v, 2),
72
+ min = _v[0],
73
+ max = _v[1];
74
+ if (isWellBehavedNumber(min) && isWellBehavedNumber(max)) {
75
+ return true;
76
+ }
77
+ }
78
+ return false;
79
+ }
80
+ export function extendDomain(providedDomain, boundaryDomain, allowDataOverflow) {
81
+ if (allowDataOverflow) {
82
+ // If the data are allowed to overflow - we're fine with whatever user provided
83
+ return providedDomain;
84
+ }
85
+ /*
86
+ * If the data are not allowed to overflow - we need to extend the domain.
87
+ * Means that effectively the user is allowed to make the domain larger
88
+ * but not smaller.
89
+ */
90
+ return [
91
+ Math.min(providedDomain[0], boundaryDomain[0]),
92
+ Math.max(providedDomain[1], boundaryDomain[1]),
93
+ ];
94
+ }
95
+
96
+ /**
97
+ * So Recharts allows users to provide their own domains,
98
+ * but it also places some expectations on what the domain is.
99
+ * We can improve on the typescript typing, but we also need a runtime test
100
+ to observe that the user-provided domain is well-formed,
101
+ * that is: an array with exactly two numbers.
102
+ *
103
+ * This function does not accept data as an argument.
104
+ * This is to enable a performance optimization - if the domain is there,
105
+ * and we know what it is without traversing all the data,
106
+ * then we don't have to traverse all the data!
107
+ *
108
+ * If the user-provided domain is not well-formed,
109
+ * this function will return undefined - in which case we should traverse the data to calculate the real domain.
110
+ *
111
+ * This function is for parsing the numerical domain only.
112
+ *
113
+ * @param userDomain external prop, user provided, before validation. Can have various shapes: array, function, special magical strings inside too.
114
+ * @param allowDataOverflow boolean, provided by users. If true then the data domain wins
115
+ *
116
+ * @return [min, max] domain if it's well-formed; undefined if the domain is invalid
117
+ */
118
+ export function numericalDomainSpecifiedWithoutRequiringData(userDomain, allowDataOverflow) {
119
+ if (!allowDataOverflow) {
120
+ // Cannot compute data overflow if the data is not provided
121
+ return undefined;
122
+ }
123
+ if (typeof userDomain === 'function') {
124
+ // The user function expects the data to be provided as an argument
125
+ return undefined;
126
+ }
127
+ if (Array.isArray(userDomain) && userDomain.length === 2) {
128
+ var _userDomain = _slicedToArray(userDomain, 2),
129
+ providedMin = _userDomain[0],
130
+ providedMax = _userDomain[1];
131
+ var finalMin, finalMax;
132
+ if (isWellBehavedNumber(providedMin)) {
133
+ finalMin = providedMin;
134
+ } else if (typeof providedMin === 'function') {
135
+ // The user function expects the data to be provided as an argument
136
+ return undefined;
137
+ }
138
+ if (isWellBehavedNumber(providedMax)) {
139
+ finalMax = providedMax;
140
+ } else if (typeof providedMax === 'function') {
141
+ // The user function expects the data to be provided as an argument
142
+ return undefined;
143
+ }
144
+ var candidate = [finalMin, finalMax];
145
+ if (isWellFormedNumberDomain(candidate)) {
146
+ return candidate;
147
+ }
148
+ }
149
+ return undefined;
150
+ }
151
+
152
+ /**
153
+ * So Recharts allows users to provide their own domains,
154
+ * but it also places some expectations on what the domain is.
155
+ * We can improve on the typescript typing, but we also need a runtime test
156
+ * to observe that the user-provided domain is well-formed,
157
+ * that is: an array with exactly two numbers.
158
+ * If the user-provided domain is not well-formed,
159
+ * this function will return undefined - in which case we should traverse the data to calculate the real domain.
160
+ *
161
+ * This function is for parsing the numerical domain only.
162
+ *
163
+ * You are probably thinking, why does domain need tick count?
164
+ * Well it adjusts the domain based on where the "nice ticks" land, and nice ticks depend on the tick count.
165
+ *
166
+ * @param userDomain external prop, user provided, before validation. Can have various shapes: array, function, special magical strings inside too.
167
+ * @param dataDomain calculated from data. Can be undefined, as an option for performance optimization
168
+ * @param allowDataOverflow provided by users. If true then the data domain wins
169
+ *
170
+ * @return [min, max] domain if it's well-formed; undefined if the domain is invalid
171
+ */
172
+ export function parseNumericalUserDomain(userDomain, dataDomain, allowDataOverflow) {
173
+ if (!allowDataOverflow && dataDomain == null) {
174
+ // Cannot compute data overflow if the data is not provided
175
+ return undefined;
176
+ }
177
+ if (typeof userDomain === 'function' && dataDomain != null) {
178
+ try {
179
+ var result = userDomain(dataDomain, allowDataOverflow);
180
+ if (isWellFormedNumberDomain(result)) {
181
+ return extendDomain(result, dataDomain, allowDataOverflow);
182
+ }
183
+ } catch (_unused) {
184
+ /* ignore the exception and compute domain from data later */
185
+ }
186
+ }
187
+ if (Array.isArray(userDomain) && userDomain.length === 2) {
188
+ var _userDomain2 = _slicedToArray(userDomain, 2),
189
+ providedMin = _userDomain2[0],
190
+ providedMax = _userDomain2[1];
191
+ var finalMin, finalMax;
192
+ if (providedMin === 'auto') {
193
+ if (dataDomain != null) {
194
+ finalMin = Math.min(...dataDomain);
195
+ }
196
+ } else if (isNumber(providedMin)) {
197
+ finalMin = providedMin;
198
+ } else if (typeof providedMin === 'function') {
199
+ try {
200
+ if (dataDomain != null) {
201
+ finalMin = providedMin(
202
+ dataDomain === null || dataDomain === void 0 ? void 0 : dataDomain[0],
203
+ );
204
+ }
205
+ } catch (_unused2) {
206
+ /* ignore the exception and compute domain from data later */
207
+ }
208
+ } else if (typeof providedMin === 'string' && MIN_VALUE_REG.test(providedMin)) {
209
+ var match = MIN_VALUE_REG.exec(providedMin);
210
+ if (match == null || match[1] == null || dataDomain == null) {
211
+ finalMin = undefined;
212
+ } else {
213
+ var value = +match[1];
214
+ finalMin = dataDomain[0] - value;
215
+ }
216
+ } else {
217
+ finalMin = dataDomain === null || dataDomain === void 0 ? void 0 : dataDomain[0];
218
+ }
219
+ if (providedMax === 'auto') {
220
+ if (dataDomain != null) {
221
+ finalMax = Math.max(...dataDomain);
222
+ }
223
+ } else if (isNumber(providedMax)) {
224
+ finalMax = providedMax;
225
+ } else if (typeof providedMax === 'function') {
226
+ try {
227
+ if (dataDomain != null) {
228
+ finalMax = providedMax(
229
+ dataDomain === null || dataDomain === void 0 ? void 0 : dataDomain[1],
230
+ );
231
+ }
232
+ } catch (_unused3) {
233
+ /* ignore the exception and compute domain from data later */
234
+ }
235
+ } else if (typeof providedMax === 'string' && MAX_VALUE_REG.test(providedMax)) {
236
+ var _match = MAX_VALUE_REG.exec(providedMax);
237
+ if (_match == null || _match[1] == null || dataDomain == null) {
238
+ finalMax = undefined;
239
+ } else {
240
+ var _value = +_match[1];
241
+ finalMax = dataDomain[1] + _value;
242
+ }
243
+ } else {
244
+ finalMax = dataDomain === null || dataDomain === void 0 ? void 0 : dataDomain[1];
245
+ }
246
+ var candidate = [finalMin, finalMax];
247
+ if (isWellFormedNumberDomain(candidate)) {
248
+ if (dataDomain == null) {
249
+ return candidate;
250
+ }
251
+ return extendDomain(candidate, dataDomain, allowDataOverflow);
252
+ }
253
+ }
254
+ return undefined;
255
+ }
@@ -0,0 +1,8 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/isWellBehavedNumber.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ export function isWellBehavedNumber(n) {
4
+ return Number.isFinite(n);
5
+ }
6
+ export function isPositiveNumber(n) {
7
+ return typeof n === 'number' && n > 0 && Number.isFinite(n);
8
+ }
@@ -0,0 +1,96 @@
1
+ // Vendored from recharts@3.9.2 es6/util/propsAreEqual.js with ONE adaptation:
2
+ // shallowEqual comes from @octanejs/redux instead of react-redux (identical
3
+ // algorithm). Update by re-vendoring when the recharts devDependency moves.
4
+ import { shallowEqual } from '@octanejs/redux';
5
+ var propsToShallowCompare = new Set([
6
+ 'axisLine',
7
+ 'tickLine',
8
+ 'activeBar',
9
+ 'activeDot',
10
+ 'activeLabel',
11
+ 'activeShape',
12
+ 'allowEscapeViewBox',
13
+ 'background',
14
+ 'cursor',
15
+ 'dot',
16
+ 'label',
17
+ 'line',
18
+ 'margin',
19
+ 'padding',
20
+ 'position',
21
+ 'shape',
22
+ 'style',
23
+ 'tick',
24
+ 'wrapperStyle',
25
+ // radius can be an array of 4 numbers, easy to compare shallowly
26
+ 'radius',
27
+ 'throttledEvents',
28
+ ]);
29
+
30
+ /**
31
+ * When comparing two values, returns true if they are the same value or
32
+ * are both NaN.
33
+ *
34
+ * If we used just a simple triple equals, we would get false negatives for two NaNs
35
+ * which could cause extra re-renders so let's have this instead.
36
+ *
37
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Equality_comparisons_and_sameness#same-value-zero_equality
38
+ *
39
+ * @param x first value to compare
40
+ * @param y second value to compare
41
+ * return true if the same, false if different
42
+ */
43
+ function sameValueZero(x, y) {
44
+ if (x == null && y == null) {
45
+ /*
46
+ * treat null and undefined as equal. Internally in Recharts we make no difference between these two
47
+ * so there is no need to re-render.
48
+ */
49
+ return true;
50
+ }
51
+ if (typeof x === 'number' && typeof y === 'number') {
52
+ // x and y are equal (this is true for -0 and 0) or they are both NaN
53
+ // eslint-disable-next-line no-self-compare
54
+ return x === y || (x !== x && y !== y);
55
+ }
56
+ return x === y;
57
+ }
58
+
59
+ /**
60
+ * So usually React would compare only the first level of props using Object.is.
61
+ * However, in our case many props are objects or arrays, and our own docs recommend to do that!
62
+ * Therefore, we need a custom comparison function that does a shallow comparison of each prop value.
63
+ *
64
+ * Because charts can and do receive large props (typically the data array),
65
+ * we only limit this to a subset of known props that are likely to be objects/arrays.
66
+ *
67
+ * @param prevProps
68
+ * @param nextProps
69
+ */
70
+ export function propsAreEqual(prevProps, nextProps) {
71
+ var allKeys = new Set([...Object.keys(prevProps), ...Object.keys(nextProps)]);
72
+ for (var key of allKeys) {
73
+ /*
74
+ * If a key is on a special allowlist, go one level deeper
75
+ * and do a shallow comparison of the values.
76
+ */
77
+ if (propsToShallowCompare.has(key)) {
78
+ if (prevProps[key] == null && nextProps[key] == null) {
79
+ /*
80
+ * treat null and undefined as equal. Internally in Recharts we make no difference between these two
81
+ * so there is no need to re-render.
82
+ */
83
+ continue;
84
+ }
85
+ if (!shallowEqual(prevProps[key], nextProps[key])) {
86
+ return false;
87
+ }
88
+ /*
89
+ * Otherwise do a simple same-value comparison (with NaN support).
90
+ */
91
+ } else if (!sameValueZero(prevProps[key], nextProps[key])) {
92
+ return false;
93
+ }
94
+ }
95
+ return true;
96
+ }
@@ -0,0 +1,131 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/resolveDefaultProps.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ function ownKeys(e, r) {
4
+ var t = Object.keys(e);
5
+ if (Object.getOwnPropertySymbols) {
6
+ var o = Object.getOwnPropertySymbols(e);
7
+ (r &&
8
+ (o = o.filter(function (r) {
9
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
10
+ })),
11
+ t.push.apply(t, o));
12
+ }
13
+ return t;
14
+ }
15
+ function _objectSpread(e) {
16
+ for (var r = 1; r < arguments.length; r++) {
17
+ var t = null != arguments[r] ? arguments[r] : {};
18
+ r % 2
19
+ ? ownKeys(Object(t), !0).forEach(function (r) {
20
+ _defineProperty(e, r, t[r]);
21
+ })
22
+ : Object.getOwnPropertyDescriptors
23
+ ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))
24
+ : ownKeys(Object(t)).forEach(function (r) {
25
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
26
+ });
27
+ }
28
+ return e;
29
+ }
30
+ function _defineProperty(e, r, t) {
31
+ return (
32
+ (r = _toPropertyKey(r)) in e
33
+ ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 })
34
+ : (e[r] = t),
35
+ e
36
+ );
37
+ }
38
+ function _toPropertyKey(t) {
39
+ var i = _toPrimitive(t, 'string');
40
+ return 'symbol' == typeof i ? i : i + '';
41
+ }
42
+ function _toPrimitive(t, r) {
43
+ if ('object' != typeof t || !t) return t;
44
+ var e = t[Symbol.toPrimitive];
45
+ if (void 0 !== e) {
46
+ var i = e.call(t, r || 'default');
47
+ if ('object' != typeof i) return i;
48
+ throw new TypeError('@@toPrimitive must return a primitive value.');
49
+ }
50
+ return ('string' === r ? String : Number)(t);
51
+ }
52
+ /**
53
+ * This function mimics the behavior of the `defaultProps` static property in React.
54
+ * Functional components do not have a defaultProps property, so this function is useful to resolve default props.
55
+ *
56
+ * The common recommendation is to use ES6 destructuring with default values in the function signature,
57
+ * but you need to be careful there and make sure you destructure all the individual properties
58
+ * and not the whole object. See the test file for example.
59
+ *
60
+ * And because destructuring all properties one by one is a faff, and it's easy to miss one property,
61
+ * this function exists.
62
+ *
63
+ * @param realProps - the props object passed to the component by the user
64
+ * @param defaultProps - the default props object defined in the component by Recharts
65
+ * @returns - the props object with all the default props resolved. All `undefined` values are replaced with the default value.
66
+ */
67
+ export function resolveDefaultProps(realProps, defaultProps) {
68
+ /*
69
+ * To avoid mutating the original `realProps` object passed to the function, create a shallow copy of it.
70
+ * `resolvedProps` will be modified directly with the defaults.
71
+ */
72
+ var resolvedProps = _objectSpread({}, realProps);
73
+ /*
74
+ * Since the function guarantees `D extends Partial<T>`, this assignment is safe.
75
+ * It allows TypeScript to work with the well-defined `Partial<T>` type inside the loop,
76
+ * making subsequent type inference (especially for `dp[key]`) much more straightforward for the compiler.
77
+ * This is a key step to improve type safety *without* value assertions later.
78
+ */
79
+ var dp = defaultProps;
80
+ /*
81
+ * `Object.keys` doesn't preserve strong key types - it always returns Array<string>.
82
+ * However, due to the `D extends Partial<T>` constraint,
83
+ * we know these keys *must* also be valid keys of `T`.
84
+ * This assertion informs TypeScript of this relationship, avoiding type errors when using `key` to index `acc` (type T).
85
+ *
86
+ * Type assertions are not sound but in this case it's necessary
87
+ * as `Object.keys` does not do what we want it to do.
88
+ */
89
+ var keys = Object.keys(defaultProps);
90
+ var withDefaults = keys.reduce((acc, key) => {
91
+ if (acc[key] === undefined && dp[key] !== undefined) {
92
+ acc[key] = dp[key];
93
+ }
94
+ return acc;
95
+ }, resolvedProps);
96
+ /*
97
+ * And again type assertions are not safe but here we have done the runtime work
98
+ * so let's bypass the lack of static type safety and tell the compiler what happened.
99
+ */
100
+ return withDefaults;
101
+ }
102
+
103
+ /**
104
+ * Helper type to extract the keys of T that are required.
105
+ * It iterates through each key K in T. If Pick<T, K> cannot be assigned an empty object {},
106
+ * it means K is required, so we keep K; otherwise, we discard it (never).
107
+ * [keyof T] at the end creates a union of the kept keys.
108
+ */
109
+
110
+ /**
111
+ * Helper type to extract the keys of T that are optional.
112
+ * It iterates through each key K in T. If Pick<T, K> can be assigned an empty object {},
113
+ * it means K is optional (or potentially missing), so we keep K; otherwise, we discard it (never).
114
+ * [keyof T] at the end creates a union of the kept keys.
115
+ */
116
+
117
+ /**
118
+ * Helper type to ensure keys of D exist in T.
119
+ * For each key K in D, if K is also a key of T, keep the type D[K].
120
+ * If K is NOT a key of T, map it to type `never`.
121
+ * An object cannot have a property of type `never`, effectively disallowing extra keys.
122
+ */
123
+
124
+ /**
125
+ * This type will take a source type `Props` and a default type `Defaults` and will return a new type
126
+ * where all properties that are optional in `Props` but required in `Defaults` are made required in the result.
127
+ * Properties that are required in `Props` and optional in `Defaults` will remain required.
128
+ * Properties that are optional in both `Props` and `Defaults` will remain optional.
129
+ *
130
+ * This is useful for creating a type that represents the resolved props of a component with default props.
131
+ */
@@ -0,0 +1,39 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/round.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ // if you go lower than 3, wild wild things happen during rendering
4
+ var defaultRoundPrecision = 4;
5
+ export function round(num) {
6
+ var roundPrecision =
7
+ arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultRoundPrecision;
8
+ var factor = 10 ** roundPrecision;
9
+ var rounded = Math.round(num * factor) / factor;
10
+ if (Object.is(rounded, -0)) {
11
+ return 0;
12
+ }
13
+ return rounded;
14
+ }
15
+
16
+ /**
17
+ * This function will accept a string template literal and for each
18
+ * variable placeholder, it will round the value to avoid long float numbers in
19
+ * the SVG path which might cause rendering issues in some browsers.
20
+ */
21
+ export function roundTemplateLiteral(strings) {
22
+ for (
23
+ var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1;
24
+ _key < _len;
25
+ _key++
26
+ ) {
27
+ values[_key - 1] = arguments[_key];
28
+ }
29
+ return strings.reduce((result, string, i) => {
30
+ var value = values[i - 1];
31
+ if (typeof value === 'string') {
32
+ return result + value + string;
33
+ }
34
+ if (value !== undefined) {
35
+ return result + round(value) + string;
36
+ }
37
+ return result + string;
38
+ }, '');
39
+ }
@@ -0,0 +1,68 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/scale/RechartsScale.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ /**
4
+ * This is internal representation of scale used in Recharts.
5
+ * Users will provide CustomScaleDefinition or a string, which we will parse into RechartsScale.
6
+ * Most importantly, RechartsScale is fully immutable - there are no setters that mutate the scale in place.
7
+ * This is important for React integration - if the scale changes, we want to trigger re-renders.
8
+ * Mutating the scale in place would not trigger re-renders, leading to stale UI.
9
+ */
10
+
11
+ /**
12
+ * Position within a band for banded scales.
13
+ * In scales that are not banded, this parameter is ignored.
14
+ *
15
+ * @inline
16
+ */
17
+
18
+ export function rechartsScaleFactory(d3Scale) {
19
+ if (d3Scale == null) {
20
+ return undefined;
21
+ }
22
+ var ticksFn = d3Scale.ticks;
23
+ var bandwidthFn = d3Scale.bandwidth;
24
+ var d3Range = d3Scale.range();
25
+ var range = [Math.min(...d3Range), Math.max(...d3Range)];
26
+ return {
27
+ domain: () => d3Scale.domain(),
28
+ range: (function (_range) {
29
+ function range() {
30
+ return _range.apply(this, arguments);
31
+ }
32
+ range.toString = function () {
33
+ return _range.toString();
34
+ };
35
+ return range;
36
+ })(() => range),
37
+ rangeMin: () => range[0],
38
+ rangeMax: () => range[1],
39
+ isInRange(value) {
40
+ var first = range[0];
41
+ var last = range[1];
42
+ return first <= last ? value >= first && value <= last : value >= last && value <= first;
43
+ },
44
+ bandwidth: bandwidthFn ? () => bandwidthFn.call(d3Scale) : undefined,
45
+ ticks: ticksFn ? (count) => ticksFn.call(d3Scale, count) : undefined,
46
+ map: (input, options) => {
47
+ var baseValue = d3Scale(input);
48
+ if (baseValue == null) {
49
+ return undefined;
50
+ }
51
+ if (d3Scale.bandwidth && options !== null && options !== void 0 && options.position) {
52
+ var bandWidth = d3Scale.bandwidth();
53
+ switch (options.position) {
54
+ case 'middle':
55
+ baseValue += bandWidth / 2;
56
+ break;
57
+ case 'end':
58
+ baseValue += bandWidth;
59
+ break;
60
+ default:
61
+ // 'start' requires no adjustment
62
+ break;
63
+ }
64
+ }
65
+ return baseValue;
66
+ },
67
+ };
68
+ }
@@ -0,0 +1,77 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/scale/createCategoricalInverse.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ /**
4
+ * Binary search to find the index where x would fit in array a.
5
+ * Works for arrays that are sorted both ascending and descending.
6
+ *
7
+ * Unlike d3.bisect, this implementation handles both ascending and descending arrays.
8
+ *
9
+ * @param haystack Sorted array of numbers
10
+ * @param needle Number to find the insertion index for
11
+ * @returns Index where x would fit in array a
12
+ */
13
+ export function bisect(haystack, needle) {
14
+ var lo = 0;
15
+ var hi = haystack.length;
16
+ var ascending = haystack[0] < haystack[haystack.length - 1];
17
+ while (lo < hi) {
18
+ var mid = Math.floor((lo + hi) / 2);
19
+ if (ascending ? haystack[mid] < needle : haystack[mid] > needle) {
20
+ lo = mid + 1;
21
+ } else {
22
+ hi = mid;
23
+ }
24
+ }
25
+ return lo;
26
+ }
27
+
28
+ /**
29
+ * Computes an inverse scale function for categorical/ordinal scales.
30
+ * Uses bisect to find the closest domain value for a given pixel coordinate.
31
+ */
32
+ export function createCategoricalInverse(scale, allDataPointsOnAxis) {
33
+ if (!scale) {
34
+ return undefined;
35
+ }
36
+ var domain =
37
+ allDataPointsOnAxis !== null && allDataPointsOnAxis !== void 0
38
+ ? allDataPointsOnAxis
39
+ : scale.domain();
40
+ // Build an array of pixel positions for each domain value
41
+ // @ts-expect-error we're attempting to scale unknown without having guarantee that it is a Domain type
42
+ var pixelPositions = domain.map((d) => {
43
+ var _scale;
44
+ return (_scale = scale(d)) !== null && _scale !== void 0 ? _scale : 0;
45
+ });
46
+ var range = scale.range();
47
+ if (domain.length === 0 || range.length < 2) {
48
+ return undefined;
49
+ }
50
+ return (pixelValue) => {
51
+ var _pixelPositions, _pixelPositions$index;
52
+ // Find the closest domain value using bisect
53
+ var index = bisect(pixelPositions, pixelValue);
54
+
55
+ // Clamp to valid range
56
+ if (index <= 0) {
57
+ return domain[0];
58
+ }
59
+ if (index >= domain.length) {
60
+ return domain[domain.length - 1];
61
+ }
62
+
63
+ // Check which neighbor is closer
64
+ var leftPixel =
65
+ (_pixelPositions = pixelPositions[index - 1]) !== null && _pixelPositions !== void 0
66
+ ? _pixelPositions
67
+ : 0;
68
+ var rightPixel =
69
+ (_pixelPositions$index = pixelPositions[index]) !== null && _pixelPositions$index !== void 0
70
+ ? _pixelPositions$index
71
+ : 0;
72
+ if (Math.abs(pixelValue - leftPixel) <= Math.abs(pixelValue - rightPixel)) {
73
+ return domain[index - 1];
74
+ }
75
+ return domain[index];
76
+ };
77
+ }