victory-core 36.5.3 → 36.6.2

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 (107) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/victory-core.js +5305 -4728
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/index.d.ts +2 -1
  5. package/es/types/callbacks.d.ts +2 -1
  6. package/es/victory-animation/victory-animation.js +1 -1
  7. package/es/victory-label/victory-label.d.ts +4 -8
  8. package/es/victory-label/victory-label.js +19 -19
  9. package/es/victory-portal/portal.js +2 -2
  10. package/es/victory-primitives/arc.js +1 -1
  11. package/es/victory-primitives/circle.d.ts +1 -0
  12. package/es/victory-primitives/line.d.ts +1 -0
  13. package/es/victory-primitives/path.d.ts +1 -0
  14. package/es/victory-primitives/rect.d.ts +1 -0
  15. package/es/victory-primitives/tspan.d.ts +1 -0
  16. package/es/victory-state/victory-provider.d.ts +1 -0
  17. package/es/victory-transition/victory-transition.js +22 -22
  18. package/es/victory-util/add-events.d.ts +30 -9
  19. package/es/victory-util/add-events.js +4 -5
  20. package/es/victory-util/axis.js +22 -20
  21. package/es/victory-util/collection.d.ts +2 -2
  22. package/es/victory-util/data.d.ts +1 -1
  23. package/es/victory-util/data.js +2 -2
  24. package/es/victory-util/domain.js +4 -4
  25. package/es/victory-util/events.d.ts +1 -1
  26. package/es/victory-util/events.js +2 -2
  27. package/es/victory-util/helpers.d.ts +2 -1
  28. package/es/victory-util/hooks/use-animation-state.d.ts +22 -0
  29. package/es/victory-util/hooks/use-animation-state.js +2 -2
  30. package/es/victory-util/label-helpers.js +12 -12
  31. package/es/victory-util/prop-types.js +2 -2
  32. package/es/victory-util/scale.js +1 -1
  33. package/es/victory-util/selection.d.ts +6 -2
  34. package/es/victory-util/selection.js +16 -16
  35. package/es/victory-util/style.js +12 -12
  36. package/es/victory-util/textsize.js +2 -2
  37. package/es/victory-util/transitions.js +2 -2
  38. package/es/victory-util/user-props.d.ts +1 -1
  39. package/es/victory-util/user-props.js +3 -1
  40. package/es/victory-util/with-container.d.ts +2 -2
  41. package/es/victory-util/with-container.js +2 -1
  42. package/es/victory-util/wrapper.d.ts +1 -1
  43. package/es/victory-util/wrapper.js +8 -8
  44. package/lib/index.d.ts +2 -1
  45. package/lib/types/callbacks.d.ts +2 -1
  46. package/lib/victory-label/victory-label.d.ts +4 -8
  47. package/lib/victory-label/victory-label.js +19 -19
  48. package/lib/victory-portal/portal.js +2 -2
  49. package/lib/victory-primitives/circle.d.ts +1 -0
  50. package/lib/victory-primitives/line.d.ts +1 -0
  51. package/lib/victory-primitives/path.d.ts +1 -0
  52. package/lib/victory-primitives/rect.d.ts +1 -0
  53. package/lib/victory-primitives/tspan.d.ts +1 -0
  54. package/lib/victory-state/victory-provider.d.ts +1 -0
  55. package/lib/victory-transition/victory-transition.js +21 -21
  56. package/lib/victory-util/add-events.d.ts +30 -9
  57. package/lib/victory-util/add-events.js +4 -4
  58. package/lib/victory-util/axis.js +22 -20
  59. package/lib/victory-util/collection.d.ts +2 -2
  60. package/lib/victory-util/data.d.ts +1 -1
  61. package/lib/victory-util/data.js +2 -2
  62. package/lib/victory-util/domain.js +4 -4
  63. package/lib/victory-util/events.d.ts +1 -1
  64. package/lib/victory-util/events.js +2 -2
  65. package/lib/victory-util/helpers.d.ts +2 -1
  66. package/lib/victory-util/hooks/use-animation-state.d.ts +22 -0
  67. package/lib/victory-util/hooks/use-animation-state.js +2 -2
  68. package/lib/victory-util/label-helpers.js +12 -12
  69. package/lib/victory-util/prop-types.js +2 -2
  70. package/lib/victory-util/scale.js +1 -1
  71. package/lib/victory-util/selection.d.ts +6 -2
  72. package/lib/victory-util/selection.js +21 -17
  73. package/lib/victory-util/style.js +12 -12
  74. package/lib/victory-util/textsize.js +2 -2
  75. package/lib/victory-util/transitions.js +2 -2
  76. package/lib/victory-util/user-props.d.ts +1 -1
  77. package/lib/victory-util/user-props.js +3 -1
  78. package/lib/victory-util/with-container.d.ts +2 -2
  79. package/lib/victory-util/with-container.js +5 -3
  80. package/lib/victory-util/wrapper.d.ts +1 -1
  81. package/lib/victory-util/wrapper.js +8 -8
  82. package/package.json +261 -7
  83. package/src/index.ts +2 -4
  84. package/src/types/callbacks.ts +3 -1
  85. package/src/victory-animation/victory-animation.tsx +1 -1
  86. package/src/victory-label/victory-label.tsx +24 -28
  87. package/src/victory-primitives/arc.tsx +1 -1
  88. package/src/victory-transition/victory-transition.tsx +24 -26
  89. package/src/victory-util/add-events.tsx +59 -15
  90. package/src/victory-util/axis.tsx +12 -13
  91. package/src/victory-util/collection.tsx +13 -4
  92. package/src/victory-util/data.ts +2 -3
  93. package/src/victory-util/domain.ts +6 -6
  94. package/src/victory-util/events.ts +3 -3
  95. package/src/victory-util/helpers.ts +5 -1
  96. package/src/victory-util/hooks/{use-animation-state.js → use-animation-state.ts} +23 -8
  97. package/src/victory-util/label-helpers.ts +8 -12
  98. package/src/victory-util/point-path-helpers.ts +1 -1
  99. package/src/victory-util/prop-types.ts +1 -2
  100. package/src/victory-util/scale.ts +1 -1
  101. package/src/victory-util/selection.ts +15 -14
  102. package/src/victory-util/style.ts +10 -11
  103. package/src/victory-util/textsize.ts +3 -3
  104. package/src/victory-util/transitions.ts +1 -2
  105. package/src/victory-util/user-props.ts +2 -1
  106. package/src/victory-util/with-container.tsx +4 -7
  107. package/src/victory-util/wrapper.tsx +9 -11
