victory-core 37.3.1 → 37.3.3
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 +20 -0
- package/dist/victory-core.js +436 -405
- package/dist/victory-core.min.js +1 -1
- package/es/types/callbacks.d.ts +11 -11
- package/es/types/prop-types.d.ts +28 -28
- package/es/victory-animation/util.js +7 -7
- package/es/victory-animation/victory-animation.d.ts +3 -3
- package/es/victory-clip-container/victory-clip-container.d.ts +6 -1
- package/es/victory-clip-container/victory-clip-container.js +20 -12
- package/es/victory-container/victory-container.js +5 -5
- package/es/victory-label/victory-label.d.ts +3 -3
- package/es/victory-label/victory-label.js +12 -16
- package/es/victory-portal/victory-portal.js +4 -4
- package/es/victory-primitives/arc.js +2 -2
- package/es/victory-primitives/background.js +2 -2
- package/es/victory-primitives/border.js +2 -2
- package/es/victory-primitives/line-segment.js +2 -2
- package/es/victory-primitives/point.js +2 -2
- package/es/victory-primitives/tspan.d.ts +0 -1
- package/es/victory-primitives/types.d.ts +1 -1
- package/es/victory-primitives/whisker.d.ts +1 -1
- package/es/victory-primitives/whisker.js +2 -2
- package/es/victory-theme/types.d.ts +11 -11
- package/es/victory-transition/victory-transition.d.ts +1 -1
- package/es/victory-transition/victory-transition.js +8 -8
- package/es/victory-util/add-events.d.ts +8 -8
- package/es/victory-util/add-events.js +14 -14
- package/es/victory-util/axis.js +12 -12
- package/es/victory-util/data.js +16 -20
- package/es/victory-util/domain.js +13 -16
- package/es/victory-util/events.d.ts +5 -5
- package/es/victory-util/events.js +17 -23
- package/es/victory-util/helpers.d.ts +94 -19
- package/es/victory-util/helpers.js +95 -50
- package/es/victory-util/hooks/use-animation-state.d.ts +2 -2
- package/es/victory-util/hooks/use-animation-state.js +4 -4
- package/es/victory-util/label-helpers.d.ts +4 -3
- package/es/victory-util/label-helpers.js +3 -3
- package/es/victory-util/line-helpers.d.ts +1 -1
- package/es/victory-util/log.js +3 -2
- package/es/victory-util/merge-refs.d.ts +2 -2
- package/es/victory-util/scale.js +2 -3
- package/es/victory-util/selection.d.ts +3 -3
- package/es/victory-util/textsize.js +7 -5
- package/es/victory-util/timer.d.ts +1 -1
- package/es/victory-util/transitions.d.ts +1 -1
- package/es/victory-util/transitions.js +15 -19
- package/es/victory-util/type-helpers.d.ts +0 -1
- package/es/victory-util/type-helpers.js +0 -5
- package/es/victory-util/user-props.d.ts +2 -2
- package/es/victory-util/wrapper.js +12 -13
- package/lib/types/callbacks.d.ts +11 -11
- package/lib/types/prop-types.d.ts +28 -28
- package/lib/victory-animation/util.js +7 -7
- package/lib/victory-animation/victory-animation.d.ts +3 -3
- package/lib/victory-clip-container/victory-clip-container.d.ts +6 -1
- package/lib/victory-clip-container/victory-clip-container.js +20 -12
- package/lib/victory-container/victory-container.js +6 -6
- package/lib/victory-label/victory-label.d.ts +3 -3
- package/lib/victory-label/victory-label.js +12 -16
- package/lib/victory-portal/victory-portal.js +5 -5
- package/lib/victory-primitives/arc.js +2 -2
- package/lib/victory-primitives/background.js +2 -2
- package/lib/victory-primitives/border.js +2 -2
- package/lib/victory-primitives/line-segment.js +2 -2
- package/lib/victory-primitives/point.js +2 -2
- package/lib/victory-primitives/tspan.d.ts +0 -1
- package/lib/victory-primitives/types.d.ts +1 -1
- package/lib/victory-primitives/whisker.d.ts +1 -1
- package/lib/victory-primitives/whisker.js +2 -2
- package/lib/victory-theme/types.d.ts +11 -11
- package/lib/victory-transition/victory-transition.d.ts +1 -1
- package/lib/victory-transition/victory-transition.js +8 -8
- package/lib/victory-util/add-events.d.ts +8 -8
- package/lib/victory-util/add-events.js +14 -14
- package/lib/victory-util/axis.js +12 -12
- package/lib/victory-util/data.js +16 -21
- package/lib/victory-util/domain.js +13 -17
- package/lib/victory-util/events.d.ts +5 -5
- package/lib/victory-util/events.js +17 -24
- package/lib/victory-util/helpers.d.ts +94 -19
- package/lib/victory-util/helpers.js +96 -52
- package/lib/victory-util/hooks/use-animation-state.d.ts +2 -2
- package/lib/victory-util/hooks/use-animation-state.js +4 -4
- package/lib/victory-util/label-helpers.d.ts +4 -3
- package/lib/victory-util/label-helpers.js +3 -5
- package/lib/victory-util/line-helpers.d.ts +1 -1
- package/lib/victory-util/log.js +3 -2
- package/lib/victory-util/merge-refs.d.ts +2 -2
- package/lib/victory-util/scale.js +2 -4
- package/lib/victory-util/selection.d.ts +3 -3
- package/lib/victory-util/textsize.js +5 -5
- package/lib/victory-util/timer.d.ts +1 -1
- package/lib/victory-util/transitions.d.ts +1 -1
- package/lib/victory-util/transitions.js +15 -19
- package/lib/victory-util/type-helpers.d.ts +0 -1
- package/lib/victory-util/type-helpers.js +0 -6
- package/lib/victory-util/user-props.d.ts +2 -2
- package/lib/victory-util/wrapper.js +12 -13
- package/package.json +6 -38
- package/src/victory-animation/util.ts +4 -2
- package/src/victory-clip-container/victory-clip-container.tsx +26 -11
- package/src/victory-container/victory-container.tsx +4 -4
- package/src/victory-label/victory-label.tsx +5 -3
- package/src/victory-portal/victory-portal.tsx +3 -1
- package/src/victory-primitives/arc.tsx +1 -1
- package/src/victory-primitives/background.tsx +1 -1
- package/src/victory-primitives/border.tsx +1 -1
- package/src/victory-primitives/line-segment.tsx +1 -1
- package/src/victory-primitives/point.tsx +3 -3
- package/src/victory-primitives/whisker.tsx +1 -1
- package/src/victory-transition/victory-transition.tsx +5 -3
- package/src/victory-util/add-events.tsx +6 -3
- package/src/victory-util/axis.tsx +8 -4
- package/src/victory-util/common-props.tsx +3 -3
- package/src/victory-util/data.ts +9 -13
- package/src/victory-util/domain.ts +8 -6
- package/src/victory-util/events.ts +18 -13
- package/src/victory-util/helpers.ts +155 -40
- package/src/victory-util/hooks/use-animation-state.ts +1 -1
- package/src/victory-util/label-helpers.ts +1 -2
- package/src/victory-util/log.ts +3 -2
- package/src/victory-util/merge-refs.ts +2 -0
- package/src/victory-util/scale.ts +1 -2
- package/src/victory-util/textsize.ts +2 -1
- package/src/victory-util/transitions.ts +6 -6
- package/src/victory-util/type-helpers.ts +0 -5
- package/src/victory-util/user-props.ts +1 -1
- package/src/victory-util/wrapper.tsx +5 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
type SafeAttribute = string;
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that value is not null or undefined, throwing an error if it is.
|
|
5
5
|
* @param value The value to assert
|
|
@@ -14,7 +14,7 @@ export declare function assert<T>(value: T, message?: string): asserts value is
|
|
|
14
14
|
* @param {Object} props: props to be filtered against USER_PROPS_SAFELIST
|
|
15
15
|
* @returns {Object}: object containing remaining acceptable props
|
|
16
16
|
*/
|
|
17
|
-
export declare const getSafeUserProps: <T>(props: T) => Record<SafeAttribute, string>;
|
|
17
|
+
export declare const getSafeUserProps: <T>(props: T extends Record<string, any> ? T : never) => Record<SafeAttribute, string>;
|
|
18
18
|
/**
|
|
19
19
|
* Wraps a component and adds safe user props
|
|
20
20
|
*
|
|
@@ -20,11 +20,11 @@ exports.getStringsFromChildrenCategories = getStringsFromChildrenCategories;
|
|
|
20
20
|
exports.getStringsFromData = getStringsFromData;
|
|
21
21
|
exports.getStyle = getStyle;
|
|
22
22
|
exports.getWidth = getWidth;
|
|
23
|
-
var _uniqBy2 = _interopRequireDefault(require("lodash/uniqBy"));
|
|
24
|
-
var _groupBy2 = _interopRequireDefault(require("lodash/groupBy"));
|
|
25
|
-
var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
|
|
26
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
27
23
|
var _react = _interopRequireDefault(require("react"));
|
|
24
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
25
|
+
var _uniq = _interopRequireDefault(require("lodash/uniq"));
|
|
26
|
+
var _groupBy = _interopRequireDefault(require("lodash/groupBy"));
|
|
27
|
+
var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
|
|
28
28
|
var Axis = _interopRequireWildcard(require("./axis"));
|
|
29
29
|
var Style = _interopRequireWildcard(require("./style"));
|
|
30
30
|
var Data = _interopRequireWildcard(require("./data"));
|
|
@@ -133,10 +133,10 @@ function getDataFromChildren(props, childComponents) {
|
|
|
133
133
|
}, datum));
|
|
134
134
|
};
|
|
135
135
|
const stacked = children.filter(c => c.type && c.type.role === "stack").length;
|
|
136
|
-
const combine = (memo, val) => memo.concat((0,
|
|
136
|
+
const combine = (memo, val) => memo.concat((0, _uniqBy.default)(val, "_group"));
|
|
137
137
|
const datasets = Helpers.reduceChildren(children, iteratee, props, [], combine);
|
|
138
138
|
const group = stacked ? "_group" : "_stack";
|
|
139
|
-
return Object.values((0,
|
|
139
|
+
return Object.values((0, _groupBy.default)(datasets, group));
|
|
140
140
|
}
|
|
141
141
|
function getData(props, childComponents) {
|
|
142
142
|
if (props.data) {
|
|
@@ -194,7 +194,6 @@ function getDefaultDomainPadding(props, axis, childComponents) {
|
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
function getDomainFromChildren(props, axis, childComponents) {
|
|
197
|
-
// eslint-disable-line max-statements, complexity, max-len
|
|
198
197
|
const children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
|
|
199
198
|
const parentData = props.data ? Data.getData(props) : undefined;
|
|
200
199
|
const {
|
|
@@ -264,7 +263,7 @@ function getScale(props, axis, childComponents) {
|
|
|
264
263
|
});
|
|
265
264
|
return Scale.getScaleType(sharedProps, axis);
|
|
266
265
|
};
|
|
267
|
-
const childScale = (0,
|
|
266
|
+
const childScale = (0, _uniq.default)(Helpers.reduceChildren(children, iteratee, props));
|
|
268
267
|
|
|
269
268
|
// default to linear scale if more than one uniq scale type is given by children
|
|
270
269
|
return childScale.length > 1 ? Scale.getScaleFromName("linear") : Scale.getScaleFromName(childScale[0]);
|
|
@@ -326,8 +325,8 @@ function getChildStyle(child, index, calculatedProps, theme) {
|
|
|
326
325
|
const dataWidth = role === "stack" ? {} : {
|
|
327
326
|
width: getWidth(calculatedProps)
|
|
328
327
|
};
|
|
329
|
-
const dataStyle = (0,
|
|
330
|
-
const labelsStyle = (0,
|
|
328
|
+
const dataStyle = (0, _defaults.default)({}, childStyle.data, Object.assign({}, dataWidth, style.data, defaultColor));
|
|
329
|
+
const labelsStyle = (0, _defaults.default)({}, childStyle.labels, style.labels);
|
|
331
330
|
return {
|
|
332
331
|
...childStyle,
|
|
333
332
|
parent: style.parent,
|
|
@@ -380,7 +379,7 @@ function getCategoryAndAxisStringsFromChildren(props, axis, childComponents) {
|
|
|
380
379
|
const axisComponent = Axis.getAxisComponent(childComponents, axis);
|
|
381
380
|
const axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
|
|
382
381
|
const categoryStrings = categories.length ? categories : getStringsFromChildrenCategories(childComponents, axis);
|
|
383
|
-
return (0,
|
|
382
|
+
return (0, _uniq.default)([...categoryStrings, ...axisStrings].flat());
|
|
384
383
|
}
|
|
385
384
|
function getStringsFromChildren(props, childComponents) {
|
|
386
385
|
const children = childComponents || _react.default.Children.toArray(props.children);
|
|
@@ -388,8 +387,8 @@ function getStringsFromChildren(props, childComponents) {
|
|
|
388
387
|
const yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children);
|
|
389
388
|
const dataStrings = getStringsFromData(children);
|
|
390
389
|
return {
|
|
391
|
-
x: (0,
|
|
392
|
-
y: (0,
|
|
390
|
+
x: (0, _uniq.default)([...xStrings, ...dataStrings.x].flat()),
|
|
391
|
+
y: (0, _uniq.default)([...yStrings, ...dataStrings.y].flat())
|
|
393
392
|
};
|
|
394
393
|
}
|
|
395
394
|
function getCategories(props, childComponents, allStrings) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-core",
|
|
3
|
-
"version": "37.3.
|
|
3
|
+
"version": "37.3.3",
|
|
4
4
|
"description": "Victory Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"react-fast-compare": "^3.2.0",
|
|
25
|
-
"victory-vendor": "37.3.
|
|
25
|
+
"victory-vendor": "37.3.3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=16.6.0"
|
|
@@ -180,38 +180,10 @@
|
|
|
180
180
|
"pnpm-lock.yaml"
|
|
181
181
|
]
|
|
182
182
|
},
|
|
183
|
-
"format": {
|
|
184
|
-
"command": "nps format:pkg",
|
|
185
|
-
"files": [
|
|
186
|
-
"src/**",
|
|
187
|
-
"*.json",
|
|
188
|
-
"../../.prettierignore",
|
|
189
|
-
"../../.prettierrc.json"
|
|
190
|
-
],
|
|
191
|
-
"output": [],
|
|
192
|
-
"packageLocks": [
|
|
193
|
-
"pnpm-lock.yaml"
|
|
194
|
-
]
|
|
195
|
-
},
|
|
196
|
-
"format:fix": {
|
|
197
|
-
"command": "pnpm run format || nps format:pkg:fix",
|
|
198
|
-
"files": [
|
|
199
|
-
"src/**",
|
|
200
|
-
"*.json",
|
|
201
|
-
"../../.prettierignore",
|
|
202
|
-
"../../.prettierrc.json"
|
|
203
|
-
],
|
|
204
|
-
"output": [],
|
|
205
|
-
"packageLocks": [
|
|
206
|
-
"pnpm-lock.yaml"
|
|
207
|
-
]
|
|
208
|
-
},
|
|
209
183
|
"lint": {
|
|
210
|
-
"command": "
|
|
184
|
+
"command": "eslint src",
|
|
211
185
|
"files": [
|
|
212
|
-
"src/**"
|
|
213
|
-
"../../.eslintignore",
|
|
214
|
-
"../../.eslintrc.js"
|
|
186
|
+
"src/**"
|
|
215
187
|
],
|
|
216
188
|
"output": [],
|
|
217
189
|
"dependencies": [
|
|
@@ -224,11 +196,9 @@
|
|
|
224
196
|
]
|
|
225
197
|
},
|
|
226
198
|
"lint:fix": {
|
|
227
|
-
"command": "
|
|
199
|
+
"command": "eslint --fix src",
|
|
228
200
|
"files": [
|
|
229
|
-
"src/**"
|
|
230
|
-
"../../.eslintignore",
|
|
231
|
-
"../../.eslintrc.js"
|
|
201
|
+
"src/**"
|
|
232
202
|
],
|
|
233
203
|
"output": [],
|
|
234
204
|
"dependencies": [
|
|
@@ -271,8 +241,6 @@
|
|
|
271
241
|
"check": "wireit",
|
|
272
242
|
"types:check": "wireit",
|
|
273
243
|
"types:create": "wireit",
|
|
274
|
-
"format": "wireit",
|
|
275
|
-
"format:fix": "wireit",
|
|
276
244
|
"lint": "wireit",
|
|
277
245
|
"lint:fix": "wireit",
|
|
278
246
|
"jest": "wireit"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import isPlainObject from "lodash/isPlainObject";
|
|
2
|
+
import orderBy from "lodash/orderBy";
|
|
3
|
+
|
|
1
4
|
import { interpolate } from "victory-vendor/d3-interpolate";
|
|
2
|
-
import { isPlainObject, orderBy } from "lodash";
|
|
3
5
|
|
|
4
6
|
export const isInterpolatable = function (obj) {
|
|
5
7
|
// d3 turns null into 0 and undefined into NaN, which we don't want.
|
|
@@ -83,7 +85,7 @@ export const interpolateFunction = function (a, b) {
|
|
|
83
85
|
return b;
|
|
84
86
|
}
|
|
85
87
|
return function (this: unknown) {
|
|
86
|
-
/* eslint-disable
|
|
88
|
+
/* eslint-disable prefer-rest-params */
|
|
87
89
|
const aval = typeof a === "function" ? a.apply(this, arguments) : a;
|
|
88
90
|
const bval = typeof b === "function" ? b.apply(this, arguments) : b;
|
|
89
91
|
return interpolate(aval, bval)(t);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import uniqueId from "lodash/uniqueId";
|
|
4
|
+
|
|
2
5
|
import * as Helpers from "../victory-util/helpers";
|
|
3
6
|
import * as UserProps from "../victory-util/user-props";
|
|
4
|
-
import { defaults, isObject, uniqueId } from "lodash";
|
|
5
7
|
import { ClipPath } from "../victory-primitives/clip-path";
|
|
6
8
|
import { Circle } from "../victory-primitives/circle";
|
|
7
9
|
import { Rect } from "../victory-primitives/rect";
|
|
@@ -29,7 +31,14 @@ export interface VictoryClipContainerProps {
|
|
|
29
31
|
translateY?: number;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
interface VictoryClipContainerState {
|
|
35
|
+
clipId?: number | string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class VictoryClipContainer extends React.Component<
|
|
39
|
+
VictoryClipContainerProps,
|
|
40
|
+
VictoryClipContainerState
|
|
41
|
+
> {
|
|
33
42
|
static displayName = "VictoryClipContainer";
|
|
34
43
|
static role = "container";
|
|
35
44
|
|
|
@@ -43,10 +52,18 @@ export class VictoryClipContainer extends React.Component<VictoryClipContainerPr
|
|
|
43
52
|
|
|
44
53
|
constructor(props: VictoryClipContainerProps) {
|
|
45
54
|
super(props);
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
this.state = {
|
|
56
|
+
clipId: props?.clipId,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// The clipId state is used to prevent hydration mismatches between the server and client (issue #2941).
|
|
61
|
+
// A better alternative would be to utilize React 18's useId hook instead of uniqueId, which would avoid needing state for this purpose.
|
|
62
|
+
// However, this component currently supports React 16 at the time of writing, so this workaround is necessary.
|
|
63
|
+
componentDidMount() {
|
|
64
|
+
if (!this.state.clipId) {
|
|
65
|
+
this.setState({ clipId: uniqueId("victory-clip-") });
|
|
66
|
+
}
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
calculateAttributes(props) {
|
|
@@ -58,7 +75,7 @@ export class VictoryClipContainer extends React.Component<VictoryClipContainerPr
|
|
|
58
75
|
translateX = 0,
|
|
59
76
|
translateY = 0,
|
|
60
77
|
} = props;
|
|
61
|
-
const clipPadding = Helpers.getPadding(
|
|
78
|
+
const clipPadding = Helpers.getPadding(props.clipPadding);
|
|
62
79
|
const radius = props.radius || Helpers.getRadius(props);
|
|
63
80
|
return {
|
|
64
81
|
x: (polar ? origin.x : translateX) - clipPadding.left,
|
|
@@ -141,9 +158,7 @@ export class VictoryClipContainer extends React.Component<VictoryClipContainerPr
|
|
|
141
158
|
rectComponent,
|
|
142
159
|
clipPathComponent,
|
|
143
160
|
} = props;
|
|
144
|
-
const { top, bottom, left, right } = Helpers.getPadding(
|
|
145
|
-
padding: props.clipPadding,
|
|
146
|
-
});
|
|
161
|
+
const { top, bottom, left, right } = Helpers.getPadding(props.clipPadding);
|
|
147
162
|
let child;
|
|
148
163
|
if (polar) {
|
|
149
164
|
const radius = props.radius || Helpers.getRadius(props);
|
|
@@ -201,6 +216,6 @@ export class VictoryClipContainer extends React.Component<VictoryClipContainerPr
|
|
|
201
216
|
translateX,
|
|
202
217
|
translateY,
|
|
203
218
|
});
|
|
204
|
-
return this.renderClippedGroup(clipProps, this.clipId);
|
|
219
|
+
return this.renderClippedGroup(clipProps, this.state.clipId);
|
|
205
220
|
}
|
|
206
221
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
|
-
import
|
|
2
|
+
import uniqueId from "lodash/uniqueId";
|
|
3
3
|
import { Portal } from "../victory-portal/portal";
|
|
4
4
|
import * as UserProps from "../victory-util/user-props";
|
|
5
5
|
import { OriginType } from "../victory-label/victory-label";
|
|
@@ -155,9 +155,9 @@ export const VictoryContainer = (initialProps: VictoryContainerProps) => {
|
|
|
155
155
|
...style,
|
|
156
156
|
width: responsive ? style?.width : dimensions.width,
|
|
157
157
|
height: responsive ? style?.height : dimensions.height,
|
|
158
|
-
pointerEvents: "none",
|
|
159
|
-
touchAction: "none",
|
|
160
|
-
position: "relative",
|
|
158
|
+
pointerEvents: style?.pointerEvents ?? "none",
|
|
159
|
+
touchAction: style?.touchAction ?? "none",
|
|
160
|
+
position: style?.position ?? "relative",
|
|
161
161
|
}}
|
|
162
162
|
data-ouia-component-id={ouiaId}
|
|
163
163
|
data-ouia-component-type={ouiaType}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/
|
|
2
|
-
import { defaults, isEmpty } from "lodash";
|
|
3
2
|
import React from "react";
|
|
3
|
+
import defaults from "lodash/defaults";
|
|
4
|
+
import isEmpty from "lodash/isEmpty";
|
|
5
|
+
|
|
4
6
|
import { VictoryPortal } from "../victory-portal/victory-portal";
|
|
5
7
|
import { Rect } from "../victory-primitives/rect";
|
|
6
8
|
import { Text } from "../victory-primitives/text";
|
|
@@ -144,11 +146,11 @@ const getBackgroundPadding = (props) => {
|
|
|
144
146
|
if (props.backgroundPadding && Array.isArray(props.backgroundPadding)) {
|
|
145
147
|
return props.backgroundPadding.map((backgroundPadding) => {
|
|
146
148
|
const padding = Helpers.evaluateProp(backgroundPadding, props);
|
|
147
|
-
return Helpers.getPadding(
|
|
149
|
+
return Helpers.getPadding(padding);
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
152
|
const padding = Helpers.evaluateProp(props.backgroundPadding, props);
|
|
151
|
-
return Helpers.getPadding(
|
|
153
|
+
return Helpers.getPadding(padding);
|
|
152
154
|
};
|
|
153
155
|
|
|
154
156
|
const getLineHeight = (props) => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import uniqueId from "lodash/uniqueId";
|
|
4
|
+
|
|
3
5
|
import * as Log from "../victory-util/log";
|
|
4
6
|
import * as Helpers from "../victory-util/helpers";
|
|
5
7
|
import { usePortalContext } from "./portal-context";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
|
|
2
2
|
import React from "react";
|
|
3
|
-
import
|
|
3
|
+
import defaults from "lodash/defaults";
|
|
4
4
|
|
|
5
5
|
import * as Helpers from "../victory-util/helpers";
|
|
6
6
|
import { VictoryCommonPrimitiveProps } from "../victory-util/common-props";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
3
|
|
|
4
4
|
import * as Helpers from "../victory-util/helpers";
|
|
5
5
|
import * as pathHelpers from "../victory-util/point-path-helpers";
|
|
@@ -12,9 +12,9 @@ export interface PointProps extends VictoryCommonPrimitiveProps {
|
|
|
12
12
|
datum?: any;
|
|
13
13
|
getPath?: (x: number, y: number, size: number) => string;
|
|
14
14
|
pathComponent?: React.ReactElement;
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
16
16
|
size?: number | Function;
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
18
18
|
symbol?: ScatterSymbolType | Function;
|
|
19
19
|
x?: number;
|
|
20
20
|
y?: number;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import pick from "lodash/pick";
|
|
4
|
+
import isEqual from "react-fast-compare";
|
|
5
|
+
|
|
2
6
|
import { VictoryAnimation } from "../victory-animation/victory-animation";
|
|
3
7
|
import * as Collection from "../victory-util/collection";
|
|
4
8
|
import * as Helpers from "../victory-util/helpers";
|
|
5
9
|
import TimerContext from "../victory-util/timer-context";
|
|
6
10
|
import * as Transitions from "../victory-util/transitions";
|
|
7
|
-
import { defaults, pick } from "lodash";
|
|
8
|
-
import isEqual from "react-fast-compare";
|
|
9
11
|
import Timer from "../victory-util/timer";
|
|
10
12
|
|
|
11
13
|
type VictoryTransitionChild = React.ReactElement<
|
|
@@ -66,7 +68,7 @@ export class VictoryTransition extends React.Component<
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
componentDidMount() {
|
|
69
|
-
this.setState({ nodesShouldLoad: true });
|
|
71
|
+
this.setState({ nodesShouldLoad: true });
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
shouldComponentUpdate(nextProps: VictoryTransitionProps) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import isEmpty from "lodash/isEmpty";
|
|
4
|
+
import pick from "lodash/pick";
|
|
5
|
+
|
|
3
6
|
import isEqual from "react-fast-compare";
|
|
4
7
|
|
|
5
8
|
import { VictoryLabelableProps } from "../types/prop-types";
|
|
@@ -54,7 +57,7 @@ export interface EventsMixinClass<TProps> {
|
|
|
54
57
|
): React.ReactElement;
|
|
55
58
|
cacheValues<TThis>(this: TThis, obj: Partial<TThis>): void;
|
|
56
59
|
getEventState: typeof Events.getEventState;
|
|
57
|
-
renderData(props: TProps);
|
|
60
|
+
renderData(props: TProps, shouldRenderDatum?: () => boolean);
|
|
58
61
|
renderContinuousData(props: TProps);
|
|
59
62
|
animateComponent(
|
|
60
63
|
props: TProps,
|
|
@@ -127,7 +130,7 @@ export function addEvents<
|
|
|
127
130
|
TBase extends WrappedComponentClass<TProps>,
|
|
128
131
|
TProps extends EventMixinCommonProps,
|
|
129
132
|
>(WrappedComponent: TBase, options: MixinOptions = {}) {
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
131
134
|
interface AddEventsMixin extends EventMixinCalculatedValues {}
|
|
132
135
|
|
|
133
136
|
// @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import isObject from "lodash/isObject";
|
|
4
|
+
import uniq from "lodash/uniq";
|
|
5
|
+
import orderBy from "lodash/orderBy";
|
|
6
|
+
|
|
3
7
|
import * as Collection from "./collection";
|
|
4
8
|
import * as Domain from "./domain";
|
|
5
9
|
import * as Helpers from "./helpers";
|
|
@@ -214,8 +218,8 @@ function getTickArray(props) {
|
|
|
214
218
|
arr.forEach((t, index) => {
|
|
215
219
|
if (Array.isArray(domain)) {
|
|
216
220
|
if (
|
|
217
|
-
t >= Collection.getMinValue(domain) &&
|
|
218
|
-
t <= Collection.getMaxValue(domain)
|
|
221
|
+
t >= Collection.getMinValue(domain).valueOf() &&
|
|
222
|
+
t <= Collection.getMaxValue(domain).valueOf()
|
|
219
223
|
) {
|
|
220
224
|
newTickArray.push({
|
|
221
225
|
value: t,
|
|
@@ -313,7 +317,7 @@ export function getTicks(props, scale: D3Scale, filterZero = false) {
|
|
|
313
317
|
* @param {String} axis: either x or y
|
|
314
318
|
* @returns {Array} returns a domain from tickValues
|
|
315
319
|
*/
|
|
316
|
-
|
|
320
|
+
|
|
317
321
|
function getDomainFromData(props, axis) {
|
|
318
322
|
const { polar, startAngle = 0, endAngle = 360 } = props;
|
|
319
323
|
const tickArray = getTickArray(props);
|
|
@@ -57,7 +57,7 @@ export interface VictoryCommonThemeProps {
|
|
|
57
57
|
x?: ScalePropType | D3Scale;
|
|
58
58
|
y?: ScalePropType | D3Scale;
|
|
59
59
|
};
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
61
61
|
sharedEvents?: { events: any[]; getEventState: Function };
|
|
62
62
|
singleQuadrantDomainPadding?: boolean | { x?: boolean; y?: boolean };
|
|
63
63
|
standalone?: boolean;
|
|
@@ -72,11 +72,11 @@ export interface VictoryCommonPrimitiveProps {
|
|
|
72
72
|
className?: string;
|
|
73
73
|
clipPath?: string;
|
|
74
74
|
data?: any;
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
76
76
|
desc?: string | Function;
|
|
77
77
|
disableInlineStyles?: boolean;
|
|
78
78
|
events?: object;
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
80
80
|
id?: number | string | Function;
|
|
81
81
|
index?: number | string;
|
|
82
82
|
origin?: OriginType;
|
package/src/victory-util/data.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
/* eslint-disable no-use-before-define */
|
|
2
1
|
import React from "react";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "lodash";
|
|
2
|
+
import isEmpty from "lodash/isEmpty";
|
|
3
|
+
import isEqual from "lodash/isEqual";
|
|
4
|
+
import isPlainObject from "lodash/isPlainObject";
|
|
5
|
+
import isUndefined from "lodash/isUndefined";
|
|
6
|
+
import omitBy from "lodash/omitBy";
|
|
7
|
+
import orderBy from "lodash/orderBy";
|
|
8
|
+
import property from "lodash/property";
|
|
9
|
+
import uniq from "lodash/uniq";
|
|
10
|
+
|
|
13
11
|
import * as Helpers from "./helpers";
|
|
14
12
|
import * as Collection from "./collection";
|
|
15
13
|
import * as Scale from "./scale";
|
|
@@ -141,7 +139,6 @@ export function formatDataFromDomain(dataset, domain, defaultBaseline?) {
|
|
|
141
139
|
const isOverMaxX = overMax(maxDomainX);
|
|
142
140
|
const isOverMaxY = overMax(maxDomainY);
|
|
143
141
|
|
|
144
|
-
// eslint-disable-next-line complexity
|
|
145
142
|
return dataset.map((datum) => {
|
|
146
143
|
let { _x, _y, _y0, _y1 } = datum;
|
|
147
144
|
|
|
@@ -283,7 +280,6 @@ export function formatData(
|
|
|
283
280
|
const data = preformattedData
|
|
284
281
|
? dataset
|
|
285
282
|
: dataset.reduce((dataArr, datum, index) => {
|
|
286
|
-
// eslint-disable-line complexity
|
|
287
283
|
const parsedDatum = parseDatum(datum);
|
|
288
284
|
const fallbackValues = { x: index, y: parsedDatum };
|
|
289
285
|
const processedValues = expectedKeys!.reduce((memo, type) => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
/* eslint-disable no-use-before-define */
|
|
2
1
|
import React from "react";
|
|
3
|
-
import
|
|
2
|
+
import isDate from "lodash/isDate";
|
|
3
|
+
import isPlainObject from "lodash/isPlainObject";
|
|
4
|
+
import sortedUniq from "lodash/sortedUniq";
|
|
5
|
+
|
|
4
6
|
import * as Data from "./data";
|
|
5
7
|
import * as Scale from "./scale";
|
|
6
8
|
import * as Helpers from "./helpers";
|
|
@@ -67,7 +69,6 @@ function getExtremeFromData(dataset, axis, type = "min") {
|
|
|
67
69
|
return containsDate ? new Date(result) : result;
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
// eslint-disable-next-line max-statements
|
|
71
72
|
function padDomain(domain, props, axis) {
|
|
72
73
|
if (!props.domainPadding) {
|
|
73
74
|
return domain;
|
|
@@ -110,12 +111,13 @@ function padDomain(domain, props, axis) {
|
|
|
110
111
|
: props.singleQuadrantDomainPadding;
|
|
111
112
|
|
|
112
113
|
const addsQuadrants =
|
|
113
|
-
(min >= 0 && paddedDomain.min <= 0) ||
|
|
114
|
+
(min.valueOf() >= 0 && paddedDomain.min <= 0) ||
|
|
115
|
+
(max.valueOf() <= 0 && paddedDomain.max >= 0);
|
|
114
116
|
|
|
115
117
|
const adjust = (val, type) => {
|
|
116
118
|
const coerce =
|
|
117
|
-
(type === "min" && min >= 0 && val <= 0) ||
|
|
118
|
-
(type === "max" && max <= 0 && val >= 0);
|
|
119
|
+
(type === "min" && min.valueOf() >= 0 && val <= 0) ||
|
|
120
|
+
(type === "max" && max.valueOf() <= 0 && val >= 0);
|
|
119
121
|
return coerce ? 0 : val;
|
|
120
122
|
};
|
|
121
123
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import isEmpty from "lodash/isEmpty";
|
|
3
|
+
import pickBy from "lodash/pickBy";
|
|
4
|
+
import omitBy from "lodash/omitBy";
|
|
5
|
+
import uniq from "lodash/uniq";
|
|
6
|
+
|
|
3
7
|
import type { EventMixinCalculatedValues } from "./add-events";
|
|
4
8
|
import { isFunction } from "./helpers";
|
|
5
9
|
|
|
@@ -72,9 +76,12 @@ export function getEvents(
|
|
|
72
76
|
const selectedEvents = getSelectedEvents();
|
|
73
77
|
return (
|
|
74
78
|
Array.isArray(selectedEvents) &&
|
|
75
|
-
selectedEvents.reduce(
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
selectedEvents.reduce(
|
|
80
|
+
(memo, event) => {
|
|
81
|
+
return event ? Object.assign(memo, event.eventHandlers) : memo;
|
|
82
|
+
},
|
|
83
|
+
{} as ComponentEvent["eventHandlers"],
|
|
84
|
+
)
|
|
78
85
|
);
|
|
79
86
|
};
|
|
80
87
|
|
|
@@ -84,13 +91,13 @@ export function getEvents(
|
|
|
84
91
|
*/
|
|
85
92
|
const getAllEvents = () => {
|
|
86
93
|
// Mandatory usage: `getEvents.bind(this)`
|
|
87
|
-
|
|
94
|
+
|
|
88
95
|
if (Array.isArray(this.componentEvents)) {
|
|
89
96
|
return Array.isArray(props.events)
|
|
90
97
|
? this.componentEvents.concat(...props.events)
|
|
91
98
|
: this.componentEvents;
|
|
92
99
|
}
|
|
93
|
-
|
|
100
|
+
|
|
94
101
|
return props.events;
|
|
95
102
|
};
|
|
96
103
|
|
|
@@ -127,12 +134,12 @@ export function getScopedEvents(
|
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
// Mandatory usage: `getScopedEvents.bind(this)`
|
|
130
|
-
|
|
137
|
+
|
|
131
138
|
const newBaseProps = baseProps || this.baseProps;
|
|
132
139
|
// returns the original base props or base state of a given target element
|
|
133
140
|
const getTargetProps = (identifier, type) => {
|
|
134
141
|
const { childName, target, key } = identifier;
|
|
135
|
-
|
|
142
|
+
|
|
136
143
|
const baseType = type === "props" ? newBaseProps : this.state || {};
|
|
137
144
|
const base =
|
|
138
145
|
childName === undefined || childName === null || !baseType[childName]
|
|
@@ -173,7 +180,6 @@ export function getScopedEvents(
|
|
|
173
180
|
|
|
174
181
|
// returns the state object with mutated props applied for a single key
|
|
175
182
|
const getMutationObject = (key, childName) => {
|
|
176
|
-
// eslint-disable-next-line no-invalid-this
|
|
177
183
|
const baseState = this.state || {};
|
|
178
184
|
if (!isFunction(eventReturn.mutation)) {
|
|
179
185
|
return baseState;
|
|
@@ -270,11 +276,10 @@ export function getScopedEvents(
|
|
|
270
276
|
// into a state mutation, and calls setState
|
|
271
277
|
// eslint-disable-next-line max-params
|
|
272
278
|
const onEvent = (evt, childProps, eventKey, eventName) => {
|
|
273
|
-
// eslint-disable-next-line no-invalid-this
|
|
274
279
|
const eventReturn = events[eventName](evt, childProps, eventKey, this);
|
|
275
280
|
if (!isEmpty(eventReturn)) {
|
|
276
281
|
const callbacks = compileCallbacks(eventReturn);
|
|
277
|
-
|
|
282
|
+
|
|
278
283
|
this.setState(parseEventReturn(eventReturn, eventKey), callbacks);
|
|
279
284
|
}
|
|
280
285
|
};
|
|
@@ -319,7 +324,7 @@ export function getEventState(
|
|
|
319
324
|
childType?: string,
|
|
320
325
|
) {
|
|
321
326
|
// Mandatory usage: `getEventState.bind(this)`
|
|
322
|
-
|
|
327
|
+
|
|
323
328
|
const state = this.state || {};
|
|
324
329
|
if (!childType) {
|
|
325
330
|
return eventKey === "parent"
|