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
|
@@ -61,9 +61,9 @@ var getConstructor = function (value) {
|
|
|
61
61
|
return undefinedConstructor;
|
|
62
62
|
} else if (value === null) {
|
|
63
63
|
return nullConstructor;
|
|
64
|
-
} else {
|
|
65
|
-
return value.constructor;
|
|
66
64
|
}
|
|
65
|
+
|
|
66
|
+
return value.constructor;
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
69
|
* Get the name of the constructor used to create `value`, using
|
package/es/victory-util/scale.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { VictoryCommonProps } from "./
|
|
2
|
+
import { VictoryCommonProps } from "./common-props";
|
|
3
3
|
import type { DomainPropType, ScaleXYPropType } from "../types/prop-types";
|
|
4
4
|
export declare function getParentSVG(evt: Pick<React.SyntheticEvent, "target"> & Partial<Pick<React.SyntheticEvent, "nativeEvent">>): SVGElement;
|
|
5
5
|
export declare function getSVGEventCoordinates(evt: React.SyntheticEvent, svg?: SVGElement): SVGCoordinateType;
|
|
6
|
-
export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "scale" | "horizontal">, domain?: DomainPropType):
|
|
6
|
+
export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "scale" | "horizontal">, domain?: DomainPropType): {
|
|
7
|
+
x: number[];
|
|
8
|
+
y: number[];
|
|
9
|
+
};
|
|
7
10
|
export declare function getDataCoordinates(props: any, scale: ScaleXYPropType, x: number, y: number): SVGCoordinateType;
|
|
8
11
|
export declare function getBounds(props: ComputedCommonProps): SVGCoordinateBounds;
|
|
9
12
|
export declare type SVGCoordinateType = {
|
|
@@ -20,6 +23,7 @@ declare type ComputedCommonProps = {
|
|
|
20
23
|
x2: number;
|
|
21
24
|
y1: number;
|
|
22
25
|
y2: number;
|
|
26
|
+
horizontal?: boolean;
|
|
23
27
|
};
|
|
24
28
|
export {};
|
|
25
29
|
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Collection from "./collection";
|
|
2
2
|
|
|
3
3
|
// Private Functions
|
|
4
4
|
function transformTarget(target, matrix, dimension) {
|
|
@@ -31,9 +31,9 @@ export function getParentSVG(evt) {
|
|
|
31
31
|
var getParent = function (target) {
|
|
32
32
|
if (target.nodeName === "svg") {
|
|
33
33
|
return target;
|
|
34
|
-
} else {
|
|
35
|
-
return target.parentNode ? getParent(target.parentNode) : target;
|
|
36
34
|
}
|
|
35
|
+
|
|
36
|
+
return target.parentNode ? getParent(target.parentNode) : target;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
return getParent(evt.target);
|
|
@@ -79,20 +79,20 @@ export function getDataCoordinates(props, scale, x, y) {
|
|
|
79
79
|
x: horizontal ? scale.x.invert(y) : scale.x.invert(x),
|
|
80
80
|
y: horizontal ? scale.y.invert(x) : scale.y.invert(y)
|
|
81
81
|
};
|
|
82
|
-
} else {
|
|
83
|
-
var origin = props.origin || {
|
|
84
|
-
x: 0,
|
|
85
|
-
y: 0
|
|
86
|
-
};
|
|
87
|
-
var baseX = x - origin.x;
|
|
88
|
-
var baseY = y - origin.y;
|
|
89
|
-
var radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
|
|
90
|
-
var angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
|
|
91
|
-
return {
|
|
92
|
-
x: scale.x.invert(angle),
|
|
93
|
-
y: scale.y.invert(radius)
|
|
94
|
-
};
|
|
95
82
|
}
|
|
83
|
+
|
|
84
|
+
var origin = props.origin || {
|
|
85
|
+
x: 0,
|
|
86
|
+
y: 0
|
|
87
|
+
};
|
|
88
|
+
var baseX = x - origin.x;
|
|
89
|
+
var baseY = y - origin.y;
|
|
90
|
+
var radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
|
|
91
|
+
var angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
|
|
92
|
+
return {
|
|
93
|
+
x: scale.x.invert(angle),
|
|
94
|
+
y: scale.y.invert(radius)
|
|
95
|
+
};
|
|
96
96
|
}
|
|
97
97
|
export function getBounds(props) {
|
|
98
98
|
var x1 = props.x1,
|
package/es/victory-util/style.js
CHANGED
|
@@ -16,22 +16,22 @@ export var toTransformString = function (obj) {
|
|
|
16
16
|
return more.reduce(function (memo, currentObj) {
|
|
17
17
|
return [memo, toTransformString(currentObj)].join(" ");
|
|
18
18
|
}, toTransformString(obj)).trim();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (obj === undefined || obj === null || typeof obj === "string") {
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
var transforms = [];
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
27
|
+
for (var key in obj) {
|
|
28
|
+
if (obj.hasOwnProperty(key)) {
|
|
29
|
+
var value = obj[key];
|
|
30
|
+
transforms.push("".concat(key, "(").concat(value, ")"));
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
return transforms.join(" ").trim();
|
|
34
32
|
}
|
|
33
|
+
|
|
34
|
+
return transforms.join(" ").trim();
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Given the name of a color scale, getColorScale will return an array
|
|
@@ -15,7 +15,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
15
15
|
|
|
16
16
|
// Based on measuring specific character widths
|
|
17
17
|
// as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf
|
|
18
|
-
//prettier-ignore
|
|
18
|
+
// prettier-ignore
|
|
19
19
|
var fonts = {
|
|
20
20
|
"American Typewriter": {
|
|
21
21
|
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.4203125, 0.3296875, 0.6, 0.6375, 0.8015625, 0.8203125, 0.1875, 0.45625, 0.45625, 0.6375, 0.5, 0.2734375, 0.309375, 0.2734375, 0.4390625, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.2734375, 0.2734375, 0.5, 0.5, 0.5, 0.6, 0.6921875, 0.7640625, 0.6921875, 0.6375, 0.728125, 0.6734375, 0.6203125, 0.7109375, 0.784375, 0.3828125, 0.6421875, 0.7859375, 0.6375, 0.9484375, 0.7640625, 0.65625, 0.6375, 0.65625, 0.7296875, 0.6203125, 0.6375, 0.7109375, 0.740625, 0.940625, 0.784375, 0.7578125, 0.6203125, 0.4375, 0.5, 0.4375, 0.5, 0.5, 0.4921875, 0.5734375, 0.5890625, 0.5109375, 0.6, 0.528125, 0.43125, 0.5578125, 0.6375, 0.3109375, 0.40625, 0.6234375, 0.309375, 0.928125, 0.6375, 0.546875, 0.6, 0.58125, 0.4921875, 0.4921875, 0.4, 0.6203125, 0.625, 0.825, 0.6375, 0.640625, 0.528125, 0.5, 0.5, 0.5, 0.6671875],
|
|
@@ -121,7 +121,7 @@ var fonts = {
|
|
|
121
121
|
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.35, 0.39375, 0.459375, 0.81875, 0.6359375, 1.0765625, 0.759375, 0.26875, 0.4546875, 0.4546875, 0.6359375, 0.81875, 0.3640625, 0.4546875, 0.3640625, 0.4703125, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.4546875, 0.4546875, 0.81875, 0.81875, 0.81875, 0.546875, 1, 0.684375, 0.6859375, 0.6984375, 0.771875, 0.6328125, 0.575, 0.7765625, 0.7515625, 0.421875, 0.4546875, 0.69375, 0.5578125, 0.84375, 0.7484375, 0.7875, 0.603125, 0.7875, 0.7, 0.684375, 0.6171875, 0.7328125, 0.684375, 0.9890625, 0.6859375, 0.615625, 0.6859375, 0.4546875, 0.46875, 0.4546875, 0.81875, 0.6421875, 0.6359375, 0.6015625, 0.6234375, 0.521875, 0.6234375, 0.596875, 0.384375, 0.6234375, 0.6328125, 0.275, 0.3765625, 0.5921875, 0.275, 0.9734375, 0.6328125, 0.6078125, 0.6234375, 0.6234375, 0.43125, 0.521875, 0.3953125, 0.6328125, 0.5921875, 0.81875, 0.5921875, 0.5921875, 0.5265625, 0.6359375, 0.4546875, 0.6359375, 0.81875],
|
|
122
122
|
avg: 0.6171875000000003
|
|
123
123
|
}
|
|
124
|
-
}; //https://developer.mozilla.org/en/docs/Web/CSS/length
|
|
124
|
+
}; // https://developer.mozilla.org/en/docs/Web/CSS/length
|
|
125
125
|
// Absolute sizes in pixels for obsolete measurement units.
|
|
126
126
|
|
|
127
127
|
var absoluteMeasurementUnitsToPixels = {
|
|
@@ -345,9 +345,9 @@ export function getTransitionPropsFactory(props, state, setState) {
|
|
|
345
345
|
if (defaultTransitions) {
|
|
346
346
|
var animationDuration = animate[type] && animate[type].duration;
|
|
347
347
|
return animationDuration !== undefined ? animationDuration : defaultTransitions[type] && defaultTransitions[type].duration;
|
|
348
|
-
} else {
|
|
349
|
-
return {};
|
|
350
348
|
}
|
|
349
|
+
|
|
350
|
+
return {};
|
|
351
351
|
}; // eslint-disable-next-line max-statements, complexity, max-len
|
|
352
352
|
|
|
353
353
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare type SafeAttribute =
|
|
2
|
+
declare type SafeAttribute = string;
|
|
3
3
|
/**
|
|
4
4
|
* getSafeUserProps - function that takes in a props object and removes any
|
|
5
5
|
* key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
|
|
@@ -27,7 +27,9 @@ import * as React from "react";
|
|
|
27
27
|
var USER_PROPS_SAFELIST = {
|
|
28
28
|
startsWith: ["data-", "aria-"],
|
|
29
29
|
exactMatch: []
|
|
30
|
-
};
|
|
30
|
+
}; // Normally we'd use Template Literal Types, but we're avoiding it to maximize TS compatibility with TS < 4.1
|
|
31
|
+
|
|
32
|
+
// `data-${string}` | `aria-${string}`;
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* doesPropStartWith: Function that takes a prop's key and runs it against all
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { VictoryProviderProps } from "victory-
|
|
2
|
+
import { VictoryProviderProps } from "../victory-state";
|
|
3
3
|
import { VictoryCommonProps } from "./common-props";
|
|
4
|
-
export declare function withContainer<Props extends VictoryCommonProps>(WrappedComponent:
|
|
4
|
+
export declare function withContainer<Props extends VictoryCommonProps>(WrappedComponent: React.FC<Props>, initialProviderProps?: Partial<VictoryProviderProps>): React.FC<Props>;
|
|
5
5
|
//# sourceMappingURL=with-container.d.ts.map
|
|
@@ -5,7 +5,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
import React from "react";
|
|
8
|
-
import { VictoryProvider
|
|
8
|
+
import { VictoryProvider } from "../victory-state";
|
|
9
|
+
import { VictoryContainer } from "../victory-container/victory-container";
|
|
9
10
|
var defaultProviderProps = {
|
|
10
11
|
width: 450,
|
|
11
12
|
height: 300,
|
|
@@ -31,7 +31,7 @@ export declare function getStringsFromChildren(props: any, childComponents: any)
|
|
|
31
31
|
x: any[];
|
|
32
32
|
y: any[];
|
|
33
33
|
};
|
|
34
|
-
export declare function getCategories(props: any, childComponents: any, allStrings
|
|
34
|
+
export declare function getCategories(props: any, childComponents: any, allStrings?: any): {
|
|
35
35
|
x: any;
|
|
36
36
|
y: any;
|
|
37
37
|
};
|
|
@@ -241,9 +241,9 @@ export function getDomainFromChildren(props, axis, childComponents) {
|
|
|
241
241
|
return null;
|
|
242
242
|
} else if (child.type && _isFunction(child.type.getDomain)) {
|
|
243
243
|
return child.props && child.type.getDomain(sharedProps, axis);
|
|
244
|
-
} else {
|
|
245
|
-
return Domain.getDomain(sharedProps, axis);
|
|
246
244
|
}
|
|
245
|
+
|
|
246
|
+
return Domain.getDomain(sharedProps, axis);
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
var childDomains = Helpers.reduceChildren(children, iteratee, props);
|
|
@@ -366,13 +366,13 @@ export function getStringsFromCategories(childComponents, axis) {
|
|
|
366
366
|
|
|
367
367
|
if (!Domain.isDomainComponent(child) || !childProps.categories) {
|
|
368
368
|
return null;
|
|
369
|
-
} else {
|
|
370
|
-
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
|
|
371
|
-
var categoryStrings = categories && categories.filter(function (val) {
|
|
372
|
-
return typeof val === "string";
|
|
373
|
-
});
|
|
374
|
-
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
|
|
375
369
|
}
|
|
370
|
+
|
|
371
|
+
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
|
|
372
|
+
var categoryStrings = categories && categories.filter(function (val) {
|
|
373
|
+
return typeof val === "string";
|
|
374
|
+
});
|
|
375
|
+
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
|
|
376
376
|
};
|
|
377
377
|
|
|
378
378
|
return Helpers.reduceChildren(childComponents.slice(0), iteratee);
|
package/lib/index.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export * from "./victory-portal/portal";
|
|
|
12
12
|
export * from "./victory-portal/portal-context";
|
|
13
13
|
export * from "./victory-portal/victory-portal";
|
|
14
14
|
export * from "./victory-primitives";
|
|
15
|
-
export { Border as Box
|
|
15
|
+
export { Border as Box } from "./victory-primitives";
|
|
16
|
+
export type { BorderProps as BoxProps } from "./victory-primitives";
|
|
16
17
|
export * from "./victory-util";
|
|
17
18
|
export * from "./victory-state";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/callbacks.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface CallbackArgs {
|
|
|
12
12
|
data?: Datum[];
|
|
13
13
|
datum?: Datum;
|
|
14
14
|
horizontal?: boolean;
|
|
15
|
-
index
|
|
15
|
+
index?: ID;
|
|
16
16
|
x?: number;
|
|
17
17
|
y?: number;
|
|
18
18
|
scale?: {
|
|
@@ -34,4 +34,5 @@ export declare type VictoryOrientationCallback = (args: CallbackArgs) => Orienta
|
|
|
34
34
|
export declare type NumberOrCallback = number | VictoryNumberCallback;
|
|
35
35
|
export declare type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback;
|
|
36
36
|
export declare type OrientationOrCallback = OrientationTypes | VictoryOrientationCallback;
|
|
37
|
+
export declare type ValueOrCallback<TValue> = TValue | ((args: CallbackArgs) => TValue);
|
|
37
38
|
//# sourceMappingURL=callbacks.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback } from "../types/callbacks";
|
|
2
|
+
import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback, ValueOrCallback } from "../types/callbacks";
|
|
3
3
|
import { PaddingProps, VerticalAnchorType, VictoryLabelStyleObject } from "../victory-theme/victory-theme";
|
|
4
4
|
export declare type TextAnchorType = "start" | "middle" | "end" | "inherit";
|
|
5
5
|
export declare type OriginType = {
|
|
@@ -34,15 +34,11 @@ export interface VictoryLabelProps {
|
|
|
34
34
|
tabIndex?: NumberOrCallback;
|
|
35
35
|
text?: string[] | StringOrNumberOrCallback;
|
|
36
36
|
textComponent?: React.ReactElement;
|
|
37
|
-
textAnchor?: TextAnchorType
|
|
38
|
-
(): TextAnchorType;
|
|
39
|
-
};
|
|
37
|
+
textAnchor?: ValueOrCallback<TextAnchorType>;
|
|
40
38
|
title?: string;
|
|
41
|
-
transform?: string | object
|
|
39
|
+
transform?: ValueOrCallback<string | object>;
|
|
42
40
|
tspanComponent?: React.ReactElement;
|
|
43
|
-
verticalAnchor?: VerticalAnchorType
|
|
44
|
-
(): VerticalAnchorType;
|
|
45
|
-
};
|
|
41
|
+
verticalAnchor?: ValueOrCallback<VerticalAnchorType>;
|
|
46
42
|
x?: number;
|
|
47
43
|
y?: number;
|
|
48
44
|
dx?: StringOrNumberOrCallback;
|
|
@@ -85,14 +85,14 @@ var getFontSize = function (style) {
|
|
|
85
85
|
} else if (baseSize === undefined || baseSize === null) {
|
|
86
86
|
return defaultStyles.fontSize;
|
|
87
87
|
} else if (typeof baseSize === "string") {
|
|
88
|
-
var fontSize =
|
|
88
|
+
var fontSize = Number(baseSize.replace("px", ""));
|
|
89
89
|
|
|
90
90
|
if (!isNaN(fontSize)) {
|
|
91
91
|
return fontSize;
|
|
92
|
-
} else {
|
|
93
|
-
Log.warn("fontSize should be expressed as a number of pixels");
|
|
94
|
-
return defaultStyles.fontSize;
|
|
95
92
|
}
|
|
93
|
+
|
|
94
|
+
Log.warn("fontSize should be expressed as a number of pixels");
|
|
95
|
+
return defaultStyles.fontSize;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
return defaultStyles.fontSize;
|
|
@@ -149,12 +149,12 @@ var getBackgroundPadding = function (props) {
|
|
|
149
149
|
padding: padding
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
|
-
} else {
|
|
153
|
-
var padding = Helpers.evaluateProp(props.backgroundPadding, props);
|
|
154
|
-
return Helpers.getPadding({
|
|
155
|
-
padding: padding
|
|
156
|
-
});
|
|
157
152
|
}
|
|
153
|
+
|
|
154
|
+
var padding = Helpers.evaluateProp(props.backgroundPadding, props);
|
|
155
|
+
return Helpers.getPadding({
|
|
156
|
+
padding: padding
|
|
157
|
+
});
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
var getLineHeight = function (props) {
|
|
@@ -162,9 +162,9 @@ var getLineHeight = function (props) {
|
|
|
162
162
|
|
|
163
163
|
if (Array.isArray(lineHeight)) {
|
|
164
164
|
return (0, _isEmpty2.default)(lineHeight) ? [1] : lineHeight;
|
|
165
|
-
} else {
|
|
166
|
-
return lineHeight;
|
|
167
165
|
}
|
|
166
|
+
|
|
167
|
+
return lineHeight;
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
var getContent = function (text, props) {
|
|
@@ -207,13 +207,13 @@ var getDy = function (props, verticalAnchor, lineHeight) {
|
|
|
207
207
|
return anchor === "end" ? dy + (capHeight / 2 - lineHeights[0] / 2) * fontSizes[0] : dy + capHeight / 2 * fontSizes[0];
|
|
208
208
|
} else if (length === 1) {
|
|
209
209
|
return anchor === "end" ? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0] : dy + (capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0];
|
|
210
|
-
} else {
|
|
211
|
-
var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) {
|
|
212
|
-
return memo + (capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i] / length;
|
|
213
|
-
}, 0);
|
|
214
|
-
|
|
215
|
-
return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1];
|
|
216
210
|
}
|
|
211
|
+
|
|
212
|
+
var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) {
|
|
213
|
+
return memo + (capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i] / length;
|
|
214
|
+
}, 0);
|
|
215
|
+
|
|
216
|
+
return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1];
|
|
217
217
|
};
|
|
218
218
|
|
|
219
219
|
var getTransform = function (props, x, y) {
|
|
@@ -417,9 +417,9 @@ var getTSpanDy = function (tspanValues, calculatedProps, i) {
|
|
|
417
417
|
return calculateSpanDy(tspanValues, i, calculatedProps);
|
|
418
418
|
} else if (inline) {
|
|
419
419
|
return i === 0 ? current.backgroundPadding.top : undefined;
|
|
420
|
-
} else {
|
|
421
|
-
return current.backgroundPadding.top;
|
|
422
420
|
}
|
|
421
|
+
|
|
422
|
+
return current.backgroundPadding.top;
|
|
423
423
|
};
|
|
424
424
|
|
|
425
425
|
var evaluateProps = function (props) {
|
|
@@ -39,8 +39,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
39
39
|
|
|
40
40
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
41
|
|
|
42
|
-
var Portal = /*#__PURE__*/function (
|
|
43
|
-
_inherits(Portal,
|
|
42
|
+
var Portal = /*#__PURE__*/function (_ref) {
|
|
43
|
+
_inherits(Portal, _ref);
|
|
44
44
|
|
|
45
45
|
var _super = _createSuper(Portal);
|
|
46
46
|
|
|
@@ -85,7 +85,7 @@ var VictoryTransition = /*#__PURE__*/function (_React$Component) {
|
|
|
85
85
|
value: function componentDidMount() {
|
|
86
86
|
this.setState({
|
|
87
87
|
nodesShouldLoad: true
|
|
88
|
-
}); //eslint-disable-line react/no-did-mount-set-state
|
|
88
|
+
}); // eslint-disable-line react/no-did-mount-set-state
|
|
89
89
|
}
|
|
90
90
|
}, {
|
|
91
91
|
key: "shouldComponentUpdate",
|
|
@@ -120,26 +120,26 @@ var VictoryTransition = /*#__PURE__*/function (_React$Component) {
|
|
|
120
120
|
oldProps: oldProps,
|
|
121
121
|
nextProps: nextProps
|
|
122
122
|
};
|
|
123
|
-
}
|
|
124
|
-
var oldChildren = _react.default.Children.toArray(props.children);
|
|
123
|
+
}
|
|
125
124
|
|
|
126
|
-
|
|
125
|
+
var oldChildren = _react.default.Children.toArray(props.children);
|
|
127
126
|
|
|
128
|
-
|
|
129
|
-
nodesWillExit = _Transitions$getIniti.nodesWillExit,
|
|
130
|
-
nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
|
|
131
|
-
childrenTransitions = _Transitions$getIniti.childrenTransitions,
|
|
132
|
-
nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
|
|
127
|
+
var nextChildren = _react.default.Children.toArray(nextProps.children);
|
|
133
128
|
|
|
134
|
-
|
|
135
|
-
nodesWillExit
|
|
136
|
-
nodesWillEnter
|
|
137
|
-
childrenTransitions
|
|
138
|
-
nodesShouldEnter
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
129
|
+
var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
|
|
130
|
+
nodesWillExit = _Transitions$getIniti.nodesWillExit,
|
|
131
|
+
nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
|
|
132
|
+
childrenTransitions = _Transitions$getIniti.childrenTransitions,
|
|
133
|
+
nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
nodesWillExit: nodesWillExit,
|
|
137
|
+
nodesWillEnter: nodesWillEnter,
|
|
138
|
+
childrenTransitions: childrenTransitions,
|
|
139
|
+
nodesShouldEnter: nodesShouldEnter,
|
|
140
|
+
oldProps: nodesWillExit ? props : null,
|
|
141
|
+
nextProps: nextProps
|
|
142
|
+
};
|
|
143
143
|
}
|
|
144
144
|
}, {
|
|
145
145
|
key: "getDomainFromChildren",
|
|
@@ -164,10 +164,10 @@ var VictoryTransition = /*#__PURE__*/function (_React$Component) {
|
|
|
164
164
|
|
|
165
165
|
if (!childProps.children && domain) {
|
|
166
166
|
return domain;
|
|
167
|
-
} else {
|
|
168
|
-
var childDomains = getChildDomains([child]);
|
|
169
|
-
return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
|
|
170
167
|
}
|
|
168
|
+
|
|
169
|
+
var childDomains = getChildDomains([child]);
|
|
170
|
+
return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
|
|
171
171
|
}
|
|
172
172
|
}, {
|
|
173
173
|
key: "pickProps",
|
|
@@ -6,7 +6,7 @@ import { VictoryLabelableProps } from "../types/prop-types";
|
|
|
6
6
|
export declare type MixinOptions = {
|
|
7
7
|
components?: Array<{
|
|
8
8
|
name: string;
|
|
9
|
-
index?: string;
|
|
9
|
+
index?: string | number;
|
|
10
10
|
}>;
|
|
11
11
|
};
|
|
12
12
|
export interface EventMixinCommonProps extends VictoryCommonProps, VictoryDatableProps, VictoryLabelableProps {
|
|
@@ -21,11 +21,14 @@ export interface EventMixinCommonProps extends VictoryCommonProps, VictoryDatabl
|
|
|
21
21
|
* class MyComponent extends React.Component<MyProps> { ... }
|
|
22
22
|
*/
|
|
23
23
|
export interface EventsMixinClass<TProps> {
|
|
24
|
-
renderContainer(component: React.ReactElement, children: React.ReactElement[]): React.ReactElement;
|
|
24
|
+
renderContainer(component: React.ReactElement, children: React.ReactElement | React.ReactElement[]): React.ReactElement;
|
|
25
25
|
cacheValues<TThis>(this: TThis, obj: Partial<TThis>): void;
|
|
26
26
|
getEventState: typeof Events.getEventState;
|
|
27
|
+
renderData(props: TProps): any;
|
|
27
28
|
renderContinuousData(props: TProps): any;
|
|
28
|
-
animateComponent(props: TProps, defaultAnimationWhitelist:
|
|
29
|
+
animateComponent(props: TProps, defaultAnimationWhitelist: string[]): React.ReactElement;
|
|
30
|
+
getComponentProps(component: React.ReactElement, type: string, index: number): TProps;
|
|
31
|
+
dataKeys: string[];
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* These fields are calculated by the Mixin
|
|
@@ -38,14 +41,30 @@ export interface EventMixinCalculatedValues {
|
|
|
38
41
|
hasEvents: unknown;
|
|
39
42
|
events: unknown;
|
|
40
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* These are the common roles that we care about internally.
|
|
46
|
+
*/
|
|
47
|
+
export declare type VictoryComponentCommonRole = "container" | "group" | "histogram" | "label" | "line" | "portal" | "stack" | "tooltip" | "voronoi";
|
|
48
|
+
/**
|
|
49
|
+
* A component can have any "role",
|
|
50
|
+
* but there are certain ones that we actually care about internally
|
|
51
|
+
*/
|
|
52
|
+
export declare type VictoryComponentRole = VictoryComponentCommonRole | string;
|
|
53
|
+
/**
|
|
54
|
+
* Static component fields used by Victory for common behavior
|
|
55
|
+
*/
|
|
56
|
+
export interface VictoryComponentConfiguration<TProps> {
|
|
57
|
+
getBaseProps?(props: TProps): EventMixinCalculatedValues["baseProps"];
|
|
58
|
+
role?: VictoryComponentRole;
|
|
59
|
+
expectedComponents?: Array<keyof TProps | string>;
|
|
60
|
+
getChildren?: (props: TProps, childComponents?: Array<React.ReactNode>, calculatedProps?: TProps) => void;
|
|
61
|
+
animationWhitelist?: Array<keyof TProps | string>;
|
|
62
|
+
}
|
|
41
63
|
/**
|
|
42
64
|
* This represents the class itself, including static fields
|
|
43
65
|
*/
|
|
44
|
-
export interface WrappedComponentClass<TProps> {
|
|
66
|
+
export interface WrappedComponentClass<TProps> extends VictoryComponentConfiguration<TProps> {
|
|
45
67
|
new (props: TProps): React.Component<TProps>;
|
|
46
|
-
getBaseProps?(props: TProps): EventMixinCalculatedValues["baseProps"];
|
|
47
|
-
role?: string;
|
|
48
|
-
expectedComponents?: string[];
|
|
49
68
|
}
|
|
50
69
|
export declare function addEvents<TBase extends WrappedComponentClass<TProps>, TProps extends EventMixinCommonProps>(WrappedComponent: TBase, options?: MixinOptions): {
|
|
51
70
|
new (props: TProps): {
|
|
@@ -73,7 +92,7 @@ export declare function addEvents<TBase extends WrappedComponentClass<TProps>, T
|
|
|
73
92
|
getAllEvents(props: any): any;
|
|
74
93
|
getComponentProps(component: any, type: any, index: any): any;
|
|
75
94
|
renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
76
|
-
animateComponent(props: TProps, defaultAnimationWhitelist: string[]):
|
|
95
|
+
animateComponent(props: TProps, defaultAnimationWhitelist: string[]): React.ReactElement;
|
|
77
96
|
renderContinuousData(props: TProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
78
97
|
renderData(props: any, shouldRenderDatum?: (datum: any) => boolean): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
79
98
|
context: unknown;
|
|
@@ -101,6 +120,8 @@ export declare function addEvents<TBase extends WrappedComponentClass<TProps>, T
|
|
|
101
120
|
};
|
|
102
121
|
getBaseProps?(props: TProps): Record<string, object>;
|
|
103
122
|
role?: string | undefined;
|
|
104
|
-
expectedComponents?: string[] | undefined;
|
|
123
|
+
expectedComponents?: (string | keyof TProps)[] | undefined;
|
|
124
|
+
getChildren?: ((props: TProps, childComponents?: React.ReactNode[] | undefined, calculatedProps?: TProps | undefined) => void) | undefined;
|
|
125
|
+
animationWhitelist?: (string | keyof TProps)[] | undefined;
|
|
105
126
|
} & TBase;
|
|
106
127
|
//# sourceMappingURL=add-events.d.ts.map
|
|
@@ -227,11 +227,11 @@ function addEvents(WrappedComponent) {
|
|
|
227
227
|
if (!props.standalone && component.name === "parent") {
|
|
228
228
|
// don't check for changes on parent props for non-standalone components
|
|
229
229
|
return undefined;
|
|
230
|
-
} else {
|
|
231
|
-
return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
|
|
232
|
-
return getState(key, component.name);
|
|
233
|
-
}).filter(Boolean);
|
|
234
230
|
}
|
|
231
|
+
|
|
232
|
+
return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
|
|
233
|
+
return getState(key, component.name);
|
|
234
|
+
}).filter(Boolean);
|
|
235
235
|
}).filter(Boolean);
|
|
236
236
|
return stateChanges;
|
|
237
237
|
}
|