package/es/index.d.ts CHANGED
@@ -12,7 +12,8 @@ export * from "./victory-portal/portal";
12
12
  export * from "./victory-portal/portal-context";
13
13
  export * from "./victory-portal/victory-portal";
14
14
  export * from "./victory-primitives";
15
- export { Border as Box, type BorderProps as BoxProps, } from "./victory-primitives";
15
+ export { Border as Box } from "./victory-primitives";
16
+ export type { BorderProps as BoxProps } from "./victory-primitives";
16
17
  export * from "./victory-util";
17
18
  export * from "./victory-state";
18
19
  //# sourceMappingURL=index.d.ts.map
@@ -12,7 +12,7 @@ export interface CallbackArgs {
12
12
  data?: Datum[];
13
13
  datum?: Datum;
14
14
  horizontal?: boolean;
15
- index: ID;
15
+ index?: ID;
16
16
  x?: number;
17
17
  y?: number;
18
18
  scale?: {
@@ -34,4 +34,5 @@ export declare type VictoryOrientationCallback = (args: CallbackArgs) => Orienta
34
34
  export declare type NumberOrCallback = number | VictoryNumberCallback;
35
35
  export declare type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback;
36
36
  export declare type OrientationOrCallback = OrientationTypes | VictoryOrientationCallback;
37
+ export declare type ValueOrCallback<TValue> = TValue | ((args: CallbackArgs) => TValue);
37
38
  //# sourceMappingURL=callbacks.d.ts.map
@@ -30,7 +30,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
30
30
 
31
31
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
32
32
 
33
- /*global setTimeout:false */
33
+ /* global setTimeout:false */
34
34
  import React from "react";
35
35
  import PropTypes from "prop-types";
36
36
  import * as d3Ease from "victory-vendor/d3-ease";
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback } from "../types/callbacks";
2
+ import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback, ValueOrCallback } from "../types/callbacks";
3
3
  import { PaddingProps, VerticalAnchorType, VictoryLabelStyleObject } from "../victory-theme/victory-theme";
4
4
  export declare type TextAnchorType = "start" | "middle" | "end" | "inherit";
