victory-core 36.5.2 → 36.6.1

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 (108) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/victory-core.js +5303 -4726
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/index.d.ts +1 -0
  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 +3 -3
  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 +5 -1
  34. package/es/victory-util/selection.js +15 -15
  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 +1 -1
  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 +1 -0
  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 +3 -3
  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 +5 -1
  72. package/lib/victory-util/selection.js +15 -15
  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 +1 -1
  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 +1 -0
  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} +24 -9
  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 +12 -13
  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 +2 -5
  107. package/src/victory-util/wrapper.tsx +9 -11
  108. package/dist/victory-core.min.js.LICENSE.txt +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-core",
3
- "version": "36.5.2",
3
+ "version": "36.6.1",
4
4
  "description": "Victory Core",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -13,6 +13,7 @@
13
13
  "url": "https://github.com/formidablelabs/victory.git"
14
14
  },
15
15
  "homepage": "https://formidable.com/open-source/victory",
16
+ "sideEffects": false,
16
17
  "main": "lib/index.js",
17
18
  "module": "es/index.js",
18
19
  "jsnext:main": "es/index.js",
@@ -22,14 +23,267 @@
22
23
  "lodash": "^4.17.21",
23
24
  "prop-types": "^15.8.1",
24
25
  "react-fast-compare": "^3.2.0",
25
- "victory-vendor": "^36.5.1"
26
+ "victory-vendor": "^36.6.1"
26
27
  },
27
28
  "peerDependencies": {
28
29
  "react": ">=16.6.0"
29
30
  },
