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
package/es/types/callbacks.d.ts
CHANGED
|
@@ -23,15 +23,15 @@ export interface CallbackArgs {
|
|
|
23
23
|
ticks?: any;
|
|
24
24
|
text?: any;
|
|
25
25
|
}
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
26
|
+
export type VictoryStringOrNumberCallback = (args: CallbackArgs) => string | number;
|
|
27
|
+
export type VictoryStringCallback = (args: CallbackArgs) => string;
|
|
28
|
+
export type StringOrNumberOrCallback = string | number | VictoryStringOrNumberCallback;
|
|
29
|
+
export type StringOrCallback = string | VictoryStringCallback;
|
|
30
|
+
export type SliceNumberOrCallback<T, P extends string | number | symbol = never> = number | ((props: Omit<T, P>) => number);
|
|
31
|
+
export type VictoryNumberCallback = (args: CallbackArgs) => number;
|
|
32
|
+
export type VictoryPaddingCallback = (args: CallbackArgs) => number | BlockProps;
|
|
33
|
+
export type VictoryOrientationCallback = (args: CallbackArgs) => OrientationTypes;
|
|
34
|
+
export type NumberOrCallback = number | VictoryNumberCallback;
|
|
35
|
+
export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback;
|
|
36
|
+
export type OrientationOrCallback = OrientationTypes | VictoryOrientationCallback;
|
|
37
37
|
//# sourceMappingURL=callbacks.d.ts.map
|
package/es/types/prop-types.d.ts
CHANGED
|
@@ -2,25 +2,25 @@ import * as React from "react";
|
|
|
2
2
|
import { ScaleLinear, ScaleLogarithmic, ScalePower, ScaleTime } from "victory-vendor/d3-scale";
|
|
3
3
|
import { AnimationEasing, AnimationStyle } from "../victory-animation/victory-animation";
|
|
4
4
|
import { CallbackArgs, StringOrNumberOrCallback } from "./callbacks";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
5
|
+
export type AxisType = "x" | "y";
|
|
6
|
+
export type DatumValue = number | string | Date | null | undefined;
|
|
7
|
+
export type Datum = any;
|
|
8
|
+
export type ForAxes<T> = T | {
|
|
9
9
|
x?: T;
|
|
10
10
|
y?: T;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
12
|
+
export type ID = number | string;
|
|
13
|
+
export type ValueOrAccessor<ValueType, PropsType = CallbackArgs> = ValueType | ((props: PropsType) => ValueType);
|
|
14
|
+
export type Tuple<T> = [T, T];
|
|
15
|
+
export type ValueOrAxes<T> = T | ForAxes<T>;
|
|
16
|
+
export type DomainPaddingPropType = ValueOrAxes<PaddingType>;
|
|
17
|
+
export type DomainPropType = ValueOrAxes<DomainTuple>;
|
|
18
|
+
export type DomainValue = number | Date;
|
|
19
|
+
export type DomainTuple = Tuple<number> | Tuple<Date>;
|
|
20
|
+
export type PaddingType = number | Tuple<number>;
|
|
21
|
+
export type RangePropType = ValueOrAxes<RangeTuple>;
|
|
22
|
+
export type RangeTuple = number[];
|
|
23
|
+
export type StringOrNumberOrList = string | number | (string | number)[];
|
|
24
24
|
export interface Padding {
|
|
25
25
|
top: number;
|
|
26
26
|
bottom: number;
|
|
@@ -69,7 +69,7 @@ export interface EventPropTypeInterface<TTarget, TEventKey> {
|
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
type NumberValue = number | {
|
|
73
73
|
valueOf(): number;
|
|
74
74
|
};
|
|
75
75
|
/**
|
|
@@ -91,14 +91,14 @@ export interface D3Scale<TRange = any> {
|
|
|
91
91
|
copy: () => this;
|
|
92
92
|
invert: (value: number) => number;
|
|
93
93
|
}
|
|
94
|
-
export
|
|
95
|
-
export
|
|
96
|
-
export
|
|
97
|
-
export
|
|
94
|
+
export type D3ScaleFn<TRange = any, TOutput = any> = () => ScaleLinear<TRange, TOutput, unknown> | ScaleLogarithmic<TRange, TOutput, unknown> | ScaleTime<TRange, TOutput, unknown> | ScalePower<TRange, TOutput, unknown>;
|
|
95
|
+
export type ScaleName = "linear" | "time" | "log" | "sqrt";
|
|
96
|
+
export type ScalePropType = ScaleName;
|
|
97
|
+
export type ScaleXYPropType = {
|
|
98
98
|
x: D3Scale;
|
|
99
99
|
y: D3Scale;
|
|
100
100
|
};
|
|
101
|
-
export
|
|
101
|
+
export type CategoryPropType = string[] | {
|
|
102
102
|
x: string[];
|
|
103
103
|
} | {
|
|
104
104
|
y: string[];
|
|
@@ -106,10 +106,10 @@ export declare type CategoryPropType = string[] | {
|
|
|
106
106
|
x: string[];
|
|
107
107
|
y: string[];
|
|
108
108
|
};
|
|
109
|
-
export
|
|
110
|
-
export
|
|
111
|
-
export
|
|
112
|
-
export
|
|
109
|
+
export type DataGetterPropType = ValueOrAccessor<string | string[] | number | number[], any>;
|
|
110
|
+
export type InterpolationPropType = "basis" | "basisClosed" | "basisOpen" | "bundle" | "cardinal" | "cardinalClosed" | "cardinalOpen" | "catmullRom" | "catmullRomClosed" | "catmullRomOpen" | "linear" | "linearClosed" | "monotoneX" | "monotoneY" | "natural" | "radial" | "step" | "stepAfter" | "stepBefore";
|
|
111
|
+
export type ColorScalePropType = "grayscale" | "qualitative" | "heatmap" | "warm" | "cool" | "red" | "green" | "blue" | string[];
|
|
112
|
+
export type SortOrderPropType = "ascending" | "descending";
|
|
113
113
|
export interface VictoryLabelableProps {
|
|
114
114
|
labelComponent?: React.ReactElement;
|
|
115
115
|
}
|
|
@@ -123,10 +123,10 @@ export interface VictorySingleLabelableProps extends VictoryLabelableProps {
|
|
|
123
123
|
(data: any): string | number | null;
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
export
|
|
126
|
+
export type CoordinatesPropType = {
|
|
127
127
|
x: number;
|
|
128
128
|
y: number;
|
|
129
129
|
};
|
|
130
|
-
export
|
|
130
|
+
export type VictoryEventHandler = (event?: any, targetProps?: any, eventKey?: any, context?: any) => void;
|
|
131
131
|
export {};
|
|
132
132
|
//# sourceMappingURL=prop-types.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import isPlainObject from "lodash/isPlainObject";
|
|
2
|
+
import orderBy from "lodash/orderBy";
|
|
3
3
|
import { interpolate } from "victory-vendor/d3-interpolate";
|
|
4
4
|
export const isInterpolatable = function (obj) {
|
|
5
5
|
// d3 turns null into 0 and undefined into NaN, which we don't want.
|
|
@@ -22,7 +22,7 @@ export const isInterpolatable = function (obj) {
|
|
|
22
22
|
return false;
|
|
23
23
|
case "object":
|
|
24
24
|
// Don't try to interpolate class instances (except Date or Array).
|
|
25
|
-
return obj instanceof Date || Array.isArray(obj) ||
|
|
25
|
+
return obj instanceof Date || Array.isArray(obj) || isPlainObject(obj);
|
|
26
26
|
case "function":
|
|
27
27
|
// Careful! There may be extra properties on function objects that the
|
|
28
28
|
// component expects to access - for instance, it may be a `d3.scale()`
|
|
@@ -82,7 +82,7 @@ export const interpolateFunction = function (a, b) {
|
|
|
82
82
|
return b;
|
|
83
83
|
}
|
|
84
84
|
return function () {
|
|
85
|
-
/* eslint-disable
|
|
85
|
+
/* eslint-disable prefer-rest-params */
|
|
86
86
|
const aval = typeof a === "function" ? a.apply(this, arguments) : a;
|
|
87
87
|
const bval = typeof b === "function" ? b.apply(this, arguments) : b;
|
|
88
88
|
return interpolate(aval, bval)(t);
|
|
@@ -108,7 +108,7 @@ export const interpolateObject = function (startValue, endValue) {
|
|
|
108
108
|
if (typeof x === "function" || typeof y === "function") {
|
|
109
109
|
return interpolateFunction(x, y);
|
|
110
110
|
}
|
|
111
|
-
if (typeof x === "object" &&
|
|
111
|
+
if (typeof x === "object" && isPlainObject(x) || typeof y === "object" && isPlainObject(y)) {
|
|
112
112
|
return interpolateObject(x, y);
|
|
113
113
|
}
|
|
114
114
|
return interpolate(x, y);
|
|
@@ -117,7 +117,7 @@ export const interpolateObject = function (startValue, endValue) {
|
|
|
117
117
|
// When the value is an array, attempt to sort by "key" so that animating nodes may be identified
|
|
118
118
|
// based on "key" instead of index
|
|
119
119
|
const keyData = val => {
|
|
120
|
-
return Array.isArray(val) ?
|
|
120
|
+
return Array.isArray(val) ? orderBy(val, "key") : val;
|
|
121
121
|
};
|
|
122
122
|
const i = {};
|
|
123
123
|
const c = {};
|
|
@@ -184,7 +184,7 @@ export const victoryInterpolator = function (a, b) {
|
|
|
184
184
|
if (typeof a === "function" || typeof b === "function") {
|
|
185
185
|
return interpolateFunction(a, b);
|
|
186
186
|
}
|
|
187
|
-
if (
|
|
187
|
+
if (isPlainObject(a) || isPlainObject(b)) {
|
|
188
188
|
// @ts-expect-error These generics are tough, but they work :)
|
|
189
189
|
return interpolateObject(a, b);
|
|
190
190
|
}
|
|
@@ -3,14 +3,14 @@ import TimerContext from "../victory-util/timer-context";
|
|
|
3
3
|
/**
|
|
4
4
|
* Single animation object to interpolate
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type AnimationStyle = {
|
|
7
7
|
[key: string]: string | number;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* Animation styles to interpolate
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
export
|
|
12
|
+
export type AnimationData = AnimationStyle | AnimationStyle[];
|
|
13
|
+
export type AnimationEasing = "back" | "backIn" | "backOut" | "backInOut" | "bounce" | "bounceIn" | "bounceOut" | "bounceInOut" | "circle" | "circleIn" | "circleOut" | "circleInOut" | "linear" | "linearIn" | "linearOut" | "linearInOut" | "cubic" | "cubicIn" | "cubicOut" | "cubicInOut" | "elastic" | "elasticIn" | "elasticOut" | "elasticInOut" | "exp" | "expIn" | "expOut" | "expInOut" | "poly" | "polyIn" | "polyOut" | "polyInOut" | "quad" | "quadIn" | "quadOut" | "quadInOut" | "sin" | "sinIn" | "sinOut" | "sinInOut";
|
|
14
14
|
export interface VictoryAnimationProps {
|
|
15
15
|
children: (style: AnimationStyle, info: AnimationInfo) => React.ReactElement;
|
|
16
16
|
duration?: number;
|
|
@@ -20,7 +20,10 @@ export interface VictoryClipContainerProps {
|
|
|
20
20
|
translateX?: number;
|
|
21
21
|
translateY?: number;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
interface VictoryClipContainerState {
|
|
24
|
+
clipId?: number | string;
|
|
25
|
+
}
|
|
26
|
+
export declare class VictoryClipContainer extends React.Component<VictoryClipContainerProps, VictoryClipContainerState> {
|
|
24
27
|
static displayName: string;
|
|
25
28
|
static role: string;
|
|
26
29
|
static defaultProps: {
|
|
@@ -31,6 +34,7 @@ export declare class VictoryClipContainer extends React.Component<VictoryClipCon
|
|
|
31
34
|
};
|
|
32
35
|
clipId: VictoryClipContainerProps["clipId"];
|
|
33
36
|
constructor(props: VictoryClipContainerProps);
|
|
37
|
+
componentDidMount(): void;
|
|
34
38
|
calculateAttributes(props: any): {
|
|
35
39
|
x: number;
|
|
36
40
|
y: number;
|
|
@@ -44,4 +48,5 @@ export declare class VictoryClipContainer extends React.Component<VictoryClipCon
|
|
|
44
48
|
getTranslateValue(props: any, axis: any): any;
|
|
45
49
|
render(): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
46
50
|
}
|
|
51
|
+
export {};
|
|
47
52
|
//# sourceMappingURL=victory-clip-container.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import _uniqueId from "lodash/uniqueId";
|
|
2
|
-
import _isObject from "lodash/isObject";
|
|
3
|
-
import _defaults from "lodash/defaults";
|
|
4
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import uniqueId from "lodash/uniqueId";
|
|
5
4
|
import * as Helpers from "../victory-util/helpers";
|
|
6
5
|
import * as UserProps from "../victory-util/user-props";
|
|
7
6
|
import { ClipPath } from "../victory-primitives/clip-path";
|
|
@@ -18,7 +17,20 @@ export class VictoryClipContainer extends React.Component {
|
|
|
18
17
|
};
|
|
19
18
|
constructor(props) {
|
|
20
19
|
super(props);
|
|
21
|
-
this.
|
|
20
|
+
this.state = {
|
|
21
|
+
clipId: props?.clipId
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The clipId state is used to prevent hydration mismatches between the server and client (issue #2941).
|
|
26
|
+
// A better alternative would be to utilize React 18's useId hook instead of uniqueId, which would avoid needing state for this purpose.
|
|
27
|
+
// However, this component currently supports React 16 at the time of writing, so this workaround is necessary.
|
|
28
|
+
componentDidMount() {
|
|
29
|
+
if (!this.state.clipId) {
|
|
30
|
+
this.setState({
|
|
31
|
+
clipId: uniqueId("victory-clip-")
|
|
32
|
+
});
|
|
33
|
+
}
|
|
22
34
|
}
|
|
23
35
|
calculateAttributes(props) {
|
|
24
36
|
const {
|
|
@@ -29,9 +41,7 @@ export class VictoryClipContainer extends React.Component {
|
|
|
29
41
|
translateX = 0,
|
|
30
42
|
translateY = 0
|
|
31
43
|
} = props;
|
|
32
|
-
const clipPadding = Helpers.getPadding(
|
|
33
|
-
padding: props.clipPadding
|
|
34
|
-
});
|
|
44
|
+
const clipPadding = Helpers.getPadding(props.clipPadding);
|
|
35
45
|
const radius = props.radius || Helpers.getRadius(props);
|
|
36
46
|
return {
|
|
37
47
|
x: (polar ? origin.x : translateX) - clipPadding.left,
|
|
@@ -100,9 +110,7 @@ export class VictoryClipContainer extends React.Component {
|
|
|
100
110
|
bottom,
|
|
101
111
|
left,
|
|
102
112
|
right
|
|
103
|
-
} = Helpers.getPadding(
|
|
104
|
-
padding: props.clipPadding
|
|
105
|
-
});
|
|
113
|
+
} = Helpers.getPadding(props.clipPadding);
|
|
106
114
|
let child;
|
|
107
115
|
if (polar) {
|
|
108
116
|
const radius = props.radius || Helpers.getRadius(props);
|
|
@@ -157,12 +165,12 @@ export class VictoryClipContainer extends React.Component {
|
|
|
157
165
|
}
|
|
158
166
|
const translateX = this.getTranslateValue(this.props, "x");
|
|
159
167
|
const translateY = this.getTranslateValue(this.props, "y");
|
|
160
|
-
const clipProps =
|
|
168
|
+
const clipProps = defaults({}, this.props, {
|
|
161
169
|
clipHeight,
|
|
162
170
|
clipWidth,
|
|
163
171
|
translateX,
|
|
164
172
|
translateY
|
|
165
173
|
});
|
|
166
|
-
return this.renderClippedGroup(clipProps, this.clipId);
|
|
174
|
+
return this.renderClippedGroup(clipProps, this.state.clipId);
|
|
167
175
|
}
|
|
168
176
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _uniqueId from "lodash/uniqueId";
|
|
2
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
import React, { useRef } from "react";
|
|
3
|
+
import uniqueId from "lodash/uniqueId";
|
|
4
4
|
import { Portal } from "../victory-portal/portal";
|
|
5
5
|
import * as UserProps from "../victory-util/user-props";
|
|
6
6
|
import { mergeRefs } from "../victory-util";
|
|
@@ -28,7 +28,7 @@ export function useVictoryContainer(initialProps) {
|
|
|
28
28
|
const localContainerRef = useRef(null);
|
|
29
29
|
|
|
30
30
|
// Generated ID stored in ref because it needs to persist across renders
|
|
31
|
-
const generatedId = useRef(
|
|
31
|
+
const generatedId = useRef(uniqueId("victory-container-"));
|
|
32
32
|
const containerId = props.containerId ?? generatedId.current;
|
|
33
33
|
const getIdForElement = elName => `${containerId}-${elName}`;
|
|
34
34
|
const userProps = UserProps.getSafeUserProps(props);
|
|
@@ -103,9 +103,9 @@ export const VictoryContainer = initialProps => {
|
|
|
103
103
|
...style,
|
|
104
104
|
width: responsive ? style?.width : dimensions.width,
|
|
105
105
|
height: responsive ? style?.height : dimensions.height,
|
|
106
|
-
pointerEvents: "none",
|
|
107
|
-
touchAction: "none",
|
|
108
|
-
position: "relative"
|
|
106
|
+
pointerEvents: style?.pointerEvents ?? "none",
|
|
107
|
+
touchAction: style?.touchAction ?? "none",
|
|
108
|
+
position: style?.position ?? "relative"
|
|
109
109
|
},
|
|
110
110
|
"data-ouia-component-id": ouiaId,
|
|
111
111
|
"data-ouia-component-type": ouiaType,
|
|
@@ -2,12 +2,12 @@ import React from "react";
|
|
|
2
2
|
import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback } from "../types/callbacks";
|
|
3
3
|
import { ValueOrAccessor } from "../types/prop-types";
|
|
4
4
|
import { PaddingProps, VerticalAnchorType, VictoryLabelStyleObject } from "../victory-theme/victory-theme";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type TextAnchorType = "start" | "middle" | "end" | "inherit";
|
|
6
|
+
export type OriginType = {
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type LabelOrientationType = "parallel" | "perpendicular" | "vertical";
|
|
11
11
|
export interface VictoryLabelProps {
|
|
12
12
|
angle?: StringOrNumberOrCallback;
|
|
13
13
|
ariaLabel?: StringOrCallback;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _isEmpty from "lodash/isEmpty";
|
|
2
|
-
import _defaults from "lodash/defaults";
|
|
3
1
|
/* eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/
|
|
4
2
|
import React from "react";
|
|
3
|
+
import defaults from "lodash/defaults";
|
|
4
|
+
import isEmpty from "lodash/isEmpty";
|
|
5
5
|
import { VictoryPortal } from "../victory-portal/victory-portal";
|
|
6
6
|
import { Rect } from "../victory-primitives/rect";
|
|
7
7
|
import { Text } from "../victory-primitives/text";
|
|
@@ -52,7 +52,7 @@ const shouldUseMultilineBackgrounds = props => {
|
|
|
52
52
|
backgroundStyle,
|
|
53
53
|
backgroundPadding
|
|
54
54
|
} = props;
|
|
55
|
-
return Array.isArray(backgroundStyle) && !
|
|
55
|
+
return Array.isArray(backgroundStyle) && !isEmpty(backgroundStyle) || Array.isArray(backgroundPadding) && !isEmpty(backgroundPadding);
|
|
56
56
|
};
|
|
57
57
|
const getStyles = (style, props) => {
|
|
58
58
|
if (props.disableInlineStyles) {
|
|
@@ -63,37 +63,33 @@ const getStyles = (style, props) => {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
const getSingleStyle = s => {
|
|
66
|
-
const baseStyles = Helpers.evaluateStyle(s ?
|
|
66
|
+
const baseStyles = Helpers.evaluateStyle(s ? defaults({}, s, defaultStyles) : defaultStyles, props);
|
|
67
67
|
return Object.assign({}, baseStyles, {
|
|
68
68
|
fontSize: getFontSize(baseStyles)
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
|
-
return Array.isArray(style) && !
|
|
71
|
+
return Array.isArray(style) && !isEmpty(style) ? style.map(s => getSingleStyle(s)) : getSingleStyle(style);
|
|
72
72
|
};
|
|
73
73
|
const getBackgroundStyles = (style, props) => {
|
|
74
74
|
if (!style) {
|
|
75
75
|
return undefined;
|
|
76
76
|
}
|
|
77
|
-
return Array.isArray(style) && !
|
|
77
|
+
return Array.isArray(style) && !isEmpty(style) ? style.map(s => Helpers.evaluateStyle(s, props)) : Helpers.evaluateStyle(style, props);
|
|
78
78
|
};
|
|
79
79
|
const getBackgroundPadding = props => {
|
|
80
80
|
if (props.backgroundPadding && Array.isArray(props.backgroundPadding)) {
|
|
81
81
|
return props.backgroundPadding.map(backgroundPadding => {
|
|
82
82
|
const padding = Helpers.evaluateProp(backgroundPadding, props);
|
|
83
|
-
return Helpers.getPadding(
|
|
84
|
-
padding
|
|
85
|
-
});
|
|
83
|
+
return Helpers.getPadding(padding);
|
|
86
84
|
});
|
|
87
85
|
}
|
|
88
86
|
const padding = Helpers.evaluateProp(props.backgroundPadding, props);
|
|
89
|
-
return Helpers.getPadding(
|
|
90
|
-
padding
|
|
91
|
-
});
|
|
87
|
+
return Helpers.getPadding(padding);
|
|
92
88
|
};
|
|
93
89
|
const getLineHeight = props => {
|
|
94
90
|
const lineHeight = Helpers.evaluateProp(props.lineHeight, props);
|
|
95
91
|
if (Array.isArray(lineHeight)) {
|
|
96
|
-
return
|
|
92
|
+
return isEmpty(lineHeight) ? [1] : lineHeight;
|
|
97
93
|
}
|
|
98
94
|
return lineHeight;
|
|
99
95
|
};
|
|
@@ -213,7 +209,7 @@ const getFullBackground = (calculatedProps, tspanValues) => {
|
|
|
213
209
|
x: inline ? xCoordinate - backgroundPadding.left : xCoordinate + dx - backgroundPadding.left,
|
|
214
210
|
y: yCoordinate
|
|
215
211
|
};
|
|
216
|
-
return /*#__PURE__*/React.cloneElement(backgroundComponent,
|
|
212
|
+
return /*#__PURE__*/React.cloneElement(backgroundComponent, defaults({}, backgroundComponent.props, backgroundProps));
|
|
217
213
|
};
|
|
218
214
|
const getInlineXOffset = (calculatedProps, textElements, index) => {
|
|
219
215
|
const {
|
|
@@ -283,7 +279,7 @@ const getChildBackgrounds = (calculatedProps, tspanValues) => {
|
|
|
283
279
|
x: xCoord - padding.left,
|
|
284
280
|
y: yCoord
|
|
285
281
|
};
|
|
286
|
-
return /*#__PURE__*/React.cloneElement(backgroundComponent,
|
|
282
|
+
return /*#__PURE__*/React.cloneElement(backgroundComponent, defaults({}, backgroundComponent.props, backgroundProps));
|
|
287
283
|
});
|
|
288
284
|
};
|
|
289
285
|
const getBackgroundElement = (calculatedProps, tspanValues) => {
|
|
@@ -429,7 +425,7 @@ const defaultProps = {
|
|
|
429
425
|
lineHeight: 1
|
|
430
426
|
};
|
|
431
427
|
export const VictoryLabel = initialProps => {
|
|
432
|
-
const props = evaluateProps(
|
|
428
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
433
429
|
if (props.text === null || props.text === undefined) {
|
|
434
430
|
return null;
|
|
435
431
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _uniqueId from "lodash/uniqueId";
|
|
2
|
-
import _defaults from "lodash/defaults";
|
|
3
1
|
import React, { useState } from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import uniqueId from "lodash/uniqueId";
|
|
4
4
|
import * as Log from "../victory-util/log";
|
|
5
5
|
import * as Helpers from "../victory-util/helpers";
|
|
6
6
|
import { usePortalContext } from "./portal-context";
|
|
@@ -12,7 +12,7 @@ export const VictoryPortal = initialProps => {
|
|
|
12
12
|
...defaultProps,
|
|
13
13
|
...initialProps
|
|
14
14
|
};
|
|
15
|
-
const [id] = useState(
|
|
15
|
+
const [id] = useState(uniqueId());
|
|
16
16
|
const portalContext = usePortalContext();
|
|
17
17
|
if (!portalContext) {
|
|
18
18
|
const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
|
|
@@ -27,7 +27,7 @@ export const VictoryPortal = initialProps => {
|
|
|
27
27
|
groupComponent,
|
|
28
28
|
standalone: false
|
|
29
29
|
} : {};
|
|
30
|
-
const newProps =
|
|
30
|
+
const newProps = defaults(standardProps, childProps, Helpers.omit(props, ["children", "groupComponent"]), {
|
|
31
31
|
key: childProps.key ?? id
|
|
32
32
|
});
|
|
33
33
|
const child = children && /*#__PURE__*/React.cloneElement(children, newProps);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
1
|
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
|
|
3
2
|
import React from "react";
|
|
3
|
+
import defaults from "lodash/defaults";
|
|
4
4
|
import * as Helpers from "../victory-util/helpers";
|
|
5
5
|
import { Path } from "./path";
|
|
6
6
|
const getArcPath = props => {
|
|
@@ -59,7 +59,7 @@ const defaultProps = {
|
|
|
59
59
|
shapeRendering: "auto"
|
|
60
60
|
};
|
|
61
61
|
export const Arc = initialProps => {
|
|
62
|
-
const props = evaluateProps(
|
|
62
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
63
63
|
return /*#__PURE__*/React.cloneElement(props.pathComponent, {
|
|
64
64
|
...props.events,
|
|
65
65
|
"aria-label": props.ariaLabel,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
3
|
import * as Helpers from "../victory-util/helpers";
|
|
4
4
|
import { Rect } from "./rect";
|
|
5
5
|
import { Circle } from "./circle";
|
|
@@ -20,7 +20,7 @@ const defaultProps = {
|
|
|
20
20
|
shapeRendering: "auto"
|
|
21
21
|
};
|
|
22
22
|
export const Background = initialProps => {
|
|
23
|
-
const props = evaluateProps(
|
|
23
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
24
24
|
return props.polar ? /*#__PURE__*/React.cloneElement(props.circleComponent, {
|
|
25
25
|
...props.events,
|
|
26
26
|
style: props.style,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
3
|
import * as Helpers from "../victory-util/helpers";
|
|
4
4
|
import { Rect } from "./rect";
|
|
5
5
|
const evaluateProps = props => {
|
|
@@ -32,7 +32,7 @@ const defaultProps = {
|
|
|
32
32
|
shapeRendering: "auto"
|
|
33
33
|
};
|
|
34
34
|
export const Border = initialProps => {
|
|
35
|
-
const props = evaluateProps(
|
|
35
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
36
36
|
return /*#__PURE__*/React.cloneElement(props.rectComponent, {
|
|
37
37
|
...props.events,
|
|
38
38
|
"aria-label": props.ariaLabel,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
3
|
import * as Helpers from "../victory-util/helpers";
|
|
4
4
|
import { Line } from "./line";
|
|
5
5
|
const evaluateProps = props => {
|
|
@@ -32,7 +32,7 @@ const defaultProps = {
|
|
|
32
32
|
shapeRendering: "auto"
|
|
33
33
|
};
|
|
34
34
|
export const LineSegment = initialProps => {
|
|
35
|
-
const props = evaluateProps(
|
|
35
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
36
36
|
return /*#__PURE__*/React.cloneElement(props.lineComponent, {
|
|
37
37
|
...props.events,
|
|
38
38
|
"aria-label": props.ariaLabel,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
3
|
import * as Helpers from "../victory-util/helpers";
|
|
4
4
|
import * as pathHelpers from "../victory-util/point-path-helpers";
|
|
5
5
|
import * as UserProps from "../victory-util/user-props";
|
|
@@ -52,7 +52,7 @@ const defaultProps = {
|
|
|
52
52
|
shapeRendering: "auto"
|
|
53
53
|
};
|
|
54
54
|
export const Point = initialProps => {
|
|
55
|
-
const props = evaluateProps(
|
|
55
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
56
56
|
const userProps = UserProps.getSafeUserProps(props);
|
|
57
57
|
return /*#__PURE__*/React.cloneElement(props.pathComponent, {
|
|
58
58
|
...props.events,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VictoryCommonPrimitiveProps } from "../victory-util/common-props";
|
|
2
|
-
export
|
|
2
|
+
export type ScatterSymbolType = "circle" | "cross" | "diamond" | "plus" | "minus" | "square" | "star" | "triangleDown" | "triangleUp";
|
|
3
3
|
export interface VictoryPrimitiveShapeProps extends VictoryCommonPrimitiveProps {
|
|
4
4
|
desc?: string;
|
|
5
5
|
rx?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
3
|
import * as Helpers from "../victory-util/helpers";
|
|
4
4
|
import { Line } from "./line";
|
|
5
5
|
const evaluateProps = props => {
|
|
@@ -31,7 +31,7 @@ const defaultProps = {
|
|
|
31
31
|
shapeRendering: "auto"
|
|
32
32
|
};
|
|
33
33
|
export const Whisker = initialProps => {
|
|
34
|
-
const props = evaluateProps(
|
|
34
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
35
35
|
const {
|
|
36
36
|
ariaLabel,
|
|
37
37
|
groupComponent,
|
|
@@ -2,22 +2,22 @@ import * as React from "react";
|
|
|
2
2
|
import { VictoryCommonThemeProps, VictoryDatableProps } from "../victory-util/common-props";
|
|
3
3
|
import { NumberOrCallback, OrientationOrCallback, PaddingOrCallback, StringOrNumberOrCallback } from "../types/callbacks";
|
|
4
4
|
import { DomainPropType } from "../types/prop-types";
|
|
5
|
-
export
|
|
5
|
+
export type BlockProps = {
|
|
6
6
|
top?: number;
|
|
7
7
|
bottom?: number;
|
|
8
8
|
left?: number;
|
|
9
9
|
right?: number;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
11
|
+
export type PaddingProps = number | BlockProps;
|
|
12
|
+
export type OrientationTypes = "top" | "bottom" | "left" | "right";
|
|
13
|
+
export type VictoryStyleObject = {
|
|
14
14
|
[K in keyof React.CSSProperties]: StringOrNumberOrCallback;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type LabelProps = React.CSSProperties & {
|
|
17
17
|
angle?: number;
|
|
18
18
|
verticalAnchor?: VerticalAnchorType;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type VictoryLabelStyleObject = {
|
|
21
21
|
[K in keyof LabelProps]: StringOrNumberOrCallback;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -29,10 +29,10 @@ export interface VictoryStyleInterface {
|
|
|
29
29
|
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
|
|
30
30
|
border?: VictoryStyleObject;
|
|
31
31
|
}
|
|
32
|
-
export
|
|
32
|
+
export type TickProps = React.CSSProperties & {
|
|
33
33
|
size?: number;
|
|
34
34
|
};
|
|
35
|
-
export
|
|
35
|
+
export type VictoryTickStyleObject = {
|
|
36
36
|
[K in keyof TickProps]: StringOrNumberOrCallback;
|
|
37
37
|
};
|
|
38
38
|
export interface VictoryAxisCommonProps {
|
|
@@ -59,9 +59,9 @@ export interface VictoryAxisCommonProps {
|
|
|
59
59
|
};
|
|
60
60
|
tickValues?: any[];
|
|
61
61
|
}
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
export
|
|
62
|
+
export type VerticalAnchorType = "start" | "middle" | "end";
|
|
63
|
+
type VictoryThemePaletteKeys = "blue" | "pink" | "teal" | "purple" | "green" | "orange" | "cyan" | "red" | "yellow";
|
|
64
|
+
export type VictoryThemePalette = {
|
|
65
65
|
[key in VictoryThemePaletteKeys]?: string;
|
|
66
66
|
};
|
|
67
67
|
export interface VictoryThemeDefinition {
|