5
5
  export declare type OriginType = {
@@ -34,15 +34,11 @@ export interface VictoryLabelProps {
34
34
  tabIndex?: NumberOrCallback;
35
35
  text?: string[] | StringOrNumberOrCallback;
36
36
  textComponent?: React.ReactElement;
37
- textAnchor?: TextAnchorType | {
38
- (): TextAnchorType;
39
- };
37
+ textAnchor?: ValueOrCallback<TextAnchorType>;
40
38
  title?: string;
41
- transform?: string | object | (() => string | object);
39
+ transform?: ValueOrCallback<string | object>;
42
40
  tspanComponent?: React.ReactElement;
43
- verticalAnchor?: VerticalAnchorType | {
44
- (): VerticalAnchorType;
45
- };
41
+ verticalAnchor?: ValueOrCallback<VerticalAnchorType>;
46
42
  x?: number;
47
43
  y?: number;
48
44
  dx?: StringOrNumberOrCallback;
@@ -57,14 +57,14 @@ var getFontSize = function (style) {
57
57
  } else if (baseSize === undefined || baseSize === null) {
58
58
  return defaultStyles.fontSize;
59
59
  } else if (typeof baseSize === "string") {
60
- var fontSize = +baseSize.replace("px", "");
60
+ var fontSize = Number(baseSize.replace("px", ""));
61
61
 
62
62
  if (!isNaN(fontSize)) {
63
63
  return fontSize;
64
- } else {
65
- Log.warn("fontSize should be expressed as a number of pixels");
66
- return defaultStyles.fontSize;
67
64
  }
65
+
66
+ Log.warn("fontSize should be expressed as a number of pixels");
67
+ return defaultStyles.fontSize;
68
68
  }
69
69
 
70
70
  return defaultStyles.fontSize;
@@ -121,12 +121,12 @@ var getBackgroundPadding = function (props) {
121
121
  padding: padding
122
122
  });
123
123
  });
124
- } else {
125
- var padding = Helpers.evaluateProp(props.backgroundPadding, props);
126
- return Helpers.getPadding({
127
- padding: padding
128
- });
129
124
  }
125
+
126
+ var padding = Helpers.evaluateProp(props.backgroundPadding, props);
127
+ return Helpers.getPadding({
128
+ padding: padding
129
+ });
130
130
  };
131
131
 
132
132
  var getLineHeight = function (props) {
@@ -134,9 +134,9 @@ var getLineHeight = function (props) {
134
134
 
135
135
  if (Array.isArray(lineHeight)) {
136
136
  return _isEmpty(lineHeight) ? [1] : lineHeight;
137
- } else {
138
- return lineHeight;
139
137
  }
138
+
139
+ return lineHeight;
140
140
  };
141
141
 
142
142
  var getContent = function (text, props) {
@@ -179,13 +179,13 @@ var getDy = function (props, verticalAnchor, lineHeight) {
179
179
  return anchor === "end" ? dy + (capHeight / 2 - lineHeights[0] / 2) * fontSizes[0] : dy + capHeight / 2 * fontSizes[0];
180
180
  } else if (length === 1) {
181
181
  return anchor === "end" ? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0] : dy + (capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0];
182
- } else {
183
- var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) {
184
- return memo + (capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i] / length;
185
- }, 0);
186
-
187
- return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1];
188
182
  }
183
+
184
+ var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) {
185
+ return memo + (capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i] / length;
186
+ }, 0);
187
+
188
+ return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1];
189
189
  };
190
190
 
191
191
  var getTransform = function (props, x, y) {
@@ -389,9 +389,9 @@ var getTSpanDy = function (tspanValues, calculatedProps, i) {
389
389
  return calculateSpanDy(tspanValues, i, calculatedProps);
390
390
  } else if (inline) {
391
391
  return i === 0 ? current.backgroundPadding.top : undefined;
392
- } else {
393
- return current.backgroundPadding.top;
394
392
  }
393
+
394
+ return current.backgroundPadding.top;
395
395
  };
396
396
 