30
- "scripts": {
31
- "version": "yarn run nps build-libs && nps build-dists"
31
+ "devDependencies": {
32
+ "victory-axis": "*",
33
+ "victory-bar": "*",
34
+ "victory-core": "*",
35
+ "victory-line": "*"
32
36
  },
33
- "sideEffects": false,
34
- "gitHead": "def218e9749ecafc159ef458dd03a8b92e227666"
35
- }
37
+ "wireit": {
38
+ "### THESE WIREIT CONFIGS ARE GENERATED ####": {},
39
+ "### DO NOT MODIFY THESE MANUALLY ####": {},
40
+ "build": {
41
+ "dependencies": [
42
+ "build:lib",
43
+ "build:dist",
44
+ "types:create"
45
+ ]
46
+ },
47
+ "build:lib": {
48
+ "dependencies": [
49
+ "build:lib:esm",
50
+ "build:lib:cjs"
51
+ ]
52
+ },
53
+ "build:lib:esm": {
54
+ "command": "nps build:lib:esm",
55
+ "files": [
56
+ "src/**",
57
+ "!src/**/*.test.*",
58
+ "../../.babelrc.build.js"
59
+ ],
60
+ "output": [
61
+ "es/**/*.js",
62
+ "es/**/*.js.map"
63
+ ],
64
+ "dependencies": [
65
+ "../victory-vendor:build:lib:esm"
66
+ ],
67
+ "packageLocks": [
68
+ "pnpm-lock.yaml"
69
+ ]
70
+ },
71
+ "build:lib:cjs": {
72
+ "command": "nps build:lib:cjs",
73
+ "files": [
74
+ "src/**",
75
+ "!src/**/*.test.*",
76
+ "../../.babelrc.build.js"
77
+ ],
78
+ "output": [
79
+ "lib/**/*.js",
80
+ "lib/**/*.js.map"
81
+ ],
82
+ "dependencies": [
83
+ "../victory-vendor:build:lib:cjs"
84
+ ],
85
+ "packageLocks": [
86
+ "pnpm-lock.yaml"
87
+ ]
88
+ },
89
+ "build:dist": {
90
+ "dependencies": [
91
+ "build:dist:dev",
92
+ "build:dist:min"
93
+ ]
94
+ },
95
+ "build:dist:dev": {
96
+ "command": "nps build:dist:dev",
97
+ "files": [
98
+ "src/**",
99
+ "!src/**/*.test.*",
100
+ "../../.babelrc.build.js",
101
+ "../../config/webpack.config.js",
102
+ "../../config/webpack.config.dev.js"
103
+ ],
104
+ "output": [
105
+ "dist/victory*.js",
106
+ "!dist/victory*.min.js*"
107
+ ],
108
+ "dependencies": [
109
+ "../victory-vendor:build:lib:esm"
110
+ ],
111
+ "packageLocks": [
112
+ "pnpm-lock.yaml"
113
+ ]
114
+ },
115
+ "build:dist:min": {
116
+ "command": "nps build:dist:min",
117
+ "files": [
118
+ "src/**",
119
+ "!src/**/*.test.*",
120
+ "../../.babelrc.build.js",
121
+ "../../config/webpack.config.js"
122
+ ],
123
+ "output": [
124
+ "dist/victory*.min.js*"
125
+ ],
126
+ "dependencies": [
127
+ "../victory-vendor:build:lib:esm"
128
+ ],
129
+ "packageLocks": [
130
+ "pnpm-lock.yaml"
131
+ ]
132
+ },
133
+ "check": {
134
+ "dependencies": [
135
+ "types:check",
136
+ "jest",
137
+ "format",
138
+ "lint"
139
+ ]
140
+ },
141
+ "types:check": {
142
+ "command": "nps types:pkg:check",
143
+ "files": [
144
+ "src/**/*.{ts,tsx}",
145
+ "../../tsconfig.base.json",
146
+ "tsconfig.json"
147
+ ],
148
+ "dependencies": [
149
+ "types:create",
150
+ "../victory-vendor:types:create",
151
+ "../victory-axis:types:create",
152
+ "../victory-bar:types:create",
153
+ "../victory-line:types:create",
154
+ "../victory-voronoi:types:create"
155
+ ],
156
+ "output": [],
157
+ "packageLocks": [
158
+ "pnpm-lock.yaml"
159
+ ]
160
+ },
161
+ "types:create": {
162
+ "command": "nps types:pkg:create",
163
+ "files": [
164
+ "src/**",
165
+ "!src/**/*.test.*",
166
+ "../../tsconfig.base.json",
167
+ "tsconfig.build.json"
168
+ ],
169
+ "output": [
170
+ "es/**/*.d.ts",
171
+ "es/**/*.d.ts.map",
172
+ "lib/**/*.d.ts",
173
+ "lib/**/*.d.ts.map"
174
+ ],
175
+ "dependencies": [
176
+ "../victory-vendor:types:create"
177
+ ],
178
+ "packageLocks": [
179
+ "pnpm-lock.yaml"
180
+ ]
181
+ },
182
+ "format": {
183
+ "command": "nps format:pkg",
184
+ "files": [
185
+ "src/**",
186
+ "*.json",
187
+ "../../.prettierignore",
188
+ "../../.prettierrc.json"
189
+ ],
190
+ "output": [],
191
+ "packageLocks": [
192
+ "pnpm-lock.yaml"
193
+ ]
194
+ },
195
+ "format:fix": {
196
+ "command": "pnpm run format || nps format:pkg:fix",
197
+ "files": [
198
+ "src/**",
199
+ "*.json",
200
+ "../../.prettierignore",
201
+ "../../.prettierrc.json"
202
+ ],
203
+ "output": [],
204
+ "packageLocks": [
205
+ "pnpm-lock.yaml"
206
+ ]
207
+ },
208
+ "lint": {
209
+ "command": "nps lint:pkg",
210
+ "files": [
211
+ "src/**",
212
+ "../../.eslintignore",
213
+ "../../.eslintrc.js"
214
+ ],
215
+ "output": [],
216
+ "dependencies": [
217
+ "../victory-vendor:build",
218
+ "../victory-vendor:types:create",
219
+ "../victory-axis:types:create",
220
+ "../victory-bar:types:create",
221
+ "../victory-line:types:create",
222
+ "../victory-voronoi:types:create"
223
+ ],
224
+ "packageLocks": [
225
+ "pnpm-lock.yaml"
226
+ ]
227
+ },
228
+ "lint:fix": {
229
+ "command": "pnpm run lint || nps lint:pkg:fix",
230
+ "files": [
231
+ "src/**",
232
+ "../../.eslintignore",
233
+ "../../.eslintrc.js"
234
+ ],
235
+ "output": [],
236
+ "dependencies": [
237
+ "../victory-vendor:build",
238
+ "../victory-vendor:types:create",
239
+ "../victory-axis:types:create",
240
+ "../victory-bar:types:create",
241
+ "../victory-line:types:create",
242
+ "../victory-voronoi:types:create"
243
+ ],
244
+ "packageLocks": [
245
+ "pnpm-lock.yaml"
246
+ ]
247
+ },
248
+ "jest": {
249
+ "command": "nps jest:pkg",
250
+ "files": [
251
+ "src/**/*.test.*",
252
+ "../../.babelrc.js",
253
+ "../../test/jest-config.js",
254
+ "../../test/jest-setup.ts"
255
+ ],
256
+ "output": [],
257
+ "dependencies": [
258
+ "build:lib:cjs",
259
+ "../victory-axis:build:lib:cjs",
260
+ "../victory-bar:build:lib:cjs",
261
+ "../victory-line:build:lib:cjs",
262
+ "../victory-vendor:build:lib:cjs",
263
+ "../victory-voronoi:build:lib:cjs"
264
+ ],
265
+ "packageLocks": [
266
+ "pnpm-lock.yaml"
267
+ ]
268
+ }
269
+ },
270
+ "scripts": {
271
+ "### THESE SCRIPTS ARE GENERATED ###": "true",
272
+ "### DO NOT MODIFY THESE MANUALLY ###": "true",
273
+ "build": "wireit",
274
+ "build:lib": "wireit",
275
+ "build:lib:esm": "wireit",
276
+ "build:lib:cjs": "wireit",
277
+ "build:dist": "wireit",
278
+ "build:dist:dev": "wireit",
279
+ "build:dist:min": "wireit",
280
+ "check": "wireit",
281
+ "types:check": "wireit",
282
+ "types:create": "wireit",
283
+ "format": "wireit",
284
+ "format:fix": "wireit",
285
+ "lint": "wireit",
286
+ "lint:fix": "wireit",
287
+ "jest": "wireit"
288
+ }
289
+ }
package/src/index.ts CHANGED
@@ -13,5 +13,6 @@ export * from "./victory-portal/portal-context";
13
13
  export * from "./victory-portal/victory-portal";
