victory-core 36.5.2 → 36.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/victory-core.js +5303 -4726
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +1 -0
- 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 +3 -3
- 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 +5 -1
- package/es/victory-util/selection.js +15 -15
- 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 +1 -1
- 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 +1 -0
- 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 +3 -3
- 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 +5 -1
- package/lib/victory-util/selection.js +15 -15
- 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 +1 -1
- 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 +1 -0
- 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} +24 -9
- 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 +12 -13
- 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 +2 -5
- package/src/victory-util/wrapper.tsx +9 -11
- package/dist/victory-core.min.js.LICENSE.txt +0 -19
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
function isNonEmptyArray(
|
|
1
|
+
function isNonEmptyArray<T>(
|
|
2
|
+
collection: Array<T> | unknown,
|
|
3
|
+
): collection is Array<T> {
|
|
2
4
|
return Array.isArray(collection) && collection.length > 0;
|
|
3
5
|
}
|
|
4
6
|
|
|
@@ -23,15 +25,22 @@ export function containsNumbers(collection) {
|
|
|
23
25
|
);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
export function containsOnlyStrings(
|
|
28
|
+
export function containsOnlyStrings(
|
|
29
|
+
collection: Array<string> | unknown,
|
|
30
|
+
): collection is Array<string> {
|
|
27
31
|
return (
|
|
28
32
|
isNonEmptyArray(collection) &&
|
|
29
33
|
collection.every((value) => typeof value === "string")
|
|
30
34
|
);
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
export function isArrayOfArrays(
|
|
34
|
-
|
|
37
|
+
export function isArrayOfArrays<T>(
|
|
38
|
+
collection: Array<T> | Array<Array<T>> | unknown,
|
|
39
|
+
): collection is Array<Array<T>> {
|
|
40
|
+
return (
|
|
41
|
+
isNonEmptyArray(collection) &&
|
|
42
|
+
(collection as Array<Array<T>>).every(Array.isArray)
|
|
43
|
+
);
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
export function removeUndefined(arr) {
|
package/src/victory-util/data.ts
CHANGED
|
@@ -117,16 +117,15 @@ function addEventKeys(props, data) {
|
|
|
117
117
|
} else if (hasEventKeyAccessor) {
|
|
118
118
|
const eventKey = eventKeyAccessor(datum, index);
|
|
119
119
|
return eventKey !== undefined ? assign({ eventKey }, datum) : datum;
|
|
120
|
-
} else {
|
|
121
|
-
return datum;
|
|
122
120
|
}
|
|
121
|
+
return datum;
|
|
123
122
|
});
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
// Exported Functions
|
|
127
126
|
|
|
128
127
|
// This method will remove data points that fall outside of the desired domain (non-continuous charts only)
|
|
129
|
-
export function formatDataFromDomain(dataset, domain, defaultBaseline) {
|
|
128
|
+
export function formatDataFromDomain(dataset, domain, defaultBaseline?) {
|
|
130
129
|
const exists = (val) => val !== undefined;
|
|
131
130
|
|
|
132
131
|
const minDomainX = Collection.getMinValue(domain.x);
|
|
@@ -74,7 +74,7 @@ function getExtremeFromData(dataset, axis, type = "min") {
|
|
|
74
74
|
return containsDate ? new Date(result) : result;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
//eslint-disable-next-line max-statements
|
|
77
|
+
// eslint-disable-next-line max-statements
|
|
78
78
|
function padDomain(domain, props, axis) {
|
|
79
79
|
if (!props.domainPadding) {
|
|
80
80
|
return domain;
|
|
@@ -311,15 +311,15 @@ export function getDomainFromMinMax(min, max) {
|
|
|
311
311
|
const verySmallDate = 1;
|
|
312
312
|
const minVal =
|
|
313
313
|
val instanceof Date
|
|
314
|
-
? new Date(
|
|
315
|
-
:
|
|
314
|
+
? new Date(Number(val) - verySmallDate)
|
|
315
|
+
: Number(val) - verySmallNumber;
|
|
316
316
|
const maxVal =
|
|
317
317
|
val instanceof Date
|
|
318
|
-
? new Date(
|
|
319
|
-
:
|
|
318
|
+
? new Date(Number(val) + verySmallDate)
|
|
319
|
+
: Number(val) + verySmallNumber;
|
|
320
320
|
return val === 0 ? [0, maxVal] : [minVal, maxVal];
|
|
321
321
|
};
|
|
322
|
-
return
|
|
322
|
+
return Number(min) === Number(max) ? getSinglePointDomain(max) : [min, max];
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
/**
|
|
@@ -20,7 +20,8 @@ export interface ComponentEvent {
|
|
|
20
20
|
eventKey?: ComponentEventKey | ComponentEventKey[];
|
|
21
21
|
eventHandlers: ComponentEventHandlers;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
// Normally we'd use Template Literal Types, but we're avoiding it to maximize TS compatibility with TS < 4.1
|
|
24
|
+
export type ComponentEventName = string; // `on${Capitalize<string>}`;
|
|
24
25
|
export interface ComponentEventHandlers {
|
|
25
26
|
[k: ComponentEventName]: ComponentEventHandler;
|
|
26
27
|
}
|
|
@@ -447,9 +448,8 @@ export function getExternalMutation(
|
|
|
447
448
|
// coerce arrays to strings before matching
|
|
448
449
|
const stringArray = mutation[type].map((m) => `${m}`);
|
|
449
450
|
return includes(stringArray, identifier[type]);
|
|
450
|
-
} else {
|
|
451
|
-
return false;
|
|
452
451
|
}
|
|
452
|
+
return false;
|
|
453
453
|
};
|
|
454
454
|
|
|
455
455
|
mutations = Array.isArray(mutations) ? mutations : [mutations];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-use-before-define */
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { defaults, isFunction, property, pick, assign, keys } from "lodash";
|
|
4
|
+
import { CallbackArgs, ValueOrCallback } from "../types/callbacks";
|
|
4
5
|
|
|
5
6
|
// Private Functions
|
|
6
7
|
|
|
@@ -126,7 +127,10 @@ export function getStyles(style, defaultStyles) {
|
|
|
126
127
|
};
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
export function evaluateProp(
|
|
130
|
+
export function evaluateProp<TValue>(
|
|
131
|
+
prop: ValueOrCallback<TValue>,
|
|
132
|
+
props: CallbackArgs,
|
|
133
|
+
): TValue {
|
|
130
134
|
return isFunction(prop) ? prop(props) : prop;
|
|
131
135
|
}
|
|
132
136
|
|
|
@@ -4,18 +4,33 @@ import { defaults, some } from "lodash";
|
|
|
4
4
|
import * as Collection from "../collection";
|
|
5
5
|
import * as Transitions from "../transitions";
|
|
6
6
|
|
|
7
|
-
const INITIAL_STATE = {
|
|
7
|
+
const INITIAL_STATE: AnimationState = {
|
|
8
8
|
nodesShouldLoad: false,
|
|
9
9
|
nodesDoneLoad: false,
|
|
10
10
|
animating: true,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
type AnyObject = Record<string, any>;
|
|
14
|
+
|
|
15
|
+
export type AnimationState = {
|
|
16
|
+
nodesShouldLoad?: boolean;
|
|
17
|
+
nodesDoneLoad?: boolean;
|
|
18
|
+
animating?: boolean;
|
|
19
|
+
childrenTransitions?: any[];
|
|
20
|
+
nodesWillExit?: boolean;
|
|
21
|
+
nodesWillEnter?: boolean;
|
|
22
|
+
nodesShouldEnter?: boolean;
|
|
23
|
+
oldProps?: AnyObject;
|
|
24
|
+
nextProps?: AnyObject;
|
|
25
|
+
continuous?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
13
28
|
export const useAnimationState = (initialState = INITIAL_STATE) => {
|
|
14
29
|
const [state, _setState] = React.useState(initialState);
|
|
15
30
|
|
|
16
31
|
// This allows us to use a state object and maintain the same API as this.setState
|
|
17
32
|
const setState = React.useCallback(
|
|
18
|
-
(newState) => {
|
|
33
|
+
(newState: AnimationState) => {
|
|
19
34
|
_setState((oldState) => ({ ...oldState, ...newState }));
|
|
20
35
|
},
|
|
21
36
|
[_setState],
|
|
@@ -23,8 +38,8 @@ export const useAnimationState = (initialState = INITIAL_STATE) => {
|
|
|
23
38
|
|
|
24
39
|
// This is a copy of Wrapper.getAnimationProps
|
|
25
40
|
const getAnimationProps = React.useCallback(
|
|
26
|
-
(props, child, index) => {
|
|
27
|
-
if (!props
|
|
41
|
+
(props: AnyObject | undefined, child, index) => {
|
|
42
|
+
if (!props?.animate) {
|
|
28
43
|
return child.props.animate;
|
|
29
44
|
}
|
|
30
45
|
const getFilteredState = () => {
|
|
@@ -59,8 +74,8 @@ export const useAnimationState = (initialState = INITIAL_STATE) => {
|
|
|
59
74
|
|
|
60
75
|
// This is a copy of Wrapper.setAnimationState
|
|
61
76
|
const setAnimationState = React.useCallback(
|
|
62
|
-
(props, nextProps) => {
|
|
63
|
-
if (!props
|
|
77
|
+
(props: AnyObject | undefined, nextProps) => {
|
|
78
|
+
if (!props?.animate) {
|
|
64
79
|
return;
|
|
65
80
|
}
|
|
66
81
|
if (props.animate.parentState) {
|
|
@@ -81,7 +96,7 @@ export const useAnimationState = (initialState = INITIAL_STATE) => {
|
|
|
81
96
|
|
|
82
97
|
const continuous =
|
|
83
98
|
!props.polar &&
|
|
84
|
-
some(oldChildren, (child) => {
|
|
99
|
+
some(oldChildren, (child: React.ReactElement) => {
|
|
85
100
|
return (
|
|
86
101
|
isContinuous(child) ||
|
|
87
102
|
(child.props.children && isContinuous(child.props.children))
|
|
@@ -101,7 +116,7 @@ export const useAnimationState = (initialState = INITIAL_STATE) => {
|
|
|
101
116
|
childrenTransitions: Collection.isArrayOfArrays(childrenTransitions)
|
|
102
117
|
? childrenTransitions[0]
|
|
103
118
|
: childrenTransitions,
|
|
104
|
-
oldProps: nodesWillExit ? props :
|
|
119
|
+
oldProps: nodesWillExit ? props : undefined,
|
|
105
120
|
nextProps,
|
|
106
121
|
continuous,
|
|
107
122
|
});
|
|
@@ -111,7 +126,7 @@ export const useAnimationState = (initialState = INITIAL_STATE) => {
|
|
|
111
126
|
);
|
|
112
127
|
|
|
113
128
|
const getProps = React.useCallback(
|
|
114
|
-
(initialProps) => {
|
|
129
|
+
(initialProps: AnyObject) => {
|
|
115
130
|
return state && state.nodesWillExit
|
|
116
131
|
? state.oldProps || initialProps
|
|
117
132
|
: initialProps;
|
|
@@ -12,9 +12,8 @@ function getVerticalAnchor(props, datum) {
|
|
|
12
12
|
return datum.verticalAnchor || labelStyle.verticalAnchor;
|
|
13
13
|
} else if (!props.horizontal) {
|
|
14
14
|
return sign >= 0 ? "end" : "start";
|
|
15
|
-
} else {
|
|
16
|
-
return "middle";
|
|
17
15
|
}
|
|
16
|
+
return "middle";
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
function getTextAnchor(props, datum) {
|
|
@@ -26,9 +25,8 @@ function getTextAnchor(props, datum) {
|
|
|
26
25
|
return datum.verticalAnchor || labelStyle.verticalAnchor;
|
|
27
26
|
} else if (!horizontal) {
|
|
28
27
|
return "middle";
|
|
29
|
-
} else {
|
|
30
|
-
return sign >= 0 ? "start" : "end";
|
|
31
28
|
}
|
|
29
|
+
return sign >= 0 ? "start" : "end";
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
function getAngle(props, datum) {
|
|
@@ -66,13 +64,12 @@ function getPosition(props, datum) {
|
|
|
66
64
|
const { x, y } = Helpers.scalePoint(props, datum);
|
|
67
65
|
if (!polar) {
|
|
68
66
|
return { x, y };
|
|
69
|
-
} else {
|
|
70
|
-
const polarPadding = getPolarPadding(props, datum);
|
|
71
|
-
return {
|
|
72
|
-
x: x + polarPadding.x,
|
|
73
|
-
y: y + polarPadding.y,
|
|
74
|
-
};
|
|
75
67
|
}
|
|
68
|
+
const polarPadding = getPolarPadding(props, datum);
|
|
69
|
+
return {
|
|
70
|
+
x: x + polarPadding.x,
|
|
71
|
+
y: y + polarPadding.y,
|
|
72
|
+
};
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
function getPolarPadding(props, datum) {
|
|
@@ -106,9 +103,8 @@ function getPolarOrientation(degrees) {
|
|
|
106
103
|
// eslint-disable-next-line no-magic-numbers
|
|
107
104
|
} else if (degrees > 135 && degrees < 225) {
|
|
108
105
|
return "left";
|
|
109
|
-
} else {
|
|
110
|
-
return "bottom";
|
|
111
106
|
}
|
|
107
|
+
return "bottom";
|
|
112
108
|
}
|
|
113
109
|
|
|
114
110
|
// Exported Functions
|
|
@@ -50,9 +50,8 @@ export function getParentSVG(
|
|
|
50
50
|
const getParent = (target) => {
|
|
51
51
|
if (target.nodeName === "svg") {
|
|
52
52
|
return target;
|
|
53
|
-
} else {
|
|
54
|
-
return target.parentNode ? getParent(target.parentNode) : target;
|
|
55
53
|
}
|
|
54
|
+
return target.parentNode ? getParent(target.parentNode) : target;
|
|
56
55
|
};
|
|
57
56
|
return getParent(evt.target);
|
|
58
57
|
}
|
|
@@ -83,7 +82,7 @@ export function getSVGEventCoordinates(
|
|
|
83
82
|
export function getDomainCoordinates(
|
|
84
83
|
props: Pick<VictoryCommonProps, "scale" | "horizontal">,
|
|
85
84
|
domain?: DomainPropType,
|
|
86
|
-
)
|
|
85
|
+
) {
|
|
87
86
|
const { horizontal } = props;
|
|
88
87
|
const scale = props.scale as ScaleXYPropType;
|
|
89
88
|
// FIXME: add support for DomainTuple: [number, number]
|
|
@@ -114,17 +113,16 @@ export function getDataCoordinates(
|
|
|
114
113
|
x: horizontal ? scale.x.invert(y) : scale.x.invert(x),
|
|
115
114
|
y: horizontal ? scale.y.invert(x) : scale.y.invert(y),
|
|
116
115
|
};
|
|
117
|
-
} else {
|
|
118
|
-
const origin = props.origin || { x: 0, y: 0 };
|
|
119
|
-
const baseX = x - origin.x;
|
|
120
|
-
const baseY = y - origin.y;
|
|
121
|
-
const radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
|
|
122
|
-
const angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
|
|
123
|
-
return {
|
|
124
|
-
x: scale.x.invert(angle),
|
|
125
|
-
y: scale.y.invert(radius),
|
|
126
|
-
};
|
|
127
116
|
}
|
|
117
|
+
const origin = props.origin || { x: 0, y: 0 };
|
|
118
|
+
const baseX = x - origin.x;
|
|
119
|
+
const baseY = y - origin.y;
|
|
120
|
+
const radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
|
|
121
|
+
const angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
|
|
122
|
+
return {
|
|
123
|
+
x: scale.x.invert(angle),
|
|
124
|
+
y: scale.y.invert(radius),
|
|
125
|
+
};
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
export function getBounds(props: ComputedCommonProps): SVGCoordinateBounds {
|
|
@@ -155,4 +153,5 @@ type ComputedCommonProps = {
|
|
|
155
153
|
x2: number;
|
|
156
154
|
y1: number;
|
|
157
155
|
y2: number;
|
|
156
|
+
horizontal?: boolean;
|
|
158
157
|
};
|
|
@@ -14,19 +14,18 @@ export const toTransformString = function (obj, ...more) {
|
|
|
14
14
|
return [memo, toTransformString(currentObj)].join(" ");
|
|
15
15
|
}, toTransformString(obj))
|
|
16
16
|
.trim();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
17
|
+
}
|
|
18
|
+
if (obj === undefined || obj === null || typeof obj === "string") {
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
const transforms = [] as string[];
|
|
22
|
+
for (const key in obj) {
|
|
23
|
+
if (obj.hasOwnProperty(key)) {
|
|
24
|
+
const value = obj[key];
|
|
25
|
+
transforms.push(`${key}(${value})`);
|
|
27
26
|
}
|
|
28
|
-
return transforms.join(" ").trim();
|
|
29
27
|
}
|
|
28
|
+
return transforms.join(" ").trim();
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// http://www.pearsonified.com/2012/01/characters-per-line.php
|
|
2
|
-
/*eslint-disable no-magic-numbers */
|
|
2
|
+
/* eslint-disable no-magic-numbers */
|
|
3
3
|
import { assign, defaults } from "lodash";
|
|
4
4
|
|
|
5
5
|
// Based on measuring specific character widths
|
|
6
6
|
// as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf
|
|
7
|
-
//prettier-ignore
|
|
7
|
+
// prettier-ignore
|
|
8
8
|
const fonts = {
|
|
9
9
|
"American Typewriter": {
|
|
10
10
|
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],
|
|
@@ -112,7 +112,7 @@ const fonts = {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
//https://developer.mozilla.org/en/docs/Web/CSS/length
|
|
115
|
+
// https://developer.mozilla.org/en/docs/Web/CSS/length
|
|
116
116
|
// Absolute sizes in pixels for obsolete measurement units.
|
|
117
117
|
const absoluteMeasurementUnitsToPixels = {
|
|
118
118
|
mm: 3.8,
|
|
@@ -342,9 +342,8 @@ export function getTransitionPropsFactory(props, state, setState) {
|
|
|
342
342
|
return animationDuration !== undefined
|
|
343
343
|
? animationDuration
|
|
344
344
|
: defaultTransitions[type] && defaultTransitions[type].duration;
|
|
345
|
-
} else {
|
|
346
|
-
return {};
|
|
347
345
|
}
|
|
346
|
+
return {};
|
|
348
347
|
};
|
|
349
348
|
|
|
350
349
|
// eslint-disable-next-line max-statements, complexity, max-len
|
|
@@ -11,7 +11,8 @@ const USER_PROPS_SAFELIST = {
|
|
|
11
11
|
exactMatch: [] as string[],
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// Normally we'd use Template Literal Types, but we're avoiding it to maximize TS compatibility with TS < 4.1
|
|
15
|
+
type SafeAttribute = string; // `data-${string}` | `aria-${string}`;
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* doesPropStartWith: Function that takes a prop's key and runs it against all
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
VictoryProviderProps,
|
|
5
|
-
VictoryContainer,
|
|
6
|
-
} from "victory-core";
|
|
2
|
+
import { VictoryProvider, VictoryProviderProps } from "../victory-state";
|
|
3
|
+
import { VictoryContainer } from "../victory-container/victory-container";
|
|
7
4
|
import { VictoryCommonProps } from "./common-props";
|
|
8
5
|
|
|
9
6
|
const defaultProviderProps = {
|
|
@@ -228,9 +228,8 @@ export function getDomainFromChildren(props, axis, childComponents) {
|
|
|
228
228
|
return null;
|
|
229
229
|
} else if (child.type && isFunction(child.type.getDomain)) {
|
|
230
230
|
return child.props && child.type.getDomain(sharedProps, axis);
|
|
231
|
-
} else {
|
|
232
|
-
return Domain.getDomain(sharedProps, axis);
|
|
233
231
|
}
|
|
232
|
+
return Domain.getDomain(sharedProps, axis);
|
|
234
233
|
};
|
|
235
234
|
|
|
236
235
|
const childDomains = Helpers.reduceChildren(children, iteratee, props);
|
|
@@ -360,15 +359,14 @@ export function getStringsFromCategories(childComponents, axis) {
|
|
|
360
359
|
const childProps = child.props || {};
|
|
361
360
|
if (!Domain.isDomainComponent(child) || !childProps.categories) {
|
|
362
361
|
return null;
|
|
363
|
-
} else {
|
|
364
|
-
const categories =
|
|
365
|
-
childProps.categories && !Array.isArray(childProps.categories)
|
|
366
|
-
? childProps.categories[axis]
|
|
367
|
-
: childProps.props.categories;
|
|
368
|
-
const categoryStrings =
|
|
369
|
-
categories && categories.filter((val) => typeof val === "string");
|
|
370
|
-
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
|
|
371
362
|
}
|
|
363
|
+
const categories =
|
|
364
|
+
childProps.categories && !Array.isArray(childProps.categories)
|
|
365
|
+
? childProps.categories[axis]
|
|
366
|
+
: childProps.props.categories;
|
|
367
|
+
const categoryStrings =
|
|
368
|
+
categories && categories.filter((val) => typeof val === "string");
|
|
369
|
+
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
|
|
372
370
|
};
|
|
373
371
|
return Helpers.reduceChildren(childComponents.slice(0), iteratee);
|
|
374
372
|
}
|
|
@@ -451,7 +449,7 @@ export function getStringsFromChildren(props, childComponents) {
|
|
|
451
449
|
};
|
|
452
450
|
}
|
|
453
451
|
|
|
454
|
-
export function getCategories(props, childComponents, allStrings) {
|
|
452
|
+
export function getCategories(props, childComponents, allStrings?) {
|
|
455
453
|
const xPropCategories =
|
|
456
454
|
props.categories && !Array.isArray(props.categories)
|
|
457
455
|
? props.categories.x
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-dom.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @license React
|
|
13
|
-
* scheduler.production.min.js
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
16
|
-
*
|
|
17
|
-
* This source code is licensed under the MIT license found in the
|
|
18
|
-
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*/
|