397
397
  var evaluateProps = function (props) {
@@ -23,8 +23,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
23
23
  import React from "react";
24
24
  import PropTypes from "prop-types";
25
25
  import * as CustomPropTypes from "../victory-util/prop-types";
26
- export var Portal = /*#__PURE__*/function (_React$Component) {
27
- _inherits(Portal, _React$Component);
26
+ export var Portal = /*#__PURE__*/function (_ref) {
27
+ _inherits(Portal, _ref);
28
28
 
29
29
  var _super = _createSuper(Portal);
30
30
 
@@ -6,7 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
8
 
9
- /*eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
9
+ /* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
10
10
  import React from "react";
11
11
  import PropTypes from "prop-types";
12
12
  import * as Helpers from "../victory-util/helpers";
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryPrimitiveShapeProps } from "./types";
2
3
  export declare const Circle: (props: VictoryPrimitiveShapeProps) => JSX.Element;
3
4
  //# sourceMappingURL=circle.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryPrimitiveShapeProps } from "./types";
2
3
  export declare const Line: (props: VictoryPrimitiveShapeProps) => JSX.Element;
3
4
  //# sourceMappingURL=line.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryPrimitiveShapeProps } from "./types";
2
3
  export declare const Path: (props: VictoryPrimitiveShapeProps) => JSX.Element;
3
4
  //# sourceMappingURL=path.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryPrimitiveShapeProps } from "./types";
2
3
  export declare const Rect: (props: VictoryPrimitiveShapeProps) => JSX.Element;
3
4
  //# sourceMappingURL=rect.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryCommonPrimitiveProps } from "../victory-util/common-props";
2
3
  export declare const TSpan: (props: VictoryCommonPrimitiveProps) => JSX.Element;
3
4
  //# sourceMappingURL=tspan.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { D3ScaleFn, DomainTuple, ForAxes } from "../types/prop-types";
2
3
  import { FormattedDatum } from "./helpers/get-data";
3
4
  import { VictoryCalculatedStateProps, VictoryProviderProps } from "./types";
@@ -62,7 +62,7 @@ export var VictoryTransition = /*#__PURE__*/function (_React$Component) {
62
62
  value: function componentDidMount() {
63
63
  this.setState({
64
64
  nodesShouldLoad: true
65
- }); //eslint-disable-line react/no-did-mount-set-state
65
+ }); // eslint-disable-line react/no-did-mount-set-state
66
66
  }
67
67
  }, {
68
68
  key: "shouldComponentUpdate",
@@ -97,25 +97,25 @@ export var VictoryTransition = /*#__PURE__*/function (_React$Component) {
97
97
  oldProps: oldProps,
98
98
  nextProps: nextProps
99
99
  };
100
- } else {
101
- var oldChildren = React.Children.toArray(props.children);
102
- var nextChildren = React.Children.toArray(nextProps.children);
103
-
104
- var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
105
- nodesWillExit = _Transitions$getIniti.nodesWillExit,
106
- nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
107
- childrenTransitions = _Transitions$getIniti.childrenTransitions,
108
- nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
109
-
110
- return {
111
- nodesWillExit: nodesWillExit,
112
- nodesWillEnter: nodesWillEnter,
113
- childrenTransitions: childrenTransitions,
114
- nodesShouldEnter: nodesShouldEnter,
115
- oldProps: nodesWillExit ? props : null,
116
- nextProps: nextProps
117
- };
118
100
  }
101
+
102
+ var oldChildren = React.Children.toArray(props.children);
103
+ var nextChildren = React.Children.toArray(nextProps.children);
104
+
105
+ var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
106
+ nodesWillExit = _Transitions$getIniti.nodesWillExit,
107
+ nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
108
+ childrenTransitions = _Transitions$getIniti.childrenTransitions,
109
+ nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
110
+
111
+ return {
112
+ nodesWillExit: nodesWillExit,
113
+ nodesWillEnter: nodesWillEnter,
114
+ childrenTransitions: childrenTransitions,
115
+ nodesShouldEnter: nodesShouldEnter,
116
+ oldProps: nodesWillExit ? props : null,
117
+ nextProps: nextProps
118
+ };
119
119
  }
