victory-tooltip 36.8.2 → 36.8.4

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.
@@ -1,17 +1,67 @@
1
- /* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2] }]*/
2
1
  import React from "react";
3
- import PropTypes from "prop-types";
4
- import { Helpers, CommonProps, Path, UserProps } from "victory-core";
5
- import { isPlainObject, assign } from "lodash";
2
+ import {
3
+ Helpers,
4
+ Path,
5
+ UserProps,
6
+ VictoryCommonProps,
7
+ OrientationTypes,
8
+ VictoryStyleObject,
9
+ StringOrNumberOrCallback,
10
+ } from "victory-core";
6
11
 
7
- const getVerticalPath = (props) => {
12
+ export interface FlyoutProps extends VictoryCommonProps {
13
+ active?: boolean;
14
+ center?: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ className?: string;
19
+ clipPath?: string;
20
+ cornerRadius?: number;
21
+ data?: any[];
22
+ datum?: object;
23
+ dx?: number;
24
+ dy?: number;
25
+ events?: object;
26
+ id?: StringOrNumberOrCallback;
27
+ index?: number;
28
+ orientation?: OrientationTypes;
29
+ pathComponent?: React.ReactElement;
30
+ pointerLength?: number;
31
+ pointerWidth?: number;
32
+ role?: string;
33
+ shapeRendering?: string;
34
+ style?: VictoryStyleObject;
35
+ transform?: string;
36
+ x?: number;
37
+ y?: number;
38
+ }
39
+
40
+ interface FlyoutPathProps {
41
+ center: {
42
+ x: number;
43
+ y: number;
44
+ };
45
+ cornerRadius: number;
46
+ dx?: number;
47
+ dy?: number;
48
+ height: number;
49
+ orientation: OrientationTypes;
50
+ pointerLength: number;
51
+ pointerWidth: number;
52
+ width: number;
53
+ x: number;
54
+ y: number;
55
+ }
56
+
57
+ const getVerticalPath = (props: FlyoutPathProps) => {
8
58
  const { pointerWidth, cornerRadius, orientation, width, height, center } =
9
59
  props;
10
60
  const sign = orientation === "bottom" ? 1 : -1;
11
61
  const x = props.x + (props.dx || 0);
12
62
  const y = props.y + (props.dy || 0);
13
- const centerX = isPlainObject(center) && center.x;
14
- const centerY = isPlainObject(center) && center.y;
63
+ const centerX = center.x;
64
+ const centerY = center.y;
15
65
  const pointerEdge = centerY + sign * (height / 2);
16
66
  const oppositeEdge = centerY - sign * (height / 2);
17
67
  const rightEdge = centerX + width / 2;
@@ -35,14 +85,14 @@ const getVerticalPath = (props) => {
35
85
  z`;
36
86
  };
37
87
 
38
- const getHorizontalPath = (props) => {
88
+ const getHorizontalPath = (props: FlyoutPathProps) => {
39
89
  const { pointerWidth, cornerRadius, orientation, width, height, center } =
40
90
  props;
41
91
  const sign = orientation === "left" ? 1 : -1;
42
92
  const x = props.x + (props.dx || 0);
43
93
  const y = props.y + (props.dy || 0);
44
- const centerX = isPlainObject(center) && center.x;
45
- const centerY = isPlainObject(center) && center.y;
94
+ const centerX = center.x;
95
+ const centerY = center.y;
46
96
  const pointerEdge = centerX - sign * (width / 2);
47
97
  const oppositeEdge = centerX + sign * (width / 2);
48
98
  const bottomEdge = centerY + height / 2;
@@ -66,14 +116,14 @@ const getHorizontalPath = (props) => {
66
116
  z`;
67
117
  };
68
118
 
69
- const getFlyoutPath = (props) => {
119
+ const getFlyoutPath = (props: FlyoutPathProps) => {
70
120
  const orientation = props.orientation || "top";
71
121
  return orientation === "left" || orientation === "right"
72
122
  ? getHorizontalPath(props)
73
123
  : getVerticalPath(props);
74
124
  };
75
125
 
76
- const evaluateProps = (props) => {
126
+ const evaluateProps = (props: FlyoutProps) => {
77
127
  /**
78
128
  * Potential evaluated props are:
79
129
  * `id`
@@ -82,7 +132,7 @@ const evaluateProps = (props) => {
82
132
  const id = Helpers.evaluateProp(props.id, props);
83
133
  const style = Helpers.evaluateStyle(props.style, props);
84
134
 
85
- return assign({}, props, { id, style });
135
+ return { ...props, id, style };
86
136
  };
87
137
 
88
138
  const defaultProps = {
@@ -91,15 +141,36 @@ const defaultProps = {
91
141
  shapeRendering: "auto",
92
142
  };
93
143
 
94
- const Flyout = (props) => {
95
- props = evaluateProps({ ...defaultProps, ...props });
144
+ export const Flyout: React.FC<FlyoutProps> = (initialProps) => {
145
+ const props = evaluateProps({ ...defaultProps, ...initialProps });
96
146
  const userProps = UserProps.getSafeUserProps(props);
97
147
 
98
- return React.cloneElement(props.pathComponent, {
148
+ // check for required props for this subcomponent
149
+ // they should be passed in from the wrapper
150
+ UserProps.assert(props.height, "Flyout props[height] is undefined");
151
+ UserProps.assert(props.width, "Flyout props[width] is undefined");
152
+ UserProps.assert(props.x, "Flyout props[x] is undefined");
153
+ UserProps.assert(props.y, "Flyout props[y] is undefined");
154
+
155
+ const flyoutPathProps: FlyoutPathProps = {
156
+ center: props.center || { x: 0, y: 0 },
157
+ cornerRadius: props.cornerRadius || 0,
158
+ dx: props.dx,
159
+ dy: props.dy,
160
+ height: props.height,
161
+ orientation: props.orientation || "top",
162
+ pointerLength: props.pointerLength || 0,
163
+ pointerWidth: props.pointerWidth || 0,
164
+ width: props.width,
165
+ x: props.x,
166
+ y: props.y,
167
+ };
168
+
169
+ return React.cloneElement(props.pathComponent!, {
99
170
  ...props.events,
100
171
  ...userProps,
101
172
  style: props.style,
102
- d: getFlyoutPath(props),
173
+ d: getFlyoutPath(flyoutPathProps),
103
174
  className: props.className,
104
175
  shapeRendering: props.shapeRendering,
105
176
  role: props.role,
@@ -107,22 +178,3 @@ const Flyout = (props) => {
107
178
  clipPath: props.clipPath,
108
179
  });
109
180
  };
110
-
111
- Flyout.propTypes = {
112
- ...CommonProps.primitiveProps,
113
- center: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
114
- cornerRadius: PropTypes.number,
115
- datum: PropTypes.object,
116
- dx: PropTypes.number,
117
- dy: PropTypes.number,
118
- height: PropTypes.number,
119
- orientation: PropTypes.oneOf(["top", "bottom", "left", "right"]),
120
- pathComponent: PropTypes.element,
121
- pointerLength: PropTypes.number,
122
- pointerWidth: PropTypes.number,
123
- width: PropTypes.number,
124
- x: PropTypes.number,
125
- y: PropTypes.number,
126
- };
127
-
128
- export default Flyout;
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./victory-tooltip";
2
+ export * from "./flyout";
@@ -1,109 +1,95 @@
1
+ /* eslint-disable react/prop-types */
1
2
  import React from "react";
2
- import PropTypes from "prop-types";
3
3
  import {
4
- PropTypes as CustomPropTypes,
5
4
  TextSize,
6
5
  Helpers,
7
6
  LabelHelpers,
8
7
  VictoryLabel,
9
8
  VictoryTheme,
10
9
  VictoryPortal,
10
+ VictoryLabelableProps,
11
+ VictoryLabelProps,
12
+ VictoryLabelStyleObject,
13
+ NumberOrCallback,
14
+ PaddingOrCallback,
15
+ VictoryStyleObject,
16
+ OrientationTypes,
17
+ VictoryThemeDefinition,
11
18
  } from "victory-core";
12
- import Flyout from "./flyout";
13
19
  import { assign, defaults, uniqueId, isPlainObject, orderBy } from "lodash";
14
20
 
21
+ import { Flyout } from "./flyout";
22
+
15
23
  const fallbackProps = {
16
24
  cornerRadius: 5,
17
25
  pointerLength: 10,
18
26
  pointerWidth: 10,
19
27
  };
20
28
 
21
- export default class VictoryTooltip extends React.Component {
29
+ export interface VictoryTooltipProps
30
+ extends VictoryLabelableProps,
31
+ VictoryLabelProps {
32
+ activateData?: boolean;
33
+ active?: boolean;
34
+ activePoints?: any[];
35
+ angle?: number;
36
+ center?: { x?: number; y?: number };
37
+ centerOffset?: {
38
+ x?: NumberOrCallback;
39
+ y?: NumberOrCallback;
40
+ };
41
+ constrainToVisibleArea?: boolean;
42
+ cornerRadius?: NumberOrCallback;
43
+ events?: any;
44
+ height?: number;
45
+ horizontal?: boolean;
46
+ flyoutComponent?: React.ReactElement;
47
+ flyoutHeight?: NumberOrCallback;
48
+ flyoutPadding?: PaddingOrCallback;
49
+ flyoutStyle?: VictoryStyleObject;
50
+ flyoutWidth?: NumberOrCallback;
51
+ id?: number | string;
52
+ index?: number | string;
53
+ orientation?: OrientationTypes | ((...args: any[]) => OrientationTypes);
54
+ pointerLength?: NumberOrCallback;
55
+ pointerOrientation?:
56
+ | OrientationTypes
57
+ | ((...args: any[]) => OrientationTypes);
58
+ pointerWidth?: NumberOrCallback;
59
+ style?:
60
+ | (VictoryLabelStyleObject & {
61
+ angle?: number;
62
+ })
63
+ | VictoryLabelStyleObject[];
64
+ theme?: VictoryThemeDefinition;
65
+ width?: number;
66
+ }
67
+
68
+ type InternalEvaluatedProps = VictoryTooltipProps & {
69
+ centerOffset: { x: number; y: number };
70
+ cornerRadius?: number;
71
+ dx?: string | number;
72
+ dy?: string | number;
73
+ flyoutHeight: number;
74
+ flyoutPadding: {
75
+ top: number;
76
+ bottom: number;
77
+ left: number;
78
+ right: number;
79
+ };
80
+ flyoutWidth: number;
81
+ orientation: OrientationTypes;
82
+ pointerLength?: number;
83
+ pointerWidth?: number;
84
+ // TODO: This is a hack to get around the fact that the type of
85
+ // style is used in akward ways in the functions
86
+ style: any;
87
+ text: string | string[];
88
+ };
89
+
90
+ export class VictoryTooltip extends React.Component<VictoryTooltipProps> {
22
91
  static displayName = "VictoryTooltip";
23
92
  static role = "tooltip";
24
- static propTypes = {
25
- activateData: PropTypes.bool,
26
- active: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
27
- activePoints: PropTypes.array,
28
- angle: PropTypes.number,
29
- center: PropTypes.shape({
30
- x: CustomPropTypes.nonNegative,
31
- y: CustomPropTypes.nonNegative,
32
- }),
33
- centerOffset: PropTypes.shape({
34
- x: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
35
- y: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
36
- }),
37
- constrainToVisibleArea: PropTypes.bool,
38
- cornerRadius: PropTypes.oneOfType([
39
- CustomPropTypes.nonNegative,
40
- PropTypes.func,
41
- ]),
42
- data: PropTypes.array,
43
- datum: PropTypes.object,
44
- dx: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
45
- dy: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
46
- events: PropTypes.object,
47
- flyoutComponent: PropTypes.element,
48
- flyoutHeight: PropTypes.oneOfType([
49
- CustomPropTypes.nonNegative,
50
- PropTypes.func,
51
- ]),
52
- flyoutPadding: PropTypes.oneOfType([
53
- PropTypes.func,
54
- PropTypes.number,
55
- PropTypes.shape({
56
- top: PropTypes.number,
57
- bottom: PropTypes.number,
58
- left: PropTypes.number,
59
- right: PropTypes.number,
60
- }),
61
- ]),
62
- flyoutStyle: PropTypes.object,
63
- flyoutWidth: PropTypes.oneOfType([
64
- CustomPropTypes.nonNegative,
65
- PropTypes.func,
66
- ]),
67
- groupComponent: PropTypes.element,
68
- height: PropTypes.number,
69
- horizontal: PropTypes.bool,
70
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
71
- index: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
72
- labelComponent: PropTypes.element,
73
- orientation: PropTypes.oneOfType([
74
- PropTypes.oneOf(["top", "bottom", "left", "right"]),
75
- PropTypes.func,
76
- ]),
77
- pointerLength: PropTypes.oneOfType([
78
- CustomPropTypes.nonNegative,
79
- PropTypes.func,
80
- ]),
81
- pointerOrientation: PropTypes.oneOfType([
82
- PropTypes.oneOf(["top", "bottom", "left", "right"]),
83
- PropTypes.func,
84
- ]),
85
- pointerWidth: PropTypes.oneOfType([
86
- CustomPropTypes.nonNegative,
87
- PropTypes.func,
88
- ]),
89
- polar: PropTypes.bool,
90
- renderInPortal: PropTypes.bool,
91
- scale: PropTypes.shape({
92
- x: CustomPropTypes.scale,
93
- y: CustomPropTypes.scale,
94
- }),
95
- style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
96
- text: PropTypes.oneOfType([
97
- PropTypes.string,
98
- PropTypes.number,
99
- PropTypes.func,
100
- PropTypes.array,
101
- ]),
102
- theme: PropTypes.object,
103
- width: PropTypes.number,
104
- x: PropTypes.number,
105
- y: PropTypes.number,
106
- };
107
93
 
108
94
  static defaultProps = {
109
95
  active: false,
@@ -113,7 +99,7 @@ export default class VictoryTooltip extends React.Component {
113
99
  groupComponent: <g />,
114
100
  };
115
101
 
116
- static defaultEvents = (props) => {
102
+ static defaultEvents = (props: VictoryTooltipProps) => {
117
103
  const activate = props.activateData
118
104
  ? [
119
105
  { target: "labels", mutation: () => ({ active: true }) },
@@ -141,25 +127,27 @@ export default class VictoryTooltip extends React.Component {
141
127
  ];
142
128
  };
143
129
 
144
- constructor(props) {
130
+ id: string | number;
131
+
132
+ constructor(props: VictoryTooltipProps) {
145
133
  super(props);
146
134
  this.id = props.id === undefined ? uniqueId("tooltip-") : props.id;
147
135
  }
148
136
 
149
- getDefaultOrientation(props) {
137
+ getDefaultOrientation(props: VictoryTooltipProps): OrientationTypes {
150
138
  const { datum, horizontal, polar } = props;
151
139
  if (!polar) {
152
140
  const positive = horizontal ? "right" : "top";
153
141
  const negative = horizontal ? "left" : "bottom";
154
142
  return datum && datum.y < 0 ? negative : positive;
155
143
  }
156
- return this.getPolarOrientation(props, datum);
144
+ return this.getPolarOrientation(props);
157
145
  }
158
146
 
159
- getPolarOrientation(props, datum) {
160
- const degrees = LabelHelpers.getDegrees(props, datum);
147
+ getPolarOrientation(props: VictoryTooltipProps): OrientationTypes {
148
+ const degrees = LabelHelpers.getDegrees(props, props.datum);
161
149
  const placement = props.labelPlacement || "vertical";
162
- if (placement === " vertical") {
150
+ if (placement === "vertical") {
163
151
  return this.getVerticalOrientations(degrees);
164
152
  } else if (placement === "parallel") {
165
153
  return degrees < 90 || degrees > 270 ? "right" : "left";
@@ -167,7 +155,7 @@ export default class VictoryTooltip extends React.Component {
167
155
  return degrees > 180 ? "bottom" : "top";
168
156
  }
169
157
 
170
- getVerticalOrientations(degrees) {
158
+ getVerticalOrientations(degrees: number): OrientationTypes {
171
159
  // eslint-disable-next-line no-magic-numbers
172
160
  if (degrees < 45 || degrees > 315) {
173
161
  return "right";
@@ -205,14 +193,19 @@ export default class VictoryTooltip extends React.Component {
205
193
  return { style, flyoutStyle };
206
194
  }
207
195
 
208
- getEvaluatedProps(props) {
196
+ getEvaluatedProps(props: VictoryTooltipProps): InternalEvaluatedProps {
209
197
  const { cornerRadius, centerOffset, dx, dy } = props;
210
198
 
211
199
  const active = Helpers.evaluateProp(props.active, props);
212
- const text = Helpers.evaluateProp(
213
- props.text,
214
- assign({}, props, { active }),
215
- );
200
+
201
+ let text = Helpers.evaluateProp(props.text, assign({}, props, { active }));
202
+ if (text === undefined || text === null) {
203
+ text = "";
204
+ }
205
+ if (typeof text === "number") {
206
+ text = text.toString();
207
+ }
208
+
216
209
  const { style, flyoutStyle } = this.getStyles(
217
210
  assign({}, props, { active, text }),
218
211
  );
@@ -269,24 +262,32 @@ export default class VictoryTooltip extends React.Component {
269
262
  });
270
263
 
271
264
  const offsetX =
272
- isPlainObject(centerOffset) && centerOffset.x !== undefined
265
+ isPlainObject(centerOffset) && centerOffset?.x !== undefined
273
266
  ? Helpers.evaluateProp(centerOffset.x, evaluatedProps)
274
267
  : 0;
275
268
 
276
269
  const offsetY =
277
- isPlainObject(centerOffset) && centerOffset.y !== undefined
270
+ isPlainObject(centerOffset) && centerOffset?.y !== undefined
278
271
  ? Helpers.evaluateProp(centerOffset.y, evaluatedProps)
279
272
  : 0;
280
273
 
281
- return assign({}, evaluatedProps, {
274
+ return {
275
+ ...evaluatedProps,
282
276
  centerOffset: { x: offsetX, y: offsetY },
283
277
  dx: dx !== undefined ? Helpers.evaluateProp(dx, evaluatedProps) : 0,
284
278
  dy: dy !== undefined ? Helpers.evaluateProp(dy, evaluatedProps) : 0,
285
279
  cornerRadius: Helpers.evaluateProp(cornerRadius, evaluatedProps),
286
- });
280
+ };
287
281
  }
288
282
 
289
- getCalculatedValues(props) {
283
+ getCalculatedValues(props: InternalEvaluatedProps): {
284
+ style: any;
285
+ flyoutStyle?: VictoryStyleObject;
286
+ labelSize: { width: number; height: number };
287
+ flyoutDimensions: { height: number; width: number };
288
+ flyoutCenter: { x: number; y: number };
289
+ transform?: string;
290
+ } {
290
291
  const { style, text, flyoutStyle, flyoutHeight, flyoutWidth } = props;
291
292
  const labelSize = TextSize.approximateTextSize(text, style);
292
293
  const flyoutDimensions = { height: flyoutHeight, width: flyoutWidth };
@@ -302,7 +303,7 @@ export default class VictoryTooltip extends React.Component {
302
303
  };
303
304
  }
304
305
 
305
- getTransform(props) {
306
+ getTransform(props): string | undefined {
306
307
  const { x, y, style } = props;
307
308
  const labelStyle = style || {};
308
309
  const angle =
@@ -310,8 +311,7 @@ export default class VictoryTooltip extends React.Component {
310
311
  return angle ? `rotate(${angle} ${x} ${y})` : undefined;
311
312
  }
312
313
 
313
- // eslint-disable-next-line complexity
314
- getDefaultAngle(props) {
314
+ getDefaultAngle(props): number {
315
315
  const { polar, labelPlacement, orientation, datum } = props;
316
316
  if (!polar || !labelPlacement || labelPlacement === "vertical") {
317
317
  return 0;
@@ -319,7 +319,8 @@ export default class VictoryTooltip extends React.Component {
319
319
  const degrees = LabelHelpers.getDegrees(props, datum);
320
320
  const sign = (degrees > 90 && degrees < 180) || degrees > 270 ? 1 : -1;
321
321
  const labelRotation = labelPlacement === "perpendicular" ? 0 : 90;
322
- let angle;
322
+
323
+ let angle = 0;
323
324
  if (degrees === 0 || degrees === 180) {
324
325
  angle = orientation === "top" && degrees === 180 ? 270 : 90;
325
326
  } else if (degrees > 0 && degrees < 180) {
@@ -424,6 +425,7 @@ export default class VictoryTooltip extends React.Component {
424
425
  flyoutPadding,
425
426
  } = props;
426
427
  const cornerRadius = Helpers.evaluateProp(props.cornerRadius, props);
428
+
427
429
  const getHeight = () => {
428
430
  const calculatedHeight =
429
431
  labelSize.height + flyoutPadding.top + flyoutPadding.bottom;
@@ -434,6 +436,7 @@ export default class VictoryTooltip extends React.Component {
434
436
  : 2 * cornerRadius + pointerWidth;
435
437
  return Math.max(minHeight, calculatedHeight);
436
438
  };
439
+
437
440
  const getWidth = () => {
438
441
  const calculatedWidth =
439
442
  labelSize.width + flyoutPadding.left + flyoutPadding.right;
@@ -444,17 +447,18 @@ export default class VictoryTooltip extends React.Component {
444
447
  : 2 * cornerRadius;
445
448
  return Math.max(minWidth, calculatedWidth);
446
449
  };
450
+
447
451
  return {
448
452
  flyoutHeight: flyoutHeight
449
453
  ? Helpers.evaluateProp(flyoutHeight, props)
450
- : getHeight(props, labelSize, orientation),
454
+ : getHeight(),
451
455
  flyoutWidth: flyoutWidth
452
456
  ? Helpers.evaluateProp(flyoutWidth, props)
453
- : getWidth(props, labelSize, orientation),
457
+ : getWidth(),
454
458
  };
455
459
  }
456
460
 
457
- getLabelProps(props, calculatedValues) {
461
+ getLabelProps(props: InternalEvaluatedProps, calculatedValues) {
458
462
  const { flyoutCenter, style, labelSize, dy = 0, dx = 0 } = calculatedValues;
459
463
  const { text, datum, activePoints, labelComponent, index, flyoutPadding } =
460
464
  props;
@@ -469,7 +473,7 @@ export default class VictoryTooltip extends React.Component {
469
473
  const sign = textAnchor === "end" ? -1 : 1;
470
474
  return flyoutCenter.x - sign * (labelSize.width / 2);
471
475
  };
472
- return defaults({}, labelComponent.props, {
476
+ return defaults({}, labelComponent!.props, {
473
477
  key: `${this.id}-label-${index}`,
474
478
  text,
475
479
  datum,
@@ -485,7 +489,11 @@ export default class VictoryTooltip extends React.Component {
485
489
  });
486
490
  }
487
491
 
488
- getPointerOrientation(point, center, flyoutDimensions) {
492
+ getPointerOrientation(
493
+ point: { x: number; y: number },
494
+ center: { x: number; y: number },
495
+ flyoutDimensions: { height: number; width: number },
496
+ ): string {
489
497
  const edges = {
490
498
  bottom: center.y + flyoutDimensions.height / 2,
491
499
  top: center.y - flyoutDimensions.height / 2,
@@ -509,7 +517,7 @@ export default class VictoryTooltip extends React.Component {
509
517
  return orderBy(gaps, "val", "desc")[0].side;
510
518
  }
511
519
 
512
- getFlyoutProps(props, calculatedValues) {
520
+ getFlyoutProps(props: InternalEvaluatedProps, calculatedValues) {
513
521
  const { flyoutDimensions, flyoutStyle, flyoutCenter } = calculatedValues;
514
522
  const {
515
523
  x,
@@ -529,7 +537,7 @@ export default class VictoryTooltip extends React.Component {
529
537
  props.pointerOrientation,
530
538
  props,
531
539
  );
532
- return defaults({}, flyoutComponent.props, {
540
+ return defaults({}, flyoutComponent!.props, {
533
541
  x,
534
542
  y,
535
543
  dx,
@@ -543,7 +551,11 @@ export default class VictoryTooltip extends React.Component {
543
551
  events,
544
552
  orientation:
545
553
  pointerOrientation ||
546
- this.getPointerOrientation({ x, y }, flyoutCenter, flyoutDimensions),
554
+ this.getPointerOrientation(
555
+ { x: x!, y: y! },
556
+ flyoutCenter,
557
+ flyoutDimensions,
558
+ ),
547
559
  key: `${this.id}-tooltip-${index}`,
548
560
  width: flyoutDimensions.width,
549
561
  height: flyoutDimensions.height,
@@ -553,34 +565,34 @@ export default class VictoryTooltip extends React.Component {
553
565
  }
554
566
 
555
567
  // Overridden in victory-core-native
556
- renderTooltip(props) {
568
+ renderTooltip(props: VictoryTooltipProps): React.ReactElement | null {
557
569
  const active = Helpers.evaluateProp(props.active, props);
558
570
  const { renderInPortal } = props;
559
571
  if (!active) {
560
- return renderInPortal ? <VictoryPortal>{null}</VictoryPortal> : null;
572
+ return renderInPortal ? <VictoryPortal /> : null;
561
573
  }
562
574
  const evaluatedProps = this.getEvaluatedProps(props);
563
575
  const { flyoutComponent, labelComponent, groupComponent } = evaluatedProps;
564
576
  const calculatedValues = this.getCalculatedValues(evaluatedProps);
565
577
  const children = [
566
578
  React.cloneElement(
567
- flyoutComponent,
579
+ flyoutComponent!,
568
580
  this.getFlyoutProps(evaluatedProps, calculatedValues),
569
581
  ),
570
582
  React.cloneElement(
571
- labelComponent,
583
+ labelComponent!,
572
584
  this.getLabelProps(evaluatedProps, calculatedValues),
573
585
  ),
574
586
  ];
575
587
  const tooltip = React.cloneElement(
576
- groupComponent,
588
+ groupComponent!,
577
589
  { role: "presentation", transform: calculatedValues.transform },
578
590
  children,
579
591
  );
580
592
  return renderInPortal ? <VictoryPortal>{tooltip}</VictoryPortal> : tooltip;
581
593
  }
582
594
 
583
- render() {
595
+ render(): React.ReactElement | null {
584
596
  const props = Helpers.modifyProps(this.props, fallbackProps, "tooltip");
585
597
  return this.renderTooltip(props);
586
598
  }