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.
- package/CHANGELOG.md +36 -0
- package/dist/victory-core.js +5305 -4728
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +2 -1
- package/es/types/callbacks.d.ts +2 -1
- package/es/victory-animation/victory-animation.js +1 -1
- package/es/victory-label/victory-label.d.ts +4 -8
- package/es/victory-label/victory-label.js +19 -19
- package/es/victory-portal/portal.js +2 -2
- package/es/victory-primitives/arc.js +1 -1
- package/es/victory-primitives/circle.d.ts +1 -0
- package/es/victory-primitives/line.d.ts +1 -0
- package/es/victory-primitives/path.d.ts +1 -0
- package/es/victory-primitives/rect.d.ts +1 -0
- package/es/victory-primitives/tspan.d.ts +1 -0
- package/es/victory-state/victory-provider.d.ts +1 -0
- package/es/victory-transition/victory-transition.js +22 -22
- package/es/victory-util/add-events.d.ts +30 -9
- package/es/victory-util/add-events.js +4 -5
- package/es/victory-util/axis.js +22 -20
- package/es/victory-util/collection.d.ts +2 -2
- package/es/victory-util/data.d.ts +1 -1
- package/es/victory-util/data.js +2 -2
- package/es/victory-util/domain.js +4 -4
- package/es/victory-util/events.d.ts +1 -1
- package/es/victory-util/events.js +2 -2
- package/es/victory-util/helpers.d.ts +2 -1
- package/es/victory-util/hooks/use-animation-state.d.ts +22 -0
- package/es/victory-util/hooks/use-animation-state.js +2 -2
- package/es/victory-util/label-helpers.js +12 -12
- package/es/victory-util/prop-types.js +2 -2
- package/es/victory-util/scale.js +1 -1
- package/es/victory-util/selection.d.ts +6 -2
- package/es/victory-util/selection.js +16 -16
- package/es/victory-util/style.js +12 -12
- package/es/victory-util/textsize.js +2 -2
- package/es/victory-util/transitions.js +2 -2
- package/es/victory-util/user-props.d.ts +1 -1
- package/es/victory-util/user-props.js +3 -1
- package/es/victory-util/with-container.d.ts +2 -2
- package/es/victory-util/with-container.js +2 -1
- package/es/victory-util/wrapper.d.ts +1 -1
- package/es/victory-util/wrapper.js +8 -8
- package/lib/index.d.ts +2 -1
- package/lib/types/callbacks.d.ts +2 -1
- package/lib/victory-label/victory-label.d.ts +4 -8
- package/lib/victory-label/victory-label.js +19 -19
- package/lib/victory-portal/portal.js +2 -2
- package/lib/victory-primitives/circle.d.ts +1 -0
- package/lib/victory-primitives/line.d.ts +1 -0
- package/lib/victory-primitives/path.d.ts +1 -0
- package/lib/victory-primitives/rect.d.ts +1 -0
- package/lib/victory-primitives/tspan.d.ts +1 -0
- package/lib/victory-state/victory-provider.d.ts +1 -0
- package/lib/victory-transition/victory-transition.js +21 -21
- package/lib/victory-util/add-events.d.ts +30 -9
- package/lib/victory-util/add-events.js +4 -4
- package/lib/victory-util/axis.js +22 -20
- package/lib/victory-util/collection.d.ts +2 -2
- package/lib/victory-util/data.d.ts +1 -1
- package/lib/victory-util/data.js +2 -2
- package/lib/victory-util/domain.js +4 -4
- package/lib/victory-util/events.d.ts +1 -1
- package/lib/victory-util/events.js +2 -2
- package/lib/victory-util/helpers.d.ts +2 -1
- package/lib/victory-util/hooks/use-animation-state.d.ts +22 -0
- package/lib/victory-util/hooks/use-animation-state.js +2 -2
- package/lib/victory-util/label-helpers.js +12 -12
- package/lib/victory-util/prop-types.js +2 -2
- package/lib/victory-util/scale.js +1 -1
- package/lib/victory-util/selection.d.ts +6 -2
- package/lib/victory-util/selection.js +21 -17
- package/lib/victory-util/style.js +12 -12
- package/lib/victory-util/textsize.js +2 -2
- package/lib/victory-util/transitions.js +2 -2
- package/lib/victory-util/user-props.d.ts +1 -1
- package/lib/victory-util/user-props.js +3 -1
- package/lib/victory-util/with-container.d.ts +2 -2
- package/lib/victory-util/with-container.js +5 -3
- package/lib/victory-util/wrapper.d.ts +1 -1
- package/lib/victory-util/wrapper.js +8 -8
- package/package.json +261 -7
- package/src/index.ts +2 -4
- package/src/types/callbacks.ts +3 -1
- package/src/victory-animation/victory-animation.tsx +1 -1
- package/src/victory-label/victory-label.tsx +24 -28
- package/src/victory-primitives/arc.tsx +1 -1
- package/src/victory-transition/victory-transition.tsx +24 -26
- package/src/victory-util/add-events.tsx +59 -15
- package/src/victory-util/axis.tsx +12 -13
- package/src/victory-util/collection.tsx +13 -4
- package/src/victory-util/data.ts +2 -3
- package/src/victory-util/domain.ts +6 -6
- package/src/victory-util/events.ts +3 -3
- package/src/victory-util/helpers.ts +5 -1
- package/src/victory-util/hooks/{use-animation-state.js → use-animation-state.ts} +23 -8
- package/src/victory-util/label-helpers.ts +8 -12
- package/src/victory-util/point-path-helpers.ts +1 -1
- package/src/victory-util/prop-types.ts +1 -2
- package/src/victory-util/scale.ts +1 -1
- package/src/victory-util/selection.ts +15 -14
- package/src/victory-util/style.ts +10 -11
- package/src/victory-util/textsize.ts +3 -3
- package/src/victory-util/transitions.ts +1 -2
- package/src/victory-util/user-props.ts +2 -1
- package/src/victory-util/with-container.tsx +4 -7
- package/src/victory-util/wrapper.tsx +9 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-core",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.6.2",
|
|
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.
|
|
26
|
+
"victory-vendor": "^36.6.2"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"react": ">=16.6.0"
|
|
29
30
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"victory-axis": "*",
|
|
33
|
+
"victory-bar": "*",
|
|
34
|
+
"victory-core": "*",
|
|
35
|
+
"victory-line": "*"
|
|
32
36
|
},
|
|
33
|
-
"
|
|
34
|
-
|
|
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
|
@@ -12,9 +12,7 @@ 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 {
|
|
16
|
-
|
|
17
|
-
type BorderProps as BoxProps,
|
|
18
|
-
} from "./victory-primitives";
|
|
15
|
+
export { Border as Box } from "./victory-primitives";
|
|
16
|
+
export type { BorderProps as BoxProps } from "./victory-primitives";
|
|
19
17
|
export * from "./victory-util";
|
|
20
18
|
export * from "./victory-state";
|
package/src/types/callbacks.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface CallbackArgs {
|
|
|
13
13
|
data?: Datum[];
|
|
14
14
|
datum?: Datum;
|
|
15
15
|
horizontal?: boolean;
|
|
16
|
-
index
|
|
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
|
-
/*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
|
|
59
|
+
textAnchor?: ValueOrCallback<TextAnchorType>;
|
|
59
60
|
title?: string;
|
|
60
|
-
transform?: string | object
|
|
61
|
+
transform?: ValueOrCallback<string | object>;
|
|
61
62
|
tspanComponent?: React.ReactElement;
|
|
62
|
-
verticalAnchor?: 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 =
|
|
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) => {
|
|
@@ -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(
|
|
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(
|
|
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) ||
|