120
120
  }, {
121
121
  key: "getDomainFromChildren",
@@ -139,10 +139,10 @@ export var VictoryTransition = /*#__PURE__*/function (_React$Component) {
139
139
 
140
140
  if (!childProps.children && domain) {
141
141
  return domain;
142
- } else {
143
- var childDomains = getChildDomains([child]);
144
- return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
145
142
  }
143
+
144
+ var childDomains = getChildDomains([child]);
145
+ return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
146
146
  }
147
147
  }, {
148
148
  key: "pickProps",
@@ -6,7 +6,7 @@ import { VictoryLabelableProps } from "../types/prop-types";
6
6
  export declare type MixinOptions = {
7
7
  components?: Array<{
8
8
  name: string;
9
- index?: string;
9
+ index?: string | number;
10
10
  }>;
11
11
  };
12
12
  export interface EventMixinCommonProps extends VictoryCommonProps, VictoryDatableProps, VictoryLabelableProps {
@@ -21,11 +21,14 @@ export interface EventMixinCommonProps extends VictoryCommonProps, VictoryDatabl
21
21
  * class MyComponent extends React.Component<MyProps> { ... }
22
22
  */
23
23
  export interface EventsMixinClass<TProps> {
24
- renderContainer(component: React.ReactElement, children: React.ReactElement[]): React.ReactElement;
24
+ renderContainer(component: React.ReactElement, children: React.ReactElement | React.ReactElement[]): React.ReactElement;
25
25
  cacheValues<TThis>(this: TThis, obj: Partial<TThis>): void;
26
26
  getEventState: typeof Events.getEventState;
27
+ renderData(props: TProps): any;
27
28
  renderContinuousData(props: TProps): any;
28
- animateComponent(props: TProps, defaultAnimationWhitelist: any): any;
29
+ animateComponent(props: TProps, defaultAnimationWhitelist: string[]): React.ReactElement;
30
+ getComponentProps(component: React.ReactElement, type: string, index: number): TProps;
31
+ dataKeys: string[];
29
32
  }
30
33
  /**
31
34
  * These fields are calculated by the Mixin
@@ -38,14 +41,30 @@ export interface EventMixinCalculatedValues {
38
41
  hasEvents: unknown;
39
42
  events: unknown;
40
43
  }
44
+ /**
45
+ * These are the common roles that we care about internally.
46
+ */
47
+ export declare type VictoryComponentCommonRole = "container" | "group" | "histogram" | "label" | "line" | "portal" | "stack" | "tooltip" | "voronoi";
48
+ /**
49
+ * A component can have any "role",
50
+ * but there are certain ones that we actually care about internally
51
+ */
52
+ export declare type VictoryComponentRole = VictoryComponentCommonRole | string;
53
+ /**
54
+ * Static component fields used by Victory for common behavior
55
+ */
56
+ export interface VictoryComponentConfiguration<TProps> {
57
+ getBaseProps?(props: TProps): EventMixinCalculatedValues["baseProps"];
58
+ role?: VictoryComponentRole;
59
+ expectedComponents?: Array<keyof TProps | string>;
60
+ getChildren?: (props: TProps, childComponents?: Array<React.ReactNode>, calculatedProps?: TProps) => void;
61
+ animationWhitelist?: Array<keyof TProps | string>;
62
+ }
41
63
  /**
42
64
  * This represents the class itself, including static fields
43
65
  */
44
- export interface WrappedComponentClass<TProps> {
66
+ export interface WrappedComponentClass<TProps> extends VictoryComponentConfiguration<TProps> {
45
67
  new (props: TProps): React.Component<TProps>;
46
- getBaseProps?(props: TProps): EventMixinCalculatedValues["baseProps"];
47
- role?: string;
48
- expectedComponents?: string[];
49
68
  }
50
69
  export declare function addEvents<TBase extends WrappedComponentClass<TProps>, TProps extends EventMixinCommonProps>(WrappedComponent: TBase, options?: MixinOptions): {
51
70
  new (props: TProps): {
@@ -73,7 +92,7 @@ export declare function addEvents<TBase extends WrappedComponentClass<TProps>, T
73
92
  getAllEvents(props: any): any;
74
93
  getComponentProps(component: any, type: any, index: any): any;
75
94
  renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
76
- animateComponent(props: TProps, defaultAnimationWhitelist: string[]): JSX.Element;
95
+ animateComponent(props: TProps, defaultAnimationWhitelist: string[]): React.ReactElement;
77
96
  renderContinuousData(props: TProps): React.DetailedReactHTMLElement<any, HTMLElement>;
78
97
  renderData(props: any, shouldRenderDatum?: (datum: any) => boolean): React.DetailedReactHTMLElement<any, HTMLElement>;
79
98
  context: unknown;
@@ -101,6 +120,8 @@ export declare function addEvents<TBase extends WrappedComponentClass<TProps>, T
101
120
  };
102
121
  getBaseProps?(props: TProps): Record<string, object>;
103
122
  role?: string | undefined;
104
- expectedComponents?: string[] | undefined;
123
+ expectedComponents?: (string | keyof TProps)[] | undefined;
124
+ getChildren?: ((props: TProps, childComponents?: React.ReactNode[] | undefined, calculatedProps?: TProps | undefined) => void) | undefined;
125
+ animationWhitelist?: (string | keyof TProps)[] | undefined;
105
126
  } & TBase;
106
127
  //# sourceMappingURL=add-events.d.ts.map
@@ -40,7 +40,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
40
40
 
41
41
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
42
 
43
- /*global window:false */
44
43
  import React from "react";
45
44
  import * as Events from "./events";
46
45
  import isEqual from "react-fast-compare";
@@ -210,11 +209,11 @@ export function addEvents(WrappedComponent) {
210
209
  if (!props.standalone && component.name === "parent") {
211
210
  // don't check for changes on parent props for non-standalone components
212
211
  return undefined;
213
- } else {
214
- return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
215
- return getState(key, component.name);
216
- }).filter(Boolean);
217
212
  }
213
+
214
+ return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
215
+ return getState(key, component.name);
216
+ }).filter(Boolean);
218
217
  }).filter(Boolean);