14
14
  export * from "./victory-primitives";
15
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";
@@ -13,7 +13,7 @@ export interface CallbackArgs {
13
13
  data?: Datum[];
14
14
  datum?: Datum;
15
15
  horizontal?: boolean;
16
- index: ID;
16
+ index?: ID;
17
17
  x?: number;
18
18
  y?: number;
19
19
  scale?: {
@@ -51,3 +51,5 @@ export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback;
51
51
  export type OrientationOrCallback =
52
52
  | OrientationTypes
53
53
  | VictoryOrientationCallback;
54
+
55
+ export type ValueOrCallback<TValue> = TValue | ((args: CallbackArgs) => TValue);
@@ -1,4 +1,4 @@
1
- /*global setTimeout:false */
1
+ /* global setTimeout:false */
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import * as d3Ease from "victory-vendor/d3-ease";
@@ -1,4 +1,4 @@
1
- /*eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/
1
+ /* eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/
2
2
  import { assign, defaults, isEmpty } from "lodash";
3
3
  import PropTypes from "prop-types";
4
4
  import React from "react";
@@ -17,6 +17,7 @@ import {
17
17
  NumberOrCallback,
18
18
  StringOrCallback,
19
19
  StringOrNumberOrCallback,
20
+ ValueOrCallback,
20
21
  } from "../types/callbacks";
21
22
  import {
22
23
  PaddingProps,
@@ -55,11 +56,11 @@ export interface VictoryLabelProps {
55
56
  tabIndex?: NumberOrCallback;
56
57
  text?: string[] | StringOrNumberOrCallback;
57
58
  textComponent?: React.ReactElement;
58
- textAnchor?: TextAnchorType | { (): TextAnchorType };
59
+ textAnchor?: ValueOrCallback<TextAnchorType>;
59
60
  title?: string;
60
- transform?: string | object | (() => string | object);
61
+ transform?: ValueOrCallback<string | object>;
61
62
  tspanComponent?: React.ReactElement;
62
- verticalAnchor?: VerticalAnchorType | { (): VerticalAnchorType };
63
+ verticalAnchor?: ValueOrCallback<VerticalAnchorType>;
63
64
  x?: number;
64
65
  y?: number;
65
66
  dx?: StringOrNumberOrCallback;
@@ -89,13 +90,12 @@ const getFontSize = (style) => {
89
90
  } else if (baseSize === undefined || baseSize === null) {
90
91
  return defaultStyles.fontSize;
91
92
  } else if (typeof baseSize === "string") {
92
- const fontSize = +baseSize.replace("px", "");
93
+ const fontSize = Number(baseSize.replace("px", ""));
93
94
  if (!isNaN(fontSize)) {
94
95
  return fontSize;
95
- } else {
96
- Log.warn("fontSize should be expressed as a number of pixels");
97
- return defaultStyles.fontSize;
98
96
  }
97
+ Log.warn("fontSize should be expressed as a number of pixels");
98
+ return defaultStyles.fontSize;
99
99
  }
100
100
  return defaultStyles.fontSize;
101
101
  };
@@ -146,19 +146,17 @@ const getBackgroundPadding = (props) => {
146
146
  const padding = Helpers.evaluateProp(backgroundPadding, props);
147
147
  return Helpers.getPadding({ padding });
148
148
  });
149
- } else {
150
- const padding = Helpers.evaluateProp(props.backgroundPadding, props);
151
- return Helpers.getPadding({ padding });
152
149
  }
150
+ const padding = Helpers.evaluateProp(props.backgroundPadding, props);
151
+ return Helpers.getPadding({ padding });
153
152
  };
154
153
 
155
154
  const getLineHeight = (props) => {
156
155
  const lineHeight = Helpers.evaluateProp(props.lineHeight, props);
157
156
  if (Array.isArray(lineHeight)) {
158
157
  return isEmpty(lineHeight) ? [1] : lineHeight;
159
- } else {
160
- return lineHeight;
161
158
  }
159
+ return lineHeight;
162
160
  };
163
161
 
164
162
  const getContent = (text, props) => {
@@ -200,20 +198,19 @@ const getDy = (props, verticalAnchor, lineHeight) => {
200
198
  ? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0]
201
199
  : dy +
202
200
  (capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0];
203
- } else {
204
- const allHeights = [...Array(length).keys()].reduce((memo, i) => {
205
- return (
206
- memo +
207
- ((capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i]) /
208
- length
209
- );
210
- }, 0);
211
- return anchor === "end"
212
- ? dy + allHeights
213
- : dy +
214
- allHeights / 2 +
215
- (capHeight / 2) * lineHeights[length - 1] * fontSizes[length - 1];
216
201
  }
202
+ const allHeights = [...Array(length).keys()].reduce((memo, i) => {
203
+ return (
204
+ memo +
205
+ ((capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i]) /
206
+ length
207
+ );
208
+ }, 0);
209
+ return anchor === "end"
210
+ ? dy + allHeights
211
+ : dy +
212
+ allHeights / 2 +
213
+ (capHeight / 2) * lineHeights[length - 1] * fontSizes[length - 1];
217
214
  };
218
215
 
219
216
  const getTransform = (props, x, y) => {
@@ -455,9 +452,8 @@ const getTSpanDy = (tspanValues, calculatedProps, i) => {
455
452
  return calculateSpanDy(tspanValues, i, calculatedProps);
456
453
  } else if (inline) {
457
454
  return i === 0 ? current.backgroundPadding.top : undefined;
458
- } else {
459
- return current.backgroundPadding.top;
460
455
  }
456
+ return current.backgroundPadding.top;
461
457
  };
462
458
 
463
459
  const evaluateProps = (props) => {
@@ -1,4 +1,4 @@
1
- /*eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
1
+ /* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import * as Helpers from "../victory-util/helpers";
@@ -73,7 +73,7 @@ export class VictoryTransition extends React.Component<
73
73
  }
74
74
 
75
75
  componentDidMount() {
76
- this.setState({ nodesShouldLoad: true }); //eslint-disable-line react/no-did-mount-set-state
76
+ this.setState({ nodesShouldLoad: true }); // eslint-disable-line react/no-did-mount-set-state
77
77
  }
78
78
 
79
79
  shouldComponentUpdate(nextProps: VictoryTransitionProps) {
@@ -101,24 +101,23 @@ export class VictoryTransition extends React.Component<
101
101
  const state = animate.parentState;
102
102
  const oldProps = state.nodesWillExit ? props : null;
103
103
  return { oldProps, nextProps };
104
- } else {
105
- const oldChildren = React.Children.toArray(props.children);
106
- const nextChildren = React.Children.toArray(nextProps.children);
107
- const {
108
- nodesWillExit,
109
- nodesWillEnter,
110
- childrenTransitions,
111
- nodesShouldEnter,
112
- } = Transitions.getInitialTransitionState(oldChildren, nextChildren);
113
- return {
114
- nodesWillExit,
115
- nodesWillEnter,
116
- childrenTransitions,
117
- nodesShouldEnter,
118
- oldProps: nodesWillExit ? props : null,
119
- nextProps,
120
- };
121
104
  }
105
+ const oldChildren = React.Children.toArray(props.children);
106
+ const nextChildren = React.Children.toArray(nextProps.children);
107
+ const {
108
+ nodesWillExit,
109
+ nodesWillEnter,
110
+ childrenTransitions,
111
+ nodesShouldEnter,
112
+ } = Transitions.getInitialTransitionState(oldChildren, nextChildren);
113
+ return {
114
+ nodesWillExit,
115
+ nodesWillEnter,
116
+ childrenTransitions,
117
+ nodesShouldEnter,
118
+ oldProps: nodesWillExit ? props : null,
119
+ nextProps,
120
+ };
122
121
  }
123
122
 
124
123
  private getDomainFromChildren(
@@ -149,15 +148,14 @@ export class VictoryTransition extends React.Component<
149
148
  : childProps.domain && childProps.domain[axis];
150
149
  if (!childProps.children && domain) {
151
150
  return domain;
152
- } else {
153
- const childDomains = getChildDomains([child]);
154
- return childDomains.length === 0
155
- ? [0, 1]
156
- : [
157
- Collection.getMinValue(childDomains),
158
- Collection.getMaxValue(childDomains),
159
- ];
160
151
  }
152
+ const childDomains = getChildDomains([child]);
153
+ return childDomains.length === 0
154
+ ? [0, 1]
155
+ : [
156
+ Collection.getMinValue(childDomains),
157
+ Collection.getMaxValue(childDomains),
158
+ ];
161
159
  }
162
160
 
163
161
  pickProps() {
@@ -1,4 +1,3 @@
1
- /*global window:false */
2
1
  import React from "react";
3
2
  import {
4
3
  assign,
@@ -37,7 +36,7 @@ const defaultComponents: NonNullable<MixinOptions["components"]> = [
37
36
  export type MixinOptions = {
38
37
  components?: Array<{
39
38
  name: string;
40
- index?: string;
39
+ index?: string | number;
41
40
  }>;
42
41
  };
43
42
 
@@ -58,12 +57,22 @@ export interface EventMixinCommonProps
58
57
  export interface EventsMixinClass<TProps> {
59
58
  renderContainer(
60
59
  component: React.ReactElement,
61
- children: React.ReactElement[],
60
+ children: React.ReactElement | React.ReactElement[],
62
61
  ): React.ReactElement;
63
62
  cacheValues<TThis>(this: TThis, obj: Partial<TThis>): void;
64
63
  getEventState: typeof Events.getEventState;
64
+ renderData(props: TProps);
65
65
  renderContinuousData(props: TProps);
66
- animateComponent(props: TProps, defaultAnimationWhitelist);
66
+ animateComponent(
67
+ props: TProps,
68
+ defaultAnimationWhitelist: string[],
69
+ ): React.ReactElement;
70
+ getComponentProps(
71
+ component: React.ReactElement,
72
+ type: string,
73
+ index: number,
74
+ ): TProps;
75
+ dataKeys: string[];
67
76
  }
68
77
 
69
78
  /**
@@ -78,14 +87,47 @@ export interface EventMixinCalculatedValues {
78
87
  events: unknown;
79
88
  }
80
89
 
90
+ /**
91
+ * These are the common roles that we care about internally.
92
+ */
93
+ export type VictoryComponentCommonRole =
94
+ | "container"
95
+ | "group"
96
+ | "histogram"
97
+ | "label"
98
+ | "line"
99
+ | "portal"
100
+ | "stack"
101
+ | "tooltip"
102
+ | "voronoi";
103
+
104
+ /**
105
+ * A component can have any "role",
106
+ * but there are certain ones that we actually care about internally
107
+ */
108
+ export type VictoryComponentRole = VictoryComponentCommonRole | string;
109
+
110
+ /**
111
+ * Static component fields used by Victory for common behavior
112
+ */
113
+ export interface VictoryComponentConfiguration<TProps> {
114
+ getBaseProps?(props: TProps): EventMixinCalculatedValues["baseProps"];
115
+ role?: VictoryComponentRole;
116
+ expectedComponents?: Array<keyof TProps | string>;
117
+ getChildren?: (
118
+ props: TProps,
119
+ childComponents?: Array<React.ReactNode>,
120
+ calculatedProps?: TProps,
121
+ ) => void;
122
+ animationWhitelist?: Array<keyof TProps | string>;
123
+ }
124
+
81
125
  /**
82
126
  * This represents the class itself, including static fields
83
127
  */
84
- export interface WrappedComponentClass<TProps> {
128
+ export interface WrappedComponentClass<TProps>
129
+ extends VictoryComponentConfiguration<TProps> {
85
130
  new (props: TProps): React.Component<TProps>;
86
- getBaseProps?(props: TProps): EventMixinCalculatedValues["baseProps"];
87
- role?: string;
88
- expectedComponents?: string[];
89
131
  }
90
132
 
91
133
  export function addEvents<
@@ -214,13 +256,12 @@ export function addEvents<
214
256
  if (!props.standalone && component.name === "parent") {
215
257
  // don't check for changes on parent props for non-standalone components
216
258
  return undefined;
217
- } else {
218
- return component.index !== undefined
219
- ? getState(component.index, component.name)
220
- : this.dataKeys
221
- .map((key) => getState(key, component.name))
222
- .filter(Boolean);
223
259
  }
260
+ return component.index !== undefined
261
+ ? getState(component.index, component.name)
262
+ : this.dataKeys
263
+ .map((key) => getState(key, component.name))
264
+ .filter(Boolean);
224
265
  })
225
266
  .filter(Boolean);
226
267
  return stateChanges;
@@ -361,7 +402,10 @@ export function addEvents<
361
402
  return React.cloneElement(component, parentProps, children);
362
403
  }
363
404
 
364
- animateComponent(props: TProps, defaultAnimationWhitelist: string[]) {
405
+ animateComponent(
406
+ props: TProps,
407
+ defaultAnimationWhitelist: string[],
408
+ ): React.ReactElement {
365
409
  const animationWhitelist =
366
410
  (typeof props.animate === "object" &&
367
411
  props.animate?.animationWhitelist) ||
@@ -154,14 +154,13 @@ function getDefaultTickFormat(props) {
154
154
  return stringTicks(props)
155
155
  ? (x, index) => tickValues[index]
156
156
  : fallbackFormat;
157
- } else {
158
- const invertedStringMap = stringMap && invert(stringMap);
159
- const tickValueArray = orderBy(values(stringMap), (n) => n);
160
- const dataNames = tickValueArray.map((tick) => invertedStringMap[tick]);
161
- // string ticks should have one tick of padding at the beginning
162
- const dataTicks = ["", ...dataNames, ""];
163
- return (x) => dataTicks[x];
164
157
  }
158
+ const invertedStringMap = stringMap && invert(stringMap);
159
+ const tickValueArray = orderBy(values(stringMap), (n) => n);
160
+ const dataNames = tickValueArray.map((tick) => invertedStringMap[tick]);
161
+ // string ticks should have one tick of padding at the beginning
162
+ const dataTicks = ["", ...dataNames, ""];
163
+ return (x) => dataTicks[x];
165
164
  }
166
165
 
167
166
  function getStringTicks(props) {
@@ -207,7 +206,7 @@ function getTickArray(props) {
207
206
  const newTickArray = [] as Array<{ value: number; index: number }>;
208
207
  const domain = (props.domain && props.domain[axis]) || props.domain;
209
208
  if (arr) {
210
- arr.forEach(function (t, index) {
209
+ arr.forEach((t, index) => {
211
210
  if (Array.isArray(domain)) {
212
211
  if (
213
212
  t >= Collection.getMinValue(domain) &&
@@ -226,7 +225,8 @@ function getTickArray(props) {
226
225
  }
227
226
  });
228
227
  return newTickArray;
229
- } else return undefined;
228
+ }
229
+ return undefined;
230
230
  };
231
231
  return Array.isArray(tickArray) && tickArray.length
232
232
  ? buildTickArray(tickArray)
@@ -261,9 +261,8 @@ export function getTickFormat(props, scale) {
261
261
  return props.tickFormat(invertedStringMap[tick], index, stringTickArray);
262
262
  };
263
263
  return stringMap ? applyStringTicks : tickFormat;
264
- } else {
265
- return (x) => x;
266
264
  }
265
+ return (x) => x;
267
266
  }
268
267
 
269
268
  function downsampleTicks(ticks: number[], tickCount: number) {
@@ -304,7 +303,7 @@ export function getTicks(props, scale: D3Scale, filterZero = false) {
304
303
  * @param {String} axis: either x or y
305
304
  * @returns {Array} returns a domain from tickValues
306
305
  */
307
- //eslint-disable-next-line max-statements
306
+ // eslint-disable-next-line max-statements
308
307
  function getDomainFromData(props, axis) {
309
308
  const { polar, startAngle = 0, endAngle = 360 } = props;
310
309
  const tickArray = getTickArray(props);
@@ -315,7 +314,7 @@ function getDomainFromData(props, axis) {
315
314
  const minDomain = Domain.getMinFromProps(props, axis);
316
315
  const maxDomain = Domain.getMaxFromProps(props, axis);
317
316
  const tickStrings = stringTicks(props);
318
- const ticks = tickValues.map((value) => +value);
317
+ const ticks = tickValues.map((value) => Number(value));
319
318
  const defaultMin = tickStrings ? 1 : Collection.getMinValue(ticks);
320
319
  const defaultMax = tickStrings
321
320
  ? tickValues.length