219
218
  return stateChanges;
220
219
  }
@@ -160,22 +160,22 @@ function getDefaultTickFormat(props) {
160
160
  return stringTicks(props) ? function (x, index) {
161
161
  return tickValues[index];
162
162
  } : fallbackFormat;
163
- } else {
164
- var invertedStringMap = stringMap && _invert(stringMap);
163
+ }
165
164
 
166
- var tickValueArray = _orderBy(_values(stringMap), function (n) {
167
- return n;
168
- });
165
+ var invertedStringMap = stringMap && _invert(stringMap);
169
166
 
170
- var dataNames = tickValueArray.map(function (tick) {
171
- return invertedStringMap[tick];
172
- }); // string ticks should have one tick of padding at the beginning
167
+ var tickValueArray = _orderBy(_values(stringMap), function (n) {
168
+ return n;
169
+ });
173
170
 
174
- var dataTicks = [""].concat(_toConsumableArray(dataNames), [""]);
175
- return function (x) {
176
- return dataTicks[x];
177
- };
178
- }
171
+ var dataNames = tickValueArray.map(function (tick) {
172
+ return invertedStringMap[tick];
173
+ }); // string ticks should have one tick of padding at the beginning
174
+
175
+ var dataTicks = [""].concat(_toConsumableArray(dataNames), [""]);
176
+ return function (x) {
177
+ return dataTicks[x];
178
+ };
179
179
  }
180
180
 
181
181
  function getStringTicks(props) {
@@ -242,7 +242,9 @@ function getTickArray(props) {
242
242
  }
243
243
  });
244
244
  return newTickArray;
245
- } else return undefined;
245
+ }
246
+
247
+ return undefined;
246
248
  };
247
249
 
248
250
  return Array.isArray(tickArray) && tickArray.length ? buildTickArray(tickArray) : undefined;
@@ -284,11 +286,11 @@ export function getTickFormat(props, scale) {
284
286
  };
285
287
 
286
288
  return stringMap ? applyStringTicks : tickFormat;
287
- } else {
288
- return function (x) {
289
- return x;
290
- };
291
289
  }
290
+
291
+ return function (x) {
292
+ return x;
293
+ };
292
294
  }
293
295
 
294
296
  function downsampleTicks(ticks, tickCount) {
@@ -335,7 +337,7 @@ export function getTicks(props, scale) {
335
337
  * @param {String} axis: either x or y
336
338
  * @returns {Array} returns a domain from tickValues
337
339
  */
338
- //eslint-disable-next-line max-statements
340
+ // eslint-disable-next-line max-statements
339
341
 
340
342
  function getDomainFromData(props, axis) {
341
343
  var polar = props.polar,
@@ -356,7 +358,7 @@ function getDomainFromData(props, axis) {
356
358
  var maxDomain = Domain.getMaxFromProps(props, axis);
357
359
  var tickStrings = stringTicks(props);
358
360
  var ticks = tickValues.map(function (value) {
359
- return +value;
361
+ return Number(value);
360
362
  });
361
363
  var defaultMin = tickStrings ? 1 : Collection.getMinValue(ticks);
362
364
  var defaultMax = tickStrings ? tickValues.length : Collection.getMaxValue(ticks);
@@ -1,8 +1,8 @@
1
1
  export declare function containsStrings<T>(collection: Array<T>): boolean;
2
2
  export declare function containsDates(collection: Array<number | Date>): boolean;
3
3
  export declare function containsNumbers(collection: any): boolean;
4
- export declare function containsOnlyStrings(collection: any): any;
5
- export declare function isArrayOfArrays(collection: any): any;
4
+ export declare function containsOnlyStrings(collection: Array<string> | unknown): collection is Array<string>;
5
+ export declare function isArrayOfArrays<T>(collection: Array<T> | Array<Array<T>> | unknown): collection is Array<Array<T>>;
6
6
  export declare function removeUndefined(arr: any): any;
7
7
  export declare function getMaxValue(arr: Array<number | Date>, ...values: Array<number | Date>): number | Date;
8
8
  export declare function getMinValue(arr: Array<number | Date>, ...values: Array<number | Date>): number | Date;
@@ -1,4 +1,4 @@
1
- export declare function formatDataFromDomain(dataset: any, domain: any, defaultBaseline: any): any;
1
+ export declare function formatDataFromDomain(dataset: any, domain: any, defaultBaseline?: any): any;
2
2
  /**
3
3
  * Returns an object mapping string data to numeric data
4
4
  * @param {Object} props: the props object
@@ -141,9 +141,9 @@ function addEventKeys(props, data) {
141
141
  return eventKey !== undefined ? _assign({
142
142
  eventKey: eventKey
143
143
  }, datum) : datum;
144
- } else {
145
- return datum;
146
144
  }
145
+
146
+ return datum;
147
147
  });
148
148
  } // Exported Functions
149
149
  // This method will remove data points that fall outside of the desired domain (non-continuous charts only)
@@ -81,7 +81,7 @@ function getExtremeFromData(dataset, axis) {
81
81
  }, initialValue);
82
82
 
83
83
  return containsDate ? new Date(result) : result;
84
- } //eslint-disable-next-line max-statements
84
+ } // eslint-disable-next-line max-statements
85
85
 
86
86
 
87
87
  function padDomain(domain, props, axis) {
@@ -274,12 +274,12 @@ export function getDomainFromMinMax(min, max) {
274
274
  var verySmallNumber = // eslint-disable-next-line no-magic-numbers
275
275
  val === 0 ? 2 * Math.pow(10, -10) : Math.pow(10, -10);
276
276
  var verySmallDate = 1;
277
- var minVal = val instanceof Date ? new Date(+val - verySmallDate) : +val - verySmallNumber;
278
- var maxVal = val instanceof Date ? new Date(+val + verySmallDate) : +val + verySmallNumber;
277
+ var minVal = val instanceof Date ? new Date(Number(val) - verySmallDate) : Number(val) - verySmallNumber;
278
+ var maxVal = val instanceof Date ? new Date(Number(val) + verySmallDate) : Number(val) + verySmallNumber;
279
279
  return val === 0 ? [0, maxVal] : [minVal, maxVal];
280
280
  };
281
281
 
282
- return +min === +max ? getSinglePointDomain(max) : [min, max];
282
+ return Number(min) === Number(max) ? getSinglePointDomain(max) : [min, max];
283
283
  }
284
284
  /**
285
285
  * Returns a the domain for a given axis if domain is given in props
@@ -6,7 +6,7 @@ export interface ComponentEvent {
6
6
  eventKey?: ComponentEventKey | ComponentEventKey[];
7
7
  eventHandlers: ComponentEventHandlers;
8
8
  }
9
- export declare type ComponentEventName = `on${Capitalize<string>}`;
9
+ export declare type ComponentEventName = string;
10
10
  export interface ComponentEventHandlers {
11
11
  [k: ComponentEventName]: ComponentEventHandler;
12
12
  }
@@ -386,9 +386,9 @@ export function getExternalMutation(mutations, baseProps, baseState, identifier)
386
386
  return "".concat(m);
387
387
  });
388
388
  return _includes(stringArray, identifier[type]);
389
- } else {
390
- return false;
391
389
  }
390
+
391
+ return false;
392
392
  };
393
393
 
394
394
  mutations = Array.isArray(mutations) ? mutations : [mutations];
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { CallbackArgs, ValueOrCallback } from "../types/callbacks";
2
3
  /**
3
4
  * creates an object with some keys excluded
4
5
  * replacement for lodash.omit for performance. does not mimic the entire lodash.omit api
@@ -23,7 +24,7 @@ export declare function getPadding(props: any, name?: string): {
23
24
  export declare function isTooltip(component: any): boolean;
24
25
  export declare function getDefaultStyles(props: any, role: any): any;
25
26
  export declare function getStyles(style: any, defaultStyles: any): any;
26
- export declare function evaluateProp(prop: any, props: any): any;
27
+ export declare function evaluateProp<TValue>(prop: ValueOrCallback<TValue>, props: CallbackArgs): TValue;
27
28
  export declare function evaluateStyle(style: any, props: any): any;
28
29
  export declare function degreesToRadians(degrees: any): any;
29
30
  export declare function radiansToDegrees(radians: any): any;
@@ -0,0 +1,22 @@
1
+ declare type AnyObject = Record<string, any>;
2
+ export declare type AnimationState = {
3
+ nodesShouldLoad?: boolean;
4
+ nodesDoneLoad?: boolean;
5
+ animating?: boolean;
6
+ childrenTransitions?: any[];
7
+ nodesWillExit?: boolean;
8
+ nodesWillEnter?: boolean;
9
+ nodesShouldEnter?: boolean;
10
+ oldProps?: AnyObject;
11
+ nextProps?: AnyObject;
12
+ continuous?: boolean;
13
+ };
14
+ export declare const useAnimationState: (initialState?: AnimationState) => {
15
+ state: AnimationState;
16
+ setState: (newState: AnimationState) => void;
17
+ getAnimationProps: (props: AnyObject | undefined, child: any, index: any) => any;
18
+ setAnimationState: (props: AnyObject | undefined, nextProps: any) => void;
19
+ getProps: (initialProps: AnyObject) => AnyObject;
20
+ };
21
+ export {};
22
+ //# sourceMappingURL=use-animation-state.d.ts.map
@@ -76,7 +76,7 @@ export var useAnimationState = function () {
76
76
  }, [state, setState]); // This is a copy of Wrapper.setAnimationState
77
77
 
78
78
  var setAnimationState = React.useCallback(function (props, nextProps) {
79
- if (!props || !props.animate) {
79
+ if (!(props !== null && props !== void 0 && props.animate)) {
80
80
  return;
81
81
  }
82
82
 
@@ -117,7 +117,7 @@ export var useAnimationState = function () {
117
117
  nodesWillEnter: nodesWillEnter,
118
118
  nodesShouldEnter: nodesShouldEnter,
119
119
  childrenTransitions: Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[0] : childrenTransitions,
120
- oldProps: _nodesWillExit ? props : null,
120
+ oldProps: _nodesWillExit ? props : undefined,
121
121
  nextProps: nextProps,
122
122
  continuous: continuous
123
123
  });
@@ -13,9 +13,9 @@ function getVerticalAnchor(props, datum) {
13
13
  return datum.verticalAnchor || labelStyle.verticalAnchor;
14
14
  } else if (!props.horizontal) {
15
15
  return sign >= 0 ? "end" : "start";
16
- } else {
17
- return "middle";
18
16
  }
17
+
18
+ return "middle";
19
19
  }
20
20
 
21
21
  function getTextAnchor(props, datum) {
@@ -29,9 +29,9 @@ function getTextAnchor(props, datum) {
29
29
  return datum.verticalAnchor || labelStyle.verticalAnchor;
30
30
  } else if (!horizontal) {
31
31
  return "middle";
32
- } else {
33
- return sign >= 0 ? "start" : "end";
34
32
  }
33
+
34
+ return sign >= 0 ? "start" : "end";
35
35
  }
36
36
 
37
37
  function getAngle(props, datum) {
@@ -77,13 +77,13 @@ function getPosition(props, datum) {
77
77
  x: x,
78
78
  y: y
79
79
  };
80
- } else {
81
- var polarPadding = getPolarPadding(props, datum);
82
- return {
83
- x: x + polarPadding.x,
84
- y: y + polarPadding.y
85
- };
86
80
  }
81
+
82
+ var polarPadding = getPolarPadding(props, datum);
83
+ return {
84
+ x: x + polarPadding.x,
85
+ y: y + polarPadding.y
86
+ };
87
87
  }
88
88
 
89
89
  function getPolarPadding(props, datum) {
@@ -114,9 +114,9 @@ function getPolarOrientation(degrees) {
114
114
  return "top"; // eslint-disable-next-line no-magic-numbers
115
115
  } else if (degrees > 135 && degrees < 225) {
116
116
  return "left";
117
- } else {
118
- return "bottom";
119
117
  }
118
+
119
+ return "bottom";
120
120
  } // Exported Functions
121
121
 
122
122